#ifndef vtk_m_rendering_View_h #define vtk_m_rendering_View_h #include #include #include namespace vtkm { namespace rendering { class View3D { public: vtkm::Vec Up; vtkm::Vec LookAt; vtkm::Vec Position; vtkm::Float32 NearPlane; vtkm::Float32 FarPlane; vtkm::Float32 FieldOfView; vtkm::Float32 AspectRatio; vtkm::Int32 Height; vtkm::Int32 Width; VTKM_CONT_EXPORT View3D() { Up[0] = 0.f; Up[1] = 1.f; Up[2] = 0.f; Position[0] = 0.f; Position[1] = 0.f; Position[2] = 0.f; LookAt[0] = 0.f; LookAt[1] = 0.f; LookAt[2] = 1.f; FieldOfView = 60.f; NearPlane = 1.0f; FarPlane = 100.0f; Height = 500; Width = 500; } VTKM_CONT_EXPORT vtkm::Matrix CreateViewMatrix() { vtkm::Normalize(Up); vtkm::Matrix viewMatrix; vtkm::MatrixIdentity(viewMatrix); vtkm::Vec viewDir = Position - LookAt; //looking down the neg z axis vtkm::Normalize(viewDir); vtkm::Vec right = vtkm::Cross(Up,viewDir); vtkm::Vec ru = vtkm::Cross(right,viewDir); vtkm::Normalize(ru); vtkm::Normalize(right); viewMatrix(0,0) = right[0]; viewMatrix(0,1) = right[1]; viewMatrix(0,2) = right[2]; viewMatrix(1,0) = ru[0]; viewMatrix(1,1) = ru[1]; viewMatrix(1,2) = ru[2]; viewMatrix(2,0) = viewDir[0]; viewMatrix(2,1) = viewDir[1]; viewMatrix(2,2) = viewDir[2]; viewMatrix(0,3) = -vtkm::dot(right,Position); viewMatrix(1,3) = -vtkm::dot(ru,Position); viewMatrix(2,3) = -vtkm::dot(viewDir,Position); return viewMatrix; } VTKM_CONT_EXPORT vtkm::Matrix CreateProjectionMatrix() { AspectRatio = vtkm::Float32(Width) / vtkm::Float32(Height); vtkm::Matrix projectionMatrix; vtkm::MatrixIdentity(projectionMatrix); vtkm::Float32 fovRad = (FieldOfView * 3.1415926f)/180.f; fovRad = vtkm::Tan( fovRad * 0.5f); std::cout<<"Field of View "<Up = other.Up; this->LookAt = other.LookAt; this->Position = other.Position; this->NearPlane = other.NearPlane; this->FarPlane = other.FarPlane; this->FieldOfView = other.FieldOfView; this->Height = other.Height; this->Width = other.Width; } VTKM_CONT_EXPORT static void PrintMatrix(const vtkm::Matrix &mat) { std::cout<