Request Gateway transport system

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,056
Reaction score
1,756
Points
203
Location
Langendernbach
Thanks. I was looking at the B5 jump gate.

He had a MFD.

Not sure what values I would look at.

As I understand the code. It gets info on the vessels. And moves the vessel from Gate_A to Gate_B if Jump =1.

For example you could care about the position of the vessel relative to your gate. Or if the jump had been triggered. Which gates are connected.

such things.

Jump=1 makes sense for Babylon 5, because jump points had to be opened by a jump drive (Unless you are a Shadow)
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Thanks.

Well for what I need there is just 2 gates.

Since the distance to the gate isn't the trigger yet. I want to see if you switch to the gate vessel and press K (Jump=1) then it should move any other vessel to the other gate position.
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,462
Reaction score
1,715
Points
203
Location
between the planets
So this is what I have for code. But when I press K to jump it nothing happens.

Well, as far as I can see you don't actually apply the state to the vessel...
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Thanks
But isn't want this does:
Code:
				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);
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,462
Reaction score
1,715
Points
203
Location
between the planets
Ah, yes, it is. There was so much empty space between the previous line of code and this that I didn't see it.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Not sure how check to see what is going on.

Basically the whole process ( getting Vessel info and replacing it with Next Gate info). Then I can see if dock/attached vehicles can go thru.

---------- Post added at 05:18 PM ---------- Previous post was at 10:08 AM ----------

Well I went back to Fred's code. Except added if Jump==1 then do something.
Now when I press K and focus on the DG I get a CTD.
Code:
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);

			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;






				v->DefSetStateEx(&vs_vessel);
			}
		}
	}


}

Weird it puts the dg and GAte_A on the SUN

---------- Post added at 07:41 PM ---------- Previous post was at 05:18 PM ----------

Here is the quicksave before pressing k:
Code:
BEGIN_DESC
Orbiter saved state at T = 6
END_DESC

BEGIN_ENVIRONMENT
  System Sol
  Date MJD 51981.8172503449
END_ENVIRONMENT

BEGIN_FOCUS
  Ship Gate_A
END_FOCUS

BEGIN_CAMERA
  TARGET Gate_A
  MODE Extern
  POS 127.83 34.41 -7.16
  TRACKMODE TargetRelative
  FOV 60.00
END_CAMERA

BEGIN_HUD
  TYPE Surface
END_HUD

BEGIN_SHIPS
Gate_A:WORMHOLE
  STATUS Orbiting Earth
  RPOS 2961984.49 -0.02 6351400.34
  RVEL -6834.971 -0.000 3187.501
  AROT 0.00 -0.00 0.00
  AFCMODE 7
  NAVFREQ 0 0
  XPDR 0
END
Gate_B:WORMHOLE
  STATUS Orbiting Moon
  RPOS 1379582.27 1287016.21 161048.00
  RVEL 1070.299 1054.472 51.022
  AROT 0.00 -0.00 0.00
  AFCMODE 7
  NAVFREQ 0 0
  XPDR 0
END
dg:Deltaglider
  STATUS Orbiting Earth
  RPOS 2961982.02 -0.02 6351394.76
  RVEL -6835.826 -0.000 3185.570
  AROT 180.00 23.87 180.00
  AFCMODE 7
  PRPLEVEL 0:0.986677 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

BEGIN_ReFuelMFD
  SCENARIO_TREE 
    NAMED Computers
    END_NODE 
  END_NODE 
END
and then after pressing K:
Code:
BEGIN_DESC
Orbiter saved state at T = 18
END_DESC

BEGIN_ENVIRONMENT
  System Sol
  Date MJD 51981.8173889539
END_ENVIRONMENT

BEGIN_FOCUS
  Ship Gate_A
END_FOCUS

BEGIN_CAMERA
  TARGET Gate_A
  MODE Extern
  POS 127.83 34.41 -7.16
  TRACKMODE TargetRelative
  FOV 60.00
END_CAMERA

BEGIN_HUD
  TYPE Surface
END_HUD

BEGIN_SHIPS
Gate_A:WORMHOLE
  STATUS Orbiting Earth
  RPOS 2879886.44 -0.02 6389044.70
  RVEL -6875.482 -0.000 3099.152
  AROT 0.00 -0.00 0.00
  AFCMODE 7
  NAVFREQ 0 0
  XPDR 0
END
Gate_B:WORMHOLE
  STATUS Orbiting Sun
  RPOS 2835990529933697.50 327581488164294.87 -1249300167210184.50
  RVEL 2610732405096220200000000000.000 301562222240178370000000000.000 -1150070987384147500000000000.000
  AROT 0.00 -0.00 0.00
  AFCMODE 7
  NAVFREQ 0 0
  XPDR 0
END
dg:Deltaglider
  STATUS Orbiting Sun
  RPOS 2835990529933697.50 327581488164294.87 -1249300167210184.50
  RVEL 5221464810368949500000000000.000 603124444425226600000000000.000 -2300141974382063300000000000.000
  AROT 0.00 -0.00 0.00
  AFCMODE 7
  PRPLEVEL 0:0.986471 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

BEGIN_ReFuelMFD
  SCENARIO_TREE 
    NAMED Computers
    END_NODE 
  END_NODE 
END
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Thanks. makes sense.
Code:
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);

			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");

				//which gate A or B
				if (strcmp(myname, GateA) == 0)
				{
					h_other_gate = oapiGetVesselByName("Gate_B");
				}
				else{
					h_other_gate = oapiGetVesselByName("Gate_A");
				}
				//get other gate info
				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;
				//make vessel then same as other gate
				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);
			}
		}
	}

}
But not sure why the vessel state info is invalid.

---------- Post added at 04:58 AM ---------- Previous post was at 04:11 AM ----------

Well I redid the code and this works.
Code:
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);

			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");

				//which gate A or B
				if (strcmp(myname, GateA) == 0)
				{
					h_other_gate = oapiGetVesselByName("Gate_B");
				}
				else{
					h_other_gate = oapiGetVesselByName("Gate_A");
				}
				//get other gate info
				VESSEL *v_other_gate;
				v_other_gate = oapiGetVesselInterface(h_other_gate);
				v_other_gate->GetStatusEx(&vs_other_gate);
				//make vessel then same as 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);
				//jump = 0; //stop jump
			}
		}
	}

}
But I noticed that the vessel was changing. I think because it is continue to jump til you switch focus.

But If I uncomment the jump=0 end the jump. it doesn't jump.

docked vessels do well.


Well if I focus on Gate B and press K it moves the vessel to Gate A. But then Gate A doesn't move it to Gate B.

Seeing if it is close to gate might be an issue for me
 
Last edited:

toto76math

New member
Joined
May 12, 2016
Messages
12
Reaction score
1
Points
3
May i ask you for help? i have issues with 4th rock Skylab_B addon. I cannot play all the scenarios about the Soyuz visiting the station,because when i load it, i can see only a few seconds, and hearing some Russian language,before the game goes silent and a pop up says "Orbiter.exe a cessé de fonctionner". (Since i am French,i have programmed my computer to speak French"). I have tinkered a bit and reduced the number of lines in error report but

>>> ERROR: Invalid DDS signature
>>> [ReadDDSSurface | .\Texture.cpp | 211]
---------------------------------------------------------------
ERROR: TextureManager::LoadTexture|ReadDDSSurface (code: -2147467259)
---------------------------------------------------------------
>>> ERROR: Missing texture: AAPO\white.dds
>>> [TextureManager::AcquireTexture | .\Texture.cpp | 750]

remains,whatever i try. Do you know a procedure to fix that?

Otherwise,due to a more powerful computer,i really enjoy this game!:cool:
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
This is off topic. But Do you have that AAPO\white texture? If you pm me I can take a look

So on the gateway. That way I think it should work is:

Focus on Gate_A. press K (Jump=1)
See which gate you are focused on.
In this case get Gate_B info and then replaced the vessels state with Gate_b
Then Jump=0. So it is a one time event.
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,462
Reaction score
1,715
Points
203
Location
between the planets
Trying to make sense of this. I get what you're trying to do , I think, and I can't spot an obvious error, but there's some things I'm not quite clear about.

First, could you explain what you're doing in this code?

Code:
//make vessel then same as other gate
				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;

Second, since it seems to work from one gate to another but not vice versa, are you certain that the condition:
Code:
if (strcmp(myname, GateA) == 0)
				{
					h_other_gate = oapiGetVesselByName("Gate_B");
				}
				else{
					h_other_gate = oapiGetVesselByName("Gate_A");
				}
evaluates correctly? (I can't see anything obviously wrong with it, but since this is a deciding point it would be prudent to set a breakpoint and see if it is traversed correctly in both cases).

Finally, could you post the header file of the class?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Thanks.
Fred18 wrote the code
https://www.orbiter-forum.com/showthread.php?p=554575&postcount=21
But I comment that out. But it looked like it was setting the Vessel to the gates velocity. We never could get the distance think working.

Well after testing it seems to work once each way and then stops working.

This is what I have for the cpp and h:
cpp:
Code:
// ==============================================================
//                 ORBITER MODULE: WORMHOLE
//                  Part of the ORBITER SDK
//          Copyright (C) 2002-2004 Martin Schweiger
//                   All rights reserved
//
// WORMHOLE.cpp
// Control module for WORMHOLE vessel class
//
// Notes:
// This is an example for a "minimal" vessel implementation which
// only overloads the clbkSetClassCaps method to define vessel
// capabilities and otherwise uses the default VESSEL class
// behaviour.
// ==============================================================

#define ORBITER_MODULE
#include "orbitersdk.h"
#include "WORMHOLE.h"
VISHANDLE MainExternalMeshVisual = 0;




void WORMHOLE::clbkPostCreation (void)

{

}

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);

			if (jump==1)  //do the jump
			{

				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");

				//which gate A or B
				if (strcmp(myname, GateA) == 0)  // if myname is Gate_A  then h_other_gate is Gate_B else h_other_gate is Gate_A
				{
					h_other_gate = oapiGetVesselByName("Gate_B");
				}
				else{
					h_other_gate = oapiGetVesselByName("Gate_A");
				}
				//get other gate info
				VESSEL *v_other_gate;
				v_other_gate = oapiGetVesselInterface(h_other_gate);
				v_other_gate->GetStatusEx(&vs_other_gate);
				//make vessel then same as 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);
				//jump = 0; //stop jump
			}
		}
	}

}
 








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;
	}
	if (key == OAPI_KEY_J) // ATTACH
	{

		jump = 0;
		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;	
}

h:
Code:
// ==============================================================
//                 ORBITER MODULE: LSWORMHOLE
//                  Part of the ORBITER SDK
//          Copyright (C) 2002-2004 Martin Schweiger
//                   All rights reserved
//
// LSWORMHOLE.cpp
// Control module for LSWORMHOLE vessel class
//
// Notes:
// This is an example for a "minimal" vessel implementation which
// only overloads the clbkSetClassCaps method to define vessel
// capabilities and otherwise uses the default VESSEL class
// behaviour.
// ==============================================================



#include "orbitersdk.h"



class WORMHOLE: public VESSEL2 {
public:
	WORMHOLE (OBJHANDLE hVessel, int flightmodel);
	//	: VESSEL2 (hVessel, flightmodel) {}
     void clbkPostCreation (void);
	void clbkSetClassCaps (FILEHANDLE cfg);
	int clbkConsumeBufferedKey(DWORD key, bool down, char *kstate);
	void clbkVisualCreated (VISHANDLE vis, int refcount);
	void clbkVisualDestroyed (VISHANDLE vis, int refcount);
	void clbkPostStep (double simtt, double simdt, double mjd);

   
    
private: 
UINT iMeshMAIN;
int jump;
double distance;


};

Trying to make sense of this. I get what you're trying to do , I think, and I can't spot an obvious error, but there's some things I'm not quite clear about.

First, could you explain what you're doing in this code?

Code:
//make vessel then same as other gate
				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;

Second, since it seems to work from one gate to another but not vice versa, are you certain that the condition:
Code:
if (strcmp(myname, GateA) == 0)
				{
					h_other_gate = oapiGetVesselByName("Gate_B");
				}
				else{
					h_other_gate = oapiGetVesselByName("Gate_A");
				}
evaluates correctly? (I can't see anything obviously wrong with it, but since this is a deciding point it would be prudent to set a breakpoint and see if it is traversed correctly in both cases).

Finally, could you post the header file of the class?
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,462
Reaction score
1,715
Points
203
Location
between the planets
But it looked like it was setting the Vessel to the gates velocity. We never could get the distance think working.

Doesn't look like that to me at all. For that you'd simply have to apply the gateways velocity vector without transformation. On the quick and dirty, it looks like the code is intended to make the relative velocity of the vessel to the reference body the relative velocity to the gateway.

Another thing I can tell you is that you should be checking for down == false, not vice versa. If you're checking for down without any safety measures, you'll get multiple keypresses most of the time.

I can't see anything that would prevent the whole thing from working multiple times on a quick glance though, so that's a bit strange. I assume you have set breakpoints and traced the paths? The code is executed as expected?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Thanks.

Not sure what you mean here?
Another thing I can tell you is that you should be checking for down == false, not vice versa. If you're checking for down without any safety measures, you'll get multiple keypresses most of the time.

I will try it in the debugger and set a breakpoint to see what is going on.

It would nice if it worked when the vessel was x distance from the center of the hole
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,462
Reaction score
1,715
Points
203
Location
between the planets
It would nice if it worked when the vessel was x distance from the center of the hole

I don't see a problem with that. You already have the distance, all you need is another check.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Thank
So I went back to the original code:
Code:
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 %0.4f", distance);


			if ((distance<2) && (rpos.z>0) && (rvel.z<0))
			{

				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);
			}
		}
	}


}

And I placed the DG at the same location as Gate_A
Code:
BEGIN_SHIPS
Gate_A:WORMHOLE
  STATUS Orbiting Earth
  RPOS 2452944.74 -0.02 6564807.71
  RVEL -7064.626 -0.000 2639.705
  AROT 0.00 -0.00 0.00
  AFCMODE 7
  NAVFREQ 0 0
  XPDR 0
END
Gate_B:WORMHOLE
  STATUS Orbiting Moon
  RPOS 1455365.04 1361810.35 164486.05
  RVEL 1001.328 990.032 43.099
  AROT 0.00 -0.00 0.00
  AFCMODE 7
  NAVFREQ 0 0
  XPDR 0
END
dg:Deltaglider
  STATUS Orbiting Earth
  RPOS 2452944.74 -0.02 6564807.71
  RVEL -7064.626 -0.000 2639.705
  AROT 0.00 -0.00 0.00
  AFCMODE 7
  PRPLEVEL 0:0.985416 1:1.000000
  THLEVEL 0:0.0 1:0.0
  NAVFREQ 0 0 0 0
  XPDR 0
  AAP 0:0 0:0 0:0
END
END_SHIPS

But look at the distance:
syrYFks.jpg
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Not sure if this is what you are asking for:
- rpos {data=0x00aefbc4 {1.2372870705478169e-062, 1.562538575694e-314#DEN, -6.4627346403884268e+288} x=1.2372870705478169e-062 ...} VECTOR3


distance 16636966455.034630 double
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,462
Reaction score
1,715
Points
203
Location
between the planets
- rpos {data=0x00aefbc4 {1.2372870705478169e-062, 1.562538575694e-314#DEN, -6.4627346403884268e+288} x=1.2372870705478169e-062 ...}
VECTOR3

Are you sure this is the value of rpos AFTER oapiGetRelativePos has been applied, not before?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
7,609
Reaction score
1,754
Points
203
Location
Dallas, TX
Well I ran the debugger again and got this;
- rpos {data=0x00aefbc4 {-1.0083114138695043e+184, 5.6088503154155600e-224, 4.3699285199173170e-277} x=-1.0083114138695043e+184 ...} VECTOR3
:
and then this:
+ rpos {data=0x00aefbc4 {-3.0167094274102534e-307, 1.7107501104333495e-052, -8.8521892572144229e+256} x=-3.0167094274102534e-307 ...} VECTOR3
Ywad5yv.jpg
 
Top