Vizard 8 » Reference » Vizconnect » Advanced GUI » Wrapped Objects
8.1

Wrapped and Raw Objects

Each time an object is added in vizconnect, both a raw and a wrapped object are added to the vizconnect session. The raw object is the same as the tracker, display window, input device etc. that is returned when using Vizard code to add the object. The wrapped object is a vizconnect layer that wraps up the raw object along with meta data, such as the device make and model. It supports additional functionality based on the object type, for example wrapped trackers have commands for applying offsets and resets.

Getting Handles to Wrapped Objects

The following table shows commands to get each of the wrapped object types:

Command
vizconnect.getTracker(name)
vizconnect.getDisplay(name)
vizconnect.getInput(name)
vizconnect.getTransport(name)

vizconnect.getAvatar(name)

vizconnect.getTool(name)
vizconnect.getEvent(name)

The name parameter is a string that matches the name assigned in the GUI:

wrappedTracker = vizconnect.getTracker('r_hand_tracker')

If name is not specified, the default object will be returned. The image below shows two trackers, with head_tracker set to be the default:

The following code returns the default tracker, in this case head_tracker:

wrappedTracker = vizconnect.getTracker()

Raw Object

The getRaw() method can be called on any wrapped object to get the associated raw object:

wrappedTracker = vizconnect.getTracker('head_tracker')
rawTracker = tracker.getRaw()

Node3D Object

All wrapped objects with the exception of inputs and events wrap up a node3D object along with the raw object. The node3D object is useful as a linkable node. Both the node and wrapped objects return the same position and orientation when queried. Only the node, however, can be used with the viz.link command. The following links a car model to a driving transport:

transport = vizconnect.getTransport('driving')
viz.link(transport.getNode3d(), car)

Changing Parent/Child Relationships

Use wrapped objects when changing parent/child relationships in the code. The following example shows how to change the parent tracker of a display:

#Get wrapped trackers and display
keyTracker = vizconnect.getTracker('keyboard')
mouseKeyTracker = vizconnect.getTracker('mouse_and_keyboard_flying')
display = vizconnect.getDisplay('custom_window')
#Change the display's parent tracker
vizact.onkeydown('1',display.setParent,keyTracker)
vizact.onkeydown('2',display.setParent,mouseKeyTracker)

Wrapped Object Methods

The following methods are available on all wrapped objects (from <node> class):

Method Description
<wrappedObject>.getClassification() Returns the classification for a given node

<wrappedObject>.getConfiguration()

Returns the configuration associated with a given node. It is possible for a node not to have a configuration. All nodes added via the add[classification] functions are automatically added to the current vizconnect configuration.

<wrappedObject>.getMake() Returns the object's make, as obtained from template file.
<wrappedObject>.getModel() Returns the object's model, as obtained from template file.
<wrappedObject>.getName() Gets the name of the object.
<wrappedObject>.getRaw() Returns the raw object associated with this wrapped class.
<wrappedObject>.remove() Removes this wrapped object, will also remove the raw item.
<wrappedObject>.removeRaw() Removes the raw object. Uses the template object's remove function. This requires make and model be specified and match a registered template.
<wrappedObject>.setRaw(raw) Allows a new raw item to be set for this wrapped object.

The following methods are available on all wrapped objects with the exception of inputs and events (from <node3D> class):

Method Description
<wrappedObject>.getNode3d() Returns the node3d object associated with this wrapped object.
<wrappedObject>.getChildren() Returns a list of the child nodes for this object.
<wrappedObject>.getParent() Returns the parent wrapped object for this node.
<wrappedObject>.getRoot() Returns the root node associated with this node's configuration.
<wrappedObject>.setParent(parent) Sets the parent of the node.
<wrappedObject>.removeChild(node) Removes a child of this node.