2016-01-20 22:40:54 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2016-01-20 22:40:54 +00:00
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_rendering_raytracing_Camera_h
|
|
|
|
#define vtk_m_rendering_raytracing_Camera_h
|
2017-07-08 20:48:38 +00:00
|
|
|
|
2017-06-17 21:28:45 +00:00
|
|
|
#include <vtkm/cont/CoordinateSystem.h>
|
2016-06-02 19:04:01 +00:00
|
|
|
#include <vtkm/rendering/Camera.h>
|
2016-01-20 22:40:54 +00:00
|
|
|
#include <vtkm/rendering/raytracing/Ray.h>
|
2016-05-18 05:13:36 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace rendering
|
|
|
|
{
|
|
|
|
namespace raytracing
|
|
|
|
{
|
2017-06-17 21:28:45 +00:00
|
|
|
|
|
|
|
class VTKM_RENDERING_EXPORT Camera
|
2016-01-20 22:40:54 +00:00
|
|
|
{
|
|
|
|
private:
|
2023-05-17 18:38:43 +00:00
|
|
|
vtkm::Int32 Height = 500;
|
|
|
|
vtkm::Int32 Width = 500;
|
|
|
|
vtkm::Int32 SubsetWidth = 500;
|
|
|
|
vtkm::Int32 SubsetHeight = 500;
|
|
|
|
vtkm::Int32 SubsetMinX = 0;
|
|
|
|
vtkm::Int32 SubsetMinY = 0;
|
|
|
|
vtkm::Float32 FovX = 30.f;
|
|
|
|
vtkm::Float32 FovY = 30.f;
|
|
|
|
vtkm::Float32 Zoom = 1.f;
|
|
|
|
bool IsViewDirty = true;
|
|
|
|
|
|
|
|
vtkm::Vec3f_32 Look{ 0.f, 0.f, -1.f };
|
|
|
|
vtkm::Vec3f_32 Up{ 0.f, 1.f, 0.f };
|
|
|
|
vtkm::Vec3f_32 LookAt{ 0.f, 0.f, -1.f };
|
|
|
|
vtkm::Vec3f_32 Position{ 0.f, 0.f, 0.f };
|
2016-06-02 19:04:01 +00:00
|
|
|
vtkm::rendering::Camera CameraView;
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Matrix<vtkm::Float32, 4, 4> ViewProjectionMat;
|
2016-05-18 05:13:36 +00:00
|
|
|
|
2016-01-20 22:40:54 +00:00
|
|
|
public:
|
2017-06-17 21:28:45 +00:00
|
|
|
VTKM_CONT
|
|
|
|
std::string ToString();
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2023-05-17 18:38:43 +00:00
|
|
|
void SetParameters(const vtkm::rendering::Camera& camera, vtkm::Int32 width, vtkm::Int32 height);
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
void SetHeight(const vtkm::Int32& height);
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
vtkm::Int32 GetHeight() const;
|
2016-05-19 22:37:37 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
void SetWidth(const vtkm::Int32& width);
|
2016-05-19 22:37:37 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
vtkm::Int32 GetWidth() const;
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
vtkm::Int32 GetSubsetWidth() const;
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
vtkm::Int32 GetSubsetHeight() const;
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
void SetZoom(const vtkm::Float32& zoom);
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
vtkm::Float32 GetZoom() const;
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
void SetFieldOfView(const vtkm::Float32& degrees);
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
vtkm::Float32 GetFieldOfView() const;
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-07-31 16:20:38 +00:00
|
|
|
void SetUp(const vtkm::Vec3f_32& up);
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-07-31 16:20:38 +00:00
|
|
|
void SetPosition(const vtkm::Vec3f_32& position);
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Vec3f_32 GetPosition() const;
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Vec3f_32 GetUp() const;
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-07-31 16:20:38 +00:00
|
|
|
void SetLookAt(const vtkm::Vec3f_32& lookAt);
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Vec3f_32 GetLookAt() const;
|
2016-05-18 05:13:36 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
void ResetIsViewDirty();
|
2016-01-20 22:40:54 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
bool GetIsViewDirty() const;
|
2016-05-18 05:13:36 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2023-05-17 18:38:43 +00:00
|
|
|
void CreateRays(Ray<vtkm::Float32>& rays, const vtkm::Bounds& bounds);
|
2018-09-11 02:25:42 +00:00
|
|
|
|
2017-06-17 21:28:45 +00:00
|
|
|
VTKM_CONT
|
2023-05-17 18:38:43 +00:00
|
|
|
void CreateRays(Ray<vtkm::Float64>& rays, const vtkm::Bounds& bounds);
|
2016-05-18 05:13:36 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-06-17 21:28:45 +00:00
|
|
|
void GetPixelData(const vtkm::cont::CoordinateSystem& coords,
|
|
|
|
vtkm::Int32& activePixels,
|
|
|
|
vtkm::Float32& aveRayDistance);
|
|
|
|
|
2018-09-11 02:25:42 +00:00
|
|
|
template <typename Precision>
|
2023-05-17 18:38:43 +00:00
|
|
|
VTKM_CONT void CreateRaysImpl(Ray<Precision>& rays, const vtkm::Bounds& boundingBox);
|
2017-06-17 21:28:45 +00:00
|
|
|
|
2019-07-31 16:20:38 +00:00
|
|
|
void CreateDebugRay(vtkm::Vec2i_32 pixel, Ray<vtkm::Float32>& rays);
|
2017-06-17 21:28:45 +00:00
|
|
|
|
2019-07-31 16:20:38 +00:00
|
|
|
void CreateDebugRay(vtkm::Vec2i_32 pixel, Ray<vtkm::Float64>& rays);
|
2017-06-17 21:28:45 +00:00
|
|
|
|
|
|
|
bool operator==(const Camera& other) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
template <typename Precision>
|
2023-05-17 18:38:43 +00:00
|
|
|
VTKM_CONT void CreateDebugRayImp(vtkm::Vec2i_32 pixel, Ray<Precision>& rays);
|
|
|
|
|
2017-06-17 21:28:45 +00:00
|
|
|
VTKM_CONT
|
|
|
|
void FindSubset(const vtkm::Bounds& bounds);
|
|
|
|
|
2023-05-17 18:38:43 +00:00
|
|
|
VTKM_CONT
|
|
|
|
void WriteSettingsToLog();
|
|
|
|
|
2018-09-11 02:25:42 +00:00
|
|
|
template <typename Precision>
|
2017-06-17 21:28:45 +00:00
|
|
|
VTKM_CONT void UpdateDimensions(Ray<Precision>& rays,
|
2017-10-26 14:58:02 +00:00
|
|
|
const vtkm::Bounds& boundingBox,
|
|
|
|
bool ortho2D);
|
2016-05-18 05:13:36 +00:00
|
|
|
|
2016-01-20 22:40:54 +00:00
|
|
|
}; // class camera
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} //namespace vtkm::rendering::raytracing
|
2016-04-18 20:42:59 +00:00
|
|
|
#endif //vtk_m_rendering_raytracing_Camera_h
|