AC3D file format: Difference between revisions

→‎Identifying an object: add an example showing how to load and name an object from an .ac file
m (cut the sketchup part into its own section. the identifying an object section needs to be expanded so show xml examples of loading and accessing objects from .ac files.)
(→‎Identifying an object: add an example showing how to load and name an object from an .ac file)
Line 50: Line 50:


If you write an XML file for your AC model (which you always should), you might want to refer from the XML file to certain objects in the AC file. This is necessary when you want to make certain objects rotate or change their size or illuminate them after nightfall or anything like that.
If you write an XML file for your AC model (which you always should), you might want to refer from the XML file to certain objects in the AC file. This is necessary when you want to make certain objects rotate or change their size or illuminate them after nightfall or anything like that.
For example, you might want to load a beacon. Let's say that it is in a file named beacon.ac. Inside the .ac file, the object's name is "Beacon_RED". You can load the model and set the object's name in XML like this:
<small>
'''Key tags:'''<br />
* <model></model>
* <path></path>
* <object-name></object-name>
</small>
  <PropertyList>
    <model>
      <nowiki><!-- load and name the object model --></nowiki>
      <path>Lights/Models/beacon.ac</path>
      <nopreview/>
      <object-name>Beacon_RED</object-name>
    </model>
    <animation>
      <nowiki><!-- set the size of the object model --></nowiki>
      <type>scale</type>
      <object-name>Beacon_RED</object-name>
      <x-offset>2.0</x-offset>
      <y-offset>2.0</y-offset>
      <z-offset>2.0</z-offset>
    </animation>
    <animation>
      <nowiki><!-- set the size of the object model based on distance --></nowiki>
      <nowiki><!-- at "ind" units (meters?) distance, the size of the object will be multiplied by "dep" --></nowiki>
      <type>dist-scale</type>
      <object-name>Beacon_Red</object-name>
      <interpolation>
        <entry><ind>    0</ind><dep>    1</dep></entry>
        <entry><ind>  300</ind><dep>    4</dep></entry>
        <entry><ind> 1500</ind><dep>    8</dep></entry>
      </interpolation>
    </animation>
    <effect>
      <inherits-from>Lights/Effects/beacon</inherits-from>
      <object-name>Beacon_RED</object-name>
    </effect>
  </PropertyList>
The above code might be stored in an XML file named beacon-object.xml. Another XML file would load it using code like this:
<small>
'''Key tags:'''<br />
* <model></model>
</small>
  <PropertyList>
    <nowiki><!-- Load and position the Beacon Light model --></nowiki>
    <nowiki><!-- Position is in meters from model's center coordinates, 0,0,0 --></nowiki>
    <model>
      <path>Lights/beacon-object.xml</path>
      <offsets>
        <x-m> 0.0000</x-m>
        <y-m> 0.0000</y-m>
        <z-m> 4.9500</z-m>
      </offsets>
    </model>
  </PropertyList>
<!-- The next part to be added should show how to load an .ac file that has multiple objects named in it and how to access those objects individually. -->


=== SketchUp Notes ===
=== SketchUp Notes ===
185

edits