Vizard 7 » Reference » Tools » Examiner
7.7

Examiner

The examiner tool allows users to highlight an object. A copy of the object can then be brought to the location of the examiner or a node in the scene. The following command creates an Examiner object:

Command

Description

examiner.Examiner(reelTime=60

                         sizeOfCopy=0.5

                         autoScale=True

                         stand=None

                         highlightMode=highlighter.MODE_OUTLINE)

reelTime: The length of time to bring in the copy

sizeOfCopy: The size of the copy's bounding sphere in meters. AutoScale must be enabled.

autoScale: Specifies whether or not the model will be scaled.

stand: A node to which the copy is moved. When set to None, the copy is moved to the tool's location.

highlightMode: Can be highlighter.MODE_ARROW, highlighter.MODE_OUTLINE, highlighter.MODE_BOX

The following methods are available on the Examiner object:

Method

Description

<Examiner>.setStand(stand)

stand: A node to move the copy to.

<Examiner>.getStand()

Returns the node set as the stand.

<Examiner>.setHighlightMode(highlightMode)

Sets the highlight mode.

highlightMode: Can be highlighter.MODE_ARROW, highlighter.MODE_OUTLINE, highlighter.MODE_BOX

<Examiner>.getHighlightMode()

Returns the highlight mode.

<Examiner>.setItems()

Sets the objects that can examined.

items: a list of Vizard nodes.

<Examiner>.highlight()

Draws a ray and highlights the intersecting object. An object must be highlighted before it is examined.

<Examiner>.examine()

Creates a copy of the highlighted object and reels it in for examination.

<Examiner>.release()

Deletes the object copy and clears the highlight on the original object.

<Examiner>.remove()

Removes the examiner tool.

<Highlighter>.setUpdateFunction(updateFunction)

Sets the update function that gets called every frame. The update function calls methods on the tool based on the state of input devices.

The following event is triggered when the object highlighted by the examiner changes:

Event

Description

highlighter.HIGHLIGHT_EVENT

This event is generated when the object highlighted by the examiner is updated. It provides a single event structure e with the following attributes:

e.new: The object currently highlighted by the highlighter. Returns None if there is no object.

e.old: The object that was previously highlighted by the highlighter. Returns None if there was no object.

Example

"""  
Left mouse button highlights.  
Right mouse button examines.  
Middle mouse button releases.  
Mouse movements and arrow keys  
control the viewpoint.  
""" 

import viz
import vizact
import vizshape
import vizinfo
vizinfo.InfoPanel()

viz.setOption('viz.display.stencil',1)

viz.setMultiSample(4)
viz.fov(60)
viz.go()

environment = viz.addChild('sky_day.osgb')
soccerball = viz.addChild('soccerball.osgb',pos=[-1,1.8,2])
basketball = viz.addChild('basketball.osgb',pos=[0,1.8,2])
volleyball = viz.addChild('volleyball.osgb',pos=[1,1.8,2])

#Add a model to represent the tool
arrow = vizshape.addArrow(length=0.2, color = viz.ORANGE, alpha=0.5)

#Initialize the examiner and items that can be examined
from tools import examiner
tool = examiner.Examiner(sizeOfCopy=1)
tool.setItems([soccerball,basketball,volleyball])

# update code for examiner
def updateExaminer(tool):
    state = viz.mouse.getState()
    if state & viz. MOUSEBUTTON_LEFT:
        tool.highlight()
    if state & viz. MOUSEBUTTON_RIGHT:
        tool.examine()
    if state & viz. MOUSEBUTTON_MIDDLE:
        tool.release()
tool.setUpdateFunction(updateExaminer)

#Link the examiner tool to an arrow in order to
#visualize it's position
from vizconnect.util import virtual_trackers
mouseTracker = virtual_trackers.ScrollWheel(followMouse = True)
mouseTracker.distance = 1
arrowLink = viz.link(mouseTracker,arrow)
arrowLink.postMultLinkable(viz.MainView)
viz.link(arrowLink,tool)

import vizcam
cam = vizcam.FlyNavigate()

#Hide the mouse cursor
viz.mouse.setVisible(viz.OFF)