Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
qrigidbody.h
1 
2 /************************************************************************************
3  * MIT License
4  *
5  * Copyright (c) 2023 Eray Zesen
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  *
24  * https://github.com/erayzesen/QuarkPhysics
25  *
26 **************************************************************************************/
27 
28 #ifndef QRIGIDBODY_H
29 #define QRIGIDBODY_H
30 #include "qbody.h"
31 #include "qvector.h"
32 
39 class QRigidBody : public QBody
40 {
41  bool fixedRotation=false;
42 protected:
43  float angularForce=0.0f;
44  QVector force=QVector::Zero();
45 public:
46  QRigidBody();
47 
48  //Get Methods
51  return fixedRotation;
52  }
55  return isKinematic;
56  }
59  return allowKinematicCollisions;
60  }
61 
64  return force;
65  }
67  float GetAngularForce(){
68  return angularForce;
69  }
70 
71  //Set Methods
74  fixedRotation=value;
75  return this;
76  }
79  isKinematic=value;
80  return this;
81  }
85  allowKinematicCollisions=value;
86  return this;
87  }
88 
93  QRigidBody * SetPositionAndCollide(QVector value,bool withPreviousPosition=true);
94 
95 
96  //#Rigidbody Methods
102  QRigidBody* ApplyForce(QVector force,QVector r,bool updateMeshTransforms=true);
112  QRigidBody *SetForce(QVector value);
117  QRigidBody *AddForce(QVector value);
118 
123  QRigidBody *SetAngularForce(float value);
128  QRigidBody *AddAngularForce(float value);
129 
130 
132  virtual void Update();
133 
135  virtual void PostUpdate();
136 
137 
138 };
139 
140 #endif // QRIGIDBODY_H
QBody objects are the base class for all types of bodies. Any class derived from QBody shares these m...
Definition: qbody.h:43
QRigidBody is a type of body that is simulated with the dynamics of Rigid body. A rigid body is a typ...
Definition: qrigidbody.h:40
QRigidBody * AddAngularForce(float value)
Definition: qrigidbody.cpp:97
QVector GetForce()
Definition: qrigidbody.h:63
QRigidBody * ApplyImpulse(QVector impulse, QVector r)
Definition: qrigidbody.cpp:64
QRigidBody * SetKinematicCollisionsEnabled(bool value)
Definition: qrigidbody.h:84
QRigidBody * SetAngularForce(float value)
Definition: qrigidbody.cpp:90
QRigidBody * SetFixedRotationEnabled(bool value)
Definition: qrigidbody.h:73
virtual void Update()
Definition: qrigidbody.cpp:102
float GetAngularForce()
Definition: qrigidbody.h:67
QRigidBody * SetPositionAndCollide(QVector value, bool withPreviousPosition=true)
Definition: qrigidbody.cpp:41
QRigidBody * SetKinematicEnabled(bool value)
Definition: qrigidbody.h:78
bool GetKinematicEnabled()
Definition: qrigidbody.h:54
bool GetKinematicCollisionsEnabled()
Definition: qrigidbody.h:58
QRigidBody * ApplyForce(QVector force, QVector r, bool updateMeshTransforms=true)
Definition: qrigidbody.cpp:50
QRigidBody * SetForce(QVector value)
Definition: qrigidbody.cpp:78
bool GetFixedRotationEnabled()
Definition: qrigidbody.h:50
QRigidBody * AddForce(QVector value)
Definition: qrigidbody.cpp:85
virtual void PostUpdate()
Definition: qrigidbody.cpp:166
Definition: qvector.h:44