"white_dune" is a continuation of the "dune" project by Stephan F. White.
"dune" is a graphical VRML97 Editor and animation tool with some OpenGL
scene rendering capabilities.
In princple, the structure of the white_dune program can be written as:
The GUI of white_dune consists of 2 parts:
The 2D GUI mainloop of white_dune is event driven. Typical events are
mouse-movement, mouse-click, resize of window and so on.
Additionally the mainloop can produce timer events.
When a event occures, the matching callback function is started.
The callbacks work for every subwindow of white_dune.
The following image shows the subwindows (red text) of the mainwindow.
The name of classes is identical to the filenames.
A additional callback OnUpdate is used to distribute
messages like UPDATE_FIELD or UPDATE_ADD_NODE to the
child classes of SceneView. OnUpdate is started by
the function UpdateViews of class Scene.
The class Scene (Scene.h/cpp) can be identified with one VRML file. For example Scene.write() writes the VRML file to disk.
The global variable TheApp of class DuneApp (DuneApp.h/cpp) can be identified with things that are global to all VRML files.
The internals of each VRML Nodes are implemented in the files named NodeNodeName (for example NodeTransform (NodeTransform.h/cpp), NodeShape (NodeShape.h/cpp) or NodeBox (NodeBox.h/cpp)).
Every NodeNodeName.h file contain 2 classes: the
class NodeNodeName which contain functionality
like draw() for 3D rendering of shapes and the class
ProtoNodeName which are used to build the definitions
of the VRML97 standard.
For example, the definiton of the Transform Node in
the ISO/IEC 14772 standard
is implemented in the constructor of the class ProtoTransform
(in file NodeTransform.cpp):
ProtoTransform::ProtoTransform(Scene *scene) : Proto(scene, "Transform") { addEventIn(MFNODE, "addChildren"); addEventIn(MFNODE, "removeChildren"); addExposedField(SFVEC3F, "center", new SFVec3f(0.0f, 0.0f, 0.0f)); addExposedField(MFNODE, "children", new MFNode(), NODE_CHILD); addExposedField(SFROTATION, "rotation", new SFRotation(0.0f, 0.0f, 1.0f, 0.0f)); addExposedField(SFVEC3F, "scale", new SFVec3f(1.0f, 1.0f, 1.0f), new SFFloat(0.0f)); addExposedField(SFROTATION, "scaleOrientation", new SFRotation(0.0f, 0.0f, 1.0f, 0.0f)); addExposedField(SFVEC3F, "translation", new SFVec3f(0.0f, 0.0f, 0.0f)); addField(SFVEC3F, "bboxCenter", new SFVec3f(0, 0, 0)); addField(SFVEC3F, "bboxSize", new SFVec3f(-1, -1, -1), new SFFloat(-1.0f)); }
Functionality common to all Nodes (like writing a Node to a file (Node.write())
is in the class Node (file Node.h/cpp). All NodeNodeName classes are
subclasses of the class Node.
Some of the memberfunctions of the class Node are virtual and can be
overwritten by the NodeNodeName classes (for example, the
class NodeScript need a special version of Node.write()).
Dune need to read and parse ("understand") VRML97 files.
This is done with using the tools lex/yacc (it looks like, the advanced
tools flex and bison from the GNU project are needed).
The file lexer.l do the lexical analysis (detect things like "what is
a string", "what is a number", "what is that VRML97 keyword").
The file parser.y do the grammatical analysis (detect and prove, if the
tokens found by the lexical analysis form valid VRML contructions
(like Node or ROUTE statements).
If doxygen
is installed, a class hierarchy of white_dune can be produced by typing
make documentationand can then be found here.