Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP]+[Matrix1Utils] Relative Object Positioning

Author
Message
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 24th Mar 2011 10:03
Basically... Well, it pops up a lot in video games, that you want an object lying on something that's moving and rotating around. The problem is that it can be tricky to figure out how to position the object.

This program solves that problem, using matrix math. I tried to make it well commented, so that anyone who was learning how to handle transformations could learn from this code.

To use it, make three objects: One is the platform, another is the "child" object, that is sitting on the platform, and another is the platform last frame (hidden, preferably). You call a function with the object numbers of those three arguments, and the function updates the child object's position and rotation where it should be.

This also works with scaling!



Link102
19
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 15th May 2011 15:38
Whatever happened to putting objects in a mesh?
Wouldn't that be much easier than this? Or does that have it's limitations?

Jimpo
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 15th May 2011 22:53
Nice work! But since your already using Matrix1Utils, there is a command called "object matrix4" that does what getObjectsWorldMatrix() does in your code.

Login to post a reply

Server time is: 2024-04-26 05:38:52
Your offset time is: 2024-04-26 05:38:52