Discriminate over different types of DzNode
mattiascibien
Posts: 140
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.
Comments
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.
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?
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).
I am going to try something... Thank for your help. I will post something when I discover it.
If you want to know if a node inherits DzSkeleton, you can do this:
But, I wouldn't do this for the 4.5 SDK. I would instead check for 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.
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.
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...
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. ;)
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.
I haven't compiled this... but if it doesn't, it should be pretty close...
If you want to limit which DzNode subclasses you get the object from, you can use something like...
... in place of...
-Rob