/// <summary> /// Construir plano /// </summary> public override void doCreation() { var input = Control.creator.Input; //Si hacen clic con el mouse, ver si hay colision con el suelo if (input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Obtener altura en Y segun movimient en Y del mouse var heightY = creatingInitMouseY - input.Ypos; var adjustedHeightY = MeshCreatorUtils.getMouseIncrementHeightSpeed(Control.Camera, BoundingBox, heightY); //Determinar posicion Z segun la colision con el grid var collisionPoint = Control.Grid.getPicking(); var extensionPoint = new TGCVector3(initSelectionPoint.X, initSelectionPoint.Y + adjustedHeightY, collisionPoint.Z); //Obtener maximo y minimo var min = TGCVector3.Minimize(initSelectionPoint, extensionPoint); var max = TGCVector3.Maximize(initSelectionPoint, extensionPoint); min.X = initSelectionPoint.X; max.X = initSelectionPoint.X + 1; //Configurar plano mesh.setExtremes(min, max); mesh.updateValues(); } //Solto el clic del mouse, generar plano definitivo else if (input.buttonUp(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Tiene el tamaño minimo tolerado var size = mesh.BoundingBox.calculateSize(); if (size.Y > 1 && size.Z > 1) { //Guardar size original del plano para hacer Scaling originalSize = mesh.Size; //Dejar cargado para que se pueda crear un nuevo plano Control.CurrentState = MeshCreatorModifier.State.CreatePrimitiveSelected; Control.CreatingPrimitive = new PlaneYZPrimitive(Control); //Agregar plano a la lista de modelos Control.AddMesh(this); //Seleccionar plano Control.SelectionRectangle.clearSelection(); Control.SelectionRectangle.selectObject(this); Control.UpdateModifyPanel(); } //Sino, descartar else { Control.CurrentState = MeshCreatorModifier.State.CreatePrimitiveSelected; mesh.Dispose(); mesh = null; } } }
/// <summary> /// Construir plano /// </summary> public override void doCreation() { var input = Control.creator.Input; //Si hacen clic con el mouse, ver si hay colision con el suelo if (input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Determinar el size en XZ del box var collisionPoint = Control.Grid.getPicking(); //Obtener extremos del rectángulo de selección var min = TGCVector3.Minimize(initSelectionPoint, collisionPoint); var max = TGCVector3.Maximize(initSelectionPoint, collisionPoint); min.Y = 0; max.Y = 1; //Configurar plano mesh.setExtremes(min, max); mesh.updateValues(); } //Solto el clic del mouse, generar plano definitivo else if (input.buttonUp(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Tiene el tamaño minimo tolerado var size = mesh.BoundingBox.calculateSize(); if (size.X > 1 && size.Z > 1) { //Guardar size original del plano para hacer Scaling originalSize = mesh.Size; //Dejar cargado para que se pueda crear un nuevo plano Control.CurrentState = MeshCreatorModifier.State.CreatePrimitiveSelected; Control.CreatingPrimitive = new TGCPlaneXZPrimitive(Control); //Agregar plano a la lista de modelos Control.AddMesh(this); //Seleccionar plano Control.SelectionRectangle.clearSelection(); Control.SelectionRectangle.selectObject(this); Control.UpdateModifyPanel(); } //Sino, descartar else { Control.CurrentState = MeshCreatorModifier.State.CreatePrimitiveSelected; mesh.Dispose(); mesh = null; } } }
private void InitializeFloor() { var floor = TgcTexture.createTexture(MediaDir + "Texturas\\tierra.jpg"); var planeSize = new TGCVector3(200f, 0f, 200f); var planeMesh = new TgcPlane(TGCVector3.Scale(planeSize, -0.5f), planeSize, TgcPlane.Orientations.XZplane, floor, 5f, 5f); planeMesh.updateValues(); plane = planeMesh.toMesh("floor"); plane.Transform = TGCMatrix.RotationX(FastMath.PI) * plane.Transform; plane.Effect = effect; plane.Technique = "Blinn"; }
/// <summary> /// Actualizar parametros de la pared segun los valores cargados /// </summary> private void updatePlane() { //Origen, dimensiones, tiling y AutoAdjust var origin = (Vector3)Modifiers["origin"]; var dimension = (Vector3)Modifiers["dimension"]; var tiling = (Vector2)Modifiers["tiling"]; var autoAdjust = (bool)Modifiers["autoAdjust"]; //Cambiar orienacion var orientation = (string)Modifiers["orientation"]; TgcPlane.Orientations or; if (orientation == "XY") { or = TgcPlane.Orientations.XYplane; } else if (orientation == "XZ") { or = TgcPlane.Orientations.XZplane; } else { or = TgcPlane.Orientations.YZplane; } //Cambiar textura var text = (string)Modifiers["texture"]; if (text != currentTexture.FilePath) { currentTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, text); plane.setTexture(currentTexture); } //Aplicar valores en pared plane.Origin = origin; plane.Size = dimension; plane.Orientation = or; plane.AutoAdjustUv = autoAdjust; plane.UTile = tiling.X; plane.VTile = tiling.Y; //Es necesario ejecutar updateValues() para que los cambios tomen efecto plane.updateValues(); }
public override void Init() { var d3dDevice = D3DDevice.Instance.Device; moto = new Moto(MediaDir, new Vector3(0, 0, 0)); moto.init(); texturaPiso = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SkyBoxTron\\bottom.png"); pisoPlane = new TgcPlane(); pisoPlane.Origin = new Vector3(-5000, 0, -5000); pisoPlane.Size = new Vector3(10000, 0, 10000); pisoPlane.Orientation = TgcPlane.Orientations.XZplane; pisoPlane.setTexture(texturaPiso); pisoPlane.updateValues(); piso = pisoPlane.toMesh("piso"); piso.AutoTransformEnable = true; camaraInterna = new camara(moto); Camara = camaraInterna; camaraInterna.rotateY(FastMath.ToRad(180)); skyBoxTron = new SkyBox(MediaDir); skyBoxTron.init(); texto = new TgcText2D(); texto.Color = Color.Red; texto.Align = TgcText2D.TextAlign.LEFT; texto.Text = "Perdiste, toca la tecla R para reiniciar"; texto.Size = new Size(700, 400); texto.Position = new Point(550, 150); textoModoDios = new TgcText2D(); textoModoDios.Color = Color.Red; textoModoDios.Text = "Modo Dios Activado"; textoModoDios.Position = new Point(0, 30); textoModoDios.Size = new Size(500, 200); controladorIA = new ControladorIA(); this.generarOponentes(); perdido = false; cajas = new List <TgcMesh>(); cajaConLuz = new TgcSceneLoader().loadSceneFromFile(MediaDir + Game.Default.pathCajaMetalica).Meshes[0]; cajaConLuz.Position = new Vector3(0, 0, -200); cajaConLuz.Scale = new Vector3(0.8f, 0.8f, 0.8f); efectoLuz = TgcShaders.loadEffect(ShadersDir + "MultiDiffuseLights.fx"); this.generarCajas(100); controladorIA.setObstaculosEscenario(cajas); gestorPowerUps = new GestorPowerUps(); mp3Player = new TgcMp3Player(); mp3Player.closeFile(); mp3Player.FileName = MediaDir + Game.Default.pathMusica; mp3Player.play(true); }