v2.38
 
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 and 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->GetCount(); ++objectIndex)
{
Renga::IExportedObject3DPtr pObject = pObjectCollection->Get(objectIndex);
if (pObject->GetModelObjectType() == Renga::ObjectTypes::Door || pObject->GetModelObjectType() == 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);
}
}
}
const GUID Door
Door object type.
Definition ObjectTypes.h:81
const GUID Window
Window object type.
Definition ObjectTypes.h:86

C#

Renga.IProject project = application.Project;
Renga.IDataExporter dataExporter = project.DataExporter;
Renga.IExportedObject3DCollection objectCollection = dataExporter.GetObjects3D();
for (int objectIndex = 0; objectIndex < objectCollection.Count; ++objectIndex)
{
Renga.IExportedObject3D object3d = objectCollection.Get(objectIndex);
if (object3d.ModelObjectType == Renga.ObjectTypes.Door || object3d.ModelObjectType == Renga.ObjectTypes.Window)
continue;
for (int meshIndex = 0; meshIndex < object3d.MeshCount; ++meshIndex)
{
Renga.IMesh mesh = object3d.GetMesh(meshIndex);
for (int gridIndex = 0; gridIndex < mesh.GridCount; ++gridIndex)
{
Renga.IGrid grid = mesh.GetGrid(gridIndex);
SomeRenderingMethod(grid);
}
}
}

How to export model geometry as a collection of grids

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->GetCount(); ++i)
{
Renga::IGridWithMaterialPtr pGridWithMaterial = pGridCollection->Get(i);
Renga::Color color = pGridWithMaterial->GetMaterial()->GetColor();
SomeRenderingMethod(pGridWithMaterial->GetGrid(), color);
}

C#

Renga.IProject project = application.Project;
Renga.IDataExporter dataExporter = project.DataExporter;
Renga.IGridWithMaterialCollection gridCollection = dataExporter.GetGrids();
for (int i = 0; i < gridCollection.Count; ++i)
{
Renga.IGridWithMaterial gridWithMaterial = gridCollection.Get(i);
Renga.Color color = gridWithMaterial.Material.Color;
SomeRenderingMethod(gridWithMaterial.Grid, color);
}

See also

Related samples

  • GeometryExport