AC3D file format: Difference between revisions

Jump to navigation Jump to search
Article rework in tandem with the other changes I'm making on AC3D related articles
m (Ranguli moved page AC files: Basic changes to textures and colors to The AC3D file format: More fitting title)
(Article rework in tandem with the other changes I'm making on AC3D related articles)
Line 1: Line 1:
Ac files (extension .ac) are the basis of all [[scenery]] and [[aircraft]] models in [[FlightGear]]. Knowing how to read and change an AC file can be useful sometimes, e.g. when you quickly want to change a color or use another texture. This article shows you how to modify the material and texture entries.
The '''AC3D file format''' is the native file format used by the [[AC3D]] modelling software, and is the best supported file format for 3D models in FlightGear. The file format specification has been made available [https://web.archive.org/web/20180814212703/http://www.inivis.com/ac3d/man/ac3dfileformat.html|online] by the software developer. These files contain meshes, UV-mappings, texture paths and material definitions. It's ASCII text and easy to edit via scripts or, to some extent, by hand.


=== Materials ===
== Usage with other applications ==
 
=== Blender ===
 
{{main article|Working with the AC3D file format in Blender}}
 
Blender is a free and powerful 3D editor. While Blender dropped built-in support for the AC3D file format after version 2.5, third-party addo-ons have been developed to maintain support for the file format.
 
=== Open Scenegraph Library ===
The <tt>osgviewer</tt> demo in the [http://www.openscenegraph.org/ Open Scenegraph Library] is very useful for quickly looking at models.
 
=== PrettyPoly ===
[http://prettypoly.sourceforge.net/ PrettyPoly] (ppe) is an unmaintained object editor that uses the same graphics library as FlightGear (plib). This has the advantage that objects look very much like in FlightGear (minus shader effects and shadows). Compiling ppe may be a challenge, though, and it's only useful for viewing, but hardly for editing objects.
 
=== threedconvert ===
This is a converter for all plib supported 3D formats and comes with FlightGear (see utils/Modeller/3dconvert.cxx). It can read and write <tt>*.ac</tt> files, but a written file may lack UV mapping or have other defects.
 
 
== Materials ==
[[File:AC_color.jpg|thumb|rgb 1 1 0]][[File:AC_ambient.jpg|thumb|amb 0.72 0.64 1]][[File:AC_emission.jpg|thumb|emis 1 0 0]][[File:AC_spec.jpg|thumb|spec 0 1 0]][[File:AC_trans.jpg|thumb|trans 0.5]]
[[File:AC_color.jpg|thumb|rgb 1 1 0]][[File:AC_ambient.jpg|thumb|amb 0.72 0.64 1]][[File:AC_emission.jpg|thumb|emis 1 0 0]][[File:AC_spec.jpg|thumb|spec 0 1 0]][[File:AC_trans.jpg|thumb|trans 0.5]]


Line 39: Line 57:
: With transparency it get really interesting again. Make things transparent, even without using a [[Textures & Texture Maps in SketchUp|texture]].
: With transparency it get really interesting again. Make things transparent, even without using a [[Textures & Texture Maps in SketchUp|texture]].


=== Textures ===
== Textures ==


Texture lines are found anywhere throughout the AC file and look like this:
Texture lines are found anywhere throughout the AC file and look like this:
Line 47: Line 65:




=== Identifying an object ===
== Identifying an object ==


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.
Line 121: Line 139:
<!-- 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. -->
<!-- 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 ===
Unfortunately, when using SketchUp, the [[SketchUp to AC3D exporter]] will name every object the same:
<tt>OBJECT poly<br />
name "blah"</tt>
Here is how you can find an object you are looking for: Every part of the model with a unique <tt>material</tt> is defined as a new <tt>OBJECT poly</tt>. This means that you only have to know which material an object uses to find it in the body of the AC file. Every material is given a number, starting from the '''first material after''' <tt>material "default"</tt>:
<tt>MATERIAL "default" rgb ...</tt><br />
<tt>MATERIAL "Color_A07" rgb ...</tt> This is <tt>mat 1</tt><br />
<tt>MATERIAL "Color_D01" rgb ...</tt> This is <tt>mat 2</tt><br />
<tt>MATERIAL "Color_F01" rgb ...</tt> This is <tt>mat 3</tt><br />
Now we will look for the object further below in the AC file that uses <tt>mat 2</tt>. It is this one:
<tt>
OBJECT poly<br />
name "Roof"<br />
numvert 4<br />
-5.245000 10.550000 -0.010000<br />
5.245000 0.060000 -0.010000<br />
-5.245000 0.060000 -0.010000<br />
5.245000 10.550000 -0.010000<br />
numsurf 2<br />
SURF 0x30<br />
mat 2<br />
refs 3<br />
0 0 0<br />
1 0 0<br />
2 0 0<br />
SURF 0x30<br />
mat 2<br />
refs 3<br />
1 0 0<br />
0 0 0<br />
3 0 0<br />
kids 0
</tt>
As you can see, <tt>mat 2</tt> is used in this object. Let's imagine that we know that it is a roof. So now that we have named it ''Roof'' we can refer to it from the XML file. Voilà!
Note: When you [[Textures & Texture Maps in SketchUp#Loading your texture into SketchUp|define a new texture in SketchUp]], you can give it a name. Imagine that we use the texture <tt>roof1.png</tt> and that we name the texture <tt>Roof</tt>. The name and the texture filename will appear in the AC file. Yet you will still have to rename the object. The [[SketchUp to AC3D exporter]] will give you this:
<tt>MATERIAL "Roof" rgb<br /><br />
OBJECT poly<br />
name "blah"<br />
texture "roof1.png"</tt>
The name of the material does not matter at all, it could be anything. The object name is the important thing for reference from XML. Only after renaming the object you will be able to address it from the XML file. (Or, of course, you can refer to the object "blah", if this is the only object with that name in the AC file.)
When you are modelling in SketchUp and you want to ensure that you can identify one part of it later in the AC file, simply give it a unique color or texture that is not used anywhere else in the AC file. An exception to this method exists where you want your object to be invisible until the .xml file animates it (as with some lighting effects) - in that case you MUST use a unique texture. Failure to use a unique texture in these cases will result in your object not showing in FlightGear.


[[Category:Howto|AC files: Understanding and changing .ac code]]
[[Category:Howto|AC files: Understanding and changing .ac code]]
149

edits

Navigation menu