Skip to content
Alessandro Febretti edited this page Aug 8, 2013 · 14 revisions

[[module cyclops]] extends [[SceneNode]] wraps cyclops::Entity

An entity is a drawable thing that derives from a scene node. Entities offer additional functionality for 3d model visualization, like transparency, rendering effects and link to motion capture tracked objects. Upon creation, entities are attached to the scene root, but they can be attached to different nodes in the scene after creation.

Methods

Method(s) Description
Visual Properties
bool hasEffect() Returns true if an effect is set for the entity
[[Material]] getMaterial(), [[Material]] getMaterialByIndex(int index) Retrieves a material layer for this entity. getMaterial() returns material layer 0 by default
int getMaterialCount() Returns the number of material layers for this entity.
clearMaterials() Remosed all the material layers for this entity.
addMaterial([[Material]] m) Adds a material layer to this entity. The Entity visuals will be automatically updated.
setEffect(string effectDefinition) Sets the rendering effect for the entity
EXPERIMENTAL Context menu
createContextMenu() Creates a context menu attached to this entity. When the user selectes the entity, the menu will pop up. Returns a Menu object
[[Menu]] getContextMenu() Gets the attached context menu for the entity if one has been set.
deleteContextMenu() Deletes a context menu attached to this entity
Entity Pieces Entities can be made up by multiple components (pieces). For instance, complex loaded models may have multiple parts that we want to manipulate separately.
listPieces(string path) Returns a list containing the names of all the entity pieces in the specified path. A path is a list of node names in the entity node tree. Use an empy string to list all the piece names connected directly to the entity root.
[[SceneNode]] getPiece(string path) Returns a SceneNode for a piece identified by the passed path. If no piece exists for path, returns None. All basic SceneNode functions work on entity pieces, but pieces can't be detached from this entity and attached to another one (doing so will not influence their transform, since it is always local to the owner entity).

Examples

Entity Pieces

	# Assume the house model represents a house with a door and window. The window has two panels (left and right)
	house = StaticObject.create('house')
	
	# Print the names of all root pieces for this entity (would print something like 'window, door')
	for pieceName in house.listPieces(''): print pieceName
	
	# Print the names for all pieces under the 'window' piece (would print something like 'left, right')
	for pieceName in house.listPieces('window'): print pieceName
	
	# Get the left window panel and rotate it to open the window.
	leftPanel = house.getPiece('window/left')
	leftPanel.yaw(radians(90))
Clone this wiki locally