Hi,
quite recently I fixed a bug where changing a material of a geometry
recreated the geometry display list and this is quite slow for large
geometries. Can you try it with a current cvs version?
Another way is to create a ChunkMaterial with a TextureChunk and just
add/sub the TextureChunk.
Andreas
Hi all,
I'm working on a 3D project which uses OpenSG, and I'd like to know if
there is an efficient way of adding and removing materials (in fact I'm
using SimpleTexturedMaterial) in a way such that a texture can be
toggled on or off.
The 3D data is reconstructed from 2D images and I want to toggle a
texture on a model so its possible to view the 3D data with the
overlayed image or without so its possible to visualise the quality of
the reconstruction. Currently I'm doing the following:
void OpenSGWidget::removeTexture(NodePtr &node)
{
GeometryPtr geo(GeometryPtr::dcast(node->getCore()));
if (geo == NullFC)
return;
MaterialPtr mat = geo->getMaterial();
if (mat != NullFC &&
mat->getType().isDerivedFrom(SimpleTexturedMaterial::getClassType()))
{
material_ = SimpleTexturedMaterialPtr::dcast(geo->getMaterial());
addRefCP(material_);
SimpleMaterialPtr simplemat = SimpleMaterial::create();
beginEditCP(simplemat);
simplemat->setDiffuse(Color3f(.9,.9,.9));
endEditCP(simplemat);
beginEditCP(geo, Geometry::MaterialFieldMask);
geo->setMaterial(simplemat);
endEditCP(geo, Geometry::MaterialFieldMask);
}
}
void OpenSGWidget::addTexture(NodePtr &node)
{
GeometryPtr geo(GeometryPtr::dcast(node->getCore()));
if (geo == NullFC)
return;
if (material_ != NullFC)
{
SimpleMaterialPtr simplemat =
SimpleMaterialPtr::dcast(geo->getMaterial());
beginEditCP(geo, Geometry::MaterialFieldMask);
geo->setMaterial(material_);
endEditCP(geo, Geometry::MaterialFieldMask);
if (simplemat != NullFC)
subRefCP(simplemat);
subRefCP(material_);
material_ = NullFC;
}
}
OpenSGWidget is a QT widget, material_ is a local field that stores a
pointer to the SimpleTexturedMaterial object.
The problem with this approach is that for large models, it is extremely
slow and can take between 5 and 20 seconds to re-render. The delay
occurs in the following function:
void OpenSGWidget::paintGL()
{
mgr_->redraw();
}
mgr_ here is a SimpleSceneManagerPtr.
Is there a way to efficiently toggle a texture in this way?
Thanks in advance,
Glyn Matthews
------------------------------------------------------------------------
How much free photo storage do you get? Store your holiday snaps for
FREE with Yahoo! Photos. *Get Yahoo! Photos*
<http://us.rd.yahoo.com/mail/uk/taglines/default/photos/*http://uk.photos.yahoo.com/>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users