C++ Question Why am I getting these spotlight errors?

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
When I use this code

Code:
docking_light = (SpotLight*)AddSpotLight(_V(0.0,-1.022404,12.6), _V(0,0,1), 150, 1e-3, 0, 1e-3, RAD*25, RAD*60, col_white, col_white, col_a);
docking_light->Activate(true);
I get all these errors when trying to create a spotlight module. What have I forgotten in my header?
Code:
>spotlamp.cpp
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.h(12) : warning C4005: 'STRICT' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(16) : see previous definition of 'STRICT'
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.cpp(31) : error C2065: 'docking_light' : undeclared identifier
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.cpp(31) : error C2065: 'col_white' : undeclared identifier
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.cpp(31) : error C2065: 'col_white' : undeclared identifier
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.cpp(31) : error C2065: 'col_a' : undeclared identifier
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.cpp(31) : error C3861: 'AddSpotLight': identifier not found
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.cpp(32) : error C2065: 'docking_light' : undeclared identifier
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.cpp(32) : error C2227: left of '->Activate' must point to class/struct/union/generic type
1>        type is ''unknown-type''
1>Build log was saved at "file://c:\Users\crice\Documents\Visual Studio 2008\Projects\spotlamp\spotlamp\Debug\BuildLog.htm"
1>spotlamp - 7 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Here is my entire code:

Code:
#include <OrbiterAPI.h> 
#include "spotlamp.h"
#include "OrbiterSDK.h"

// ==============================================================
// Some vessel parameters
// ==============================================================
const double MASS = 5;
 

// ==============================================================
// Overloaded callback functions
// ==============================================================
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
void spotlamp::clbkSetClassCaps (FILEHANDLE cfg)
{
 
docking_light = (SpotLight*)AddSpotLight(_V(0.0,-1.022404,12.6), _V(0,0,1), 150, 1e-3, 0, 1e-3, RAD*25, RAD*60, col_white, col_white, col_a);
docking_light->Activate(true);


	 
	SetTouchdownPoints (_V(3.08,-4.5,-.534),_V(3.08,0,-.534),_V(3.08,4.5,-.534));

 

	// visual specs
	AddMesh ("spotlamp");
}


// --------------------------------------------------------------
// Save/load vessele state to/from scenario
// --------------------------------------------------------------	
void spotlamp::clbkLoadStateEx (FILEHANDLE scn, void *vs)
{		//commented code  is for reference only

	char *line;
	while (oapiReadScenario_nextline (scn, line)) {
		//if (!strnicmp (line, "SOMEPARAM", 9)) {
		//	sscanf (line+9, "%lf", somevar);
		//} else {
			ParseScenarioLineEx (line, vs);
			// unrecognised option - pass to Orbiter's generic parser
		//}
	}
}

void spotlamp::clbkSaveState (FILEHANDLE scn)
{		//commented code  is for reference only

	//char cbuf[256];
	// default vessel parameters
	VESSEL2::clbkSaveState (scn);

	// custom parameters
	//sprintf (cbuf, "%0.1f", somefloatpara,);
	//oapiWriteScenario_string (scn, "SOMEPARAM", cbuf);
}

// --------------------------------------------------------------
// Called at each simulation time step before the state is updated
// --------------------------------------------------------------
void spotlamp::clbkPreStep (double simt, double simdt, double mjd)
{	//do something
}

// --------------------------------------------------------------
//Keyboard state handler. Check OrbiterAPI reference for details
// --------------------------------------------------------------
int spotlamp::clbkConsumeBufferedKey (DWORD key, bool down, char *kstate)
{	return 0;
}


// ==============================================================
// API callback interface
// ==============================================================
// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
	return new spotlamp (hvessel, flightmodel);
}

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

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,406
Reaction score
588
Points
153
Location
Vienna
I get all these errors when trying to create a spotlight module. What have I forgotten in my header?

Looks like cargo-cult programming TBH. Sorry to say that, but it seems you are trying to code by means of putting snippets together without really knowing what's going on. If that is so, please keep in mind that - going forward - everything you assume to be the error could very probably be totally wrong.

First of all: your problem seems to be unrelated to spotlights at all. Second, why do you include both OrbiterAPI.h and OrbiterSDK.h? Third, if that is your entire code, where is the header file?

I can only guess here, but it looks like you never declared docking_light as a field. Same with col_white and col_a, which you also never initialized.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,856
Reaction score
2,826
Points
203
Location
Dallas, TX
Not sure if you are adding spotlights to a vessel or compiling the spotlight vessel. For me it is just easier to add an attachment point and then attach a spotlight vessel. But you have to switch to it and turn on,.....

But if adding spotlights to your vessel then I don't think you need:
Code:
#include "spotlamp.h"
 
Top