Modelling guidelines: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
m (Copy editing)
Line 6: Line 6:


== Definitions ==
== Definitions ==
*Model = the file.
; Model
*Object/Mesh = part of the Model file. The Model can contain several Objects.
: The file with the 3D model.
*Texture = image file (.rgb, .png).
 
; Object/mesh
: Part of the model file. A model can contain several objects or meshes.
 
; Texture
: Image file (<code>.rgb</code>, <code>.png</code>) that are draped around the model.


== Modelling guidelines ==
== Modelling guidelines ==
*Vertices are free up to a point - use as many as you need.
* 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.
* 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.
* 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 {{Key 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.
:; Blender
*Use different unique names for each of the Objects in a Model file. Even more so when the different parts need to be animated.
:: Select some objects and press {{Key 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.
*Make all faces of the objects single sided.
* Use different unique names for each of the objects in a model file. Even more so when the different parts need to be animated.
*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.
* Make all faces of the objects single sided.
*Separate transparent parts into their own objects.<!-- and place at the end of the object list --><!-- I'm not sure this is not some kind of placebo-->
* 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.
** '''Blender''': Go into Edit Mode, select the part of the object that you would like to separate and press {{Key press|P}}.
* Separate transparent parts into their own objects.<!-- and place at the end of the object list --><!-- I'm not sure this is not some kind of placebo-->
*Assign to all transparent Objects at least the ''model-transparent'' effect:
:; Blender
:: Go into ''edit mode'', select the part of the object that you would like to separate and press {{Key press|P}}.
* Assign to all transparent objects at least the ''model-transparent'' effect:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<effect>
<effect>
Line 30: Line 37:
</effect>
</effect>
</syntaxhighlight>
</syntaxhighlight>
*The interior should be a separate Model. Having it separate enables delayed loading of such models in multiplayer/AI contexts.  
* 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:
: Only one instance of the tag is allowed for the whole aircraft. Such a model is specified as follows in the XML file:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<model>
<model>
Line 39: Line 46:
</syntaxhighlight>
</syntaxhighlight>


If your <model> require an <offsets> you must move the <offsets> section in the children XML like:
If your model require an <code><nowiki><offsets></nowiki></code> section, you must move the <code><nowiki><offsets></nowiki></code> section in the children XML like:


your/aircraft/Models/aircraft.xml:
<code>your/aircraft/Models/aircraft.xml</code>:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<PropertyList>
<PropertyList>
Line 53: Line 60:
</syntaxhighlight>
</syntaxhighlight>


your/aircraft/Models/Interior/model.xml:
<code>your/aircraft/Models/Interior/model.xml</code>:
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<PropertyList>
<PropertyList>
Line 73: Line 80:


== Texturing guidelines ==
== Texturing guidelines ==
*Combine as many parts of a single Model to a single texture as you can - the maximum texture size is 4096 x 4096 pixels.
* 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 assign multiple textures to the same object/mesh. The object will be split so as to have a single texture per mesh.
*Do not use different parts of a single texture for different models. Split the texture into smaller parts then.
* Do not use different parts of a single texture for different models. Instead, split the texture into smaller parts.
*If using the same texture on multiple models, use a single file, do not make different copies.
* 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).
* 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.
* 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 <tt>Layers > Transparency > Remove alpha layer</tt>.
:; GIMP
** '''Inkscape''': Go to <tt>File > Document Properties</tt> and set the "Background" to a non transparent colour (preferably black).
:: Go to ''Layers'' > ''Transparency'' > ''Remove alpha layer''.
*Hive off transparent parts of textures into their own textures.
:; Inkscape
*Use power of two dimensions for textures (2<sup>n</sup>, 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.
:: Go to ''File'' > ''Document Properties'' and set the ''Background'' to a non transparent colour (preferably black).
*Do not have textures with the image in one corner and the rest unused.
* Hive off transparent parts of textures into their own textures.
*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.
* Use power of two dimensions for textures (in essence 2<sup>n</sup>, for example 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: <code>.png</code>. 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.
<!--== Animation guidelines ==
<!--== Animation guidelines ==
*Keep the number of range animations to a minimum. Load the instruments in a submodel XML file, to avoid having one for each instrument. Testing one range animation is cheaper than 47.--> <!--commented out for now-->
* Keep the number of range animations to a minimum. Load the instruments in a submodel XML file, to avoid having one for each instrument. Testing one range animation is cheaper than 47.--> <!--commented out for now-->
 
== 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.
== Multiplayer property usage ==
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.
When your model is loaded over multiplayer instead of the property tree starting at the top (<code>/</code>) your model will be loaded with a property tree root of <code>ai/models/multiplay[#]</code>. It is important that you use the right properties inside your model. This is possibly one of the most commonly misunderstood aspects of the correct way to use properties.
3. Writing or modifying an absolute property should never be done.


Notes:
# The general rule is that you must never include a leading <code>/</code> on any property path.
# The exception to this rule is the few properties that relate to the FlightGear instance on which the model is running. An example of this is the properties related to environmental lighting.
# 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[0]/sim/model, or ai/models/multiplay[0]/sim/model.
=== Notes ===
* 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)
* All model XML files are loaded such that their property root is correctly adjusted already, and thus <code>sim/model</code> will be either <code>/sim/model</code> or <code>ai/models/carrier[0]/sim/model</code>, or <code>ai/models/multiplay[0]/sim/model</code>.
* Any Nasal code (loaded from the model XML file) needs to use the property root that is passed into the model XML file in cmdarg (you can see this in the model XML file for the F-14 {{github source|user=Zaretto|repo=fg-aircraft|branch=develop|path=aircraft/f-14b/Models/f-14b.xml|line=25}}


[[Category:Modeling]]
[[Category:Modeling]]

Revision as of 09:41, 2 April 2020

Merge-arrows.gif
It has been suggested that this article or section be merged with Modeling - Getting Started#Improving models for best FlightGear performance.

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).

Definitions

Model
The file with the 3D model.
Object/mesh
Part of the model file. A model can contain several objects or meshes.
Texture
Image file (.rgb, .png) that are draped around the model.

Modelling guidelines

  • 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> section, you must move the <offsets> section in the children XML like:

your/aircraft/Models/aircraft.xml:

<PropertyList>
  <path>path/to/model.ac</path>
  <model>
    <path>your/aircraft/Models/Interior/model.xml</path>
    <usage>interior</usage>
  </model>
  ...
</PropertyList>

your/aircraft/Models/Interior/model.xml:

<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>
  ...

Texturing guidelines

  • 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 per mesh.
  • Do not use different parts of a single texture for different models. Instead, split the texture into smaller parts.
  • 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 (in essence 2n, for example 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 multiplayer 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. 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 FlightGear 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.

Notes

  • 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[0]/sim/model, or ai/models/multiplay[0]/sim/model.
  • Any Nasal code (loaded from the model XML file) needs to use the property root that is passed into the model XML file in cmdarg (you can see this in the model XML file for the F-14 github/Zaretto/fg-aircraft/develop/aircraft/f-14b/Models/f-14b.xml#L25