I need help from all of you!

Started by
25 comments, last by MARS_999 17 years, 4 months ago
Hello my name is Ryan im 14 years old from Turkey, cheers everyone I started ogl programming a few months ago and i am going good but i have a very serious bug that i am stuck in for 2 months! I have a very simple OpenGL project that is not working right. After looking for info on the Internet, it turns out that the glRotatef() function does the transform local to the object, and does not do a global transform. So the order of operation of is important. In the function Cylinder::ProcessMessage(), processing for the MSG_ROTATE_CURRENT_STATE message, there is an if to check if the rotation is ‘positive’ or ‘negative’ it is just dumb luck that doing the rotations in the backward order works for this program, but to add functionality, I need a function for global rotation. There has to be a function to do global rotation!!! Run the scope project, and press the ‘go’ button. The window has two cylinders, but one of them starts with a view straight-on, so you must use the arrow keys on the keyboard to see one of the cylinders. Can you please help me? I have uploaded source code of the project here: www.albayoung.com/kosta/OGL.zip Please help me!!!!! thank you very much for your time. I owe a very big favour to all who help me :)
Advertisement
please help me fix that!!!

please! this bug is driving me crazy
take a breath there kid.
relax,
before trying coding more, since you have all your life ahead of you ( 14 years old ?? ) take some time and study some basic matrix mathematics and then some basic opengl matrix / matrix stack stuff. I guess you are familiar with some opengl concepts but obviously you must master some more before you can say you are stuck because of a bug.
At this point you are, most probably, doing something in a way that you shouldn't.
Pace yourself, study more opengl, before going deep into complex stuff.

you can start from these tutorials here ( http://nehe.gamedev.net )
they are not the best code practices but they have helped a lot of people ( including myself ) to start off.

in the meantime i will take a look of your code ...


thank you very much skiritis. you cant imagine how much i appreciate it!

I know about nehe and i read tutorials almost every day:)

i am waiting very excited to see if you can help me so i can go past this bug

thanks alot!
If by global rotation you mean rotate every object, there is a simple solution. You rotate your camera in the opposite way. Still that means you have to do your rotation before drawing your objects in your loop.

Try to understand how OpenGL works,
i)you set your viewpoint(Camera)
ii) Set your transformation for your object(translate/rotate)
iii) draw your object
At this point your object is rasterized, turned to pixels, you can no longer change this object for this frame. Only thing which could happen is another object closer to the camera is rasterized and it overwrites the pixels.

The only 2 ways you could rotate every object in the world are as follows
1) rotate your camera in the opposite direction.
2) apply your rotation calculations to every object in the world.

Obviously the former is easier/faster to do.
Hello, thanks for the reply

Can you demonstrate me how i can do this in the code that i have provided? My OpenGL knowledge is not very stable and im trying my best to have a sample for the contest entry before 30th... i know im going to take last palce but i just want to do it for my pleasure

thanks alot :)
How can i change the code so i can make it that i dont need to check if the rotation is negative?
Dont really have much time now, but in general, you could do this. Ive not touched Transfomations in a long time so i might be wrong, but i believe it should work.

float[4] globalRotation;

loop every frame
{
glLoadIdentity();
//do this here if you want objects to rotate around camera
//glRotatefv(globalRotation);
for every object
glPushMatrix();
glTranslatef(ObjectPosition)
//do this here if you want objects to around their own axis
//glRotatefv(globalRotation);
glRotatef(localObjectRotation);
//draw your object here
glPopMatrix();
end for

}
Thank you very much!! can someone please also help me with the exact code that i have provided so that i can remove the if?

Thank you very much!
someone... please... ??

This topic is closed to new replies.

Advertisement