VVE provides a complete environment to create a model.
Each model consist in a single dynamically loaded library describing the model and being loaded at run time. This allows for quicker iteraction, as you don't need to rerun the program each time but more simply reload the library anytime a modification is made.
Once the model is created and compiled as a library, the VVE interpreter will take control of it to run and render it and allow a certain number of basic user interactions.
A VVE model consists in up to two classes:
To run a model, the VVE interpreter creates a Model object, a Viewer object and link them (i.e. the Viewer object knows about the Model object).
Each model begins with the inclusion of the main VVE header:
#include <vve.h>
Then, the user typically defines the main model class, inheriting the Model class.
class MyModel : public Model {
The constructor of the model has to accept a QObject
as argument and pass it to its base class. The constructor is also the place to initialize all the variables of the model.
For this trivial model, the only method that has to be provided is the Model::step method. It should describe the evolution of the model for one step.
void step() { // Compute the evolution of the model } };
At last, the user has to tell the system which class is to be used as model.
DEFINE_MODEL(MyModel);
All the methods that can be overridden to specify the model are documented in the Model class.
This minimal model is the do not have any rendering (which does not mean you cannot have any output, just not any OpenGL output in the VVE interpreter). This is, however, the minimum valid model.
To have a better feel about the structure of the model, let's create a Hello World model.
So the beginning includes the VVE main header, creates the class, its constructor and the (empty) step method.
#include <vve.h> class HelloWorldModel : public Model { HelloWorldModel(QObject *parent) : Model(parent) { } void step() { }
Now, let's look at the draw
method:
It uses the QGLViewer class, whose documentation can be found here: http://artis.imag.fr/Membres/Gilles.Debunne/QGLViewer/refManual/hierarchy.html
It simply draws the text "Hello World!" at coordinates (5,5) in the OpenGL screen.
At last, the usual ending:
}; DEFINE_MODEL(HelloWorldModel);