MATLAB: Do objects close to the viewpoint not show up in the Virtual Reality Toolbox Viewer in the Virtual Reality Toolbox

Simulink 3D Animationvrealmvrml97zbuffer

I have created a virtual world which contains two objects, with a Viewpoint set on one of the objects. Normally, I am able to view the second object without any problems. However, when the two objects become sufficiently close to one another, the second object becomes clipped, and part of the object seems to disappear from the viewer screen.

Best Answer

The effect of clipping objects occurs as a result of the z-buffering used to display the virtual world. A z-buffer is used in 3-D graphics to store the z-coordinate of each object. This information is used when determining which objects are in front of other objects relative to the viewpoint. This ensures that objects will be displayed properly, since objects in front should be rendered while objects behind other objects should not.
The limitation of this method is that there is limited precision of the z-buffer. The viewer sets a range of z-coordinates (maximum and minimum) such that only objects in the virtual world that are within that range will be rendered. The size of this range determines how precise the z-buffer can be in distinguishing whether or not one object is closer than another. Choosing a range that is too large results in loss of z-buffer precision, while choosing a range that is too small limits your ability to see very distant or very close objects.
The NavigationInfo field of an object contains subfields which are used to determine the maximum and minimum z-coordinates used by the z-buffer. The minimum z-coordinate is determined by the first element of the avatarSize field, and the maximum z-coordinate is determined by the visibilityLimit field. The NavigationInfo node is not included by default in the wrl file so you will have to add one yourself if you are having trouble. In the VRealm Builder software you can add a NavigationInfo node by clicking on Nodes -> Insert -> Bindable -> NavigationInfo.