//image
osg::Image* image = new osg::Image;
image->allocateImage(_S, _T, _R, GL_RGBA, GL_FLOAT);
for(int s = 0; s < image->s(); s++)
{
for(int t = 0; t < image->t(); t++)
{
for(int r = 0; r < image->r(); r++)
{
float*_data = (float*)(image->data(s, t, r));
_data[0] = 0.0f;
_data[1] = 0.0f;
_data[2] = 1.0f;
_data[3] = 0.1f;
}
}
}
float image_s = (float)(image->s());
float image_t = (float)(image->t())/10.0f;
float image_r = (float)(image->r());
osg::ref_ptr<osg::RefMatrix> matrix = new osg::RefMatrix();
osgVolume::Locator* locator = new osgVolume::Locator(*matrix.get());
locator->setTransformAsExtents(0.0f, 0.0f, image_s, image_t, 0.0f, image_r);
osgVolume::Layer* layer = new osgVolume::ImageLayer(image);
layer->setLocator(locator);
osgVolume::VolumeTile* tile = new osgVolume::VolumeTile;
tile->setLocator(locator);
tile->setLayer(layer);
tile->setEventCallback(new osgVolume::PropertyAdjustmentCallback());
hss::ShaderModel shaderModel = hss::StanderdShaderModel;
hss::ShaderTechnique shaderTechnique = hss::RayTracedShaderTechnique;
float alphaFunc=0.001;
switch (shaderTechnique)
{
case (hss::RayTracedShaderTechnique):
{
osgVolume::SwitchProperty* sp = new osgVolume::SwitchProperty;
sp->setActiveProperty(0);
osgVolume::AlphaFuncProperty* ap = new osgVolume::AlphaFuncProperty(alphaFunc);
osgVolume::SampleDensityProperty* sd = new osgVolume::SampleDensityProperty(0.005);
osgVolume::TransparencyProperty* tp = new osgVolume::TransparencyProperty(1.0);
osgVolume::TransferFunctionProperty* tfp = 0;
{
// Standard
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
cp->addProperty(ap);
cp->addProperty(sd);
cp->addProperty(tp);
if (tfp) cp->addProperty(tfp);
sp->addProperty(cp);
}
{
// Light
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
cp->addProperty(ap);
cp->addProperty(sd);
cp->addProperty(tp);
cp->addProperty(new osgVolume::LightingProperty);
if (tfp) cp->addProperty(tfp);
sp->addProperty(cp);
}
{
// IsoSurface
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
cp->addProperty(sd);
cp->addProperty(tp);
cp->addProperty(new osgVolume::IsoSurfaceProperty(alphaFunc));
if (tfp) cp->addProperty(tfp);
sp->addProperty(cp);
}
{
// MaximumIntensityProjection
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
cp->addProperty(ap);
cp->addProperty(sd);
cp->addProperty(tp);
cp->addProperty(new osgVolume::MaximumIntensityProjectionProperty);
if (tfp) cp->addProperty(tfp);
sp->addProperty(cp);
}
switch(shaderModel)
{
case(hss::StanderdShaderModel): sp->setActiveProperty(0); break;
case(hss::LightShaderModel): sp->setActiveProperty(1); break;
case(hss::IsosurfaceShaderModel): sp->setActiveProperty(2); break;
case(hss::MaximumIntensityProjectionShaderModel): sp->setActiveProperty(3); break;
}
layer->addProperty(sp);
tile->setVolumeTechnique(new osgVolume::RayTracedTechnique);
}
break;
default:
{
layer->addProperty(new osgVolume::AlphaFuncProperty(alphaFunc));
tile->setVolumeTechnique(new osgVolume::FixedFunctionTechnique);
}
}
//volume
osgVolume::Volume* volume = new osgVolume::Volume;
volume->addChild(tile);
osg::Group* rootBox = new osg::Group;
rootBox->addChild(volume);
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
You received this message because you are subscribed to a topic in the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/osg-users/wkva7tXcbLk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to osg-users+...@googlegroups.com.
To post to this group, send email to osg-...@googlegroups.com.
Visit this group at http://groups.google.com/group/osg-users.
For more options, visit https://groups.google.com/groups/opt_out.