From 6881c2c6ae46e8270ddcdd9c2924fc31ec742424 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 28 Sep 2026 22:59:54 +0200 Subject: refactor: make compile after changes in engine --- src/main.rs | 55 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5807b22..6edc1e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::io::Cursor; use std::path::Path; -use engine::asset::Assets; +use engine::asset::{Assets, Label as AssetLabel}; use engine::camera::fly::{ Extension as FlyCameraExtension, Fly as FlyCamera, @@ -29,7 +29,7 @@ use engine::input::Extension as InputExtension; use engine::lighting::DirectionalLight; use engine::material::Material; use engine::mesh::Mesh; -use engine::model::{MaterialDescription, Model, Spec as ModelSpec}; +use engine::model::{MaterialDescription, ModelMaterial, ModelMesh}; use engine::rendering::{ Extension as RenderingExtension, GraphicsProperties, @@ -186,34 +186,45 @@ fn init(mut assets: Single, mut actions: Actions) -> Result<(), EngineEr "Floor", ( Transform::default().position(Vec3 { x: 1.6, y: -3.0, z: 0.0 }), - Model::new(assets.store_with_name_with("floor_model", |assets| { - ModelSpec::builder() - .mesh(assets.store_with_name( - "floor_mesh", - Mesh::cube(Dimens3 { - width: 20.0, - height: 0.5, - depth: 20.0, - }), + ModelMesh { + asset: assets.store_with_name( + "floor_mesh", + Mesh::cube(Dimens3 { + width: 20.0, + height: 0.5, + depth: 20.0, + }), + ), + }, + ModelMaterial { + asset: assets.store_with_name_with("floor_material", |assets| { + MaterialDescription::new(assets.store_with_name( + "floor_surface_material", + Material::builder().build(), )) - .materials([MaterialDescription::new( - assets.store_with_name( - "floor_material", - Material::builder().build(), - ), - )]) - .build() - })), + }), + }, pair!(ChildOf, { scene_ent_id }), ), ); + let teapot_model_path = Path::new(RESOURCE_DIR).join("teapot.obj"); + actions.spawn_named( "Big teapot", ( - Model::new( - assets.load::(Path::new(RESOURCE_DIR).join("teapot.obj")), - ), + ModelMesh { + asset: assets.load::(AssetLabel { + path: teapot_model_path.as_path().into(), + name: Some("mesh".into()), + }), + }, + ModelMaterial { + asset: assets.load::(AssetLabel { + path: teapot_model_path.as_path().into(), + name: Some("material_FrontColor".into()), + }), + }, Transform::default().position(Vec3 { x: 1.6, y: 0.0, z: 0.0 }), pair!(ChildOf, { scene_ent_id }), ), -- cgit v1.2.3-18-g5258