Scene Graph Nodes | | CMake Example

Customized Geometry Nodes

In order to implement geometry nodes with special objects not covered by the basic geometry types (boxes, tetrahedra, prisms, spheres etc.) we derive from mininode_geom and override the following three virtual methods:

  • rendergeo: render geometric primitives
    • front facing triangles are specified counter-clock-wise
    • back facing triangles are culled
    • normals are specified to face outward
    • a head light shader is applied by default
    • inward facing normals are flipped when shaded
  • getbbox: provide information about the bounding box of the primitives
  • shoot: compute the intersection of a ray with the geometric primitives
    • by default the hit point is approximated by the intersection with the bounding sphere
    • if exact hit points are required, override the shoot method and provide exact calculations

See the mininode_teapot.cpp module as an example:

   : mininode_geom()

void mininode_geometry_teapot::rendergeo()





void mininode_geometry_teapot::getbbox(miniv3d &bboxmin,miniv3d &bboxmax) const

double mininode_geom::shoot(const miniv3d &o,const miniv3d &d,double mindist) const

We put the teapot at the place where it belongs to - the Utah Science and Imaging Institute (SCI):

mininode_ref teapot = new mininode_geometry_teapot;

minicoord utah;
utah.set_llh(40.767690,-111.845037); // utah science and imaging institute (sci)

group->append_child(new mininode_coord(utah))->
   append_child(new mininode_color(miniv3d(0.9, 0.9, 0.9)))->
   append_child(new mininode_scale(10000.0))->
   append_child(new mininode_translate(miniv3d(0.0, 0.0, 0.1)))->
   append_child(new mininode_rotate(90, miniv3d(1.0, 0.0, 0.0)))->

Scene Graph Nodes | | CMake Example