Using the API to draw lines


#1

Ok, so I’ve made some great progress since my last post. There’s one thing I’m rather confused about, though, and that’s dealing with lines (for the purposes of being rendered), as opposed to triangles and quads.

Using an SUGeometryInputRef doesn’t appear to work. For instance, take the following call:

SU_CHECK_RESULT( SUEntitiesFill(innerEntitiesRef, geomRef, true) );

(where SU_CHECK_RESULT(...) asserts false if the returned SUResult != SU_ERROR_NONE)

If geomRef contains faces whose SULoopInputRefs have only two vertices, the error reported is of SU_ERROR_INVALID_INPUT (enum entry 2).

So I decided to try a different approach, specifically for data which has only two verts per face:

 std::vector<SUFaceRef> faces;
 faces.resize(mesh->mNumFaces);
 memset(&faces[0].ptr, 0, sizeof(faces[0]) * faces.size());

 for (unsigned faceIndex = 0; faceIndex < mesh->mNumFaces; ++faceIndex)
 {
    SULoopInputRef loopIndex = SU_INVALID;

    SU_CHECK_RESULT( SULoopInputCreate(&loopIndex) );
        
    SU_CHECK_RESULT( SULoopInputAddVertexIndex(loopIndex, 0) );
    SU_CHECK_RESULT( SULoopInputAddVertexIndex(loopIndex, 1) );

    SUPoint3D faceVertices[2] = 
    {
        vertices[mesh->mFaces[faceIndex].mIndices[0]],
        vertices[mesh->mFaces[faceIndex].mIndices[1]]
    };
    SU_CHECK_RESULT( SUFaceCreate(&faces[faceIndex], faceVertices, &loopIndex) );
 }

Which results in the same error code on the call to SUFaceCreate(...), stating that loopIndex contains invalid data.

Thus, I’m at a bit of a loss as to how to do this. Any suggestions?


#2

A face must be planar, not linear - you cannot create faces with only two vertices, it needs at least three non-linear vertices.

To add edges without faces, use SUEntitiesAddEdges