Skip to main content
gamedev.net
🔒 Locked

Rotating an object

Started by IceGod Apr 28, 2001 at 4:36 AM 3 replies 500+ views
Original Post
IceGod
IceGod
Hi, Say I have an object that is centered on the screen and at z = 5.0, and I have my camera at the origin facing the object. When I run the program everything is cool, the object is centered perfectly on the screen. When I apply a rotation to the object, using the matrix created by D3DXMatrixRotationY and some small angle, the object ends up completely somewhere else. I don''t know where exactly because its off the screen. Eventually the object rotates back into view, but my question is, why doesn''t the object start rotating from where it is originally? This makes no sense to me =\ Its like applying a small rotation to the object warps it to some other place for no reason at all. My code is fine, is there some misunderstanding I have here? Thanks, Tom
uber_sandman
uber_sandman
You are rotating in world space ... to move into the objects local space add the reverse of the transform and then rotate, and then move back.

ie:

translate(-posx, -posy, -posz)

rotate(angle, axis)

translate(pox, posy, poz)


hope that helps
IceGod
IceGod
Thats just the thing, I actually want the object to rotate around world space But it gets all funky, it starts rotating in some weird spot which it shouldn''t do. Like I said, when the object is centered on the screen and placed at z = 5.0, when I rotate it it starts off in some wierd area and eventually gets back to z=5.0, instead of starting the rotation from z=5.0.

Thanks,
Tom
IceGod
IceGod
I figured it out, I was messing with the SDK examples, and they use TimeGetTime() / 1500.0f for their rotation value a lot. Well it turns out that the angles this produces are pretty large, and thats why it was starting out in random places. So I set my angle to a static variable with a very small angle, and it works fine. Thanks for the answers though.

Tom

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.