SHARE
TWEET

Untitled

a guest Sep 8th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn make_mesh(world: &mut World) -> Handle<Mesh>
  2. {
  3.     use amethyst::renderer::rendy::mesh::{MeshBuilder, Position, Normal, TexCoord, Tangent};
  4.     use amethyst::renderer::types::MeshData;
  5.  
  6.     let loader = world.read_resource::<Loader>();
  7.  
  8.     let verts = vec![
  9.         Position([-1.0, -1.0, 0.0]),
  10.         Position([ 1.0, -1.0, 0.0]),
  11.         Position([ 1.0,  1.0, 0.0]),
  12.         Position([-1.0,  1.0, 0.0]),
  13.     ];
  14.  
  15.     // speculative
  16.     let norms = vec![
  17.         Normal([0.0, 0.0, 0.0]),
  18.         Normal([0.0, 0.0, 0.0]),
  19.         Normal([0.0, 0.0, 0.0]),
  20.         Normal([0.0, 0.0, 0.0]),
  21.     ];
  22.    
  23.     // I really don't know what these are meant to do
  24.     let tans = vec![
  25.         // I hope it's [w, x, y, z], because the docs say that w should always be 1 or -1
  26.         Tangent([1.0, 0.0, 0.0, 0.0]),
  27.         Tangent([1.0, 0.0, 0.0, 0.0]),
  28.         Tangent([1.0, 0.0, 0.0, 0.0]),
  29.         Tangent([1.0, 0.0, 0.0, 0.0]),
  30.     ];
  31.  
  32.     let tex = vec![
  33.         TexCoord([0.0, 0.0]),
  34.         TexCoord([1.0, 0.0]),
  35.         TexCoord([1.0, 1.0]),
  36.         TexCoord([0.0, 1.0]),
  37.     ];
  38.  
  39.     let mesh_store = &world.read_resource();
  40.  
  41.     let m = MeshBuilder::new()
  42.         .with_vertices(verts)
  43.         .with_vertices(norms)
  44.         .with_vertices(tans)
  45.         .with_vertices(tex);
  46.  
  47.     loader.load_from_data(MeshData::from(m), (), mesh_store)
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top