Exemple #1
0
        public override IEnumerable <Object> FetchDependencies(ISerializedFile file, bool isLog = false)
        {
            foreach (Object @object in base.FetchDependencies(file, isLog))
            {
                yield return(@object);
            }

            foreach (Object @object in SplatDatabase.FetchDependencies(file, isLog))
            {
                yield return(@object);
            }
            foreach (Object @object in DetailDatabase.FetchDependencies(file, isLog))
            {
                yield return(@object);
            }
            foreach (Object @object in Heightmap.FetchDependencies(file, isLog))
            {
                yield return(@object);
            }

            if (IsReadLightmap(file.Version))
            {
                yield return(Lightmap.FetchDependency(file, isLog, ToLogString, "m_Lightmap"));
            }
        }
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.AddSerializedVersion(ToSerializedVersion(container.ExportVersion));
            node.Add(LightmapName, Lightmap.ExportYAML(container));
            if (HasIndirectLightmap(container.ExportVersion))
            {
                node.Add(IndirectLightmapName, IndirectLightmap.ExportYAML(container));
            }
            if (HasLightInd(container.ExportVersion))
            {
                node.Add(LightIndName, LightInd.ExportYAML(container));
                node.Add(DirIndName, DirInd.ExportYAML(container));
            }
            if (HasDirLightmap(container.ExportVersion))
            {
                node.Add(DirLightmapName, DirLightmap.ExportYAML(container));
            }
            if (HasShadowMask(container.ExportVersion))
            {
                node.Add(ShadowMaskName, ShadowMask.ExportYAML(container));
            }
            return(node);
        }
        public IEnumerable <Object> FetchDependencies(ISerializedFile file, bool isLog = false)
        {
            yield return(Lightmap.FetchDependency(file, isLog, () => nameof(LightmapData), "m_Lightmap"));

            yield return(DirLightmap.FetchDependency(file, isLog, () => nameof(LightmapData), "m_DirLightmap"));

            yield return(ShadowMask.FetchDependency(file, isLog, () => nameof(LightmapData), "m_ShadowMask"));
        }
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.AddSerializedVersion(GetSerializedVersion(container.ExportVersion));
            node.Add(LightmapName, Lightmap.ExportYAML(container));
            node.Add(DirLightmapName, DirLightmap.ExportYAML(container));
            node.Add(ShadowMaskName, ShadowMask.ExportYAML(container));
            return(node);
        }
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.AddSerializedVersion(GetSerializedVersion(container.Version));
            node.Add("m_Lightmap", Lightmap.ExportYAML(container));
            node.Add("m_DirLightmap", DirLightmap.ExportYAML(container));
            node.Add("m_ShadowMask", ShadowMask.ExportYAML(container));
            return(node);
        }
Exemple #6
0
        public override void Read(AssetStream stream)
        {
            base.Read(stream);

            SplatDatabase.Read(stream);
            DetailDatabase.Read(stream);
            Heightmap.Read(stream);
            if (IsReadLightmap(stream.Version))
            {
                Lightmap.Read(stream);
            }
        }
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            SplatDatabase.Read(reader);
            DetailDatabase.Read(reader);
            Heightmap.Read(reader);
            if (IsReadLightmap(reader.Version))
            {
                Lightmap.Read(reader);
            }
        }
 public void Read(AssetReader reader)
 {
     Lightmap.Read(reader);
     if (IsReadDirLightmap(reader.Version))
     {
         DirLightmap.Read(reader);
     }
     if (IsReadShadowMask(reader.Version))
     {
         ShadowMask.Read(reader);
     }
 }
Exemple #9
0
 public void Read(AssetStream stream)
 {
     Lightmap.Read(stream);
     if (IsReadDirLightmap(stream.Version))
     {
         DirLightmap.Read(stream);
     }
     if (IsReadShadowMask(stream.Version))
     {
         ShadowMask.Read(stream);
     }
 }
Exemple #10
0
        public override void Write(AssetWriter writer)
        {
            base.Write(writer);

            SplatDatabase.Write(writer);
            DetailDatabase.Write(writer);
            Heightmap.Write(writer);
            if (HasLightmap(writer.Version))
            {
                Lightmap.Write(writer);
            }
        }
Exemple #11
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.Add(SplatDatabaseName, SplatDatabase.ExportYAML(container));
            node.Add(DetailDatabaseName, DetailDatabase.ExportYAML(container));
            node.Add(HeightmapName, Heightmap.ExportYAML(container));
            if (HasLightmap(container.ExportVersion))
            {
                node.Add(LightmapName, Lightmap.ExportYAML(container));
            }
            return(node);
        }
Exemple #12
0
        public void Serialize(BitWriter writer)
        {
            writer.Write(Index);

            HeightMap.Serialize(writer);

            Colormap0.Serialize(writer);

            Lightmap.Serialize(writer);

            Colormap1.Serialize(writer);

            writer.Write(TextureSetting);

            Blendmap.Serialize(writer);

            writer.Write(Foliage.Count);

            foreach (var foliage in Foliage)
            {
                foliage.Serialize(writer);
            }

            foreach (var unknownByte in ColorRelatedArray)
            {
                writer.Write(unknownByte);
            }

            ShortMap.Serialize(writer);

            if (ShortMap.Data.Length == default)
            {
                return;
            }

            for (var i = 0; i < 32; i++)
            {
                writer.Write(UnknownByteArray1[i]);
            }

            for (var i = 0; i < 16; i++)
            {
                writer.Write((short)UnknownShortArray[i].Length);

                for (var j = 0; j < UnknownShortArray[i].Length; j++)
                {
                    writer.Write(UnknownShortArray[i][j]);
                }
            }
        }
Exemple #13
0
        public void PlaceLight(int x, int y, int radius)
        {
            Point xRange = GetMinMaxSubtileRange(0, x, radius + 1);
            Point yRange = GetMinMaxSubtileRange(1, y, radius + 1);

            Vector2 center = new Vector2(x, y) * Tile.FOOT + Tile.Origin;

            float fullDistance = radius * Tile.FOOT;
            float duskDistance = fullDistance + Tile.FOOT;

            float   distance;
            Vector2 subtilePos;

            Console.WriteLine("Placing light at X: " + xRange + ", Y: " + yRange);

            for (int subY = yRange.X; subY < yRange.Y; subY++)
            {
                for (int subX = xRange.X; subX < xRange.Y; subX++)
                {
                    subtilePos = new Vector2(subX * Subtile.Quarter, subY * Subtile.Quarter) + Subtile.Origin;
                    distance   = Vector2.Distance(center, subtilePos);

                    if (distance < fullDistance)
                    {
                        Lightmap[subX, subY] = 2;
                    }
                    else if (distance < duskDistance)
                    {
                        Lightmap[subX, subY] = 1;
                    }
                }
            }

            for (int subY = 0; subY < Lightmap.GetLength(1); subY++)
            {
                string line = "";
                for (int subX = 0; subX < Lightmap.GetLength(0); subX++)
                {
                    string sub = Lightmap[subX, subY].ToString();
                    if (sub == "0")
                    {
                        sub = " ";
                    }
                    line += sub;
                }
                //Console.WriteLine(line);
            }
        }
Exemple #14
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            SplatDatabase.Read(reader);
            DetailDatabase.Read(reader);
            Heightmap.Read(reader);
            if (HasLightmap(reader.Version))
            {
                Lightmap.Read(reader);
            }
            if (HasPreloadShaders(reader.Version))
            {
                PreloadShaders = reader.ReadAssetArray <PPtr <Shader> >();
            }
        }
Exemple #15
0
 public void Read(AssetReader reader)
 {
     Lightmap.Read(reader);
     if (HasIndirectLightmap(reader.Version))
     {
         IndirectLightmap.Read(reader);
     }
     if (HasLightInd(reader.Version))
     {
         LightInd.Read(reader);
         DirInd.Read(reader);
     }
     if (HasDirLightmap(reader.Version))
     {
         DirLightmap.Read(reader);
         ShadowMask.Read(reader);
     }
 }
Exemple #16
0
 public void Write(AssetWriter writer)
 {
     Lightmap.Write(writer);
     if (HasIndirectLightmap(writer.Version))
     {
         IndirectLightmap.Write(writer);
     }
     if (HasLightInd(writer.Version))
     {
         LightInd.Write(writer);
         DirInd.Write(writer);
     }
     if (HasDirLightmap(writer.Version))
     {
         DirLightmap.Write(writer);
         ShadowMask.Write(writer);
     }
 }
        /// <summary>
        /// Creates info classes for a structure lightmap
        /// </summary>
        void GenerateInfoListLightmap()
        {
            string name = Path.GetFileNameWithoutExtension(tagManager.Name);

            int vertex_count, triangle_count;

            vertex_count   = Lightmap.GetVertexCount(tagManager);
            triangle_count = Lightmap.GetTriangleCount(tagManager);

            if ((vertex_count > 0) && (triangle_count > 0))
            {
                LightmapInfoInternal lightmap_info_internal = new LightmapInfoInternal();
                internalInfoList.Add(lightmap_info_internal);

                Add(new ColladaHalo2LightmapInfo(internalInfoList.Count - 1,
                                                 name,
                                                 vertex_count,
                                                 triangle_count));
            }
        }
Exemple #18
0
        public bool Load(Stream gnd)
        {
            int          texChunkSize, textureCount;
            BinaryReader br     = new BinaryReader(gnd);
            string       header = ((char)br.ReadByte()).ToString() + ((char)br.ReadByte()) + ((char)br.ReadByte()) + ((char)br.ReadByte());

            if (header == "GRGN")
            {
                majorVersion = br.ReadByte();
                minorVersion = br.ReadByte();

                if (majorVersion != 1 || minorVersion < 5 || minorVersion > 7)
                {
                    return(false);
                }

                _width  = br.ReadInt32();
                _height = br.ReadInt32();
                _zoom   = br.ReadSingle();

                textureCount = br.ReadInt32();

                texChunkSize = br.ReadInt32();
            }
            else
            {
                majorVersion = 0;
                minorVersion = 0;

                br.BaseStream.Position = 0;

                textureCount = br.ReadInt32();

                _width  = br.ReadInt32();
                _height = br.ReadInt32();
                _zoom   = 10.0f;

                texChunkSize = 80;
            }

            _textures = new Texture2D[textureCount];

            for (int i = 0; i < _textures.Length; i++)
            {
                _textures[i] = SharedInformation.ContentManager.Load <Texture2D>(@"data\texture\" + br.ReadCString(texChunkSize));
            }

            if (majorVersion == 0 && minorVersion == 0)
            {
                int idx = 0;
                _lightmaps = new Lightmap[0];
                _cells     = new Cell[_width * _height];
                // Biggest possible amount of surfaces in this version is 3 * Width * Height.
                // We resize it to the real amount after iterating through the cells.
                _surfaces = new Surface[3 * _width * _height];
                for (int i = 0; i < _cells.Length; i++)
                {
                    int textureUp, textureOtherSide, textureSide;

                    textureUp        = br.ReadInt32();
                    textureOtherSide = br.ReadInt32();
                    textureSide      = br.ReadInt32();

                    Cell c = new Cell();

                    c.Load(br, majorVersion, minorVersion);

                    if (textureUp != -1)
                    {
                        Surface s = new Surface();

                        s.Load(this, br, majorVersion, minorVersion, textureUp);

                        textureUp = idx;

                        _surfaces[idx++] = s;
                    }
                    else
                    {
                        br.ReadBytes(32);
                    }

                    if (textureOtherSide != -1)
                    {
                        Surface s = new Surface();

                        s.Load(this, br, majorVersion, minorVersion, textureOtherSide);

                        textureOtherSide = idx;

                        _surfaces[idx++] = s;
                    }
                    else
                    {
                        br.ReadBytes(32);
                    }

                    if (textureSide != -1)
                    {
                        Surface s = new Surface();

                        s.Load(this, br, majorVersion, minorVersion, textureSide);

                        textureSide = idx;

                        _surfaces[idx++] = s;
                    }
                    else
                    {
                        br.ReadBytes(32);
                    }

                    c.SetTiles(textureUp, textureSide, textureOtherSide);

                    _cells[i] = c;
                }
                Array.Resize <Surface>(ref _surfaces, idx);
            }
            else
            {
                _lightmaps = new Lightmap[br.ReadInt32()];

                br.ReadInt32(); // Lightmap Width  = 8
                br.ReadInt32(); // Lightmap Height = 8
                br.ReadInt32(); // Lightmap Cells  = 1

                for (int i = 0; i < _lightmaps.Length; i++)
                {
                    Lightmap l = new Lightmap();

                    l.Load(br);

                    _lightmaps[i] = l;
                }

                _surfaces = new Surface[br.ReadInt32()];
                for (int i = 0; i < _surfaces.Length; i++)
                {
                    Surface s = new Surface();

                    s.Load(this, br, majorVersion, minorVersion);

                    _surfaces[i] = s;
                }

                _cells = new Cell[_width * _height];
                for (int i = 0; i < _cells.Length; i++)
                {
                    Cell c = new Cell();

                    c.Load(br, majorVersion, minorVersion);

                    _cells[i] = c;
                }
            }

            Logger.WriteLine("Calculating normals...");
            CalculateNormals();

            Logger.WriteLine("Creating ground vertex buffer...");
            SetupVertices();

            Logger.WriteLine("Ground v{0}.{1} status: {2} textures - {3} lightmaps - {4} surfaces - {5} cells - {6} vertices", majorVersion, minorVersion, _textures.Length, _lightmaps.Length, _surfaces.Length, _cells.Length, _vertices.VertexCount);

            return(true);
        }
Exemple #19
0
        public bool Load(Stream gnd)
        {
            int texChunkSize, textureCount;
            BinaryReader br = new BinaryReader(gnd);
            string header = ((char)br.ReadByte()).ToString() + ((char)br.ReadByte()) + ((char)br.ReadByte()) + ((char)br.ReadByte());

            if (header == "GRGN")
            {
                majorVersion = br.ReadByte();
                minorVersion = br.ReadByte();

                if (majorVersion != 1 || minorVersion < 5 || minorVersion > 7)
                    return false;

                _width = br.ReadInt32();
                _height = br.ReadInt32();
                _zoom = br.ReadSingle();

                textureCount = br.ReadInt32();

                texChunkSize = br.ReadInt32();
            }
            else
            {
                majorVersion = 0;
                minorVersion = 0;

                br.BaseStream.Position = 0;

                textureCount = br.ReadInt32();

                _width = br.ReadInt32();
                _height = br.ReadInt32();
                _zoom = 10.0f;

                texChunkSize = 80;
            }

            _textures = new Texture2D[textureCount];

            for (int i = 0; i < _textures.Length; i++)
            {
                _textures[i] = SharedInformation.ContentManager.Load<Texture2D>(@"data\texture\" + br.ReadCString(texChunkSize));
            }

            if (majorVersion == 0 && minorVersion == 0)
            {
                int idx = 0;
                _lightmaps = new Lightmap[0];
                _cells = new Cell[_width * _height];
                // Biggest possible amount of surfaces in this version is 3 * Width * Height.
                // We resize it to the real amount after iterating through the cells.
                _surfaces = new Surface[3 * _width * _height];
                for (int i = 0; i < _cells.Length; i++)
                {
                    int textureUp, textureOtherSide, textureSide;

                    textureUp = br.ReadInt32();
                    textureOtherSide = br.ReadInt32();
                    textureSide = br.ReadInt32();

                    Cell c = new Cell();

                    c.Load(br, majorVersion, minorVersion);

                    if (textureUp != -1)
                    {
                        Surface s = new Surface();

                        s.Load(this, br, majorVersion, minorVersion, textureUp);

                        textureUp = idx;

                        _surfaces[idx++] = s;
                    }
                    else
                    {
                        br.ReadBytes(32);
                    }

                    if (textureOtherSide != -1)
                    {
                        Surface s = new Surface();

                        s.Load(this, br, majorVersion, minorVersion, textureOtherSide);

                        textureOtherSide = idx;

                        _surfaces[idx++] = s;
                    }
                    else
                    {
                        br.ReadBytes(32);
                    }

                    if (textureSide != -1)
                    {
                        Surface s = new Surface();

                        s.Load(this, br, majorVersion, minorVersion, textureSide);

                        textureSide = idx;

                        _surfaces[idx++] = s;
                    }
                    else
                    {
                        br.ReadBytes(32);
                    }

                    c.SetTiles(textureUp, textureSide, textureOtherSide);

                    _cells[i] = c;
                }
                Array.Resize<Surface>(ref _surfaces, idx);
            }
            else
            {

                _lightmaps = new Lightmap[br.ReadInt32()];

                br.ReadInt32(); // Lightmap Width  = 8
                br.ReadInt32(); // Lightmap Height = 8
                br.ReadInt32(); // Lightmap Cells  = 1

                for (int i = 0; i < _lightmaps.Length; i++)
                {
                    Lightmap l = new Lightmap();

                    l.Load(br);

                    _lightmaps[i] = l;
                }

                _surfaces = new Surface[br.ReadInt32()];
                for (int i = 0; i < _surfaces.Length; i++)
                {
                    Surface s = new Surface();

                    s.Load(this, br, majorVersion, minorVersion);

                    _surfaces[i] = s;
                }

                _cells = new Cell[_width * _height];
                for (int i = 0; i < _cells.Length; i++)
                {
                    Cell c = new Cell();

                    c.Load(br, majorVersion, minorVersion);

                    _cells[i] = c;
                }
            }

            Logger.WriteLine("Calculating normals...");
            CalculateNormals();

            Logger.WriteLine("Creating ground vertex buffer...");
            SetupVertices();

            Logger.WriteLine("Ground v{0}.{1} status: {2} textures - {3} lightmaps - {4} surfaces - {5} cells - {6} vertices", majorVersion, minorVersion, _textures.Length, _lightmaps.Length, _surfaces.Length, _cells.Length, _vertices.VertexCount);

            return true;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Collate's the lightmap geometry from a COLLADA file into a usable format. </summary>
        ///
        /// <param name="colladaFile">	The collada file. </param>
        ///
        /// <returns>	A list of lightmap mesh data. </returns>
        List <Lightmap> CollateLightmapGeometry(ColladaFile colladaFile)
        {
            var lightmapMeshes = new List <Lightmap>();

            // Collect the geometry info
            foreach (var geometry in colladaFile.LibraryGeometries.Geometry)
            {
                if (geometry.Mesh == null)
                {
                    SendMessage(String.Format("The geometry {0} does not have a mesh", geometry.Name));
                    return(null);
                }

                if (geometry.Mesh.Triangles.Count == 0)
                {
                    SendMessage(String.Format("The geometry {0} has no triangles", geometry.Name));
                    return(null);
                }

                // Get the lightmap index from the end of the geometry name
                if (geometry.Name.EndsWith("-1"))
                {
                    continue;
                }

                var indexString = Regex.Match(geometry.Name, @"\d+$").Value;
                if (System.String.IsNullOrEmpty(indexString))
                {
                    SendMessage(String.Format("The geometry {0} does not have the lightmap index at the end of it's name", geometry.Name));
                    return(null);
                }
                int lightmapIndex = Int32.Parse(indexString);

                // Create the lightmap entry
                var lightmap = new Lightmap()
                {
                    LightmapIndex = lightmapIndex, Faces = new List <Lightmap.Face>()
                };

                foreach (var triangles in geometry.Mesh.Triangles)
                {
                    // Get the input object containing the texture coordinates
                    var texcoord1Input = triangles.Input.Find(entry => (entry.Set == 1) && (entry.Semantic == ColladaInputSharedSemantic.TEXCOORD));
                    if (texcoord1Input == null)
                    {
                        SendMessage(String.Format("Unable to find a second texture coordinate for geometry {0}", geometry.Name));
                        return(null);
                    }
                    var sourceID = texcoord1Input.Source.TrimStart('#');

                    // Get the source array for the coord data
                    var sourceArray = geometry.Mesh.Source.Find(
                        entry =>
                    {
                        return(entry.ID.EndsWith(sourceID));
                    }
                        );

                    if (sourceArray == null)
                    {
                        SendMessage(String.Format("Unable to find a texture coordinate source array for geometry {0}", geometry.Name));
                        return(null);
                    }

                    if (sourceArray.FloatArray == null)
                    {
                        SendMessage(String.Format("Unable to find a texture coordinate source array for geometry {0}", geometry.Name));
                        return(null);
                    }

                    // Collect the vertex data
                    int sourceArrayStride = (int)sourceArray.TechniqueCommon.Accessor.Stride;
                    var indexStride       = (triangles.P.Values.Count / 3) / (int)triangles.Count;

                    foreach (var faceIndex in Enumerable.Range(0, (int)triangles.Count))
                    {
                        var face = new Lightmap.Face();

                        // Get the index of the texture coordinates for the face vertices
                        int faceOffset = (indexStride * 3) * faceIndex;                         // Offset to start of current face

                        int vertex0Offset = faceOffset + (0 * indexStride) + (int)texcoord1Input.Offset;
                        int vertex1Offset = faceOffset + (1 * indexStride) + (int)texcoord1Input.Offset;
                        int vertex2Offset = faceOffset + (2 * indexStride) + (int)texcoord1Input.Offset;

                        int vertex0Index = triangles.P.Values[vertex0Offset];
                        int vertex1Index = triangles.P.Values[vertex1Offset];
                        int vertex2Index = triangles.P.Values[vertex2Offset];

                        // Get the data from the float array
                        int uIndex = (vertex0Index * sourceArrayStride);
                        int vIndex = (vertex0Index * sourceArrayStride) + 1;
                        face.Vertex0.X = sourceArray.FloatArray.Values[uIndex];
                        face.Vertex0.Y = (sourceArray.FloatArray.Values[vIndex] - 1) * -1;

                        uIndex         = (vertex1Index * sourceArrayStride);
                        vIndex         = (vertex1Index * sourceArrayStride) + 1;
                        face.Vertex1.X = sourceArray.FloatArray.Values[uIndex];
                        face.Vertex1.Y = (sourceArray.FloatArray.Values[vIndex] - 1) * -1;

                        uIndex         = (vertex2Index * sourceArrayStride);
                        vIndex         = (vertex2Index * sourceArrayStride) + 1;
                        face.Vertex2.X = sourceArray.FloatArray.Values[uIndex];
                        face.Vertex2.Y = (sourceArray.FloatArray.Values[vIndex] - 1) * -1;

                        lightmap.Faces.Add(face);
                    }
                }

                lightmapMeshes.Add(lightmap);
            }

            return(lightmapMeshes);
        }
		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Collate's the lightmap geometry from a COLLADA file into a usable format. </summary>
		///
		/// <param name="colladaFile">	The collada file. </param>
		///
		/// <returns>	A list of lightmap mesh data. </returns>
		List<Lightmap> CollateLightmapGeometry(ColladaFile colladaFile)
		{
			var lightmapMeshes = new List<Lightmap>();

			// Collect the geometry info
			foreach (var geometry in colladaFile.LibraryGeometries.Geometry)
			{
				if (geometry.Mesh == null)
				{
					SendMessage(String.Format("The geometry {0} does not have a mesh", geometry.Name));
					return null;
				}

				if (geometry.Mesh.Triangles.Count == 0)
				{
					SendMessage(String.Format("The geometry {0} has no triangles", geometry.Name));
					return null;
				}

				// Get the lightmap index from the end of the geometry name
				if(geometry.Name.EndsWith("-1"))
				{
					continue;
				}

				var indexString = Regex.Match(geometry.Name, @"\d+$").Value;
				if (System.String.IsNullOrEmpty(indexString))
				{
					SendMessage(String.Format("The geometry {0} does not have the lightmap index at the end of it's name", geometry.Name));
					return null;
				}
				int lightmapIndex = Int32.Parse(indexString);

				// Create the lightmap entry
				var lightmap = new Lightmap() { LightmapIndex = lightmapIndex, Faces = new List<Lightmap.Face>() };

				foreach (var triangles in geometry.Mesh.Triangles)
				{
					// Get the input object containing the texture coordinates
					var texcoord1Input = triangles.Input.Find(entry => (entry.Set == 1) && (entry.Semantic == ColladaInputSharedSemantic.TEXCOORD));
					if (texcoord1Input == null)
					{
						SendMessage(String.Format("Unable to find a second texture coordinate for geometry {0}", geometry.Name));
						return null;
					}
					var sourceID = texcoord1Input.Source.TrimStart('#');

					// Get the source array for the coord data
					var sourceArray = geometry.Mesh.Source.Find(
						entry =>
						{
							return entry.ID.EndsWith(sourceID);
						}
					);

					if (sourceArray == null)
					{
						SendMessage(String.Format("Unable to find a texture coordinate source array for geometry {0}", geometry.Name));
						return null;
					}

					if (sourceArray.FloatArray == null)
					{
						SendMessage(String.Format("Unable to find a texture coordinate source array for geometry {0}", geometry.Name));
						return null;
					}

					// Collect the vertex data
					int sourceArrayStride = (int)sourceArray.TechniqueCommon.Accessor.Stride;
					var indexStride = (triangles.P.Values.Count / 3) / (int)triangles.Count;

					foreach (var faceIndex in Enumerable.Range(0, (int)triangles.Count))
					{
						var face = new Lightmap.Face();

						// Get the index of the texture coordinates for the face vertices
						int faceOffset = (indexStride * 3) * faceIndex; // Offset to start of current face

						int vertex0Offset = faceOffset + (0 * indexStride) + (int)texcoord1Input.Offset;
						int vertex1Offset = faceOffset + (1 * indexStride) + (int)texcoord1Input.Offset;
						int vertex2Offset = faceOffset + (2 * indexStride) + (int)texcoord1Input.Offset;

						int vertex0Index = triangles.P.Values[vertex0Offset];
						int vertex1Index = triangles.P.Values[vertex1Offset];
						int vertex2Index = triangles.P.Values[vertex2Offset];

						// Get the data from the float array
						int uIndex = (vertex0Index * sourceArrayStride);
						int vIndex = (vertex0Index * sourceArrayStride) + 1;
						face.Vertex0.X = sourceArray.FloatArray.Values[uIndex];
						face.Vertex0.Y = (sourceArray.FloatArray.Values[vIndex] - 1) * -1;

						uIndex = (vertex1Index * sourceArrayStride);
						vIndex = (vertex1Index * sourceArrayStride) + 1;
						face.Vertex1.X = sourceArray.FloatArray.Values[uIndex];
						face.Vertex1.Y = (sourceArray.FloatArray.Values[vIndex] - 1) * -1;

						uIndex = (vertex2Index * sourceArrayStride);
						vIndex = (vertex2Index * sourceArrayStride) + 1;
						face.Vertex2.X = sourceArray.FloatArray.Values[uIndex];
						face.Vertex2.Y = (sourceArray.FloatArray.Values[vIndex] - 1) * -1;

						lightmap.Faces.Add(face);
					}
				}

				lightmapMeshes.Add(lightmap);
			}

			return lightmapMeshes;
		}