PeriDyno 1.2.1
Loading...
Searching...
No Matches
Steer.cpp
Go to the documentation of this file.
1#include "Steer.h"
2
3namespace dyno
4{
6
7 template<typename TDataType>
13
14 template<typename TDataType>
16 {
17 auto quat = this->inQuaternion()->getData();
18
19 Coord vel = this->inVelocity()->getData();
20
21 Coord omega = this->inAngularVelocity()->getData();
22
23 Matrix rot = quat.toMatrix3x3();
24
25 Coord vel_prime = rot.transpose() * vel;
26 Coord omega_prime = rot.transpose() * omega;
27
28 Real strength = this->varStrength()->getValue();
29 switch (event.key)
30 {
32 vel_prime[2] += strength;
33 vel_prime[2] = vel_prime[2] > 5.0 ? 5.0 : vel_prime[2];
34 vel_prime[2] = vel_prime[2] < -5.0 ? -5.0 : vel_prime[2];
35 break;
37 vel_prime[2] *= 0.95f;
38 break;
40 omega_prime.y += strength;
41 break;
43 omega_prime.y -= strength;
44 break;
45 default:
46 break;
47 }
48
49 this->inVelocity()->setValue(rot * vel_prime);
50 this->inAngularVelocity()->setValue(rot * omega_prime);
51 }
52
54}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
TDataType::Coord Coord
Definition Steer.h:27
TDataType::Real Real
Definition Steer.h:26
void onEvent(PKeyboardEvent event) override
Definition Steer.cpp:15
TDataType::Matrix Matrix
Definition Steer.h:28
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
@ PKEY_S
Definition InputModule.h:79
@ PKEY_A
Definition InputModule.h:61
@ PKEY_D
Definition InputModule.h:64
@ PKEY_W
Definition InputModule.h:83
PKeyboardType key
vgm::Quat quat
Definition vgMath.h:633