spacer spacer
Index   Page down
spacer
spacer spacer
Introduction  
Page up Page down

In VRML we have a node ViewPoint allowing to declare a view point in a 3D scene. Its effect is like placing a virtual camera at a specified point in the scene, described by its coordinates in the 3D space and giving the direction and the field angle of the desired view. The definition of the node is:


Viewpoint{
  eventIn      SFBool     set_bind
  exposedField SFFloat    fieldOfView 0.785398
  exposedField SFBool     jump        TRUE
  exposedField SFRotation orientation 0 0 1 0
  exposedField SFVec3f    position    0 0 1 0
  field        SFString   description ""
  eventOut     SFTime     bindTime
  eventOut     SFBool     isBound
}

The use of this node as defined will nevertheless make appear a snag due to the way the view direction is expressed: a rotation around an axis vector. Trying to set it intuitively leads to unsatisfactory views. Here after the result after five attempts to set a view point for an object placed at the origin of the coordinate system:


Viewpoint {
	orientation 1 0.4 0.4 -0.6
	position -1 2 4
	description
		"view point with orientation 4"
}
 

brass object

From the mathematical point of view the way of representing the view point is quite efficient but is impractical for immediate use since it requires some vectorial geometry computation in order to yield suitable results, as is generally mediated by the drawing software. These practical shortcomings inspired the author to devise a prototype node (PROTO) RelativeViewpoint which is easier to use and leads more rapidly to a useful result.

spacer spacer
How it works  
Page up Page down

The interface of the the PROTO RelativeViewpoint.wrl is as follows:


PROTO RelativeViewpoint[
  eventIn      SFBool   set_bind
  field        SFVec3f  viewedPoint  0 0 0
  field        SFVec3f  gravity      0 -1 0
  exposedField SFFloat  fieldOfView  0.785398
  exposedField SFBool   jump         TRUE
  exposedField SFVec3f  position     0 0 10
  field        SFString description
                        "relative viewpoint"
  eventOut     SFTime   bindTime
  eventOut     SFBool   isBound
]

As you immediately will notice it is quite similar to the standard Viewpoint node but with two additional fields:

gravity
Our way of looking at the surrounding world is fundamentally determined by the gravitational force. It tells us what is up and what is down and determines the horizon line however we may turn our head. This vector is used in the computation of the orientation vector so as to obtain a proper horizon in the view.
viewedPoint
The viewed point determines the direction from the position point and should not coincide with it. This point will always lay at the center of the view!

The node declaration


RelativeViewpoint {
	position 1 2 4
	viewedPoint 0 0 0
	description
		"relative view point toward origin"
}
 

leads to the following view:

brass object

By clicking on the image you can view a test example ( test_RelativeViewpoint.wrl) provided you have installed a VRML renderer in your browser. The example has been tested with the Cortona VRML Client.

If you play a little around with this PROTO you will quickly realise how comfortable and intuitive it can be to set fine view points in your 3D scenes.

Louis JEAN-RICHARD

December 2004

spacer spacer
References   Page up
  1. VRML
  2. RelativeViewpoint.wrl
  3. test_RelativeViewpoint.wrl
  4. Cortona VRML Client
  5. Web3D Consortium - Home Page