Jump to content
  • Advertisement


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



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

If you intended to correct an error in the post then please contact us.

Recommended Posts

this is actually for my opengl app, but im going to ask a general question here because i find that the opengl forum is slow, and id be hard pressed to get more than 2 responses within a days time. problem is scaling. im drawing cubes at specific points on a 3D graph. since i know where those points are, i know when a cube is not drawn in the right place. when i scale a cube down (to make it smaller), some of the cubes are misplaced. i tried scaling before translation, and after translation. both gives me different yet incorrect results. anyone knows why? also, a link to a good tutorial will do me some good. and i already tried google.

Share this post

Link to post
Share on other sites
all i do is scale and translate, there is not rotations.

the best results i can get is to translate first and then scale.
if i scale and then translate then the cubes appear to translate with the scale in mind...meaning with a scale of 0.25f, a translation of 1.0f on the x axis will actually be 0.25f.

this is what it appears to be anyway.

Share this post

Link to post
Share on other sites
being a directx forum im not sure if posting code will help.
but here it is anyways.

again, im putting this here as a general question rather than an opengl question.

also, i believe that opengl and directx process rotations, scaling, and translations in different orders. right?

heres my snipp:


glTranslatef(x, y, z);

Share this post

Link to post
Share on other sites

D3DXMATRIX World, Position, xRot, yRot, zRot, Scale;
//Consider the others identities by same method

D3DXMatrixTranslation(&Position, xPos, yPos, zPos);
D3DXMatrixRotationX(&xRot, xRotation);
D3DXMatrixRotationY(&yRot, yRotation);
D3DXMatrixRotationZ(&zRot, zRotation);
D3DXMatrixScaling(&Scale, xScale, yScale, zScale);
D3DXMatrixMultiply(&world, &world, &Scale);
D3DXMatrixMultiply(&world, &world, &xRot);
D3DXMatrixMultiply(&world, &world, &yRot);
D3DXMatrixMultiply(&world, &world, &zRot);
D3DXMatrixMultiply(&world, &world, &Position);
AdapterDevice->SetTransform(D3DTS_WORLD, &World);

When D3D does it, it scales the vertices, then rotates the vertices, then moves the origin. If OpenGL does it differently...

Think about it: You have a box sitting at the origin. If you scale, you move the verticies closer or further away from the origin by a specific amount. When you rotate, you recalculate their position around the origin. When you translate, you move the verticies away from the origin. It seems odd to me that you say scaling FIRST causes the movement to seem scaled, because, in D3D and according to the very little I understand about matrix math, it should be the opposite.
In matrix math: A*B != B*A.

So when you rotate before scaling, it'll look squashed. If you Transform before scaling, it'll appear that the movement was scaled as well (and the vertices may appear... off, but I'm not entirely sure about that). If you transform before rotating it'll look like you rotated around a different origin point.

Maybe OpenGL does it differently (Since I don't understand the matrix math going on behind the scenes I don't know if you can or not. It says something about the California School System when I can ace Calculus 3 in college and still not know what's going on with matricies...), does it in the reverse order as you say it appears, then maybe that is what's happening.

[edited by - Erzengeldeslichtes on September 23, 2003 12:19:44 AM]

Share this post

Link to post
Share on other sites
I know!

I tried scaling and then translating again, the boxes are very close to the origin, even though they are not suppose to.

im gonna post this one on opengl - and consequently probably wait a day or two to get a response.

thanks anyway.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!