Overte C++ Documentation
BillboardMode.h
1 //
2 // Created by Sam Gondelman on 11/30/18.
3 // Copyright 2018 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #ifndef hifi_BillboardMode_h
10 #define hifi_BillboardMode_h
11 
12 #include <functional>
13 
14 #include "QString"
15 
16 #include "glm/glm.hpp"
17 #include "glm/gtc/quaternion.hpp"
18 
19 /*@jsdoc
20  * <p>How an entity is billboarded.</p>
21  * <table>
22  * <thead>
23  * <tr><th>Value</th><th>Description</th></tr>
24  * </thead>
25  * <tbody>
26  * <tr><td><code>"none"</code></td><td>The entity will not be billboarded.</td></tr>
27  * <tr><td><code>"yaw"</code></td><td>The entity will yaw, but not pitch, to face the camera. Its actual rotation will be
28  * ignored.</td></tr>
29  * <tr><td><code>"full"</code></td><td>The entity will yaw and pitch to face the camera. Its actual rotation will be
30  * ignored.</td></tr>
31  * </tbody>
32  * </table>
33  * @typedef {string} BillboardMode
34  */
35 
36 enum class BillboardMode {
37  NONE = 0,
38  YAW,
39  FULL
40 };
41 
42 class BillboardModeHelpers {
43 public:
44  static QString getNameForBillboardMode(BillboardMode mode);
45 
46  static void setBillboardRotationOperator(std::function<glm::quat(const glm::vec3&, const glm::quat&,
47  BillboardMode, const glm::vec3&, bool)> getBillboardRotationOperator);
48  static glm::quat getBillboardRotation(const glm::vec3& position, const glm::quat& rotation, BillboardMode billboardMode,
49  const glm::vec3& frustumPos, bool rotate90x = false);
50  static void setPrimaryViewFrustumPositionOperator(std::function<glm::vec3()> getPrimaryViewFrustumPositionOperator);
51  static glm::vec3 getPrimaryViewFrustumPosition() { return _getPrimaryViewFrustumPositionOperator(); }
52 
53 private:
54  static std::function<glm::quat(const glm::vec3&, const glm::quat&, BillboardMode, const glm::vec3&, bool)> _getBillboardRotationOperator;
55  static std::function<glm::vec3()> _getPrimaryViewFrustumPositionOperator;
56 };
57 
58 #endif // hifi_BillboardMode_h