Ok I just tried your code and it seems to have about the same effect look:
http://www.talentopoly.com/adam/UPLOADS/cpp/WinMain2.exe
It work for some directions (read: angles) but gets all screwy when u rotate to other angles.
Also could U explain the logic behind the changes u made 2 the math code there? I really wanna learn this.
Camera Roation
Do you want to post all of your code?
Also, are you calling glLoadIdentity() before doing your rotate and translate?
Also, are you calling glLoadIdentity() before doing your rotate and translate?
Yes I'm loading the ident matrix.
Ya sure I'll post the code, its incredibly dirty right now b/c i've been commenting out stuff and working around things and u'll see... once i get this working and i know what i need i'll clean it up.
WinMain (win32 entry point):
Here you'll want to look at line 183 for my render calls to the OpenGLOps Object called OGLO:
http://www.talentopoly.com/adam/UPLOADS/cpp/WinMain.cpp
My OpenGL Operations Included into WinMain:
Here you'll want to look at SetUpFrame() on line 107:
http://www.talentopoly.com/adam/UPLOADS/cpp/OpenGLOps.cpp
OpenGL Operations header:
Just my class declaration...
http://www.talentopoly.com/adam/UPLOADS/cpp/OpenGLOps.h
[Edited by - Wavesonics on August 4, 2004 1:42:30 PM]
Ya sure I'll post the code, its incredibly dirty right now b/c i've been commenting out stuff and working around things and u'll see... once i get this working and i know what i need i'll clean it up.
WinMain (win32 entry point):
Here you'll want to look at line 183 for my render calls to the OpenGLOps Object called OGLO:
http://www.talentopoly.com/adam/UPLOADS/cpp/WinMain.cpp
My OpenGL Operations Included into WinMain:
Here you'll want to look at SetUpFrame() on line 107:
http://www.talentopoly.com/adam/UPLOADS/cpp/OpenGLOps.cpp
OpenGL Operations header:
Just my class declaration...
http://www.talentopoly.com/adam/UPLOADS/cpp/OpenGLOps.h
[Edited by - Wavesonics on August 4, 2004 1:42:30 PM]
Ok I must be close b/c I found this math code in a tutorial with a working camera:
if (keys[VK_UP])
{
xpos -= (float)sin(heading*piover180) * 0.005f;
zpos -= (float)cos(heading*piover180) * 0.005f;
}
Now it looks like hes converting degrees to radians by multiplying degrees (heading) by pi / 180. Besides that my math and his math is exactly the same.
Why would converting it to radians matter?
Then he takes the xpos and zpos and inverts them for the final translation:
GLfloat xtrans = -xpos;
GLfloat ztrans = -zpos;
glTranslatef(xtrans, ytrans, ztrans);
if (keys[VK_UP])
{
xpos -= (float)sin(heading*piover180) * 0.005f;
zpos -= (float)cos(heading*piover180) * 0.005f;
}
Now it looks like hes converting degrees to radians by multiplying degrees (heading) by pi / 180. Besides that my math and his math is exactly the same.
Why would converting it to radians matter?
Then he takes the xpos and zpos and inverts them for the final translation:
GLfloat xtrans = -xpos;
GLfloat ztrans = -zpos;
glTranslatef(xtrans, ytrans, ztrans);
Just looking through your code, it looks like you're not converting your angles into radians. C++'s sin and cos functions expect radians. Just multiply your angle by pi*180 to do that.
EDIT: WOOPS! Should have refreshed the page before posting... BTW, which compiler are you using?
EDIT: WOOPS! Should have refreshed the page before posting... BTW, which compiler are you using?
haha, um Dev C++ is my IDE, MinGW compiler.
Well that explains why hes converting to radians, thank you.
Now I plugged his code into my code and it still doesnt work... And I'm pretty sure I transfered it perfectly.
Aw 1 small thing, he stores yrot (rotation) and heading seperately. But I cant see why, as far as I can tell yrot is set = to heading, and is never changed. But heading is used for the translation calculations not yrot.
Well that explains why hes converting to radians, thank you.
Now I plugged his code into my code and it still doesnt work... And I'm pretty sure I transfered it perfectly.
Aw 1 small thing, he stores yrot (rotation) and heading seperately. But I cant see why, as far as I can tell yrot is set = to heading, and is never changed. But heading is used for the translation calculations not yrot.
jakem3s90 do u have icq or aim or something so maybe we could talk in real time?
ICQ: 39886687
AIM: Jebradic
YAHOO: Jebradic
MSN: wavesonics@hotmail.com
ICQ: 39886687
AIM: Jebradic
YAHOO: Jebradic
MSN: wavesonics@hotmail.com
Ok.. Here's a couple things to try
(I'm at work, so I can't really check it myself)
Restructure your render loop as such:
First, pull the glMatrixMode(GL_MODELVIEW) and the glLoadIdentity() calls from your render loop, stick them just before you start that loop.
Also, call glPushMatrix() before you call OGLO.RenderFrame() and a glPopMatrix() after.
Other than that, you're code looks good, it's hard to tell without really digging through it though.
(I'm at work, so I can't really check it myself)
Restructure your render loop as such:
First, pull the glMatrixMode(GL_MODELVIEW) and the glLoadIdentity() calls from your render loop, stick them just before you start that loop.
Also, call glPushMatrix() before you call OGLO.RenderFrame() and a glPopMatrix() after.
Other than that, you're code looks good, it's hard to tell without really digging through it though.
Quote:Original post by Wavesonics
jakem3s90 do u have icq or aim or something so maybe we could talk in real time?
ICQ: 39886687
AIM: Jebradic
YAHOO: Jebradic
MSN: wavesonics@hotmail.com
Just PM'd you my info...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement