General Question simple vc help

I gutted the code. But still nothing happens when I click
Code:
// ==============================================================
//                 ORBITER MODULE: TALON
//                  Part of the ORBITER SDK
//          Copyright (C) 2002-2004 Martin Schweiger
//                   All rights reserved
//
// TALON.cpp
// Control module for TALON vessel class
//

// ==============================================================
//#define ORBITER_MODULE
#include "orbitersdk.h"
#include "TALON.h"

#include <stdio.h>
#include <fstream>

#define LOADBMP(id) (LoadBitmap (g_Param.hDLL, MAKEINTRESOURCE (id)))

//BOOL CALLBACK ATHLETE_TEST_DlgProc(HWND, UINT, WPARAM, LPARAM);
//
//
//







void TALON::clbkPostCreation(void)
{
	
//	SetAnimation(anim_JOINT0, 0.0);
//	SetAnimation(anim_JOINT1, 0.0);
//	SetAnimation(anim_JOINT2, .5);
//	SetAnimation(anim_JOINT3, 0.0202);
//	SetAnimation(anim_JOINT4, 0.0);
//	SetAnimation(anim_JOINT5, 0.5279);
//	SetAnimation(anim_JOINT6, -0.8352);
//	SetAnimation(anim_JOINT7, 1.0);
	//PANELEXT_proc = 1;
	//PANEL_proc = 1;
}








// Constructor


// --------------------------------------------------------------
// Destructor
// --------------------------------------------------------------
TALON::~TALON() {

}




TALON::TALON (OBJHANDLE hObj, int fmodel)
: VESSEL3 (hObj, fmodel)


{

	mode = 0;
	BEACON = 0;
	ofs = _V(0, 0, 0);
	string[0] = 0;

	tex_rcs = oapiRegisterExhaustTexture("exhaust_crcs");
	tex_main = oapiRegisterExhaustTexture("exhaust_crcs");


	








}


void TALON::clbkSetClassCaps (FILEHANDLE cfg)
//void TALON::SetTransporter()
{
	// physical specs
		SetSize (3);
	SetEmptyMass (500.0);
	SetCW (0.09, 0.09, 2, 1.4);
	SetWingAspect (0.7);
	SetWingEffectiveness (2.5);
    SetCrossSections (_V(710.54,2159.34,207.95));
    SetSurfaceFrictionCoeff (0.07, 0.3);
    SetRotDrag (_V(0.10,0.13,0.04));
    SetMaxWheelbrakeForce (5e5);
    SetPMI (_V(743.84,872.38,148.19));
	SetTrimScale (0.1);
	SetCameraOffset(_V(-0.41, 1.6, 2.21));
	
	SetTouchdownPoints  (_V(0,.0001,10), _V(-1.6,.0001,-10), _V(1.6,.0001,-10));; 
EnableTransponder (true);

//SetMeshVisibilityMode (AddMesh (oapiLoadMeshGlobal ("TALON")), MESHVIS_ALWAYS ); //Main ship mesh



	// Call clbkSetClassCaps_UMMU and select a member



SetMeshVisibilityMode(meshi_Vessel = AddMesh(meshhg_Vessel = oapiLoadMeshGlobal("TALON\\TALON_VCNEW3")), MESHVIS_ALWAYS);
SetMeshVisibilityMode(meshi_VC1 = AddMesh(meshhg_Vessel), MESHVIS_VC);
SetMeshVisibilityMode(meshi_VC = AddMesh(meshhg_VC = oapiLoadMeshGlobal("TALON\\TALON_VCNEW3")), MESHVIS_VC);


}

// =======================================================
// UMMU Class Caps
// =======================================================








void TALON::clbkPostStep(double simt, double simdt, double mjd)
{

}





// --------------------------------------------------------------
// Keyboard interface handler (buffered key events)
// --------------------------------------------------------------
int TALON::clbkConsumeBufferedKey(DWORD key, bool down, char *kstate)
{
	
	if (!down) return 0; 
	return 0;
}
// ====================================================================
// clbkVisualCreated used to display UMMU initialisation message 
// because oapiDebugString() doesn't work in clbkSetClassCap
// ====================================================================
void TALON::clbkVisualCreated(VISHANDLE vis, int refcount)
{
	//MainExternalMeshVisual = GetMesh(vis, 0);

}
// ==============================================================
// Visual destroyed
// ==============================================================
void TALON::clbkVisualDestroyed(VISHANDLE vis, int refcount)
{
	//MainExternalMeshVisual = 0;
}



void TALON::clbkSaveState(FILEHANDLE scn)
{
	{
		char cbuf[256];


		

	
		// ORBITER, default vessel parameters
		SaveDefaultState(scn);

	}

}
void TALON::clbkLoadStateEx (FILEHANDLE scn, void *status)
{
	char *line;
	int value;
	while (oapiReadScenario_nextline(scn, line))
	{


		





		ParseScenarioLineEx(line, status);
	}

	
}





	

bool TALON::clbkLoadGenericCockpit() {
	return true;
}

bool TALON::clbkLoadVC(int id)
{

	SURFHANDLE const tex1 = oapiGetTextureHandle(meshhg_VC, 5);


		//switch (id) {
	//	case 0: // commander position
	SetCameraOffset(_V(-0.41, 1.6, 2.241));
	SetCameraDefaultDirection(_V(0, 0, 1));
	SetCameraMovement(_V(0, 0, 0.2), 0, 0, _V(-0.3, 0, 0), 75 * RAD, -5 * RAD, _V(0.3, 0, 0), -20 * RAD, -27 * RAD);
	oapiVCSetNeighbours(-1, 1, -1, 2);



	oapiVCRegisterArea(AID_NAVMODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
	oapiVCSetAreaClickmode_Quadrilateral(AID_NAVMODE,
		_V(-.1462004f, 1.51039f, 2.844f),//2.822
		_V(.1471258f, 1.509298f, 2.844f),
		_V(-.1440155f, 1.492364f, 2.844f),
		_V(.1465795f, 1.490726f, 2.844f));

	//}

	//return HandleLoadVC(id);

//}

return true;

}




bool TALON::clbkVCMouseEvent(int id, int event, VECTOR3 &p)
{

	switch (id) {


	case AID_NAVMODE:
		ToggleNavmode(NAVMODE_KILLROT);
		return true;

	}
	return false;
}


	
	// --------------------------------------------------------------
	// Respond to virtual cockpit mouse events
	// --------------------------------------------------------------
	

	// --------------------------------------------------------------
	// Respond to virtual cockpit area redraw requests
	// --------------------------------------------------------------
	bool TALON::clbkVCRedrawEvent(int id, int event, SURFHANDLE surf)
	{
		return false;
	} // End "LM::clbkVCRedrawEvent"


	DLLCLBK VESSEL *ovcInit(OBJHANDLE hvessel, int flightmodel)
	{
		return new TALON(hvessel, flightmodel);
	}

	// --------------------------------------------------------------
	// Vessel cleanup
	// --------------------------------------------------------------
	DLLCLBK void ovcExit(VESSEL *vessel)
	{
		if (vessel) delete (TALON*)vessel;
	}
 
In my opinion, you have a coordinate problem, usually the X coordinates are the same in the first group of two and change the Y coordinates, and the second group of two.

The Z coordinates are all equal, of course if the area does not have strange inclinations.

This is the code I use and it works.
Code:
oapiVCRegisterArea (AID_KILLROT, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
		oapiVCSetAreaClickmode_Quadrilateral (AID_KILLROT, _V(-1.084592,1.19326,4.965), _V(-1.084592,1.162672,4.965), _V(-1.023989,1.19326,4.965), _V(-1.023989,1.162672,4.965));

1 _V(-1.084592,1.19326,4.965),
2 _V(-1.084592,1.162672,4.965),
3 _V(-1.023989,1.19326,4.965),
4 _V(-1.023989,1.162672,4.965)

I3ULLFI.jpg


And leave the comment in your code:

oapiVCRegisterArea (AID_NAVMODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
oapiVCSetAreaClickmode_Quadrilateral (AID_NAVMODE,
_V(-.1462004f, 1.51039f, 2.844f),//2.822
_V(.1471258f, 1.509298f, 2.844f),
_V(-.1440155f, 1.492364f, 2.844f),
_V(.1465795f, 1.490726f, 2.844f));
:hello:
 
Thanks.

So I did this:
Code:
bool TALON::clbkLoadVC(int id)
{

	SURFHANDLE const tex1 = oapiGetTextureHandle(meshhg_VC, 5);


		//switch (id) {
	//	case 0: // commander position
	SetCameraOffset(_V(-0.41, 1.6, 2.241));
	SetCameraDefaultDirection(_V(0, 0, 1));
	SetCameraMovement(_V(0, 0, 0.2), 0, 0, _V(-0.3, 0, 0), 75 * RAD, -5 * RAD, _V(0.3, 0, 0), -20 * RAD, -27 * RAD);
	oapiVCSetNeighbours(-1, 1, -1, 2);



	oapiVCRegisterArea(AID_NAVMODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
	oapiVCSetAreaClickmode_Quadrilateral(AID_NAVMODE, _V(-1.084592, 1.19326, 4.965), _V(-1.084592, 1.162672, 4.965), _V(-1.023989, 1.19326, 4.965), _V(-1.023989, 1.162672, 4.965));

	//}

	//return HandleLoadVC(id);

//}

return true;

}




bool TALON::clbkVCMouseEvent(int id, int event, VECTOR3 &p)
{

	switch (id) {


	case AID_NAVMODE:
		ToggleNavmode(NAVMODE_KILLROT);
		return true;

	}
	return false;
}


h:

#define AID_NAVMODE 1
But I get nothing. So how did you calculate the corners?
 
Thanks. I made a mesh group. A rectangle that is black as a background. That is where I got my coordinates. I included the mesh in an earlier post if you want to confirm or not by cooridnates.

So upper left corner. So x, y will change

---------- Post added at 03:47 PM ---------- Previous post was at 01:28 PM ----------

Code:
bool TALON::clbkLoadVC(int id)
{

	SURFHANDLE const tex1 = oapiGetTextureHandle(meshhg_VC, 5);


		//switch (id) {
	//	case 0: // commander position
	SetCameraOffset(_V(-0.41, 1.6, 2.241));
	SetCameraDefaultDirection(_V(0, 0, 1));
	SetCameraMovement(_V(0, 0, 0.2), 0, 0, _V(-0.3, 0, 0), 75 * RAD, -5 * RAD, _V(0.3, 0, 0), -20 * RAD, -27 * RAD);
	oapiVCSetNeighbours(-1, 1, -1, 2);



	oapiVCRegisterArea(AID_NAVMODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
	oapiVCSetAreaClickmode_Quadrilateral(AID_NAVMODE, _V(-.1446553,  1.511254, 2.824909), _V(.1521383, 1.511254, 2.824909), _V(-.1446553, 1.487942, 2.824909), _V(.1517904, 1.487942, 2.824909));

	//}

	//return HandleLoadVC(id);

//}

return true;

}




bool TALON::clbkVCMouseEvent(int id, int event, VECTOR3 &p)
{

	switch (id) {


	case AID_NAVMODE:
		ToggleNavmode(NAVMODE_KILLROT);
		return true;

	}
	return false;
}
luBUqWy.jpg
 
Thanks.
Code:
bool TALON::clbkLoadVC(int id)
{

	SURFHANDLE const tex1 = oapiGetTextureHandle(meshhg_VC, 5);


		//switch (id) {
	//	case 0: // commander position
	SetCameraOffset(_V(-0.41, 1.6, 2.241));
	SetCameraDefaultDirection(_V(0, 0, 1));
	SetCameraMovement(_V(0, 0, 0.2), 0, 0, _V(-0.3, 0, 0), 75 * RAD, -5 * RAD, _V(0.3, 0, 0), -20 * RAD, -27 * RAD);
	oapiVCSetNeighbours(-1, 1, -1, 2);



	oapiVCRegisterArea(AID_NAVMODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
	oapiVCSetAreaClickmode_Quadrilateral(AID_NAVMODE, _V(-.1446553, 1.511254, 2.824909), _V(-.1446553, 1.487942, 2.824909), _V(.1521383, 1.511254, 2.824909), _V(.1517904, 1.487942, 2.824909));

	//}

	//return HandleLoadVC(id);

//}

return true;

}

I get nothing when I click. No break when I click that area
 
Last edited:
Code:
bool TALON::clbkLoadVC(int id)
{	


		switch (id) {
		case 0: // commander position
	SetCameraOffset(_V(-0.41, 1.6, 2.241));
	SetCameraDefaultDirection(_V(0, 0, 1));
	SetCameraMovement(_V(0, 0, 0.2), 0, 0, _V(-0.3, 0, 0), 75 * RAD, -5 * RAD, _V(0.3, 0, 0), -20 * RAD, -27 * RAD);
	//oapiVCSetNeighbours(-1, 1, -1, 2);



	oapiVCRegisterArea(AID_NAVMODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
	oapiVCSetAreaClickmode_Quadrilateral(AID_NAVMODE, _V(-.1446553, 1.511254, 2.824909), _V(-.1446553, 1.487942, 2.824909), _V(.1521383, 1.511254, 2.824909), _V(.1517904, 1.487942, 2.824909));

	    }

	

return true;

}
 
Thanks.
Code:
bool TALON::clbkLoadGenericCockpit() {
	return true;
}

bool TALON::clbkLoadVC(int id)
{


	switch (id) {
	case 0: // commander position
		SetCameraOffset(_V(-0.41, 1.6, 2.241));
		SetCameraDefaultDirection(_V(0, 0, 1));
		SetCameraMovement(_V(0, 0, 0.2), 0, 0, _V(-0.3, 0, 0), 75 * RAD, -5 * RAD, _V(0.3, 0, 0), -20 * RAD, -27 * RAD);
		//oapiVCSetNeighbours(-1, 1, -1, 2);



		oapiVCRegisterArea(AID_NAVMODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
		oapiVCSetAreaClickmode_Quadrilateral(AID_NAVMODE, _V(-.1446553, 1.511254, 2.824909), _V(-.1446553, 1.487942, 2.824909), _V(.1521383, 1.511254, 2.824909), _V(.1517904, 1.487942, 2.824909));

	}



	return true;

}


bool TALON::clbkVCMouseEvent(int id, int event, VECTOR3 &p)
{

	switch (id) {


	case AID_NAVMODE:
		ToggleNavmode(NAVMODE_KILLROT);
		return true;

	}
	return false;
}

Nothing.
I put a break here and it doesn't break
Code:
bool TALON::clbkVCMouseEvent(int id, int event, VECTOR3 &p)
{

	switch (id) {


	case AID_NAVMODE:   //BREAK
		ToggleNavmode(NAVMODE_KILLROT);
		return true;

	}
	return false;
}
 
Not sure. I guess I need to see where the mouse click is hitting.

My guess it is not in the area?

Any ideas:)
 
Good. How will you find out?
Excellent question:)

Not sure.

At one time I thought about making the dimension larger so it covered an larger area.

I guess there is some code that detects when a mouse click is detected and shows where it is?
 
One hint from my side: a "default:" statement at the end of a switch block allows you to find any values in the switch not matching to a case. Logging those unmatched values as logic error could give you a clue if your understanding of the interfaces in your program is wrong.
 
The same
Code:
		oapiVCSetAreaClickmode_Quadrilateral(AID_NAVMODE, _V(-10.1446553, 10.511254, 2.824909), _V(10.1446553, 10.487942, 2.824909), _V(-10.1521383, -10.511254, 2.824909), _V(10.1517904, 10.487942, 2.824909));





Code:
OAPIFUNC void       oapiVCSetAreaClickmode_Spherical (int id, const VECTOR3 &cnt, double rad);

	/**
	* \brief Associate a quadrilateral region in the virtual cockpit with a registered area to receive mouse events.
	* \param id area identifier (as specified during area registration)
	* \param p1 top left corner of region
	* \param p2 top right corner
	* \param p3 bottom left corner
	* \param p4 bottom right corner
	* \note This function will trigger mouse events when the user clicks within the
	*  projection of the quadrilateral region on the render window. The mouse
	*  event handler will receive the relative position within the area at which the
	*  mouse event occurred, where the top left corner has coordinates (0,0), and
	*  the bottom right corner has coordinates (1,1). 
	* \note The area can define any flat quadrilateral in space. It is not limited to
	*  rectangles, but all 4 points should be in the same plane.
Code:
bool TALON::clbkLoadVC(int id)
{


	switch (id) {
	case 0: // commander position
		SetCameraOffset(_V(-0.41, 1.6, 2.241));
		SetCameraDefaultDirection(_V(0, 0, 1));
		SetCameraMovement(_V(0, 0, 0.2), 0, 0, _V(-0.3, 0, 0), 75 * RAD, -5 * RAD, _V(0.3, 0, 0), -20 * RAD, -27 * RAD);
		//oapiVCSetNeighbours(-1, 1, -1, 2);



		oapiVCRegisterArea(AID_NAVMODE, PANEL_REDRAW_NEVER, PANEL_MOUSE_LBDOWN);
		oapiVCSetAreaClickmode_Quadrilateral(AID_NAVMODE, _V(-10.1446553, 10.511254, 2.824909), _V(10.1446553, 10.487942, 2.824909), _V(-10.1521383, -10.511254, 2.824909), _V(10.1517904, 10.487942, 2.824909));

	}



	return true;

}
 
Back
Top