Howto:Illuminate faces

From FlightGear wiki
Jump to navigation Jump to search

Imagine you see a skyline with a countless amount of lights. Somewhere in front of you there's a stretched row of lights. That's the runway you will land on. That's how you will experience a flight in the dark of the night. In reality. But in FlightGear there aren't much illuminated buildings. So here's a howto that teaches you how to make lights and illuminated buildings. Enjoy!

Basics

To make something of your building, airport, plane or what else illuminate we need an .xml file. In that .xml file we will place some stuff. Every animation (lighting is an animation) starts with the <animation> tag. Followed by the type of animation. For illumination we use the material-type. Now comes a very important part: the objects. Here we need to place the objects that should react on the animation. If we have a building with a antenne on top of it and we only want the antenne to illuminate we need to make that a seperate object. So every part that you wants to be illuminated should be seperated. You could do that in Blender, SketchUp or any other software you're using. Last part is the emisson part. The emission will tell FlightGear in what color the object should be illuminated. Using the tree colours (red, green and blue) you could make any color you want. If we did everthing as described above with a red light we will get something like:

<animation>
<type>material</type> 
<object-name>Light1</object-name>
<object-name>Light2</object-name>
<emission>	
<red>1</red>	
<green>0</green>	
<blue>0</blue>
</emission>
</animation>

Variations

The light we made above is always illuminated. Below I placed some variations that make the light only illuminate at dark or in changing colors.

Illuminate during dark

If you want a face to illuminate during dark we use the sun angle property (/sim/time/sun-angle-rad). A common value where our face should start illuminate is 1.57. But you could change the value if you want to illuminate earlier or later. Depends on your needs.

To turn lights on if the sky is dark:

<animation>
<type>material</type> 
<object-name>Light</object-name>
<condition>		
<greater-than>		
<property>/sim/time/sun-angle-rad</property>
<value>1.57</value>
</greater-than>
</condition>
<emission>	
<red>1</red>	
<green>0</green>	
<blue>0</blue>
</emission>
</animation>

And to turn the lights off during day:

<animation>
<type>material</type> 
<object-name>Light</object-name>
<condition>		
<less-than-equals>		
<property>/sim/time/sun-angle-rad</property>
<value>1.57</value>
</less-than-equals>
</condition>
<emission>	
<red>0</red>	
<green>0</green>	
<blue>0</blue>
</emission>
</animation>

Changing illumination color

Sometimes there are lights that change colours every now and then. It's not very hard to implent this in FlightGear. There are multiple ways to do this, but we will use the /sim/time/utc/ property. The example below changes color from red, green to blue every. We specified that the color should be red at every time behind 0 second. So if the time is 15:20:05 the color will be red. But at 22:01:21 color will be changed to green. Using this you could even make the lighting color be different every second of the day. Antoher possibility is a light that illuminates only between two specified times like from 21:00:00 till 6:30:00.

<animation>
<type>material</type>
<object-name>Light</object-name>
<condition>	
<equals>		
<property>/sim/time/utc/second</property>				
<value>0</value>	
</equals>
</condition>
<emission>
<red>1</red>	
<green>0</green>	
<blue>0</blue>	
</emission>
</animation>
<animation>
<type>material</type>
<object-name>Light</object-name>
<condition>	
<equals>		
<property>/sim/time/utc/second</property>				
<value>20</value>	
</equals>
</condition>
<emission>
<red>0</red>	
<green>1</green>	
<blue>0</blue>	
</emission>
</animation>
<animation>
<type>material</type>
<object-name>Light</object-name>
<condition>	
<equals>		
<property>/sim/time/utc/second</property>				
<value>40</value>	
</equals>
</condition>
<emission>
<red>0</red>	
<green>0</green>	
<blue>1</blue>	
</emission>
</animation>

Changing texture if illuminated

To change the texture of an illuminated face we add one single row to the file.

NOTE: This does not work with any version newer than v1.0!

<animation>
<type>material</type> 
<object-name>Light</object-name>
<condition>		
<greater-than>		
<property>/sim/time/sun-angle-rad</property>
<value>1.57</value>
</greater-than>
</condition>
<emission>	
<red>1</red>	
<green>1</green>	
<blue>1</blue>
</emission>
<texture>Light_lit.rgb</texture>
</animation>
<animation>
<type>material</type> 
<object-name>Light</object-name>
<condition>		
<less-than-equals>		
<property>/sim/time/sun-angle-rad</property>
<value>1.57</value>
</less-than-equals>
</condition>
<emission>	
<red>1</red>	
<green>1</green>	
<blue>1</blue>
</emission>
<texture>Light.rgb</texture>
</animation>