Jump to content
Sign in to follow this  
anthony_d

Adding lights to buildings in X-Plane

Recommended Posts

Evening all,I've been working on a little sub project (WIP) for my Aberdeen Scenery Project (you can download it here):http://forums.x-plan...&showfile=15946So, now I've cranked up the learning curve and have tried making my first building from scratch in sketchup. In this case the largest Bristows Hangar:Trouble with sketchup is that it's not possible to add lights to objects, and after searching around the org on the topic matter I couldn't find any info on the matter, other than discussions on _LIT textures and blender. There doesn't seem to be any official documentation on the matter either.So I did a little digging around some of the library objects and found the entries which define light sources.Here's an example of one such string for a default library hangarLIGHT_PARAM sodium_flood_XYZBTSS 9.5676 3.1452 -1.5798 0 -0.71 0.71 1 8 0.4 10After some experimenting with three separate lights on my Hangar, I managed to decode the string as follows:LIGHT_PARAM <light name> <x position> <z position> <y position><x shine direction><y shine direction><z shine direction><shine intensity on surfaces> <light spread> <?unknown?> <halo size> Light Name = Not sure of all the posible optionsPostion = metersDirection of light on each axis = 0....1 (unknown unit)Shine Intensity on surfaces: 0=off 1000= nuclear fusion brightLight Spead: 10= GU10 downlight 1000 = Light up the entire airport! <-- Note: light intensity is not diffused by increasing the beam spread.?unknown: 0 = no surface shine 0.1..1.0 = no visible difference 1+ = no surface shineHalo Size: 10= Blinding Antiaircraft searchlight 1= Domestic floodlight 0.2 = dying embers 0 = OffSo after figuring all this out, here's the applied result to my hangar at night:3 flood lights outside, and two down lights inside with the following code:LIGHT_PARAM sodium_flood_XYZBTSS -10 4 -46.3 0 -1 -1 1 40 0.2 1LIGHT_PARAM sodium_flood_XYZBTSS -30.25 6.7 -46.3 0 -1 -1 1 40 0.2 1LIGHT_PARAM sodium_flood_XYZBTSS -50.5 4 -46.3 0 -1 -1 1 40 0.2 1LIGHT_PARAM sodium_flood_XYZBTSS -30.25 10 -30 0 -1 0 0.25 40 0.2 0.2LIGHT_PARAM sodium_flood_XYZBTSS -30.25 10 -15 0 -1 0 0.25 40 0.2 0.2You need to apply the parameters after exporting from sketchup to xplane. Best to keep a copy of the parameters on a separate text file too.Hope someone finds this info usefulCheersAnthony

Share this post


Link to post
Share on other sites

Looks good. :good:I'm doing some objects for an airport at the moment (using blender) but I haven't looked at the lighting yet. I will do some testing on that soon. Those lights certainly bring it to life at night.Oh and thanks for the info :(

Share this post


Link to post
Share on other sites

That is excellent!And for XP10 I take it? I can follow a link!Do you know if it's possible to control these lights with datarefs?

Share this post


Link to post
Share on other sites

Datarefs..... something I'm new to. I take it these are external inputs for controlling parameters?It would be a good idea. Are you thinking of controlling lights on/off (e.g. lights off when the airport is closed at midnight?)

Share this post


Link to post
Share on other sites

Hey Anthony, a few clarifications for this particular named light:The monikor, XYZBTSS stands for < x vector><y vector><z vector><Bright><Throw><Spread><Size>You'll note there are 7 parameters there whereas the the example you gave has 10. This is because the first 3 values are the XYZ position values as you have gathered....relative to the object origin in which the lights reside and these values are usually automatically output during the export of the object whereas the 7 other values are user defined. You can indeed export out a simple light from blender and then hand edit the line item to turn it into a spotlight.....which you've done a very good job of might I add.The "BRIGHT" value is actually a alpha value used to dim a light. Most lights are not dimmed and so this values is usually fine left at a value of 1. The 'THROW" value is how far the light reaches. This value is in meters. If it's 1000.....then the light will shine 1000 meters out, which will make it very intense on nearby objects. For typical ramp spotlights...30 or so meters is pretty good but of course you need to tune depending on application. The "Spread" is the width of the light and is "...the cosine of 1/2 the light angle". So a 180 degree spread spotlight....divide by 2 = 90...the cosine of which is 0. So for example, a value of 0.4 yields a spread @ 132 degrees wide. ( Cos(132/2)) The direction vectors are all relative so values of 1, 1, 1 are the same as 4, 4, 4. As you said, it's handy to keep a table of vector values for commonly used light angles.To summarize this light values<X> The x direction vector that the light points.<Y> The y direction vector that the light points.<Z> The z direction vector that the light points.<Bright> Max of 1....set lower to dim the light but usually leave at 1.<Throw> How far the light reaches...in meters<Spread> How wide the light beam is. (This value.....numerically...is the cosine of 1/2 the light angle)<Size> The size of the haloAnother named light to have handy is sodium_flood_BB <X vector><Y vector><Z vector><halo size>This is a halo only light that does not cast any light, but is used for say a "3 lamp spotlight pole" where you only need 1 light for the light effect but 3 billboards to resemble 3 bulbs). all the KSEA ramp lights are like this.From a performance perspective, the more light cones that overlap, then the more of a performance hit x-plane takes. So shining 10 lights on the same geometry (pixels actually since lighting is calculated per pixel) , while tolerable, is not optimal. Whether or not it's acceptable depends on how much it drags down your system...though unless you have hundreds of lights like tarmac ramp lights that overlap, it's generally not performance intensive. If the lights do NOT overlap..then you can have 1000s...this is how the city and road lights are done and there are definitely 1000s of those things.Dozer...lights cannot be tied to datarefs. Some lights ARE tied to datarefs, but these are hard coded in the sim and the lights and datarefs values have been designed to match (rotating beacon best example). This could change, but I'm only guessing.Tom KylerXP10 scenery

Share this post


Link to post
Share on other sites

Thanks very much for the explanation Tom. That was very informative.So in theory if the <spread> = -1, that should cast light in all directions (ie. cos 360/2 = -1) as it would with a classic bulb inside your house. However I'm finding that if <spread> <= 0, then that just turns off the light cast on other objects. I'm trying inside my hangar to light up the roof as well as the floor. I guess the workaround is to introduce two opposing light sources on the same spot.Question: does the parameter: sodium_flood have any significance, or is it just a tag name? I'm wandering if it's possible to change the colour of the light at all.

Share this post


Link to post
Share on other sites

Hey Anthony.Omnidirectional spill lights are not supported yet. We've spoken about this at Laminar and might incorporate it. I honestly can't remember the outcome of the discussion though :( The name "sodium_flood" was one of my own chosing at the time we created it. It was just a descriptive name that made sense to me since I was the one using it in the KSEA scenery. Now I haven't tried the following light myself, but looking at the lights definition file, you might try the following named light'spot_params_sp'and using the following parameters:< X pos >< Y pos>< Z pos><Red><Green><Blue><Bright><throw>< x-vector >< y-vector >< z-vector ><spread>This light does not include a halo effect though. (price you pay for customization as we never know what authors will want ) For that you would also need:'spot_params_bb' < R >< G >< B>< size >< dX >< dY >< dZ><Width>In the above 'dX' simply means X-vector...just tired of typing it. Now with the halo effect (which we call billboards as opposed to spills.....hence the 'bb'), the width parameter controls the angle which the effect can be seen...fading from zero to max at the bisecting angle. If I recall correctly...moving this value towards zero makes for a omni billboard where it looks like the light is always in your eyes. So it's possible to have a halo effect that is viewable 360 whereas with spill lights you can not.Tom KylerV10 scenery

Share this post


Link to post
Share on other sites

Tom - datarefs animating scenery stuff would be excellent. I haven't installed any scenery, let alone built any myself, but the possibilities of plugin-controlled stuff would be amazing!Anthony: datarefs are numbers (mostly) output by the sim and used for animating stuff. (They do other things too.)For example, there's a dataref called sim/time/local_time_sec which is the local time, in seconds, since midnight. If you put wings on your hangar and turned it into an aeroplane, you could animate the lights so they don't appear when that dataref is less than 57600 - ie until 57600 seconds after midnight, which is 16 hours. That way your lights would be on 4pm-midnight. However Tom's just said this is currently not possible for scenery, only for aircraft.

Share this post


Link to post
Share on other sites

Dozer...I should clarify. You can't control light parameters via datarefs but you can animate the light position and rotation with them. The SDK 2.0 has an API for drawing objects and the whole y-probe feature is specifically for controlling ground vehicles...but to this day, nobody has used it that I know of....it needs a experienced game AI programmer to get the most of it. Ben Russell had done animated humans (like people flow in ORBX) something like 3-4 years ago...so controlling scenery with the SDK is doable.Tom KylerV10 scenery

Share this post


Link to post
Share on other sites

Excellent! There's no need to put wings on the hangars then!I could consider building a gliding airfield - the type of aviation I am most familiar with - and using the y-probe to control the winch cable retrieval truck. It just drives in a loop around the runway, picking up the cables at the winch and pulling them out to the launch point. Landing retrieval tractors too - they drive out to the landed glider and tow it back to the launch point in fairly well-established paths. Also the winch and launch point caravan, towed around the field depending on wind direction. I'll add it to the List Of Things To Look Into When I Turn Off The Web Browser And Boot Up The Compiler.

Share this post


Link to post
Share on other sites
Excellent! There's no need to put wings on the hangars then!
Afraid I've already done that! One of my efforts in sketchup to appear in Aberdeen

Share this post


Link to post
Share on other sites

Very good. Short aspect ratio wings like that should give it a high critical mach number, like the F-104, right?

Share this post


Link to post
Share on other sites

Anthony, how did You apply the parameter to the model, care to make an instruction. Are soon getting to that stage with my airport design


X-Plane Scandinavia

Norway - Sweden - Finland - Iceland - Denmark

https://www.facebook.com/xpscandinavia

Like - Share - Follow us on everything

 

Share this post


Link to post
Share on other sites

If you take a parameter like this one: LIGHT_PARAM sodium_flood_XYZBTSS -50.5 4 -46.3 0 -1 -1 1 40 0.2 1

 

Open up the .obj file in notepad and just copy and paste it to the bottom of the .obj file.

 

Open up in X-Plane, and see where the light ends up. Adjust parameters to suit positioning and then restart X-Plane. I'm not sure if there's an alternative to opening up X-Plane every time in order to preview object lights.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...