It is currently Tue Dec 10, 2019 12:01 am


All times are UTC




Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Tue Mar 29, 2011 4:59 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
Not to mention that the code was just an example, it wasn't intended to be compiled... you would be better to learn what it does and write your own function.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Tue Mar 29, 2011 5:20 am 

Joined: Sat Mar 26, 2011 6:41 pm
Posts: 8
Thanks both of you i can't belive i made such a beginer mistake thanks again


yes i guessed it wasen't ment to be compiled and is not even fully suited to be integrated in irrlicht so i modified it quite a bit but kept the structure (it's actualy 2 function now) so that i had to call it and just forgot to do so

my job has just been way to much takin i can barely get 3 hours of sleep a night


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Sun Sep 25, 2011 10:17 am 

Joined: Sun Sep 25, 2011 7:36 am
Posts: 13
In case someone else needs it, here is a full version of the convert function.

It took some time filling the missing parts (that *should* have been obvious), because in my version of Irrlicht (at least), the basic CMeshBuffer is limited to 16 bit indices (insufficient for the sphere demo), and CDynamicMeshBuffer::append was silently doing nothing.

Code:
irr::scene::IMeshBuffer* ChunkLoader::ConvertMesh(const PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>& mesh)
{
    const std::vector<uint32_t>& indices = mesh.getIndices();
    const std::vector<PolyVox::PositionMaterialNormal>& vertices = mesh.getVertices();

    irr::scene::IDynamicMeshBuffer *mb = new irr::scene::CDynamicMeshBuffer(irr::video::EVT_STANDARD, irr::video::EIT_32BIT);
    mb->getVertexBuffer().set_used(vertices.size());
    for (size_t i = 0; i < vertices.size(); ++i)
    {
        const PolyVox::Vector3DFloat& position = vertices[i].getPosition();
        const PolyVox::Vector3DFloat& normal = vertices[i].getNormal();
        mb->getVertexBuffer()[i].Pos.X = position.getX();
        mb->getVertexBuffer()[i].Pos.Y = position.getY();
        mb->getVertexBuffer()[i].Pos.Z = position.getZ();
        mb->getVertexBuffer()[i].Normal.X = normal.getX();
        mb->getVertexBuffer()[i].Normal.Y = normal.getY();
        mb->getVertexBuffer()[i].Normal.Z = normal.getZ();
        mb->getVertexBuffer()[i].Color = irr::video::SColor(255,0,200,200);
    }
    mb->getIndexBuffer().set_used(indices.size());
    for (size_t i = 0; i < indices.size(); ++i)
    {
        mb->getIndexBuffer().setValue(i, indices[i]);
    }
    mb->recalculateBoundingBox();
    return mb;
}


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Sun Sep 25, 2011 12:18 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Thanks for the code.
Gnurfos wrote:
... the basic CMeshBuffer is limited to 16 bit indices...

Yes, I found in my own project that the SurfaceExtractor will easily go past the 16-bit limit. If you can't move to 32-bit indices then your only option is to make you regions smaller, so that you generate smaller meshes but have more of them.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Wed Oct 26, 2011 6:04 pm 

Joined: Wed Oct 26, 2011 2:09 pm
Posts: 9
Hello, i wanted to try to integrate this into my Irrlicht project, so i took the basic example code (one with the sphere) and then this code example posted above. Problem is i don't get any result at all : / Anyone know what I'm doing wrong?

Code:
//Example code (sphere) ends here
SMesh* testMesh = new SMesh;
IMeshBuffer * testBuffer = ConvertMesh(mesh);
testMesh->addMeshBuffer(testBuffer);
testMesh->recalculateBoundingBox();
ISceneNode* testNode= irrScene->addMeshSceneNode(testMesh, 0, 0, vector3df(2000*2, 550*2, 2000*2),
                                       vector3df(0, 100, 0),vector3df(20.0F, 20.0F, 20.0F));


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Wed Oct 26, 2011 8:04 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Can you verify that you have a valid mesh before passing it to Irrlicht? Check that it has valid index and vertex data?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Thu Oct 27, 2011 7:57 am 

Joined: Wed Oct 26, 2011 2:09 pm
Posts: 9
Not exactly sure how to know the mesh is correct, but it seems to be ok.
Made a sphere with a radius of 10, and Vertices size is 7548 and Triangle size is 11322 and all other data seems to be valid.

Edit: It works now : ) When i made the volume smaller i forgot to make the radius smaller as well, so the sphere was larger than the volume = only empty space : p


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Tue Jul 31, 2012 3:34 pm 

Joined: Sun Jan 08, 2012 10:00 am
Posts: 31
Location: Germany
hey voxelfans,

thx to gnurfos!

if you like to use a texture for the voxels in irrlicht, you should add this lines in the vertices-for-loop:

Code:
if(fabsf(normal.getX())>fabsf(normal.getY()) && fabsf(normal.getX())>fabsf(normal.getZ())) {
   mb->getVertexBuffer()[i].TCoords.X = position.getY();
   mb->getVertexBuffer()[i].TCoords.Y = position.getZ();
} else if(fabsf(normal.getY())>fabsf(normal.getX()) && fabsf(normal.getY())>fabsf(normal.getZ())) {
   mb->getVertexBuffer()[i].TCoords.X = position.getX();
   mb->getVertexBuffer()[i].TCoords.Y = position.getZ();
} else {
   mb->getVertexBuffer()[i].TCoords.X = position.getX();
   mb->getVertexBuffer()[i].TCoords.Y = position.getY();
}


zprg ( homepage http://zenprogramming.tripod.com )


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Thu Jan 03, 2013 11:09 am 

Joined: Sat Mar 26, 2011 6:41 pm
Posts: 8
wow it's been a while since i have been here.

but i finaly got around finishing my polyvox/irrlicht integration and with the noise algo i already have the results are absolutely stuning.

how ever i was wondering if there is a quick way with polyvox to distinguish betwen isolated volumes that crosses the density treshold. Because my current noise algorythm generate a lots of small island and one big one and i would need to have the small island and the big one in diferent entities


Top
Offline Profile  
Reply with quote  
 Post subject: Re: polyvox integration to irrlicht
PostPosted: Thu Jan 03, 2013 8:08 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I'm not exactly clear what you mean... but in general it is expected that you will have one large volume rather than several seperate ones. Can you elaborate on you problem or why you need this? Also have a read of this: http://www.volumesoffun.com/polyvox/doc ... aller-ones


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 44 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 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