Example #1
0
        public void AddVertices(OBJVertex[] vertex, GeometryPrimitiveTopologies topology)
        {
            //one group can have several topologies
            //example:
            //f 74513/2367/55537 74560/2366/55584 74514/2368/55538
            //f 74514/2275/55538 74561/2369/55585 74562/2370/55586 74515/2276/55539
            //convert to one topology to simplify post processing
            switch (topology)
            {
            case GeometryPrimitiveTopologies.TriangleList:
                Vertices.Add(vertex[0]);
                Vertices.Add(vertex[1]);
                Vertices.Add(vertex[2]);
                cache.VertexCount += 3;
                break;

            case GeometryPrimitiveTopologies.TriangleFan:
                //suport triangle fan format https://en.wikipedia.org/wiki/Triangle_fan
                //https://docs.microsoft.com/en-us/windows/win32/direct3d9/triangle-fans
                Vertices.Add(vertex[0]);
                Vertices.Add(vertex[1]);
                Vertices.Add(vertex[2]);

                Vertices.Add(vertex[0]);
                Vertices.Add(vertex[2]);
                Vertices.Add(vertex[3]);

                cache.VertexCount += 6;
                break;
            }
        }
 public ImmutableGeometryData(IReadOnlyCollection <Vector3> positions,
                              IReadOnlyCollection <Vector3> normals, IReadOnlyCollection <int> indices,
                              IReadOnlyCollection <Vector2> texCoor, IReadOnlyCollection <Vector4> colors)
 {
     Positions  = positions == null ? ImmutableArray <Vector3> .Empty : positions.ToImmutableArray();
     Normals    = normals == null ? ImmutableArray <Vector3> .Empty : positions.ToImmutableArray();
     Indices    = indices == null ? ImmutableArray <int> .Empty : indices.ToImmutableArray();
     TexCoor    = texCoor == null ? ImmutableArray <Vector2> .Empty : texCoor.ToImmutableArray();
     Colors     = colors == null ? ImmutableArray <Vector4> .Empty : colors.ToImmutableArray();
     IsModified = true;
     Topology   = GeometryPrimitiveTopologies.TriangleList;
 }
Example #3
0
 public GeometryData(
     string group,
     List <Vector3> positions,
     List <Vector3> normals,
     List <Vector3> colors,
     List <int> indices,
     List <Vector2> textureCoors,
     GeometryPrimitiveTopologies topology)
 {
     Positions    = positions.AsReadOnly();
     Normals      = normals.AsReadOnly();
     Colors       = colors.AsReadOnly();
     Indices      = indices.AsReadOnly();
     TextureCoors = textureCoors.AsReadOnly();
     Name         = group;
     Topology     = topology;
 }