Question How to use the SpotLight class

Kamran

New member
Joined
May 29, 2013
Messages
22
Reaction score
0
Points
0
I'm trying to define and switch on spotlights in my clbkSetClassCaps method. Below is my implimentation...
Code:
static SpotLight* spotlight;
COLOUR4 col={1,1,1,0};  //I've tried {1,1,1,1} as well
spotlight=(SpotLight*)AddSpotLight(_V(0,100,0),_V(0,-1,0),100,1,1,1,RAD*45,RAD*60,col,col,col);
spotlight->Activate(true);
...I don't see any lights, even at night time. Any help, thanks :hailprobe:
 
Last edited:

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
Sorry if it is an obvious question from my side, but I hope that you are aware of that it is impossible to light up the ground. You can only light up other ships (or yourself). Also, your range is quite low in relation to the position of the spotlight. I would also try to adjust the att0, att1 and att2 values (the 1's after the range of 100). I programmed a small probe, and its engine had the values 0.1, -0.01, 0.2. With your values of 1, the intensity has dropped to 1 percent after just 10 meters, while at 100 meters, the intensity has dropped to 0.0099 percent, which is practically nothing in Orbiter.
 

Kamran

New member
Joined
May 29, 2013
Messages
22
Reaction score
0
Points
0
Thanks for your reply, however I'm still not able to see any lights. I've adjusted all of the att values to 100. Does this force the drop in light intensity to remain the same? I've also tried your recommended att values, still didn't work. And I've also used 0 values in my att parameters. Nothing works! :thumbsdown:
I've also tried all the above att values in all orders that I can think off using a higher intensity rate of 100. Still not working. I'm not getting even a spek of light, not a sign of it at all. Am I initiallising the light instance correctly? This is in my clbkSetClassCaps method. Worked on another orbiter addon before, couldn't get light sources to work there either, would really like to know what I'm doing wrong. Any help will be greatly appreciated. Thanks:salute:
 

asbjos

tuanibrO
Addon Developer
Joined
Jun 22, 2011
Messages
696
Reaction score
259
Points
78
Location
This place called "home".
First, how large is your spacecraft? If it's 200 meters long, then the position value is OK. If it's smaller, make the position vector correspond to this size. Second, I think you should read the API_Reference.pdf file on page 476. As you can see there, the intensity is defined with the att values like this:
[math]\frac{1}{att_0+d\cdot att_1+d^2\cdot att_2}[/math]This shows that putting larger att values, the fraction will get smaller, e.g. att values should be closer to 0 the stronger the lights are.

I think that SetClassCaps is the right location, but I have no personal experience with the AddSpotLight function, so I would recommend you to look into the DeltaGlider's source code in the Orbiter\Orbitersdk folder and look for the definition of the docking light.

Good luck!
 

Kamran

New member
Joined
May 29, 2013
Messages
22
Reaction score
0
Points
0
Thanks for the explaination, it makes sense, lower numbers give less falloff and so more light. I had already looked through the documentation and the DeltaGlider.cpp file and can see no difference in the code and what I'm being told to do in the documentation, but it's still not working. At this point I feel that the code I wrote at the start of this thread was a simplification of "what I was trying to do" to help you understand the specific problem I felt I was facing, however, since I still can't get any spotlights, here are the actual values that I am using...
Code:
SpotLight* lights;
COLOUR4 col={1,1,1,0};
void SMC_HQ::clbkSetClassCaps (FILEHANDLE cfg)
{
	VECTOR3 spotLightVec=_V(0,22.84105,0);
	VECTOR3 spotLightDir=_V(0,-1,0);	
	lights=(SpotLight*)AddSpotLight(spotLightVec,spotLightDir,150,1e-3, 0, 1e-3,RAD*25,RAD*60,col,col,col);
	lights->Activate(true);
}
...I'm sure that you can agree that the principle in applying a light source has been followed the same as my original example, but maybe the magnitudes of my values are too large or too small to allow me to see them. The light is meant to be situated 22.84105 above the centre point of my mesh and to be shining down upon the origin. The mesh has a floor that is just a fraction above the origin so that my floor mesh doesn't flash with the mesh of the Earth and it allows the light to reflect of this surface. Upon saving the mesh using the blender export to orbiter mesh addon, no alterations were made to the mesh data or flags. The mesh does get brighter when the sun is shining on it.
 

Zatnikitelman

Addon Developer
Addon Developer
Joined
Jan 13, 2008
Messages
2,302
Reaction score
6
Points
38
Location
Atlanta, GA, USA, North America
Um, I apologize for asking such a simple question, but we all miss the obvious from time to time, but have you enabled local light sources in the visual effects tab?
 

Kamran

New member
Joined
May 29, 2013
Messages
22
Reaction score
0
Points
0
I think you might have just found my problem. My local light sources weren't enabled in my orbiter startup options, and so I enabled them, but my orbiter now crashes to desktop. I checked the log file and the last messages given by my Graphics class is as follows...
Graphics: Viewport: Window 1274 x 772 x 32
Graphics: Hardware T&L capability: No
Graphics: Z-buffer depth: 32 bit
Graphics: Active lights supported: -1
...do I need to make any changes to my graphics card? I am running orbiter off a Sony Vaio VGN-NS11J laptop with chipset graphics and Windows 7 http://www.laptopsdirect.co.uk/Sony_VAIO_NS11J-S_VGN-NS11J-S.CEK/version.asp. I think that local light sources are a mundane graphical issue and so I think that any graphics card built this century should have this capability. The highest graphical game I can play on this computer is Mafia I.
Also, when I'm running orbiter through Visual Studio 2010 in debug mode the debugger errors out on crash to desktop and displays a "No Source Available" screen telling me that "No symbols are loaded for any call stack frame" for KernelBase.dll!7500d36f(). This is probably not related to this problem and hoepefully will go away if local light sources was enabled correctly.

Any suggestions upon what I should do, or what I need to look for appreciated.

Thanks :thumbup:
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
Any suggestions upon what I should do, or what I need to look for appreciated.
Add "MaxLights = 8" line to your "Orbiter.cfg" Orbiter configuration file.
 

Kamran

New member
Joined
May 29, 2013
Messages
22
Reaction score
0
Points
0
I've added MaxLights=8 in my orbiter config file and enabled Local Light Sources in my visual effects tab. Orbiter doesn't crash now, so I know it's reading the config file, but still no light. Can't believe how many things can go wrong with such a simple thing on my computer :facepalm:
"Maybe I should just pray for shrimp"
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,755
Reaction score
2,738
Points
203
Location
Dallas, TX
Can you put another vessel in front/near yours to see if light is hitting it?
 

Kamran

New member
Joined
May 29, 2013
Messages
22
Reaction score
0
Points
0
The light is inside a building shining onto a mesh floor. The mesh floor crosses the origin and so as long as the light is shining on the origin it should reach the mesh floor.
 

BrianJ

Addon Developer
Addon Developer
Joined
Apr 19, 2008
Messages
1,679
Reaction score
902
Points
128
Location
Code 347
Hi,
I have a hunch that it is the vertices of a mesh poly that determines its illumination. If your building is large, and the floor is only made from 1 or 2 polys, the vertices may be out of range. As gattispilot said, put a small vessel/mesh under your light (e.g. use scenario editor to put a Carina sattelite there) and see if it is lit. Any good?
 

Kamran

New member
Joined
May 29, 2013
Messages
22
Reaction score
0
Points
0
BrianJ, you are right!
I've put an object under my light, waited until it was dark (with accellerated time for the impatient). My object was visible until I drove it out of the light. My floor doesn't have many vertices and so as you have said, the light shines between the vertices and doesn't produce the light that I was looking for. I don't particularly want to increase the number of vertices in my mesh :hmm:, so perhaps I will add spotlight sources that overlap at a given height. This should illuminate everything including my floor tiles.
Thanks :thumbup:
 
Top