Announcement

Collapse
No announcement yet.

Suggestions to build a 3D shape from a 3D point (x, y, z) array and  a face array

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • vlagala@smrobotica.it
    replied
    Update: resolved using indexed triangle set...

    Leave a comment:


  • vlagala@smrobotica.it
    replied
    Dear Mike,
    thank You very much for Your fast response;

    answering to Your question,
    the pointList is an array of unique points in the model
    and faceList is an array of indexes into pointList that reprent the vertexes of triangles. The size of this array will always be 3 * nFaces..

    I was thinking to use SoTriangleStripSet, but i see only a cloud point and not a solid mesh.

    Regards,
    Vincenzo

    Leave a comment:


  • mikeheck
    replied
    Originally posted by [email protected] View Post
    Please can i do better (intended as optimized GPU 3D shape) , using faceList array, too?
    Hi Vincenzo,
    Assuming that your pointList contains 3 vertices for every triangle (what the pseudo-code implies), then this code should give good performance for this data.

    General comment: In theory, it is possible to get better performance using indexed geometry. Of course this is only possible if your triangles share vertices. For example, if the geometry is a triangle mesh (surface). When you specify 3 vertices for each triangle, every specified vertex must be transformed, lit, etc by the GPU. When you have indexed vertices, the GPU will try to cache transformed vertices so that the shared vertices are only transformed once. Whether this is effective or not depends on how close together the repeated indices are in the index list.

    Could you clarify what information is stored in the 'faceList' array?
    Regards,
    Mike

    Leave a comment:


  • Suggestions to build a 3D shape from a 3D point (x, y, z) array and  a face array

    Dear Users,
    Please i'd like to know the best way to build a 3D shape starting from a 3D point (x, y, z) array and a face array;

    if "pointList" and "faceList" are the above mentioned arrays, i was thinking to use the following pseudo-code:

    Code:
    std::vector<SbVec3f> vTriangleVertex; //the pointList array
    
    SoVertexProperty* pVertexProperty = new SoVertexProperty;
    pVertexProperty->vertex.setValuesPointer((int)vTriangleVertex.size(), &vTriangleVertex[0]);
    
    SoTriangleSet* pGeneratedPrimitivesShape = new SoTriangleSet;
    pGeneratedPrimitivesShape->numTriangles.setValue(count);
    
    pGeneratedPrimitivesShape->vertexProperty.setValue(pVertexProperty);
    
    pSep = new SoSeparator;
    
    SoShapeHints* sh = new SoShapeHints;
    sh->faceType = SoShapeHints::SOLID;
    sh->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
    sh->faceType = SoShapeHints::CONVEX;
    pSep->addChild(sh);
    
    pSep->addChild(pGeneratedPrimitivesShape);
    Please can i do better (intended as optimized GPU 3D shape) , using faceList array, too?

    Thank You for Your help in advance.

    Regards,
    Vincenzo
Working...
X