I haven’t compiled this… but if it doesn’t, it should be pretty close…
// Get the primary selection
DzNode *node = dzScene->getPrimarySelection();
// If we've got a node selected
if( node )
{
// If the node can be cast to a DzBone
if( qobject_cast<DzBone*>(node) )
{
// We want the skeleton node
node = node->getSkeleton();
}
// Get the object
DzObject *object = node->getObject();
// If we've got an object
if( object )
{
// Get the current shape
DzShape *shape = object->getCurrentShape();
// If we've got a shape
if( shape )
{
// Get the geometry
DzGeometry *geometry = shape->getGeometry();
}
}
// Else if we don't have an object
else
{
// Provide feedback
QMessageBox::warning(dzApp->getDialogParent(),
tr("Resource Error"), tr("The selected item has no object."), QMessageBox::Ok );
}
}
// Else if a node is not selected
else
{
// Provide feedback
QMessageBox::warning(dzApp->getDialogParent(),
tr("Selection Error"), tr("You must have a node in the scene selected."), QMessageBox::Ok );
}
If you want to limit which DzNode subclasses you get the object from, you can use something like…
// Declare and initialize a DzObject pointer that we'll check for later
DzObject *object = NULL;
// If the node can be cast to a [weight mapped] DzFigure
if( DzFigure *figure = qobject_cast<DzFigure*>(node) )
{
// Get the object
object = figure->getObject();
}
// Else if the node can be cast to a [parametric] DzLegacyFigure
else if( DzLegacyFigure *legacyFigure = qobject_cast<DzLegacyFigure*>(node) )
{
// Get the object
object = legacyFigure->getObject();
}
// Else if the node can be cast to a DzSkeleton
else if( DzSkeleton *skeleton = qobject_cast<DzSkeleton*>(node) )
{
// Get the object
object = skeleton->getObject();
}
... in place of…
// Get the object
DzObject *object = node->getObject();
-Rob