jit.gl.model Reference

Read and draw various 3D model formats

jit.gl.model

Description

jit.gl.model Reads and draws a variety of 3D model formats, such as OBJ, Collada, and Blender. Only tessellated polygons are drawn, and surfaces that are not tessellated are converted before drawing. Certain model formats, such as Collada, support skinned animation.

Examples

Discussion

This object requires one argument: the name of a drawing context. A named drawing context is a named instance of a jit.window, jit.pwindow, or jit.matrix object that has an instance of the jit.gl.render object associated with it. Additionally it can reference the name of a jit.gl.node sub-context. This value may also be set via the OB3D drawto attribute. If no argument is present, the object is implicitly added to the first valid drawing context or sub-context found in the current patch or by searching up the patcher hierarchy.
Supported model file types include:
Wavefront Object Model File
Collada Model File
Blender 3D Model File
3ds Max 3DS Model File
3ds Max ASE Model File
Stanford Polygon Library Model File
AutoCAD DXF Model File
LightWave Model File
Modo Model File
Stereolithography Model File
AC3D Model File
Milkshape 3D Model File
TrueSpace COB Model File
TrueSpace SCB Model File
Valve SMD Model File
Valve VTA Model File
Quake I Mesh File
Quake II Mesh File
Quake III Mesh File
Quake III BSP File
Return to Castle Wolfenstein Model File
Doom 3 Model File
Biovision BVH Motion Capture File
CharacterStudio Motion Capture File
Direct X Model File
BlitzBasic 3D Model File
Quick3D Q3D Model File
Quick3D Q3S Model File
Ogre3D XML Model File
Irrlicht Mesh File
Irrlicht Scene File
Neutral File Format File
Sense8 WorldToolKit File
Object File Format File
PovRAY Raw Model File
Terragen Terrain File
3D GameStudio Model File
3D GameStudio Terrain File
Izware Nendo Model File
For more information see the Assimp website.

Attributes

animblendmode [int]

Determine how multiple enabled animations will be blended (default = 0 - Average).

Possible values:

0 = 'Average' ( Weights will be averaged to equal 1 )
1 = 'Cumulative' ( Weights will be added and can go greater than 1 )

cache_mode [symbol]

The mode to use for the geometry cache (default = var). Synonym for mode.

Possible values:

'displaylist'
'vertexarray'
'vertexbuffer'
'immediate'

displaylist [int]

Cache in displaylist flag (default = 0). This feature may be used to speed up rendering time by creating and storing a list of gl drawing commands on the graphics card. This will have no effect if matrixoutput turned on, and will prevent model animation when enabled.

drawgroup [int]

If non-zero, draw only one mesh. If zero, draw all mesh groups in the model (default = 0).

drawskeleton [int]

If enabled draw a wireframe representation of the bones in the model (default = 0).

file [symbol]

Load a model file

find_instances [int]

Mesh instance removal on import (default = 1). An optional post-processing step when importing the model file. Instanced meshes are removed by referencing one master.

fix_normals [int]

Fix normals on import (default = 0). An optional post-processing step when importing the model file. Tries to fix normal vectors that are facing inwards.

gen_normals [int]

Generate normals on import (default = 1). An optional post-processing step when importing the model file.

gen_tangents [int]

Generate tangents on import (default = 1). An optional post-processing step when importing the model file. Calculates tangents and bitangents if possible.

hasbones [int]

g/s(get)

Indicates whether the loaded model has bone nodes.

material_mode [int]

Mode for applying built-in material properties of a model. (default = 1 - Diffuse)

Possible values:

0 = 'Ignore (Inherit Colors From OB3D)' ( Material properties are ignored )
1 = 'Diffuse (Use Diffuse Only)' ( Only diffuse color component is used )
2 = 'All (Use All Color Values)' ( All material components are used )
3 = 'JMTL (Use Jitter Material)' ( Internal jit.gl.material object is used )

mode [symbol]

Determines the method used to draw the model (default = var).

Possible values:

'displaylist' ( Synonym for Immediate mode with displaylist enabled )
'var' ( Vertex Arrays )
'vbo' ( Vertex Buffer Objects )
'immediate' ( Immediate mode drawing )

nodeaxes [int]

If non-zero, draw a RGB axes at the location of all the nodes in the model.

normalize [int]

Normalize model coordinates flag (default = 1). When enabled, the model is scaled to the range (-1.,1.) for the x, y, and z axes.

numanimations [int]

g/s(get)

Indicates the number of animations in the model.

numgroups [int]

g/s(get)

Indicates the number of mesh groups. A mesh group consists of vertex data and material data.

optimize [int]

Optimize vertices and nodes on import (default = 1). An optional post-processing step when importing the model file. Identical vertices are jointed to optimize indexing, small meshes are joined if possible, and Nodes with no data assigned are collapsed and joined.

smoothing_angle [float]

Specifies the edge angle above which to smooth vertex normals (default = 89.)

verbose [int]

Verbose mode flag (default = 0). If enabled, messages useful for debugging are printed to the Max Console.

Common Box Attributes

OB3D Attributes

Messages

(drag)

Drag and drop model files

animenable

Arguments

anim-index (optional) [int]
enable [int]
Enable a model animation. If two arguments are provided, the first is the animation index to enable. Otherwise the current animation is used.

animloop

Arguments

anim-index (optional) [int]
loop-enable [int]
Enable/disable looping on an animation. Looping on animations is enabled by default. If two arguments are provided, the first is the animation index to enable. Otherwise the current animation is used.

animlooppoints

Arguments

anim-index (optional) [int]
loop-start [float]
loop-stop [float]
Set the loop points of an animation, if looping is currently enabled on that animation. If two arguments are provided, the first is the animation index to enable. Otherwise the current animation is used.

animrate

Arguments

anim-index (optional) [int]
rate [float]
Set an animation's rate. If two arguments are provided, the first is the animation index, otherwise the current animation is used.

animreset

Arguments

anim-index (optional) [int]
Reset the state of an animation. Time is set to 0., rate to 1., weight to 1., and the loop points are set to the beginning and end of the animation. If two arguments are provided, the first is the animation index to enable. Otherwise the current animation is used.

animtime

Arguments

anim-index (optional) [int]
time [float]
Jump to a specific time, in seconds, of an animation. If two arguments are provided, the first is the animation index, otherwise the current animation is used.

animweight

Arguments

anim-index (optional) [int]
weight [float]
Set an animation's weight which determines how much influence the animation has on the affected mesh. If two arguments are provided, the first is the animation index, otherwise the current animation is used.

copynodestoclipboard

Copy all nodes in the model as jit.anim.node objects, to the clipboard. When the nodes are pasted in the patch, they will control the internal nodes of the model. Make sure the name attribute is set before using this feature.

getanim_dict

Arguments

anim-index [int]
Send a description of the animation at anim-index as a dictionary out the dumpout.

getanimnames

Sends a list of the scenes named animations out the dumpout. Some model files don't support named animations, and therefore the names will not be sent, even though animations are present.

getbonenames

Sends a list of the bones currently loaded in the model, if any, out the dumpout.

getmaterial_dict

Arguments

drawgroup (optional) [int]
Send a description of the drawgroup material as a dictionary out the dumpout. If no argument, use the current drawgroup attribute.

getnodenames

Sends a list of the scene nodes currently loaded in the model out the dumpout.

gettexnames

Sends a list of all the textures currently loaded in the model out the dumpout.

nodeanimenable

Arguments

model node name [symbol]
anim-enable [int]
Toggle the animation of the named node. If disabled, model animations will have no effect on that node.

nodebind

Arguments

model node name [symbol]
jit.anim.node name [symbol]
Takes two args, the name of the node in the model to bind, and the name of an jit.anim.node object to bind to.

nodereset

Arguments

model node name [symbol]
Resets the named node in the model to it's initial spatial transform state.

nodesetinitial

Arguments

model node name [symbol]
Sets the named nodes initial transform state to it's current transform.

read

Loads an model file from disk. The read message will attempt to find the model file in the Max search path and load it. If no file name is specified, a file dialog box is presented.

sendmaterial

Arguments

drawgroup [int]
message [symbol]
values [list]
Send the internal material for drawgroup a message. See jit.gl.material for possible messages and attributes.

sendtexture

Arguments

texture name [symbol]
message [symbol]
values [list]
Send the internal named texture a message. See jit.gl.texture for possible messages and attributes.

texgroup

Arguments

group-number [int]
texture-name [symbol]
The texgroup message is used to apply a named texture to a specific mesh within the model. The model's mesh-groups are specified in its model file. The texture applied to a group will override any textures which have been applied to the object using the texture attribute, and textures loaded from the model file.

OB3D Messages

See Also

Name Description
Working with OpenGL Working with OpenGL
Video and Graphics Programming Tutorials Video and Graphics Programming Tutorials
Online Resources Online Resources
jit.gl.mesh
jit.gl.render
jit.gl.texture
jit.gl.material
jit.gl.camera
Tutorial 36: 3D Models Tutorial 36: 3D Models