Plants and matrices
I am starting a "Tree simulator" and I'm trying to make it so I have a single component that generates the 3D shapes for the stem, branches, leaves, etc...
I quickly ran in the math problems, and basically I don't really know where to start on
Let's say I have Stem_A at [0, 0, 0] with a length of [0, 1, 0] and no rotation. When some condition is met, a second smaller Stem_B starts growing from Stem_A at a 45° angle on the X plane and a random rotation around the Y plane. So far so good.
The big question I have is "how do I grow Stem_C from Stem_B with the equivalent 45°X+rand()°Y transformation"?. Since Stem_B is no longer aligned with the axis, I lost the supe-easy referential... I understand that I should be able to represent that transformation with a 4x4 matrix, but I have no clue on how to set it up and how to use it in this context...
@Hellium each stem/branch/node will certainly be stored in a graph-like data structure. My question is more about the mathematics approach to take to keep the transformations coherent between subsequent generations.
If you store the stems in a tree structure, you have the rotation of the parent stem you're trying to attach the child stem to, so you only need to compute the offset of the parent and the child
childQuaternion = offsetQuaternion * parentQuaternion;
Your answer
Follow this Question
Related Questions
Acceleration and accelerometer calibration 0 Answers
How to translate World <->Local position without Transform component with Matrix4x4? 0 Answers
c# help with rotate and rotatearound 0 Answers
iron sight using inverse kinematic 0 Answers
How to disable diagonal Vector3 movement of non-player object using MoveTowards? 1 Answer