public static MGEOVertex Combine(MGEOVertex a, MGEOVertex b)
        {
            MGEOVertex vertex = new MGEOVertex();

            vertex.Position   = (a.Position == null && b.Position != null) ? b.Position : a.Position;
            vertex.Normal     = (a.Normal == null && b.Normal != null) ? b.Normal : a.Normal;
            vertex.DiffuseUV  = (a.DiffuseUV == null && b.DiffuseUV != null) ? b.DiffuseUV : a.DiffuseUV;
            vertex.LightmapUV = (a.LightmapUV == null && b.LightmapUV != null) ? b.LightmapUV : a.LightmapUV;

            return(vertex);
        }
Ejemplo n.º 2
0
        public MGEOVertexElementGroup(MGEOVertex vertex)
        {
            this.Usage = MGEOVertexElementGroupUsage.Static;

            if (vertex.Position != null)
            {
                this.VertexElements.Add(new MGEOVertexElement(MGEOVertexElementName.Position, MGEOVertexElementFormat.XYZ_Float32));
            }
            if (vertex.Normal != null)
            {
                this.VertexElements.Add(new MGEOVertexElement(MGEOVertexElementName.Normal, MGEOVertexElementFormat.XYZ_Float32));
            }
            if (vertex.DiffuseUV != null)
            {
                this.VertexElements.Add(new MGEOVertexElement(MGEOVertexElementName.DiffuseUV, MGEOVertexElementFormat.XY_Float32));
            }
            if (vertex.LightmapUV != null)
            {
                this.VertexElements.Add(new MGEOVertexElement(MGEOVertexElementName.LightmapUV, MGEOVertexElementFormat.XY_Float32));
            }
        }
Ejemplo n.º 3
0
        public MGEOObject(BinaryReader br, List <MGEOVertexElementGroup> vertexElementGroups, List <long> vertexBufferOffsets, List <ushort[]> indexBuffers, bool useSeparatePointLights, uint version)
        {
            this.Name = Encoding.ASCII.GetString(br.ReadBytes(br.ReadInt32()));
            uint vertexCount        = br.ReadUInt32();
            uint vertexBufferCount  = br.ReadUInt32();
            int  vertexElementGroup = br.ReadInt32();

            for (int i = 0; i < vertexCount; i++)
            {
                this.Vertices.Add(new MGEOVertex());
            }

            for (int i = 0, currentVertexElementGroup = vertexElementGroup; i < vertexBufferCount; i++, currentVertexElementGroup++)
            {
                int  vertexBufferID = br.ReadInt32();
                long returnPosition = br.BaseStream.Position;
                br.BaseStream.Seek(vertexBufferOffsets[vertexBufferID], SeekOrigin.Begin);

                for (int j = 0; j < vertexCount; j++)
                {
                    this.Vertices[j] = MGEOVertex.Combine(this.Vertices[j], new MGEOVertex(br, vertexElementGroups[currentVertexElementGroup].VertexElements));
                }

                br.BaseStream.Seek(returnPosition, SeekOrigin.Begin);
            }

            uint indexCount  = br.ReadUInt32();
            int  indexBuffer = br.ReadInt32();

            this.Indices.AddRange(indexBuffers[indexBuffer]);

            uint submeshCount = br.ReadUInt32();

            for (int i = 0; i < submeshCount; i++)
            {
                this.Submeshes.Add(new MGEOSubmesh(br, this));
            }

            if (version != 5)
            {
                this.Unknown1 = br.ReadBoolean();
            }

            this.BoundingBox    = new R3DBox(br);
            this.Transformation = new R3DMatrix44(br);
            this.Unknown2       = br.ReadByte();

            if (version == 7)
            {
                this.Unknown3 = br.ReadByte();
            }

            if (useSeparatePointLights)
            {
                this.SeparatePointLight = new Vector3(br);
            }
            for (int i = 0; i < 9; i++)
            {
                this.UnknownFloats.Add(new Vector3(br));
            }

            this.Lightmap = Encoding.ASCII.GetString(br.ReadBytes(br.ReadInt32()));
            this.Color    = new ColorRGBAVector4(br);
        }