SDK Question Questions about vessel local lights and particle streams (+ animations)

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
I am at the very beginning of C++ and programming in Orbiter. I'm making a dll for a spacecraft and the dll is very basic. I have some questions and problems. Could someone help me?

____________________

1. I want to place lightsources at the thrusters. How do I do this? I have looked in the DeltaGlider.cpp file and found this:

PHP:
COLOUR4 col_d = {0.9,0.8,1,0};
COLOUR4 col_s = {1.9,0.8,1,0};
COLOUR4 col_a = {0,0,0,0};
COLOUR4 col_white = {1,1,1,0};
LightEmitter *le = AddPointLight (_V(0,0,-10), 200, 1e-3, 0, 2e-3, col_d, col_s, col_a);
le->SetIntensityRef (&th_main_level);

...

th_main_level = GetThrusterGroupLevel (THGROUP_MAIN);
I have tried the same thing, but it wouldn't work. I searched the forum, and found this thread: http://www.orbiter-forum.com/showthread.php?t=30358

However, it seems like that I need a header file for this. As I have a very basic knowledge of C++, is it possible to get local lights without a header file?

____________________

2. I have added particlestreams, but this only activates at altitudes below approximatly 80 km.
I want the particlestreams to work at any altitudes, but I don't know how to do that (it is used on the ATV and CTV add ons by Well & NoMatter). I looked in the API_Reference.pdf, but couldn't get any answers ther. How do I do that?

____________________

3. When I build my module, the file size of the dll is very large (a basic plugin on 12 lines has a size of 190 kB).
I guess that it's my Visual C++ Express setup which causes this. I followed the steps in the "Setting up the development enviroment" video by computerex, and am in Debug mode.
Will the filesize get small when I change to "Release"?

____________________


Finally, here is my source code. Feel free to correct if you see something wrong there:

PHP:
#define STRICT
#define ORBITER_MODULE

#include "orbitersdk.h"

class ChapmanInner1: public VESSEL3
{
public:
	ChapmanInner1 (OBJHANDLE hVessel, int flightmodel)
		: VESSEL3 (hVessel, flightmodel) {}
	void clbkSetClassCaps (FILEHANDLE cfg);
	void clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv);
};

void ChapmanInner1::clbkSetClassCaps (FILEHANDLE cfg)
{
	SetSize (4);
	SetEmptyMass (679);
	SetCW (0.3, 0.3, 1.5, 1.5);
	SetCrossSections (_V(5.73, 4.37, 4.08));
	SetRotDrag (_V(2,2,2));
	SetPMI (_V(0.5, 0.5, 0.5));
	SetCameraOffset (_V(-0.449269, 0.126477, 1.24));
	SetTouchdownPoints (_V(0, -1, 0), _V(1, -1, 0), _V(-1, -1, 0));

	InitNavRadios (3);

	const double MAINFUELMASS = 980;
	const double RCSFUELMASS = 50;

	const double ISPMAINVAC = 3500;
	const double ISPMAINATM = 35;
	const double ISPRCSVAC = 1300;
	const double ISPRCSATM = 13;

	const double MAINTHRUST = 2500;
	const double RCSTHRUST = 2;

	PROPELLANT_HANDLE MainTank;
	MainTank = CreatePropellantResource (MAINFUELMASS);

	PROPELLANT_HANDLE RCSTank;
	RCSTank = CreatePropellantResource (RCSFUELMASS);

	THRUSTER_HANDLE main, rcs[24], rcsgroup[4];

	PARTICLESTREAMSPEC contrail_main =
	{
		0, 0.2, 5, 4, 0.3, 4.0, 4, 2.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};

	PARTICLESTREAMSPEC exhaust_main =
	{
		0, 2.0, 20, 150, 0.1, 0.2, 16, 2.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};

	PARTICLESTREAMSPEC contrail_RCS =
	{
		0, 0.2, 5, 4, 0.3, 4.0, 4, 2.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};

	PARTICLESTREAMSPEC exhaust_RCS =
	{
		0, 2.0, 20, 150, 0.1, 0.2, 16, 2.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};

	main = CreateThruster (_V( 0, 0, -2.0), _V(0, 0, 1), MAINTHRUST, MainTank, ISPMAINVAC, ISPMAINATM);
	CreateThrusterGroup (&main, 1, THGROUP_MAIN);
	AddExhaust (main, 2.0, 0.125, _V(0.0123, -0.0261, -2.0), _V(0, 0, -1));

	AddExhaustStream (main, _V( 0.012311, -0.026071, -2.0), &contrail_main);
	AddExhaustStream (main, _V( 0.012311, -0.026071, -2.0), &exhaust_main);

	rcs[ 0] = CreateThruster (_V( 0.512689,-0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 1] = CreateThruster (_V( 0.512689, 0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 2] = CreateThruster (_V(-0.512689, 0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 3] = CreateThruster (_V(-0.512689,-0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 4] = CreateThruster (_V( 0.880899,-0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 5] = CreateThruster (_V(-0.880899,-0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 6] = CreateThruster (_V( 0.880899, 0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 7] = CreateThruster (_V(-0.880899, 0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 8] = CreateThruster (_V( 0.618274,-0.261586,-1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 9] = CreateThruster (_V( 0.618274, 0.261586,-1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[10] = CreateThruster (_V( 0.618274,-0.261586, 1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[11] = CreateThruster (_V( 0.618274, 0.261586, 1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[12] = CreateThruster (_V(-0.618274,-0.261586,-1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[13] = CreateThruster (_V(-0.618274, 0.261586,-1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[14] = CreateThruster (_V(-0.618274,-0.261586, 1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[15] = CreateThruster (_V(-0.618274, 0.261586, 1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[16] = CreateThruster (_V( 0.512689,-0.5586355,-1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[17] = CreateThruster (_V(-0.512689,-0.5586355,-1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[18] = CreateThruster (_V(-0.512689,-0.5586355, 1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[19] = CreateThruster (_V( 0.512689,-0.5586355, 1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[20] = CreateThruster (_V( 0.512689, 0.3651495,-1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[21] = CreateThruster (_V(-0.512689, 0.3651495,-1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[22] = CreateThruster (_V( 0.512689, 0.3651495, 1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[23] = CreateThruster (_V(-0.512689, 0.3651495, 1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);

	AddExhaust (rcs[ 0], 0.30, 0.02, _V( 0.537311,-0.455072,-1.622), _V( 0, 0,-1));
	AddExhaust (rcs[ 1], 0.30, 0.02, _V( 0.537311, 0.261586,-1.622), _V( 0, 0,-1));
	AddExhaust (rcs[ 2], 0.30, 0.02, _V(-0.512689, 0.261586,-1.622), _V( 0, 0,-1));
	AddExhaust (rcs[ 3], 0.30, 0.02, _V(-0.512689,-0.455072,-1.622), _V( 0, 0,-1));
	AddExhaust (rcs[ 4], 0.30, 0.02, _V( 0.905521,-0.455062, 1.217578), _V( 0, 0, 1));
	AddExhaust (rcs[ 5], 0.30, 0.02, _V(-0.880899,-0.455062, 1.217578), _V( 0, 0, 1));
	AddExhaust (rcs[ 6], 0.30, 0.02, _V( 0.905521, 0.2633565, 1.217578), _V( 0, 0, 1));
	AddExhaust (rcs[ 7], 0.30, 0.02, _V(-0.880899, 0.2633565, 1.217578), _V( 0, 0, 1));
	AddExhaust (rcs[ 8], 0.30, 0.02, _V( 0.642896,-0.455348,-1.519011), _V( 1, 0, 0));
	AddExhaust (rcs[ 9], 0.30, 0.02, _V( 0.642896, 0.261862,-1.519011), _V( 1, 0, 0));
	AddExhaust (rcs[10], 0.30, 0.02, _V( 1.011106,-0.455338, 1.114589), _V( 1, 0, 0));
	AddExhaust (rcs[11], 0.30, 0.02, _V( 1.011106, 0.263632, 1.114589), _V( 1, 0, 0));
	AddExhaust (rcs[12], 0.30, 0.02, _V(-0.618274,-0.455348,-1.519011), _V(-1, 0, 0));
	AddExhaust (rcs[13], 0.30, 0.02, _V(-0.618274, 0.261862,-1.519011), _V(-1, 0, 0));
	AddExhaust (rcs[14], 0.30, 0.02, _V(-0.9864841,-0.455338, 1.114589), _V(-1, 0, 0));
	AddExhaust (rcs[15], 0.30, 0.02, _V(-0.9864841, 0.263632, 1.114589), _V(-1, 0, 0));
	AddExhaust (rcs[16], 0.30, 0.02, _V( 0.5368665,-0.5586355,-1.519011), _V( 0,-1, 0));
	AddExhaust (rcs[17], 0.30, 0.02, _V(-0.5122445,-0.5586355,-1.519011), _V( 0,-1, 0));
	AddExhaust (rcs[18], 0.30, 0.02, _V(-0.8804545,-0.5586355, 1.114589), _V( 0,-1, 0));
	AddExhaust (rcs[19], 0.30, 0.02, _V( 0.9050765,-0.5586355, 1.114589), _V( 0,-1, 0));
	AddExhaust (rcs[20], 0.30, 0.02, _V( 0.5368665, 0.3651495,-1.519011), _V( 0, 1, 0));
	AddExhaust (rcs[21], 0.30, 0.02, _V(-0.5122445, 0.3651495,-1.519011), _V( 0, 1, 0));
	AddExhaust (rcs[22], 0.30, 0.02, _V( 0.9050765, 0.3669295, 1.114589), _V( 0, 1, 0));
	AddExhaust (rcs[23], 0.30, 0.02, _V(-0.8804545, 0.3669295, 1.114589), _V( 0, 1, 0));

	rcsgroup[0] = rcs[ 0];
	rcsgroup[1] = rcs[ 1];
	rcsgroup[2] = rcs[ 2];
	rcsgroup[3] = rcs[ 3];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_FORWARD);

	rcsgroup[0] = rcs[ 4];
	rcsgroup[1] = rcs[ 5];
	rcsgroup[2] = rcs[ 6];
	rcsgroup[3] = rcs[ 7];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BACK);

	rcsgroup[0] = rcs[ 8];
	rcsgroup[1] = rcs[ 9];
	rcsgroup[2] = rcs[10];
	rcsgroup[3] = rcs[11];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_LEFT);

	rcsgroup[0] = rcs[12];
	rcsgroup[1] = rcs[13];
	rcsgroup[2] = rcs[14];
	rcsgroup[3] = rcs[15];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_RIGHT);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[17];
	rcsgroup[2] = rcs[18];
	rcsgroup[3] = rcs[19];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_UP);

	rcsgroup[0] = rcs[20];
	rcsgroup[1] = rcs[21];
	rcsgroup[2] = rcs[22];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_DOWN);

	rcsgroup[0] = rcs[18];
	rcsgroup[1] = rcs[19];
	rcsgroup[2] = rcs[20];
	rcsgroup[3] = rcs[21];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_PITCHUP);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[17];
	rcsgroup[2] = rcs[22];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_PITCHDOWN);

	rcsgroup[0] = rcs[10]; 
	rcsgroup[1] = rcs[11]; 
	rcsgroup[2] = rcs[12]; 
	rcsgroup[3] = rcs[13]; 
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_YAWLEFT);

	rcsgroup[0] = rcs[8];
	rcsgroup[1] = rcs[9];
	rcsgroup[2] = rcs[14];
	rcsgroup[3] = rcs[15];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_YAWRIGHT);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[19];
	rcsgroup[2] = rcs[21];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BANKLEFT);

	rcsgroup[0] = rcs[17];
	rcsgroup[1] = rcs[18];
	rcsgroup[2] = rcs[20];
	rcsgroup[3] = rcs[22];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BANKRIGHT);

	AddExhaustStream (rcs[ 0], _V( 0.537311,-0.455072,-1.622), &contrail_RCS);
	AddExhaustStream (rcs[ 1], _V( 0.537311, 0.261586,-1.622), &contrail_RCS);
	AddExhaustStream (rcs[ 2], _V(-0.512689, 0.261586,-1.622), &contrail_RCS);
	AddExhaustStream (rcs[ 3], _V(-0.512689,-0.455072,-1.622), &contrail_RCS);
	AddExhaustStream (rcs[ 4], _V( 0.905521,-0.455062, 1.217578), &contrail_RCS);
	AddExhaustStream (rcs[ 5], _V(-0.880899,-0.455062, 1.217578), &contrail_RCS);
	AddExhaustStream (rcs[ 6], _V( 0.905521, 0.2633565, 1.217578), &contrail_RCS);
	AddExhaustStream (rcs[ 7], _V(-0.880899, 0.2633565, 1.217578), &contrail_RCS);
	AddExhaustStream (rcs[ 8], _V( 0.642896,-0.455348,-1.519011), &contrail_RCS);
	AddExhaustStream (rcs[ 9], _V( 0.642896, 0.261862,-1.519011), &contrail_RCS);
	AddExhaustStream (rcs[10], _V( 1.011106,-0.455338, 1.114589), &contrail_RCS);
	AddExhaustStream (rcs[11], _V( 1.011106, 0.263632, 1.114589), &contrail_RCS);					  
	AddExhaustStream (rcs[12], _V(-0.618274,-0.455348,-1.519011), &contrail_RCS);
	AddExhaustStream (rcs[13], _V(-0.618274, 0.261862,-1.519011), &contrail_RCS);
	AddExhaustStream (rcs[14], _V(-0.9864841,-0.455338, 1.114589), &contrail_RCS);
	AddExhaustStream (rcs[15], _V(-0.9864841, 0.263632, 1.114589), &contrail_RCS);						  
	AddExhaustStream (rcs[16], _V( 0.5368665,-0.5586355,-1.519011), &contrail_RCS);
	AddExhaustStream (rcs[17], _V(-0.5122445,-0.5586355,-1.519011), &contrail_RCS);
	AddExhaustStream (rcs[18], _V(-0.8804545,-0.5586355, 1.114589), &contrail_RCS);
	AddExhaustStream (rcs[19], _V( 0.9050765,-0.5586355, 1.114589), &contrail_RCS);					  
	AddExhaustStream (rcs[20], _V( 0.5368665, 0.3651495,-1.519011), &contrail_RCS);
	AddExhaustStream (rcs[21], _V(-0.5122445, 0.3651495,-1.519011), &contrail_RCS);
	AddExhaustStream (rcs[22], _V( 0.9050765, 0.3669295, 1.114589), &contrail_RCS);
	AddExhaustStream (rcs[23], _V(-0.8804545, 0.3669295, 1.114589), &contrail_RCS);

	AddExhaustStream (rcs[ 0], _V( 0.537311,-0.455072,-1.622), &exhaust_RCS);
	AddExhaustStream (rcs[ 1], _V( 0.537311, 0.261586,-1.622), &exhaust_RCS);
	AddExhaustStream (rcs[ 2], _V(-0.512689, 0.261586,-1.622), &exhaust_RCS);
	AddExhaustStream (rcs[ 3], _V(-0.512689,-0.455072,-1.622), &exhaust_RCS);
	AddExhaustStream (rcs[ 4], _V( 0.905521,-0.455062, 1.217578), &exhaust_RCS);
	AddExhaustStream (rcs[ 5], _V(-0.880899,-0.455062, 1.217578), &exhaust_RCS);
	AddExhaustStream (rcs[ 6], _V( 0.905521, 0.2633565, 1.217578), &exhaust_RCS);
	AddExhaustStream (rcs[ 7], _V(-0.880899, 0.2633565, 1.217578), &exhaust_RCS);
	AddExhaustStream (rcs[ 8], _V( 0.642896,-0.455348,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[ 9], _V( 0.642896, 0.261862,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[10], _V( 1.011106,-0.455338, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[11], _V( 1.011106, 0.263632, 1.114589), &exhaust_RCS);					  
	AddExhaustStream (rcs[12], _V(-0.618274,-0.455348,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[13], _V(-0.618274, 0.261862,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[14], _V(-0.9864841,-0.455338, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[15], _V(-0.9864841, 0.263632, 1.114589), &exhaust_RCS);						  
	AddExhaustStream (rcs[16], _V( 0.5368665,-0.5586355,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[17], _V(-0.5122445,-0.5586355,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[18], _V(-0.8804545,-0.5586355, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[19], _V( 0.9050765,-0.5586355, 1.114589), &exhaust_RCS);					  
	AddExhaustStream (rcs[20], _V( 0.5368665, 0.3651495,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[21], _V(-0.5122445, 0.3651495,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[22], _V( 0.9050765, 0.3669295, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[23], _V(-0.8804545, 0.3669295, 1.114589), &exhaust_RCS);

	// Mesh
	AddMesh("ChapmanInner1");
}

void ChapmanInner1::clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv)
{
	if (getfocus)
	{
		oapiDisableMFDMode (MFD_LANDING);
		oapiDisableMFDMode (MFD_HSI);
	}
}

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

DLLCLBK void ovcExit (VESSEL *vessel)
{
	if (vessel) delete (ChapmanInner1*)vessel;
}

I will appreciate any help I can get!
 
Last edited:

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
I have tried the same thing, but it wouldn't work.
Are you reading GetThrusterGroupLevel (THGROUP_MAIN) every time step?

However, it seems like that I need a header file for this. As I have a very basic knowledge of C++, is it possible to get local lights without a header file?
You don't need a header file. Header file for simple projects (where the header is used only by one cpp file) is just an interface part of code which was simply moved outside of the main file to make it easier to read by humans.

2. I have added particlestreams, but this only activates at altitudes below approximatly 80 km.
I want the particlestreams to work at any altitudes, but I don't know how to do that (it is used on the ATV and CTV add ons by Well & NoMatter). I looked in the API_Reference.pdf, but couldn't get any answers ther. How do I do that?
Try changing lmin parameter to the same value as lmax, or amin parameter to the same value as amax.

3. When I build my module, the file size of the dll is very large (a basic plugin on 12 lines has a size of 190 kB).

{...}

Will the filesize get small when I change to "Release"?
The size will be smaller in "Release" build. But if it's a static build then the size of the module won't be as small as 11-16 KB, like simple stock modules have, but something around 100 KB.



I'll check the code when I'm back at home.
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
Are you reading GetThrusterGroupLevel (THGROUP_MAIN) every time step?

How do I do this?

I pasted this into my code:
PHP:
void ChapmanInner1::clbkPostStep (double simt, double simdt, double mjd)
{
	th_main_level = GetThrusterGroupLevel (THGROUP_MAIN);
}

and this:
PHP:
void ChapmanInner1::clbkSetClassCaps (FILEHANDLE cfg)
{

...

	COLOUR4 col_d = {0.9,0.8,1,0};
	COLOUR4 col_s = {1.9,0.8,1,0};
	COLOUR4 col_a = {0,0,0,0};
	COLOUR4 col_white = {1,1,1,0};
	LightEmitter *le = AddPointLight (_V(0,0,-10), 200, 1e-3, 0, 2e-3, col_d, col_s, col_a);
	le->SetIntensityRef (&th_main_level);

...

}

I got an error saying that "...'clbkPostStep' : member function not declared in 'ChapmanInner1'...". Then I wrote this:
PHP:
class ChapmanInner1: public VESSEL3
{
...
	void clbkPostStep (double simt, double simdt, double mjd);
};

But it still doesn't work. I get the errors :

Code:
warning C4305: 'initializing' : truncation from 'double' to 'float'
warning C4305: 'initializing' : truncation from 'double' to 'float'
warning C4305: 'initializing' : truncation from 'double' to 'float'
warning C4305: 'initializing' : truncation from 'double' to 'float'
error C2065: 'th_main_level' : undeclared identifier
error C2065: 'th_main_level' : undeclared identifier
where the 'initializing' errors are refering to the part containing:
Code:
COLOUR4 col_d = {0.9,0.8,1,0};
	COLOUR4 col_s = {1.9,0.8,1,0};
	COLOUR4 col_a = {0,0,0,0};
	COLOUR4 col_white = {1,1,1,0};
the first 'th_main_level' : undeclared identifier error is refering to:
Code:
le->SetIntensityRef (&th_main_level);
and the second 'th_main_level' : undeclared identifier error is refering to:
Code:
void ChapmanInner1::clbkPostStep (double simt, double simdt, double mjd)
{
	th_main_level = GetThrusterGroupLevel (THGROUP_MAIN);
}


Now my entire code look like this:
PHP:
#define STRICT
#define ORBITER_MODULE

#include "orbitersdk.h"

class ChapmanInner1: public VESSEL3
{
	public:
		ChapmanInner1 (OBJHANDLE hVessel, int flightmodel)
			: VESSEL3 (hVessel, flightmodel){}
		void clbkSetClassCaps (FILEHANDLE cfg);
		void clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv);
		// This is new:
		void clbkPostStep (double simt, double simdt, double mjd);
};

void ChapmanInner1::clbkSetClassCaps (FILEHANDLE cfg)
{
	SetSize (4);
	SetEmptyMass (679);
	SetCW (0.3, 0.3, 1.5, 1.5);
	SetCrossSections (_V(5.73, 4.37, 4.08));
	SetRotDrag (_V(2,2,2));
	SetPMI (_V(0.5, 0.5, 0.5));
	SetCameraOffset (_V(-0.449269, 0.126477, 1.24));
	SetTouchdownPoints (_V( 0.0124,-1.1662,-0.1114), _V(-0.3407,-0.7666, 0.9728), _V( 0.3696,-0.7666, 0.9684));

	InitNavRadios (3);

	const double MAINFUELMASS = 980;
	const double RCSFUELMASS = 50;

	const double ISPMAINVAC = 3500;
	const double ISPMAINATM = 35;
	const double ISPRCSVAC = 1300;
	const double ISPRCSATM = 13;

	const double MAINTHRUST = 2500;
	const double RCSTHRUST = 2;

	PROPELLANT_HANDLE MainTank;
	MainTank = CreatePropellantResource (MAINFUELMASS);

	PROPELLANT_HANDLE RCSTank;
	RCSTank = CreatePropellantResource (RCSFUELMASS);

	THRUSTER_HANDLE main, rcs[24], rcsgroup[4];

	PARTICLESTREAMSPEC exhaust_main =
    {
		// 0, size, rate, velocity, spread, life, grow, slow
        0, 0.1, 100, 10, 0.01, 0.05, 1, 2.0, PARTICLESTREAMSPEC::DIFFUSE,
        PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
        PARTICLESTREAMSPEC::ATM_PLIN, 1
    };

	PARTICLESTREAMSPEC exhaust_RCS =
    {
		// 0, size, rate, velocity, spread, life, grow, slow
        0, 0.015, 100, 1.5, 0.01, 0.05, 0.25, 2.0, PARTICLESTREAMSPEC::DIFFUSE,
        PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
        PARTICLESTREAMSPEC::ATM_PLIN, 1
    };

	main = CreateThruster (_V( 0, 0, -2.0), _V(0, 0, 1), MAINTHRUST, MainTank, ISPMAINVAC, ISPMAINATM);
	CreateThrusterGroup (&main, 1, THGROUP_MAIN);
	AddExhaust (main, 2.0, 0.125, _V(0.012311, -0.026071, -2.0), _V(0, 0, -1));

	AddExhaustStream (main, _V( 0.012311, -0.026071, -2.0), &exhaust_main);

	// This is new:
	COLOUR4 col_d = {0.9,0.8,1,0};
	COLOUR4 col_s = {1.9,0.8,1,0};
	COLOUR4 col_a = {0,0,0,0};
	COLOUR4 col_white = {1,1,1,0};
	LightEmitter *le = AddPointLight (_V(0,0,-10), 200, 1e-3, 0, 2e-3, col_d, col_s, col_a);
	le->SetIntensityRef (&th_main_level);

	rcs[ 0] = CreateThruster (_V( 0.512689,-0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 1] = CreateThruster (_V( 0.512689, 0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 2] = CreateThruster (_V(-0.512689, 0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 3] = CreateThruster (_V(-0.512689,-0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 4] = CreateThruster (_V( 0.880899,-0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 5] = CreateThruster (_V(-0.880899,-0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 6] = CreateThruster (_V( 0.880899, 0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 7] = CreateThruster (_V(-0.880899, 0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 8] = CreateThruster (_V( 0.618274,-0.261586,-1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 9] = CreateThruster (_V( 0.618274, 0.261586,-1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[10] = CreateThruster (_V( 0.618274,-0.261586, 1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[11] = CreateThruster (_V( 0.618274, 0.261586, 1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[12] = CreateThruster (_V(-0.618274,-0.261586,-1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[13] = CreateThruster (_V(-0.618274, 0.261586,-1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[14] = CreateThruster (_V(-0.618274,-0.261586, 1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[15] = CreateThruster (_V(-0.618274, 0.261586, 1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[16] = CreateThruster (_V( 0.512689,-0.5586355,-1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[17] = CreateThruster (_V(-0.512689,-0.5586355,-1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[18] = CreateThruster (_V(-0.512689,-0.5586355, 1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[19] = CreateThruster (_V( 0.512689,-0.5586355, 1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[20] = CreateThruster (_V( 0.512689, 0.3651495,-1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[21] = CreateThruster (_V(-0.512689, 0.3651495,-1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[22] = CreateThruster (_V( 0.512689, 0.3651495, 1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[23] = CreateThruster (_V(-0.512689, 0.3651495, 1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);

	AddExhaust (rcs[ 0], 0.30, 0.02, _V( 0.537311,-0.455072,-1.622), _V( 0, 0,-1));
	AddExhaust (rcs[ 1], 0.30, 0.02, _V( 0.537311, 0.261586,-1.622), _V( 0, 0,-1));
	AddExhaust (rcs[ 2], 0.30, 0.02, _V(-0.512689, 0.261586,-1.622), _V( 0, 0,-1));
	AddExhaust (rcs[ 3], 0.30, 0.02, _V(-0.512689,-0.455072,-1.622), _V( 0, 0,-1));
	AddExhaust (rcs[ 4], 0.30, 0.02, _V( 0.905521,-0.455062, 1.217578), _V( 0, 0, 1));
	AddExhaust (rcs[ 5], 0.30, 0.02, _V(-0.880899,-0.455062, 1.217578), _V( 0, 0, 1));
	AddExhaust (rcs[ 6], 0.30, 0.02, _V( 0.905521, 0.2633565, 1.217578), _V( 0, 0, 1));
	AddExhaust (rcs[ 7], 0.30, 0.02, _V(-0.880899, 0.2633565, 1.217578), _V( 0, 0, 1));
	AddExhaust (rcs[ 8], 0.30, 0.02, _V( 0.642896,-0.455348,-1.519011), _V( 1, 0, 0));
	AddExhaust (rcs[ 9], 0.30, 0.02, _V( 0.642896, 0.261862,-1.519011), _V( 1, 0, 0));
	AddExhaust (rcs[10], 0.30, 0.02, _V( 1.011106,-0.455338, 1.114589), _V( 1, 0, 0));
	AddExhaust (rcs[11], 0.30, 0.02, _V( 1.011106, 0.263632, 1.114589), _V( 1, 0, 0));
	AddExhaust (rcs[12], 0.30, 0.02, _V(-0.618274,-0.455348,-1.519011), _V(-1, 0, 0));
	AddExhaust (rcs[13], 0.30, 0.02, _V(-0.618274, 0.261862,-1.519011), _V(-1, 0, 0));
	AddExhaust (rcs[14], 0.30, 0.02, _V(-0.9864841,-0.455338, 1.114589), _V(-1, 0, 0));
	AddExhaust (rcs[15], 0.30, 0.02, _V(-0.9864841, 0.263632, 1.114589), _V(-1, 0, 0));
	AddExhaust (rcs[16], 0.30, 0.02, _V( 0.5368665,-0.5586355,-1.519011), _V( 0,-1, 0));
	AddExhaust (rcs[17], 0.30, 0.02, _V(-0.5122445,-0.5586355,-1.519011), _V( 0,-1, 0));
	AddExhaust (rcs[18], 0.30, 0.02, _V(-0.8804545,-0.5586355, 1.114589), _V( 0,-1, 0));
	AddExhaust (rcs[19], 0.30, 0.02, _V( 0.9050765,-0.5586355, 1.114589), _V( 0,-1, 0));
	AddExhaust (rcs[20], 0.30, 0.02, _V( 0.5368665, 0.3651495,-1.519011), _V( 0, 1, 0));
	AddExhaust (rcs[21], 0.30, 0.02, _V(-0.5122445, 0.3651495,-1.519011), _V( 0, 1, 0));
	AddExhaust (rcs[22], 0.30, 0.02, _V( 0.9050765, 0.3669295, 1.114589), _V( 0, 1, 0));
	AddExhaust (rcs[23], 0.30, 0.02, _V(-0.8804545, 0.3669295, 1.114589), _V( 0, 1, 0));

	rcsgroup[0] = rcs[ 0];
	rcsgroup[1] = rcs[ 1];
	rcsgroup[2] = rcs[ 2];
	rcsgroup[3] = rcs[ 3];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_FORWARD);

	rcsgroup[0] = rcs[ 4];
	rcsgroup[1] = rcs[ 5];
	rcsgroup[2] = rcs[ 6];
	rcsgroup[3] = rcs[ 7];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BACK);

	rcsgroup[0] = rcs[ 8];
	rcsgroup[1] = rcs[ 9];
	rcsgroup[2] = rcs[10];
	rcsgroup[3] = rcs[11];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_LEFT);

	rcsgroup[0] = rcs[12];
	rcsgroup[1] = rcs[13];
	rcsgroup[2] = rcs[14];
	rcsgroup[3] = rcs[15];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_RIGHT);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[17];
	rcsgroup[2] = rcs[18];
	rcsgroup[3] = rcs[19];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_UP);

	rcsgroup[0] = rcs[20];
	rcsgroup[1] = rcs[21];
	rcsgroup[2] = rcs[22];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_DOWN);

	rcsgroup[0] = rcs[18];
	rcsgroup[1] = rcs[19];
	rcsgroup[2] = rcs[20];
	rcsgroup[3] = rcs[21];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_PITCHUP);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[17];
	rcsgroup[2] = rcs[22];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_PITCHDOWN);

	rcsgroup[0] = rcs[10]; 
	rcsgroup[1] = rcs[11]; 
	rcsgroup[2] = rcs[12]; 
	rcsgroup[3] = rcs[13]; 
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_YAWLEFT);

	rcsgroup[0] = rcs[8];
	rcsgroup[1] = rcs[9];
	rcsgroup[2] = rcs[14];
	rcsgroup[3] = rcs[15];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_YAWRIGHT);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[19];
	rcsgroup[2] = rcs[21];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BANKLEFT);

	rcsgroup[0] = rcs[17];
	rcsgroup[1] = rcs[18];
	rcsgroup[2] = rcs[20];
	rcsgroup[3] = rcs[22];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BANKRIGHT);

	AddExhaustStream (rcs[ 0], _V( 0.537311,-0.455072,-1.622), &exhaust_RCS);
	AddExhaustStream (rcs[ 1], _V( 0.537311, 0.261586,-1.622), &exhaust_RCS);
	AddExhaustStream (rcs[ 2], _V(-0.512689, 0.261586,-1.622), &exhaust_RCS);
	AddExhaustStream (rcs[ 3], _V(-0.512689,-0.455072,-1.622), &exhaust_RCS);
	AddExhaustStream (rcs[ 4], _V( 0.905521,-0.455062, 1.217578), &exhaust_RCS);
	AddExhaustStream (rcs[ 5], _V(-0.880899,-0.455062, 1.217578), &exhaust_RCS);
	AddExhaustStream (rcs[ 6], _V( 0.905521, 0.2633565, 1.217578), &exhaust_RCS);
	AddExhaustStream (rcs[ 7], _V(-0.880899, 0.2633565, 1.217578), &exhaust_RCS);
	AddExhaustStream (rcs[ 8], _V( 0.642896,-0.455348,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[ 9], _V( 0.642896, 0.261862,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[10], _V( 1.011106,-0.455338, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[11], _V( 1.011106, 0.263632, 1.114589), &exhaust_RCS);					  
	AddExhaustStream (rcs[12], _V(-0.618274,-0.455348,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[13], _V(-0.618274, 0.261862,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[14], _V(-0.9864841,-0.455338, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[15], _V(-0.9864841, 0.263632, 1.114589), &exhaust_RCS);						  
	AddExhaustStream (rcs[16], _V( 0.5368665,-0.5586355,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[17], _V(-0.5122445,-0.5586355,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[18], _V(-0.8804545,-0.5586355, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[19], _V( 0.9050765,-0.5586355, 1.114589), &exhaust_RCS);					  
	AddExhaustStream (rcs[20], _V( 0.5368665, 0.3651495,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[21], _V(-0.5122445, 0.3651495,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[22], _V( 0.9050765, 0.3669295, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[23], _V(-0.8804545, 0.3669295, 1.114589), &exhaust_RCS);

	// Mesh
	AddMesh("ChapmanInner1");
}

void ChapmanInner1::clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv)
{
	if (getfocus)
	{
		oapiDisableMFDMode (MFD_LANDING);
		oapiDisableMFDMode (MFD_HSI);
	}
}

// This is new:
void ChapmanInner1::clbkPostStep (double simt, double simdt, double mjd)
{
	th_main_level = GetThrusterGroupLevel (THGROUP_MAIN);
}

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

DLLCLBK void ovcExit (VESSEL *vessel)
{
	if (vessel) delete (ChapmanInner1*)vessel;
}

But at least, the particle streams now work, so I thank you for that!
 
Last edited:

Izack

Non sequitur
Addon Developer
Joined
Feb 4, 2010
Messages
6,665
Reaction score
13
Points
113
Location
The Wilderness, N.B.
th_main_level should be declared as part of your class as a double. Also, le->SetIntensityRef() should also be placed in clbkPostStep(), as it needs to be called every frame. clbkSetClassCaps() is called only once during vessel creation, so the light intensity would also be set only once.

Alternatively, you can declare "le" as part of your class and just use:
Code:
void ChapmanInner1::clbkPostStep (double simt, double simdt, double mjd)
{
    ...
    le->SetIntensityRef(GetThrusterGroupLevel(THGROUP_MAIN);
}

The key issue here is that objects declared inside a function are available only inside the scope of that function (between the curly braces.) If you want variables or other objects to be available between functions, they must be defined 'higher up' in the scope: in this case, in the ChapmanInner1 class which all the functions are part of.

The warnings about truncation from double to float I believe can be safely ignored. The literals you're using for the colour values are being stored automatically as double-precision floating point numbers, and COLOUR4 is composed of four single-precision floating point numbers. The compiler is implicitly converting them, truncating data, which in this case is only unseen zeroes.
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
Also, le->SetIntensityRef() should also be placed in clbkPostStep(), as it needs to be called every frame.
I haven't checked that, but does it really? It takes a pointer to variable holding the value, and not the value itself. For example beacon functions which take the pointer don't require re-registering the beacon after the referenced BEACONLIGHTSPEC changed. SetIntensity (without Ref) on the other hand, which takes an intensity value directly would need to be called every frame.

Well, I haven't checked the code yet, so there might be something else missing. :p
 

Izack

Non sequitur
Addon Developer
Joined
Feb 4, 2010
Messages
6,665
Reaction score
13
Points
113
Location
The Wilderness, N.B.
I haven't checked that, but does it really? It takes a pointer to variable holding the value, and not the value itself. For example beacon functions which take the pointer don't require re-registering the beacon after the referenced BEACONLIGHTSPEC changed. SetIntensity (without Ref) on the other hand, which takes an intensity value directly would need to be called every frame.

Well, I haven't checked the code yet, so there might be something else missing. :p

Come to think of it, I haven't checked either. I've only used SetIntensity() before.
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
OK, I now have this setup
PHP:
void ChapmanInner1::clbkPostStep (double simt, double simdt, double mjd)
{
	double th_main_level = GetThrusterGroupLevel (THGROUP_MAIN);
	le->SetIntensityRef (&th_main_level);
}

...

void ChapmanInner1::clbkSetClassCaps (FILEHANDLE cfg)
{
...
	COLOUR4 col_d = {0.9,0.8,1,0};
	COLOUR4 col_s = {1.9,0.8,1,0};
	COLOUR4 col_a = {0,0,0,0};
	COLOUR4 col_white = {1,1,1,0};
	LightEmitter *le = AddPointLight (_V(0,0,-10), 200, 1e-3, 0, 2e-3, col_d, col_s, col_a);
...
}
Now I get two errors (in addition to the four "initializing" errors) saying
Code:
error C2065: 'le' : undeclared identifier
error C2227: left of '->SetIntensityRef' must point to class/struct/union/generic type

Then if I put the
Code:
le->SetIntensityRef (&th_main_level);
in the clbkSetClassCaps, I get only one error, saying
Code:
error C2065: 'th_main_level' : undeclared identifier
in response to the
PHP:
void ChapmanInner1::clbkSetClassCaps (FILEHANDLE cfg)
{
...
	le->SetIntensityRef (&th_main_level);
...
}

If I then only have
PHP:
void ChapmanInner1::clbkPostStep (double simt, double simdt, double mjd)
{
	le->SetIntensityRef(GetThrusterGroupLevel(THGROUP_MAIN));
}
I get the errors
Code:
error C2065: 'le' : undeclared identifier
error C2227: left of '->SetIntensityRef' must point to class/struct/union/generic type

So it still won't work...
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
Declare `th_main_level` in the class interface declaration (remove local (re)declaration in clbkPostStep), and remove `le->SetIntensityRef (&th_main_level);` from clbkPostStep, e.g.:
Code:
class ChapmanInner1: public VESSEL3 {
private:
    double th_main_level;
Code:
void ChapmanInner1::clbkPostStep (double simt, double simdt, double mjd) {
    th_main_level = GetThrusterGroupLevel (THGROUP_MAIN);
}
You most likely will need to initialize it with 0.0 in clbkSetClassCaps, or in the constructor.
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
Hi again. Thank you for the solution about local lights!

I have progressed in my code and a new problem has poped up. This time it's about animations:

I am animating the deployment of a solar array, and am therefore using the parent feature.

Here is the corresponding code:
PHP:
void ChapmanInner1::DefineAnimations (void)
{
	ANIMATIONCOMPONENT_HANDLE parent;

	static UINT solardeploy1[1] = {91};
	anim_solar_deploy[0] = new MGROUP_ROTATE (0, solardeploy1, 1, _V(-0.996575,-0.3313698, 0), _V( 0, 0, 1), (float)(90*RAD));
	anim_solar_deploy1 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy1, 0, 1, anim_solar_deploy[0]);

	static UINT solardeploy2[3] = {92, 227, 293};
	anim_solar_deploy[1] = new MGROUP_ROTATE (0, solardeploy2, 3, _V(-1.032802, 0.1059157, 0), _V( 0, 0, 1), (float)(-180*RAD));
	anim_solar_deploy2 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy2, 0, 1, anim_solar_deploy[1], parent);

	static UINT solardeploy3[2] = {15, 16};
	anim_solar_deploy[2] = new MGROUP_ROTATE (0, solardeploy3, 2, _V(-1.04143,-0.592322, 0), _V( 0, 0, 1), (float)(90*RAD));
	anim_solar_deploy3 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy3, 0, 1, anim_solar_deploy[2], parent);

	static UINT solardeploy4[2] = {200, 290};
	anim_solar_deploy[3] = new MGROUP_ROTATE (0, solardeploy4, 2, _V(-1.058424,-0.592322, 0), _V( 0, 0, 1), (float)(90*RAD));
	anim_solar_deploy4 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy4, 0, 1, anim_solar_deploy[3], parent);

	anim_solar_deploy[4] = new MGROUP_ROTATE (LOCALVERTEXLIST, MAKEGROUPARRAY (solar_deploy5), 2, _V(-1.065472,0.1077438, 0), _V( 0, 0, 1), (float)(-90*RAD));
	anim_solar_deploy5 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy5, 0, 1, anim_solar_deploy[4], parent);
}

When compiling, I get this error
Code:
error C2109: subscript requires array or pointer type
for every line of the type
Code:
anim_solar_deploy[n] = new MGROUP_ROTATE ...

parent = AddAnimationComponent ...

Do anyone of you know the solution for this error?
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
How is `anim_solar_deploy` declared?
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
PHP:
class ChapmanInner1: public VESSEL3
{
private:
	UINT anim_solar_deploy;
Declare it this way instead:
PHP:
class ChapmanInner1: public VESSEL3
{
private:
	MGROUP_TRANSFORM * anim_solar_deploy [5];
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
OK, new errors. This time it says
Code:
error C2440: '=' : cannot convert from 'MGROUP_ROTATE *' to 'UINT *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

error C2664: 'VESSEL::AddAnimationComponent' : cannot convert parameter 4 from 'UINT *' to 'MGROUP_TRANSFORM *'
1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

The C2440's are for the strings starting with
Code:
anim_solar_deploy[n] = new MGROUP_ROTATE ...
and the C2664's are for the strings starting with
Code:
parent = AddAnimationComponent ...


---------- Post added at 20:16 ---------- Previous post was at 20:15 ----------

By the way, the whole code now is
PHP:
#define STRICT
#define ORBITER_MODULE

#include "orbitersdk.h"

const double ARRAY_OPERATING_SPEED = 0.033;

class ChapmanInner1: public VESSEL3
{
private:
	double MAIN_THRUST_LEVEL;
	double RCS_ATT_FORWARD_LEVEL;
	double RCS_ATT_BACK_LEVEL;
	double RCS_ATT_LEFT_LEVEL;
	double RCS_ATT_RIGHT_LEVEL;
	double RCS_ATT_UP_LEVEL;
	double RCS_ATT_DOWN_LEVEL;
	double RCS_ATT_PITCHUP_LEVEL;
	double RCS_ATT_PITCHDOWN_LEVEL;
	double RCS_ATT_YAWLEFT_LEVEL;
	double RCS_ATT_YAWRIGHT_LEVEL;
	double RCS_ATT_BANKLEFT_LEVEL;
	double RCS_ATT_BANKRIGHT_LEVEL;
	
	UINT * anim_solar_deploy [5];
	UINT anim_solar_deploy1;
	UINT anim_solar_deploy2;
	UINT anim_solar_deploy3;
	UINT anim_solar_deploy4;
	UINT anim_solar_deploy5;
	UINT solar_deploy5;
	double solar_deploy_proc;

	ANIMATIONCOMPONENT_HANDLE parent;
public:
	enum DoorStatus { ARRAY_CLOSED, ARRAY_OPEN, ARRAY_CLOSING, ARRAY_OPENING } solar_deploy_status;
	ChapmanInner1 (OBJHANDLE hVessel, int flightmodel)
		: VESSEL3 (hVessel, flightmodel)
	{
		solar_deploy_status = ARRAY_CLOSED;
		solar_deploy_proc = 0.0;
		DefineAnimations ();
	}
	void clbkSetClassCaps (FILEHANDLE cfg);
	void clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv);
	void clbkPostStep (double simt, double simdt, double mjd);

	void DefineAnimations (void);
	void ActivateArray (DoorStatus action);
	void RevertArray (void);

	void clbkLoadStateEx (FILEHANDLE scn, void *vs);
	void clbkSaveState (FILEHANDLE scn);

	int clbkConsumeBufferedKey (DWORD key, bool down, char *kstate);
};

void ChapmanInner1::clbkPostStep (double simt, double simdt, double mjd)
{
	MAIN_THRUST_LEVEL = GetThrusterGroupLevel (THGROUP_MAIN);
	RCS_ATT_FORWARD_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_FORWARD);
	RCS_ATT_BACK_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_BACK);
	RCS_ATT_LEFT_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_LEFT);
	RCS_ATT_RIGHT_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_RIGHT);
	RCS_ATT_UP_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_UP);
	RCS_ATT_DOWN_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_DOWN);
	RCS_ATT_PITCHUP_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_PITCHUP);
	RCS_ATT_PITCHDOWN_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_PITCHDOWN);
	RCS_ATT_YAWLEFT_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_YAWLEFT);
	RCS_ATT_YAWRIGHT_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_YAWRIGHT);
	RCS_ATT_BANKLEFT_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_BANKLEFT);
	RCS_ATT_BANKRIGHT_LEVEL = GetThrusterGroupLevel (THGROUP_ATT_BANKRIGHT);

	// Animation solar array deploy
	if (solar_deploy_status >= ARRAY_CLOSING)
	{
		double da = simdt * ARRAY_OPERATING_SPEED;
		if (solar_deploy_status == ARRAY_CLOSING)
		{
			if (solar_deploy_proc > 0.0) solar_deploy_proc = max (0.0, solar_deploy_proc-da);
			else                  solar_deploy_status = ARRAY_CLOSED;
		}
		else
		{
			if (solar_deploy_proc < 1.0) solar_deploy_proc = min (1.0, solar_deploy_proc+da);
			else                  solar_deploy_status = ARRAY_OPEN;
		}
		SetAnimation (anim_solar_deploy1, solar_deploy_proc);
	}
}

void ChapmanInner1::clbkSetClassCaps (FILEHANDLE cfg)
{
	SetSize (4);
	SetEmptyMass (679);
	SetCW (0.3, 0.3, 1.5, 1.5);
	SetCrossSections (_V(5.73, 4.37, 4.08));
	SetRotDrag (_V(2,2,2));
	SetPMI (_V(0.5, 0.5, 0.5));
	SetCameraOffset (_V(-0.449269, 0.126477, 1.24));
	SetTouchdownPoints (_V( 0.000, 0.531,-1.550), _V(-0.248, 1.300, 0.055), _V( 0.182, 1.298, 0.055));

	InitNavRadios (3);

	const double MAINFUELMASS = 980;
	const double RCSFUELMASS = 50;

	const double ISPMAINVAC = 3500;
	const double ISPMAINATM = 35;
	const double ISPRCSVAC = 1300;
	const double ISPRCSATM = 13;

	const double MAINTHRUST = 2500;
	const double RCSTHRUST = 2;

	PROPELLANT_HANDLE MainTank;
	MainTank = CreatePropellantResource (MAINFUELMASS);

	PROPELLANT_HANDLE RCSTank;
	RCSTank = CreatePropellantResource (RCSFUELMASS);

	THRUSTER_HANDLE main, rcs[24], rcsgroup[4];

	PARTICLESTREAMSPEC exhaust_main =
    {
        0, 0.1, 100, 10, 0.01, 0.05, 1, 3, PARTICLESTREAMSPEC::DIFFUSE,
        PARTICLESTREAMSPEC::LVL_SQRT, 1, 1,
        PARTICLESTREAMSPEC::ATM_PLIN, 1.25
    };

	PARTICLESTREAMSPEC exhaust_RCS =
    {
        0, 0.015, 200, 1.5, 0.01, 0.05, 0.25, 3, PARTICLESTREAMSPEC::DIFFUSE,
        PARTICLESTREAMSPEC::LVL_SQRT, 1, 1,
        PARTICLESTREAMSPEC::ATM_PLIN, 1.25
    };

	main = CreateThruster (_V( 0, 0, -2.0), _V(0, 0, 1), MAINTHRUST, MainTank, ISPMAINVAC, ISPMAINATM);
	CreateThrusterGroup (&main, 1, THGROUP_MAIN);
	AddExhaust (main, 2.0, 0.125, _V(0.012311, -0.026071, -2.0), _V(0, 0, -1));

	AddExhaustStream (main, _V( 0.012311, -0.026071, -2.0), &exhaust_main);
	
	MAIN_THRUST_LEVEL = 0.0;
	RCS_ATT_FORWARD_LEVEL = 0.0;
	RCS_ATT_BACK_LEVEL = 0.0;
	RCS_ATT_LEFT_LEVEL = 0.0;
	RCS_ATT_RIGHT_LEVEL = 0.0;
	RCS_ATT_UP_LEVEL = 0.0;
	RCS_ATT_DOWN_LEVEL = 0.0;
	RCS_ATT_PITCHUP_LEVEL = 0.0;
	RCS_ATT_PITCHDOWN_LEVEL = 0.0;
	RCS_ATT_YAWLEFT_LEVEL = 0.0;
	RCS_ATT_YAWRIGHT_LEVEL = 0.0;
	RCS_ATT_BANKLEFT_LEVEL = 0.0;
	RCS_ATT_BANKRIGHT_LEVEL = 0.0;

	COLOUR4 col_d = {0.9,0.8,1,0};
	COLOUR4 col_s = {1.9,0.8,1,0};
	COLOUR4 col_a = {0,0,0,0};
	COLOUR4 col_white = {1,1,1,0};

	// Main
	LightEmitter *main_light = AddPointLight (_V( 0.012311, -0.026071, -2.0), 50, 0.1, -0.01, 0.2, col_d, col_s, col_a);
	main_light->SetIntensityRef (&MAIN_THRUST_LEVEL);

	const double rcs_range = 0.5;

	const double rcs_att_0 = 2;
	const double rcs_att_1 = -0.01;
	const double rcs_att_2 = 10;

	// RCS
	LightEmitter *rcs0_light = AddPointLight (_V( 0.537311,-0.455072,-1.656), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs0_light->SetIntensityRef (&RCS_ATT_FORWARD_LEVEL);

	LightEmitter *rcs1_light = AddPointLight (_V( 0.537311, 0.261586,-1.656), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs1_light->SetIntensityRef (&RCS_ATT_FORWARD_LEVEL);

	LightEmitter *rcs2_light = AddPointLight (_V(-0.512689, 0.261586,-1.656), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs2_light->SetIntensityRef (&RCS_ATT_FORWARD_LEVEL);					  
																			  
	LightEmitter *rcs3_light = AddPointLight (_V(-0.512689,-0.455072,-1.656), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs3_light->SetIntensityRef (&RCS_ATT_FORWARD_LEVEL);

	LightEmitter *rcs4_light = AddPointLight (_V( 0.905521,-0.455062, 1.251697), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs4_light->SetIntensityRef (&RCS_ATT_BACK_LEVEL);							  
																				  
	LightEmitter *rcs5_light = AddPointLight (_V(-0.880899,-0.455062, 1.251697), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs5_light->SetIntensityRef (&RCS_ATT_BACK_LEVEL);

	LightEmitter *rcs6_light = AddPointLight (_V( 0.905521, 0.2633565, 1.251697), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs6_light->SetIntensityRef (&RCS_ATT_BACK_LEVEL);							  
																				  
	LightEmitter *rcs7_light = AddPointLight (_V(-0.880899, 0.2633565, 1.251697), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs7_light->SetIntensityRef (&RCS_ATT_BACK_LEVEL);

	LightEmitter *rcs8_light = AddPointLight (_V( 0.677015,-0.455348,-1.519011), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs8_light->SetIntensityRef (&RCS_ATT_LEFT_LEVEL);
	rcs8_light->SetIntensityRef (&RCS_ATT_YAWRIGHT_LEVEL);

	LightEmitter *rcs9_light = AddPointLight (_V( 0.677015, 0.261862,-1.519011), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs9_light->SetIntensityRef (&RCS_ATT_LEFT_LEVEL);
	rcs9_light->SetIntensityRef (&RCS_ATT_YAWRIGHT_LEVEL);

	LightEmitter *rcs10_light = AddPointLight (_V( 1.045225,-0.455338, 1.114589), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs10_light->SetIntensityRef (&RCS_ATT_LEFT_LEVEL);							  
	rcs10_light->SetIntensityRef (&RCS_ATT_YAWLEFT_LEVEL);						  
																				  
	LightEmitter *rcs11_light = AddPointLight (_V( 1.045225, 0.263632, 1.114589), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs11_light->SetIntensityRef (&RCS_ATT_LEFT_LEVEL);
	rcs11_light->SetIntensityRef (&RCS_ATT_YAWLEFT_LEVEL);

	LightEmitter *rcs12_light = AddPointLight (_V(-0.6523932,-0.455348,-1.519011), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs12_light->SetIntensityRef (&RCS_ATT_RIGHT_LEVEL);						   
	rcs12_light->SetIntensityRef (&RCS_ATT_YAWLEFT_LEVEL);						   
																				   
	LightEmitter *rcs13_light = AddPointLight (_V(-0.6523932, 0.261862,-1.519011), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs13_light->SetIntensityRef (&RCS_ATT_RIGHT_LEVEL);							 
	rcs13_light->SetIntensityRef (&RCS_ATT_YAWLEFT_LEVEL);							 
																					 
	LightEmitter *rcs14_light = AddPointLight (_V(-1.0206033,-0.455338, 1.114589), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs14_light->SetIntensityRef (&RCS_ATT_RIGHT_LEVEL);						   
	rcs14_light->SetIntensityRef (&RCS_ATT_YAWRIGHT_LEVEL);						   
																				   
	LightEmitter *rcs15_light = AddPointLight (_V(-1.0206033, 0.263632, 1.114589), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs15_light->SetIntensityRef (&RCS_ATT_RIGHT_LEVEL);
	rcs15_light->SetIntensityRef (&RCS_ATT_YAWRIGHT_LEVEL);

	LightEmitter *rcs16_light = AddPointLight (_V( 0.5368665,-0.5927542,-1.519011), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs16_light->SetIntensityRef (&RCS_ATT_UP_LEVEL);
	rcs16_light->SetIntensityRef (&RCS_ATT_PITCHDOWN_LEVEL);
	rcs16_light->SetIntensityRef (&RCS_ATT_BANKLEFT_LEVEL);
	
	LightEmitter *rcs17_light = AddPointLight (_V(-0.5122445,-0.5927542,-1.519011), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs17_light->SetIntensityRef (&RCS_ATT_UP_LEVEL);
	rcs17_light->SetIntensityRef (&RCS_ATT_PITCHDOWN_LEVEL);
	rcs17_light->SetIntensityRef (&RCS_ATT_BANKRIGHT_LEVEL);

	LightEmitter *rcs18_light = AddPointLight (_V(-0.8804545,-0.5927542, 1.114589), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs18_light->SetIntensityRef (&RCS_ATT_UP_LEVEL);								 
	rcs18_light->SetIntensityRef (&RCS_ATT_PITCHUP_LEVEL);							 
	rcs18_light->SetIntensityRef (&RCS_ATT_BANKRIGHT_LEVEL);						 
																					 
	LightEmitter *rcs19_light = AddPointLight (_V( 0.9050765,-0.5927542, 1.114589), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs19_light->SetIntensityRef (&RCS_ATT_UP_LEVEL);
	rcs19_light->SetIntensityRef (&RCS_ATT_PITCHUP_LEVEL);
	rcs19_light->SetIntensityRef (&RCS_ATT_BANKLEFT_LEVEL);

	LightEmitter *rcs20_light = AddPointLight (_V( 0.5368665, 0.3992687,-1.519011), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs20_light->SetIntensityRef (&RCS_ATT_DOWN_LEVEL);								 
	rcs20_light->SetIntensityRef (&RCS_ATT_PITCHUP_LEVEL);							 
	rcs20_light->SetIntensityRef (&RCS_ATT_BANKRIGHT_LEVEL);						 
																					 
	LightEmitter *rcs21_light = AddPointLight (_V(-0.5122445, 0.3992687,-1.519011), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs21_light->SetIntensityRef (&RCS_ATT_DOWN_LEVEL);
	rcs21_light->SetIntensityRef (&RCS_ATT_PITCHUP_LEVEL);
	rcs21_light->SetIntensityRef (&RCS_ATT_BANKLEFT_LEVEL);

	LightEmitter *rcs22_light = AddPointLight (_V( 0.9050765, 0.3992687, 1.114589), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs22_light->SetIntensityRef (&RCS_ATT_DOWN_LEVEL);								 
	rcs22_light->SetIntensityRef (&RCS_ATT_PITCHDOWN_LEVEL);						 
	rcs22_light->SetIntensityRef (&RCS_ATT_BANKRIGHT_LEVEL);						 
																					 
	LightEmitter *rcs23_light = AddPointLight (_V(-0.8804545, 0.3992687, 1.114589), rcs_range, rcs_att_0, rcs_att_1, rcs_att_2, col_d, col_s, col_a);
	rcs23_light->SetIntensityRef (&RCS_ATT_DOWN_LEVEL);
	rcs23_light->SetIntensityRef (&RCS_ATT_PITCHDOWN_LEVEL);
	rcs23_light->SetIntensityRef (&RCS_ATT_BANKLEFT_LEVEL);

	rcs[ 0] = CreateThruster (_V( 0.512689,-0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 1] = CreateThruster (_V( 0.512689, 0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 2] = CreateThruster (_V(-0.512689, 0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 3] = CreateThruster (_V(-0.512689,-0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 4] = CreateThruster (_V( 0.880899,-0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 5] = CreateThruster (_V(-0.880899,-0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 6] = CreateThruster (_V( 0.880899, 0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 7] = CreateThruster (_V(-0.880899, 0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 8] = CreateThruster (_V( 0.618274,-0.261586,-1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[ 9] = CreateThruster (_V( 0.618274, 0.261586,-1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[10] = CreateThruster (_V( 0.618274,-0.261586, 1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[11] = CreateThruster (_V( 0.618274, 0.261586, 1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[12] = CreateThruster (_V(-0.618274,-0.261586,-1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[13] = CreateThruster (_V(-0.618274, 0.261586,-1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[14] = CreateThruster (_V(-0.618274,-0.261586, 1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[15] = CreateThruster (_V(-0.618274, 0.261586, 1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[16] = CreateThruster (_V( 0.512689,-0.5586355,-1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[17] = CreateThruster (_V(-0.512689,-0.5586355,-1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[18] = CreateThruster (_V(-0.512689,-0.5586355, 1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[19] = CreateThruster (_V( 0.512689,-0.5586355, 1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[20] = CreateThruster (_V( 0.512689, 0.3651495,-1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[21] = CreateThruster (_V(-0.512689, 0.3651495,-1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[22] = CreateThruster (_V( 0.512689, 0.3651495, 1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
	rcs[23] = CreateThruster (_V(-0.512689, 0.3651495, 1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);

	AddExhaust (rcs[ 0], 0.30, 0.02, _V( 0.537311,-0.455072,-1.656), _V( 0, 0,-1));
	AddExhaust (rcs[ 1], 0.30, 0.02, _V( 0.537311, 0.261586,-1.656), _V( 0, 0,-1));
	AddExhaust (rcs[ 2], 0.30, 0.02, _V(-0.512689, 0.261586,-1.656), _V( 0, 0,-1));
	AddExhaust (rcs[ 3], 0.30, 0.02, _V(-0.512689,-0.455072,-1.656), _V( 0, 0,-1));
	AddExhaust (rcs[ 4], 0.30, 0.02, _V( 0.905521,-0.455062, 1.251697), _V( 0, 0, 1));
	AddExhaust (rcs[ 5], 0.30, 0.02, _V(-0.880899,-0.455062, 1.251697), _V( 0, 0, 1));
	AddExhaust (rcs[ 6], 0.30, 0.02, _V( 0.905521, 0.2633565, 1.251697), _V( 0, 0, 1));
	AddExhaust (rcs[ 7], 0.30, 0.02, _V(-0.880899, 0.2633565, 1.251697), _V( 0, 0, 1));
	AddExhaust (rcs[ 8], 0.30, 0.02, _V( 0.677015,-0.455348,-1.519011), _V( 1, 0, 0));
	AddExhaust (rcs[ 9], 0.30, 0.02, _V( 0.677015, 0.261862,-1.519011), _V( 1, 0, 0));
	AddExhaust (rcs[10], 0.30, 0.02, _V( 1.045225,-0.455338, 1.114589), _V( 1, 0, 0));
	AddExhaust (rcs[11], 0.30, 0.02, _V( 1.045225, 0.263632, 1.114589), _V( 1, 0, 0));
	AddExhaust (rcs[12], 0.30, 0.02, _V(-0.6523932,-0.455348,-1.519011), _V(-1, 0, 0));
	AddExhaust (rcs[13], 0.30, 0.02, _V(-0.6523932, 0.261862,-1.519011), _V(-1, 0, 0));
	AddExhaust (rcs[14], 0.30, 0.02, _V(-1.0206033,-0.455338, 1.114589), _V(-1, 0, 0));
	AddExhaust (rcs[15], 0.30, 0.02, _V(-1.0206033, 0.263632, 1.114589), _V(-1, 0, 0));
	AddExhaust (rcs[16], 0.30, 0.02, _V( 0.5368665,-0.5927542,-1.519011), _V( 0,-1, 0));
	AddExhaust (rcs[17], 0.30, 0.02, _V(-0.5122445,-0.5927542,-1.519011), _V( 0,-1, 0));
	AddExhaust (rcs[18], 0.30, 0.02, _V(-0.8804545,-0.5927542, 1.114589), _V( 0,-1, 0));
	AddExhaust (rcs[19], 0.30, 0.02, _V( 0.9050765,-0.5927542, 1.114589), _V( 0,-1, 0));
	AddExhaust (rcs[20], 0.30, 0.02, _V( 0.5368665, 0.3992687,-1.519011), _V( 0, 1, 0));
	AddExhaust (rcs[21], 0.30, 0.02, _V(-0.5122445, 0.3992687,-1.519011), _V( 0, 1, 0));
	AddExhaust (rcs[22], 0.30, 0.02, _V( 0.9050765, 0.3992687, 1.114589), _V( 0, 1, 0));
	AddExhaust (rcs[23], 0.30, 0.02, _V(-0.8804545, 0.3992687, 1.114589), _V( 0, 1, 0));

	rcsgroup[0] = rcs[ 0];
	rcsgroup[1] = rcs[ 1];
	rcsgroup[2] = rcs[ 2];
	rcsgroup[3] = rcs[ 3];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_FORWARD);

	rcsgroup[0] = rcs[ 4];
	rcsgroup[1] = rcs[ 5];
	rcsgroup[2] = rcs[ 6];
	rcsgroup[3] = rcs[ 7];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BACK);

	rcsgroup[0] = rcs[ 8];
	rcsgroup[1] = rcs[ 9];
	rcsgroup[2] = rcs[10];
	rcsgroup[3] = rcs[11];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_LEFT);

	rcsgroup[0] = rcs[12];
	rcsgroup[1] = rcs[13];
	rcsgroup[2] = rcs[14];
	rcsgroup[3] = rcs[15];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_RIGHT);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[17];
	rcsgroup[2] = rcs[18];
	rcsgroup[3] = rcs[19];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_UP);

	rcsgroup[0] = rcs[20];
	rcsgroup[1] = rcs[21];
	rcsgroup[2] = rcs[22];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_DOWN);

	rcsgroup[0] = rcs[18];
	rcsgroup[1] = rcs[19];
	rcsgroup[2] = rcs[20];
	rcsgroup[3] = rcs[21];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_PITCHUP);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[17];
	rcsgroup[2] = rcs[22];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_PITCHDOWN);

	rcsgroup[0] = rcs[10]; 
	rcsgroup[1] = rcs[11]; 
	rcsgroup[2] = rcs[12]; 
	rcsgroup[3] = rcs[13]; 
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_YAWLEFT);

	rcsgroup[0] = rcs[8];
	rcsgroup[1] = rcs[9];
	rcsgroup[2] = rcs[14];
	rcsgroup[3] = rcs[15];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_YAWRIGHT);

	rcsgroup[0] = rcs[16];
	rcsgroup[1] = rcs[19];
	rcsgroup[2] = rcs[21];
	rcsgroup[3] = rcs[23];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BANKLEFT);

	rcsgroup[0] = rcs[17];
	rcsgroup[1] = rcs[18];
	rcsgroup[2] = rcs[20];
	rcsgroup[3] = rcs[22];
	CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BANKRIGHT);

	AddExhaustStream (rcs[ 0], _V( 0.537311,-0.455072,-1.656), &exhaust_RCS);
	AddExhaustStream (rcs[ 1], _V( 0.537311, 0.261586,-1.656), &exhaust_RCS);
	AddExhaustStream (rcs[ 2], _V(-0.512689, 0.261586,-1.656), &exhaust_RCS);
	AddExhaustStream (rcs[ 3], _V(-0.512689,-0.455072,-1.656), &exhaust_RCS);
	AddExhaustStream (rcs[ 4], _V( 0.905521,-0.455062, 1.251697), &exhaust_RCS);
	AddExhaustStream (rcs[ 5], _V(-0.880899,-0.455062, 1.251697), &exhaust_RCS);
	AddExhaustStream (rcs[ 6], _V( 0.905521, 0.2633565, 1.251697), &exhaust_RCS);
	AddExhaustStream (rcs[ 7], _V(-0.880899, 0.2633565, 1.251697), &exhaust_RCS);
	AddExhaustStream (rcs[ 8], _V( 0.677015,-0.455348,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[ 9], _V( 0.677015, 0.261862,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[10], _V( 1.045225,-0.455338, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[11], _V( 1.045225, 0.263632, 1.114589), &exhaust_RCS);					  
	AddExhaustStream (rcs[12], _V(-0.6523932,-0.455348,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[13], _V(-0.6523932, 0.261862,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[14], _V(-1.0206033,-0.455338, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[15], _V(-1.0206033, 0.263632, 1.114589), &exhaust_RCS);						  
	AddExhaustStream (rcs[16], _V( 0.5368665,-0.5927542,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[17], _V(-0.5122445,-0.5927542,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[18], _V(-0.8804545,-0.5927542, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[19], _V( 0.9050765,-0.5927542, 1.114589), &exhaust_RCS);					  
	AddExhaustStream (rcs[20], _V( 0.5368665, 0.3992687,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[21], _V(-0.5122445, 0.3992687,-1.519011), &exhaust_RCS);
	AddExhaustStream (rcs[22], _V( 0.9050765, 0.3992687, 1.114589), &exhaust_RCS);
	AddExhaustStream (rcs[23], _V(-0.8804545, 0.3992687, 1.114589), &exhaust_RCS);

	AddMesh("ChapmanInner1");
}

void ChapmanInner1::clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv)
{
	if (getfocus)
	{
		oapiDisableMFDMode (MFD_LANDING);
		oapiDisableMFDMode (MFD_HSI);
	}
}

void ChapmanInner1::DefineAnimations (void)
{
	ANIMATIONCOMPONENT_HANDLE parent;

	static UINT solardeploy1[1] = {91};
	anim_solar_deploy[0] = new MGROUP_ROTATE (0, solardeploy1, 1, _V(-0.996575,-0.3313698, 0), _V( 0, 0, 1), (float)(90*RAD));
	anim_solar_deploy1 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy1, 0, 1, anim_solar_deploy[0]);

	static UINT solardeploy2[3] = {92, 227, 293};
	anim_solar_deploy[1] = new MGROUP_ROTATE (0, solardeploy2, 3, _V(-1.032802, 0.1059157, 0), _V( 0, 0, 1), (float)(-180*RAD));
	anim_solar_deploy2 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy2, 0, 1, anim_solar_deploy[1], parent);

	static UINT solardeploy3[2] = {15, 16};
	anim_solar_deploy[2] = new MGROUP_ROTATE (0, solardeploy3, 2, _V(-1.04143,-0.592322, 0), _V( 0, 0, 1), (float)(90*RAD));
	anim_solar_deploy3 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy3, 0, 1, anim_solar_deploy[2], parent);

	static UINT solardeploy4[2] = {200, 290};
	anim_solar_deploy[3] = new MGROUP_ROTATE (0, solardeploy4, 2, _V(-1.058424,-0.592322, 0), _V( 0, 0, 1), (float)(90*RAD));
	anim_solar_deploy4 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy4, 0, 1, anim_solar_deploy[3], parent);

	anim_solar_deploy[4] = new MGROUP_ROTATE (LOCALVERTEXLIST, MAKEGROUPARRAY (solar_deploy5), 2, _V(-1.065472,0.1077438, 0), _V( 0, 0, 1), (float)(-90*RAD));
	anim_solar_deploy5 = CreateAnimation (0.0);
	parent = AddAnimationComponent (anim_solar_deploy5, 0, 1, anim_solar_deploy[4], parent);
}

void ChapmanInner1::ActivateArray (DoorStatus action)
{
	solar_deploy_status = action;
}

void ChapmanInner1::RevertArray (void)
{
	ActivateArray ((solar_deploy_status == ARRAY_CLOSED || solar_deploy_status == ARRAY_CLOSING) ?
		ARRAY_OPENING : ARRAY_CLOSING);
}

void ChapmanInner1::clbkLoadStateEx (FILEHANDLE scn, void *vs)
{
	char *line;

	while (oapiReadScenario_nextline (scn, line))
	{
		if (!_strnicmp (line, "SOLAR_ARRAYS", 12))
		{
			sscanf (line+12, "%d%lf", &solar_deploy_status, &solar_deploy_proc);
		}
		else
		{
			ParseScenarioLineEx (line, vs);
		}
	}

	SetAnimation (anim_solar_deploy1, solar_deploy_proc);
}

void ChapmanInner1::clbkSaveState (FILEHANDLE scn)
{
	char cbuf[256];
	SaveDefaultState (scn);
	sprintf (cbuf, "%d %0.4f", solar_deploy_status, solar_deploy_proc);
	oapiWriteScenario_string (scn, "SOLAR_ARRAYS", cbuf);
}

int ChapmanInner1::clbkConsumeBufferedKey (DWORD key, bool down, char *kstate)
{
	if (!down) return 0; // only process keydown events

	switch (key)
	{
		case OAPI_KEY_S: // deploy/fold solar arrays
			RevertArray();
			return 1;
	}

	return 0;
}

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

DLLCLBK void ovcExit (VESSEL *vessel)
{
	if (vessel) delete (ChapmanInner1*)vessel;
}
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
Did you read my post before or after I edited it? :p
 
Top