51 if (this->geometry->GetType() == VisRTX::GeometryType::TRIANGLES)
53 VisRTX::TriangleGeometry* tri =
dynamic_cast<VisRTX::TriangleGeometry*
>(this->geometry);
59 uint32_t numTriangles =
static_cast<uint32_t
>(index->GetNumElements());
60 VisRTX::Vec3ui* triangles =
reinterpret_cast<VisRTX::Vec3ui*
>(index->GetData());
61 assert(index->GetElementDataType() ==
RTW_VEC3UI);
63 uint32_t numVertices =
static_cast<uint32_t
>(vertex->
GetNumElements());
64 VisRTX::Vec3f*
vertices =
reinterpret_cast<VisRTX::Vec3f*
>(vertex->
GetData());
67 VisRTX::Vec3f* normals =
nullptr;
71 normals =
reinterpret_cast<VisRTX::Vec3f*
>(normal->
GetData());
76 tri->SetTriangles(numTriangles, triangles, numVertices,
vertices, normals);
82 VisRTX::Vec4f* colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
83 assert(color->GetElementDataType() ==
RTW_VEC4F);
84 tri->SetColors(colors);
88 tri->SetColors(
nullptr);
95 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
97 tri->SetTexCoords(texcoords);
101 tri->SetTexCoords(
nullptr);
109 std::vector<VisRTX::Material*> triangleMaterials;
110 triangleMaterials.resize(numTriangles);
114 for (uint32_t i = 0; i < numTriangles; ++i)
116 Material* materialHandle = materials[i];
118 triangleMaterials[i] = materialHandle->material;
121 tri->SetMaterials(triangleMaterials.data());
125 tri->SetMaterials(
nullptr);
130 tri->SetTriangles(0,
nullptr, 0,
nullptr,
nullptr);
138 else if (this->geometry->GetType() == VisRTX::GeometryType::SPHERES)
140 VisRTX::SphereGeometry* sphere =
dynamic_cast<VisRTX::SphereGeometry*
>(this->geometry);
145 VisRTX::Vec4f* colors =
nullptr;
149 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
150 assert(color->GetElementDataType() ==
RTW_VEC4F);
151 sphere->SetColors(
reinterpret_cast<VisRTX::Vec4f *
>(color->GetData()));
155 sphere->SetColors(
nullptr);
162 sphere->SetSpheres(numSpheres,
163 reinterpret_cast<VisRTX::Vec3f *
>(spheres->
GetData()),
164 reinterpret_cast<float *
>(radii->
GetData()));
169 sphere->SetSpheres(numSpheres,
170 reinterpret_cast<VisRTX::Vec3f *
>(spheres->
GetData()),
178 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
180 sphere->SetTexCoords(texcoords);
184 sphere->SetTexCoords(
nullptr);
193 std::vector<VisRTX::Material*> sphereMaterials;
194 sphereMaterials.resize(numSpheres);
198 for (uint32_t i = 0; i < numSpheres; ++i)
200 Material* materialHandle = materials[i];
202 sphereMaterials[i] = materialHandle->material;
205 sphere->SetMaterials(sphereMaterials.data());
209 sphere->SetMaterials(
nullptr);
218 if (this->
GetFloat({
"radius" }, &radius))
219 sphere->SetRadius(radius);
225 else if (this->geometry->GetType() == VisRTX::GeometryType::CYLINDERS)
227 VisRTX::CylinderGeometry* cyl =
dynamic_cast<VisRTX::CylinderGeometry*
>(this->geometry);
233 VisRTX::Vec4f* colors =
nullptr;
237 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
238 assert(color->GetElementDataType() ==
RTW_VEC4F);
241 int32_t bytesPerCylinder = this->
GetInt({
"bytes_per_cylinder" }, 24,
nullptr);
242 int32_t offsetVertex0 = this->
GetInt({
"offset_v0" }, 0,
nullptr);
243 int32_t offsetVertex1 = this->
GetInt({
"offset_v1" }, 12,
nullptr);
244 int32_t offsetRadius = this->
GetInt({
"offset_radius" }, -1,
nullptr);
247 cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
253 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
255 cyl->SetTexCoords(texcoords);
259 cyl->SetTexCoords(
nullptr);
267 std::vector<VisRTX::Material*> cylinderMaterials;
268 cylinderMaterials.resize(numCylinders);
272 for (uint32_t i = 0; i < numCylinders; ++i)
274 Material* materialHandle = materials[i];
276 cylinderMaterials[i] = materialHandle->material;
279 cyl->SetMaterials(cylinderMaterials.data());
283 cyl->SetMaterials(
nullptr);
289 VisRTX::Vec4f* colors =
nullptr;
293 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
294 assert(color->GetElementDataType() ==
RTW_VEC4F);
297 int32_t bytesPerCylinder = this->
GetInt({
"bytes_per_cylinder" }, 64,
nullptr);
298 int32_t offsetVertex0 = this->
GetInt({
"offset_v0" }, 0,
nullptr);
299 int32_t offsetVertex1 = this->
GetInt({
"offset_v1" }, 32,
nullptr);
300 int32_t offsetRadius = this->
GetInt({
"offset_radius" }, 12,
nullptr);
303 cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
309 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
311 cyl->SetTexCoords(texcoords);
315 cyl->SetTexCoords(
nullptr);
323 std::vector<VisRTX::Material*> cylinderMaterials;
324 cylinderMaterials.resize(numCylinders);
328 for (uint32_t i = 0; i < numCylinders; ++i)
330 Material* materialHandle = materials[i];
332 cylinderMaterials[i] = materialHandle->material;
335 cyl->SetMaterials(cylinderMaterials.data());
339 cyl->SetMaterials(
nullptr);
348 if (this->
GetFloat({
"radius" }, &radius))
349 cyl->SetRadius(radius);
361 VisRTX::Context* rtx = VisRTX_GetContext();
362 this->geometry->SetMaterial(rtx->CreateBasicMaterial());