Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc.

Reply
 
Thread Tools
Old 08-17-2012, 02:38 AM   #1
Piper
Orbiting Space Addict
 
Piper's Avatar


Default Rotating a Mesh, and a Jettisoned Payload

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?
Piper is offline   Reply With Quote
Thanked by:
Old 08-17-2012, 02:51 AM   #2
SiameseCat
Addon Developer
Default

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.
SiameseCat is offline   Reply With Quote
Old 08-17-2012, 07:39 AM   #3
jedidia
shoemaker without legs
 
jedidia's Avatar
Default

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.
jedidia is offline   Reply With Quote
Old 08-17-2012, 03:23 PM   #4
Piper
Orbiting Space Addict
 
Piper's Avatar


Default

Quote:
Originally Posted by jedidia View Post
 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.
It's the second. With that said, maybe I should be doing this as an attachment instead. I guess it would solve both problems. I'll give that a try.
Piper is offline   Reply With Quote
Old 08-17-2012, 04:14 PM   #5
martins
Orbiter Founder
Default

Quote:
Originally Posted by Piper View Post
 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.
That could indicate that you are applying the rotations in the wrong order. If R_local is the rotation of the payload relative to the parent vessel, and R_vessel is the parent vessel's global rotation matrix, you want to set the payload's rotation matrix to

R_vessel R_local

not the other way round.
martins is offline   Reply With Quote
Thanked by:
Old 08-17-2012, 05:44 PM   #6
Bibi Uncle
50% Orbinaut, 50% Developer
 
Bibi Uncle's Avatar
Default

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);
Bibi Uncle is offline   Reply With Quote
Thanked by:
Old 08-17-2012, 11:16 PM   #7
Piper
Orbiting Space Addict
 
Piper's Avatar


Default

Yaaay!!! I got it to work using attachments Thank you so much guys.
Piper is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 11:40 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2007 - 2012, Orbiter-Forum.com. All rights reserved.