Triton
Visual simulation library for ocean rendering.
Camera.h
1// Copyright (c) 2011-2016 Sundog Software, LLC. All rights reserved worldwide.
2
3#ifndef TRITON_CAMERA_H
4#define TRITON_CAMERA_H
5
6#ifdef SWIG
7%module TritonCamera
8%import "Ocean.h"
9#define TRITONAPI
10%{
11#include "Camera.h"
12using namespace Triton;
13%}
14#endif
15
16#include "TritonCommon.h"
17#include "Vector3.h"
18#include "CoordinateSystem.h"
19
20#pragma pack(push)
21#pragma pack(8)
22
23namespace Triton
24{
25class Frustum;
27class Camera;
28
29template< class Param1 >
30class signal1;
31
32typedef signal1< const Camera* > CameraSignal;
33
36class Camera : public MemObject
37{
38public:
39 Camera(CoordinateSystem cs);
40 ~Camera();
41
54 void TRITONAPI SetCameraMatrix(const double *m, const double *explicitCameraPosition = 0);
55
61 void TRITONAPI SetProjectionMatrix(const double *p);
62
64 const double * TRITONAPI GetCameraMatrix() const {
65 return modelview;
66 }
67
69 const double * TRITONAPI GetProjectionMatrix() const {
70 return projection;
71 }
72
75 const double * TRITONAPI GetCameraPosition() const {
76 return camPos;
77 }
78
82 Vector3 TRITONAPI GetUpVector() const;
83
87 Vector3 TRITONAPI GetRightVector() const;
88
91 CoordinateSystem TRITONAPI GetCoordinateSystem(void) const {
92 return coordinateSystem;
93 }
94
101 bool TRITONAPI CullSphere(const Vector3& position, double radius) const;
102
103 bool TRITONAPI CullOrientedBoundingBox(const OrientedBoundingBox& obb) const;
104
108 bool TRITONAPI IsGeocentric() const {
109 return coordinateSystem < FLAT_ZUP;
110 }
111
113 void TRITONAPI SetName(const char* name);
114
116 const char* TRITONAPI GetName(void) const;
117
122
132 void TRITONAPI SetViewport(int x, int y, int width, int height);
133
144 bool TRITONAPI GetViewport(int& x, int& y, int& width, int& height) const;
145
147 void TRITONAPI SetRenderTarget(void* target);
148 void* TRITONAPI GetRenderTarget(void) const;
149
150 bool operator==(const Camera& rhs) const;
151 bool operator!=(const Camera& rhs) const;
152protected:
153 double modelview[16], projection[16];
154
155 double camPos[3];
156
157 void ExtractFrustum();
158
159 Frustum *frustum;
160
161 CoordinateSystem coordinateSystem;
162
163 Camera();
164
165 TRITON_STRING name;
166
167 int viewport[4];
168
169 void* target;
170};
171
172}
173
174#pragma pack(pop)
175
176
177#endif
Common typedefs and defines used within Triton.
A 3D Vector class and its operations.
Triton's public interface for specifying the camera properties.
Definition: Camera.h:37
Vector3 TRITONAPI GetUpVector() const
Retrieves a normalized vector pointing "up", based on the coordinate system specified in Environment:...
const double *TRITONAPI GetProjectionMatrix() const
Retrieves an array of 16 doubles representing the projection matrix passed in via SetProjectionMatrix...
Definition: Camera.h:69
CameraSignal * signal_CameraDestroyed
Called just before the camera is deleted.
Definition: Camera.h:121
Vector3 TRITONAPI GetRightVector() const
Retrieves a normalized vector pointing "right", based on the coordinate system specified in Environme...
const char *TRITONAPI GetName(void) const
Get the name.
bool TRITONAPI IsGeocentric() const
Returns whether the CoordinateSystem passed set on the camera is geocentric, indicating an elliptical...
Definition: Camera.h:108
CoordinateSystem TRITONAPI GetCoordinateSystem(void) const
Returns the CoordinateSystem passed set on the camera, indicating the up vector and the presence of a...
Definition: Camera.h:91
void TRITONAPI SetName(const char *name)
Associated a name with a camera.
void TRITONAPI SetProjectionMatrix(const double *p)
Sets the projection matrix used for rendering the ocean; this must be called every frame prior to cal...
const double *TRITONAPI GetCameraPosition() const
Retrieves an array of 3 doubles representing the X, Y, and Z position of the camera,...
Definition: Camera.h:75
void TRITONAPI SetViewport(int x, int y, int width, int height)
Informs Triton of the current viewport position and size.
bool TRITONAPI CullSphere(const Vector3 &position, double radius) const
Returns true if the given sphere lies within the view frustum, as defined by the modelview - projecti...
const double *TRITONAPI GetCameraMatrix() const
Retrieves an array of 16 doubles representing the modelview matrix passed in via SetCameraMatrix().
Definition: Camera.h:64
bool TRITONAPI GetViewport(int &x, int &y, int &width, int &height) const
Retrieves any viewport information previously set via SetViewport().
void TRITONAPI SetCameraMatrix(const double *m, const double *explicitCameraPosition=0)
Sets the modelview matrix used for rendering the ocean; this must be called every frame prior to call...
void TRITONAPI SetRenderTarget(void *target)
Abstractly set/get the render target.
This base class for all Triton objects intercepts the new and delete operators, routing them through ...
Definition: MemAlloc.h:71
An oriented bounding box defined by a center point and three axes.
Definition: OrientedBoundingBox.h:18
A 3D double-precision Vector class and its operations.
Definition: Vector3.h:36