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