-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Miou-zora/scene
Add scene management
- Loading branch information
Showing
2 changed files
with
114 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const Sphere = @import("Sphere.zig").Sphere; | ||
const Camera = @import("Camera.zig").Camera; | ||
const Light = @import("Light.zig").Light; | ||
const Cylinder = @import("Cylinder.zig").Cylinder; | ||
const Plane = @import("Plane.zig").Plane; | ||
const Transformation = @import("Transformation.zig").Transformation; | ||
const std = @import("std"); | ||
|
||
pub const SceneObject = union(enum) { | ||
sphere: Sphere, | ||
plane: Plane, | ||
cylinder: Cylinder, | ||
}; | ||
|
||
pub const SceneLight = union(enum) { | ||
point_light: Light, | ||
ambient_light: f32, // TODO: Have a properly defined ambient_light type | ||
}; | ||
|
||
pub const Scene = struct { | ||
const Self = @This(); | ||
|
||
camera: Camera, | ||
objects: std.ArrayList(SceneObject), | ||
lights: std.ArrayList(SceneLight), | ||
transforms: std.ArrayList(Transformation), | ||
|
||
pub fn init(allocator: std.mem.Allocator, camera: Camera) Self { | ||
return Self{ | ||
.camera = camera, | ||
.objects = std.ArrayList(SceneObject).init(allocator), | ||
.lights = std.ArrayList(SceneLight).init(allocator), | ||
.transforms = std.ArrayList(Transformation).init(allocator), | ||
}; | ||
} | ||
|
||
pub fn deinit(self: *Self) void { | ||
self.objects.deinit(); | ||
self.lights.deinit(); | ||
self.transforms.deinit(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters