Howto:Use a Camera View in an Instrument: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 57: Line 57:
* In update function update camera position according to viewer->getAbsolutePosition(...).
* In update function update camera position according to viewer->getAbsolutePosition(...).
* Add the custom instrument to instrument_mgr.cxx.
* Add the custom instrument to instrument_mgr.cxx.
=Part 2: Getting that texture into an instrument=
This part doesn't require any C++ coding, just a simple XML script to use that texture in an instrument.
<syntaxhighlight lang="xml">
<?xml version="1.0"?>
<PropertyList>
    <name>Camera Instrument</name>
    <w-base>512</w-base>
    <h-base>512</h-base>
    <layers>
<layer>
        <name>camera</name>
            <texture>
                <path>image_file.png</path> <!-- Path to the file we just rendered -->
                <x1>0</x1>
                <y1>0</y1>
                <x2>1</x2>
                <y2>1</y2>
            </texture>
<emissive>1</emissive>
        <w>512</w>
        <h>512</h>
</layer>
    </layers>
</PropertyList>
</syntaxhighlight>
''You could create more layers for more cameras/different views or even have a sprite or something on the view. Or we could also add transformations or conditions to the layer to give some function to the instrument other than just show a camera view.''
<syntaxhighlight lang="xml">
<transformation>
    <type>y-shift</type>
    <property>/instrumentation/camera/y_shift</property>
    <scale>2</scale>
    </transformation>
</syntaxhighlight>


=Creating the CamView as a hard coded instrument=
=Creating the CamView as a hard coded instrument=
Line 145: Line 104:
             set_subsystem( id, new CamView( node ),1);
             set_subsystem( id, new CamView( node ),1);
         }
         }
</syntaxhighlight>
=Part 2: Getting that texture into an instrument=
This part doesn't require any C++ coding, just a simple XML script to use that texture in an instrument.
<syntaxhighlight lang="xml">
<?xml version="1.0"?>
<PropertyList>
    <name>Camera Instrument</name>
    <w-base>512</w-base>
    <h-base>512</h-base>
    <layers>
<layer>
        <name>camera</name>
            <texture>
                <path>image_file.png</path> <!-- Path to the file we just rendered -->
                <x1>0</x1>
                <y1>0</y1>
                <x2>1</x2>
                <y2>1</y2>
            </texture>
<emissive>1</emissive>
        <w>512</w>
        <h>512</h>
</layer>
    </layers>
</PropertyList>
</syntaxhighlight>
''You could create more layers for more cameras/different views or even have a sprite or something on the view. Or we could also add transformations or conditions to the layer to give some function to the instrument other than just show a camera view.''
<syntaxhighlight lang="xml">
<transformation>
    <type>y-shift</type>
    <property>/instrumentation/camera/y_shift</property>
    <scale>2</scale>
    </transformation>
</syntaxhighlight>
</syntaxhighlight>


= Related =
= Related =
* [http://flightgear.org/forums/viewtopic.php?f=6&t=13798 Zan's work on improved camera config options]
* [http://flightgear.org/forums/viewtopic.php?f=6&t=13798 Zan's work on improved camera config options]


[[Category:GSoC]]
[[Category:GSoC]]
449

edits

Navigation menu