GteViewVolumeNode.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
10 using namespace gte;
11 
12 ViewVolumeNode::ViewVolumeNode(std::shared_ptr<ViewVolume> const& viewVolume)
13  :
14  mOnUpdate([](ViewVolumeNode*){})
15 {
16  SetViewVolume(viewVolume);
17 }
18 
19 void ViewVolumeNode::SetViewVolume(std::shared_ptr<ViewVolume> const& viewVolume)
20 {
21  mViewVolume = viewVolume;
22 
23  if (mViewVolume)
24  {
25  Matrix4x4<float> rotate;
26 #if defined(GTE_USE_MAT_VEC)
27  rotate.SetCol(0, mViewVolume->GetDVector());
28  rotate.SetCol(1, mViewVolume->GetUVector());
29  rotate.SetCol(2, mViewVolume->GetRVector());
30  rotate.SetCol(3, { 0.0f, 0.0f, 0.0f, 1.0f });
31 #else
32  rotate.SetRow(0, mViewVolume->GetDVector());
33  rotate.SetRow(1, mViewVolume->GetUVector());
34  rotate.SetRow(2, mViewVolume->GetRVector());
35  rotate.SetRow(3, { 0.0f, 0.0f, 0.0f, 1.0f });
36 #endif
39  Update();
40  }
41 }
42 
43 void ViewVolumeNode::UpdateWorldData(double applicationTime)
44 {
45  Node::UpdateWorldData(applicationTime);
46 
47  if (mViewVolume)
48  {
50 
51  Matrix4x4<float> const& rotate = worldTransform.GetHMatrix();
52 #if defined(GTE_USE_MAT_VEC)
53  Vector4<float> dVector = rotate.GetCol(0);
54  Vector4<float> uVector = rotate.GetCol(1);
55  Vector4<float> rVector = rotate.GetCol(2);
56 #else
57  Vector4<float> dVector = rotate.GetRow(0);
58  Vector4<float> uVector = rotate.GetRow(1);
59  Vector4<float> rVector = rotate.GetRow(2);
60 #endif
61  mViewVolume->SetFrame(position, dVector, uVector, rVector);
62  mOnUpdate(this);
63  }
64 }
virtual void UpdateWorldData(double applicationTime)
Definition: GteNode.cpp:156
Vector< NumRows, Real > GetCol(int c) const
Definition: GteMatrix.h:383
Matrix4x4< float > const & GetHMatrix() const
Definition: GteTransform.h:262
void SetViewVolume(std::shared_ptr< ViewVolume > const &viewVolume)
Transform worldTransform
Definition: GteSpatial.h:50
Vector< NumCols, Real > GetRow(int r) const
Definition: GteMatrix.h:372
void Update(double applicationTime=0.0, bool initiator=true)
Definition: GteSpatial.cpp:28
void SetCol(int c, Vector< NumRows, Real > const &vec)
Definition: GteMatrix.h:362
void SetRow(int r, Vector< NumCols, Real > const &vec)
Definition: GteMatrix.h:352
std::shared_ptr< ViewVolume > mViewVolume
std::function< void(ViewVolumeNode *)> mOnUpdate
void SetRotation(Matrix4x4< float > const &rotate)
virtual void UpdateWorldData(double applicationTime)
Vector4< float > GetTranslationW1() const
Definition: GteTransform.h:238
void SetTranslation(float x0, float x1, float x2)
Transform localTransform
Definition: GteSpatial.h:49
ViewVolumeNode(std::shared_ptr< ViewVolume > const &viewVolume=nullptr)


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:02