Added camera uniforms for projection and view matrix
This commit is contained in:
parent
59e3997056
commit
dcb2ee0584
7 changed files with 92 additions and 28 deletions
|
|
@ -12,21 +12,18 @@ pub const Uniform = struct {
|
|||
model: math.Matrix,
|
||||
};
|
||||
|
||||
uniform: Uniform,
|
||||
position: @Vector(3, f32),
|
||||
target: @Vector(3, f32),
|
||||
direction: @Vector(3, f32),
|
||||
right: @Vector(3, f32),
|
||||
front: @Vector(3, f32),
|
||||
up: @Vector(3, f32),
|
||||
target: @Vector(3, f32) = .{0.0, 0.0, 0.0},
|
||||
front: @Vector(3, f32) = .{0.0, 0.0, 1.0 },
|
||||
up: @Vector(3, f32) = .{0.0, 1.0, 0.0 },
|
||||
speed: f32 = 2.5,
|
||||
|
||||
pub fn getProjection(width: usize, height: usize) math.Matrix {
|
||||
return math.Matrix.perspective(math.rad(45.0), (@as(f32, @floatFromInt(width)) / @as(f32, @floatFromInt(height))), 0.1, 10.0);
|
||||
return math.Matrix.perspective(math.rad(45.0), (@as(f32, @floatFromInt(width)) / @as(f32, @floatFromInt(height))), 0.1, 100.0);
|
||||
}
|
||||
|
||||
pub fn getView(self: Camera) math.Matrix {
|
||||
math.lookAt(self.position, self.position + self.front, self.up);
|
||||
return math.Matrix.lookAt(self.position, self.target, self.up);
|
||||
}
|
||||
|
||||
pub fn moveCamera(pool: *ecs.Pool) void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue