On 4/03/11 23:51 , Sajjadul Islam wrote:
> Thanks for the hint. I should have explained a little more.
> I am calculating a distance map and want to store it in the 3D texture for
> pixel processing.
>
> Which function should i used inside Texture3D to store the 3D data.
No function inside osg::Texture3D, you modify the osg::Image data and it gets
uploaded
into the 3D texture.
You can allocate a 3D osg::Image using
osg::Image::allocateImage(width, height, depth, pixelFormat, type);
where pixelFormat=GL_RED and type=GL_UNSIGNED_SHORT (based on your OpenGL call).
This allocates the pixel data and you can then get the pointer to the raw data
using
unsigned short* imageData = (unsigned short*) osg::Image::data();
As mentioned, there is no direct access using a 3D coordinate, but you can do
that
yourself based on the raw image data pointer:
void writeToImage(osg::Image* image, int x, int y, int z, unsigned short value)
{
unsigned short* imageData = (unsigned short*) image->data();
unsigned short* pixelData = imageData + (z * width * height) + (y * width)
+ x;
*pixelData = value;
}
After that, mark your image as dirty by calling osg::Image::dirty() and it will
be
uploaded to it's associated texture.
Hope this helps,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org