Hi,
Björn Harmen Gerth wrote:
Hello,
okay, I have the feeling my question is not quite new.
In case there has already been a thread in this
mailing list covering the topic, please send me simply
the subject of that thread.
How about using multiple materials in one NodeCore? Is
there a reason against it?
Currently I have an object which has to be drawn with
several materials. For each material, I'm building a
NodeCore derived from MaterialDrawable, which keeps a
list of the faces of my object to be drawn using that
material.
If I understand it correctly, you do not want to get into some
Multi-Pass issues,
where you have one material for each pass.
It is just to have a single scenegraph node instead of several.
It would be much simpler to just have one NodeCore
with my object and a list of materials.
Is it possible to do something like this (altered from
OSGMaterialDrawable.cpp):
Action::ResultE MyNodeCore::renderActionHandler(Action
*action)
{
RenderAction *a = dynamic_cast<RenderAction
*>(action);
Material::DrawFunctor func;
func = osgTypedMethodFunctor1ObjPtr(this,
MyNodeCore::drawPrimitives);
for(<< each mat in getMFMaterials() >>)
a->dropFunctor(func, mat.getCPtr());
return Action::Continue;
}
Action::ResultE MyNodeCore::drawPrimitives(Action
*action)
{
RenderAction *a = dynamic_cast<RenderAction
*>(action);
Material *m=a->getMaterial();
myObject.drawFacesOfThisMaterial(m);
}
This could work, nearly!
The only problem is finding the material in the drawPrimitives functor.
I have serious doubts that
a->getMaterial() will work in the draw functor.
There is a member RenderAction::_pActiveState which could give you some
information about
the currently active material, but not directly...
I am not sure if that is sufficient.
Regards,
Christoph
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users