Next: Molecule objects
Up: Display objects
Previous: Matrix4
  Contents
Subsections
Scene
Files: |
Scene.h, Scene.C |
Derived from: |
\bf PickList |
Global instance (if any): |
scene |
Used in optional component: |
Part of main VMD code |
The Scene maintains and organizes a database with all the
Displayable objects which are to be drawn by a DisplayDevice. It
contains routines to add new Displayable's to its database, and to draw
them to the screen or to a file. It is derived from PickList, and so
maintains the information about what diffent picking modes are available, as
well routines to pick an item with a pointer.
There are two different sets of lists stored by the Scene, with each list
kept for both the 2D case and the 3D case. The lists are:
- Registered Displayable's; this list is used to prepare items to
be drawn. Only top-level Displayable objects are kept in this list.
When a Displayable is created, it registers itself with a Scene,
and so gets added to this list.
- Registered display lists, the lists of drawing tokens created by
Displayables. This list is used to actually draw the graphics, each
item in this list represents one display list and is given to a
DisplayDevice to be rendered.
This object also contains routines to apply a constant rotation to all
Displayable's each time they are drawn, as well as to apply general
transformations to all the items in the scene. The most important function of
Scene is, however, to draw the scene to a display or to a file.
- int numDisplayable2D, numDisplayable3D - the number of 2D and 3D
Displayable's which have registered. Derived classes maintain the
actual lists.
- int numCmdLists2D, numCmdLists3D - the number of 2D and 3D
display lists have been registered. Derived classes maintain the
actual lists.
- virtual void prepare(DisplayDevice *) - goes through all
the registered objects and prepares them for drawing. This should be called
before draw.
- virtual void draw(DisplayDevice *) - actually draws the scene,
using the given DisplayDevice. If this display is in stereo, this will
first draw the left eye view, then the right.
- virtual int filedraw(char *, char *, DisplayDevice *) - very
similar to draw, except this draws the scene to a file-based
DisplayDevice. The first two arguments are the format, and the
filename. The different formats and file-rendering objects are maintained by
a global instance of the object FileRenderList.
A Scene is created at the start of the program, and all Displayable
objects should be added to that scene (or to another Displayable as a
child). It is used in the primary event loop to prepare and draw all the
Displayable's. It is also used to pick items with a pointer. The global
routine VMDupdate contains an example of using a Scene object.
There are two derived classes from Scene:
- NormalScene - this is the basic version, which is used for every
case except when the CAVE display device is being used. It uses standard
memory allocation routines to create storage for display lists, and to store
the lists of Displayables and display lists.
- CaveScene - this uses shared memory to store the display lists,
so that the CAVE processes can all see the same data for rendering the scene.
As mentioned for Displayable, the prepare routine could be modified
to return a flag indicating whether anything has changed in the
Displayable objects which would require a redraw. If nothing changed,
then a redraw could be avoided.
Next: Molecule objects
Up: Display objects
Previous: Matrix4
  Contents
vmd@ks.uiuc.edu