Howto:Illuminate faces: Difference between revisions

mNo edit summary
Line 179: Line 179:
   <texture>Light.png</texture>
   <texture>Light.png</texture>
  </animation>
  </animation>
===Switch to another part of texture if illuminated===
You can no longer change the texture (see section above), but you can switch to another part of the same texture map and illuminate it.
You need to make a texture map that is exactly 512 pixels wide (see [[Textures_&_Texture_Maps_in_SketchUp]]. The height must be any square of two (eg. 2<sup>0</sup>=1, 2<sup>1</sup>=2, 2<sup>2</sup>=4, 2<sup>3</sup>=8, 2<sup>4</sup>=16 and so on). This texture map has two sides that are each 256 pixels wide. The '''left side''' is for day-time textures, the '''right side''' is for night-time textures. Each night-time texture is positioned exactly 256 pixels to the right of the day-time texture. Here is an example taken from the shared model [http://scenemodels.flightgear.org/modeledit.php?id=1570 German village house - grey roof]:
[[Image:Germanvillagehouse1_day.png|thumb|day-time textures]]
[[Image:Germanvillagehouse1_night.png|thumb|night-time textures]]
[[Image:Germanvillagehouse1.png]]
When you have made that texture map, you apply the day-time textures as default textures to the model either in [[Blender]] or [[SketchUp]].
Finally you have to add two bits of code to the XML file: 1) Code that tells FG to move the texture to the left during night-time and 2) code that illuminates the model during night-time.
The following code tells FG to move the texture 256 pixel to the left at nightfall:
  <animation>
    <type>textranslate</type>
    <object-name>germanvillagehouse1</object-name>
    <property>/sim/time/sun-angle-rad</property>
    <step> 1.57 </step>
    <factor>0.318471338</factor>
    <center>
      <x-m> 0 </x-m>
      <y-m> 0 </y-m>
      <z-m> 0 </z-m>
    </center>
    <axis>
      <x> -1 </x>
      <y>  0 </y>
      <z>  0 </z>
    </axis>
  </animation>
The 3d object which "wears" the texture (the house) is called <tt>germanvillagehouse1</tt> here. This name refers to the name given to the respective object in the AC file. For more information on object names, see [[AC_files:_Understanding_and_changing_.ac_code#Identifying_an_object|AC files: Basic changes to textures and colors]].
In order to illuminate the object during dark, add the two blocks of code introduced above: [[Howto:_Illuminate_faces#Illuminate_during_dark|Illuminate during dark]]. Finally you will have three blocks of code: One that moves the texture at dusk and dawn, one that illuminates the object at dusk and one that switches the light off at dawn. Make sure all of them use the right object name.


===Flashing light===
===Flashing light===
248

edits