Packagealternativa.engine3d.loaders
Classpublic class ParserOBJ

Parser of OBJ data. After data has been parsed, the content property will contain all objects. The property materialFileNames will contain names of material library files.

Following OBJ commands are supported:

Command Description Action
o object_name Definition of a new object with name object_name If there were defined faces for current object, command creates new object with given name, otherwise current object just changes name to given one.
v x y z Definition of vertex with x y z coordinates Vertex is put in general list of scene vertices for further usage
vt u [v] Defining texture vertex with u v coordinates Vertex is put to general texture vertices list for further usage
f v0[/vt0] v1[/vt1] ... vN[/vtN] Defining face, which consist of given vertices and optional texture coordinates for vertices. Face is added to a current active object. If there is an active material, face is added to surface of a current object, corresponding to a current material.
usemtl material_name Set current material with name material_name From the moment of setting current material, all the faces being created are put into current surface, corresponding to this material and having identifier equal to it's name.
mtllib file1 file2 ... Declaration of material library files File names are stored in the materialFileNames property.



Public Properties
 PropertyDefined by
  content : Object3D
[read-only] This property contains all objects defined in OBJ data that was parsed by the parse method.
ParserOBJ
  materialFileNames : Array
[read-only] This property contains a list of material library files defined in OBJ data that was parsed by the parse method.
ParserOBJ
  mobility : int
The value of the mobility property of 3d objects.
ParserOBJ
  objectsAsGroups : Boolean
If true, then objects will be recognized by keyword "g" instead of "o".
ParserOBJ
  rotateModel : Boolean
If true, the loaded objects will be rotated around X axis by 90 degrees.
ParserOBJ
  scale : Number
The scaling coefficient wich is applied to all loaded objects.
ParserOBJ
Public Methods
 MethodDefined by
  
Creates a new instance of the class.
ParserOBJ
  
parse(data:String):void
Parses specified OBJ data.
ParserOBJ
Property detail
contentproperty
content:Object3D  [read-only]

This property contains all objects defined in OBJ data that was parsed by the parse method.

Implementation
    public function get content():Object3D
materialFileNamesproperty 
materialFileNames:Array  [read-only]

This property contains a list of material library files defined in OBJ data that was parsed by the parse method.

Implementation
    public function get materialFileNames():Array
mobilityproperty 
mobility:int  [read-write]

The value of the mobility property of 3d objects.

The default value is 0.

Implementation
    public function get mobility():int
    public function set mobility(value:int):void

See also

objectsAsGroupsproperty 
objectsAsGroups:Boolean  [read-write]

If true, then objects will be recognized by keyword "g" instead of "o".

The default value is false.

Implementation
    public function get objectsAsGroups():Boolean
    public function set objectsAsGroups(value:Boolean):void
rotateModelproperty 
rotateModel:Boolean  [read-write]

If true, the loaded objects will be rotated around X axis by 90 degrees.

The default value is false.

Implementation
    public function get rotateModel():Boolean
    public function set rotateModel(value:Boolean):void
scaleproperty 
scale:Number  [read-write]

The scaling coefficient wich is applied to all loaded objects.

The default value is 1.

Implementation
    public function get scale():Number
    public function set scale(value:Number):void
Constructor detail
ParserOBJ()constructor
public function ParserOBJ()

Creates a new instance of the class.

Method detail
parse()method
public function parse(data:String):void

Parses specified OBJ data. After parsing have been completed, the content property will contain 3d objects and the materialFileNames will contain names of material library files.

Parameters
data:StringOBJ data