Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Loading .Volume
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=80
Page 1 of 1

Author:  bronzebeard [ Fri Oct 15, 2010 6:40 am ]
Post subject:  Loading .Volume

First off I like to thank you for your lib, and your support of it.


I'm assuming one can load voxel's from file? (.volume if I'm not mistaken)
I was wondering how one would implement it in ogre?

From what I can gather from Thermite,

You create a singleton volume manager, Which creates a VolumeResourcePtr and which is where you put the name of the volume you wish to load, correct?

If not, Do you have any simpler example code?


Thanks again :D

Author:  bronzebeard [ Fri Oct 15, 2010 8:21 pm ]
Post subject:  Re: Loading .Volume

As of right now I have,

Code:
   
   PolyVox::Volume<PolyVox::MaterialDensityPair44> volData(64, 64, 64);
   Ogre::DataStreamPtr streamfromogre = Ogre::ResourceGroupManager::getSingleton().openResource("EditorTest.volume","General");
   std::istream stream(new StreamConverter(streamfromogre));

   PolyVox::loadVolume<PolyVox::MaterialDensityPair44>(stream, volData);

      PolyVox::SurfaceMesh mesh;
         PolyVox::SurfaceExtractor<PolyVox::MaterialDensityPair44> surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
         surfaceExtractor.execute();


etc,

StreamConverter is the same class as your datastreamwrapper from ( http://www.ogre3d.org/forums/viewtopic. ... 52&start=0 ) however it seems to not convert the stream?

as Serialization.inl is returning false

Code:
   template <typename VoxelType>
   bool loadVolume(std::istream& stream, Volume<VoxelType>& volume, VolumeSerializationProgressListener* progressListener)
   {
      OgreFramework::getSingletonPtr()->m_pLog->logMessage("Loading Shit");
      char pIdentifier[8];
      stream.read(pIdentifier, 7);
      pIdentifier[7] = '\0'; //Set the null terminator
      if(strcmp(pIdentifier, "PolyVox") != 0)
      {
         OgreFramework::getSingletonPtr()->m_pLog->logMessage("sending false");
         return false;
      }




What am i screwing up?


**EDIT** Actually my bug seemed to be the .volume file i was using. Using castle.volume works fine.

Author:  David Williams [ Sat Oct 16, 2010 2:50 pm ]
Post subject:  Re: Loading .Volume

Hi, sorry for the slow reply but i'm away from my pc for a couple of days. But it sounds like you got it working? Note that there are at least three versions of the file format - the old RAW version, the old RLE (compressed) version, and the new RLE version which starts with bytes reading 'POLYVOX' (though i forget the case) and a version number. Thermite might contain a mix of volumes as I forget what i've converted.

Author:  bronzebeard [ Sun Oct 17, 2010 4:16 am ]
Post subject:  Re: Loading .Volume

David Williams wrote:
Hi, sorry for the slow reply but i'm away from my pc for a couple of days. But it sounds like you got it working? Note that there are at least three versions of the file format - the old RAW version, the old RLE (compressed) version, and the new RLE version which starts with bytes reading 'POLYVOX' (though i forget the case) and a version number. Thermite might contain a mix of volumes as I forget what i've converted.



:D Yea i've got that all sorted out, now i'm running into a problem of displaying textures on my manual object.

I've read through the "Polyvox and Ogre3d" thread you have on here and took your recommendation of using shaders for the textures.

So i'm trying out your SingleProjectedTextureFP code and it's not doing so well, keep getting a completely material.

I've also attempted my own, but with same results.

Anyhoo, i'm getting a completely solid black texture over the the object, any idea why?

Code:

   PolyVox::Volume<PolyVox::MaterialDensityPair44> volData(64, 64, 64);
   Ogre::DataStreamPtr streamfromogre = Ogre::ResourceGroupManager::getSingleton().openResource("desert.volume","General");
   std::istream stream(new StreamConverter(streamfromogre));

   
   PolyVox::loadVolume<PolyVox::MaterialDensityPair44>(stream, volData);


         PolyVox::SurfaceMesh mesh;
         PolyVox::SurfaceExtractor<PolyVox::MaterialDensityPair44> surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
         surfaceExtractor.execute();
         

         if ( VoxelLand != NULL ) {
            VoxelLandNode->detachObject(VoxelLand);
            m_pSceneMgr->destroyManualObject(VoxelLand);
         }
         VoxelLand = m_pSceneMgr->createManualObject("VoxelLand");

         uint32_t noVertices = mesh.getNoOfVertices();
         uint32_t noIndices = mesh.getNoOfIndices();

         VoxelLand->estimateVertexCount(noVertices);
         VoxelLand->estimateIndexCount(noIndices);

         VoxelLand->begin("DesertSurfaceMaterial", Ogre::RenderOperation::OT_TRIANGLE_LIST,"General");



             // vertices
         const std::vector<PolyVox::SurfaceVertex>& vVertices = mesh.getVertices();
         for (unsigned int i=0; i<noVertices; i++) {
            const PolyVox::Vector3DFloat& pos = vVertices[i].getPosition();
            VoxelLand->position(pos.getX(), pos.getY(), pos.getZ());
            const PolyVox::Vector3DFloat& normal = vVertices[i].getNormal();
            VoxelLand->normal(normal.getX(), normal.getY(), normal.getZ());
         
            
         }

         // indices
         const std::vector<uint32_t>& vIndices = mesh.getIndices();
         for (unsigned int i=0; i<noIndices; i++) {
            VoxelLand->index( vIndices[i] );
         }

         
         
         VoxelLand->end();
         

      

         if ( VoxelLandNode == NULL ) {
            VoxelLandNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode();
         }
         VoxelLandNode->attachObject(VoxelLand);
         VoxelLandNode->setPosition(0.0, 0.0, 0.0);



Author:  David Williams [ Sun Oct 17, 2010 3:03 pm ]
Post subject:  Re: Loading .Volume

Unfortunatly you probably can't just 'drop in' the materials from Thermite as they are specific to Thermite. Thermite does not just use the raw PolyVox mesh - it also duplicates some triangles, sets up some blending stuff, etc. In particular I think it uses two channels for the materialId, where the 'y' channel is an alpha value. Proabably this is set to black in your version, but there are probably other things you need to change. In general, you can use the Thermite shaders for ideas and concepts but you'll need to adapt them to your own system.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/