~tagglink/solar-system

1cccd9bab064bb8a8eb9275eeaa5a7648682fb19 — Tomas Granlund 10 months ago acb1ac0 master
added material
3 files changed, 26 insertions(+), 10 deletions(-)

A assets/mesh/planet-mat.ron
M src/main.rs
M src/universe.rs
A assets/mesh/planet-mat.ron => assets/mesh/planet-mat.ron +0 -0
M src/main.rs => src/main.rs +2 -1
@@ 75,7 75,8 @@ fn main() -> amethyst::Result<()> {
    .add_bundle(
      RenderingBundle::<DefaultBackend>::new()
        .with_plugin(
          RenderToWindow::from_config_path(display_config_path)?.with_clear(ClearColor { float32: [0.0, 0.0, 0.0, 1.0] }),
          RenderToWindow::from_config_path(display_config_path)?.with_clear(
            ClearColor { float32: [0.0, 0.0, 0.0, 1.0] }),
        )
        .with_plugin(RenderPbr3D::default())
        //.with_plugin(RenderUi::default()),

M src/universe.rs => src/universe.rs +24 -9
@@ 1,5 1,5 @@
use amethyst::{
  assets::{DefaultLoader, Handle, Loader, ProgressCounter},
  assets::{DefaultLoader, Handle, Loader, ProgressCounter, ProcessingQueue},
  controls::HideCursor,
  core::{
      Transform,


@@ 10,12 10,13 @@ use amethyst::{
  renderer::{
      formats::texture::TextureGenerator,
      light::PointLight,
      palette::Srgb,
      loaders::load_from_srgba,
      palette::{Srgb, Srgba},
      rendy::{
          mesh::{Mesh, MeshBuilder},
          mesh::MeshBuilder,
      },
      types::{DefaultBackend, MeshData, TextureData},
      Camera, Texture,
      types::{DefaultBackend, Mesh, TextureData},
      Camera, Material, MaterialDefaults, Texture,
  },
  utils::auto_fov::AutoFov,
  winit::event::MouseButton,


@@ 56,12 57,26 @@ impl SimpleState for Universe {

    {
        let loader = resources.get::<DefaultLoader>().unwrap();
        let mesh: Handle<MeshData> = loader.load("mesh/planet.obj");
        //let albedo = TextureGenerator::Srgba(0.906, 0.471, 0.137, 1.0).data();
        //let emission = TextureGenerator::Srgba(1.0, 0.933, 0.0, 1.0).data();
        let mesh: Handle<Mesh> = loader.load("mesh/planet.obj");
        let albedo = load_from_srgba((0.906, 0.471, 0.137, 1.0).into());
        let emission = load_from_srgba((1.0, 0.933, 0.0, 1.0).into());

        let tex_storage = resources.get::<ProcessingQueue<TextureData>>().unwrap();

        let albedo = loader.load_from_data(albedo.into(), (), &tex_storage);
        let emission = loader.load_from_data(emission.into(), (), &tex_storage);

        let dmat = resources.get::<MaterialDefaults>().unwrap().0.clone();

        let mat = Material {
            albedo,
            emission,
            .. dmat
        };

        transform.set_translation_xyz(0.0, 0.0, 0.0);
        *transform.scale_mut() = Vector3::new(696.342, 696.342, 696.342);
        world.push((transform.clone(), mesh));
        world.push((transform.clone(), mat, mesh));
    }
    
    /*