C++ Question Help with identifier spotlight error

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
I am trying to make a spotlight as a vessel I can move around on my base.
after toiling over this with others...
I still get this 'identifier not found error'
It seems to be something with member function calling Any ideas
Here's the error:
Code:
1>Compiling...
1>spotlamp.cpp
1>c:\users\crice\documents\visual studio 2008\projects\spotlamp\spotlamp\spotlamp.cpp(32) : error C3861: 'AddSpotLight': identifier not found
1>Build log was saved at "file://c:\Users\crice\Documents\Visual Studio 2008\Projects\spotlamp\spotlamp\Debug\BuildLog.htm"
1>spotlamp - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Here is my header .h
Code:
#define ORBITER_MODULE  
#include "Orbitersdk.h"
 
// ==============================================================
// spotlamp class interface
// ==============================================================

class spotlamp: public VESSEL2 {
public:
	spotlamp (OBJHANDLE hVessel, int flightmodel)
		: VESSEL2 (hVessel, flightmodel) {}
	void clbkSetClassCaps (FILEHANDLE cfg);

	void clbkLoadStateEx (FILEHANDLE scn, void *vs);
	void clbkSaveState (FILEHANDLE scn);
	void clbkPreStep (double simt, double simdt, double mjd);
	void SetDockingLight (bool on);
	int lightfront_status;
	int clbkConsumeBufferedKey (DWORD key, bool down, char *kstate);
    SpotLight *docking_lightfront;
    
};

And here is my .cpp

Code:
#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)
{
	COLOUR4 col_a={0,0,0,0};
	COLOUR4 col_white={1,1,1,0};
	docking_lightfront = (SpotLight*)AddSpotLight(_V(-.441,0,1.582), _V(0,0,1), 150, 1e-3, 0, 1e-3, RAD*25, RAD*60, col_white, col_white, col_a);
    docking_lightfront->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;
}
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,689
Reaction score
2,670
Points
203
Location
Dallas, TX
If you use the spotlight2 as a vessel. Just add it with scenarios editor. Make an attachment and attach.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,398
Reaction score
578
Points
153
Location
Vienna
Try changing the base class to VESSEL3, not VESSEL2. Just a guess here, according to the SDK headers it should be a method of VESSEL, though.

---------- Post added at 10:00 ---------- Previous post was at 07:15 ----------

Scratch that... just tried it with the ShuttlePB example. No matter if it is derived from VESSEL2 or VESSEL3, AddSpotLight works. As it should according to the SDK headers, because it is declared in the VESSEL base-class directly.

At this point, without your complete project code I can only guess what happens on your end. Perhaps a wrong project setup, or simply an old Orbiter version.
 

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
This IS my complete code. I hate to sound foolish, but I am a bit of a noob to C++, just want to make sure that I didn't leave some obvious stuff out of the top of the .cpp file above. So you mean to say that if you yourself copied the above cut/paste into two text files just as they appear above "spotlamp.h" and spotlamp.cpp.....and then using Orbiter Vessel Wizard created a project called spotlamp unchecking the "use ShuttlePB code" and unchecked engines / RCS and just left the call back areas. then went into your compiler under the project and switched the above to files for the ones that are there i.e. spotlamp.h and .cpp already exist do you want to overwrite them...YES...and hit "Build Spotlamp" on yourend.....it would work....or have I left something obvious out of the top of the .cpp file.... I mean I made a ring of beacon lights like this with the above a while back and it compiled fine... with BEACONLIGHTSPEC .....my compiler VS 2008 just seems like it has never heard of the words SpotLight or AddSpotLight...no matter what I do. I thought it was directly a member of the base VESSEL class too!
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,398
Reaction score
578
Points
153
Location
Vienna
This IS my complete code.

<snip>

So you mean to say that if you yourself copied the above cut/paste into two text files just as they appear above "spotlamp.h" and spotlamp.cpp.....and then using Orbiter Vessel Wizard created a project called spotlamp unchecking the "use ShuttlePB code" and unchecked engines / RCS and just left the call back areas.

Ah. Now we are getting closer. You are using a project generator tool called "Orbiter Vessel Wizard"? I never tried that myself. All I did was using the ShuttlePB example project and compile it.

You have posted 2 files of your project code. The header and the source. But this is NOT your complete project code. Your project consists of more than just those 2 files. You say your compiler is Visual Studio, so I guess you have at least 2 additional files: the solution and the project. These files are important, because they contain your project's compilation settings, which includes what libraries and header files are used.

Without access to your complete project, I can only guess what your compiler does. At this point, it looks like you are using the SDK of an old orbiter version. Could it be that this "wizard" is rather old and brings along the orbitersdk.lib and headers?
 

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
Well I am running Orbiter 2010 Aug30 build. I looked in the Orbitersdk.h and OrbiterAPI.h files. At the top one says copyright Sweiger 2001-2004 while the other says copyright 2001-2008...if that even means anything. HOWEVER, here are my .sln and vproj. files . Don't know if you can get anything from it or not. FYI I copied my own files from above on this thread and made new .cpp and .h files out of them. NOW it COMPILES fine w/ no errors....but when I run the scenario, there is a mesh with NO light ....UGGGG....:(
 
Last edited:

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,398
Reaction score
578
Points
153
Location
Vienna
Well I am running Orbiter 2010 Aug30 build. I looked in the Orbitersdk.h and OrbiterAPI.h files. At the top one says copyright Sweiger 2001-2004 while the other says copyright 2001-2008...if that even means anything. HOWEVER, here are my .sln and vproj. files . Don't know if you can get anything from it or not. FYI I copied my own files from above on this thread and made new .cpp and .h files out of them. NOW it COMPILES fine w/ no errors....but when I run the scenario, there is a mesh with NO light ....UGGGG....:(

One think I've noticed in the project file just by looking through it is that the Release target might not produce a DLL in your Orbiter Modules folder, because it seems to miss a backslash:
Code:
OutputFile="C:\Users\crice\My Documents\orbiter\modules$(ProjectName).dll"

That looks like it would produce a file "modulesspotlamp.dll" in your root Orbiter folder.
 

tauruslittrow84

New member
Joined
Nov 12, 2011
Messages
58
Reaction score
0
Points
0
Well I finally found what my problem(s) were. It created a spotlamp.dll. That was ok. One main problem was that I was looking for a cone of light to be coming out of this lamp even when it wasnt pointed at anything AND some light source actually on the thing. Huh, uh. You probably know now what I did(didnt do). Needed to aim it at something...some threads say another module...but it even lit up my trees which arn't modules. You just have to point it at something in range. And as you know you must add a beacon light on the module...or even tho it spotlights up something you wont see a light on the actual spotlight. However, I just chose to make my material completely emissive on the glass faceplate in my spotlamp mesh file. Oula...A spotlight on my vessel that shows up lit itself while lighting a vessel. I need to slow down and read other posts completely. That's my problem. Thanks for your help though. You helped me to learn a lot... Somebody needs to put a TRUER English version of the API guide out though that describes more like what I said above...it would save people a WHOLE lot of headache! As for what was happening with the compiler not compiling. I think maybe what happens is/using OrbiterVesselWizard/ if you keep changing things in a .cpp file on notepad outside the compiler and then slide the .cpp file in the project folder and then build...its works for a while but after several builds you get corupt lib's , .pdb's, .ilks all the stuff that is created by the compiler. Thats why when I cut and pasted my own file from this page and completely set up a new project for it in OrbiterVesselWizard and built it for the FIRST time instead of the 50th it wasn't corrupt and compiled,
This must be it cause I had exactly what was written above in my header and .cpp files the whole time it wasn't compiling. Uggg. We live and we learn! ;)
 
Last edited:
Top