internal override void Update(float elapsedTime) { //Size size = texts[selectedText].Size; //size.Height -= 10; //size.Width -= 10; //texts[selectedText].Size = size; texts[selectedText].Color = Color.Crimson; TgcD3dInput input = GuiController.Instance.D3dInput; if (input.keyPressed(Key.Up) || input.keyPressed(Key.W)) { selectedText--; } else if (input.keyPressed(Key.Down) || input.keyPressed(Key.S)) { selectedText++; } if (selectedText == texts.Length - 1) { selectedText = 0; } else if (selectedText < 0) { selectedText = texts.Length - 2; } //size = texts[selectedText].Size; //size.Height += 10; //size.Width += 10; //texts[selectedText].Size = size; texts[selectedText].Color = Color.Red; }
public int verSiAprietaSpace() { if (input.keyPressed(Key.Space)) { return(1); } return(0); }
private void _LvlHack() { TgcD3dInput input = GuiController.Instance.D3dInput; if (input.keyPressed(Key.F2)) { _SetLevel(_NextIndex); } else if (input.keyPressed(Key.F1)) { _SetLevel(_PrevIndex); } }
internal override void Update(float elapsedTime) { base.Update(elapsedTime); TgcD3dInput input = GuiController.Instance.D3dInput; if (input.keyPressed(Key.Space) || input.keyPressed(Key.Return)) { select = true; switch (texts[selectedText].Text) { case "Back": MenuManager.Instance.cargarPantalla(new MainMenu()); break; } } }
private void CheckRoll(float elapsedTime) { if (input.keyPressed(Game.Default.LeftKey)) { this.SetRolling(Game.Default.LeftKey == LastKeyPressed && Environment.TickCount - LastKeyPressedMillis < Game.Default.RollInterval); LastKeyPressed = Game.Default.LeftKey; LastKeyPressedMillis = Environment.TickCount; } else if (input.keyPressed(Game.Default.RightKey)) { this.SetRolling(Game.Default.RightKey == LastKeyPressed && Environment.TickCount - LastKeyPressedMillis < Game.Default.RollInterval); LastKeyPressed = Game.Default.RightKey; LastKeyPressedMillis = Environment.TickCount; } }
private void Disparar(TgcD3dInput input, float ElapsedTime) { tiempoDesdeUltimoDisparo += ElapsedTime; if (input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { if (tiempoDesdeUltimoDisparo > tiempoEntreDisparos) { tiempoDesdeUltimoDisparo = 0f; VariablesGlobales.managerElementosTemporales.AgregarElemento(new Misil(CalcularPosicionInicialMisil(), coordenadaEsferica, rotation, "Misil\\misil_xwing-TgcScene.xml", Misil.OrigenMisil.XWING)); VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.DISPARO_MISIL_XWING); } } tiempoDesdeUltimaBomba += ElapsedTime; if (tiempoDesdeUltimaBomba > tiempoEntreBombas) { VariablesGlobales.SumarBomba(); } if (input.keyPressed(Key.G)) { if (tiempoDesdeUltimaBomba > tiempoEntreBombas) { VariablesGlobales.RestarBomba(); tiempoDesdeUltimaBomba = 0f; var bomba = new Bomba(this.GetPosition(), coordenadaEsferica); VariablesGlobales.endgameManager.AgregarBomba(bomba); VariablesGlobales.managerElementosTemporales.AgregarElemento(bomba); VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.DISPARO_MISIL_XWING); } } }
private void MedioBarrelRoll(TgcD3dInput input, float ElapsedTime) { if (input.keyPressed(Key.B) && ESTADO_BARREL.NADA.Equals(estadoBarrel)) { estadoBarrel = ESTADO_BARREL.MEDIO_BARRELROLL; medioBarrelRollTimer = 0; } if (ESTADO_BARREL.MEDIO_BARRELROLL.Equals(estadoBarrel)) { barrelRollAdvance += ElapsedTime * 4; matrizInicialTransformacion = TGCMatrix.RotationYawPitchRoll(0, barrelRollAdvance, 0); if (barrelRollAdvance >= FastMath.PI_HALF) { estadoBarrel = ESTADO_BARREL.ESPERA_MEDIO_BARRELROLL; } } if (ESTADO_BARREL.ESPERA_MEDIO_BARRELROLL.Equals(estadoBarrel)) { medioBarrelRollTimer += ElapsedTime; if (medioBarrelRollTimer >= tiempoPermanenciaMedioBarrelRoll) { estadoBarrel = ESTADO_BARREL.VOLVIENDO_MEDIO_BARRELROLL; } } if (ESTADO_BARREL.VOLVIENDO_MEDIO_BARRELROLL.Equals(estadoBarrel)) { barrelRollAdvance -= ElapsedTime * 4; if (barrelRollAdvance <= 0) { barrelRollAdvance = 0; estadoBarrel = ESTADO_BARREL.NADA; } matrizInicialTransformacion = TGCMatrix.RotationYawPitchRoll(0, barrelRollAdvance, 0); } }
public void UpdateInput(TgcD3dInput input, float ElapsedTime) { if (input.keyPressed(Key.F)) { renderBoundingBoxes = !renderBoundingBoxes; } }
public void Update(float elapsedTime, TgcD3dInput input) { //Forward if (input.keyDown(Key.W)) { moveForward(MovementSpeed * elapsedTime); } //Backward if (input.keyDown(Key.S)) { moveForward(-MovementSpeed * elapsedTime); } //Strafe right if (input.keyDown(Key.D)) { moveSide(MovementSpeed * elapsedTime); } //Strafe left if (input.keyDown(Key.A)) { moveSide(-MovementSpeed * elapsedTime); } //Jump if (input.keyDown(Key.Space)) { moveUp(JumpSpeed * elapsedTime); } //Crouch if (input.keyDown(Key.LeftControl)) { moveUp(-JumpSpeed * elapsedTime); } if (input.keyPressed(Key.L)) { LockCam = !LockCam; } //Solo rotar si se esta aprentando el boton izq del mouse if (lockCam || input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { rotate(-input.XposRelative * RotationSpeed, -input.YposRelative * RotationSpeed); } if (lockCam) { Cursor.Position = mouseCenter; } viewMatrix = TGCMatrix.LookAtLH(eye, target, up); updateViewMatrix(D3DDevice.Instance.Device); }
private void renderJuego(float elapsedTime, Device d3dDevice) { //Poner luz a los meshes Vector3 posLuz = new Vector3(POS_SHIP.X - 10000, POS_SHIP.Y + 5000, POS_SHIP.Z - 25000); lightMesh.Position = posLuz; this.cargarLuces(posLuz); lightMesh.render(); //Obtener valor modifier heightOlas = (float)GuiController.Instance.Modifiers["heightOlas"]; //Device device = GuiController.Instance.D3dDevice; time += elapsedTime; d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkSlateBlue, 1.0f, 0); update(elapsedTime, time); terrain.render(); skyBox.render(); //skyBoundingBox.render(); // Cargar variables de shader, por ejemplo el tiempo transcurrido. effect.SetValue("time", time); effect.SetValue("height", heightOlas); effect.SetValue("menorAltura", terrain.menorVerticeEnY); effect.SetValue("offset", (float)(terrain.Center.Y * currentScaleY)); effect.SetValue("texHeightmap", TerrenoSimple.toTexture(currentHeightmap)); //GuiController.Instance.Logger.log("OFFSET: " + (terrain.Center.Y * currentScaleY).ToString() + "MENOR ALTURA: " + terrain.menorVerticeEnY); efectoSombra.SetValue("time", time); efectoSombra.SetValue("height", heightOlas); efectoSombra.SetValue("menorAltura", terrain.menorVerticeEnY); efectoSombra.SetValue("offset", (float)(terrain.Center.Y * currentScaleY)); efectoSombra.SetValue("texHeightmap", TerrenoSimple.toTexture(currentHeightmap)); agua.heightOlas = heightOlas; agua.AlphaBlendEnable = true; agua.render(); d3dDevice.Transform.World = Matrix.Identity; TgcD3dInput input = GuiController.Instance.D3dInput; if (input.keyPressed(Microsoft.DirectX.DirectInput.Key.L)) { lloviendo = lloviendo ? false : true; } ship.renderizar(); shipContrincante.renderizar(); lluvia.render(); }
public void Update(TgcD3dInput input) { if (input.keyPressed(mappedKey)) { isCurrent = false; VariablesGlobales.managerSonido.StopID(SoundManager.SONIDOS.PAUSE); VariablesGlobales.managerSonido.ResumeAll(); } }
public void Update(TgcD3dInput input) { if (input.keyPressed(mappedKey)) { isCurrent = false; VariablesGlobales.managerSonido.StopID(SoundManager.SONIDOS.MAIN_MENU); VariablesGlobales.managerMenu.SetCurrent(new StoryMenu(Key.E)); } }
private void checkInputs(TgcD3dInput Input, float deltaTime) { float FRAME_WALK_SPEED = WALK_SPEED * deltaTime; float FRAME_JUMP_SPEED = JUMP_SPEED * deltaTime; if (Input.keyDown(Key.W) || Input.keyDown(Key.UpArrow)) { vel.Z = -FRAME_WALK_SPEED; moving = true; meshAngle = 0; } if (Input.keyDown(Key.S) || Input.keyDown(Key.DownArrow)) { vel.Z = FRAME_WALK_SPEED; moving = true; meshAngle = 2; } if (Input.keyDown(Key.D) || Input.keyDown(Key.RightArrow)) { vel.X = -FRAME_WALK_SPEED; moving = true; meshAngle = 1; } if (Input.keyDown(Key.A) || Input.keyDown(Key.LeftArrow)) { vel.X = FRAME_WALK_SPEED; moving = true; meshAngle = 3; } if (Input.keyPressed(Key.Space) && saltosRestantes > 0) { vel.Y = FRAME_JUMP_SPEED; saltosRestantes--; } // HACK: no puede correr mientras patina // si pudiera correr mientras patina se hace quilombo con el sliding // y le queda una velocidad constante, que podría ser un feature mas que // un bug pero no se if (Input.keyDown(Key.LeftShift) && !patinando) { vel.X = vel.X * MULT_CORRER; vel.Z = vel.Z * MULT_CORRER; } else if (Input.keyDown(Key.LeftAlt)) { vel.X = vel.X * MULT_CAMINAR; vel.Z = vel.Z * MULT_CAMINAR; } }
}//@ ver si hay alguna forma de no tener q pasar los dos scale, usar aspect_ratio del rect capaz public bool CheckStartKey(TgcD3dInput input) { if (input.keyPressed(mappedKey)) { isCurrent = true; VariablesGlobales.managerSonido.PauseAll(); VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.PAUSE); return(true); } return(false); }
public void actualizarSiEsJugador(float anguloRotacion, float elapsedTime, float velBarco) { if (input.keyPressed(Key.A)) { elevacion_visible = elevacion_visible ? false : true; } if (input.keyPressed(Key.Space)) { if (balasRestantes >= 0) { shoot(elapsedTime, anguloRotacion, velBarco); } else { if (EjemploAlumno.Instance.shipContrincante.tieneVida()) { EjemploAlumno.Instance.estado = EstadoDelJuego.Perdido; } } } if (input.keyDown(Key.W)) { incrementarAnguloElevacion(elapsedTime); } if (input.keyDown(Key.S)) { decrementarAnguloElevacion(elapsedTime); } //foreach (Bala bala in balasEnElAire) for (int i = 0; i < balasEnElAire.Count; i++) { Bala bala = balasEnElAire[i]; bala.actualizar(elapsedTime); bala.render(); } }
internal override void Update(float elapsedTime) { base.Update(elapsedTime); TgcD3dInput input = GuiController.Instance.D3dInput; if (input.keyPressed(Key.Space) || input.keyPressed(Key.Return)) { select = true; switch (texts[selectedText].Text) { case "Play": MenuManager.Instance.cargarPantalla(PostProcessManager.Instance); break; case "Help": MenuManager.Instance.cargarPantalla(new HelpMenu()); break; case "Credits": MenuManager.Instance.cargarPantalla(new CreditsMenu()); break; } } }
public void Update(TgcD3dInput input) { timer += VariablesGlobales.elapsedTime; if (input.keyPressed(skipKey) || timer > 138) { isCurrent = false; VariablesGlobales.managerSonido.StopID(SoundManager.SONIDOS.FORCE_THEME); VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.FLYBY_2); VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.XWING_ENGINE); VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.BACKGROUND_BATTLE); VariablesGlobales.managerSonido.StopID(SoundManager.SONIDOS.EXPLOSION_FINAL); Dispose(); } }
/// <summary> /// Procesar shorcuts de teclado /// </summary> private void processShortcuts() { TgcD3dInput input = GuiController.Instance.D3dInput; //Select if (input.keyPressed(Key.Q)) { setSelectState(); } //Select all else if (input.keyDown(Key.LeftControl) && input.keyPressed(Key.E)) { selectAll(); } //Delete else if (input.keyPressed(Key.Delete)) { deleteSelectedPrimitives(); } //Translate else if (input.keyPressed(Key.W)) { activateTranslateGizmo(); } //Zoom else if (input.keyPressed(Key.Z)) { EditablePolyUtils.zoomPrimitives(control.Camera, selectionList, Transform); } //Top view else if (input.keyPressed(Key.T)) { EditablePolyUtils.setCameraTopView(control.Camera, selectionList, Transform); } //Left view else if (input.keyPressed(Key.L)) { EditablePolyUtils.setCameraLeftView(control.Camera, selectionList, Transform); } //Front view else if (input.keyPressed(Key.F)) { EditablePolyUtils.setCameraFrontView(control.Camera, selectionList, Transform); } }
public void Update(TgcD3dInput input, float time) { dynamicsWorld.StepSimulation(1 / 60f, 100); var strength = 10.30f; var angle = 5; #region Comoportamiento if (input.keyDown(Key.W)) { //Activa el comportamiento de la simulacion fisica para la capsula capsuleRigidBody.ActivationState = ActivationState.ActiveTag; capsuleRigidBody.AngularVelocity = TGCVector3.Empty.ToBsVector; capsuleRigidBody.ApplyCentralImpulse(-strength * director.ToBsVector); } if (input.keyDown(Key.S)) { //Activa el comportamiento de la simulacion fisica para la capsula capsuleRigidBody.ActivationState = ActivationState.ActiveTag; capsuleRigidBody.AngularVelocity = TGCVector3.Empty.ToBsVector; capsuleRigidBody.ApplyCentralImpulse(strength * director.ToBsVector); } if (input.keyDown(Key.A)) { director.TransformCoordinate(TGCMatrix.RotationY(-angle * time)); character.Transform = TGCMatrix.Translation(TGCVector3.Empty) * TGCMatrix.RotationY(-angle * time) * new TGCMatrix(capsuleRigidBody.InterpolationWorldTransform); capsuleRigidBody.WorldTransform = character.Transform.ToBsMatrix; } if (input.keyDown(Key.D)) { director.TransformCoordinate(TGCMatrix.RotationY(angle * time)); character.Transform = TGCMatrix.Translation(TGCVector3.Empty) * TGCMatrix.RotationY(angle * time) * new TGCMatrix(capsuleRigidBody.InterpolationWorldTransform); capsuleRigidBody.WorldTransform = character.Transform.ToBsMatrix; } if (input.keyPressed(Key.Space)) { //Activa el comportamiento de la simulacion fisica para la capsula capsuleRigidBody.ActivationState = ActivationState.ActiveTag; capsuleRigidBody.ApplyCentralImpulse(new TGCVector3(0, 80 * strength, 0).ToBsVector); } #endregion Comoportamiento }
private void BarrelRoll(TgcD3dInput input, float ElapsedTime) { if (input.keyPressed(Key.Space) && ESTADO_BARREL.NADA.Equals(estadoBarrel)) { estadoBarrel = ESTADO_BARREL.BARRELROLL; } if (ESTADO_BARREL.BARRELROLL.Equals(estadoBarrel)) { barrelRollAdvance += ElapsedTime * 4; matrizInicialTransformacion = TGCMatrix.RotationYawPitchRoll(0, barrelRollAdvance, 0); if (barrelRollAdvance >= FastMath.TWO_PI) { barrelRollAdvance = 0; estadoBarrel = ESTADO_BARREL.NADA; } } }
/// <summary> /// Método que se llama cada vez que hay que refrescar la pantalla. /// Escribir aquí todo el código referido al renderizado. /// Borrar todo lo que no haga falta /// </summary> /// <param name="elapsedTime">Tiempo en segundos transcurridos desde el último frame</param> public override void render(float elapsedTime) { //Device de DirectX para renderizar Device d3dDevice = GuiController.Instance.D3dDevice; TgcD3dInput input = GuiController.Instance.D3dInput; if (input.keyPressed(Microsoft.DirectX.DirectInput.Key.I)) { estado = EstadoDelJuego.Instrucciones; } if (EjemploAlumno.Instance.estado == EstadoDelJuego.SinEmpezar) { menu.renderSinEmpezar(this); } if (EjemploAlumno.Instance.estado == EstadoDelJuego.Instrucciones) { menu.renderInstrucciones(this); } if (EjemploAlumno.Instance.estado == EstadoDelJuego.Ganado) { menu.renderGanado(this); } if (EjemploAlumno.Instance.estado == EstadoDelJuego.Perdido) { menu.renderPerdido(this); } if (EjemploAlumno.Instance.estado == EstadoDelJuego.Jugando) { renderJuego(elapsedTime, d3dDevice); } }
public void Update(TgcD3dInput input, float elapsedTime, float timeBetweenFrames) { dynamicsWorld.StepSimulation(elapsedTime, 10, timeBetweenFrames); var strength = 1.50f; var angle = 5; if (input.keyDown(Key.W)) { //Activa el comportamiento de la simulacion fisica para la capsula dragonBall.ActivationState = ActivationState.ActiveTag; dragonBall.ApplyCentralImpulse(-strength * director.ToBulletVector3()); } if (input.keyDown(Key.S)) { //Activa el comportamiento de la simulacion fisica para la capsula dragonBall.ActivationState = ActivationState.ActiveTag; dragonBall.ApplyCentralImpulse(strength * director.ToBulletVector3()); } if (input.keyDown(Key.A)) { director.TransformCoordinate(TGCMatrix.RotationY(-angle * 0.001f)); } if (input.keyDown(Key.D)) { director.TransformCoordinate(TGCMatrix.RotationY(angle * 0.001f)); } if (input.keyPressed(Key.Space)) { dragonBall.ActivationState = ActivationState.ActiveTag; dragonBall.ApplyCentralImpulse(TGCVector3.Up.ToBulletVector3() * 150); } }
private void reproducirMusica(TgcD3dInput Input) { var estadoActual = reproductorMp3.getStatus(); if (Input.keyPressed(Key.M)) { if (estadoActual == TgcMp3Player.States.Open) { //Reproducir MP3 reproductorMp3.play(true); } if (estadoActual == TgcMp3Player.States.Stopped) { //Parar y reproducir MP3 reproductorMp3.closeFile(); reproductorMp3.play(true); } if (estadoActual == TgcMp3Player.States.Playing) { //Parar el MP3 reproductorMp3.stop(); } } }
public void EscribirTeclasEnPantalla(TgcD3dInput Input) { if (this.EstadoMenu == "E") { if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.BackSpace)) { if (this.NombreJugador.Length == 0) { return; } this.NombreJugador = this.NombreJugador.Substring(0, this.NombreJugador.Length - 1); } if (this.NombreJugador.Length < 10) { if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.A)) { this.NombreJugador += "a"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.B)) { this.NombreJugador += "b"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.C)) { this.NombreJugador += "c"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.D)) { this.NombreJugador += "d"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.E)) { this.NombreJugador += "e"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.F)) { this.NombreJugador += "f"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.G)) { this.NombreJugador += "g"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.H)) { this.NombreJugador += "h"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.I)) { this.NombreJugador += "i"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.J)) { this.NombreJugador += "j"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.K)) { this.NombreJugador += "k"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.L)) { this.NombreJugador += "l"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.M)) { this.NombreJugador += "m"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.N)) { this.NombreJugador += "n"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.O)) { this.NombreJugador += "o"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.P)) { this.NombreJugador += "p"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.Q)) { this.NombreJugador += "q"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.R)) { this.NombreJugador += "r"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.S)) { this.NombreJugador += "s"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.T)) { this.NombreJugador += "t"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.U)) { this.NombreJugador += "u"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.V)) { this.NombreJugador += "v"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.W)) { this.NombreJugador += "w"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.X)) { this.NombreJugador += "x"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.Y)) { this.NombreJugador += "y"; } if (Input.keyPressed(Microsoft.DirectX.DirectInput.Key.Z)) { this.NombreJugador += "z"; } } } }
public void actualizar(Vector3 pos) { if (input.keyPressed(Key.P)) { if (!apuntando) { apuntando = true; apuntado = new Vector3(0, 50, -50); camera.OffsetForward = DISTANCIA_APUNTANDO; camera.OffsetHeight = ALTURA_APUNTANDO; } else { apuntando = false; apuntado = new Vector3(0, 0, 0); camera.setCamera(pos, ALTURA, DISTANCIA); } } if (apuntando) { camera.RotationY = ship.anguloRotacion; } //Solo rotar si se esta aprentando el boton izq del mouse if (input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { if (!apuntando) { camera.rotateY(-input.XposRelative * ROTATION_SPEED); } } if (input.keyDown(Key.LeftShift)) { camera.OffsetHeight += 5; camera.OffsetForward += 5; } if (input.keyDown(Key.LeftControl)) { camera.OffsetHeight -= 5; camera.OffsetForward -= 5; } if (input.WheelPos != wheelPos) { zoom = input.WheelPos - wheelPos < 0 ? 20f : -20F; camera.OffsetHeight += zoom; camera.OffsetForward += zoom; } Vector3 aux = ship.delante; aux.Y = 0; camera.Target = pos + new Vector3(0, apuntado.Y, 0) + (apuntado.Z * aux); camera.updateCamera(); }
public void Update(TgcD3dInput input) { dynamicsWorld.StepSimulation(1 / 60f, 100); var strength = 10f; var angle = 0; if (input.keyDown(Key.I)) { ball.ActivationState = ActivationState.ActiveTag; ball.ApplyCentralImpulse(-strength * director.ToBsVector); } if (input.keyDown(Key.K)) { ball.ActivationState = ActivationState.ActiveTag; ball.ApplyCentralImpulse(strength * director.ToBsVector); } if (input.keyDown(Key.J)) { director.TransformCoordinate(TGCMatrix.RotationY(-angle * 0.001f)); } if (input.keyDown(Key.L)) { director.TransformCoordinate(TGCMatrix.RotationY(angle * 0.001f)); } if (input.keyPressed(Key.G)) { ball.ActivationState = ActivationState.ActiveTag; ball.ApplyCentralImpulse(TGCVector3.Up.ToBsVector * 150); } if (Frecuencia < 360) { dynamicPlatform.ActivationState = ActivationState.ActiveTag; Frecuencia++; if (sentido == 1) { dynamicPlatform.LinearVelocity = new Vector3(5, 10, 0); } else { dynamicPlatform.LinearVelocity = new Vector3(-5, -10, 0); } } else { Frecuencia = 0; if (sentido == 1) { sentido = 0; } else { sentido = 1; } } dynamicPlatformMesh.Transform = new TGCMatrix(dynamicPlatform.InterpolationWorldTransform); }
public void render(float elapsedTime) { //moverse y rotar son variables que me indican a qué velocidad se moverá o rotará el mesh respectivamente. //Se inicializan en 0, porque por defecto está quieto. float moverse = 0f; float rotar = 0f; habilitarDecremento = true; GuiController.Instance.UserVars.setValue("Velocidad", Math.Abs(auto.velocidadActual)); GuiController.Instance.UserVars.setValue("Vida", escalaVida.X); GuiController.Instance.UserVars.setValue("AngCol", Geometry.RadianToDegree(anguloColision)); GuiController.Instance.UserVars.setValue("AngRot", Geometry.RadianToDegree(anguloARotar)); //aumento de la velocidad de rotacion al derrapar modificarVelocidadRotacion(auto); //Procesa las entradas del teclado. if (entrada.keyDown(Key.Q)) { finDeJuego = true; salirConQ = true; } if (entrada.keyDown(Key.S)) { moverse = auto.irParaAtras(elapsedTime); } if (entrada.keyDown(Key.W)) { moverse = auto.irParaAdelante(elapsedTime); } if (entrada.keyDown(Key.A) && (auto.velocidadActual > 0.5f || auto.velocidadActual < -0.5f)) //izquierda { rotar = -auto.velocidadRotacion; } if (entrada.keyDown(Key.D) && (auto.velocidadActual > 0.5f || auto.velocidadActual < -0.5f)) //derecha { rotar = auto.velocidadRotacion; } if (entrada.keyPressed(Key.M)) { musica.muteUnmute(); auto.mutearSonido(); } if (entrada.keyPressed(Key.R)) //boton de reset, el mesh vuelve a la posicion de inicio y restaura todos sus parametros { auto.reiniciar(); auto.mesh.move(new Vector3(0, 0, -3100)); auto.mesh.rotateY(-1.57f); EjemploAlumno.instance.activar_efecto = false; nivel.reiniciar(); this.reiniciar(); GuiController.Instance.ThirdPersonCamera.resetValues(); GuiController.Instance.ThirdPersonCamera.rotateY(-1.57f); } if (entrada.keyPressed(Key.B)) //Modo debug para visualizar BoundingBoxes entre otras cosas que nos sirvan a nosotros { Shared.debugMode = !Shared.debugMode; } if (entrada.keyPressed(Key.I)) { modoDios = !modoDios; } //Frenado por inercia if (!entrada.keyDown(Key.W) && !entrada.keyDown(Key.S) && auto.velocidadActual != 0) { moverse = auto.frenarPorInercia(elapsedTime); } if (moverse > auto.velocidadMaxima) { auto.velocidadActual = auto.velocidadMaxima; } if (moverse < (-auto.velocidadMaxima)) { auto.velocidadActual = -auto.velocidadMaxima; } int sentidoRotacion = 0; //sentido de rotacion del reajuste de camara float rotCamara = GuiController.Instance.ThirdPersonCamera.RotationY; float rotAuto = auto.mesh.Rotation.Y; float deltaRotacion = rotAuto - rotCamara; float dif = FastMath.Abs(Geometry.RadianToDegree(deltaRotacion)); float rapidez = 5f; //aceleracion de reajuste de camara if (rotar != 0) { habilitarDecremento = false; habilitarContador = true; } if (dif < 40) { if (dif < 30) { if (dif < 20) { rapidez = 0.8f; } else { rapidez = 2f; } } else { rapidez = 3f; } } if (habilitarContador) { pasaronSegundos += elapsedTime; } if (deltaRotacion < 0) { sentidoRotacion = -1; } else { sentidoRotacion = 1; } if (deltaRotacion != 0 && pasaronSegundos > 0.5f) { ajustar = true; pasaronSegundos = 0f; habilitarContador = false; } float rotAngle = Geometry.DegreeToRadian(rotar * elapsedTime); if (ajustar) { GuiController.Instance.ThirdPersonCamera.rotateY(sentidoRotacion * rapidez * elapsedTime); } if (deltaRotacion < 0) { sentidoRotacion = -1; } else { sentidoRotacion = 1; } incrementarTiempo(this, elapsedTime, habilitarDecremento); auto.mesh.rotateY(rotAngle); auto.obb.rotate(new Vector3(0, rotAngle, 0)); if (FastMath.Abs(Geometry.RadianToDegree(deltaRotacion)) % 360 < 3) { GuiController.Instance.ThirdPersonCamera.RotationY = rotAuto; ajustar = false; } if (habilitarDecremento) { incrementarTiempo(this, elapsedTime, habilitarDecremento); } if (moverse != 0 || auto.velocidadActual != 0) //Si hubo movimiento { Vector3 lastPos = auto.mesh.Position; auto.mesh.moveOrientedY(moverse * elapsedTime); Vector3 position = auto.mesh.Position; Vector3 posDiff = position - lastPos; auto.obb.move(posDiff); Vector3 direccion = new Vector3(FastMath.Sin(auto.mesh.Rotation.Y) * moverse, 0, FastMath.Cos(auto.mesh.Rotation.Y) * moverse); auto.direccion.PEnd = auto.obb.Center + Vector3.Multiply(direccion, 50f); //Detectar colisiones de BoundingBox utilizando herramienta TgcCollisionUtils bool collide = false; Vector3[] cornersAuto; Vector3[] cornersObstaculo; foreach (ObstaculoRigido obstaculo in nivel.obstaculos) { if (Colisiones.testObbObb2(auto.obb, obstaculo.obb)) //chequeo obstáculo por obstáculo si está chocando con auto { collide = true; obstaculoChocado = obstaculo; Shared.mostrarChispa = true; if (FastMath.Abs(auto.velocidadActual) > 800) { auto.reproducirSonidoChoque(FastMath.Abs(auto.velocidadActual)); auto.deformarMesh(obstaculo.obb, FastMath.Abs(auto.velocidadActual)); } if (FastMath.Abs(auto.velocidadActual) > 800 && !modoDios) { escalaVida.X -= 0.00003f * Math.Abs(auto.velocidadActual) * escalaInicial.X; if (escalaVida.X > 0.03f) { vida.setEscala(new Vector2(escalaVida.X, escalaVida.Y)); } else { finDeJuego = true; muerte = true; } } break; } } //Si hubo colision, restaurar la posicion anterior (sino sigo de largo) if (collide) { auto.mesh.Position = lastPos; auto.obb.updateValues(); moverse = auto.chocar(elapsedTime); if (FastMath.Abs(auto.velocidadActual) > 0) { cornersAuto = CalculosVectores.computeCorners(auto); cornersObstaculo = CalculosVectores.computeCorners(obstaculoChocado); List <Plane> carasDelObstaculo = CalculosVectores.generarCaras(cornersObstaculo); Vector3 NormalAuto = direccion; caraChocada = CalculosVectores.detectarCaraChocada(carasDelObstaculo, auto.puntoChoque); Vector3 NormalObstaculo = new Vector3(caraChocada.A, caraChocada.B, caraChocada.C); GuiController.Instance.UserVars.setValue("NormalObstaculoX", NormalObstaculo.X); GuiController.Instance.UserVars.setValue("NormalObstaculoZ", NormalObstaculo.Z); float desplazamientoInfinitesimal = 5f; float constanteDesvio = 1.3f; //Calculo el angulo entre ambos vectores anguloColision = CalculosVectores.calcularAnguloEntreVectoresNormalizados(NormalAuto, NormalObstaculo);//Angulo entre ambos vectores //rota mesh if (FastMath.Abs(auto.velocidadActual) > 800) { if (Geometry.RadianToDegree(anguloColision) < 25) //dado un cierto umbral, el coche rebota sin cambiar su direccion { auto.velocidadActual = -auto.velocidadActual; } else //el coche choca y cambia su direccion { if (NormalObstaculo.Z > 0 && direccion.X > 0 && direccion.Z > 0) { anguloARotar = constanteDesvio * (Geometry.DegreeToRadian(90) - anguloColision); auto.mesh.move(new Vector3(0, 0, -10)); colorDeColision = Color.Red; } if (NormalObstaculo.X > 0 && direccion.X > 0 && direccion.Z > 0) { anguloARotar = -constanteDesvio * (Geometry.DegreeToRadian(90) - anguloColision); auto.mesh.move(new Vector3(-5, 0, 0)); colorDeColision = Color.Salmon; } if (NormalObstaculo.X > 0 && direccion.X > 0 && direccion.Z < 0) { anguloARotar = constanteDesvio * (Geometry.DegreeToRadian(90) - anguloColision); colorDeColision = Color.Blue; auto.mesh.move(new Vector3(-desplazamientoInfinitesimal, 0, 0)); } if (NormalObstaculo.Z < 0 && direccion.X > 0 && direccion.Z < 0) { anguloARotar = -constanteDesvio * (Geometry.DegreeToRadian(90) - anguloColision); auto.mesh.move(new Vector3(0, 0, desplazamientoInfinitesimal)); colorDeColision = Color.Green; } if (NormalObstaculo.Z < 0 && direccion.X < 0 && direccion.Z < 0) { anguloARotar = constanteDesvio * (Geometry.DegreeToRadian(90) - anguloColision); auto.mesh.move(new Vector3(0, 0, desplazamientoInfinitesimal)); colorDeColision = Color.Pink; } if (NormalObstaculo.X < 0 && direccion.X < 0 && direccion.Z < 0) { anguloARotar = -constanteDesvio * (Geometry.DegreeToRadian(90) - anguloColision); auto.mesh.move(new Vector3(desplazamientoInfinitesimal, 0, 0)); colorDeColision = Color.Silver; } if (NormalObstaculo.X < 0 && direccion.X < 0 && direccion.Z > 0) { anguloARotar = constanteDesvio * (Geometry.DegreeToRadian(90) - anguloColision); auto.mesh.move(new Vector3(desplazamientoInfinitesimal, 0, 0)); colorDeColision = Color.Aquamarine; } if (NormalObstaculo.Z > 0 && direccion.X < 0 && direccion.Z > 0) { anguloARotar = -constanteDesvio * (Geometry.DegreeToRadian(90) - anguloColision); auto.mesh.move(new Vector3(0, 0, -desplazamientoInfinitesimal)); colorDeColision = Color.Yellow; } auto.mesh.rotateY(anguloARotar); } } } } foreach (Recursos recurso in nivel.recursos) { TgcCollisionUtils.BoxBoxResult result = TgcCollisionUtils.classifyBoxBox(auto.mesh.BoundingBox, recurso.modelo.BoundingBox); if (result == TgcCollisionUtils.BoxBoxResult.Adentro || result == TgcCollisionUtils.BoxBoxResult.Atravesando) { nivel.recursos.Remove(recurso); //Saca el recurso de la lista para que no se renderice más float puntos = Convert.ToSingle(this.puntos.Text) + 100f; this.puntos.Text = Convert.ToString(puntos); break; } } //Chequeo si el auto agarro el checkpoint actual if (Colisiones.testObbObb2(auto.obb, nivel.checkpointActual.obb)) { if (nivel.checkpointsRestantes.Text != "1") { nivel.checkpoints.Remove(nivel.checkpointActual); //Saca el checkpoint de la lista para que no se renderice más int restantes = (Convert.ToInt16(nivel.checkpointsRestantes.Text) - 1); nivel.checkpointsRestantes.Text = restantes.ToString(); //Le resto uno a los restantes this.tiempoRestante.Text = (Convert.ToSingle(this.tiempoRestante.Text) + 10f).ToString(); nivel.checkpointActual = nivel.checkpoints.ElementAt(0); } else { finDeJuego = true; } } //Efecto blur if (FastMath.Abs(auto.velocidadActual) > (auto.velocidadMaxima * 0.5555)) { EjemploAlumno.instance.activar_efecto = true; EjemploAlumno.instance.blur_intensity = 0.003f * (float)Math.Round(FastMath.Abs(auto.velocidadActual) / (auto.velocidadMaxima), 5); } else { EjemploAlumno.instance.activar_efecto = false; } } GuiController.Instance.ThirdPersonCamera.Target = auto.mesh.Position; //actualizo cam Vector2 vectorCam = (Vector2)GuiController.Instance.Modifiers["AlturaCamara"]; GuiController.Instance.ThirdPersonCamera.setCamera(auto.mesh.Position, vectorCam.X, vectorCam.Y); float tope = 1f; float constanteDerrape = ((tiempoTrans / 2) < tope) ? (tiempoTrans / 2) : tope; float proporcion = FastMath.Abs(auto.velocidadActual / auto.velocidadMaxima); if (sentidoAnterior != sentidoRotacion && tiempoTrans != 0) { incrementarTiempo(this, elapsedTime * 5, true); } if (tiempoTrans == 0) { sentidoAnterior = sentidoRotacion; } auto.mesh.rotateY(constanteDerrape * sentidoAnterior * proporcion); auto.render(); auto.obb = TgcObb.computeFromAABB(auto.mesh.BoundingBox); auto.obb.setRotation(auto.mesh.Rotation); auto.obb.setRenderColor(colorDeColision); auto.mesh.rotateY(-constanteDerrape * sentidoAnterior * proporcion); //dibuja el nivel nivel.render(elapsedTime); //AJUSTE DE CAMARA SEGUN COLISION ajustarCamaraSegunColision(auto, nivel.obstaculos); //Dibujo checkpoints restantes nivel.checkpointsRestantes.render(); //Dibujo el puntaje del juego this.puntos.render(); //CUENTA REGRESIVA if (this.tiempoRestante.Text == "1") { uno.render(); } if (this.tiempoRestante.Text == "2") { dos.render(); } if (this.tiempoRestante.Text == "3") { tres.render(); } //Actualizo y dibujo el relops if ((DateTime.Now.Subtract(this.horaInicio).TotalSeconds) > segundosAuxiliares && !modoDios) { this.tiempoRestante.Text = (Convert.ToDouble(tiempoRestante.Text) - 1).ToString(); if (this.tiempoRestante.Text == "0") //Si se acaba el tiempo, me muestra el game over y reseetea todo { finDeJuego = true; muerte = true; } segundosAuxiliares++; } this.tiempoRestante.render(); //Si se le acabo el tiempo o la vida, o apretó "Q" if (finDeJuego) { //corta la música al salir TgcMp3Player player = GuiController.Instance.Mp3Player; player.closeFile(); GuiController.Instance.UserVars.clearVars(); //saca el blur EjemploAlumno.instance.activar_efecto = false; //reinicia los valores de las cosas del juego auto.reiniciar(); nivel.reiniciar(); this.reiniciar(); //reinicia la camara GuiController.Instance.ThirdPersonCamera.resetValues(); if (muerte) { EjemploAlu.setPantalla(EjemploAlu.getPantalla(1)); } else if (salirConQ) { EjemploAlumno.getInstance().setPantalla(new PantallaInicio()); } else { EjemploAlu.setPantalla(EjemploAlu.getPantalla(2)); } } if (comienzoNivel) { if (DateTime.Now.Subtract(this.horaInicio).TotalSeconds < 3) { if (auto.nombre == "Luigi") { misionLuigi.render(); } else { misionMario.render(); } } else { comienzoNivel = false; } } else { //Dibujo barrita if (auto.nombre == "Luigi") { barra2.render(); } else { barra.render(); } vida.render(); } //renderizo utilidades del debugMode if (Shared.debugMode) { Vector2 vectorModifier = (Vector2)GuiController.Instance.Modifiers["PosicionFlechaDebug"]; Vector3 vectorPosicion = new Vector3(vectorModifier.X, 10, vectorModifier.Y); debugArrow.PStart = vectorPosicion + new Vector3(0, 400f, 0); debugArrow.PEnd = vectorPosicion; debugArrow.updateValues(); debugArrow.render(); //renderizo normal al plano chocado if (obstaculoChocado != null) { collisionNormalArrow.PStart = obstaculoChocado.obb.Center; collisionNormalArrow.PEnd = obstaculoChocado.obb.Center + Vector3.Multiply(new Vector3(caraChocada.A, caraChocada.B, caraChocada.C), 500f); collisionNormalArrow.updateValues(); collisionNormalArrow.render(); } } }
/// <summary> /// Actualizar colisiones y camara /// </summary> /// <returns>Nueva posicion de la camara</returns> public TGCVector3 update(float elapsedTime, TgcD3dInput input) { Camera.Update(elapsedTime, input); //Capturar eventos de algunas teclas //Jump if (input.keyPressed(Key.Space)) { //Salta si esta en el piso if (OnGround) { //Vector3 velocity = GuiController.Instance.FpsCamera.Velocity; velocidad.Y = JumpSpeed; } } time += elapsedTime; var camPos = Camera.getPosition(); var camLookAt = Camera.getLookAt(); /* * if (noClip) * camera.JumpSpeed = 100.0f; * else * camera.JumpSpeed = 0f; */ //Detecto las colisiones if (!firstTime && !NoClip) { var lookDir = camLookAt - camPos; //aplico la velocidad var aceleracion = new TGCVector3(0, -Gravity, 0); //aplico la gravedad velocidad = velocidad + elapsedTime * aceleracion; camPos = camPos + velocidad * elapsedTime; camPos.Y -= kEpsilon * 1.5f; //aplico las colisiones //traceType = TYPE_SPHERE; //camPos = TraceSphere(antCamPos, camPos, 25.0f); camPos = TraceBox(antCamPos, camPos, PlayerBB.PMin, PlayerBB.PMax); //dist if (bCollided) { //float dist = Vector3.Dot(vCollisionNormal, velocidad); //velocidad = velocidad - vCollisionNormal*dist; } // actualizo la posicion de la camara //Camara.setCamera(camPos, camPos + lookDir); Camera.move(camPos - Camera.getPosition()); if (!OnGround) { //Vector3 aceleracion = new Vector3(0, -9.8f, 0); //aplico la gravidad //velocidad = velocidad + elapsedTime*aceleracion; } else { if (velocidad.Y < 0) { velocidad.Y = 0; } } } antCamPos = camPos; firstTime = false; return(camPos); }
public void Update(TgcD3dInput input, float elapsedTime, float timeBetweenFrames) { dynamicsWorld.StepSimulation(elapsedTime, 10, timeBetweenFrames); var strength = 10.30f; var angle = 5; var moving = false; #region Comoportamiento if (input.keyDown(Key.W)) { moving = true; //Activa el comportamiento de la simulacion fisica para la capsula capsuleRigidBody.ActivationState = ActivationState.ActiveTag; capsuleRigidBody.AngularVelocity = TGCVector3.Empty.ToBulletVector3(); capsuleRigidBody.ApplyCentralImpulse(-strength * director.ToBulletVector3()); } if (input.keyDown(Key.S)) { moving = true; //Activa el comportamiento de la simulacion fisica para la capsula capsuleRigidBody.ActivationState = ActivationState.ActiveTag; capsuleRigidBody.AngularVelocity = TGCVector3.Empty.ToBulletVector3(); capsuleRigidBody.ApplyCentralImpulse(strength * director.ToBulletVector3()); } if (input.keyDown(Key.A)) { director.TransformCoordinate(TGCMatrix.RotationY(-angle * 0.01f)); personaje.Transform = TGCMatrix.Translation(TGCVector3.Empty) * TGCMatrix.RotationY(-angle * 0.01f) * new TGCMatrix(capsuleRigidBody.InterpolationWorldTransform); capsuleRigidBody.WorldTransform = personaje.Transform.ToBulletMatrix(); } if (input.keyDown(Key.D)) { director.TransformCoordinate(TGCMatrix.RotationY(angle * 0.01f)); personaje.Transform = TGCMatrix.Translation(TGCVector3.Empty) * TGCMatrix.RotationY(angle * 0.01f) * new TGCMatrix(capsuleRigidBody.InterpolationWorldTransform); capsuleRigidBody.WorldTransform = personaje.Transform.ToBulletMatrix(); } if (input.keyPressed(Key.Space)) { //Activa el comportamiento de la simulacion fisica para la capsula capsuleRigidBody.ActivationState = ActivationState.ActiveTag; capsuleRigidBody.ApplyCentralImpulse(new TGCVector3(0, 80 * strength, 0).ToBulletVector3()); } #endregion Comoportamiento #region Animacion if (moving) { personaje.playAnimation("Caminando", true); } else { personaje.playAnimation("Parado", true); } #endregion Animacion }
public override void render(float elapsedTime) { Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice; //Obtener boolean para saber si hay que mostrar Bounding Box bool showBB = (bool)GuiController.Instance.Modifiers.getValue("showBoundingBox"); //obtener velocidades de Modifiers float velocidadCaminar = (float)GuiController.Instance.Modifiers.getValue("VelocidadCaminar"); float velocidadRotacion = (float)GuiController.Instance.Modifiers.getValue("VelocidadRotacion"); float velocidadSalto = (float)GuiController.Instance.Modifiers.getValue("VelocidadSalto"); float tiempoSalto = (float)GuiController.Instance.Modifiers.getValue("TiempoSalto"); //Calcular proxima posicion de personaje segun Input float moveForward = 0f; float rotate = 0; TgcD3dInput d3dInput = GuiController.Instance.D3dInput; bool moving = false; bool rotating = false; float jump = 0; //Adelante if (d3dInput.keyDown(Key.W)) { moveForward = -velocidadCaminar; moving = true; } //Atras if (d3dInput.keyDown(Key.S)) { moveForward = velocidadCaminar; moving = true; } //Derecha if (d3dInput.keyDown(Key.D)) { rotate = velocidadRotacion; rotating = true; } //Izquierda if (d3dInput.keyDown(Key.A)) { rotate = -velocidadRotacion; rotating = true; } //Jump if (!jumping && d3dInput.keyPressed(Key.Space)) { if (collisionManager.Collision) { jumping = true; jumpingElapsedTime = 0f; jump = 0; } } //Si hubo rotacion if (rotating) { //Rotar personaje y la camara, hay que multiplicarlo por el tiempo transcurrido para no atarse a la velocidad el hardware float rotAngle = Geometry.DegreeToRadian(rotate * elapsedTime); personaje.rotateY(rotAngle); GuiController.Instance.ThirdPersonCamera.rotateY(rotAngle); } //Si hubo desplazamiento if (moving) { //Activar animacion de caminando personaje.playAnimation("Caminando", true); } //Si no se esta moviendo, activar animacion de Parado else { personaje.playAnimation("Parado", true); } //Actualizar salto if (jumping) { jumpingElapsedTime += elapsedTime; if (jumpingElapsedTime > tiempoSalto) { jumping = false; } else { jump = velocidadSalto; } } //Vector de movimiento Vector3 movementVector = Vector3.Empty; if (moving || jumping) { //Aplicar movimiento, desplazarse en base a la rotacion actual del personaje //jump *= elapsedTime; movementVector = new Vector3( FastMath.Sin(personaje.Rotation.Y) * moveForward, jump, FastMath.Cos(personaje.Rotation.Y) * moveForward ); } //Actualizar valores de gravedad collisionManager.GravityEnabled = (bool)GuiController.Instance.Modifiers["HabilitarGravedad"]; collisionManager.GravityForce = (Vector3)GuiController.Instance.Modifiers["Gravedad"] /** elapsedTime*/; collisionManager.SlideFactor = (float)GuiController.Instance.Modifiers["SlideFactor"]; collisionManager.OnGroundMinDotValue = (float)GuiController.Instance.Modifiers["Pendiente"]; //Si esta saltando, desactivar gravedad if (jumping) { collisionManager.GravityEnabled = false; } //Mover personaje con detección de colisiones, sliding y gravedad if ((bool)GuiController.Instance.Modifiers["Collisions"]) { Vector3 realMovement = collisionManager.moveCharacter(characterSphere, movementVector, objetosColisionables); personaje.move(realMovement); //Cargar desplazamiento realizar en UserVar GuiController.Instance.UserVars.setValue("Movement", TgcParserUtils.printVector3(realMovement)); GuiController.Instance.UserVars.setValue("ySign", realMovement.Y); } else { personaje.move(movementVector); } //Si estaba saltando y hubo colision de una superficie que mira hacia abajo, desactivar salto if (jumping && collisionManager.Collision) { jumping = false; } //Hacer que la camara siga al personaje en su nueva posicion GuiController.Instance.ThirdPersonCamera.Target = personaje.Position; //Actualizar valores de la linea de movimiento directionArrow.PStart = characterSphere.Center; directionArrow.PEnd = characterSphere.Center + Vector3.Multiply(movementVector, 50); directionArrow.updateValues(); //Actualizar valores de normal de colision if (collisionManager.Collision) { collisionNormalArrow.PStart = collisionManager.LastCollisionPoint; collisionNormalArrow.PEnd = collisionManager.LastCollisionPoint + Vector3.Multiply(collisionManager.LastCollisionNormal, 200);; collisionNormalArrow.updateValues(); collisionNormalArrow.render(); collisionPoint.Position = collisionManager.LastCollisionPoint; collisionPoint.render(); } //Render de mallas foreach (TgcMesh mesh in escenario.Meshes) { mesh.render(); } //Render personaje personaje.animateAndRender(); if (showBB) { characterSphere.render(); } //Render linea directionArrow.render(); //Render SkyBox skyBox.render(); }