3DModels:obj meta

From Spring
Jump to navigationJump to search

.obj Mesh Meta Reference

so because wavefront .obj files dont contain all the required information for 3d models in spring this extra file was needed to fill in the missing pieces.

the file accompanies your mesh such that:

objects3d/myobjmesh.obj

objects3d/myobjmesh.lua (this is the meta info file)

variables are organised as such: type VariableName  default: value range: [valid range] Required

Description

If you notice something is incorrect, fix it please!

Source

The engine source code which reads this file is viewable here:

General Formatting

check Lua Documentation.

Data Types

int
An integer number. eg. 5
float
A number with decimals. eg 1.023
bool
A value which can be true or false. eg true
string
Text, or more precisely a string of alphanumeric characters. eg "string of characters"
rgb
Three float components, representing red, green and blue components, ranged from 0.0 to 1.0. eg {0.0, 0.0, 0.0}
float3
Three float components, eg {0.0, 0.0, 0.0}
float4
Four float components, eg {0.0, 0.0, 0.0, 0.0}

Notes

  • each model-table must define EXACTLY one root-piece in its "pieces" sub-table
  • the script MUST return exactly one model-table (which may be named arbitrarily)
  • the tree must reference ONLY object names defined in the .obj file
  • a piece-table key may NOT be "name" or "offset" (these are reserved keywords)

Sections

meshname.lua

meshname = {
    pieces = {
       ...
    },

    radius = 0,
    midpos = 0,
    tex1 = "",
    --tex2 = "",
    numpieces = 1,

    globalvertexoffset = true,
    localpieceoffset = true,
}
return meshname
meshname

name of your mesh...

float3 midpos  default: ? Required

the local of the median point of the mesh from the origin

float radius  default: ? Required

from the midpos the radius of the mesh, used for occlusion culling

string tex1  default: ?

filename of the texture image to use for diffuse and teamcolor

string tex2  default: ?

filename of the texture image to use for ambient, specular and transparency

bool globalvertexoffsets  default: ?

whether the vertex coordinates are relative to the global origin, or the local origin

bool localpieceoffsets  default: ?

whether the piece offsets are relative to the global origin, or the parent offset

pieces

Specifies the hierarchy of objects

meshname = {
    pieces = {
        piecename = {
            offset = {0.0, 0.0, 0.0},
            anotherpiecename = {
                offset = {0.0, 0.0, 0.0},
                ...
            },
            ...
        },
    },
    ...
}
return meshname

string name  default: ? Required

each piece name needs to correspond to an object in the mesh file. For an .obj file it would be the "o" tag

float3 offset  default: ? Required

the offset of the piece vertices either in parent or world space