54 if (this->geometry->GetType() == VisRTX::GeometryType::TRIANGLES)
56 VisRTX::TriangleGeometry* tri =
dynamic_cast<VisRTX::TriangleGeometry*
>(this->geometry);
62 uint32_t numTriangles =
static_cast<uint32_t
>(index->GetNumElements());
63 VisRTX::Vec3ui* triangles =
reinterpret_cast<VisRTX::Vec3ui*
>(index->GetData());
64 assert(index->GetElementDataType() ==
RTW_VEC3UI);
66 uint32_t numVertices =
static_cast<uint32_t
>(vertex->
GetNumElements());
67 VisRTX::Vec3f*
vertices =
reinterpret_cast<VisRTX::Vec3f*
>(vertex->
GetData());
70 VisRTX::Vec3f* normals =
nullptr;
74 normals =
reinterpret_cast<VisRTX::Vec3f*
>(normal->
GetData());
79 tri->SetTriangles(numTriangles, triangles, numVertices,
vertices, normals);
85 VisRTX::Vec4f* colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
86 assert(color->GetElementDataType() ==
RTW_VEC4F);
87 tri->SetColors(colors);
91 tri->SetColors(
nullptr);
98 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
100 tri->SetTexCoords(texcoords);
104 tri->SetTexCoords(
nullptr);
112 std::vector<VisRTX::Material*> triangleMaterials;
113 triangleMaterials.resize(numTriangles);
117 for (uint32_t i = 0; i < numTriangles; ++i)
119 Material* materialHandle = materials[i];
121 triangleMaterials[i] = materialHandle->material;
124 tri->SetMaterials(triangleMaterials.data());
128 tri->SetMaterials(
nullptr);
133 tri->SetTriangles(0,
nullptr, 0,
nullptr,
nullptr);
141 else if (this->geometry->GetType() == VisRTX::GeometryType::SPHERES)
143 VisRTX::SphereGeometry* sphere =
dynamic_cast<VisRTX::SphereGeometry*
>(this->geometry);
148 VisRTX::Vec4f* colors =
nullptr;
152 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
153 assert(color->GetElementDataType() ==
RTW_VEC4F);
154 sphere->SetColors(
reinterpret_cast<VisRTX::Vec4f *
>(color->GetData()));
158 sphere->SetColors(
nullptr);
165 sphere->SetSpheres(numSpheres,
166 reinterpret_cast<VisRTX::Vec3f *
>(spheres->
GetData()),
167 reinterpret_cast<float *
>(radii->
GetData()));
172 sphere->SetSpheres(numSpheres,
173 reinterpret_cast<VisRTX::Vec3f *
>(spheres->
GetData()),
181 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
183 sphere->SetTexCoords(texcoords);
187 sphere->SetTexCoords(
nullptr);
196 std::vector<VisRTX::Material*> sphereMaterials;
197 sphereMaterials.resize(numSpheres);
201 for (uint32_t i = 0; i < numSpheres; ++i)
203 Material* materialHandle = materials[i];
205 sphereMaterials[i] = materialHandle->material;
208 sphere->SetMaterials(sphereMaterials.data());
212 sphere->SetMaterials(
nullptr);
221 if (this->
GetFloat({
"radius" }, &radius))
222 sphere->SetRadius(radius);
228 else if (this->geometry->GetType() == VisRTX::GeometryType::CYLINDERS)
230 VisRTX::CylinderGeometry* cyl =
dynamic_cast<VisRTX::CylinderGeometry*
>(this->geometry);
236 VisRTX::Vec4f* colors =
nullptr;
240 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
241 assert(color->GetElementDataType() ==
RTW_VEC4F);
244 int32_t bytesPerCylinder = this->
GetInt({
"bytes_per_cylinder" }, 24,
nullptr);
245 int32_t offsetVertex0 = this->
GetInt({
"offset_v0" }, 0,
nullptr);
246 int32_t offsetVertex1 = this->
GetInt({
"offset_v1" }, 12,
nullptr);
247 int32_t offsetRadius = this->
GetInt({
"offset_radius" }, -1,
nullptr);
250 cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
256 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
258 cyl->SetTexCoords(texcoords);
262 cyl->SetTexCoords(
nullptr);
270 std::vector<VisRTX::Material*> cylinderMaterials;
271 cylinderMaterials.resize(numCylinders);
275 for (uint32_t i = 0; i < numCylinders; ++i)
277 Material* materialHandle = materials[i];
279 cylinderMaterials[i] = materialHandle->material;
282 cyl->SetMaterials(cylinderMaterials.data());
286 cyl->SetMaterials(
nullptr);
292 VisRTX::Vec4f* colors =
nullptr;
296 colors =
reinterpret_cast<VisRTX::Vec4f*
>(color->GetData());
297 assert(color->GetElementDataType() ==
RTW_VEC4F);
300 int32_t bytesPerCylinder = this->
GetInt({
"bytes_per_cylinder" }, 64,
nullptr);
301 int32_t offsetVertex0 = this->
GetInt({
"offset_v0" }, 0,
nullptr);
302 int32_t offsetVertex1 = this->
GetInt({
"offset_v1" }, 32,
nullptr);
303 int32_t offsetRadius = this->
GetInt({
"offset_radius" }, 12,
nullptr);
306 cyl->SetCylindersAndColors(numCylinders, cylinders->
GetData(), bytesPerCylinder, offsetVertex0, offsetVertex1, offsetRadius, colors);
312 VisRTX::Vec2f* texcoords =
reinterpret_cast<VisRTX::Vec2f*
>(texcoord->
GetData());
314 cyl->SetTexCoords(texcoords);
318 cyl->SetTexCoords(
nullptr);
326 std::vector<VisRTX::Material*> cylinderMaterials;
327 cylinderMaterials.resize(numCylinders);
331 for (uint32_t i = 0; i < numCylinders; ++i)
333 Material* materialHandle = materials[i];
335 cylinderMaterials[i] = materialHandle->material;
338 cyl->SetMaterials(cylinderMaterials.data());
342 cyl->SetMaterials(
nullptr);
351 if (this->
GetFloat({
"radius" }, &radius))
352 cyl->SetRadius(radius);
364 VisRTX::Context* rtx = VisRTX_GetContext();
365 this->geometry->SetMaterial(rtx->CreateBasicMaterial());