Custom entity UI, math functions, physics triggers
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Camera_Type :: enum {
|
||||
Camera_Projection_Type :: enum {
|
||||
ORTHOGRAPHIC;
|
||||
PERSPECTIVE;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ Camera_Buffer_Data :: struct {
|
||||
}
|
||||
|
||||
Camera :: struct {
|
||||
type : Camera_Type;
|
||||
type : Camera_Projection_Type;
|
||||
|
||||
position : Vector3;
|
||||
rotation : struct {
|
||||
|
||||
@@ -368,6 +368,34 @@ reflect :: (incident: Vector3, normal: Vector3) -> Vector3 {
|
||||
return reflected;
|
||||
}
|
||||
|
||||
get_rotated_direction :: (direction: Vector3, by_pitch: float, by_yaw: float, by_roll: float) -> Vector3 {
|
||||
pitch := by_pitch * DEGREES_TO_RADIANS;
|
||||
yaw := by_yaw * DEGREES_TO_RADIANS;
|
||||
roll := by_roll * DEGREES_TO_RADIANS;
|
||||
|
||||
pitch_mat := Matrix4.{
|
||||
1, 0, 0, 0,
|
||||
0, cos(pitch), sin(pitch), 0,
|
||||
0, -sin(pitch), cos(pitch), 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
yaw_mat := Matrix4.{
|
||||
cos(yaw), 0, -sin(yaw), 0,
|
||||
0, 1, 0, 0,
|
||||
sin(yaw), 0, cos(yaw), 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
roll_mat := Matrix4.{
|
||||
cos(roll), sin(roll), 0, 0,
|
||||
-sin(roll), cos(roll), 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1};
|
||||
|
||||
matrix := yaw_mat * pitch_mat * roll_mat;
|
||||
|
||||
return normalize(to_v3(matrix * Vector4.{direction.x, direction.y, direction.z, 0.0}));
|
||||
}
|
||||
|
||||
quat_to_pitch_yaw_roll :: (using q: Quaternion) -> pitch: float, yaw: float, roll: float {
|
||||
roll := atan2(2*y*w - 2*x*z, 1 - 2*y*y - 2*z*z);
|
||||
pitch := atan2(2*x*w - 2*y*z, 1 - 2*x*x - 2*z*z);
|
||||
|
||||
Reference in New Issue
Block a user