22 VisRTX::Context* rtx = VisRTX_GetContext();
24 if (
type ==
"DirectionalLight" ||
type ==
"distant")
25 this->light = rtx->CreateDirectionalLight();
26 else if (
type ==
"PointLight" ||
type ==
"point" ||
type ==
"SphereLight" ||
type ==
"sphere")
27 this->light = rtx->CreateSphericalLight();
28 else if (
type ==
"SpotLight" ||
type ==
"spot")
29 this->light = rtx->CreateSpotLight();
30 else if (
type ==
"QuadLight" ||
type ==
"quad")
31 this->light = rtx->CreateQuadLight();
32 else if (
type ==
"AmbientLight" ||
type ==
"ambient")
33 this->light = rtx->CreateAmbientLight();
34 else if (
type ==
"HDRILight" ||
type ==
"hdri")
35 this->light = rtx->CreateHDRILight();
38 vtkLogF(ERROR,
"VisRTX Error: Unhandled light type \"%s\"",
type.c_str());
45 this->light->Release();
50 switch(this->light->GetType())
52 case VisRTX::LightType::AMBIENT:
54 case VisRTX::LightType::DIRECTIONAL:
56 case VisRTX::LightType::SPHERICAL:
58 case VisRTX::LightType::SPOT:
60 case VisRTX::LightType::QUAD:
62 case VisRTX::LightType::HDRI:
73 this->light->SetColor(
color);
82 if (this->light->GetType() == VisRTX::LightType::DIRECTIONAL)
90 float angularDiameter;
91 if (this->
GetFloat({
"angularDiameter" }, &angularDiameter))
92 dirLight->SetAngularDiameter(angularDiameter);
98 else if (this->light->GetType() == VisRTX::LightType::SPHERICAL)
100 VisRTX::SphericalLight* sphereLight =
dynamic_cast<VisRTX::SphericalLight*
>(this->light);
108 sphereLight->SetRadius(
radius);
114 else if (this->light->GetType() == VisRTX::LightType::SPOT)
127 if (this->
GetFloat({
"openingAngle" }, &openingAngle))
128 spot->SetOpeningAngle(openingAngle);
131 if (this->
GetFloat({
"penumbraAngle" }, &penumbraAngle))
132 spot->SetPenumbraAngle(penumbraAngle);
142 else if (this->light->GetType() == VisRTX::LightType::QUAD)
144 VisRTX::QuadLight* quad =
dynamic_cast<VisRTX::QuadLight*
>(this->light);
146 VisRTX::Vec3f
position, edge1, edge2;
148 quad->SetRect(
position, edge1, edge2);
150 quad->SetTwoSided(
false);
156 else if (this->light->GetType() == VisRTX::LightType::HDRI)
158 VisRTX::HDRILight* hdri =
dynamic_cast<VisRTX::HDRILight*
>(this->light);
160 Texture* texture = this->GetObject<Texture>({
"map" });
162 hdri->SetTexture(texture->texture);
175 VisRTX::Light* light =
nullptr;
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.