SDK Question (solved) How to set a vessel landed?

Topper

Addon Developer
Addon Developer
Donator
Joined
Mar 28, 2008
Messages
666
Reaction score
20
Points
33
Why this is not working to set a vessel landed and how I can change the vesselstatus status to 1 (which means vessel is landed) at current location?

I want to make sure that the vessel (v) change to status 1 after landing, because some older vessels are slipping over the ground after landing...

Code:
VESSELSTATUS2 vs2;
v->GetStatusEx(&vs2);
vs2.status = 1;
v->DefSetStateEx(&vs2);

[edit]
I solved it thanks to this post:
https://www.orbiter-forum.com/showthread.php?t=37527&highlight=GetStatusEx
 
Last edited:

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
That was a dirty hack, don't take it as a good solution, use the code I developed in General Vehicle instead:


Code:
        VESSELSTATUS2 vs2;
        memset(&vs2, 0, sizeof(vs2));
	vs2.version = 2;
	GetStatusEx(&vs2);

	double lng, lat, hdg;
	lng = vs2.surf_lng;
	lat = vs2.surf_lat;
	hdg = vs2.surf_hdg;

////OR MAKE SURE THAT LATITUDE, LONGITUDE AND HEADING ARE THE ONE YOU WANT!


                MATRIX3 rot1 = RotationMatrix(_V(0 * RAD, (90 * RAD - lng), 0 * RAD), TRUE);
		MATRIX3 rot2 = RotationMatrix(_V(-lat + 0 * RAD, 0, 0 * RAD), TRUE);
		MATRIX3 rot3 = RotationMatrix(_V(0, 0, 180 * RAD + hdg), TRUE);
		MATRIX3 rot4 = RotationMatrix(_V(90*RAD, 0, 0), TRUE);


	
		MATRIX3 RotMatrix_Def = mul(rot1, mul(rot2, mul(rot3, rot4)));


		vs2.arot.x = atan2(RotMatrix_Def.m23, RotMatrix_Def.m33);
		vs2.arot.y = -asin(RotMatrix_Def.m13);
		vs2.arot.z = atan2(RotMatrix_Def.m12, RotMatrix_Def.m11);
		vs2.vrot.x = Height_From_Ground ;
		
		DefSetStateEx(&vs2);

Where the rotation matrix function is:
Code:
MATRIX3 GeneralVehicle::RotationMatrix(VECTOR3 angles, bool xyz = FALSE)
{
	MATRIX3 m;
	MATRIX3 RM_X, RM_Y, RM_Z;
	RM_X = _M(1, 0, 0, 0, cos(angles.x), -sin(angles.x), 0, sin(angles.x), cos(angles.x));
	RM_Y = _M(cos(angles.y), 0, sin(angles.y), 0, 1, 0, -sin(angles.y), 0, cos(angles.y));
	RM_Z = _M(cos(angles.z), -sin(angles.z), 0, sin(angles.z), cos(angles.z), 0, 0, 0, 1);
	if (!xyz) {
		m = mul(RM_Z, mul(RM_Y, RM_X));
	}
	else {
		m = mul(RM_X, mul(RM_Y, RM_Z));
	}
	return m;
}
 
Top