16VTK_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:
75 if (this->
GetVec3f({
"color" }, &color))
76 this->light->SetColor(color);
79 if (this->
GetFloat({
"intensity" }, &intensity))
80 this->light->SetIntensity(intensity);
85 if (this->light->GetType() == VisRTX::LightType::DIRECTIONAL)
87 VisRTX::DirectionalLight* dirLight =
dynamic_cast<VisRTX::DirectionalLight*
>(this->light);
89 VisRTX::Vec3f direction;
90 if (this->
GetVec3f({
"direction" }, &direction))
91 dirLight->SetDirection(direction);
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);
105 VisRTX::Vec3f position;
106 if (this->
GetVec3f({
"position" }, &position))
107 sphereLight->SetPosition(position);
110 if (this->
GetFloat({
"radius" }, &radius))
111 sphereLight->SetRadius(radius);
117 else if (this->light->GetType() == VisRTX::LightType::SPOT)
119 VisRTX::SpotLight* spot =
dynamic_cast<VisRTX::SpotLight*
>(this->light);
121 VisRTX::Vec3f position;
122 if (this->
GetVec3f({
"position" }, &position))
123 spot->SetPosition(position);
125 VisRTX::Vec3f direction;
126 if (this->
GetVec3f({
"direction" }, &direction))
127 spot->SetDirection(direction);
130 if (this->
GetFloat({
"openingAngle" }, &openingAngle))
131 spot->SetOpeningAngle(openingAngle);
134 if (this->
GetFloat({
"penumbraAngle" }, &penumbraAngle))
135 spot->SetPenumbraAngle(penumbraAngle);
138 if (this->
GetFloat({
"radius" }, &radius))
139 spot->SetRadius(radius);
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;
150 if (this->
GetVec3f({
"position" }, &position) && this->
GetVec3f({
"edge1" }, &edge1) && this->
GetVec3f({
"edge2" }, &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);
167 VisRTX::Vec3f direction;
168 if (this->
GetVec3f({
"dir",
"direction" }, &direction))
169 hdri->SetDirection(direction);
178 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.