Vizard 8 » Reference » Viewpoints & Windows » Viewpoints » Viewpoint collision & gravity
8.0

Viewpoint collision & gravity

If you want the viewer's navigation of a world to be limited by a couple basic real-world constraints, you can add collision detection and gravity. With collision detection on, the view will stop when it hits an object and will fall if there's no ground beneath it.

Using collision detection and gravity

The command <viewpoint>.collision( viz.ON ) will make it so that when the viewpoint collides with objects, it can't move any further. The collision buffer is the distance the viewpoint must be from an object to trigger a collision. In that sense, it simulates the radius of the viewpoint's body. If you'd like to set this buffer, add <viewpoint>.collisionBuffer(<distance>) where <distance> is the radius in meters.

 

When your viewpoint's collision detection is turned on, use <viewpoint>.stepSize(<height>) to set the height at which an object blocks the viewpoint. If an object is below that height then the viewpoint will continue, stepping atop the object. If an object is above that height, then the viewpoint will be blocked. For example, if stepsize is 0.3 and the height of the ground in front of you is 0.4 then you won't be able to move forward.

 

When you apply collision detection to a viewpoint, it automatically adds gravity to your viewpoint. To turn gravity off when collision detection is on, use <viewpoint>.gravity(0). You can also set gravity to something else unearthly by dropping a value other than 9.8 in <viewpoint>.gravity().  

#Start collision detection.
viz.MainView.collision( viz.ON )
#Get rid of gravity.
viz.MainView.gravity (0)

See also

In this section:

Viewpoint basics

Camera handlers

Moving and rotating a viewpoint

Viewpoint command table

Other sections:

Viewpoint and Window basics

Tutorial: Viewpoint control

Tutorial: Windows & views

Tutorial: Viewpoint collision

Example scripts:

Viewpoint camera control

Viewpoint animation

Viewpoint collision

Window views