16 VTK_ABI_NAMESPACE_BEGIN
25 VisRTX::Context* rtx = VisRTX_GetContext();
27 if (
type ==
"DirectionalLight" ||
type ==
"distant")
28 this->light = rtx->CreateDirectionalLight();
29 else if (
type ==
"PointLight" ||
type ==
"point" ||
type ==
"SphereLight" ||
type ==
"sphere")
30 this->light = rtx->CreateSphericalLight();
31 else if (
type ==
"SpotLight" ||
type ==
"spot")
32 this->light = rtx->CreateSpotLight();
33 else if (
type ==
"QuadLight" ||
type ==
"quad")
34 this->light = rtx->CreateQuadLight();
35 else if (
type ==
"AmbientLight" ||
type ==
"ambient")
36 this->light = rtx->CreateAmbientLight();
37 else if (
type ==
"HDRILight" ||
type ==
"hdri")
38 this->light = rtx->CreateHDRILight();
41 vtkLogF(ERROR,
"VisRTX Error: Unhandled light type \"%s\"",
type.c_str());
48 this->light->Release();
53 switch(this->light->GetType())
55 case VisRTX::LightType::AMBIENT:
57 case VisRTX::LightType::DIRECTIONAL:
59 case VisRTX::LightType::SPHERICAL:
61 case VisRTX::LightType::SPOT:
63 case VisRTX::LightType::QUAD:
65 case VisRTX::LightType::HDRI:
76 this->light->SetColor(
color);
85 if (this->light->GetType() == VisRTX::LightType::DIRECTIONAL)
93 float angularDiameter;
94 if (this->
GetFloat({
"angularDiameter" }, &angularDiameter))
95 dirLight->SetAngularDiameter(angularDiameter);
101 else if (this->light->GetType() == VisRTX::LightType::SPHERICAL)
103 VisRTX::SphericalLight* sphereLight =
dynamic_cast<VisRTX::SphericalLight*
>(this->light);
111 sphereLight->SetRadius(
radius);
117 else if (this->light->GetType() == VisRTX::LightType::SPOT)
130 if (this->
GetFloat({
"openingAngle" }, &openingAngle))
131 spot->SetOpeningAngle(openingAngle);
134 if (this->
GetFloat({
"penumbraAngle" }, &penumbraAngle))
135 spot->SetPenumbraAngle(penumbraAngle);
145 else if (this->light->GetType() == VisRTX::LightType::QUAD)
147 VisRTX::QuadLight* quad =
dynamic_cast<VisRTX::QuadLight*
>(this->light);
149 VisRTX::Vec3f
position, edge1, edge2;
151 quad->SetRect(
position, edge1, edge2);
153 quad->SetTwoSided(
false);
159 else if (this->light->GetType() == VisRTX::LightType::HDRI)
161 VisRTX::HDRILight* hdri =
dynamic_cast<VisRTX::HDRILight*
>(this->light);
163 Texture* texture = this->GetObject<Texture>({
"map" });
165 hdri->SetTexture(texture->texture);
178 VisRTX::Light* light =
nullptr;
180 VTK_ABI_NAMESPACE_END
Light(const std::string &type)
float GetFloat(const std::vector< std::string > &ids, float defaultValue=0.0f, bool *found=nullptr) const
VisRTX::Vec3f GetVec3f(const std::vector< std::string > &ids, const VisRTX::Vec3f &defaultValue=VisRTX::Vec3f(), bool *found=nullptr) const
#define vtkLogF(verbosity_name,...)
Add to log given the verbosity level.