Torque3D Documentation / _generateds / sceneCameraState.h

sceneCameraState.h

Engine/source/scene/sceneCameraState.h

More...

Classes:

class

An object that combines all the state that is relevant to looking into the scene from a particular point of view.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _SCENECAMERASTATE_H_
 25#define _SCENECAMERASTATE_H_
 26
 27#ifndef _MATHUTIL_FRUSTUM_H_
 28#include "math/util/frustum.h"
 29#endif
 30
 31#ifndef _MRECT_H_
 32#include "math/mRect.h"
 33#endif
 34
 35#ifndef _MMATRIX_H_
 36#include "math/mMatrix.h"
 37#endif
 38
 39
 40/// An object that combines all the state that is relevant to looking into the
 41/// scene from a particular point of view.
 42class SceneCameraState
 43{
 44   protected:
 45
 46      /// The screen-space viewport rectangle.
 47      RectI mViewport;
 48
 49      /// The viewing frustum.
 50      Frustum mFrustum;
 51
 52      /// The inverse of the frustum's transform stored here for caching.
 53      MatrixF mWorldViewMatrix;
 54
 55      /// Actual head position (will be - eye pos)
 56      MatrixF mHeadWorldViewMatrix;
 57
 58      /// The projection matrix.
 59      MatrixF mProjectionMatrix;
 60
 61      /// World-space vector representing the view direction.
 62      Point3F mViewDirection;
 63
 64      /// Internal constructor.
 65      SceneCameraState() {}
 66
 67   public:
 68
 69      /// Freeze the given viewing state.
 70      ///
 71      /// @param viewport Screen-space viewport rectangle.
 72      /// @param frustum Camera frustum.
 73      /// @param worldView World->view matrix.
 74      /// @param projection Projection matrix.
 75      SceneCameraState( const RectI& viewport, const Frustum& frustum, const MatrixF& worldView, const MatrixF& projection );
 76
 77      /// Capture the view state from the current GFX state.
 78      static SceneCameraState fromGFX();
 79
 80      ///
 81      static SceneCameraState fromGFXWithViewport( const RectI& viewport );
 82
 83      /// Return the screen-space viewport rectangle.
 84      const RectI& getViewport() const { return mViewport; }
 85
 86      /// Return the camera frustum.
 87      const Frustum& getFrustum() const { return mFrustum; }
 88
 89      /// Return the view position.  This is a shortcut for getFrustum().getPosition().
 90      const Point3F& getViewPosition() const { return mFrustum.getPosition(); }
 91
 92      /// Return the world-space view vector.
 93      const Point3F& getViewDirection() const { return mViewDirection; }
 94
 95      /// Returns the world->view transform for the head (used to calculate various display metrics)
 96      const MatrixF& getHeadWorldViewMatrix() const { return mHeadWorldViewMatrix; }
 97
 98      /// Return the view->world transform.  This is a shortcut for getFrustum().getTransform().
 99      const MatrixF& getViewWorldMatrix() const { return mFrustum.getTransform(); }
100
101      /// Return the world->view transform.
102      const MatrixF& getWorldViewMatrix() const { return mWorldViewMatrix; }
103
104      /// Return the projection transform.
105      const MatrixF& getProjectionMatrix() const { return mProjectionMatrix; }
106};
107
108#endif // !_SCENECAMERASTATE_H_
109