Overte C++ Documentation
FancyCamera.h
1 //
2 // FancyCamera.h
3 // interface/src
4 //
5 // Copyright 2017 High Fidelity, Inc.
6 //
7 // Distributed under the Apache License, Version 2.0.
8 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 //
10 
11 #ifndef hifi_FancyCamera_h
12 #define hifi_FancyCamera_h
13 
14 #include <shared/Camera.h>
15 
16 #include <EntityTypes.h>
17 
18 class FancyCamera : public Camera {
19  Q_OBJECT
20 
21  /*@jsdoc
22  * The <code>Camera</code> API provides access to the "camera" that defines your view in desktop and HMD display modes.
23  * The Overte camera has axes <code>x</code> = right, <code>y</code> = up, <code>-z</code> = forward.
24  *
25  * @namespace Camera
26  *
27  * @hifi-interface
28  * @hifi-client-entity
29  * @hifi-avatar
30  *
31  * @property {Vec3} position - The position of the camera. You can set this value only when the camera is in independent
32  * mode.
33  * @property {Quat} orientation - The orientation of the camera. You can set this value only when the camera is in
34  * independent mode.
35  * @property {Camera.Mode} mode - The camera mode.
36  * @property {ViewFrustum} frustum - The camera frustum.
37  * @property {Uuid} cameraEntity - The ID of the entity that is used for the camera position and orientation when the
38  * camera is in entity mode.
39  * @property {boolean} captureMouse - The mouse capture state. When <code>true</code>, the mouse is invisible and cannot leave the bounds of
40  * Interface, as long as Interface is the active window and no menu item is selected. When <code>false</code>, the mouse
41  * behaves normally.
42  * @property {number} sensitivity - The current camera sensitivity. Must be positive.
43  */
44  Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
45 
46 public:
47  FancyCamera() : Camera() {}
48 
49  EntityItemPointer getCameraEntityPointer() const { return _cameraEntity; }
50  PickRay computePickRay(float x, float y) const override;
51 
52 
53 public slots:
54  /*@jsdoc
55  * Gets the ID of the entity that the camera is set to follow (i.e., use the position and orientation from) when it's in
56  * entity mode. You can also get the entity ID using the {@link Camera|Camera.cameraEntity} property.
57  * @function Camera.getCameraEntity
58  * @returns {Uuid} The ID of the entity that the camera is set to follow when in entity mode; <code>null</code> if no
59  * camera entity has been set.
60  */
61  QUuid getCameraEntity() const;
62 
63  /*@jsdoc
64  * Sets the entity that the camera should follow (i.e., use the position and orientation from) when it's in entity mode.
65  * You can also set the entity using the {@link Camera|Camera.cameraEntity} property.
66  * @function Camera.setCameraEntity
67  * @param {Uuid} entityID - The entity that the camera should follow when it's in entity mode.
68  * @example <caption>Move your camera to the position and orientation of the closest entity.</caption>
69  * Camera.setModeString("entity");
70  * var entity = Entities.findClosestEntity(MyAvatar.position, 100.0);
71  * Camera.setCameraEntity(entity);
72  */
73  void setCameraEntity(QUuid entityID);
74 
75 private:
76  EntityItemPointer _cameraEntity;
77 };
78 
79 #endif // hifi_FancyCamera_h