Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

repreated model transformation causing mutation

Started by xavstone Dec 29, 2006 at 11:46 AM 3 replies 1.2k views
Original Post
xavstone
xavstone
Hello everybody, This is a newbie 3d maths question. I am using a transformation matrix to repeatedly transform a game map. after a while the the map becomes flat then reduces to a dot. Very inconvenient. Is this becuase my matrix is broken? Is this a natural 'creep' in the maths? Should i cast a new map object from the original to do the transformations on? Has anyone else experienced this? Any kind of idea appreciated, thanks.
Gagyi
Gagyi
This is because of the rounding errors of the floating point operations.
You shouldnt keep transformed stuff, because the data will almost always be corrupted.

You should save the original object, and make a rotation matrix every frame, depending on the rotation, use that, and trash the transformed coords.
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)
Ravyne
Ravyne
Yes, you should never alter the original vertices. Leaving your map asside for a moment, think about doing so with your models. Ignoring the Increadible Shrinking Model problem for a moment, you wouldn't want to keep an entire copy of the vertex information for each and every instance of that model in the game would you?
throw table_exception("(? ???)? ? ???");
LeGreg
LeGreg
Quote:
Original post by xavstone
I am using a transformation matrix to repeatedly transform a game map. after a while the the map becomes flat then reduces to a dot. Very inconvenient. Is this becuase my matrix is broken? Is this a natural 'creep' in the maths? Should i cast a new map object from the original to do the transformations on? Has anyone else experienced this?


It's what floating point does for you, repeated transform makes precision worse and worse as already said above.

Rather than what you do, you keep original instances of all your data in memory : meshes (read only), angles (or quaternions), scaling, translation vector.

If you do anything incremental (like an incremental rotation of an object), then you keep as many parameters separated as possible, for example you compute rotation as a separate matrix that you renormalize, reorthogonalize every now and then so that it doesn't shrink, expand and skew. If you do it often enough, things won't pop up as the "correction" will be minor each time.

LeGreg
xavstone
xavstone
Thank you, thank you, all, for help with my incredible shrinking models!

Does anyone know if there a common consensus on the best way to copy objects? My models are using inner classes for triangle and vectors coordinates. I can 'deepclone' or 'clone' the models (using java at the moment) but this seems to be putting alot of strain on resources. How would this be done in c++? Create a new object and copy across its vital statistics in loops for transform, then kill the new object after render?

Topic Locked

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

Sign in to reply to this topic.