Regular API function
simImportMesh / sim.importMesh
Description
|
Imports a mesh from a file. See also sim.exportMesh, sim.importShape and sim.createMeshShape
|
C/C++ synopsis
|
simInt simImportMesh(simInt fileformat,const simChar* pathAndFilename,simInt options,simFloat identicalVerticeTolerance,simFloat scalingFactor,simFloat*** vertices,simInt** verticesSizes,simInt*** indices,simInt** indicesSizes,simFloat*** reserved,simChar*** names)
|
C/C++ parameters |
fileformat: set to 0. Fileformat is automatically detected
pathAndFilename: the location of the file to import.
options: bit-coded: bit0 set (1): keep identical vertices, bit7 set (128): ignore up-vector coded in fileformat
identicalVerticeTolerance: has no effect. set to zero
scalingFactor: the scaling factor to apply to the imported vertices
vertices: an array to vertice arrays. The import operation may generate several meshes depending on the fileformat. The user is in charge of releasing the memory. See the example below
verticesSizes: an array indicating the individual vertice array sizes. The user is in charge of releasing the memory. See the example below
indices: an array to indice arrays. The import operation may generate several meshes depending on the fileformat. The user is in charge of releasing the memory. Can be nullptr. See the example below
indicesSizes: an array indicating the individual indice array sizes. The user is in charge of releasing the memory. Can be nullptr if indices is also nullptr. See the example below
reserved: reserved for future extensions. Keep at nullptr.
names: not used anymore. Set to nullptr
USAGE EXAMPLE:
simFloat** vertices;
simInt* verticesSizes;
simInt** indices;
simInt* indicesSizes;
simInt elementCount=simImportMesh(1,"d:\\example.dxf",0,0.0001f,1.0f,&vertices,
&verticesSizes,&indices,&indicesSizes,nullptr,nullptr);
if (elementCount>0)
{
const float grey[3]={0.5f,0.5f,0.5f};
for (int i=0;i<elementCount;i++)
{
simInt shapeHandle=simCreateMeshShape(2,20.0f*3.1415f/180.0f,vertices[i],
verticesSizes[i],indices[i],indicesSizes[i],nullptr);
simSetShapeColor(shapeHandle,"",sim.colorcomponent_ambient,grey);
simReleaseBuffer((simChar*)indices[i]);
simReleaseBuffer((simChar*)vertices[i]);
}
simReleaseBuffer((simChar*)indicesSizes);
simReleaseBuffer((simChar*)indices);
simReleaseBuffer((simChar*)verticesSizes);
simReleaseBuffer((simChar*)vertices);
}
|
C/C++ return value
|
Number of imported meshes, or 0 or -1 if the operation was not successful
|
Lua synopsis
|
float[] vertices,int[] indices=sim.importMesh(int fileformat,string pathAndFilename,int options,float identicalVerticeTolerance,float scalingFactor)
|
Lua parameters |
Similar to the C-function counterpart
|
Lua return values
|
vertices: a table to vertice tables. The import operation may generate several meshes depending on the fileformat. See the example below
indices: a table to indice tables. The import operation may generate several meshes depending on the fileformat. See the example below
if (importButtonPressed) then
vertices,indices,reserved,names=sim.importMesh(1,"d:\\example.dxf",0,0.0001,1)
for i=1,#vertices,1 do
h=sim.createMeshShape(2,20*math.pi/180,vertices[i],indices[i])
sim.setShapeColor(h,"",sim.colorcomponent_ambient,{0.5,0.5,0.5})
sim.setObjectAlias(h,names[i])
end
end
|
Python synopsis |
list vertices,list indices=sim.importMesh(int fileformat,string pathAndFilename,int options,float identicalVerticeTolerance,float scalingFactor) |
|