It is currently Sat Aug 22, 2020 3:52 am


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How polyvox manages streams of vertices?
PostPosted: Sun Nov 04, 2012 6:21 pm 

Joined: Mon Oct 15, 2012 4:33 pm
Posts: 52
the subject of the post is self explanatory but i need to know this because I want to implement a method to create an object ofMesh (a class to create mesh in openFrameworks). It got to the point that the mesh is created, but what I get (it should be a sphere) is completely different, are obviously misinterpreted the vertices.
So if I get the vertices from a mesh in polyvox how they are treated?
Quote:
VertexX1, VertexY1, VertexZ1, NormalX1, NormalY1, NormalZ10, Material1, ....?

or what?

Thanks
Walter


Top
Offline Profile  
Reply with quote  
 Post subject: Re: How polyvox manages streams of vertices?
PostPosted: Mon Nov 05, 2012 9:23 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
The structure of the vertices is defined in VertexTypes.h. You're working with the MarchingCubesSurfaceExtractor so that uses the 'PositionMaterialNormal' type. You can see the definition here: http://www.gitorious.org/polyvox/polyvo ... s.h#line60

This does not nicely correspond to a GPU format. For example, a position is uaually a 4D vector with the fourth (w) component set 1.0. So you cannot just do a memory copy to bring the data from PolyVox into the GPU. Instead you need to write some conversion code to go between PolyVox's format and your own GPU format.

This is one area I would like to improve with fairly high priority, but not until after the next release.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: How polyvox manages streams of vertices?
PostPosted: Tue Nov 06, 2012 4:23 pm 

Joined: Mon Oct 15, 2012 4:33 pm
Posts: 52
i have made some progress in the development but it's not totally solved. It help me a lot, even if it is is not mantained anymore this : https://www.gitorious.org/thermite3d/th ... erable.cpp

and of course the tips that you gave me.

Quote:
his is one area I would like to improve with fairly high priority, but not until after the next release.


good to know!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: How polyvox manages streams of vertices?
PostPosted: Tue Nov 06, 2012 10:41 pm 

Joined: Mon Oct 15, 2012 4:33 pm
Posts: 52
i was able to solve it and to have my first ofMesh although without normals ! :D
This is a little piece of code which describe how to output an polyvox mesh to an ofMesh:
Code:
void ofxPolyvox::polyvoxToOfMesh(const PolyVox::SurfaceMesh<PositionMaterialNormal>& surfaceMesh, ofMesh& polyvxToOfMesh){

    //Convienient access to the vertices and indices
   const vector<uint32_t>& vecIndices = surfaceMesh.getIndices();
   const vector<PositionMaterialNormal>& vecVertices = surfaceMesh.getVertices();//surfaceMesh.getRawVertexData();

   ofIndexType ofVecIndices;
   const void* pIndices = static_cast<const void*>(&(vecIndices[0]));

   int* indices = (int*)pIndices;

    vector<int> indx;


     for (int i = 0; i < surfaceMesh.getNoOfIndices(); i++ ){

     indx.push_back(indices[i]);
     //cout << "indices:" << indices[i] << endl;
    polyvxToOfMesh.addIndex(indx[i]);
     }


    ofVec3f ofVecVertices;

    //vector <ofVec3f> points;
     for (int i = 0; i < surfaceMesh.getNoOfVertices(); i++ ){


    PositionMaterialNormal vert0 = vecVertices[i];


    ofVecVertices = ofVec3f(vert0.getPosition().getX(),vert0.getPosition().getY(),vert0.getPosition().getZ());

    polyvxToOfMesh.addVertex(ofVecVertices);

    }


}


This is super becuase now i can manipulate the mesh with all the OpenFrameworks addons and utilities. I have to add a lot of features but i believe that this is one of the most important. For every one interested here is my github repo: https://github.com/kalwalt/ofxPolyvox
Thanks for this great lib!


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

All times are UTC


Who is online

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