Most visited

Recently visited

Object3D

public class Object3D
extends Node

java.lang.Object
   ↳ com.viro.core.Node
     ↳ com.viro.core.Object3D


Object3D defines a Node that can load FBX or OBJ models. These file formats may contain not just single Geometry instances but entire subgraphs of Nodes. This Node acts as the parent to the generated subgraph.

OBJ loading supports MTL files, for loading material properties and textures. For OBJ files, Materials can also be manually injected by invoking setMaterials(List). FBX loading fully supports material properties, diffuse, specular, and normal maps, and skeletal and keyframe animation.

For an extended discussion on 3D model loading, refer to the 3D Objects Guide.

Summary

Nested classes

enum Object3D.Type

Supported model formats for loading into an Object3D

Public constructors

Object3D()

Construct a new Object3D.

Public methods

void dispose()

Release native resources associated with this Object3D.

List<Material> getMaterials()

Get a list of unique Material objects used by this 3D model.

void loadModel(Uri uri, Object3D.Type type, AsyncObject3DListener asyncListener)

Load an FBX or OBJ model at the given URI into this Node.

void setLightReceivingBitMask(int bitMask)

Set the bit mask that determines what lights will illuminate this Node.

void setShadowCastingBitMask(int bitMask)

Set the bit mask that determines for which lights the contents of this Node will cast shadows.

Public constructors

Object3D

Object3D ()

Construct a new Object3D. To load 3D model data into this Node, use loadModel(Uri, Type, AsyncObject3DListener).

Public methods

dispose

void dispose ()

Release native resources associated with this Object3D.

getMaterials

List<Material> getMaterials ()

Get a list of unique Material objects used by this 3D model. These may be modified at runtime to change the textures and/or other material properties of the model. Materials can often be identified by their name, which is set by the 3D model loader.

Note that if a model file (OBJ or FBX) contains multiple geometries, this list will contain all the materials across all geometries.

Returns
List<Material> A list containing each Material used by this 3D model.

loadModel

void loadModel (Uri uri, 
                Object3D.Type type, 
                AsyncObject3DListener asyncListener)

Load an FBX or OBJ model at the given URI into this Node. The model will load asynchronously, and the provided listener will receive a notification when model loading is completed. To load Android assets, use URI's of the form file:///android_asset/[asset-name]. If the model requires other resources (e.g. textures), those are expected to be found at the same base path as the model URI.

Parameters
uri Uri: The URI of the model to load.

type Object3D.Type: The type of model (FBX or OBJ).

asyncListener AsyncObject3DListener: Listener to respond to model loading status.

setLightReceivingBitMask

void setLightReceivingBitMask (int bitMask)

Set the bit mask that determines what lights will illuminate this Node. This bit mask is bitwise and-ed (&) with each Light's influenceBitMask. If the result is > 0, then the Light will illuminate this Node. The default value is 0x1.

Parameters
bitMask int: The bit mask to set.

setShadowCastingBitMask

void setShadowCastingBitMask (int bitMask)

Set the bit mask that determines for which lights the contents of this Node will cast shadows. This bit mask is bitwise and-ed (&) with each Light's influenceBitMask. If the result is > 0, then this Node will cast shadows from the light. The default value is 0x1.

Parameters
bitMask int: The bit mask to set.

Hooray!