opensurgsim
AddRandomSphereBehavior.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef EXAMPLES_DROPPINGBALLS_ADDRANDOMSPHEREBEHAVIOR_H
17 #define EXAMPLES_DROPPINGBALLS_ADDRANDOMSPHEREBEHAVIOR_H
18 
19 #include <random>
20 
21 #include "SurgSim/Framework/Behavior.h"
22 
23 namespace SurgSim
24 {
25 
26 namespace Blocks
27 {
28 
32 {
33 public:
36  explicit AddRandomSphereBehavior(const std::string& name = "AddRandomSphereBehavior");
37 
40 
43  void update(double dt) override;
44 
45 protected:
47  bool doInitialize() override;
49  bool doWakeUp() override;
50 
51 private:
53  double m_totalTime;
55  int m_numElements;
57  std::default_random_engine m_generator;
59  std::uniform_real_distribution<double> m_distribution_xz;
61  std::uniform_real_distribution<double> m_distribution_y;
62 };
63 
64 }; // namespace Blocks
65 
66 }; // namespace SurgSim
67 
68 #endif //EXAMPLES_DROPPINGBALLS_ADDRANDOMSPHEREBEHAVIOR_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
bool doInitialize() override
Initialize the behavior.
Definition: AddRandomSphereBehavior.cpp:53
bool doWakeUp() override
Wakeup the behavior.
Definition: AddRandomSphereBehavior.cpp:58
AddRandomSphereBehavior(const std::string &name="AddRandomSphereBehavior")
Constructor.
Definition: AddRandomSphereBehavior.cpp:42
~AddRandomSphereBehavior()
Destructor.
Definition: AddRandomSphereBehavior.cpp:49
A behavior to add sphere elements into scene dynamically.
Definition: AddRandomSphereBehavior.h:31
Behaviors perform actions.
Definition: Behavior.h:40
void update(double dt) override
Update the behavior.
Definition: AddRandomSphereBehavior.cpp:63