1 module armos.graphics.buffermesh; 2 3 import armos.graphics.bufferbundle; 4 import armos.graphics.vao; 5 import armos.graphics.mesh; 6 import armos.graphics.buffer; 7 8 /++ 9 +/ 10 class BufferMesh : BufferBundle{ 11 public{ 12 // alias attrs this; 13 14 /// 15 this(Mesh mesh, in BufferUsageFrequency freq, in BufferUsageNature nature){ 16 this(); 17 _vao.begin(); 18 attrs["vertex"].array(mesh.vertices, freq, nature); 19 attrs["normal"].array(mesh.normals, freq, nature); 20 attrs["tangent"].array(mesh.tangents, freq, nature); 21 attrs["texCoord0"].array(mesh.texCoords0, freq, nature); 22 attrs["texCoord1"].array(mesh.texCoords1, freq, nature); 23 import std.algorithm; 24 import std.array; 25 import std.conv; 26 import armos.math:Vector4f; 27 import armos.types.color; 28 attrs["color"].array(mesh.colors.map!(c => c.to!Vector4f).array, freq, nature); 29 attrs["index"].array(mesh.indices, 0, freq, nature); 30 _vao.end(); 31 } 32 33 this(){ 34 super(); 35 attrs["vertex"] = new Buffer(BufferType.Array); // Vector4f 36 attrs["normal"] = new Buffer(BufferType.Array); // Vector3f 37 attrs["tangent"] = new Buffer(BufferType.Array); // Vector3f 38 attrs["texCoord0"] = new Buffer(BufferType.Array); // Vector4f 39 attrs["texCoord1"] = new Buffer(BufferType.Array); // Vector4f 40 attrs["color"] = new Buffer(BufferType.Array); // Vector4f 41 attrs["index"] = new Buffer(BufferType.ElementArray); // int 42 } 43 44 /// 45 ~this(){} 46 47 /// 48 Buffer vertex(){return attrs["buffer"];} 49 50 /// 51 Buffer normal(){return attrs["normal"];} 52 53 /// 54 Buffer tangent(){return attrs["tangent"];} 55 56 /// 57 Buffer texCoord0(){return attrs["texCoord0"];} 58 59 /// 60 Buffer texCoord1(){return attrs["texCoord1"];} 61 62 /// 63 alias texCoord = texCoord0; 64 65 /// 66 Buffer color(){return attrs["color"];} 67 68 /// 69 Buffer index(){return attrs["index"];} 70 71 }//public 72 73 private{ 74 // Mesh _rawMesh; 75 Vao _vao; 76 }//private 77 }//class BufferMesh