From 1e70d8cf96c1e67678ed815629fcb8415eb0680b Mon Sep 17 00:00:00 2001 From: jonathan santis Date: Mon, 25 Nov 2024 10:17:41 +0100 Subject: [PATCH] add primitives --- src/primitives.zig | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/primitives.zig diff --git a/src/primitives.zig b/src/primitives.zig new file mode 100644 index 0000000..cd64f4e --- /dev/null +++ b/src/primitives.zig @@ -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, +};