Vizard 7 » Reference » Appearance & Texturing » Visibility
7.7

Visibility

Basics

The visibility of any 3D object can be turned on and off using <node3d>.visible. An invisible object isn't removed from the scene, but can be revealed by again calling <node3d>.visible. You can also vary the transparency of an object by adjusting its alpha level with <node3d>.alpha . The lower the alpha level, the more light that will pass through the object. If you want to permanently remove an object entirely from the scene, use <node3d>.remove.

 

Here is a simple example showing how to toggle the visibility of a node using the space key:

#Add a ball.
ball = viz.add('ball.wrl')
#Make its appearance toggle on and off with the spacebar.
vizact.onkeydown( ' ', ball.visible, viz.TOGGLE )

#Add a box with a alpha level of .5.
box = viz.add('box.wrl')
box.alpha(.5)
#Remove the box permanently with the tab key.
vizact.onkeydown( viz.KEY_TAB, box.remove )

When a node is invisible it will not take part in any scene graph operations, such as rendering, picking, intersection tests, and collisions. All children nodes will also be invisible. You can apply more fine grained control over the scene graph participation of a node using the various commands below.

Rendering Visibility

If you would like disable the rendering of a node, but still have it participate in other operations (picking, collisions, etc..), you can disable viz.RENDERING:

ball.disable(viz.RENDERING)

You can even control whether the node renders to the left or right eye when running in stereo by using the viz.RENDER_RIGHT or viz.RENDER_LEFT flags:

# Do not render to right eye
ball.disable(viz.RENDER_RIGHT)

or

# Do not render to left eye
ball.disable(viz.RENDER_LEFT)

Picking Visibility

You can prevent a node from participating in pick operations ( <window>.pick ), by disabling viz.PICKING:

ball.disable(viz.PICKING)

Intersection/Collision Visibility

You can prevent a node from participating in intersect tests ( <scene>.intersect ) or viewpoint collisions ( <view>.collision ), by disabling viz.INTERSECTION:

ball.disable(viz.INTERSECTION)

Physics Visibility

To prevent a node from participating in the physics simulation, disable viz.PHYSICS:

ball.disable(viz.PHYSICS)

Disabling physics will have no effect if physics geometry has not been defined for the node.

Color/Depth Visibility

In certain advanced cases you might want to disable a node from being rendered to the OpenGL color buffer or depth buffer. You can use the viz.COLOR_WRITE and viz.DEPTH_WRITE flags to control this behavior.

# Do not render to depth buffer 
ball.disable(viz.DEPTH_WRITE)

# Do not render to color buffer
ball.disable(viz.COLOR_WRITE)

Window Visibility

If you have created sub-windows with the <viz>.addWindow command, you can prevent a node from appearing in the window or have a node only appear in that window.

 

The <node3d>.renderToAllWindowsExcept command is used to specify a set of windows the node should not be rendered to:

# Do not render to window
ball.renderToAllWindowsExcept([window])

Inversely, you can have the node only render to a specific set of windows using the <node3d>.renderOnlyToWindows command:

# Only render to window
ball.renderOnlyToWindows([window])

The same restrictions can be applied to render nodes by using the <node3d>.renderToAllRenderNodesExcept and <node3d>.renderOnlyToRenderNodes commands.

See also

In this section:

Appearance & texturing basics

Texture wrapping

Multi-texturing

Environment mapping

Texture appearance and filtering

Texture types

Texture matrix

Draw order & Z offsetting

Projecting textures

Appearance & texturing command table

Other sections:

3D model basics