add primitives

This commit is contained in:
jonathan santis 2024-11-25 10:17:41 +01:00
parent c3b9fbc298
commit 1e70d8cf96

41
src/primitives.zig Normal file
View File

@ -0,0 +1,41 @@
pub const Direction = struct {
x: i8 = 1,
y: i8 = 1,
z: i8 = 1,
};
pub const Color = struct {
r : u8 = 0,
g : u8 = 0,
b : u8 = 0,
};
pub const Point = struct {
x: f32 = 0,
y: f32 = 0,
z: f32 = 0,
color: Color = .{.r=0,.g=0,.b=0},
};
pub const Vec = struct {
const Self = @This();
a: Point = .{ .x = 0, .y = 0, .z = 0},
pub fn add(self:*Self,m1:Self) void {
self.a.x = self.a.x + m1.a.x;
self.a.y = self.a.y + m1.a.y;
self.a.z = self.a.z + m1.a.z;
}
};
pub const Vec2 = struct {
a: Point = .{ .x = 0, .y = 0, .z = 0},
b: Point = .{ .x = 0, .y = 0, .z = 0},
};
pub const Vec3 = struct {
a: Point = .{ .x = 0, .y = 0, .z = 0},
b: Point = .{ .x = 0, .y = 0, .z = 0},
c: Point = .{ .x = 0, .y = 0, .z = 0},
};
pub const Triangle = struct {
bufa: *i32,
bufb: *i32,
bufc: *i32,
};