moving attachment points

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
10,540
Reaction score
4,371
Points
203
Location
Dallas, TX
I have run across an issue. I have a landing pad that is about 45 degress. I normalized the attachment point which gives me:
LP1 = CreateAttachment (false, _V(-303.776,12.029,517.3211),_V(0,1,0),_V(.7,0,.7),"1",true);

that is good. but I want to lower the pad and attached vessel. I have to adjust the y value. but the ship shakes.

LP1_pos.x = -303.776;
LP1_pos.y = 12.029;
LP1_pos.z = 517.3211;


{LP1_pos.y=LP1_INT_POS-(LP1_proc*BAYFACTOR);
SetAttachmentParams(LP1,LP1_pos,_V(0,1,0),_V(.7,0,.7));

}

Any ideas?


EDIT:
After reading the SDK I think they have to at right angles. The pad attachment point was a angle that is not at a right angle to the ship.
 
Last edited:
OK I need help.

I have moved attachment point in the y direction and in the x and z but only 1 axis at a time.
So not sure how move an attachment point in the x and z direction.

here is the attachment point:
R1 = CreateAttachment (false, _V( 415.5538,5.79,386.2883),_V(0,-1,0),_V(-0.499528953505622,0,-0.866297191851375),"R1",false

any ideas?
 
I am not really sure where the problem is. Does the transition in y now work, but you want a transition along a vector that is not parallel to y?

In that case, let r_0 be the initial position and r_1 the final position of the attachment transition. Then the current attachment position r is given by
[math]
\vec{r} = \vec{r}_0 + \alpha (\vec{r}_1 - \vec{r}_0)
[/math]
where alpha is a state parameter between 0 (initial state) and 1 (final state) - presumably your LP1_proc variable.

Note that OrbiterAPI.h defines all the vector operators required for directly implementing the equation above. No need to muck about with individual vector elements during the transition.
 
Thanks
I got it
R1X=25.9752;
R1Z=44.9078;
R1 = CreateAttachment (false, _V( 415.5538,5.79,386.2883),_V(0,-1,0),_V(-0.499528953505622,0,-0.866297191851375),"R1",false);

R1_pos.x=R1_INTX_POS-(RAIL2A_proc*R1X);
R1_pos.z=R1_INTZ_POS-(RAIL2A_proc*R1Z);
SetAttachmentParams(R1,R1_pos,_V(0,1,0),_V(-0.498250001991689,0,-0.867033410841406));

the animation info is
static UINT EGrp131[2] = {GRP_rail4A,GRP_eagleframeA};//
static MGROUP_TRANSLATE RAIL1A(0, EGrp131, 2,_V(-25.9752,0,-44.9078));
anim_RAIL2A = CreateAnimation (0.0);
AddAnimationComponent (anim_RAIL2A, .0,1, &RAIL1A);

so I had to make it go the x and z length

now the attachment follows the animation.
 
Good to hear it works, although from your code snippet I gather that you don't trust in vector operations (believe me, it makes the code more readable/maintainable than scalar operations on individual vector elements).
now the attachment follows the animation.
For a simple linear transition this is ok, but for more complicated animations (e.g. animations that are themselves children of other animations), it is better to make the attachment point a part of the animation itself (using the LOCALVERTEXLIST mechanism) and let Orbiter worry about performing the transformation.
 
I first tried that. I have used it is a part of parent-child. But really all I have is a parent. the attachment is the parent and it is what I needed to move.
 
Ok now how to do I save the moved attachment point? When I exit and restart the animation is saved but the attachment info isn't. But when I press the key to get it to move again it jumps to that position.

Got it to work I just had to move the
R1_pos.x=R1_INTX_POS-(RAIL2A_proc*R1X);
R1_pos.z=R1_INTZ_POS-(RAIL2A_proc*R1Z);
SetAttachmentParams(R1,R1_pos,_V(0,1,0),_V(-0.498250001991689,0,-0.867033410841406));
 
Last edited:
Ok now how to do I save the moved attachment point? When I exit and restart the animation is saved but the attachment info isn't. But when I press the key to get it to move again it jumps to that position.
By using the LOCALVERTEXLIST as Martin suggested. It doesn't need to be a child either, it can be another component of the parent animation.
 
Back
Top