Begin move mesh + Vertex and Camera into core
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 20m30s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 20m30s
This commit is contained in:
parent
2fbf4e6ce2
commit
852d72d716
11 changed files with 64 additions and 3 deletions
19
src/core/camera/mod.rs
Normal file
19
src/core/camera/mod.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
use bevy_ecs::component::Component;
|
||||||
|
use glam::{Mat4, Quat, Vec3};
|
||||||
|
|
||||||
|
pub trait Camera: Into<Mat4> + Component {}
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct Camera3D {
|
||||||
|
pub projection: Mat4,
|
||||||
|
pub position: Vec3,
|
||||||
|
pub rotation: Quat,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<Mat4> for Camera3D {
|
||||||
|
fn into(self) -> Mat4 {
|
||||||
|
Mat4::from_rotation_translation(self.rotation, self.position) * self.projection
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Camera for Camera3D {}
|
|
@ -1 +1,4 @@
|
||||||
pub mod app;
|
pub mod app;
|
||||||
|
pub mod camera;
|
||||||
|
pub mod render;
|
||||||
|
pub mod scene;
|
||||||
|
|
14
src/core/render/mesh.rs
Normal file
14
src/core/render/mesh.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
use bevy_ecs::component::Component;
|
||||||
|
|
||||||
|
use super::vertex::Vertex2D;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct Mesh2D {
|
||||||
|
pub vertices: Vec<Vertex2D>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Mesh2D {
|
||||||
|
pub fn new(vertices: Vec<Vertex2D>) -> Self {
|
||||||
|
Self { vertices }
|
||||||
|
}
|
||||||
|
}
|
2
src/core/render/mod.rs
Normal file
2
src/core/render/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod mesh;
|
||||||
|
pub mod vertex;
|
21
src/core/scene.rs
Normal file
21
src/core/scene.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
use bevy_ecs::world::World;
|
||||||
|
|
||||||
|
pub struct Scene {
|
||||||
|
world: World,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Scene {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
world: World::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn world(&self) -> &World {
|
||||||
|
&self.world
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn world_mut(&mut self) -> &mut World {
|
||||||
|
&mut self.world
|
||||||
|
}
|
||||||
|
}
|
1
src/game/mod.rs
Normal file
1
src/game/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::error::Error;
|
||||||
use winit::event_loop::{ControlFlow, EventLoop};
|
use winit::event_loop::{ControlFlow, EventLoop};
|
||||||
|
|
||||||
pub mod core;
|
pub mod core;
|
||||||
|
pub mod game;
|
||||||
pub mod vulkan;
|
pub mod vulkan;
|
||||||
|
|
||||||
fn main() -> Result<(), impl Error> {
|
fn main() -> Result<(), impl Error> {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
pub mod pipelines;
|
pub mod pipelines;
|
||||||
pub mod vertex;
|
|
||||||
pub mod vulkan_context;
|
pub mod vulkan_context;
|
||||||
pub mod window_render_context;
|
pub mod window_render_context;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use vulkano::pipeline::{
|
||||||
use vulkano::shader::{EntryPoint, ShaderStages};
|
use vulkano::shader::{EntryPoint, ShaderStages};
|
||||||
use vulkano::swapchain::Swapchain;
|
use vulkano::swapchain::Swapchain;
|
||||||
|
|
||||||
use crate::vulkan::vertex::Vertex2D;
|
use crate::core::render::vertex::Vertex2D;
|
||||||
|
|
||||||
pub mod shaders {
|
pub mod shaders {
|
||||||
pub mod vs {
|
pub mod vs {
|
||||||
|
|
|
@ -8,7 +8,8 @@ use vulkano::command_buffer::{AutoCommandBufferBuilder, PrimaryAutoCommandBuffer
|
||||||
use vulkano::descriptor_set::{DescriptorSet, WriteDescriptorSet};
|
use vulkano::descriptor_set::{DescriptorSet, WriteDescriptorSet};
|
||||||
use vulkano::pipeline::{GraphicsPipeline, Pipeline, PipelineBindPoint};
|
use vulkano::pipeline::{GraphicsPipeline, Pipeline, PipelineBindPoint};
|
||||||
|
|
||||||
use crate::vulkan::{pipelines::triangle_pipeline::create_triangle_pipeline, vertex::Vertex2D};
|
use crate::core::render::vertex::Vertex2D;
|
||||||
|
use crate::vulkan::pipelines::triangle_pipeline::create_triangle_pipeline;
|
||||||
|
|
||||||
use super::vulkan_context::VulkanContext;
|
use super::vulkan_context::VulkanContext;
|
||||||
use super::window_render_context::WindowRenderContext;
|
use super::window_render_context::WindowRenderContext;
|
||||||
|
|
Loading…
Add table
Reference in a new issue