#### Archived

This topic is now archived and is closed to further replies.

# Hard to Explain

This topic is 5994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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...
...
}
//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

##### Share on other sites
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.

##### Share on other sites
Yes Elber Kain!! It''s the exactly thing I have to do!! But it''s the problem!!! I don''t know how to do this calculus!

Há!!! I almost forgot!
Thank you for your help Shadow_of_light, but I thing it''s not what I want!!!

Fernando

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002274
×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!