20 VisRTX::Context* rtx = VisRTX_GetContext();
22 if (type ==
"perspective")
23 this->camera = rtx->CreatePerspectiveCamera();
24 else if (type ==
"orthographic")
25 this->camera = rtx->CreateOrthographicCamera();
32 this->camera->Release();
38 if (this->
GetVec3f({
"position" }, &pos))
40 this->camera->SetPosition(pos);
44 if (this->
GetVec3f({
"direction" }, &dir))
46 this->camera->SetDirection(dir);
52 this->camera->SetUp(up);
55 VisRTX::Vec2f imageBegin, imageEnd;
56 if (this->
GetVec2f({
"imageStart" }, &imageBegin) && this->
GetVec2f({
"imageEnd" }, &imageEnd))
58 this->camera->SetImageRegion(imageBegin, imageEnd);
61 if (this->camera->GetType() == VisRTX::CameraType::PERSPECTIVE)
63 VisRTX::PerspectiveCamera* pc =
dynamic_cast<VisRTX::PerspectiveCamera*
>(this->camera);
66 if (this->
GetFloat({
"fovy" }, &fovy))
72 if (this->
GetFloat({
"aspect" }, &aspect))
74 pc->SetAspect(aspect);
78 if (this->
GetFloat({
"focusDistance" }, &focalDistance))
80 pc->SetFocalDistance(focalDistance);
84 if (this->
GetFloat({
"apertureRadius" }, &apertureRadius))
86 pc->SetApertureRadius(apertureRadius);
90 else if (this->camera->GetType() == VisRTX::CameraType::ORTHOGRAPHIC)
92 VisRTX::OrthographicCamera* oc =
dynamic_cast<VisRTX::OrthographicCamera*
>(this->camera);
95 if (this->
GetFloat({
"height" }, &height))
97 oc->SetHeight(height);
101 if (this->
GetFloat({
"aspect" }, &aspect))
103 oc->SetAspect(aspect);
114 VisRTX::Camera* camera =
nullptr;
Camera(const std::string &type)
VisRTX::Vec2f GetVec2f(const std::vector< std::string > &ids, const VisRTX::Vec2f &defaultValue=VisRTX::Vec2f(), bool *found=nullptr) const
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