Digital Art Zone

 
     
Discriminate over different types of DzNode
Posted: 28 October 2012 03:58 AM   [ Ignore ]
Member
Avatar
Rank
Total Posts:  124
Joined  2007-09-12

Hello,
work on my thesis finally produced some… wrong results unfortunately.

I have actually worked with DzSkeleton in my Bullet world (I cannot explain much more since the library I am working on is not available to the public now) but I actually need to work with all the other subclasses of DzNode, in particular everything that has a geometry.

How can I discriminate towards these classes? Since if I use DzNode class i get, other than DzSkeleton’s geometry, even the geometry of every child (DzBone).

So checking if DzNode has geometry is not an option.

I have read of QtObject metatype system but I am not sure on how to use it.

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 28 October 2012 06:47 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15803
Joined  2003-10-09

You should check the inheritance and className of the node - but I think you are asking about the C++ SDK, not scripting, in which case this needs to be moved.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 28 October 2012 09:45 AM   [ Ignore ]   [ # 2 ]
Member
Avatar
Rank
Total Posts:  124
Joined  2007-09-12

Yes. I was asking about the C++ SDK. Sorry for the wrong post. So should I use the ->className() in qt? does it return DzSkeleton if i pass a DzNode to it?

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 28 October 2012 02:23 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15803
Joined  2003-10-09

Moved to the SDK forum.

I know only scripting, but if the item is a DzSkeleton then classFactory().className() will return that - as long as it’s supported (check it inherits DzBase)  - if I understand the DS3 docs I just looked at. (In script classname is directly available in the base class).

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 28 October 2012 02:52 PM   [ Ignore ]   [ # 4 ]
Member
Avatar
Rank
Total Posts:  124
Joined  2007-09-12

I am going to try something… Thank for your help. I will post something when I discover it.

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 28 October 2012 03:49 PM   [ Ignore ]   [ # 5 ]
New Member
Total Posts:  3
Joined  2011-02-12

If you want to know if a node inherits DzSkeleton, you can do this:

if(node->inherits("DzSkeleton")) {

But, I wouldn’t do this for the 4.5 SDK.  I would instead check for DzFigure:

if(node->inherits("DzFigure")) {


As the figure contains the skeleton, this is what you probably want to use.

I don’t think skeletons can exist without a figure in the 4.5 SDK.
The SDK does it best to prevent you from allocating an instance of some classes.

I was able to do it with the 3.x SDK, but not anymore.

Profile
 
 
Posted: 28 October 2012 04:53 PM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15803
Joined  2003-10-09

There are now two types of figure and they are both sub-classes of DzSkeleton - DzFigure is a TriAx figure, DzLegacyFigure is what would have been a DzSkeleton in DS3.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 29 October 2012 04:09 AM   [ Ignore ]   [ # 7 ]
Member
Avatar
Rank
Total Posts:  124
Joined  2007-09-12

But whi can’t it work using DzSkeleton? Isn’t it a class which is inherited by DzFigure and DzLegacyFigure?

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 30 October 2012 09:55 AM   [ Ignore ]   [ # 8 ]
New Member
Total Posts:  3
Joined  2011-02-12
gravity0 - 29 October 2012 04:09 AM

But whi can’t it work using DzSkeleton? Isn’t it a class which is inherited by DzFigure and DzLegacyFigure?

You can search for DzSkeleton in nodes if you want.  What I’m saying is you can also search for DzFigure instead,
and cast that to a skeleton.  This is because skeletons don’t seem to exist by themselves.
DzFigure also contains access to other useful data, like the skin and bone binding, weights, etc…

Profile
 
 
Posted: 30 October 2012 10:10 AM   [ Ignore ]   [ # 9 ]
Member
Avatar
Rank
Total Posts:  124
Joined  2007-09-12

For what I need right now (retrieving node’s geometry) checking for !DzBone (to prevent from adding both skeleton geometry and bones geometry twice) seems to be my case. Testing ASAP. wink

 Signature 

Favourite Figure: Olympia 6
My website: http://mattiascibien.net
My Art Gallery: http://mattiascibien.deviantart.com/
Developer of AutoCam (commercial follow-up of my thesis project, currently on hold).

Profile
 
 
Posted: 30 October 2012 02:14 PM   [ Ignore ]   [ # 10 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  15803
Joined  2003-10-09
coredevel - 30 October 2012 09:55 AM
gravity0 - 29 October 2012 04:09 AM

But whi can’t it work using DzSkeleton? Isn’t it a class which is inherited by DzFigure and DzLegacyFigure?

You can search for DzSkeleton in nodes if you want.  What I’m saying is you can also search for DzFigure instead,
and cast that to a skeleton.  This is because skeletons don’t seem to exist by themselves.
DzFigure also contains access to other useful data, like the skin and bone binding, weights, etc…

At the (considerable) risk of misusing terminology I thin DzSkeleton is a virtual class - you can’t create members, but you can create members of it’s derivatives (DzFigure and DzLegacyFigure). You should, however, use DzSkeleton as an inheritance check if you are in a situation where either derivative type would be relevant.

 Signature 

DAZ Studio Frequently Asked Questions

Index of free DAZ Studio scripts and plugins list

Profile
 
 
Posted: 30 October 2012 09:09 PM   [ Ignore ]   [ # 11 ]
Administrator
Avatar
RankRank
Total Posts:  373
Joined  2003-10-09

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

 Signature 

- Documentation Center
- Install Manager
- DAZ Studio 4.x
- DSON Importer
- DSON File Format Specification

Profile