WORMHOLE::WORMHOLE (OBJHANDLE hObj, int fmodel)
: VESSEL2 (hObj, fmodel)
{
distance = 0;
rpos = _V(0, 0, 0);
rvel = _V(0, 0, 0);
gpos1 = _V(0, 0, 0);
}
void WORMHOLE::clbkSetClassCaps (FILEHANDLE cfg)
{
// physical specs
SetSize (500);
SetEmptyMass (1000.0);
SetCW (0.3, 0.3, 0.6, 0.9);
SetWingAspect (1.7);
SetWingEffectiveness (14.1);
SetCrossSections (_V(5.4, 5.4,25.77 ));
SetRotDrag (_V(3.5,3.5,3.5));
if (GetFlightModel() >= 1) {
SetPitchMomentScale (1e-4);
SetBankMomentScale (1e-4);
}
SetPMI (_V(2.58,2.57, 12.00));
SetTrimScale (0.08);
SetCameraOffset (_V(0,2.5,0));
SetTouchdownPoints (_V(0,.01,5.7), _V(-3.448,.01,-5.0), _V(3.448,.01,-5.0));;
EnableTransponder (true);
// propellant resources
//SetMeshVisibilityMode(AddMesh(oapiLoadMeshGlobal("INTERSTELLAR\\VESSEL\\WHole")), MESHVIS_ALWAYS); //Main ship mesh
SetMeshVisibilityMode(AddMesh(oapiLoadMeshGlobal("gateway")), MESHVIS_ALWAYS); //Main ship mesh
}
void WORMHOLE::clbkPostStep(double simt, double simdt, double mjd)
{
for (UINT i = 0; i<oapiGetVesselCount(); i++)
{
OBJHANDLE hvessel = oapiGetVesselByIndex(i);
if (hvessel != GetHandle())
{
VECTOR3 vesselpos = _V(0, 0, 0);
VECTOR3 gatepos = _V(0, 0, 0);
oapiGetGlobalPos(hvessel, &vesselpos);
oapiGetGlobalPos(GetHandle(), &gatepos);
relpos = vesselpos - gatepos;
double distance = length(relpos);
}
sprintf(oapiDebugString(), "DISTANCE %0.9f" , distance);
/*
// if ((distance<2) && (rpos.z>0) && (rvel.z<0))
//if (distance<2)
{
VESSELSTATUS2 vs_vessel, vs_other_gate;
memset(&vs_vessel, 0, sizeof(vs_vessel));
memset(&vs_other_gate, 0, sizeof(vs_other_gate));
vs_vessel.version = 2;
vs_other_gate.version = 2;
VESSEL *v;
v = oapiGetVesselInterface(hvessel);
v->GetStatusEx(&vs_vessel);
OBJHANDLE h_other_gate;
char myname[16];
char GateA[16];
sprintf(myname, GetName());
sprintf(GateA, "Gate_A");
if (strcmp(myname, GateA) == 0)
{
h_other_gate = oapiGetVesselByName("Gate_B");
}
else{
h_other_gate = oapiGetVesselByName("Gate_A");
}
VESSEL *v_other_gate;
v_other_gate = oapiGetVesselInterface(h_other_gate);
v_other_gate->GetStatusEx(&vs_other_gate);
vs_vessel.rbody = vs_other_gate.rbody;
vs_vessel.rpos = vs_other_gate.rpos;
vs_vessel.vrot = vs_other_gate.vrot;
vs_vessel.arot = vs_other_gate.arot;
VECTOR3 outvel = _V(rvel.x, rvel.y, rvel.z);
VECTOR3 rofs;
GlobalRot(outvel, rofs);
vs_vessel.rvel.x = vs_other_gate.rvel.x + rofs.x;
vs_vessel.rvel.y = vs_other_gate.rvel.y + rofs.y;
vs_vessel.rvel.z = vs_other_gate.rvel.z + rofs.z;
v->DefSetStateEx(&vs_vessel);
}
*/
}
}