}
}
-#operator + macro (v1, v2: Vector3) => Vector3.{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
-#operator - macro (v1, v2: Vector3) => Vector3.{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
+#operator + macro (v1, v2: Vector3) => Vector3.{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
+#operator - macro (v1, v2: Vector3) => Vector3.{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
+#operator * macro (v: Vector3, s: f32) => Vector3.{ v.x * s, v.y * s, v.z * s };
update_world_matrix :: (position: Vector3, facing: Vector3, up: Vector3) {
forward := Vector3.norm(facing); //center - position);
theta := 0.0f; // y-axis
phi := 0.0f; // x-axis
+pos := Vector3.{ 5, 5, 5 };
update :: (dt: f32) {
#persist t := 0.0f;
math.cos(theta) * math.cos(phi)
};
- update_world_matrix(.{ 5, 5, 5 }, facing, .{ 0, 1, 0 });
+ up := Vector3.{0,1,0};
+
+ if glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS {
+ pos += Vector3.norm(facing) * 3 * dt;
+ }
+ if glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS {
+ pos -= Vector3.norm(facing) * 3 * dt;
+ }
+ if glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS {
+ pos += Vector3.norm(Vector3.cross(facing, up)) * 3 * dt;
+ }
+ if glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS {
+ pos -= Vector3.norm(Vector3.cross(facing, up)) * 3 * dt;
+ }
+
+ update_world_matrix(pos, facing, up);
}
draw :: () {