public override string ToString() { return("Min[" + TgcParserUtils.printFloat(pMin.X) + ", " + TgcParserUtils.printFloat(pMin.Y) + ", " + TgcParserUtils.printFloat(pMin.Z) + "]" + " Max[" + TgcParserUtils.printFloat(pMax.X) + ", " + TgcParserUtils.printFloat(pMax.Y) + ", " + TgcParserUtils.printFloat(pMax.Z) + "]"); }
public override string ToString() { return("Origin[" + TgcParserUtils.printFloat(Origin.X) + ", " + TgcParserUtils.printFloat(Origin.Y) + ", " + TgcParserUtils.printFloat(Origin.Z) + "]" + " Direction[" + TgcParserUtils.printFloat(direction.X) + ", " + TgcParserUtils.printFloat(direction.Y) + ", " + TgcParserUtils.printFloat(direction.Z) + "]"); }
/// <summary> /// String de codigo para setear la camara desde GuiController, con la posicion actual y direccion de la camara /// </summary> internal string getPositionCode() { //TODO ver de donde carajo sacar el LookAt de esta camara Vector3 lookAt = this.LookAt; return("GuiController.Instance.setCamera(new Vector3(" + TgcParserUtils.printFloat(eye.X) + "f, " + TgcParserUtils.printFloat(eye.Y) + "f, " + TgcParserUtils.printFloat(eye.Z) + "f), new Vector3(" + TgcParserUtils.printFloat(lookAt.X) + "f, " + TgcParserUtils.printFloat(lookAt.Y) + "f, " + TgcParserUtils.printFloat(lookAt.Z) + "f));"); }
/// <summary> /// Configura la posicion de la cámara /// </summary> /// <param name="pos">Posición de la cámara</param> /// <param name="lookAt">Punto hacia el cuál se quiere ver</param> public void setCamera(Vector3 pos, Vector3 lookAt) { tgcD3dDevice.D3dDevice.Transform.View = Matrix.LookAtLH(pos, lookAt, new Vector3(0, 1, 0)); //Imprimir posicion string statusPos = "Position: [" + TgcParserUtils.printFloat(pos.X) + ", " + TgcParserUtils.printFloat(pos.Y) + ", " + TgcParserUtils.printFloat(pos.Z) + "] " + "- LookAt: [" + TgcParserUtils.printFloat(lookAt.X) + ", " + TgcParserUtils.printFloat(lookAt.Y) + ", " + TgcParserUtils.printFloat(lookAt.Z) + "]"; mainForm.setStatusPosition(statusPos); }
/// <summary> /// Actualiza en la pantalla principal la posicion actual de la camara /// </summary> private void setStatusPosition() { //Actualizar el textbox en todos los cuadros reduce los FPS en algunas PC if (mainForm.MostrarPosicionDeCamaraEnable) { Vector3 pos = currentCamera.getPosition(); Vector3 lookAt = currentCamera.getLookAt(); string statusPosition = "Position: [" + TgcParserUtils.printFloat(pos.X) + ", " + TgcParserUtils.printFloat(pos.Y) + ", " + TgcParserUtils.printFloat(pos.Z) + "] " + "- LookAt: [" + TgcParserUtils.printFloat(lookAt.X) + ", " + TgcParserUtils.printFloat(lookAt.Y) + ", " + TgcParserUtils.printFloat(lookAt.Z) + "]"; mainForm.setStatusPosition(statusPosition); } }
/// <summary> /// Carga una malla estatica de formato TGC /// </summary> private void loadMesh(string path) { currentPath = path; //Dispose de escena anterior if (currentScene != null) { currentScene.disposeAll(); } //Cargar escena con herramienta TgcSceneLoader var loader = new TgcSceneLoader(); currentScene = loader.loadSceneFromFile(path); //Ajustar camara en base al tamano del objeto Camara = new TgcRotationalCamera(currentScene.BoundingBox.calculateBoxCenter(), currentScene.BoundingBox.calculateBoxRadius() * 2, Input); //Calcular cantidad de triangulos y texturas var triangleCount = 0; var verticesCount = 0; var texturesCount = 0; foreach (var mesh in currentScene.Meshes) { triangleCount += mesh.NumberTriangles; verticesCount += mesh.NumberVertices; texturesCount += mesh.RenderType == TgcMesh.MeshRenderType.VERTEX_COLOR ? 0 : mesh.DiffuseMaps.Length; } //UserVars UserVars.setValue("Name", currentScene.SceneName); UserVars.setValue("Meshes", currentScene.Meshes.Count); UserVars.setValue("Textures", texturesCount); UserVars.setValue("Triangles", triangleCount); UserVars.setValue("Vertices", verticesCount); var size = currentScene.BoundingBox.calculateSize(); UserVars.setValue("SizeX", TgcParserUtils.printFloat(size.X)); UserVars.setValue("SizeY", TgcParserUtils.printFloat(size.Y)); UserVars.setValue("SizeZ", TgcParserUtils.printFloat(size.Z)); }
/// <summary> /// Carga una malla estatica de formato TGC /// </summary> private void loadMesh(string path) { currentPath = path; //Dispose de escena anterior if (currentScene != null) { currentScene.disposeAll(); } //Cargar escena con herramienta TgcSceneLoader TgcSceneLoader loader = new TgcSceneLoader(); currentScene = loader.loadSceneFromFile(path); //Ajustar camara en base al tamaño del objeto GuiController.Instance.RotCamera.targetObject(currentScene.BoundingBox); //Calcular cantidad de triangulos y texturas int triangleCount = 0; int verticesCount = 0; int texturesCount = 0; foreach (TgcMesh mesh in currentScene.Meshes) { triangleCount += mesh.NumberTriangles; verticesCount += mesh.NumberVertices; texturesCount += mesh.RenderType == TgcMesh.MeshRenderType.VERTEX_COLOR ? 0 : mesh.DiffuseMaps.Length; } //UserVars GuiController.Instance.UserVars.setValue("Name", currentScene.SceneName); GuiController.Instance.UserVars.setValue("Meshes", currentScene.Meshes.Count); GuiController.Instance.UserVars.setValue("Textures", texturesCount); GuiController.Instance.UserVars.setValue("Triangles", triangleCount); GuiController.Instance.UserVars.setValue("Vertices", verticesCount); Vector3 size = currentScene.BoundingBox.calculateSize(); GuiController.Instance.UserVars.setValue("SizeX", TgcParserUtils.printFloat(size.X)); GuiController.Instance.UserVars.setValue("SizeY", TgcParserUtils.printFloat(size.Y)); GuiController.Instance.UserVars.setValue("SizeZ", TgcParserUtils.printFloat(size.Z)); }
public override string ToString() { return("Center[" + TgcParserUtils.printFloat(Center.X) + ", " + TgcParserUtils.printFloat(Center.Y) + ", " + TgcParserUtils.printFloat(Center.Z) + "]" + " Radius[" + TgcParserUtils.printFloat(Radius) + "]"); }
/// <summary> /// Imprime un TGCVector3 de la forma [150.0,150.0,150.0] /// </summary> /// <returns>String para poder visualizar las coordenadas del Vector.</returns> public static string PrintTGCVector3(float x, float y, float z) { return("[" + TgcParserUtils.printFloat(x) + "," + TgcParserUtils.printFloat(y) + "," + TgcParserUtils.printFloat(z) + "]"); }
public static void log(string text, float n) { BigLogger.log(text + ": " + TgcParserUtils.printFloat(n)); }
/// <summary> /// Imprime un TGCVector2 de la forma [150.0,150.0] /// </summary> /// <returns></returns> public static string PrintVector2(float x, float y) { return("[" + TgcParserUtils.printFloat(x) + "," + TgcParserUtils.printFloat(y) + "]"); }
/// <summary> /// Graba todo el mapa a un XML propio del Modifier para que luego el escenario pueda /// ser restaurado y seguir trabajando. /// Copia todas las texturas utilizadas a una subcarpeta relativa al directorio donde se guarda /// </summary> private void saveMap(string saveDir, string savePath) { //Crear directorio de texturas, respetar si ya existe porque puede ser la fuente de las texturas de ahora var texturesDir = saveDir + "\\" + DEFAULT_TEXTURES_DIR; if (!Directory.Exists(texturesDir)) { Directory.CreateDirectory(texturesDir); } //Crear XML var doc = new XmlDocument(); XmlNode root = doc.CreateElement("roomsEditor-Map"); //mapSettings var mapSettingsNode = doc.CreateElement("mapSettings"); mapSettingsNode.SetAttribute("width", mapView.MapSize.Width.ToString()); mapSettingsNode.SetAttribute("height", mapView.MapSize.Height.ToString()); mapSettingsNode.SetAttribute("scaleX", TgcParserUtils.printFloat(mapView.MapScale.X)); mapSettingsNode.SetAttribute("scaleY", TgcParserUtils.printFloat(mapView.MapScale.Y)); mapSettingsNode.SetAttribute("scaleZ", TgcParserUtils.printFloat(mapView.MapScale.Z)); root.AppendChild(mapSettingsNode); //rooms var roomsNode = doc.CreateElement("rooms"); roomsNode.SetAttribute("count", Rooms.Count.ToString()); foreach (var room in Rooms) { //room var roomNode = doc.CreateElement("room"); roomNode.SetAttribute("name", room.Name); roomNode.SetAttribute("x", room.RoomPanel.Label.Location.X.ToString()); roomNode.SetAttribute("y", room.RoomPanel.Label.Location.Y.ToString()); roomNode.SetAttribute("width", room.RoomPanel.Label.Width.ToString()); roomNode.SetAttribute("length", room.RoomPanel.Label.Height.ToString()); roomNode.SetAttribute("height", room.Height.ToString()); roomNode.SetAttribute("floorLevel", room.FloorLevel.ToString()); foreach (var wall in room.Walls) { //wall var wallNode = doc.CreateElement("wall"); wallNode.SetAttribute("name", wall.Name); wallNode.SetAttribute("textureName", wall.Texture.FileName); wallNode.SetAttribute("autoAdjustUv", wall.AutoAdjustUv.ToString()); wallNode.SetAttribute("uTile", wall.UTile.ToString()); wallNode.SetAttribute("vTile", wall.VTile.ToString()); roomNode.AppendChild(wallNode); //copiar textura, respetar si ya existe porque puede ser la fuente actual var textDest = texturesDir + "\\" + wall.Texture.FileName; if (!File.Exists(textDest)) { File.Copy(wall.Texture.FilePath, textDest, true); } } roomsNode.AppendChild(roomNode); } root.AppendChild(roomsNode); //Guardar XML doc.AppendChild(root); doc.Save(savePath); MessageBox.Show(this, "Map saved OK", "Save Map", MessageBoxButtons.OK, MessageBoxIcon.Information); }