Difference between revisions of "Model system"

From PioneerWiki
Jump to: navigation, search
(Other special nodes)
(Overview)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
 +
 +
=== Nodes ===
 +
 +
==== Node ====
 +
 +
Base class. A node can have a name and one or more parents.
 +
 +
==== Group ====
 +
 +
A group is a Node that can have several children.
 +
 +
==== MatrixTransform ====
 +
 +
A Group that applies a transformation to its child nodes when rendering.
 +
 +
==== StaticGeometry ====
 +
 +
Contains one or more StaticMeshes.
 +
 +
==== LOD ====
 +
 +
Detail level control node, picks one of the child nodes based on the approximate size of the model on screen.
 +
 +
==== ModelNode ====
 +
 +
Can be used to attach another Model as a submodel. Use case: dynamic equipment on ships.
 +
 +
==== More! ====
 +
 +
Some marginal nodes that exist at the moment are:
 +
 +
* Thruster: spaceship thruster
 +
* Billboard: can be used for light sprites (navlights on ships)
 +
* Label3D: dynamic 2d text, meant for labeling ships
  
 
== Importing models ==
 
== Importing models ==

Revision as of 00:54, 9 October 2012

Overview

Nodes

Node

Base class. A node can have a name and one or more parents.

Group

A group is a Node that can have several children.

MatrixTransform

A Group that applies a transformation to its child nodes when rendering.

StaticGeometry

Contains one or more StaticMeshes.

LOD

Detail level control node, picks one of the child nodes based on the approximate size of the model on screen.

ModelNode

Can be used to attach another Model as a submodel. Use case: dynamic equipment on ships.

More!

Some marginal nodes that exist at the moment are:

  • Thruster: spaceship thruster
  • Billboard: can be used for light sprites (navlights on ships)
  • Label3D: dynamic 2d text, meant for labeling ships

Importing models

Materials

Only material names are imported from 3D models, to set material properties use a small definition like this:

material CobraI_body
tex_diff CobraI_diff.png
tex_glow CobraI_emit.png
tex_spec CobraI_spec.png
diffuse 1.0 1.0 1.0
specular 1.0 1.0 1.0
shininess 150

The available properties are

material Name. Mandatory! Note, some exporters modify the names from what is visible in the modeling program, for example the Blender 2.6 Collada exporter adds "-material" to each name. You'll have to use this final name.
diffuse Diffuse colour RGB. Default white.
specular Colour of specular highlights, RGB. Default white. Set to black to disable highlights.
emissive Self-illumination colour, RGB. Default black.
shininess Sharpness/size of specular highlights, 0 - 200. Default 200.
tex_diff Diffuse texture, file name (in the same folder). If you don't specify this, a white dummy texture is generated.
tex_glow Self-illumination texture, overrides emissive colour parameter. Default none.
tex_spec Specular highlight colour/intensity texture. Default none.
use_patterns yes/no. This material will use the pattern/colour system. Read more below. Default no.

Detail levels

Meshes can be grouped into detail levels using the lod pixelsize directive:

lod 100
mesh hull_low.dae

lod 200
mesh hull_med.dae

lod 1000
mesh hull_hi.dae
mesh landing_gear.dae

A detail level will be picked if the approximate size of the model on screen is less than pixelsize (for the highest level it does not matter as long as it's larger than the others). Use the modelviewer to find optimal sizes.

You may specify any number of detail levels in any order, they will be sorted according to size.

Animations

Position and rotation keyframe animation is supported. Since the Blender 2.6 Collada exporter cannot export multiple animations in one file, you will have to put it all in one timeline and split it at the import stage. An animation is defined (after all the meshes) in format anim name startframe endframe:

anim gear_down 0 10
anim something_else 12 25

Start/end may be also in seconds, depends on the format.

The game will recognize animations by name, the list of supported animations is to be decided.

Internally, an animation consists of Channels. Each channel controls one node (a MatrixTransform) and has a list of position and rotation keys. Each key has a time and value. Keys are always linearly interpolated.

Attachments

Models may have special "tag point" Group nodes where other models may be attached. You may define a tag point in Blender by placing an Empty object and giving it one of the predefined names.

The system is meant for attaching equipment: guns, cargo pods, turrets...

Example: A generic gun model attached to a point "tag_gun_right":

Newmodel tagpoints01.png

The actual list of available names has not been determined yet.

Collisions

By default, the collision mesh of a model is the bounding box of all the meshes. For more control, you can import a custom mesh using the collision directive in the model definition:

collision collision.obj

Newmodel collmesh01.png

Decals

Decals are meant for customizable insignia on spaceships and changing advertisements on space stations. Up to four unique decals are available for a model (multiple identical decals are allowed). Place a piece of geometry, usually a flat quad, with proper UV coordinates and name it decal_01, 02, 03 or 04. The game will then use a special material on the geometry.

Newmodel decals01.png

Other special nodes

  • Labels
  • Billboard lights

Thrusters

Thrusters are marked with dummy objects. In Blender, create an "Empty" object and point its Z-axis (change the object display type to "arrows" or "single arrow" to visualize this) where the thruster should point. Thruster size is taken from the object scale. Begin the object name with either thruster or thruster_linear so the importer can recognize them (linear thrusters light up only when moving up/down/left/right/forward/backward, not when turning).

New systems that need to be developed

Lots of them :)

  • Lua API
  • System to handle attachments
    • Tag points may be rotated in code to implement target tracking guns
  • System to handle spaceship logos, station advertisements and shipyard UI to customize your ship
  • UI to paint your ship and a system to give faction-appropriate colour schemes to NPC ships
  • Building sets
  • Update collision system to handle animation (just updating BB should be enough)
  • etc