v2.0
How to export geometry of objects

Overview

To get the triangulated geometry of objects in the project use the IDataExporter interface, available via the IProject::GetDataExporter() method of current project. It supports two ways of export:

The difference between the methods is that IExportedObject3D provide represent the geometry aggregated per object, whereas IGridWithMaterial items aggregate the geometry by grid type or material.

How to export the model object geometry

To get the collection of IExportedObject3D items call IDataExporter::GetObjects3D(). Querying of the collection (such as filtering objects out by their type) is then performed by iterating it and picking the objects of interest.

For example, to draw all the objects in the scene except doors and windows:

C++

Renga::IProjectPtr pProject = pApplication->GetProject();
Renga::IDataExporterPtr pDataExporter = pProject->GetDataExporter();
Renga::IExportedObject3DCollectionPtr pObjectCollection = pDataExporter->GetObjects3D();
for (int objectIndex = 0; objectIndex < pObjectCollection->GetSize(); ++objectIndex)
{
Renga::IExportedObject3DPtr pObject = pObjectCollection->Get(objectIndex);
if (pObject->GetObjectType() == Renga::ObjectTypes::Door || pObject->GetObjectType() == Renga::ObjectTypes::Window)
continue;
for (int meshIndex = 0; meshIndex < pObject->GetMeshCount(); ++meshIndex)
{
Renga::IMeshPtr pMesh = pObject->GetMesh(meshIndex);
for (int gridIndex = 0; gridIndex < pMesh->GetGridCount(); ++gridIndex)
{
Renga::IGridPtr pGrid = pMesh->GetGrid(gridIndex);
SomeRenderingMethod(pGrid);
}
}
}

C#

Renga.IProject project = application.GetProject();
Renga.IDataExporter dataExporter = project.GetDataExporter();
Renga.IExportedObject3DCollection objectCollection = dataExporter.GetObjects3D();
for (int objectIndex = 0; objectIndex < objectCollection.GetSize(); ++objectIndex)
{
Renga.IExportedObject3D object3d = objectCollection.Get(objectIndex);
if (object3d.GetObjectType() == Renga.ObjectTypes.Door || object3d.GetObjectType() == Renga.ObjectTypes.Window)
continue;
for (int meshIndex = 0; meshIndex < object3d.GetMeshCount(); ++meshIndex)
{
Renga.IMesh mesh = object3d.GetMesh(meshIndex);
for (int gridIndex = 0; gridIndex < mesh.GetGridCount(); ++gridIndex)
{
Renga.IGrid grid = mesh.GetGrid(gridIndex);
SomeRenderingMethod(grid);
}
}
}

How to export geometry data

Is cases where only the geometry of a project (with or without the associated material data) is needed and no information about which geometry belongs to which object is necessary, use the IDataExporter::GetGrids() method.

For example, get all grids and draw them using different colors, to show that grids have different materials:

C++

Renga::IProjectPtr pProject = pApplication->GetProject();
Renga::IDataExporterPtr pDataExporter = pProject->GetDataExporter();
Renga::IGridWithMaterialCollectionPtr pGridCollection = pDataExporter->GetGrids();
for (int i = 0; i < pGridCollection->GetSize(); ++i)
{
Renga::IGridWithMaterialPtr pGridWithMaterial = pGridCollection->Get(i);
Renga::Color color = pGridWithMaterial->GetMaterial()->GetColor();
SomeRenderingMethod(pGridWithMaterial->GetGrid(), color);
}

C#

Renga.IProject project = application.GetProject();
Renga.IDataExporter dataExporter = project.GetDataExporter();
Renga.IGridWithMaterialCollection gridCollection = dataExporter.GetGrids();
for (int i = 0; i < gridCollection.GetSize(); ++i)
{
Renga.IGridWithMaterial gridWithMaterial = gridCollection.Get(i);
Renga.Color color = gridWithMaterial.GetMaterial().GetColor();
SomeRenderingMethod(gridWithMaterial.GetGrid(), color);
}

See also

Related samples

  • GeometryExport