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.
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(); } } }
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); } } }
In the future, this scene graph will be modified in order to offer a better interface for the development of an X3D browser.