private static void CreateMiniThing(ref SpecialTextures tex, List<int> rads, Color color) { tex = new SpecialTextures(); foreach (int rad in rads) tex.Add(rad.ToString(), new Texture(Drawing.OurDevice, CreateSphere(rad * ((MiniMap.Size*1.0)/WorkSpace.MapLen), color), Usage.None, Pool.Managed)); }
/// <summary> /// Exports the model to an .obj file /// </summary> /// <param name="baseVertex">The number of vertices we have processed so far in the model</param> /// <param name="objExportType"></param> /// <param name="vertexCount">The number of vertices in this model</param> /// <param name="activeTexture"></param> /// <param name="lastUsedTexture"></param> /// <returns></returns> public List <string> GetMeshExport(int baseVertex, string activeTexture, ObjExportType objExportType, out int vertexCount, out string lastUsedTexture) { var frames = new List <string>(); var usedVertices = new List <int>(); var unusedVertices = new List <int>(); int currentPolygon = 0; var faceOutput = new StringBuilder(); // First assemble the faces that are needed foreach (RenderGroup group in RenderGroups) { int textureIndex = group.TextureIndex; int polygonCount = group.PolygonCount; List <int> activeArray = null; bool bitmapValid = false; // Figure out the correct export array if (objExportType == ObjExportType.Textured) { activeArray = MaterialList.Materials[textureIndex].IsInvisible ? unusedVertices : usedVertices; bitmapValid = true; } else if (objExportType == ObjExportType.Collision) { activeArray = usedVertices; bitmapValid = false; } else if (objExportType == ObjExportType.Water) { if (MaterialList.Materials[textureIndex].IsInvisible) { activeArray = unusedVertices; bitmapValid = false; } else { string bitmapName = MaterialList.Materials[textureIndex].TextureInfoReference.TextureInfo .BitmapNames[0].Filename; activeArray = SpecialTextures.IsWater(bitmapName) ? usedVertices : unusedVertices; bitmapValid = SpecialTextures.IsWater(bitmapName); } } else if (objExportType == ObjExportType.Lava) { if (MaterialList.Materials[textureIndex].IsInvisible) { activeArray = unusedVertices; bitmapValid = false; } else { string bitmapName = MaterialList.Materials[textureIndex].TextureInfoReference.TextureInfo .BitmapNames[0].Filename; activeArray = SpecialTextures.IsLava(bitmapName) ? usedVertices : unusedVertices; bitmapValid = SpecialTextures.IsLava(bitmapName); } } else if (objExportType == ObjExportType.NoSpecialZones) { if (MaterialList.Materials[textureIndex].IsInvisible) { activeArray = unusedVertices; bitmapValid = false; } else { string bitmapName = MaterialList.Materials[textureIndex].TextureInfoReference.TextureInfo .BitmapNames[0].Filename; if (SpecialTextures.IsWater(bitmapName) || SpecialTextures.IsLava(bitmapName)) { activeArray = unusedVertices; bitmapValid = false; } else { activeArray = usedVertices; bitmapValid = true; } } } if (!MaterialList.Materials[textureIndex].IsInvisible && objExportType != ObjExportType.Collision) { string bitmapName = MaterialList.Materials[textureIndex].TextureInfoReference.TextureInfo .BitmapNames[0].Filename; string pngName = bitmapName.Substring(0, bitmapName.Length - 4); string materialName = ImageWriter.GetExportedImageName(pngName, MaterialList.Materials[textureIndex].ShaderType); if (materialName != activeTexture && bitmapValid) { faceOutput.AppendLine(LanternStrings.ObjUseMtlPrefix + materialName); activeTexture = materialName; } } for (int j = 0; j < polygonCount; ++j) { int vertex1 = Polygons[currentPolygon].Vertex1 + baseVertex + 1; int vertex2 = Polygons[currentPolygon].Vertex2 + baseVertex + 1; int vertex3 = Polygons[currentPolygon].Vertex3 + baseVertex + 1; if (!Polygons[currentPolygon].Solid && objExportType == ObjExportType.Collision) { continue; } if (activeArray == usedVertices) { int index1 = vertex1 - unusedVertices.Count; int index2 = vertex2 - unusedVertices.Count; int index3 = vertex3 - unusedVertices.Count; // Vertex + UV if (objExportType != ObjExportType.Collision) { faceOutput.AppendLine("f " + index3 + "/" + index3 + " " + index2 + "/" + index2 + " " + +index1 + "/" + index1); } else { faceOutput.AppendLine("f " + index3 + " " + index2 + " " + +index1); } } AddIfNotContained(activeArray, Polygons[currentPolygon].Vertex1); AddIfNotContained(activeArray, Polygons[currentPolygon].Vertex2); AddIfNotContained(activeArray, Polygons[currentPolygon].Vertex3); currentPolygon++; } } var vertexOutput = new StringBuilder(); usedVertices.Sort(); int frameCount = 1; if (AnimatedVertices != null) { frameCount += AnimatedVertices.Frames.Count; } for (int i = 0; i < frameCount; ++i) { // Add each vertex foreach (var usedVertex in usedVertices) { vec3 vertex; if (i == 0) { vertex = Vertices[usedVertex]; } else { if (AnimatedVertices == null) { continue; } vertex = AnimatedVertices.Frames[i - 1][usedVertex]; } vertexOutput.AppendLine("v " + (vertex.x + Center.x) + " " + (vertex.y + Center.y) + " " + (vertex.z + Center.z)); if (objExportType == ObjExportType.Collision) { continue; } vec2 vertexUvs = TextureUvCoordinates[usedVertex]; vertexOutput.AppendLine("vt " + vertexUvs.x + " " + vertexUvs.y); } frames.Add(vertexOutput.ToString() + faceOutput); vertexOutput.Clear(); } vertexCount = usedVertices.Count; lastUsedTexture = activeTexture; // Ensure that output use the decimal point rather than the comma (as in Germany) for (var i = 0; i < frames.Count; i++) { frames[i] = frames[i].Replace(',', '.'); } return(frames); }