SDK Question Variable thrust vector

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
10,547
Reaction score
4,373
Points
203
Location
Dallas, TX
It is possible to tie the thrust vector to a variable? If the variable =0 then the thrust vectors would be 0,0,1. If the variable = .5 then the vectors would be 0,0,-1. The variable .25 then vectors (1,0,0).

The range of the variab le would be 0 to 1. THen the varible would be tied to degrees. O=0 degrees .25=90 degrees,....

The x and y vector would have to calculated. I think it has to do with sin and cos.
 
you can't do that directly, but you can let Orbiter help you, if you use animations.

You can let orbiter rotate an array of vectors instead of a number of mesh group in the semiautomatic animation mode. If you define two points at the engine that are 1m away, the rotations and translations will ALWAYS keep the points 1m away... the difference between the two points is a direction vector for your engine, if the line between both is parallel to the thrust vector in the mesh initial state.
 
Yep what Urwumpe said is probably the best way to go about it as you will probably want to have an associated animation with your rotatable thruster anyway. If you want to calculate it manually though you could do it this way:

vector = _V(sin(2*PI*var), 0, cos(2*PI*var));
 
The default delta glider changes the main engine thrust directions to do its thrust vector control.
 
ThaI am using an animation.

Here TURN_proc is the variable:
SetAnimation (anim_axle1, TURN_proc);



// Wheel1
static UINT WGrp1[2] = {59,70};

wheel1 = new MGROUP_ROTATE (0,WGrp1, 2, _V(-1.529,-1.759,1.494), _V(1,0,0), (float)(360*RAD));

// rear Left Wheel Turn
static UINT TuGrp1[1] = {66};

static MGROUP_ROTATE tu1 (0,TuGrp1, 1, _V(-1.5363,-1.759,1.494), _V(0,1,0), (float)(360*RAD));

anim_axle1 = CreateAnimation (0.0);
parent1=AddAnimationComponent (anim_axle1, 0, 1, &tu1);
anim_wheel1 = CreateAnimation (0.0);
AddAnimationComponent (anim_wheel1, 0, 1, wheel1, parent1);

So in this example the axle1 rotates 360 degrees

---------- Post added at 04:38 PM ---------- Previous post was at 03:00 PM ----------

ThaI am using an animation.

Here TURN_proc is the variable:
SetAnimation (anim_axle1, TURN_proc);



// Wheel1
static UINT WGrp1[2] = {59,70};

wheel1 = new MGROUP_ROTATE (0,WGrp1, 2, _V(-1.529,-1.759,1.494), _V(1,0,0), (float)(360*RAD));

// rear Left Wheel Turn
static UINT TuGrp1[1] = {66};

static MGROUP_ROTATE tu1 (0,TuGrp1, 1, _V(-1.5363,-1.759,1.494), _V(0,1,0), (float)(360*RAD));

anim_axle1 = CreateAnimation (0.0);
parent1=AddAnimationComponent (anim_axle1, 0, 1, &tu1);
anim_wheel1 = CreateAnimation (0.0);
AddAnimationComponent (anim_wheel1, 0, 1, wheel1, parent1);

So in this example the axle1 rotates 360 degrees


update code:
VECTOR3 dir = {0,0,0};
VECTOR3 dirR = {0,0,0};

th_main = CreateThruster (_V(0,0,0), dir, MAXMAINTH, TANK, ISP);
CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);

th_retro = CreateThruster (_V(0,0,0), dirR, MAXRETROTH, TANK, ISP);
CreateThrusterGroup (&th_retro, 1, THGROUP_RETRO);

SetThrusterDir (th_main, _V(sin(2*PI*TURN_proc), 0, cos(2*PI*TURN_proc)));


the direction changes. but I can't get the vessel to move. It has fuel

const double FUELMASS = 1000;
const double ISP = 2.5e5;
const double MAXMAINTH = 6e18;
const double MAXRETROTH = 6e18;
 
Did you calculate when you run out of fuel?
 
No, I got it to work. I had the thrust set way to high.
 
Back
Top