![]() |
|
|||||||
| Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc. |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Orbiting Space Addict
![]() ![]() ![]() |
So I've finally decided on taking the great leap from Spacecraft3 to creating proper modules for all my spacecraft. Right now I'm working with my Io Orbiter, and I've got all the basics down for creating and releasing a payload, but for the Lander I need to rotate the mesh 90deg first, and of course it needs to be rotated the same amount and direction when it's released.
I've tried MeshgroupTransform to rotate the mesh, but I've absolutely gotten no where with that one. No matter what I do I can't get the mesh to rotate, even in the wrong direction. I know I could just create a mesh that's physically rotated the right way, I'd rather see if I can do it with code. With the released payload I can rotate it, but I just can't get it rotated in the right direction. I've tried applying a rotation matix to the vessel's orientation, but that only rotates it against the ecliptic, and not the axis of the spacecraft. Anyone able to give me any help on this? |
|
|
|
| Thanked by: |
|
|
#2 |
|
Addon Developer
![]() |
You should be able to use a regular animation. Instead of passing an array when creating the MGROUP_ROTATE struct, set the 'grp' pointer to NULL - this will animate the entire mesh.
|
|
|
|
|
|
#3 |
|
shoemaker without legs
![]() |
I'm not sure I quite follow... is the payload a separate vessel all the time, or is its mesh integrated into the main vessel and only becomes its own vessel on release?
If the first, The easiest thing is to rotate the attachment point it is attached to. If the second, things get a bit more involved. |
|
|
|
|
|
#4 |
|
Orbiting Space Addict
![]() ![]() ![]() |
Quote:
|
|
|
|
|
|
#5 |
|
Orbiter Founder
![]() |
Quote:
R_vessel R_local not the other way round. |
|
|
|
| Thanked by: |
|
|
#6 |
|
50% Orbinaut, 50% Developer
![]() |
I wrote this function for jettisonning a payload with specified angle (x is pitch, y is roll and z is yaw, rotation is a VECTOR3):
Code:
MATRIX3 mat, matX, matY, matZ, matF; // Getting current rotation matrix m_pVessel->GetRotationMatrix(mat); // rotation in pitch double sina = sin(rotation.x*RAD); double cosa = cos(rotation.x*RAD); matX = _M(1,0,0, 0,cosa,sina, 0,-sina,cosa); // rotation in roll sina = sin(rotation.y*RAD); cosa = cos(rotation.y*RAD); matY = _M(cosa,0,sina, 0,1,0, -sina,0,cosa); // rotation in yaw sina = sin(rotation.z*RAD); cosa = cos(rotation.z*RAD); matZ = _M(cosa,sina,0, -sina,cosa,0, 0,0,1); // multiply everything matF = mul(mat, mul(matX, mul(matY, matZ))); // calculate the angles vs.arot.x = atan2(matF.m23, matF.m33); vs.arot.y = -asin(matF.m13); vs.arot.z = atan2(matF.m12, matF.m11); // create the vessel OBJHANDLE obj = oapiCreateVessel(GetName().c_str(), configName.c_str(), vs); |
|
|
|
| Thanked by: |
|
|
#7 |
|
Orbiting Space Addict
![]() ![]() ![]() |
Yaaay!!! I got it to work using attachments
Thank you so much guys.
|
|
|
|
![]() |
|
| Thread Tools | |
|
|
|||||
| Quick Links | Need Help? |