Game Development Reference
In-Depth Information
pCompound->getChildTransform(i);
btScalar thisMatrix[16];
thisTransform.getOpenGLMatrix(thisMatrix);
// call drawshape recursively for each
child. The matrix
// stack takes care of positioning/
orienting the object for us
DrawShape(thisMatrix,
pCompound->getChildShape(i), color);
}
break;
}
If the purpose of the matrix stack wasn't clear earlier, then the preceding exercise
might help. When the two weights of the dumbbell are drawn, it might appear that the
only transform information given are the positions at ( -1.75,0,0 ) or ( 1.75,0,0 ),
and yet it doesn't always render at those exact world space coordinates.
In reality, it renders at the above location relative to the parent object. But why? This
powerful mechanism is achieved by adding the child's transformation matrix to the
stack (with another call to glPushMatrix() ) rendering the child, removing its trans-
form from the stack (with another call to glPopMatrix() ), and repeating for the
next child. Thus, wherever the parent's transform begins, the matrix stack ensures
that the children are always drawn relative to that starting location.
Our application now features our new dumbbell object:
Search WWH ::




Custom Search