Point lights

This commit is contained in:
2024-12-04 23:41:52 +01:00
parent 71668cc2f5
commit c4073d7d91
5 changed files with 66 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
#load "../renderer/directional_light.jai";
#load "../renderer/point_light.jai";
#load "particles.jai";
MAX_CACHED_PILES :: 8;
@@ -160,7 +161,7 @@ create_scene :: (name: string = "", max_entities: s64 = 256) -> *Scene {
array_reserve(*scene.entities, max_entities);
scene.directional_light.color_and_intensity = .{1,1,1,2};
scene.directional_light.color_and_intensity = .{1,1,1,1};
scene.directional_light.direction = to_v4(normalize(Vector3.{0.2, -0.7, 0.4}));
dir_light_data : Directional_Light_Buffer_Data;

View File

@@ -72,7 +72,7 @@ translate :: (transform: *Transform, translation: Vector3, calculate_matrix: boo
}
euler_to_quaternion :: (value: Vector3) -> Quaternion {
return euler_to_quaternion(value.x, value.y, value.z);
return euler_to_quaternion(value.y, value.x, value.z);
}
euler_to_quaternion :: (yaw: float, pitch: float, roll: float) -> Quaternion {
@@ -102,8 +102,8 @@ quaternion_to_euler_v3 :: (q: Quaternion) -> Vector3 {
yaw, pitch, roll := quaternion_to_euler(q);
v : Vector3 = ---;
v.x = yaw;
v.y = pitch;
v.x = pitch;
v.y = yaw;
v.z = roll;
return v;
@@ -130,7 +130,7 @@ quaternion_to_euler :: (q: Quaternion) -> yaw: float, pitch: float, roll: float
cosy_cosp := 1.0 - 2.0 * (q.y * q.y + q.z * q.z);
yaw = atan2(siny_cosp, cosy_cosp);
return yaw, pitch, roll;
return pitch, yaw, roll;
}
set_rotation :: (e: *Entity, orientation: Quaternion, calculate_matrix: bool = true) {
@@ -148,6 +148,10 @@ set_rotation :: (transform: *Transform, euler_angles: Vector3, calculate_matrix:
if calculate_matrix update_matrix(transform);
}
set_rotation :: (e: *Entity, euler_angles: Vector3, calculate_matrix: bool = true) {
set_rotation(*e.transform, euler_angles, calculate_matrix);
}
set_scale :: (e: *Entity, scale: Vector3, calculate_matrix: bool = true) {
set_scale(*e.transform, scale, calculate_matrix);
}