oK. if we use the gate example. I would walk perpendicular to the opening. parallel would along the side of it.
Last edited:
oK. if we use the gate example. I would walk perpendicular to the opening. parallel would along the side of it.
dotp(rpos, rvel)
:headbang:
So:
the dot product dotp(normal, velocity) gives you the velocity away or towards the plane.)
gives velocity away or towards.Code:dotp(rpos, rvel)
I hope some one update the code.
I guess it would be too easy to get the vessel position and the gateway. compare the x, y, z and if within a value execute the move?
Easy for you not meWhy? It is easy.
The problem is: You need to prevent that after jumping from Gate A to Gate B, Gate B jumps you back to Gate A, etc.
For that you should have a definition that makes sure, movement away from the gate is ignored.
That is all.
Easy for you not me
But wouldn't you just look at the z difference to see if you were heading towards or away.
Z position of vessel and z position gateway. I guess you could store a reading and if the next reading was less then the vessel is moving closer
How easy is this going to be to code?
WORMHOLE::WORMHOLE (OBJHANDLE hObj, int fmodel)
: VESSEL2 (hObj, fmodel)
{
jump = 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 rpos, rvel;
oapiGetRelativePos(hvessel, GetHandle(), &rpos);
double distance = length(rpos);
oapiGetRelativeVel(hvessel, GetHandle(), &rvel);
// sprintf(oapiDebugString(), "distance %f rpos.z %f rvel.z %f", distance, rpos.z, rvel.z);
// if ((distance<1000) && (rpos.z>0) && (rvel.z<0))
if (jump==1)
{
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;
jump = 0;
v->DefSetStateEx(&vs_vessel);
}
}
}
}
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
return new WORMHOLE (hvessel, flightmodel);
}
DLLCLBK void ovcExit(VESSEL *vessel)
{
if (vessel) delete (WORMHOLE*)vessel;
}
// --------------------------------------------------------------
// Keyboard interface handler (buffered key events)
// --------------------------------------------------------------
int WORMHOLE::clbkConsumeBufferedKey(DWORD key, bool down, char *kstate)
{
// only process keydown events
if (!down)
return 0;
if (key == OAPI_KEY_K) // ATTACH
{
jump=1;
return 1;
}
return 0;
}
// ====================================================================
// clbkVisualCreated used to display UMMU initialisation message
// because oapiDebugString() doesn't work in clbkSetClassCap
// ====================================================================
void WORMHOLE::clbkVisualCreated (VISHANDLE vis, int refcount)
{
MainExternalMeshVisual = GetMesh(vis,0);
// We warn the user, in the case UMmu isn't installed it's a good idea to send a "oapiDebugString"
// Orbiter message, otherwise your addon will not be fully operational and user may not notice.
//(nobody read doc, you may be the only one, if you read this send me a postcard ;)
}
// ==============================================================
// Visual destroyed
// ==============================================================
void WORMHOLE::clbkVisualDestroyed (VISHANDLE vis, int refcount)
{
MainExternalMeshVisual = 0;
}
BEGIN_SHIPS
Gate_A:WORMHOLE
STATUS Orbiting Earth
RPOS 3001430.11 -0.02 6332855.27
RVEL -6815.014 -0.000 3229.950
AROT 0.00 -0.00 0.00
AFCMODE 7
NAVFREQ 0 0
XPDR 0
END
Gate_B:WORMHOLE
STATUS Orbiting Moon
RPOS 1373379.71 1280906.25 160751.21
RVEL 1076.083 1059.868 51.698
HEADING 66.83
AFCMODE 7
NAVFREQ 0 0
XPDR 0
END
dg:Deltaglider
STATUS Orbiting Earth
RPOS 3001430.11 -0.02 6332855.27
RVEL -6815.014 -0.000 3229.950
AROT 180.00 23.87 180.00
AFCMODE 7
PRPLEVEL 0:0.986777 1:1.000000
THLEVEL 0:0.027778 1:0.027778
NAVFREQ 0 0 0 0
XPDR 0
AAP 0:0 0:0 0:0
END
END_SHIPS