hi, this is my first post on this forum, I found polyvox after some research about voxel . I m very glad to use it and i started to do a little addon for OpenFrameworks :
http://www.openframeworks.cc/. I was able to implement the little example into OpenFrameworks, just to see how to works with it.
Now one of the first functionality that i would like to add to the addon is the function to load .Raw files. i found :
Quote:
polyvox_shared_ptr< VolumeType< VoxelType > > PolyVox::loadVolumeRaw ( std::istream & stream,
VolumeSerializationProgressListener * progressListener = 0
)
but i m a bit confused on how to use it... you can see here what i tried to do:
Quote:
void loadraw(const char *filename){
int width = 256;
int height = 256;
int depth = 256;
//Create a volume
LargeVolume<MaterialDensityPair44> volData(&load, &unload, 256);
FILE *fp = fopen(filename, "rb");
if (!fp){
std::cout<<"raw file missed! "<<"\n";
return 0;
}
float *data = new float [width*height*depth];
fread(data, sizeof(float), width*height*depth, fp);
fclose(fp);
//Clear volume to zeros.
//FIXME - Add function to PolyVox for this.
for(unsigned int z = 0; z < volData.getDepth(); ++z)
{
for(unsigned int y = 0; y < volData.getHeight(); ++y)
{
for(unsigned int x = 0; x < volData.getWidth(); ++x)
{
float voxelVal;
MaterialDensityPair44 voxel;
if(voxelVal > 0.0f)
{
voxel.setDensity(MaterialDensityPair44::getMaxDensity());
voxel.setMaterial(1);
}
else
{
voxel.setDensity(MaterialDensityPair44::getMinDensity());
voxel.setMaterial(0);
}
volData.setVoxelAt(x,y,z,voxel);
}
}
cout << z << endl;
}
SimpleVolume<MaterialDensityPair88> Volume(const PolyVox::Region& reg);
//polyvox_shared_ptr< VolumeType > volume(new LargeVolume<VolumeType::VoxelType>(width, height, depth));
//polyvox_shared_ptr< volData > loadVolumeRaw(fp);
polyvox_shared_ptr< Volume > loadVolumeRaw(fp);
//loadVolumeRaw(fp);
}
please, could someone explain how to use loadVolumeRaw? maybe with a little piece of code?
and also wich .raw files can i'use? 32 bit or 16 bit?
Thanks
Walter