Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
qspring.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 QSPRING_H
29 #define QSPRING_H
30 #include "qparticle.h"
31 
32 class QMesh;
38 class QSpring
39 {
40  float rigidity=1.0f;
41  QParticle *pA;
42  QParticle *pB;
43  float length;
44  bool isInternal=false;
45  bool enabled=true;
46 public:
53  QSpring(QParticle *particleA,QParticle *particleB,bool internal=false);
61  QSpring(QParticle *particleA,QParticle *particleB,float length,bool internal=false);
62 
63 
64 
71  virtual void Update(float rigidity,bool internalsException,bool isWorldSpring=false);
72 
73  //Get Methods
76  return pA;
77  }
80  return pB;
81  }
83  float GetLength(){
84  return length;
85  }
87  bool GetIsInternal(){
88  return isInternal;
89  }
91  float GetRigidity(){
92  return rigidity;
93  }
95  bool GetEnabled(){
96  return enabled;
97  }
98 
99  //Set Methods
105  pA=particle;
106  return this;
107  }
113  pB=particle;
114  return this;
115  }
120  QSpring *SetLength(float length){
121  this->length=length;
122  return this;
123  }
128  QSpring *SetIsInternal(bool value){
129  isInternal=value;
130  return this;
131  }
136  QSpring *SetRigidity(float rigidity){
137  this->rigidity=rigidity;
138  return this;
139  }
144  QSpring *SetEnabled(bool value){
145  enabled=value;
146  return this;
147  }
148 
149 
150 
151 
152 
153 };
154 
155 #endif // QSPRING_H
QParticle objects form the network structures of QMesh objects defined for all body object types....
Definition: qparticle.h:37
You can apply distance constraints between 2 particles using the QSpring. The physics engine uses QSp...
Definition: qspring.h:39
virtual void Update(float rigidity, bool internalsException, bool isWorldSpring=false)
Definition: qspring.cpp:50
QParticle * GetParticleA()
Definition: qspring.h:75
QSpring * SetIsInternal(bool value)
Definition: qspring.h:128
QSpring(QParticle *particleA, QParticle *particleB, bool internal=false)
Definition: qspring.cpp:33
QSpring * SetLength(float length)
Definition: qspring.h:120
float GetLength()
Definition: qspring.h:83
QSpring * SetRigidity(float rigidity)
Definition: qspring.h:136
QParticle * GetParticleB()
Definition: qspring.h:79
bool GetIsInternal()
Definition: qspring.h:87
float GetRigidity()
Definition: qspring.h:91
QSpring * SetParticleA(QParticle *particle)
Definition: qspring.h:104
QSpring * SetParticleB(QParticle *particle)
Definition: qspring.h:112
bool GetEnabled()
Definition: qspring.h:95
QSpring * SetEnabled(bool value)
Definition: qspring.h:144
Every QBody object requires meshes. In other traditional physics engines, the term 'shape' is used in...
Definition: qmesh.h:48