82 lines
2.4 KiB
Rust
82 lines
2.4 KiB
Rust
use std::path::Path;
|
|
use glam::{Quat, Vec3};
|
|
use raidillon_core::{Engine, Scene, System};
|
|
use raidillon_core::system::SystemContext;
|
|
use raidillon_platform::{Platform, Camera};
|
|
use raidillon_assets::model_path;
|
|
use raidillon_ecs::components::ModelHandle;
|
|
use raidillon_ecs::Transform;
|
|
#[cfg(feature = "glium")]
|
|
use raidillon_glium::GliumPlatform;
|
|
|
|
const TEST_GLTF: &str = "pink-monkey.gltf";
|
|
|
|
const RENDERING_TEST_SYSTEM: &str = "rendering_test_system";
|
|
|
|
const MAIN_SCENE_ID: &str = "main_scene";
|
|
|
|
struct RenderingTestSystem;
|
|
|
|
impl System for RenderingTestSystem {
|
|
fn initialize(&mut self) {}
|
|
fn load_world(&mut self, ctx: &mut SystemContext) {
|
|
ctx.scene.world.spawn((Camera {
|
|
eye: Vec3::new(0.0, 0.0, 2.0),
|
|
center: Vec3::ZERO,
|
|
up: Vec3::Y,
|
|
fovy: 60_f32.to_radians(),
|
|
aspect: ctx.platform_context.frame_width / ctx.platform_context.frame_height,
|
|
znear: 0.1,
|
|
zfar: 100.0,
|
|
},));
|
|
|
|
let mut am = ctx.platform_context.asset_manager.borrow_mut();
|
|
|
|
am.load_gltf(TEST_GLTF, &model_path(TEST_GLTF));
|
|
|
|
ctx.scene.world.spawn((
|
|
Transform {
|
|
translation: Vec3::new(0.0, 0.0, 0.0),
|
|
rotation: Quat::IDENTITY,
|
|
scale: Vec3::new(1.0, 1.0, 1.0),
|
|
},
|
|
ModelHandle(TEST_GLTF),
|
|
));
|
|
}
|
|
|
|
fn update(&mut self, ctx: &mut SystemContext) {
|
|
// if let Some(mut debug_ui) = ctx.platform_context.imgui_ui.as_ref().map(|ui| ui.borrow_mut()) {
|
|
// debug_ui.text("Hello World!");
|
|
// }
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let mut engine = Engine::new();
|
|
// Define systems
|
|
// engine.system_manager.add_system("spawn_chunks".to_string(), ChunkSystem);
|
|
// engine.system_manager.add_system("movement".to_string(), MovementSystem);
|
|
engine.system_manager.add_system(RENDERING_TEST_SYSTEM, Box::new(RenderingTestSystem));
|
|
|
|
// Set up the scene
|
|
let main_scene = Scene::new(
|
|
MAIN_SCENE_ID.to_owned(),
|
|
None,
|
|
);
|
|
engine.scene_manager.add_scene(MAIN_SCENE_ID, main_scene);
|
|
engine.scene_manager.set_active_scene(MAIN_SCENE_ID);
|
|
|
|
#[cfg(feature = "glium")]
|
|
{
|
|
let mut platform = GliumPlatform::initialize(
|
|
engine,
|
|
"Raidillon".to_string(),
|
|
1920,
|
|
1080,
|
|
);
|
|
platform.run()
|
|
};
|
|
|
|
#[cfg(not(any(feature = "glium")))]
|
|
compile_error!("No platform feature enabled.");
|
|
}
|