Howto:Multi-channel lightmap: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 224: Line 224:


== Using XML and GLSL to activate the lightmap in FlightGear ==
== Using XML and GLSL to activate the lightmap in FlightGear ==
Now that we have a multi-channel lightmap we are ready to use it in FlightGear. First thing we need is to assign the lightmap effect to the objects that the lightmap was created for. The code looks like this. Even though in my Blender baking example I joined all the object into one object prior to baking (I called it cabin). In the XML they need to be listed as they are actually used or called in the XML. In the case of the shuttle there were approximately 600 objects affected by the lights and subsequent lightmap. But for this example I will only use a small subset of the total objects involved.
First in the aircraft's model file. Where shuttle-interior is the name assigned to the effects code in the effects file that will contain the code to activate the lightmap. This block tells the program what objects to apply the associated effect to.
Aircraft/SpaceShuttle/Models/cockpit.xml
<syntaxhighlight lang="xml">
<effect>
        <inherits-from>Aircraft/SpaceShuttle/Models/Effects/Interior/shuttle-interior</inherits-from>
        <object-name>backwall</object-name>
        <object-name>floor</object-name>
        <object-name>panels</object-name>
        <object-name>switches</object-name>
</effect>
</syntaxhighlight>
Next is the XML effects file with all the information needed to implement the effect, in this case the lightmap.
Aircraft/SpaceShuttle/Models/Effects/Interior/shuttle-interior.xml
<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
    <name>Effects/shuttle-interior</name>
    <inherits-from>Aircraft/SpaceShuttle/Effects/model-interior-extended</inherits-from>
    <parameters>
        <lightmap-enabled type="int">1</lightmap-enabled>
        <lightmap-multi type="int">1</lightmap-multi>   
        <lightmap-factor type="float" n="0"><use>/fdm/jsbsim/systems/light/cabinlight1-intensity</use></lightmap-factor>
        <lightmap-color type="vec3d" n="0"> 1.0 1.0 1.0 </lightmap-color>
        <lightmap-factor type="float" n="1"><use>/fdm/jsbsim/systems/light/cabinlight2-intensity</use></lightmap-factor>
        <lightmap-color type="vec3d" n="1"> 1.0 1.0 1.0 </lightmap-color>
        <lightmap-factor type="float" n="2"><use>/fdm/jsbsim/systems/light/cabinlight3-intensity</use></lightmap-factor>
        <lightmap-color type="vec3d" n="2"> 1.0 1.0 1.0 </lightmap-color>
        <lightmap-factor type="float" n="3"><use>/fdm/jsbsim/systems/light/cabinlight4-intensity</use></lightmap-factor>
        <lightmap-color type="vec3d" n="3"> 1.0 1.0 1.0 </lightmap-color>
        <texture n="3">
            <image>Aircraft/SpaceShuttle/Models/Effects/Interior/lm-F1-F2-F3-F4.png</image>
            <type>2d</type>
            <filter>linear-mipmap-linear</filter>
            <wrap-s>clamp</wrap-s>
            <wrap-t>clamp</wrap-t>
            <internal-format>normalized</internal-format>
        </texture>
    </parameters>
</PropertyList>
</syntaxhighlight>
330

edits