Class vxlActor

Actors represent models (assets) in a Scene

Constructor

vxlActor(model)

An actor is a representation of a model in Voxelent. Actors can cache model properties and modified them. This is useful when there are several actors based in the same modelbut each one of them needs to have a different version of any given model property (i.e. color)

To propagate one change for all the actors based in the same model, the setProperty methodshould be invoked by setting the third parameter (scope) like this:

var actor = vxl.c.scene.getActorByName('example');actor.setProperty('color',[1.0,0.0,0.0], vxl.def.model)

If the change should be local (for just that actor) then you should write:

var actor = vxl.c.scene.getActorByName('example');actor.setProperty('color',[1.0,0.0,0.0], vxl.def.actor)

Or simply

var actor = vxl.c.scene.getActorByName('example');actor.setProperty('color',[1.0,0.0,0.0])

Parameters:

model

Methods

.addTrackingCamera(camera)
Adds a tracking camera

Parameters:

Type Name Description
camera

vxlActor .clone()
Duplicates this actor.

The model property of the actor (vxlModel) is shared with the new instance

The actor level properties are copied by VALUE.

If a cloned actor modifies his internal model, any other actor that shares the model will beaffected. A cloned actor however can have different position, colors, etc. (actor level properties)The returned actor is not added to the scene automatically. It is up theprogrammer to determine the scene the cloned actor needs to be added to if at all.The clone does not keep any information about the current position or rotation of the originalactor.

Returns:

{vxlActor} an actor

See:

vxlModel
.cullFace(face)
Sets the culling mode for this actor.

Parameters:

Type Name Description
vxl.def.actor.cull face

face needs to be one of the elements defined in vxl.def.actor.cull

.flipNormals()
Flips the normal for this actor. It delegates the task to the model
Array .getBoundingBox()
Returns the bounding box for this actor. The actor's bounding box observes any geometrictransformation suffered by the actor. Therefore it is ideal to do collision detection.The format of the returned bounding box is [x-min, y-min, z-min, x-ax, y-max, z-max]

Returns:

{Array} the current bounding box.
Array .getBoundingBoxVertices()
Returns an array with the bounding box vertices. Good for rendering the transformedbounding box (after geometric transformations)

Returns:

{Array} a 8-element array with the vertices that constitute the actor bounding box
Number .getHeight()
Returns the height for the current actor.

Returns:

{Number} the current height
.getPickingType()
Returns the picking type
Object .getProperty(property)
Returns an actor property if that property exists in the actor. Otherwise it will search in the model. This method is used by the renderer. There are some cases where actors have local changesthat are not reflected in the model. In these cases the renderer should pick the actor propertyover the model property

Parameters:

Type Name Description
String property

the property name

Returns:

{Object} the property or undefined if the property is not found
.isPickable()
Reports if the current actor is pickable or not
boolean .isVisible()
Is visible?

Returns:

{boolean} true if the object is visible
.reallocate()
This method needs to be invoked whenever the actor undergoes changes thataffect its rendering. These changes are:1. morphing = the geometry has changed2. texturing = the actor has a new texture3.
.removeTrackingCamera(camera)
Removes a tracking camera

Parameters:

Type Name Description
camera

.rotateX(angle)
Rotates the actor on the X axis

Parameters:

Type Name Description
Number angle

the angle

.rotateY(angle)
Rotates the actor on the Y axis

Parameters:

Type Name Description
Number angle

the angle

.rotateZ(angle)
Rotates the actor on the Z axis

Parameters:

Type Name Description
Number angle

the angle

.setColor(r, g, b)
Sets the actor color. This color can be different from the original model color

Parameters:

Type Name Description
Number|Array|vec3 r

it can be the red component, a 3-dimensional Array or a vec3 (glMatrix)

Number g

if r is a number, then this parameter corresponds to the green component

Number b

if r is a number, then this parameter corresponds to the blue component

.setLookupTable(lutID, min, max)
Sets the lookup table for this actor.This method will only succeed if the model that this actor represents has scalars

Parameters:

Type Name Description
String lutID

the lookup table id. See vxl.def.lut for currently supported ids.

Number min

lowest value for interpolation

Number max

highest value for interpolation

.setMaterial(p_material)

Parameters:

Type Name Description
vxlMaterial p_material

the new material

.setOpacity(o)
Sets the opacity of this actor.

Parameters:

Type Name Description
Number o

a float value between 0 and 1.

.setPicking(type, pick, unpick)

Parameters:

Type Name Description
String type

one of the possible values for vxl.def.actor.picking

Function pick

a function that is invoked when a picking event occurs. This parameter is required if the type (first argument) is different from vxl.def.actor.picking.DISABLED the callback receives an actor object to operate over it.

Function unpick

a function that is invoked when an unpicking event occurs.

.setPosition(x, y, z)
Sets the position of this actor.

Parameters:

Type Name Description
Number|Array|vec3 x

it can be the x coordinate, a 3-dimensional Array or a vec3 (glMatrix)

Number y

if x is a number, then this parameter corresponds to the y-coordinate

Number z

if x is a number, then this parameter corresponds to the z-coordinate

.setProperty(property, value, scope)
If the property exists, then it updates it

Parameters:

Type Name Description
String property

name of the property

Object value

value to be set

String scope

indicates if the change is made at the actor level or at the model levelvalid values for scope are vxl.def.model and vxl.def.actor

.setScale(s, a, b)
Scales this actor.

Parameters:

Type Name Description
Number|Array|vec3 s

the scaling factor. The scaling factor is applied in all axes.

a

b

.setScene(scene)
Sets the scene the actor belongs to. Used to notifiy the sceneabout changes in actor properties

Parameters:

Type Name Description
scene

.setShading(flag)
Enables or disables the calculation of the shading. Any shader should take into account this actor property to decide how to render it.

Parameters:

Type Name Description
Boolean flag

can be true or false

.setShininess(s)
Sets the shininess of this actor

Parameters:

Type Name Description
Number s

a value for the shininess

.setTexture(p_texture)
Associates a new texture with this actor

Parameters:

Type Name Description
vxlTexture|String p_texture

the texture to load

.setVisible(flag)
Sets the visibility of the actor

Parameters:

Type Name Description
boolean flag

true or false

.setVisualizationMode(mode)
Sets the visualization mode for this actor.

Parameters:

Type Name Description
vxl.def.actor.mode mode

mode needs to be one of the elements defined in vxl.def.actor.mode

.translate(x, y, z)
Translates the actor by a given vector

Parameters:

Type Name Description
Number|Array|vec3 x

it can be the x coordinate, a 3-dimensional Array or a vec3 (glMatrix)

Number y

if x is a number, then this parameter corresponds to the y-coordinate

Number z

if x is a number, then this parameter corresponds to the z-coordinate

.updateRenderable(task)
Used by vxlMesh to update the renderable object after the mesh has changed

Parameters:

Type Name Description
String task

type of update