AGX Dynamics  2.35.0.1
UniformGravityField.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_UNIFORMGRAVITYFIELD_H
18 #define AGX_UNIFORMGRAVITYFIELD_H
19 
20 #include <agx/GravityField.h>
21 
22 #include <agxData/Value.h>
23 
24 namespace agx
25 {
27 
33  {
34  public:
40 
42  void setGravity( const Vec3& gravity );
43 
45  Vec3 getGravity( ) const;
46 
51  virtual Vec3 calculateGravity( const Vec3& position ) const override;
52 
54  virtual Task* createRigidBodyTask() override;
55 
57  virtual Task* createParticleSystemTask() override;
58 
59 
60  protected:
62 
64 
65  private:
66  agxData::ValueRefT<Vec3> m_gravity;
67  };
68 
69 
71 
73  {
74  return m_gravity->get();
75  }
76 
77  inline void UniformGravityField::setGravity( const Vec3& gravity )
78  {
79  m_gravity->set(gravity);
80  }
81 
83  {
84  return m_gravity->get();
85  }
86 } //namespace agx
87 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXPHYSICS_EXPORT
Templated value-reference.
Definition: Value.h:257
The class GravityField is responsible for calculating and applying a gravity force on a set of bodies...
Definition: GravityField.h:39
A representation of a generic task.
Definition: Task.h:58
The class UniformGravityField calculates a gravity which is uniform in magnitude over the entire spac...
virtual Vec3 calculateGravity(const Vec3 &position) const override
UniformGravityField(Vec3 gravity=Vec3(0, 0, -agx::GRAVITY_ACCELERATION))
Constructor.
virtual Task * createParticleSystemTask() override
Internal use.
void setGravity(const Vec3 &gravity)
Set the gravity vector.
virtual Task * createRigidBodyTask() override
Internal use.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: agx/Vec3.h:36
const Real GRAVITY_ACCELERATION
Definition: Math.h:52