Beispiel #1
0
        public unsafe Model(Vector3[] vertices, int[] indices, Vector2[] uvs = null, Vector3[] normals = null, Vector4[] colors = null)
        {
            Vertices = vertices ?? throw new Exception("Vertices are required");
            Indices  = indices;
            UVs      = uvs;
            Normals  = normals;
            Colors   = colors;

            _verticesData = new GenericVector <float> [vertices.Length];
            Bound         = Cuboid.NegativeMax;
            for (int i = 0; i < _verticesData.Length; i++)
            {
                _verticesData[i] = new GenericVector <float>(sizeof(ShaderInOutPatternDefault) / sizeof(float))
                {
                    vertices[i], 1f,
                    uvs != null ? uvs[i] : Vector2.Zero,
                    normals != null ? normals[i] : Vector3.Zero,
                    colors != null ? colors[i] : Vector4.Zero
                };
                Bound.ExtendToContain(vertices[i]);
            }
        }