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

How polyvox manages streams of vertices?
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=457
Page 1 of 1

Author:  kalwalt [ Sun Nov 04, 2012 6:21 pm ]
Post subject:  How polyvox manages streams of vertices?

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

Author:  David Williams [ Mon Nov 05, 2012 9:23 am ]
Post subject:  Re: How polyvox manages streams of vertices?

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.

Author:  kalwalt [ Tue Nov 06, 2012 4:23 pm ]
Post subject:  Re: How polyvox manages streams of vertices?

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!

Author:  kalwalt [ Tue Nov 06, 2012 10:41 pm ]
Post subject:  Re: How polyvox manages streams of vertices?

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!

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