anyKode Marilou
ContentsIndexHome
PreviousUpNext
Geom::GetMesh (int)

Getting the geometry's mesh.

C++
MeshSubset * GetMesh(int SubsetNumber);
Parameters 
Description 
int SubsetNumber 
[in] subset number to retrieve. 

A MeshSubset pointer if no error occurred, NULL otherwise. In the case of an empty result, GetMesh returns a mesh that contains 0 points and 0 faces.

GetMesh returns the complete (or partial) mesh of the geometry. The final result is according to the geometry type and 'SubsetNumber' value. 

 

The general case:
  • SubsetNumber >=0 : ask for the subset numbered 'SubsetNumber' (see Notes),
  • SubsetNumber == -1 : ask for the complete mesh as described in the 3D mesh file or as used in physics's internal structure (native geometry),
  • SubsetNumber == -2 : ask for selected subset(s) in modeling, if any, for the complete mesh otherwise.

 

Geometry type 
Expected result 
Native 'physics geometry' or 'simple 3D' geometry (box, sphere, cylinder, pyramid, cone, etc...) 
SubsetNumber > 0 : empty result (empty mesh).
SubsetNumber <= 0 : returns the displayable mesh, optimized for physics. 
Géométrie 'physique' ou 'affichage 3D' de type Mesh File (fichier 3D) 
SubsetNumber >= 0 : returns the subset numbered 'SubsetNumber' if it exits, empty result otherwise.
SubsetNumber == -1 : returns the complete mesh as defined in the mesh file.
SubsetNumber == -2 : returns a mesh that contains all subsets selected in modeling (See notes) 
SubsetNumber > 0 : empty result.
SubsetNumber <= 0 : returns the mesh used in physics. 

 

Getting the mesh locks the physics engine : the response time can be different from a call to GetMesh to another. It is suggested to 'cache' the returned mesh instead of getting it at each use. The returned object must be deleted by calling the delete operator.

Marilou Editor : sample of a subset selection (physics or 3d-only subsets from a 3D mesh file). 

 

v4.7.4

//Example from Samples/Simple/GetMesh

(...)
ModaCPP::Geom *pPhysicsBox=pWorld->QueryGeom("/physicsBOX");
Moda::Commons::MeshSubset *pBoxMesh=pPhysicsBox->GetMesh();
DisplayMesh("Physics box",pBoxMesh);
(...)

////////////////////////////////////////////////////////////////////////////////////////
//Displays mesh information
////////////////////////////////////////////////////////////////////////////////////////
void DisplayMesh(const xkode::lib::String &Prefix, Moda::Commons::MeshSubset *pMesh, bool bDisplayBuffers=false)
    {
    if(pMesh==NULL)
        {
        _cprintf("\t%s: Mesh NULL\r\n",Prefix.GetData());
        }
    else
        {
        _cprintf("\t%s: %d faces, %d points\r\n",Prefix.GetData(),pMesh->FacesCount,pMesh->PointsCount);
        if(bDisplayBuffers)
            {
            _cprintf("\t\tEnum points:\r\n");
            for(int i=0;i<(int)pMesh->PointsCount;i++)
                {
                _cprintf("\t\t[%03d] %f, %f, %f\r\n",i,pMesh->pPoints[i].x,pMesh->pPoints[i].y,pMesh->pPoints[i].z);
                }

            _cprintf("\r\n\t\tEnum indices:\r\n");
            for(int i=0;i<(int)pMesh->FacesCount;i++)
                {
                _cprintf("\t\t[%03d] %d, %d, %d\r\n",i,pMesh->pIndices[i*3+0],pMesh->pIndices[i*3+1],pMesh->pIndices[i*3+2]);
                }
            }
        }
    }
Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.
What do you think about this topic? Send feedback!