There is more than one way to solve it and so I will just give you the solution that I came up with. P.S.: considering performance would be great. But mathematics behind Rotation and Scale still unclear for me.Ĭan you help me with algorithm that will calculate Local and Absolute Position, Rotation and Scale? To get LocalPosition i can subtract from AbsolutePosition last column of parent transformations matrix. I can take last column from transformations matrix and it will be my AbsolutePosition. How to calculate Absolute and Local Position i have an idea: It's a very simple example, in real scenario we have to consider parent's scale and rotation to calculate Position. It's LocalPosition will now be = (-1, -1, -1). Now we set child's AbsolutePosition = (0, 0, 0). While setting Absolute values Local should be updated consistently and vice versa.Įxample: We have parent at position (1, 1, 1) and child with LocalPosition = (0, 0, 0), having this information we can calculate child's AbsolutePosition = (1, 1, 1). I want to have ability to get and set absolute transformations to child transforms. Code that calculates final transformations matrix looks like this: public Vector3 LocalPosition Each transform can have parent transform. I have Transform class that provides transformations matrix to shader. I have an OpenGL C# project, that I would like to give functionality like Unit圓D game engine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |