Ocean
Experience.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_INTERACTION_EXPERIENCES_EXPERIENCE_H
9 #define META_OCEAN_INTERACTION_EXPERIENCES_EXPERIENCE_H
10 
12 
14 
15 #include "ocean/rendering/Engine.h"
16 
17 namespace Ocean
18 {
19 
20 namespace Interaction
21 {
22 
23 namespace Experiences
24 {
25 
26 /**
27  * This class is the base class for all experiences defined via the interaction plugin mechanism.
28  * An experience can be anything which combines rendering with user input and sensor information like e.g., 6-DOF trackers.<br>
29  * This base class mainly defines several event functions which can be used to realize an experience.
30  * @ingroup interactionexperiences
31  */
32 class OCEAN_INTERACTION_EXPERIENCES_EXPORT Experience
33 {
34  friend class ExperiencesLibrary;
35 
36  public:
37 
38  /**
39  * Destructs the experience.
40  */
41  virtual ~Experience() = default;
42 
43  /**
44  * Loads this experience.
45  * @param userInterface The application's UI elements
46  * @param engine Current engine
47  * @param timestamp Recent timestamp
48  * @param properties Optional properties for the experience
49  * @return True, if succeeded
50  */
51  virtual bool load(const UserInterface& userInterface, const Rendering::EngineRef& engine, const Timestamp timestamp, const std::string& properties = std::string());
52 
53  /**
54  * Unloads this experience.
55  * @see Library::unload().
56  */
57  virtual bool unload(const UserInterface& userInterface, const Rendering::EngineRef& engine, const Timestamp timestamp);
58 
59  /**
60  * Pre update interaction function.
61  * @see Library::preUpdate().
62  */
63  virtual Timestamp preUpdate(const UserInterface& userInterface, const Rendering::EngineRef& engine, const Rendering::ViewRef& view, const Timestamp timestamp);
64 
65  /**
66  * Post update interaction function.
67  * @see Library::postUpdate().
68  */
69  virtual void postUpdate(const UserInterface& userInterface, const Rendering::EngineRef& engine, const Rendering::ViewRef& view, const Timestamp timestamp);
70 
71  /**
72  * Mouse press event function.
73  * @see Library::onMousePress().
74  */
75  virtual void onMousePress(const UserInterface& userInterface, const Rendering::EngineRef& engine, const std::string& button, const Vector2& screenPosition, const Line3& ray, const Timestamp timestamp);
76 
77  /**
78  * Mouse move event function.
79  * @see Library::onMouseMove().
80  */
81  virtual void onMouseMove(const UserInterface& userInterface, const Rendering::EngineRef& engine, const std::string& button, const Vector2& screenPosition, const Line3& ray, const Timestamp timestamp);
82 
83  /**
84  * Mouse release event function.
85  * @see Library::onMouseRelease().
86  */
87  virtual void onMouseRelease(const UserInterface& userInterface, const Rendering::EngineRef& engine, const std::string& button, const Vector2& screenPosition, const Line3& ray, const Timestamp timestamp);
88 
89  /**
90  * Key press function.
91  * @see Library::onKeyPress().
92  */
93  virtual void onKeyPress(const UserInterface& userInterface, const Rendering::EngineRef& engine, const std::string& key, const Timestamp timestamp);
94 
95  /**
96  * Key release function.
97  * @see Library::onKeyRelease().
98  */
99  virtual void onKeyRelease(const UserInterface& userInterface, const Rendering::EngineRef& engine, const std::string& key, const Timestamp timestamp);
100 
101  protected:
102 
103  /**
104  * Creates a new experience object.
105  */
106  Experience() = default;
107 
108  /**
109  * Event function before the experience is loaded.
110  * @param userInterface The application's UI elements
111  * @param engine Current engine
112  * @param timestamp Recent timestmap
113  * @param properties Optional properties for the experience
114  * @return True, if succeeded
115  */
116  virtual bool preLoad(const UserInterface& userInterface, const Rendering::EngineRef& engine, const Timestamp timestamp, const std::string& properties);
117 
118  /**
119  * Event function after the experience is unloaded.
120  * @see Library::unload().
121  */
122  virtual bool postUnload(const UserInterface& userInterface, const Rendering::EngineRef& engine, const Timestamp timestamp);
123 
124  /**
125  * Explicitly releases this experience.
126  */
127  virtual void release();
128 };
129 
130 } // namespace Experiences
131 
132 } // namespace Interaction
133 
134 } // namespace Ocean
135 
136 #endif // META_OCEAN_INTERACTION_EXPERIENCES_EXPERIENCE_H
This class is the base class for all experiences defined via the interaction plugin mechanism.
Definition: Experience.h:33
virtual void onKeyPress(const UserInterface &userInterface, const Rendering::EngineRef &engine, const std::string &key, const Timestamp timestamp)
Key press function.
Experience()=default
Creates a new experience object.
virtual void onKeyRelease(const UserInterface &userInterface, const Rendering::EngineRef &engine, const std::string &key, const Timestamp timestamp)
Key release function.
virtual ~Experience()=default
Destructs the experience.
virtual bool load(const UserInterface &userInterface, const Rendering::EngineRef &engine, const Timestamp timestamp, const std::string &properties=std::string())
Loads this experience.
virtual bool unload(const UserInterface &userInterface, const Rendering::EngineRef &engine, const Timestamp timestamp)
Unloads this experience.
virtual bool postUnload(const UserInterface &userInterface, const Rendering::EngineRef &engine, const Timestamp timestamp)
Event function after the experience is unloaded.
virtual Timestamp preUpdate(const UserInterface &userInterface, const Rendering::EngineRef &engine, const Rendering::ViewRef &view, const Timestamp timestamp)
Pre update interaction function.
virtual void postUpdate(const UserInterface &userInterface, const Rendering::EngineRef &engine, const Rendering::ViewRef &view, const Timestamp timestamp)
Post update interaction function.
virtual void onMouseRelease(const UserInterface &userInterface, const Rendering::EngineRef &engine, const std::string &button, const Vector2 &screenPosition, const Line3 &ray, const Timestamp timestamp)
Mouse release event function.
virtual void onMouseMove(const UserInterface &userInterface, const Rendering::EngineRef &engine, const std::string &button, const Vector2 &screenPosition, const Line3 &ray, const Timestamp timestamp)
Mouse move event function.
virtual void onMousePress(const UserInterface &userInterface, const Rendering::EngineRef &engine, const std::string &button, const Vector2 &screenPosition, const Line3 &ray, const Timestamp timestamp)
Mouse press event function.
virtual void release()
Explicitly releases this experience.
virtual bool preLoad(const UserInterface &userInterface, const Rendering::EngineRef &engine, const Timestamp timestamp, const std::string &properties)
Event function before the experience is loaded.
This class implements the experiences interaction library object.
Definition: ExperiencesLibrary.h:34
This class holds UI elements of the application from which the interaction is executed.
Definition: UserInterface.h:28
This class implements an infinite line in 3D space.
Definition: Line3.h:70
This class implements a timestamp.
Definition: Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15