
Hard to Explain
Hi guys!!!!!!!!!!
I''m getting some problems that I''ll try to explain. Bear with me, because it''s not that easy for me! :-)
Ok! The problem is: I have a little engine 3D. All that it do is to ability the player to walk around a 3D real world. For this, I''m using Quaternions, and when I have to do Rotations to look at right, left, up, or down I rotate all the objects.
So, this is my problem! Everything is working fine, but when I try for example to Add a new CUBE to the world, it''s very difficult for me to do the calculus for the new Object Position. It''s Because, the World have been rotated many many times (remember when I do rotations, the Objects that rotate), and in reason for this, the position of objects are now changed.
I would like to know, if there is a technic to calcule the new position, or any algoritmh or something liked.
I don''t know if my explanation were very well, but I hope you''ll understand!!!
Thank you very much guys!!!! and sorry for the english!
Fernando

If I''m understanding the problem correctly your having trouble with rotating objects within you world... try this...
for each individual object rotate and the translate...
example:
for(objloop=0;objloop//cycles through all the individual objects (cubes etc)
{
x=object[objloop].x;
y=object[objloop].y;
z=object[objloop].z;
glRotatef(rotx,1.0f,0,0); //rotate around x axis
glRotatef(roty,0,1.0f,0); //rotate around y axis
glTranslatef(x+viewp.x,y+viewp.y,-z+viewp.z);
//here your translate out the distance of the object PLUS
//the location of the view port
for(triloop=0;triloop //loops through all the trianlges
{
...
//the code for the vertices...
...
}
glLoadIdentity();
//this parts important, this clear the matrix so that all
//the translates and rotates are relative to the origin.
}
That should take care of you problem, that code should generaly work although I may have gotten one of the axis flipped backwards, I have a tendency to do that sometimes
for each individual object rotate and the translate...
example:
for(objloop=0;objloop
{
x=object[objloop].x;
y=object[objloop].y;
z=object[objloop].z;
glRotatef(rotx,1.0f,0,0); //rotate around x axis
glRotatef(roty,0,1.0f,0); //rotate around y axis
glTranslatef(x+viewp.x,y+viewp.y,-z+viewp.z);
//here your translate out the distance of the object PLUS
//the location of the view port
for(triloop=0;triloop
{
...
//the code for the vertices...
...
}
glLoadIdentity();
//this parts important, this clear the matrix so that all
//the translates and rotates are relative to the origin.
}
That should take care of you problem, that code should generaly work although I may have gotten one of the axis flipped backwards, I have a tendency to do that sometimes

I'm don't know much but I can try to help... just email me at... Shadow_0f_Light@Yahoo.com(the '0' in 'Of' is a zero :P)
the way you describe the problem, I would think that you couldnt just add a new object at some arbratary location. You will have to make the new object relatave to an existing object.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement