public static Object3dManager LoadFromRaw(string vboFile)
        {
            var vboBytes = File.ReadAllBytes(vboFile);

            var vboFloats = new float[vboBytes.Length / 4];

            System.Buffer.BlockCopy(vboBytes, 0, vboFloats, 0, vboBytes.Length);

            return(new Object3dManager(VertexInfo.FromFloatArray(vboFloats)));
        }
Esempio n. 2
0
 public Object3dInfo(List <VertexInfo> vbo)
 {
     VBO          = VertexInfo.ToFloatList(vbo).ToArray();
     IndicesCount = vbo.Count;
     if (vbo.Count > 0)
     {
         var a = vbo[0].Position;
         var b = vbo[0].Position;
         foreach (var v in vbo)
         {
             a = Min(a, v.Position);
             b = Max(b, v.Position);
         }
         BoundingBoxMin = a;
         BoundingBoxMax = b;
     }
 }
        public static List <VertexInfo> FromFloatArray2(float[] vbo)
        {
            List <VertexInfo> vs = new List <VertexInfo>(vbo.Length / 8);
            var cnt = vbo.Length;

            for (int i = 0; i < cnt; i += 8)
            {
                var v = new VertexInfo();
                v.Position.X = vbo[i];
                v.Position.Y = vbo[i + 1];
                v.Position.Z = vbo[i + 2];
                v.UV.X       = vbo[i + 3];
                v.UV.Y       = vbo[i + 4];
                v.Normal.X   = vbo[i + 5];
                v.Normal.Y   = vbo[i + 6];
                v.Normal.Z   = vbo[i + 7];
                vs.Add(v);
            }
            return(vs);
        }