Exemplo n.º 1
0
            public void Write(Stream stream)
            {
                // TODO: validate in debug mode that this is producing the current data model. Look at the schema!

                stream.WriteBFastHeader(Header);
                stream.WriteBFastBody(Header, Names, Sizes, (_stream, index, name, size) =>
                {
                    switch (name)
                    {
                    case "meta":
                        _stream.Write(Meta);
                        break;

                    case VimConstants.G3dLegacySchema.Position:
                        Geometries.ForEach(g => stream.Write(g.Vertices.ToArray()));
                        break;

                    case "g3d:vertex:color:0:float32:4":
                        if (UseColors)
                        {
                            Geometries.ForEach(g => stream.Write(g.Colors.ToArray()));
                        }
                        break;

                    case VimConstants.G3dLegacySchema.Index:
                        for (var i = 0; i < Geometries.Count; ++i)
                        {
                            var g      = Geometries[i];
                            var offset = VertexOffsets[i];
                            stream.Write(g.Indices.Select(idx => idx + offset).ToArray());
                        }
                        break;

                    case VimConstants.G3dLegacySchema.Uv:
                        Geometries.ForEach(g => stream.Write(g.UVs.ToArray()));
                        break;

                    case VimConstants.G3dLegacySchema.MaterialId:
                        Geometries.ForEach(g => stream.Write(g.MaterialIds.ToArray()));
                        break;

                    case VimConstants.G3dLegacySchema.GroupId:
                        Geometries.ForEach(g => stream.Write(g.FaceGroupIds.ToArray()));
                        break;

                    case VimConstants.G3dLegacySchema.IndexOffset:
                        stream.Write(IndexOffsets);
                        break;

                    case VimConstants.G3dLegacySchema.VertexOffset:
                        stream.Write(VertexOffsets);
                        break;

                    default:
                        throw new Exception($"Not a recognized geometry buffer: {name}");
                    }
                    return(size);
                });
            }
Exemplo n.º 2
0
 public void Bind(int shaderProgram, int textureLoc, int haveTextureLoc, int ambientLoc, int diffuseLoc, int specularLoc, int shininessLoc)
 {
     Geometries.ForEach(g => g.Bind(shaderProgram));
     Materials.ForEach(m => m.Bind(textureLoc, haveTextureLoc, ambientLoc, diffuseLoc, specularLoc, shininessLoc));
 }
Exemplo n.º 3
0
 public void Render()
 {
     Geometries.ForEach(g => g.Render());
 }
Exemplo n.º 4
0
 public void CreateVBOs()
 {
     Geometries.ForEach(g => g.CreateVBOs());
 }