When modelling an aircraft, building or any other 3D model, you are encouraged to follow the modelling guidelines outlined in this article.
Feel free to add/modify. (please leave a comment in the talk page for radical modifications).
- Model = the file.
- Object/Mesh = part of the Model file. The Model can contain several Objects.
- Texture = image file (.rgb, .png).
- Vertices are free up to a point - use as many as you need.
- Many small (in vertex numbers) Objects/Meshes have a far worse negative impact on performance than a single Object/Mesh with very high vertex numbers.
- Combine all different parts of the Model into one single Object/Mesh, with the exception of parts that need to be animated, or of transparent parts.
- Blender: Select some objects and press Ctrl+J to join them into one Object. The new object origin/transform/orientation/name will be based on the ones of the last object selected.
- Use different unique names for each of the Objects in a Model file. Even more so when the different parts need to be animated.
- Make all faces of the objects single sided.
- If you need a part of the model to be visible from both sides, duplicate it in place and flip the normals. The extra geometry overhead is negligible compared to the extra work generated by double-sided faces.
- Separate transparent parts into their own objects.
- Blender: Go into Edit Mode, select the part of the object that you would like to separate and press P.
- Assign to all transparent Objects at least the model-transparent effect:
<effect> <inherits-from>Effects/model-transparent</inherits-from> <object-name>Transparent-object1</object-name> <object-name>Transparent-object2</object-name> <object-name>Transparent-object3</object-name> <object-name>other-Transparent-object</object-name> </effect>
- The interior should be a separate Model. Having it separate enables delayed loading of such models in multiplayer/AI contexts.
Only one instance of the tag is allowed for the whole aircraft. Such a model is specified as follows in the .xml file:
<model> <usage>interior</usage> <!--make sure to have this tag--> <path>Models/your-interior-model.xml</path> </model>
If your <model> require an <offsets> you must move the <offsets> section in the children XML like:
<PropertyList> <path>path/to/model.ac</path> <model> <path>your/aircraft/Models/Interior/model.xml</path> <usage>interior</usage> </model> ... </PropertyList>
<PropertyList> <path>path/to/another/model.ac</path> <offsets> <x-m> -1.91552 </x-m> <y-m> 0.00000 </y-m> <z-m> 0.23706 </z-m> <roll-deg> 40.0 </roll-deg> <pitch-deg> 35.0 </pitch-deg> <heading-deg> 60.0 </heading-deg> </offsets> <model> <path>path/to/another/model.xml</path> </model> ...
- Combine as many parts of a single Model to a single texture as you can - the maximum texture size is 4096 x 4096 pixels.
- Do not assign multiple textures to the same Object/Mesh. The Object will be split so as to have a single texture/Mesh.
- Do not use different parts of a single texture for different models. Split the texture into smaller parts then.
- If using the same texture on multiple models, use a single file, do not make different copies.
- Prefer texture replacing animations to textranslate for models that spend large amounts of their time in one state (day/night animations).
- Avoid transparency like the plague, it kills frame rate like nothing else: remove the alpha channel from textures if they are non-transparent.
- GIMP: Go to Layers > Transparency > Remove alpha layer.
- Inkscape: Go to File > Document Properties and set the "Background" to a non transparent colour (preferably black).
- Hive off transparent parts of textures into their own textures.
- Use power of two dimensions for textures (2n, e.g. 256x256, 512x1024). Do not worry if your image would get stretched in the texture, you can fix that with the mapping on the model.
- Do not have textures with the image in one corner and the rest unused.
- Recommended texture format is: .png. In general any texture format supported by OSG could be used, but be aware of varying cross-platform support for such formats, or of lossy compression.
Multiplayer Property usage
When your model is loaded over MP instead of the property tree starting at the top (/) your model will be loaded with a property tree root of ai/models/multiplay[#]. It is important that you use the right properties inside your model; and this is possibly one of the most commonly misunderstood aspects of the correct way to use properties.
1. The general rule is that you must never include a leading "/" on any property path. 2. The exception to this rule is the few properties that relate to the FG instance on which the model is running. An example of this is the properties related to environmental lighting. 3. Writing or modifying an absolute property should never be done.
- All model xml files are loaded such that their property root is correctly adjusted already, and thus sim/model will be either /sim/model or ai/models/carrier/sim/model, or ai/models/multiplay/sim/model.
- Any Nasal code (loaded from the model xml) needs to use the property root that is passed into the model xml in cmdarg (you can see this in the model xml for the F-14 https://github.com/Zaretto/fg-aircraft/blob/develop/aircraft/f-14b/Models/f-14b.xml#L25)