AGX Dynamics 2.42.2.1
Loading...
Searching...
No Matches
agxGL::Camera Class Reference

#include <Camera.h>

+ Inheritance diagram for agxGL::Camera:

Public Types

enum  Projection { PERSPECTIVE , ORTHOGONAL }
 
- Public Types inherited from agx::Component
typedef Event2< Component *, Object * > ObjectEvent
 Event when adding removing child objects.
 
typedef Callback1< Object * > TraverseCallback
 
- Public Types inherited from agx::Object
typedef agx::observer_ptr< const EventEventConstObserver
 
typedef agx::ref_ptr< const EventEventConstRef
 
typedef agx::observer_ptr< EventEventObserver
 
typedef agx::Vector< EventObserverEventObserverVector
 
typedef agx::VectorPOD< Event * > EventPtrVector
 
typedef agx::ref_ptr< EventEventRef
 
typedef agx::Vector< EventRefEventRefVector
 

Public Member Functions

 Camera (const agx::Name &name="camera")
 
void alignUpVector (const agx::Vec3 &up=agx::Vec3(0, 0, 1))
 
void calculatePickRay (const agx::Vec2 &mousePoint, agx::Vec3 &pos, agx::Vec3 &direction)
 
virtual void configure (agx::TiXmlElement *eCamera) override
 
agx::Vec3 getForwardVector () const
 
const agx::Matrix4x4getProjectionMatrix () const
 Get the projection matrix.
 
bool getProjectionMatrixAsFrustum (double &left, double &right, double &bottom, double &top, double &zNear, double &zFar) const
 Get the frustum setting of a perspective projection matrix.
 
bool getProjectionMatrixAsOrtho (double &left, double &right, double &bottom, double &top, double &zNear, double &zFar) const
 Get the orthographic settings of the orthographic projection matrix.
 
bool getProjectionMatrixAsPerspective (double &fovy, double &aspectRatio, double &zNear, double &zFar) const
 Get the frustum setting of a symmetric perspective projection matrix.
 
const agx::Matrix4x4getViewMatrix () const
 Get the view matrix.
 
void getViewMatrixAsLookAt (agx::Vec3 &eye, agx::Vec3 &center, agx::Vec3 &up, double lookDistance=1.0) const
 Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt.
 
void move (const agx::Vec3 &offset)
 
void moveLocal (const agx::Vec3 &offset)
 
void render ()
 
void setProjectionMatrix (const agx::Matrix4x4 &matrix)
 Set the projection matrix.
 
void setProjectionMatrixAsFrustum (double left, double right, double bottom, double top, double zNear, double zFar)
 Set to a perspective projection.
 
void setProjectionMatrixAsOrtho (double left, double right, double bottom, double top, double zNear, double zFar)
 Set to an orthographic projection.
 
void setProjectionMatrixAsPerspective (double fovy, double aspectRatio, double zNear, double zFar)
 Create a symmetrical perspective projection, See OpenGL gluPerspective documentation for further details.
 
void setViewMatrix (const agx::Matrix4x4 &matrix)
 Set the view matrix.
 
void setViewMatrixAsLookAt (const agx::Vec3 &eye, const agx::Vec3 &center, const agx::Vec3 &up)
 Set to the position and orientation of view matrix, using the same convention as gluLookAt.
 
void setViewPort (unsigned width, unsigned height)
 
- Public Member Functions inherited from agx::Component
 Component (const agx::Name &name=agx::Name(), agx::Model *model=agx::Component::ClassModel(), agx::Device *device=nullptr)
 
virtual void addObject (agx::Object *object, bool assignContext=true)
 Add an object to the component.
 
virtual String autoComplete (const String &partialName, StringVector &matchingNames) const
 
virtual void buildNavigationTree (agxJson::Value &eNode) const override
 
void configure (Model *model)
 
virtual void configure (TiXmlElement *eComponent) override
 
agx::DevicegetDevice ()
 
template<typename T >
T * getDevice ()
 
const agx::DevicegetDevice () const
 
template<typename T >
const T * getDevice () const
 
size_t getNumObjects (const agx::Name &name) const
 
agx::ObjectgetObject (const agx::Name &name, agx::Model *model, size_t index=0)
 
const agx::ObjectgetObject (const agx::Name &name, agx::Model *model, size_t index=0) const
 
agx::ObjectgetObject (const agx::Name &name, size_t index=0)
 
template<typename T >
T * getObject (const agx::Name &name, size_t index=0)
 
const agx::ObjectgetObject (const agx::Name &name, size_t index=0) const
 
template<typename T >
const T * getObject (const agx::Name &name, size_t index=0) const
 
const agx::ObjectRefVectorgetObjects () const
 
template<typename T >
void getObjects (agx::ObjectPtrVector &result, bool recursive=false) const
 Returns All child objects of a specified type in the result container.
 
void getObjects (agx::ObjectPtrVector &result, const agx::Model *model, bool recursive=false) const
 
virtual ObjectgetResourceImpl (const Path &path, agx::Model *model) override
 
virtual void printSubtree () const override
 
void printSubtree (std::ostream &stream, int depth=0) const
 
virtual void rebind () override
 
void removeAllObjects ()
 Remove all components.
 
virtual void removeObject (agx::Object *object)
 Remove an object from the component.
 
void removeObject (const agx::Name &name, size_t index=0)
 Remove an object with a specified name (and optional index) from the component.
 
virtual void snapshot (TiXmlNode *eParent, const String &directory) const override
 
void traverse (ComponentVisitor *)
 
void traverse (const TraverseCallback &callback)
 
- Public Member Functions inherited from agx::Object
 Object (const Name &name=Name(), Model *model=Object::ClassModel())
 
void addListener (EventListener *listener)
 
virtual void buildNavigationTree (agxJson::Value &eNode) const
 
virtual void configure (TiXmlElement *)
 
agx::String fullName () const
 
agx::String fullPath () const
 
agx::String fullPath (const agx::Object *root) const
 
template<typename T >
T * getAutoScopedResource (const agx::Path &path)
 
template<typename T >
const T * getAutoScopedResource (const agx::Path &path) const
 
agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr) const
 
agx::ObjectgetContext ()
 
template<typename T >
T * getContext ()
 
const agx::ObjectgetContext () const
 
template<typename T >
const T * getContext () const
 
agx::UInt32 getId () const
 
const agx::NamegetImplementationName () const
 
agx::ModelgetModel ()
 
const agx::ModelgetModel () const
 
const agx::NamegetName () const
 
agx::ObjectgetNextSibling ()
 
const agx::ObjectgetNextSibling () const
 
agx::Path getPath () const
 
agx::Path getPath (const agx::Object *root) const
 
template<typename T >
T * getResource (const agx::Path &path)
 
template<typename T >
const T * getResource (const agx::Path &path) const
 
agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr) const
 
virtual agx::ObjectgetResourceImpl (const agx::Path &path, agx::Model *model)
 
agx::ObjectgetRootContext ()
 
const agx::ObjectgetRootContext () const
 
bool hasListener (EventListener *listener)
 
bool hasParent (const agx::Object *node) const
 
bool isUnique () const
 
virtual void printSubtree () const
 
virtual void rebind ()
 
void removeListener (EventListener *listener)
 
virtual void save (TiXmlElement *) const
 
virtual void setContext (agx::Object *context)
 
void setId (UInt32 id)
 
void setModel (agx::Model *model)
 Set the object model (handled automatically).
 
void setName (const agx::Name &name)
 Set the name of the object.
 
virtual void snapshot (TiXmlNode *, const String &) const
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Static Public Member Functions

static agx::ModelClassModel ()
 
static CameragetActiveCamera ()
 
static Cameraload (agx::TiXmlElement *eCamera, agx::Device *device)
 
static CameramainCamera ()
 
static void setMainCamera (Camera *camera)
 
- Static Public Member Functions inherited from agx::Component
static Component_load (TiXmlElement *eComponent, Device *device)
 
static agx::ModelClassModel ()
 
static Componentload (const Path &path, const Name &implementation, Device *device, const Path &_namespace=Path())
 
static Componentload (const String &path, const Path &_namespace=Path())
 
static Componentload (const String &path, Device *device, const Path &_namespace=Path())
 
static Componentload (TiXmlElement *eComponent, Device *device)
 
- Static Public Member Functions inherited from agx::Object
static agx::ModelClassModel ()
 
static agx::String generateName (const agx::String &bindPath)
 
static const HashSet< Object * > & getActiveObjects ()
 
static bool getEnableRebind ()
 Should rebinding be allowed? Right now a global setting.
 
static Objectload (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
static Objectload (const String &path, Device *device, const String &type="", size_t instance=0)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type="", size_t instance=0)
 
static void load (const String &path, Device *device, ObjectPtrVector &loadedObjects)
 
static Objectload (TiXmlElement *eObject, Device *device)
 
template<typename T >
static T * load (TiXmlElement *eObject, Device *device)
 
static TiXmlDocument openDocument (const String &path)
 
static void setEnableRebind (bool flag)
 Sets if rebinding of objects should be allowed (Right now a global setting).
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~Camera ()
 
void transformCallback (agxData::Value *)
 
void updateFov (agxData::Value *)
 
- Protected Member Functions inherited from agx::Component
virtual ~Component ()
 
String expandAutoCompletionMatch (const String &query, const StringVector &matchingNames) const
 
void setDevice (Device *device)
 
- Protected Member Functions inherited from agx::Object
virtual ~Object ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

agx::ClockRef m_clock
 
agxData::ValueRefT< agx::Realm_fovX
 
agxData::ValueRefT< agx::Realm_fovY
 
agxData::ValueRefT< agx::Matrix4x4m_modelViewProjectionMatrix
 
agxData::Value::Event::CallbackType m_projectionCallback
 
agxData::ValueRefT< agx::Matrix4x4m_projectionMatrix
 
agx::Real m_ratio
 
agx::TaskRef m_renderTask
 
agxData::ValueRefT< agx::AffineMatrix4x4m_transform
 
agxData::Value::Event::CallbackType m_transformCallback
 
agxData::ValueRefT< agx::Matrix4x4m_viewMatrix
 
agxData::ValueRefT< agx::UIntm_windowHeight
 
agxData::ValueRefT< agx::UIntm_windowWidth
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Public Attributes inherited from agx::Component
ObjectEvent addObjectEvent
 
ObjectEvent removeObjectEvent
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

Definition at line 49 of file agxGL/Camera.h.

Member Enumeration Documentation

◆ Projection

Enumerator
PERSPECTIVE 
ORTHOGONAL 

Definition at line 60 of file agxGL/Camera.h.

Constructor & Destructor Documentation

◆ Camera()

agxGL::Camera::Camera ( const agx::Name name = "camera")

◆ ~Camera()

virtual agxGL::Camera::~Camera ( )
protectedvirtual

Member Function Documentation

◆ alignUpVector()

void agxGL::Camera::alignUpVector ( const agx::Vec3 up = agx::Vec3(0, 0, 1))

◆ calculatePickRay()

void agxGL::Camera::calculatePickRay ( const agx::Vec2 mousePoint,
agx::Vec3 pos,
agx::Vec3 direction 
)

◆ ClassModel()

static agx::Model * agxGL::Camera::ClassModel ( )
static

◆ configure()

virtual void agxGL::Camera::configure ( agx::TiXmlElement *  eCamera)
overridevirtual

◆ getActiveCamera()

static Camera * agxGL::Camera::getActiveCamera ( )
static

◆ getForwardVector()

agx::Vec3 agxGL::Camera::getForwardVector ( ) const

◆ getProjectionMatrix()

const agx::Matrix4x4 & agxGL::Camera::getProjectionMatrix ( ) const
inline

Get the projection matrix.

Definition at line 187 of file agxGL/Camera.h.

References m_projectionMatrix.

Referenced by agxOSG::CameraSynchronization::operator()().

◆ getProjectionMatrixAsFrustum()

bool agxGL::Camera::getProjectionMatrixAsFrustum ( double &  left,
double &  right,
double &  bottom,
double &  top,
double &  zNear,
double &  zFar 
) const

Get the frustum setting of a perspective projection matrix.

Returns false if matrix is not a perspective matrix, where parameter values are undefined.

◆ getProjectionMatrixAsOrtho()

bool agxGL::Camera::getProjectionMatrixAsOrtho ( double &  left,
double &  right,
double &  bottom,
double &  top,
double &  zNear,
double &  zFar 
) const

Get the orthographic settings of the orthographic projection matrix.

Returns false if matrix is not an orthographic matrix, where parameter values are undefined.

◆ getProjectionMatrixAsPerspective()

bool agxGL::Camera::getProjectionMatrixAsPerspective ( double &  fovy,
double &  aspectRatio,
double &  zNear,
double &  zFar 
) const

Get the frustum setting of a symmetric perspective projection matrix.

Returns false if matrix is not a perspective matrix, where parameter values are undefined. Note, if matrix is not a symmetric perspective matrix then the shear will be lost. Asymmetric matrices occur when stereo, power walls, caves and reality center display are used. In these configurations one should use the 'getProjectionMatrixAsFrustum' method instead.

◆ getViewMatrix()

const agx::Matrix4x4 & agxGL::Camera::getViewMatrix ( ) const
inline

Get the view matrix.

Definition at line 188 of file agxGL/Camera.h.

References m_viewMatrix.

Referenced by agxOSG::CameraSynchronization::operator()().

◆ getViewMatrixAsLookAt()

void agxGL::Camera::getViewMatrixAsLookAt ( agx::Vec3 eye,
agx::Vec3 center,
agx::Vec3 up,
double  lookDistance = 1.0 
) const

Get to the position and orientation of a modelview matrix, using the same convention as gluLookAt.

◆ load()

static Camera * agxGL::Camera::load ( agx::TiXmlElement *  eCamera,
agx::Device device 
)
static

◆ mainCamera()

static Camera * agxGL::Camera::mainCamera ( )
static

◆ move()

void agxGL::Camera::move ( const agx::Vec3 offset)

◆ moveLocal()

void agxGL::Camera::moveLocal ( const agx::Vec3 offset)

◆ render()

void agxGL::Camera::render ( )

◆ setMainCamera()

static void agxGL::Camera::setMainCamera ( Camera camera)
static

◆ setProjectionMatrix()

void agxGL::Camera::setProjectionMatrix ( const agx::Matrix4x4 matrix)

Set the projection matrix.

Can be thought of as setting the lens of a camera.

Referenced by agxOSG::CameraSynchronization::operator()().

◆ setProjectionMatrixAsFrustum()

void agxGL::Camera::setProjectionMatrixAsFrustum ( double  left,
double  right,
double  bottom,
double  top,
double  zNear,
double  zFar 
)

Set to a perspective projection.

See OpenGL glFrustum documentation for further details.

◆ setProjectionMatrixAsOrtho()

void agxGL::Camera::setProjectionMatrixAsOrtho ( double  left,
double  right,
double  bottom,
double  top,
double  zNear,
double  zFar 
)

Set to an orthographic projection.

See OpenGL glOrtho for documentation further details.

◆ setProjectionMatrixAsPerspective()

void agxGL::Camera::setProjectionMatrixAsPerspective ( double  fovy,
double  aspectRatio,
double  zNear,
double  zFar 
)

Create a symmetrical perspective projection, See OpenGL gluPerspective documentation for further details.

Aspect ratio is defined as width/height.

◆ setViewMatrix()

void agxGL::Camera::setViewMatrix ( const agx::Matrix4x4 matrix)

Set the view matrix.

Can be thought of as setting the position of the world relative to the camera in camera coordinates.

Referenced by agxOSG::CameraSynchronization::operator()().

◆ setViewMatrixAsLookAt()

void agxGL::Camera::setViewMatrixAsLookAt ( const agx::Vec3 eye,
const agx::Vec3 center,
const agx::Vec3 up 
)

Set to the position and orientation of view matrix, using the same convention as gluLookAt.

◆ setViewPort()

void agxGL::Camera::setViewPort ( unsigned  width,
unsigned  height 
)

◆ transformCallback()

void agxGL::Camera::transformCallback ( agxData::Value )
protected

◆ updateFov()

void agxGL::Camera::updateFov ( agxData::Value )
protected

Member Data Documentation

◆ m_clock

agx::ClockRef agxGL::Camera::m_clock
protected

Definition at line 175 of file agxGL/Camera.h.

◆ m_fovX

agxData::ValueRefT<agx::Real> agxGL::Camera::m_fovX
protected

Definition at line 167 of file agxGL/Camera.h.

◆ m_fovY

agxData::ValueRefT<agx::Real> agxGL::Camera::m_fovY
protected

Definition at line 168 of file agxGL/Camera.h.

◆ m_modelViewProjectionMatrix

agxData::ValueRefT<agx::Matrix4x4> agxGL::Camera::m_modelViewProjectionMatrix
protected

Definition at line 166 of file agxGL/Camera.h.

◆ m_projectionCallback

agxData::Value::Event::CallbackType agxGL::Camera::m_projectionCallback
protected

Definition at line 180 of file agxGL/Camera.h.

◆ m_projectionMatrix

agxData::ValueRefT<agx::Matrix4x4> agxGL::Camera::m_projectionMatrix
protected

Definition at line 165 of file agxGL/Camera.h.

Referenced by getProjectionMatrix().

◆ m_ratio

agx::Real agxGL::Camera::m_ratio
protected

Definition at line 174 of file agxGL/Camera.h.

◆ m_renderTask

agx::TaskRef agxGL::Camera::m_renderTask
protected

Definition at line 181 of file agxGL/Camera.h.

◆ m_transform

agxData::ValueRefT<agx::AffineMatrix4x4> agxGL::Camera::m_transform
protected

Definition at line 163 of file agxGL/Camera.h.

◆ m_transformCallback

agxData::Value::Event::CallbackType agxGL::Camera::m_transformCallback
protected

Definition at line 179 of file agxGL/Camera.h.

◆ m_viewMatrix

agxData::ValueRefT<agx::Matrix4x4> agxGL::Camera::m_viewMatrix
protected

Definition at line 164 of file agxGL/Camera.h.

Referenced by getViewMatrix().

◆ m_windowHeight

agxData::ValueRefT<agx::UInt> agxGL::Camera::m_windowHeight
protected

Definition at line 170 of file agxGL/Camera.h.

◆ m_windowWidth

agxData::ValueRefT<agx::UInt> agxGL::Camera::m_windowWidth
protected

Definition at line 169 of file agxGL/Camera.h.


The documentation for this class was generated from the following file: