Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

GL scene graph API

Introduction

The GL scene graph is the view of the X3D scene graph specialized in rendering. The structure of the scene graph is slighlty different from the X3D scene graph, At that moment this structure renders only static 3D objets, and the main node is X3DTK::X3D::IndexedFaceSet.

We present here the common interfaces X3DTK::GL::X3DNode of all the node types of the X3D scene graph, and X3DTK::GL::X3DGeometryNode of all the geometric drawable nodes. Notice that X3DTK::GL::X3DNode inherits X3DTK::X3DAbstractNode.

Special content

X3DTK::GL::X3DNode interface

Three methods are added to the X3DTK::X3DAbstractNode interface. setX3DReference and getX3DReference define the link with the related X3D node. The update method is used to update the attributes of the node. Here is an example:
namespace X3DTK { namespace GL { void Box::update() { if (getX3DReference() == 0) return; X3D::Box *B = static_cast<X3D::Box *>(getX3DReference()); _size = B->getSize(); _boxArray = BoxDrawArray::getInstance(); } } }

X3DTK::GL::X3DNode interface

A draw method is added to the X3DTK::GL::X3DNode interface. An example:
namespace X3DTK { namespace GL { void Box::draw() const { glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glCullFace(GL_BACK); glPushMatrix(); glScalef(_size.x, _size.y, _size.z); glInterleavedArrays(GL_N3F_V3F, 0, _boxArray->getBoxVertexArrayAddress()); glDrawElements(GL_TRIANGLES, _boxArray->getBoxSize(), GL_UNSIGNED_INT, _boxArray->getBoxIndexArrayAddress()); glPopMatrix(); glDisable(GL_CULL_FACE); } } }

How to use it

The GL scene graph is designed to be integrated in a viewer, because of the optimized version of the GL nodes, the interface is not easy to use. It is commonly used in the X3DTK::GL::Renderer processor. Check the animation example for animating a model.

In the future, this scene graph will be modified in order to offer a better interface for the development of an X3D browser.


Generated on Thu Jun 3 10:12:13 2004 for X3DToolKit by doxygen 1.3.6