Packagealternativa.engine3d.loaders
Classpublic class LoaderOBJ
InheritanceLoaderOBJ Inheritance Loader3D Inheritance flash.events.EventDispatcher

Loader for OBJ files. Because OBJ format doesn't support objects hierarchy, all loaded models are put into one container Object3D.

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 ... Defining files containing material definitions Files are being loaded and material library is being formed. For texture materials lightmaps can be specified. If size of diffuse texture and size of lightmap of a material are different, then the lightmap is resized to match dimensions of the diffuse texture.

See also

alternativa.engine3d.loaders.ParserOBJ


Public Properties
 PropertyDefined by
  blendMode : String = "normal"
The value of the blendMode property of texture materials which are created during loading process.
LoaderOBJ
 Inheritedcontent : Object3D
The container with all loaded objects.
Loader3D
  loadMaterials : Boolean = true
If false, then materials will not be loaded.
LoaderOBJ
  mobility : int
The value of the mobility property of 3d objects.
LoaderOBJ
  objectsAsGroups : Boolean
If true, then objects will be recognized by keyword "g" instead of "o".
LoaderOBJ
  precision : Number = 10
The value of the precision property of texture materials which are created during loading process.
LoaderOBJ
  rotateModel : Boolean
If true, the loaded objects will be rotated around X axis by 90 degrees.
LoaderOBJ
  scale : Number
The scaling coefficient wich is applied to all loaded objects.
LoaderOBJ
  smooth : Boolean = false
The value of the smooth property of texture materials which are created during loading process.
LoaderOBJ
Protected Properties
 PropertyDefined by
 InheritedbaseURL : String
Loader3D
 Inherited_content : Object3D
Loader3D
 InheritedloaderContext : LoaderContext
Loader3D
 InheritedloaderState : int = 0
Loader3D
Public Methods
 MethodDefined by
  
Creates a new LoaderOBJ instance.
LoaderOBJ
 Inherited
close():void
Stops current loading process.
Loader3D
 Inherited
load(url:String, loaderContext:LoaderContext = null):void
Loads a scene from specified URL.
Loader3D
 Inherited
loadBytes(data:ByteArray, baseUrl:String = null, loaderContext:LoaderContext = null):void
Loads data from a byte array.
Loader3D
 Inherited
unload():void
Clears internal references to the loaded data.
Loader3D
Protected Methods
 MethodDefined by
  
clean():void
LoaderOBJ
  
LoaderOBJ
 Inherited
complete():void
Loader3D
 Inherited
onMainLoadingError(e:ErrorEvent):void
Loader3D
  
parse(data:ByteArray):void
LoaderOBJ
 Inherited
setState(state:int):void
Loader3D
  
LoaderOBJ
Events
 EventSummaryDefined by
 Inherited Dispatched when all scene data is loaded and parsed.Loader3D
 Inherited Dispatched when an error occurs during loading process.Loader3D
 Inherited Dispatched when a loading process stage is completed.Loader3D
 Inherited Dispatched when data is recieved during loading process.Loader3D
 Inherited Dispatched when a loading process stage is started.Loader3D
 Inherited Dispatched when a call of the load() method violates the security rules.Loader3D
Property detail
blendModeproperty
public var blendMode:String = "normal"

The value of the blendMode property of texture materials which are created during loading process.

The default value is BlendMode.NORMAL.

See also

loadMaterialsproperty 
public var loadMaterials:Boolean = true

If false, then materials will not be loaded.

The default value is true.

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
precisionproperty 
public var precision:Number = 10

The value of the precision property of texture materials which are created during loading process.

The default value is TextureMaterialPrecision.MEDIUM.

See also

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
smoothproperty 
public var smooth:Boolean = false

The value of the smooth property of texture materials which are created during loading process.

The default value is false.

See also

Constructor detail
LoaderOBJ()constructor
public function LoaderOBJ()

Creates a new LoaderOBJ instance.

Method detail
clean()method
protected override function clean():void

closeInternal()method 
protected override function closeInternal():void

parse()method 
protected override function parse(data:ByteArray):void

Parameters
data:ByteArray
unloadInternal()method 
protected override function unloadInternal():void