Thank you very much for helping.  Below is how we make the call.

This has been working fine until very recently we received scan data from some 
CBCT scanners that we haven't encountered before.  However those scans could be 
viewed correctly in all popular DICOM viewers in the market.  As mentioned, I 
also took the pixel data and dumped it into a .bmp file, which looks correct.  
So the only possibility seems to be that we are missing some setting here......

I did try changing the texture coordinates around but that doesn't change the 
twisted nature of the display.

I also tried changing `packing' from 1 to 0 but that crashes the software.

Is there anything in particular that one needs to set for `rowLength'?



        osg::Geode* pGeode = new osg::Geode;

        osg::Vec3 v1(pBottomLeft[0], pBottomLeft[1], pBottomLeft[2]);
        osg::Vec3 v2(pBottomRight[0], pBottomRight[1], pBottomRight[2]);
        osg::Vec3 v3(pTopRight[0], pTopRight[1], pTopRight[2]);
        osg::Vec3 v4(pTopLeft[0], pTopLeft[1], pTopLeft[2]);

        osg::Geometry* geom = new osg::Geometry;
        geom->setDataVariance(osg::Object::DYNAMIC);
        osg::Vec3Array* vertices = new osg::Vec3Array(4);
        (*vertices)[0] = v1;
        (*vertices)[1] = v2;
        (*vertices)[2] = v3;
        (*vertices)[3] = v4;
        geom->setVertexArray(vertices);

        osg::Vec2Array* texcoords = new osg::Vec2Array(4);
        (*texcoords)[0].set(0.0f, 0.0f);
        (*texcoords)[1].set(1, 0.0f);
        (*texcoords)[2].set(1, 1);
        (*texcoords)[3].set(0.0f, 1);

        geom->setTexCoordArray(0, texcoords);

        osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array(1);
        (*normals)[0].set(0.0f, -1.0f, 0.0f);
        geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
        osg::Vec4Array* colors = new osg::Vec4Array(1);
        (*colors)[0].set(1.0f, 1.0f, 1.0f, 1.0f);
        geom->setColorArray(colors, osg::Array::BIND_OVERALL);

        geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4));
        geom->setUseDisplayList(false);
        osg::ref_ptr<osg::Image> img = new osg::Image;

        img->setImage(image.GetWidth(), image.GetHeight(), 1,
                GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 
image.GetPixelData(),
                osg::Image::USE_NEW_DELETE);

        //osg::ref_ptr<osg::Image> img = 
osgDB::readRefImageFile("C:\\Users\\rupeshb\\Pictures\\error.bmp");

        //osg::ref_ptr<osg::Image> img = osgDB::readRefImageFile(filename);

        osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D(img);
        texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
        texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
        osg::ref_ptr<osg::TexMat> texmat = new osg::TexMat;
        texmat->setScaleByTextureRectangleSize(true);
        // setup state
        osg::ref_ptr<osg::StateSet> state = geom->getOrCreateStateSet();
        state->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON 
| osg::StateAttribute::PROTECTED);
        state->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON | 
osg::StateAttribute::PROTECTED);
        
        state->setMode(GL_LIGHTING, osg::StateAttribute::OFF); 

        pGeode->addDrawable(geom);
        addChild(pGeode);

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70254#70254





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to