It is currently Sat Aug 22, 2020 4:12 am


All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Loading .Volume
PostPosted: Fri Oct 15, 2010 6:40 am 

Joined: Fri Oct 15, 2010 6:10 am
Posts: 3
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


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Loading .Volume
PostPosted: Fri Oct 15, 2010 8:21 pm 

Joined: Fri Oct 15, 2010 6:10 am
Posts: 3
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Loading .Volume
PostPosted: Sat Oct 16, 2010 2:50 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Loading .Volume
PostPosted: Sun Oct 17, 2010 4:16 am 

Joined: Fri Oct 15, 2010 6:10 am
Posts: 3
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);




Top
Offline Profile  
Reply with quote  
 Post subject: Re: Loading .Volume
PostPosted: Sun Oct 17, 2010 3:03 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net