libjbt

jbt_build Class Reference

Handy BlobTree construction class. More...

#include <build.h>

List of all members.

Public Members


Detailed Description

Handy BlobTree construction class.

This class implements a stack construction paradigm for jbt_blobtree objects. To construct a BlobTree purely programatically using the constructors can be tedious, and it is difficult to change the structure without large changes to the code. This class allows you to write very simple intuitive code which is very readable.

As an example the following function generates the clasic IS peanut shape:

  jbt_blobtree* peanut( jFlt t, const jColour& a, const jColour& b )
  {
    jbt_build jbt;
    jbt.begin(new jbt_blend);
    {
      jbt.attribute(new jbt_diffuse(a);
      jbt.translate(0,t,0);
      jbt.primitive(new jbt_point);
      jbt.attribute(new jbt_diffuse(b));
      jbt.translate(0,-2*t,0);
      jbt.primitive(new jbt_point);
    }
    jbt.end(); 
    return jbt.blobtree();
  }


Member Function Documentation

jbt_build::jbt_build()

Construct a new construction stack.

virtual jbt_build::~jbt_build() [virtual]

jbt_blobtree* jbt_build::blobtree()

Returns the constructed BlobTree.

void jbt_build::translate( jFlt, jFlt, jFlt )

void jbt_build::scale( jFlt )

void jbt_build::scale( jFlt, jFlt, jFlt )

void jbt_build::rotate( int, jFlt )

void jbt_build::uvtranslate( jFlt, jFlt )

void jbt_build::uvscale( jFlt )

void jbt_build::uvscale( jFlt, jFlt )

void jbt_build::uvrotate( jFlt )

void jbt_build::coefficient( jFlt )

Sets the coefficient for the field functions of primitives.

void jbt_build::field( jbt_field* )

Sets the field function to be used for subsequent primitives, pass zero to clear it. If the previous field was not passed to any primitives it will be deleted.

void jbt_build::distance( jbt_distance* )

Sets the distance measure to be used for subsequent primitives, pass zero to clear it. If the previous distance was not passed to any primitives it will be deleted.

void jbt_build::push()

Pushes the stack. This causes the current attribute's, transformation's etc. to be pushed onto a stack for later restoration.

void jbt_build::pop()

Pops the stack. Restore the state of the construction from the previous push.

void jbt_build::attribute( jbt_attribute* )

Sets the attribute that should be used for the current branches of a tree. This attribute will be placed into the tree at the beginning of all nodes placed in the at this level. Therefore it is important to consider the nature of the tree that you are constructing, a poor construction can lead to a less efficient tree. This function is just a wrapper for changeState. Without this function you would have to allways call changeState(new jbt_attributenode(<attr>)); which is not just a small pain.

void jbt_build::primitive( jbt_primitive* )

Terminates the current branch. All leaf nodes of the BlobTree are jbt_primitive objects. If there was a call to jbt_build::begin() then the given primitive is added as a child to the jbt_compound object that was passed to jbt_build::begin(). If there was no call to jbt_build::begin() then the result of multiple calls to primitive is undefined.

void jbt_build::primitive( jbt_ngnode*, jbt_primitive* )

Terminates the current branch. All leaf nodes of the BlobTree are jbt_primitive objects. This primitive object is added as the child of the given non-geometric node. If there was a call to jbt_build::begin() then the given jbt_ngnode is added as a child to the jbt_compound object that was passed to jbt_build::begin(). If there was no call to jbt_build::begin() then the result of multiple calls to primitive is undefined.

void jbt_build::add( jbt_blobtree* )

Terminates the current branch. It is assumed that the given BlobTree is valid. Improper use of this function will result in undefined behaviour. Make sure that all BlobTree's added with this function are complete (ie, all leaf nodes are jbt_primitive objects). If there was a call to jbt_build::begin() then the given object is added as a child to the jbt_compound object that was passed to jbt_build::begin(). If there was no call to jbt_build::begin() then the result of multiple calls to add is undefined. If the current node at this hierarchy level is a non-geometric node, then the given BlobTree is set to its child (ignoring any existing children), and the given BlobTree is set to the current at this hierarchy.

void jbt_build::begin( jbt_compound* )

Starts a new n - ary node in the tree. The stack is pushed to save the state for siblings.

void jbt_build::end()

Terminates an n - ary node in the tree. The stack is popped to restore the state for siblings.

void jbt_build::changeState( jbt_ngnode* )

Change the general state. You can place any non-geometric node into the tree. The following sub-BlobTree will be affected by the new state. The uses of this function are to build warped or parameterized BlobTree's, or whatever may be added in the future.

bool jbt_build::valid() const

Returns true if the BlobTree was properly constructed. This means foremost that every call to jbt_build::begin() | jbt_build::push() was terminated with a jbt_build::end() | jbt_build::pop() call, and also that all leaf nodes are children.


The documentation for this class was generated from the following file:
JSP / libjbt v0.1 mtigges@cpsc.ucalgary.ca