Logo
Physics.h
1#pragma once
2
3#include "Math/Vector3.h"
4
5namespace XXSharpKmyMath
6{
7 value class Matrix4;
8 value struct Vector3;
9}
10
11namespace XXSharpKmyPhysics
12{
13 private enum struct DebugDrawError{
14 None,
16 };
17
18 ref class PhysicsNode;
19 ref class Collider;
20 ref class RigidBody;
21 ref class Vehicle;
22 ref class PhysicsBase;
23 ref class PhysicsNotifyTarget;
24
25 private ref class RayCastHit
26 {
27 public:
28 PhysicsNode^ node;
29 XXSharpKmyMath::Vector3 position;
30 XXSharpKmyMath::Vector3 normal;
31 float distance;
32 int triangleIndex;
33 };
34
35 private ref class PhysicsBase
36 {
37 public:
38
39 PhysicsBase(kmyPhysics::PhysicsBase* p);
40
41 void lockUpdate();
42 void unlockUpdate();
43
44 void setGravity(float x, float y, float z);
45 void removeRigidBody(RigidBody ^r);
46 void removeCollider(Collider ^c);
47 void removeVehicle(Vehicle^ v);
48 bool rayCast(XXSharpKmyMath::Vector3 from, XXSharpKmyMath::Vector3 to, unsigned short mask, RayCastHit^ hit);
49 bool rayCast(XXSharpKmyMath::Vector3 from, XXSharpKmyMath::Vector3 to, unsigned short mask, RayCastHit^ hit, PhysicsNotifyTarget^ self);
50 bool rayCast(XXSharpKmyMath::Vector3 from, XXSharpKmyMath::Vector3 to, unsigned short mask, RayCastHit^ hit, PhysicsNotifyTarget^ self, unsigned short type);
51 bool rayCast(XXSharpKmyMath::Vector3 from, XXSharpKmyMath::Vector3 to, unsigned short mask, RayCastHit^ hit, PhysicsNotifyTarget^ self, unsigned short type, int fellowId);
52 bool convexSweepTest(float radius, float height, XXSharpKmyMath::Vector3 from, XXSharpKmyMath::Vector3 to, unsigned short mask, RayCastHit^ hit);
53 bool convexSweepTest(float radius, float height, XXSharpKmyMath::Vector3 from, XXSharpKmyMath::Vector3 to, unsigned short mask, RayCastHit^ hit, PhysicsNotifyTarget^ self, unsigned short type);
54 bool convexSweepTest(float radius, float height, XXSharpKmyMath::Vector3 from, XXSharpKmyMath::Vector3 to, unsigned short mask, RayCastHit^ hit, PhysicsNotifyTarget^ self, unsigned short type, int fellowId);
55
56 Collider^ createBoxCollider(
57 float halfWidth, float halfHeight, float halfDepth,
58 XXSharpKmyMath::Matrix4 ^mtx,
59 unsigned short group,
60 unsigned short mask
61 );
62
63 Collider^ createSphereCollider(
64 float radius,
65 XXSharpKmyMath::Matrix4 ^mtx,
66 unsigned short group,
67 unsigned short mask
68 );
69
70 Collider^ createCapsuleCollider(
71 float radius,
72 float height,
73 XXSharpKmyMath::Matrix4 ^mtx,
74 unsigned short group,
75 unsigned short mask,
76 int axis
77 );
78
79 Collider^ createTriMeshCollider(
80 array<float> ^vertices,
81 array<unsigned short> ^indices,
82 XXSharpKmyMath::Matrix4 ^mtx,
83 XXSharpKmyMath::Vector3 ^scl,
84 unsigned short group,
85 unsigned short mask,
86 int verticesCount,
87 int indicesCount
88 );
89
90 Collider^ createTriMeshCollider(
91 System::Guid guid,
92 XXSharpKmyMath::Matrix4 ^mtx,
93 XXSharpKmyMath::Vector3 ^scl,
94 unsigned short group,
95 unsigned short mask
96 );
97
98 Collider^ createCompoundCollider(
99 array<float> ^boxes,
100 XXSharpKmyMath::Matrix4 ^mtx,
101 XXSharpKmyMath::Vector3 ^scl,
102 unsigned short group,
103 unsigned short mask
104 );
105
106 RigidBody^ createBoxRigidBody(
107 float halfWidth, float halfHeight, float halfDepth,
108 float mass,
109 bool kinematic,
110 XXSharpKmyMath::Matrix4 ^mtx,
111 unsigned short group,
112 unsigned short mask
113 );
114
115 RigidBody^ createSphereRigidBody(
116 float radius,
117 float mass,
118 bool kinematic,
119 XXSharpKmyMath::Matrix4 ^mtx,
120 unsigned short group,
121 unsigned short mask
122 );
123
124 RigidBody^ createCapsuleRigidBody(
125 float radius,
126 float height,
127 float mass,
128 bool kinematic,
129 XXSharpKmyMath::Matrix4 ^mtx,
130 unsigned short group,
131 unsigned short mask,
132 int axis
133 );
134
135 RigidBody^ createCompoundRigidBody(
136 array<float> ^boxes,
137 float mass,
138 bool kinematic,
139 XXSharpKmyMath::Matrix4 ^mtx,
140 XXSharpKmyMath::Vector3 ^scl,
141 unsigned short group,
142 unsigned short mask
143 );
144
145 RigidBody^ createTriMeshRigidBody(
146 System::Guid guid,
147 XXSharpKmyMath::Vector3 ^massCenter,
148 float mass,
149 bool kinematic,
150 XXSharpKmyMath::Matrix4 ^mtx,
151 XXSharpKmyMath::Vector3 ^scl,
152 unsigned short group,
153 unsigned short mask
154 );
155
156 Vehicle^ createVehicle(
157 float width, float height, float depth
158 , float wheelRadius, float wheelWidth, float wheelFriction
159 , float suspensionRestLength, float connectionHeight
160 , float suspensionStiffness, float suspensionDamping, float suspensionCompression
161 , float rigidbodyOffsetX, float rigidbodyOffsetY, float rigidbodyOffsetZ
162 , float positionX, float positionY, float positionZ
163 , float mass
164 );
165
166 void update(f32 delta);
167 DebugDrawError getDebugDrawError();
168
169 private:
170 kmyPhysics::PhysicsBase *obj = nullptr;
171 };
172
173
174
175}
DebugDrawError
Definition: PhysicsBase.cs:8