Jump to content

Global TurnEntity in parent's local space?


Canardia
 Share

Recommended Posts

I can't figure out how to turn a mesh around an axis which is the parent entity's local axis.

I have 3 nested rings, where ring1 is the outer ring. These 4 lines of code work fine, but I can't figure out how to turn ring2 around ring1's local axis. Ring1's parent is the world, so I can use the global parameter to turn it in the world's "local" space (which is ring1's global space).

	EntityParent(ring2,ring1);
EntityParent(ring3,ring2);

	TurnEntity(ring1, Vec3(0,0,1), 1);
TurnEntity(ring1, Vec3(0,1,0)   );
TurnEntity(ring2, Vec3(1,0,0)   );
//TurnEntity(ring2, Vec3(0,1,0)   ); // doesn't work right
TurnEntity(ring3, Vec3(0,0,1)     );
//TurnEntity(ring3, Vec3(0,1,0)   ); // doesn't work right

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Ahh, I found the solution, TFormVector does exactly what I want: It transforms a vector from another entity's space to another entity's space, so now everything works perfectly:

TurnEntity(ring1, Vec3(0,0, ringspeed1*AppSpeed()), 1);
TurnEntity(ring1, Vec3(0, ringspeed2*AppSpeed(),0)   );
TurnEntity(ring2, TFormVector(Vec3(ringspeed1*AppSpeed(),0,0),ring1,ring2));
TurnEntity(ring2, Vec3(0, ringspeed2*AppSpeed(),0)   );
TurnEntity(ring3, TFormVector(Vec3(0,0,ringspeed1*AppSpeed()),ring2,ring3));
TurnEntity(ring3, Vec3(0, ringspeed2*AppSpeed(),0)   );

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...