18             VisRTX::Context* rtx = VisRTX_GetContext();
 
   20             if (
type == 
"triangles" || 
type == 
"trianglemesh")
 
   21                 this->geometry = rtx->CreateTriangleGeometry();
 
   22             else if (
type == 
"spheres")
 
   23                 this->geometry = rtx->CreateSphereGeometry();
 
   24             else if (
type == 
"cylinders")
 
   25                 this->geometry = rtx->CreateCylinderGeometry();
 
   26             else if (
type == 
"isosurfaces")
 
   30                 std::cerr << 
"Error: Unhandled geometry type \"" << 
type << 
"\"" << std::endl;
 
   37             this->geometry->Release();
 
   48             if (this->geometry->GetType() == VisRTX::GeometryType::TRIANGLES)
 
   50                 VisRTX::TriangleGeometry* tri = 
dynamic_cast<VisRTX::TriangleGeometry*
>(this->geometry);
 
   52                 Data* vertex = this->GetObject<Data>({ 
"position", 
"vertex" });
 
   53                 Data* 
index = this->GetObject<Data>({ 
"index" });
 
   56                     uint32_t numTriangles = 
static_cast<uint32_t
>(
index->GetNumElements());
 
   57                     VisRTX::Vec3ui* triangles = 
reinterpret_cast<VisRTX::Vec3ui*
>(
index->GetData());
 
   60                     uint32_t numVertices = 
static_cast<uint32_t
>(vertex->
GetNumElements());
 
   61                     VisRTX::Vec3f* 
vertices = 
reinterpret_cast<VisRTX::Vec3f*
>(vertex->
GetData());
 
   64                     VisRTX::Vec3f* normals = 
nullptr;
 
   65                     Data* normal = this->GetObject<Data>({ 
"vertex.normal" });
 
   68                         normals = 
reinterpret_cast<VisRTX::Vec3f*
>(normal->
GetData());
 
   72                     tri->SetTriangles(numTriangles, triangles, numVertices, 
vertices, normals);
 
   75                     Data* 
color = this->GetObject<Data>({ 
"vertex.color" });
 
   78                         VisRTX::Vec4f* colors = 
reinterpret_cast<VisRTX::Vec4f*
>(
color->GetData());
 
   80                         tri->SetColors(colors);
 
   84                         tri->SetColors(
nullptr);
 
   88                     Data* texcoord = GetObject<Data>({ 
"vertex.texcoord" });
 
   91                         VisRTX::Vec2f* texcoords = 
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
 
   93                         tri->SetTexCoords(texcoords);
 
   97                         tri->SetTexCoords(
nullptr);
 
  101                     Data* materialList = GetObject<Data>({ 
"materialList" });
 
  102                     Data* materialIndices = GetObject<Data>({ 
"prim.materialID" });
 
  103                     if (materialList && materialIndices)
 
  106                         assert(materialIndices->GetDataType() == 
RTW_INT);
 
  108                         std::vector<VisRTX::Material*> triangleMaterials;
 
  109                         triangleMaterials.resize(numTriangles);
 
  112                         int* indices = 
reinterpret_cast<int*
>(materialIndices->GetData());
 
  114                         for (uint32_t i = 0; i < numTriangles; ++i)
 
  116                             int triIndex = indices[i];
 
  119                                 Material* materialHandle = materials[triIndex];
 
  121                                     triangleMaterials[i] = materialHandle->material;
 
  125                         tri->SetMaterials(triangleMaterials.data());
 
  129                         tri->SetMaterials(
nullptr);
 
  134                     tri->SetTriangles(0, 
nullptr, 0, 
nullptr, 
nullptr);
 
  142             else if (this->geometry->GetType() == VisRTX::GeometryType::SPHERES)
 
  144                 VisRTX::SphereGeometry* sphere = 
dynamic_cast<VisRTX::SphereGeometry*
>(this->geometry);
 
  146                 Data* spheres = GetObject<Data>({ 
"spheres" });
 
  149                     VisRTX::Vec4f* colors = 
nullptr;
 
  150                     Data* 
color = GetObject<Data>({ 
"color" });
 
  153                         colors = 
reinterpret_cast<VisRTX::Vec4f*
>(
color->GetData());
 
  157                     int32_t bytesPerSphere = this->
Get1i({ 
"bytes_per_sphere" }, 16, 
nullptr);
 
  158                     int32_t offsetCenter = this->
Get1i({ 
"offset_center" }, 0, 
nullptr);
 
  159                     int32_t offsetRadius = this->
Get1i({ 
"offset_radius" }, -1, 
nullptr);
 
  160                     int32_t offsetColorIndex = this->
Get1i({ 
"offset_colorID" }, -1, 
nullptr);
 
  164                     sphere->SetSpheresAndColors(numSpheres, spheres->
GetData(), bytesPerSphere, offsetCenter, offsetRadius, offsetColorIndex, colors);
 
  166                     Data* texcoord = GetObject<Data>({ 
"texcoord" });
 
  169                         VisRTX::Vec2f* texcoords = 
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
 
  171                         sphere->SetTexCoords(texcoords);
 
  175                         sphere->SetTexCoords(
nullptr);
 
  178                     Data* materialList = GetObject<Data>({ 
"materialList" });
 
  179                     int offset_materialID = this->
Get1i({ 
"offset_materialID" }, -1);
 
  180                     if (materialList && offset_materialID >= 0)
 
  184                         std::vector<VisRTX::Material*> sphereMaterials;
 
  185                         sphereMaterials.resize(numSpheres);
 
  189                         const uint8_t* base = 
reinterpret_cast<const uint8_t*
>(spheres->
GetData());
 
  191                         for (uint32_t i = 0; i < numSpheres; ++i)
 
  193                             int index = *
reinterpret_cast<const int*
>(base + i * bytesPerSphere + offset_materialID);
 
  198                                     sphereMaterials[i] = materialHandle->material;
 
  202                         sphere->SetMaterials(sphereMaterials.data());
 
  206                         sphere->SetMaterials(
nullptr);
 
  216                     sphere->SetRadius(
radius);
 
  222             else if (this->geometry->GetType() == VisRTX::GeometryType::CYLINDERS)
 
  224                 VisRTX::CylinderGeometry* cyl = 
dynamic_cast<VisRTX::CylinderGeometry*
>(this->geometry);
 
  226                 Data* cylinders = GetObject<Data>({ 
"cylinders" });
 
  229                     VisRTX::Vec4f* colors = 
nullptr;
 
  230                     Data* 
color = GetObject<Data>({ 
"color" });
 
  233                         colors = 
reinterpret_cast<VisRTX::Vec4f*
>(
color->GetData());
 
  237                     int32_t bytesPerCylinder = this->
Get1i({ 
"bytes_per_cylinder" }, 24, 
nullptr);
 
  238                     int32_t offsetVertex0 = this->
Get1i({ 
"offset_v0" }, 0, 
nullptr);
 
  239                     int32_t offsetVertex1 = this->
Get1i({ 
"offset_v1" }, 12, 
nullptr);
 
  240                     int32_t offsetRadius = this->
Get1i({ 
"offset_radius" }, -1, 
nullptr);
 
  244                     cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
 
  246                     Data* texcoord = GetObject<Data>({ 
"texcoord" });
 
  249                         VisRTX::Vec2f* texcoords = 
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
 
  251                         cyl->SetTexCoords(texcoords);
 
  255                         cyl->SetTexCoords(
nullptr);
 
  258                     Data* materialList = GetObject<Data>({ 
"materialList" });
 
  259                     int offset_materialID = this->
Get1i({ 
"offset_materialID" }, -1);
 
  260                     if (materialList && offset_materialID >= 0)
 
  264                         std::vector<VisRTX::Material*> cylinderMaterials;
 
  265                         cylinderMaterials.resize(numCylinders);
 
  269                         const uint8_t* base = 
reinterpret_cast<const uint8_t*
>(cylinders->
GetData());
 
  271                         for (uint32_t i = 0; i < numCylinders; ++i)
 
  273                             int index = *
reinterpret_cast<const int*
>(base + i * bytesPerCylinder + offset_materialID);
 
  278                                     cylinderMaterials[i] = materialHandle->material;
 
  282                         cyl->SetMaterials(cylinderMaterials.data());
 
  286                         cyl->SetMaterials(
nullptr);
 
  308                 VisRTX::Context* rtx = VisRTX_GetContext();
 
  309                 this->geometry->SetMaterial(rtx->CreateBasicMaterial());
 
  324                 this->geometry->SetMaterial(material->material);
 
  325                 this->material = material;
 
  330                 this->geometry->SetMaterial(
nullptr);
 
  331                 this->material = 
nullptr;
 
  336         VisRTX::Geometry* geometry = 
nullptr;