Project Westcott RPE (Upgrade)

That works nicely, i'll keep that there til I remember how it used to work!
 
Last edited:
Got to the bottom of page 1 :
http://www.orbiter-forum.com/blog.php?b=574
and it compiles and links ok, dosen't show my panel of course, no surprise there.

Don't know what I've left out, but I have started to use the debugger. Set a breakpoint after the oapiLoadTexture
function, and I get this:

http://i89.photobucket.com/albums/k207/Notebook_04/Westcott_P2.jpg

Guess its not loading my panel?
("Aardvark.dds" dosen't exist, I was using that to see if it CTD, it dosen't, another puzzle?)

EDIT : Basic error....was't using the F8 to change panels, so no change in panels...Saturday mornng, thats my excuse.
Working now.

All input appreciated
N.
 
Last edited:
Thanks Orb.
How could I tell if a texture was loaded in that function(besides it not appearing in Orbiter)?

N.
 
The value of Control_Bunker::panel2dtex would be different than 0 (NULL).
 
Makes sense, thanks again.

N.
 
As its a Sunday, no questions today.

A small query..., this is the working panel with my modified MFDTemplate on it.
http://s89.photobucket.com/albums/k207/Notebook_04/?action=view&current=Westcott_1.mp4

I now have 2 (.dll) files, Control_Bunker.dll and MFDTemplate.dll
Have't put them as two projects in one solution, that would just confuse things at the moment.

With MFDTemplate, can it be renamed? If its left as that title, it will overwrite the default Orbiter install, can't do that.
If it is renamed, how do I enable it?
MFDTemplate has an entry in the Modules tab, does this enable any "derived" MFD2 class?

N.
 
Apologies for dragging this up, but made some progress...

Renamed the Solotion/Projects and .cpp/.h files, and MyMFDTemplate now appears in the Modules Tab under the default MFD Template entry:

http://i89.photobucket.com/albums/k207/Notebook_04/MyMFDTemplate.png

Happy that its appeared, but confused how it got there. Is there something in the MyMFDTemplate that tells Orbiter its derived from MDFTemplate?


EDIT: had a think, and guessing its nothing to do with MFD Template deriving MyMFDTemplate. Looked at a clean install of Orbiter and the "miscellaneous" entry in the Modules tab isn't there.

Was this generated when I compiled the MFD Template in SDK\Samples?
Is this what Orbiter does for all new.dll it finds in \Orbiter\Modules\Plugin?
All input appreciated.

N.
 
Last edited:
More apologies for dragging this up again...

Been following Hlynkacq's tutorials, and inspired to have another go!
http://www.orbiter-forum.com/showthread.php?t=29969&page=3

Starting again using the section 12, #35 onward.

This is my P2TestCell.dll, modified to follow Hlynkacq Virtual Cockpit tutorial.

P2TestCell.cpp

Code:
// ==============================================================
//                 ORBITER MODULE: P2TestCell
//                  Part of the ORBITER SDK
//          Copyright (C) 2002-2004 Martin Schweiger
//                   All rights reserved
//
// P2TestCell.cpp
// Control module for P2TestCell 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 STRICT
#define ORBITER_MODULE

#include "orbitersdk.h"
#include "P2TestCell.h"



P2TestCell::P2TestCell (OBJHANDLE hVessel, int flightmodel)
: VESSEL3 (hVessel, flightmodel)
{
	mh_P2External		= oapiLoadMeshGlobal("P2TestCell");
	mh_P2Internal		= oapiLoadMeshGlobal("P2TestCellInterior");

}

P2TestCell::~P2TestCell ()
{
}


// ==============================================================
// Overloaded callback functions
// ==============================================================
	int id=0;
bool P2TestCell::clbkLoadVC(int id)
{
	SetCameraOffset (_V(0,1.5,0)); 
	SetCameraDefaultDirection (_V(0,0,1)); 
	SetCameraRotationRange (RAD*120, RAD*120, RAD*70, RAD*70); 
	SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0));
	return 0;
} // End "P2TestCell::clbkLoadVC"

// --------------------------------------------------------------
// Respond to virtual cockpit mouse events
// --------------------------------------------------------------
bool P2TestCell::clbkVCMouseEvent (int id, int event, VECTOR3 &p)
{
	return false;
}  End "P2TestCell::clbkVCMouseEvent"
// --------------------------------------------------------------
// Respond to virtual cockpit area redraw requests
// --------------------------------------------------------------
bool P2TestCell::clbkVCRedrawEvent (int id, int event, SURFHANDLE surf)
{
	return false;
} // End "P2TestCell::clbkVCRedrawEvent"
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
void P2TestCell::clbkSetClassCaps (FILEHANDLE cfg)
{
	THRUSTER_HANDLE (th_main);

		// physical vessel parameters
	SetSize (P2_SIZE);
	SetEmptyMass (P2_EMPTYMASS);
	SetPMI (P2_PMI);
	SetCrossSections (P2_CS);
	SetRotDrag (P2_RD);
	SetTouchdownPoints (P2_TDP[0], P2_TDP[1], P2_TDP[2]);


	// propellant resources
	PROPELLANT_HANDLE hpr = CreatePropellantResource (P2_FUELMASS);

	// main engine
	th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), P2_MAXMAINTH, hpr, P2_ISP);
	CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
	AddExhaust (th_main, 8, 1, _V(0,0.3,-4.35), _V(0,0,-1));

	PARTICLESTREAMSPEC contrail_main = {
		0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};
	PARTICLESTREAMSPEC exhaust_main = {
		0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main);
	AddExhaustStream (th_main, _V(0,0.3,-5), &exhaust_main);
	
	// camera parameters
	SetCameraOffset (_V(-0,0.8,0));

	// associate a mesh for the visual
	//AddMesh ("P2TestCell");
	mesh_P2External		= AddMesh (mh_P2External);
	mesh_P2Internal		= AddMesh (mh_P2Internal);

	SetMeshVisibilityMode (mesh_P2Internal, MESHVIS_VC);		// Set P2_Internal mesh to be visible in virtual cockpit view 
	
}

// ==============================================================
// API callback interface


// ==============================================================

// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
	return new P2TestCell (hvessel, flightmodel);
}

// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
DLLCLBK void ovcExit (VESSEL *vessel)
{
	if (vessel) delete (P2TestCell*)vessel;
}

P2TestCell.h

Code:
#include "orbitersdk.h"

// ==============================================================
// Some vessel parameters
// ==============================================================

const double  P2_SIZE       = 10.5;             // mean radius [m]
const VECTOR3 P2_CS         = {10.5,15.0,5.8}; // x,y,z cross sections [m^2]
const VECTOR3 P2_PMI        = {2.28,2.31,0.79};// principal moments of inertia (mass-normalised) [m^2]
const VECTOR3 P2_RD         = {0.025,0.025,0.02};//{0.05,0.1,0.05};  // rotation drag coefficients
const double  P2_EMPTYMASS  = 500.0;           // empty vessel mass [kg]
const double  P2_FUELMASS   = 750.0;           // max fuel mass [kg]
const double  P2_ISP        = 5e4;             // fuel-specific impulse [m/s]
//const VECTOR3 P2_TDP[3]     = {{0,-1.5,2},{-1,-1.5,-1.5},{1,-1.5,-1.5}}; // touchdown points [m]
const VECTOR3 P2_TDP[3]     = {{0,0.01,2},{-1,0.01,-1.5},{1,0.01,-1.5}}; // touchdown points [m]


const double  P2_MAXMAINTH  = 3e4;             


// ==============================================================
// P2TestCell class interface
// ==============================================================

class P2TestCell: public VESSEL3 {
public:
	P2TestCell (OBJHANDLE hVessel, int flightmodel);
	~P2TestCell ();
	void clbkSetClassCaps (FILEHANDLE cfg);

	int id;

	//meshes
	MESHHANDLE	mh_P2External, mh_P2Internal;
	UINT		mesh_P2External;
	UINT		mesh_P2Internal;

	bool	clbkLoadVC (int id);													// Load virtual cockpit mode
	bool	clbkVCMouseEvent (int id, int event, VECTOR3 &p);						// Respond to virtual cockpit mouse events
	bool	clbkVCRedrawEvent (int id, int event, SURFHANDLE surf);	


private:
	


};

It all compiles and link fine, and runs ok. Dosen't show the interior when I press F8 though?

It does switch to the VC mode, as the camera position changes.
I can't switch away from the VC once the cockpit view is changed.

In external view, zooming in shows the P2TestCell interior. I've tried fliping the normals for that mesh, dosent show either way.

All input appreciated.

N.
 
Changed "return 0" to "return true" in:

Code:
int id=0;
bool P2TestCell::clbkLoadVC(int id)
{
	SetCameraOffset (_V(0,1.5,0)); 
	SetCameraDefaultDirection (_V(0,0,1)); 
	SetCameraRotationRange (RAD*120, RAD*120, RAD*70, RAD*70); 
	SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0));
	return true;
} // End "P2TestCell::clbkLoadVC"

Now switches cockpit views, still no sign of an interior.

EDIT: switched the mesh to the inverted normals and now have a VC cockpit! Marvellous.



EDIT : for info, current external/internal view of the P3TestCell.

http://i89.photobucket.com/albums/k207/Notebook_04/13021316-37-40P2TestCell_zpsc5554415.jpg
http://i89.photobucket.com/albums/k207/Notebook_04/13021316-35-17P2TestCell_zps229d2676.jpg


N.
 
Last edited:
Plodding on with the VC.

Made the desk into a editable poly in 3dsMax, and detached a poly to be the group/mesh for the left MFD.

http://i89.photobucket.com/albums/k207/Notebook_04/13021511-41-37P2TestCell_zps1d1b9167.jpg

This is the mesh(edited for space saving):
Code:
MSHX1
GROUPS 2
LABEL Interior
MATERIAL 1
TEXTURE 1
GEOM 24 12 ; Interior
4.31395 0.01 2.82572 0.0 1.0 0.0 1.0 1.0
...lots of data
-4.31395 2.79545 -2.82572 0.0 0.0 1.0 0.0 0.0
2 3 0
1 0 3
5 7 4
6 4 7
10 18 8
16 8 18
14 22 11
19 11 22
12 20 15
23 15 20
9 17 13
21 13 17
LABEL Desk
MATERIAL 2
TEXTURE 2
GEOM 202 132 ; Desk
1.00038 0.0271144 1.45396 0.0 -1.0 0.0 0.0 1.0
...even more data
-0.666291 0.575834 0.521924 -1.80166e-007 0.564086 -0.825716 0.501775 0.166667
9 0 8
0 9 1
10 76 91
76 10 2
11 78 92
78 11 3
12 80 93
80 12 4
13 82 94
82 13 5
14 84 95
84 14 6
15 86 96
86 15 7
90 88 97
88 90 74
17 8 16
8 17 9
18 91 99
91 18 10
19 92 100
92 19 11
20 93 101
93 20 12
21 94 102
94 21 13
22 95 103
95 22 14
23 96 104
96 23 15
98 97 105
97 98 90
25 16 24
16 25 17
26 99 107
99 26 18
27 100 108
100 27 19
28 101 109
101 28 20
29 102 110
102 29 21
30 103 111
103 30 22
31 104 112
104 31 23
106 105 113
105 106 98
33 24 32
24 33 25
34 107 115
107 34 26
35 108 116
108 35 27
36 109 117
109 36 28
37 110 118
110 37 29
38 111 119
111 38 30
39 112 123
112 39 31
114 113 127
113 114 106
41 32 40
32 41 33
42 115 129
115 42 34
43 116 130
116 43 35
44 117 131
117 44 36
45 118 132
118 45 37
70 68 73
68 70 69
47 123 46
123 47 39
128 127 139
127 128 114
49 40 48
40 49 41
50 129 142
129 50 42
51 130 144
130 51 43
52 131 146
131 52 44
53 132 148
132 53 45
71 73 72
73 71 70
55 46 54
46 55 47
140 139 158
139 140 128
83 79 81
85 79 83
85 77 79
85 75 77
87 75 85
87 89 75
154 141 159
145 149 147
145 150 149
143 150 145
141 150 143
154 150 141
120 57 124
165 121 56
125 58 136
170 126 166
137 59 155
175 138 171
156 60 151
180 157 176
152 61 133
185 153 181
134 160 122
161 135 186
162 63 167
192 163 62
168 64 172
194 169 193
173 65 177
196 174 195
178 66 182
198 179 197
183 67 187
200 184 199
188 190 164
191 189 201
MATERIALS 2
Concrete
TankBase
MATERIAL Concrete
0.588235 0.588235 0.588235 1.0
0.588235 0.588235 0.588235 1.0
0.9 0.9 0.9 1.0 0.0
0.0 0.0 0.0 1.0
MATERIAL TankBase
0.588235 0.588235 0.588235 1.0
0.588235 0.588235 0.588235 1.0
0.9 0.9 0.9 1.0 0.0
0.0 0.0 0.0 1.0
TEXTURES 2
Concrete.dds
metalcon.dds

I ran that mesh through meshc.exe in OrbiterSDK/utils and got this

Code:
// ========================================================
// Mesh resource file for P2TestCellInteriorInv
// Generated with meshc on Fri Feb 15 10:27:20 2013

// ========================================================

// Number of mesh groups:
#define NGRP 0

// Number of materials:
#define NMAT 0

// Number of textures:
#define NTEX 0

I was expecting 2 groups/materials/textures?

Never used meshc before, so guessing its finger trouble.

EDIT: just seen something now its written down! The two groups in the mesh are Interior and Desk, the poly that was detched dosen't appear? Have to sort that out.
still dosen't explain the zero mesh.c file entries though?


All help appreciated
 
Last edited:
Never used meshc before, so guessing its finger trouble.

All help appreciated
You have to include the file extension as well as the file name. So if your mesh is named P2TestCellInteriorInv.msh that is what you have to enter in MeshC.
 
Brilliant DaveS, got this now:

Code:
// ========================================================
// Mesh resource file for P2TestCellInteriorInv.msh
// Generated with meshc on Fri Feb 15 12:04:42 2013

// ========================================================

// Number of mesh groups:
#define NGRP 2

// Number of materials:
#define NMAT 2

// Number of textures:
#define NTEX 2

// Named mesh groups:
#define GRP_Interior 0
#define GRP_Desk 1

Just got to find my wayward panel now!

Thanks, N.
 
Looking at these functions:

static VCMFDSPEC LEFT_MFD = {mesh_P2Internal, GRP_Interior}; // Surface on which to display MFD. [Mesh, Mesh Group]
oapiVCRegisterMFD (0, &LEFT_MFD); // Register MFD in orbiter's interface [registry # and VCMFDSPEC]. (registry numbers start at 0 and count up)
and changing the Mesh Group paramater, I get these results

with Mesh Group = GRP_PanelLH
http://i89.photobucket.com/albums/k207/Notebook_04/Panel_LH_zpsc46ab822.jpg

with Mesh Group = GRP_Desk 1
http://i89.photobucket.com/albums/k207/Notebook_04/Desk_zps0af9c3f5.jpg

with Mesh Group = GRP_Interior
http://i89.photobucket.com/albums/k207/Notebook_04/Interior_zps906570e0.jpg

These are all using the "P2TestCellInteriorInv.msh"

A couple of questions....

I'm guessing the MFD orientation follows the mesh axis, so I need to rectify this in 3DS MAX?

How do I get the MFD onto the GRP_PanelLH, do I split off the Desk group as a new mesh from P2TestCellInteriorInv.msh?

All input appreciated.

N.
 
I'm guessing the MFD orientation follows the mesh axis, so I need to rectify this in 3DS MAX?
MFD orientation follows UV map of the mesh group (0,0 - top left; 1,1 - bottom right).


How do I get the MFD onto the GRP_PanelLH, do I split off the Desk group as a new mesh from P2TestCellInteriorInv.msh?
No need to do that. You put the right group index into VCMFDSPEC (and the right mesh index, of course) when you register the MFD surface with oapiVCRegisterMFD.

If GRP_PanelLH isn't the surface for MFD, but its "background", then you should put a new square mesh group atop of it first (and set the UV map for it accordingly, with the mentioned earlier texture coordinates), which will be used for the MFD surface (you get the index of that group for VCMFDSPEC).
 
Thanks for that Orb.

1)I haven't altered or defined the UV parameters of GRP_PanelLH, how do I check its value?

2) Do you mean making another planar surface in 3DS max above the panel on the desk, and detaching that as a group?

I thought I just had to give orbiter the correct paramaters in VCMFDSPEC and orbiter would sort it out?

Here's what I have at the moment:

All of .h file
Code:
// ========================================================
// Mesh resource file for P2TestCellInteriorInv.msh
// Generated with meshc on Fri Feb 15 12:18:53 2013

// ========================================================

// Number of mesh groups:
#define NGRP 3

// Number of materials:
#define NMAT 2

// Number of textures:
#define NTEX 2

// Named mesh groups:
#define GRP_Interior 0
#define GRP_Desk 1
#define GRP_PanelLH 2

const VECTOR3 LEFTMFD_POS = { 0.1, 1, 1};	//

// ==============================================================
// Some vessel parameters
// ==============================================================

const double  P2_SIZE       = 10.5;             // mean radius [m]
const VECTOR3 P2_CS         = {10.5,15.0,5.8}; // x,y,z cross sections [m^2]
const VECTOR3 P2_PMI        = {2.28,2.31,0.79};// principal moments of inertia (mass-normalised) [m^2]
const VECTOR3 P2_RD         = {0.025,0.025,0.02};//{0.05,0.1,0.05};  // rotation drag coefficients
const double  P2_EMPTYMASS  = 500.0;           // empty vessel mass [kg]
const double  P2_FUELMASS   = 750.0;           // max fuel mass [kg]
const double  P2_ISP        = 5e4;             // fuel-specific impulse [m/s]
//const VECTOR3 P2_TDP[3]     = {{0,-1.5,2},{-1,-1.5,-1.5},{1,-1.5,-1.5}}; // touchdown points [m]
const VECTOR3 P2_TDP[3]     = {{0,0.01,2},{-1,0.01,-1.5},{1,0.01,-1.5}}; // touchdown points [m]


const double  P2_MAXMAINTH  = 3e4;             


// ==============================================================
// P2TestCell class interface
// ==============================================================

class P2TestCell: public VESSEL3 {
public:
	P2TestCell (OBJHANDLE hVessel, int flightmodel);
	~P2TestCell ();
	void clbkSetClassCaps (FILEHANDLE cfg);
	void clbkPostStep(double simt, double simdt, double mjd);
	//oapiProcessMFDButton (MFD_LEFT, bt, event);


	int id;

	//meshes
	MESHHANDLE	mh_P2External, mh_P2Internal;
	UINT		mesh_P2External;
	UINT		mesh_P2Internal;

	//SURFHANDLE tex;

	bool	clbkLoadVC (int id);													// Load virtual cockpit mode
	bool	clbkVCMouseEvent (int id, int event, VECTOR3 &p);						// Respond to virtual cockpit mouse events
	bool	clbkVCRedrawEvent (int id, int event, SURFHANDLE surf);	


private:
	


};

bits of the .cpp file
Code:
P2TestCell::P2TestCell (OBJHANDLE hVessel, int flightmodel)
: VESSEL3 (hVessel, flightmodel)
{
	mh_P2External		= oapiLoadMeshGlobal("P2TestCell");
	mh_P2Internal		= oapiLoadMeshGlobal("P2TestCellInteriorInv");
	int id = 0;		// VC identifier
}

P2TestCell::~P2TestCell ()
{
}
.....
bool P2TestCell::clbkLoadVC(int id)
{
			// Register Camera (view) properties
	switch (id)
	{
	case 0: // Commander's position
	
	SetCameraOffset (_V(0,1.0,-3.0));								// Set camera position (x,y,z)
	SetCameraDefaultDirection (_V(0,0,1));							// Set camera direction (x,y,z)
	SetCameraRotationRange (RAD*120, RAD*120, RAD*70, RAD*70);		// Set camera range of motion (Left, Right, Up, Down)
	SetCameraShiftRange (_V(0,0,0.1), _V(-0.2,0,0), _V(0.2,0,0));
		break;
	case 1: // Pilot's position
		
		SetCameraOffset (_V( 0.57, 0.68, 1.12));					// Set camera position (x,y,z)
		SetCameraDefaultDirection (_V( 0, 0, 1));					// Set camera direction (x,y,z)
		SetCameraRotationRange (RAD*120, RAD*120, RAD*60, RAD*60);	// Set camera range of motion (Left, Right, Up, Down)
		oapiVCSetNeighbours ( 0,-1,-1,-1);	
		break;
	case 2: // Commander's position (looking up through COAS Reticle)
		
		SetCameraOffset (_V(-0.59, 0.68, 1.12));					// Set camera position (x,y,z)
		SetCameraDefaultDirection (_V( 0, 1, 0));					// Set camera direction (x,y,z)
		SetCameraRotationRange (RAD*15, RAD*15, RAD*15, RAD*15);	// Set camera range of motion (Left, Right, Up, Down)
		oapiVCSetNeighbours (-1, 1,-1, 0);	
		break;
	} // end "switch (id)"

	
	// --- Register MFDs ----------------------------------------------------------------------------

	VECTOR3 MFD_position = LEFTMFD_POS;	// Location of MFD within VC
	static VCMFDSPEC LEFT_MFD = {mesh_P2Internal, GRP_Interior};	// Surface on which to display MFD. [Mesh, Mesh Group] 
	oapiVCRegisterMFD (0, &LEFT_MFD);	// Register MFD in orbiter's interface [registry # and VCMFDSPEC]. (registry numbers start at 0 and count up)

	
	return true;

} // End "P2TestCell::clbkLoadVC"

N.
 
1)I haven't altered or defined the UV parameters of GRP_PanelLH, how do I check its value?
When you open the .msh file with a text editor (notepad, for example), find the mesh group you're looking for (I see you use labels, so it shouldn't be hard). Below the GEOM keyword you should see lines with 8 values. The last 2 are UV map coordinates ('u' in 7th and 'v' in 8th). If there are fewer values in the line, and NONORMAL flag wasn't set, then the UV map wasn't set for the group, and it needs to be added. If NONORMAL flag is set for the group, then UV map coordinates should be in 4th and 5th value in the line.

2) Do you mean making another planar surface in 3DS max above the panel on the desk, and detaching that as a group?
Yes.

I thought I just had to give orbiter the correct paramaters in VCMFDSPEC and orbiter would sort it out?
Orbiter needs to have correct data contained in the mesh file, too.
 
thanks again Orb, all makes sense, I'll give it a try.

Gosh this is exciting!

N.
 
Back
Top