PeriDyno 1.0.0
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 switch (event.key)
29 {
31 vel_prime[2] += 0.5f;
32 vel_prime[2] = vel_prime[2] > 5.0 ? 5.0 : vel_prime[2];
33 vel_prime[2] = vel_prime[2] < -5.0 ? -5.0 : vel_prime[2];
34 break;
36 vel_prime[2] *= 0.95f;
37 break;
39 omega_prime.y += 0.5;
40 break;
42 omega_prime.y -= 0.5;
43 break;
44 default:
45 break;
46 }
47
48 this->inVelocity()->setValue(rot * vel_prime);
49 this->inAngularVelocity()->setValue(rot * omega_prime);
50 }
51
53}
#define DEFINE_CLASS(name)
Definition Object.h:140
#define IMPLEMENT_TCLASS(name, T1)
Definition Object.h:103
TDataType::Coord Coord
Definition Steer.h:27
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