[QUOTE=NotoriousSpy;34062958]What's the best way to separate playable characters from NPC's?[/QUOTE]
In what context? How are Characters defined?
[QUOTE=marcin1337;34082296]Hey guys
How would I read an entire file to a string in c++.[/QUOTE]
[cpp]std::ifstream t("file.txt");
std::string str((std::istreambuf_iterator<char>(t)),
std::istreambuf_iterator<char>());[/cpp]
or
[cpp]std::ifstream t("file.txt");
std::string str;
t.seekg(0, std::ios::end);
str.reserve(t.tellg());
t.seekg(0, std::ios::beg);
str.assign((std::istreambuf_iterator<char>(t)),
std::istreambuf_iterator<char>());[/cpp]
The first one allocates memory as it goes, relying on string's dynamic reallocation. The second one allocates all the memory up front.
[url]http://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring/2602060#2602060[/url]
[QUOTE=ThePuska;34082504]Alternatively you could fseek the EoF, ftell the position of the fcursor, frewind back to the fstart and fread as many characters as you ftold.
I only know C though.[/QUOTE]
I found reading this post strangely humorous...
How I debug a message to Visual Studio's output with stuff (=%s, %f..)?
This prints it to command line. I don't use it so I can't see it.
printf ("%s \n", "A string");
This prints it to right place, but it doesn't allow stuff like %s
DebugMessage("debug! \n");
[QUOTE=CrashLemon;34070307]So I'm trying to learn some Android shenanigans but I'm wondering, how would I go about showing the Java console or something so I can see my System.out.print()?
Is there an easy way to debug with the Android Emulator in Eclipse?[/QUOTE]
[url]http://developer.android.com/reference/android/util/Log.html[/url]
[QUOTE=rute;34091790]How I debug a message to Visual Studio's output with stuff (=%s, %f..)?
This prints it to command line. I don't use it so I can't see it.
printf ("%s \n", "A string");
This prints it to right place, but it doesn't allow stuff like %s
DebugMessage("debug! \n");[/QUOTE]
[cpp]
void DbgPrint(const char *szFormat, ...)
{
va_list pList;
char szBuffer[4096];
va_start(pList, szFormat);
vsnprintf_s(szBuffer, 4096, szFormat, pList);
va_end(pList);
OutputDebugString(szBuffer);
}
[/cpp]
[QUOTE=ROBO_DONUT;34091818][url]http://developer.android.com/reference/android/util/Log.html[/url][/QUOTE]
Yeah I read about it, although I can't seem to find where's the LogCat... I've tried using the debug terminal but it says access denied.
In Eclipse, when you type in the name of an object and the ., you get a window with all the available methods...
That is, if you use the default Java methods.
How come, when I import anything from Slick to LWJGL, I can type (for example) app. and nothing shows up? am I missing something to import?
[img]http://gyazo.com/9459f52ebdb9fca335ee5b0ef3932cb2.png?1325979444[/img]
Ok so this is my G-bufer and sometimes flickering lines appear.
Pretty sure it's because of the depth buffer precision but what can I do about it?
Someone who've drawn voxel scenes maby know how to fix this?
Thanks.
If you're talking about that blue line there, then yes, it probably is a depth buffer issue.
First, try using GL_DEPTH_COMPONENT32 as the depth attachment on the FBO. Second, and ABSOLUTELY MOST IMPORTANT, make sure your near clip plane is no closer than it must be. Many rendering newbies make the near clip plane something like 0.000001 because they think 'the nearer, the better'. This is absolutely wrong. Depth buffer values are non-linear -- most of your depth precision is concentrated around the near clip plane, and if you make it too close you're throwing away a good chunk of the precision of your depth buffer.
Thank you for your reply.
I tried to set up the fbo in another way using GL_DEPTH_COMPONENT32, but the problem still remains.
Haha no the near clip is set to 1.0.
Any other suggestions?
The blue line is a face which shouldn't be visible at all, so the best option is probably to not draw hidden faces. How you go about this depends largely on how your voxel set is structured.
Exactly. I have some ideas but how would you do it?
[Obligatory double-submission]
[IMG]http://i.imgur.com/J6AaT.png[/IMG]
Hey guys, I recently just started working with the LOVE engine and I have a fairly above-average knowledge of Lua.
What confuses me(and quite a few other people) is how I would tweak the sample map tile generator to create biomes?
I've been trying to get my laptop's internal speaker to beep using python, however, winsound, as nearly every resource points me to, does not use the internal speakers as far as I can tell. (I can turn it off by muting my normal speakers)
Is it that my laptop doesn't have an internal speaker, or...?
So I'm working on a first person camera in XNA, and I seem to have run into an issue. The camera behaves VERY strangely, bouncing up and down with no input whatsoever. If I move my mouse very far very fast, It becomes "stuck", but if I move it the way it was going, it resumes without a hitch. What on earth am I doing wrong?
[csharp]
private void processMouse()
{
MouseState mouseState = Mouse.GetState();
currentMousePos.X = mouseState.X;
currentMousePos.Y = mouseState.Y;
mouseStart = currentMousePos;
//Mouse.SetPosition(device.Viewport.Width / 2, device.Viewport.Height / 2);
mouseStart = new Vector2(device.Viewport.Width / 2, device.Viewport.Height / 2);
//if (currentMousePos != new Vector2(device.Viewport.Width / 2, device.Viewport.Height / 2))
//{
moveDistance = mouseStart - mouseDifference;
mouseDifference = currentMousePos;
//rollSpeed -= (moveDistance.X / 20000);
//upDownRotSpeed -= (moveDistance.Y / 20000);
cameraYaw += mouseDifference.Y / 10000;
//}
}
private void updateCamera()
{
Vector3 cameraPosition = new Vector3(0, 0.1f, 0.6f);
//cameraPosition = Vector3.Transform(cameraPosition, Matrix.CreateFromQuaternion(cameraRotation));
cameraPosition = Vector3.Transform(cameraPosition, Matrix.CreateFromYawPitchRoll(cameraYaw, cameraPitch, cameraRoll));
//cameraPosition += shipPosition;
Vector3 cameraUp = new Vector3(0, 1, 0);
cameraUp = Vector3.Transform(cameraUp, Matrix.CreateFromQuaternion(cameraRotation));
viewMatrix = Matrix.CreateLookAt(cameraPosition, new Vector3(0, 0, 0), cameraUp);
Matrix worldMatrix = Matrix.CreateScale(1f, 1f, 1f) *
Matrix.CreateRotationY(MathHelper.Pi) * Matrix.CreateFromQuaternion(shipRotation) *
Matrix.CreateTranslation (cameraPosition);
projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
device.Viewport.AspectRatio, 0.2f, 500.0f);
}
[/csharp]
I'm no camera control guru but looking at your processMouse() function, that looks fine. I'd reckon it's another function you're using in the updateCamera() function where you're performing the math to change the camera shit.
[QUOTE=Protocol7;34107955]I'm no camera control guru but looking at your processMouse() function, that looks fine. I'd reckon it's another function you're using in the updateCamera() function where you're performing the math to change the camera shit.[/QUOTE]
God damn
You'd think rotations would be easier
[QUOTE=Mr. Smartass;34108007]God damn
You'd think rotations would be easier[/QUOTE]
[url=http://en.wikipedia.org/wiki/Quaternion]Quaternions[/url]
[QUOTE=robmaister12;34108701][url=http://en.wikipedia.org/wiki/Quaternion]Quaternions[/url][/QUOTE]
I took one look at those and pretty much said "fuck this", I've been using them as little as I can.
[QUOTE=Mr. Smartass;34108756]I took one look at those and pretty much said "fuck this", I've been using them as little as I can.[/QUOTE]
It's nice because it avoids gimbal locking and a bunch of other issues with euler angles, but it's pretty difficult to learn. I still haven't got around to using it for my free-roam camera.
Hello, friends. So, I've skipped most of my programming classes and one of the classes I skipped were about pointers.
Can anyone tell me why in this code:
[code]
#include <stdio.h>
#define DIM 4
void proc( int v[], int i, int n )
{
int j = 0;
while ( j <= n )
{
if ( v[ j ] >= i )
v[ j ] = i;
j++;
}
}
int main( void )
{
int q[] = { 2 , 3 , 4 , 5 };
proc( q , q[2], DIM );
printf( "%d %d %d %d\n", q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] );
return 0;
}[/code]
The information in the q array changes in the printf?
[QUOTE=MountainWatcher;34115132]Hello, friends. So, I've skipped most of my programming classes and one of the classes I skipped were about pointers.
Can anyone tell me why in this code:
[code]
#include <stdio.h>
#define DIM 4
void proc( int v[], int i, int n )
{
int j = 0;
while ( j <= n )
{
if ( v[ j ] >= i )
v[ j ] = i;
j++;
}
}
int main( void )
{
int q[] = { 2 , 3 , 4 , 5 };
proc( q , q[2], DIM );
printf( "%d %d %d %d\n", q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] );
return 0;
}[/code]
The information in the q array changes in the printf?[/QUOTE]
That's because in C/C++ arrays are passed by reference. Writing your function parameters like this:
[code]void proc(int v[], int i, int n)[/code]
Is equivalent to:
[code]void proc(int * v, int i, int n)[/code]
[B]v[/B] will contain the address of the first element of the array you passed.
Oh, I see. What if I wanted to pass the array without it being a pointer? Would I just write (int v, int i, int n)?
I really should have paid more attention in class.
[editline]8th January 2012[/editline]
Wait, can you even do that?
[QUOTE=MountainWatcher;34116078]Oh, I see. What if I wanted to pass the array without it being a pointer? Would I just write (int v, int i, int n)?
I really should have paid more attention in class.[/QUOTE]
Arrays can't get passed by value.
Thank you, guys.
[editline]8th January 2012[/editline]
Okay, okay, bonus round.
[code]
#include <stdio.h>
void proc( double x, double y, double *z)
{
if ( x > y )
*z = x;
else
*z = y;
}
int main( void )
{
double m;
double a = 12.7;
double b = 10.9;
proc( a, b, m);
return 0;
}[/code]
I'm sorry for giving you such trivial crap, but why can't I compile this?
is it because I can't pass fro ma variable to a pointer like that?
[QUOTE=MountainWatcher;34116197]Thank you, guys.
[editline]8th January 2012[/editline]
Okay, okay, bonus round.
[code]
#include <stdio.h>
void proc( double x, double y, double *z)
{
if ( x > y )
*z = x;
else
*z = y;
}
int main( void )
{
double m;
double a = 12.7;
double b = 10.9;
proc( a, b, m);
return 0;
}[/code]
I'm sorry for giving you such trivial crap, but why can't I compile this?
is it because I can't pass fro ma variable to a pointer like that?[/QUOTE]
You don't pass a pointer, you pass the variable itself.
proc(a, b, &m);
-snip-
My laptops GPU is wonderful. If I'm drawing VBOs the programs frame rate will be higher the more pixels is filled on the screen. I'm just drawing 1 single cube but if I zoom it in so it's being draw on around 90 % of the pixels on the screen( 800x600) the fps will be around 20... Any ideas why?
I'm trying to draw a 2D GUI using DirectX.
I have a 512x512 image I'm drawing to the screen using a 2D quad (who's coordinates are in screen-space).
Looking in PIX the vertex-coordinates I upload are exactly 512x512:
[img]http://i55.tinypic.com/709992.png[/img]
However, once I multiply them in my shader by World*View*Proj, the coordinates end up slightly off-square. The rendered quad becomes 512x494 pixels.
Here's my View and Projection Matrix's (World is Identity)
[cpp]
void RenderSystem::SetViewMatrix()
{
D3DXVECTOR3 eye = D3DXVECTOR3(0.0f, 1.0f, -5.0f);
D3DXVECTOR3 lookAt = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
D3DXVECTOR3 Up = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&viewMatrix, &eye, &lookAt, &Up);
}
void RenderSystem::SetProjMatrix()
{
D3DXMatrixOrthoLH(&projMatrix, (float)VideoBackend()->GetWidth(), (float)VideoBackend()->GetHeight(), 1.0f, 100.0f);
}[/cpp]
Where GetWidth() returns 1280 and GetHeight() returns 720.
My guess is the reason it's not square is the Orthographic matrix isn't perfect. I think this because my window's total size is: 1290x730, with the 'interior' (renderable, backbuffer'd surface) is only 1276x694.
Anyone have any experience with this? It's a minor thing, but it's driving me nuts.
[b]Edit:[/b]
Looks like it was a problem with my AdjustWindowRect not liking my flags. Seems to work now that I've gotten the backbuffer to actually be 1280x720.
Sorry, you need to Log In to post a reply to this thread.