Retrieving Mesh Strip Data
 
 
 

The mesh strip data is accessible through the Mesh::strips member variable. This is declared as a StripTab which is a Tab<> collection of Strip pointers.

The data is maintained as an array of indexes into the main mesh data of the vertex, normals and texture coordinates each being its own DWORD tab. If you are writing hardware shaders then the graphics layer will pass this information in the form of a MeshData pointer

The following code can be used to extract the mesh strip data:

// Utility function to give us the TriObject
TriObject* GetTriObjectFromNode(INode *node, TimeValue t,
    int &deleteIt)
{
    deleteIt = FALSE;
    Object *obj = node->EvalWorldState(t).obj;
    if (obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID,
        0))) {
        TriObject *tri = (TriObject *) obj->
        ConvertToType(t, Class_ID(TRIOBJ_CLASS_ID, 0));
        
        // Note that the TriObject should only be deleted
        // if the pointer to it is not equal to the object
        // pointer that called ConvertToType()
        if (obj != tri) deleteIt = TRUE;
             return tri;
        }
        else {
             return NULL;
        }
}
 
void GetStripData()
{
    INode *sNode = ip->GetSelNode(0);
    if(!sNode) return;
    BOOL deleteTri = FALSE;
    TriObject *pTri = GetTriObjectFromNode(sNode,
        ip->GetTime(), deleteTri);
    Mesh m = pTri->mesh;
    
    //Make sure the strips are there and upto date ?
    m.BuildStripsAndEdges();   
    StripTab *pStab = m.stab;
    int c = pStab->Count(); //How may Strips do we have ?  
    for(int i=0; i<c; i++) {
        Strip *pS = (*pStab)[i]; // Access the Strip data
        int d= pS->v.Count(); // Access the Vertex Tab data  
        for(int j=0; j<d; j++) {
            DebugPrint("Vertex Index %d\n", pS->v[j]);
        }
    }
    //If we own it - remember to delete it !!
    if(deleteTri) pTri->DeleteThis();
}

The same method would be used to access the normals and texture vertex data.