public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //Crear Sprite sprite = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "\\Texturas\\LogoTGC.png"); //Ubicarlo centrado en la pantalla Size screenSize = GuiController.Instance.Panel3d.Size; Size textureSize = sprite.Texture.Size; sprite.Position = new Vector2(FastMath.Max(screenSize.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(screenSize.Height / 2 - textureSize.Height / 2, 0)); //Modifiers para variar parametros del sprite GuiController.Instance.Modifiers.addVertex2f("position", new Vector2(0, 0), new Vector2(screenSize.Width, screenSize.Height), sprite.Position); GuiController.Instance.Modifiers.addVertex2f("scaling", new Vector2(0, 0), new Vector2(4, 4), sprite.Scaling); GuiController.Instance.Modifiers.addFloat("rotation", 0, 360, 0); //Creamos un Box3D para que se vea como el Sprite es en 2D y se dibuja siempre arriba de la escena 3D box = TgcBox.fromSize(new Vector3(10, 10, 10), TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "\\Texturas\\pasto.jpg")); //Hacer que la camara se centre en el box3D GuiController.Instance.RotCamera.targetObject(box.BoundingBox); }
public MySprite(string texturePath, Size frameSize, int totalFrames, float frameRate) { this.enabled = true; this.currentFrame = 0; this.frameSize = frameSize; this.totalFrames = totalFrames; this.currentTime = 0; this.playing = true; //Crear textura Device d3dDevice = GuiController.Instance.D3dDevice; TgcTexture texture = TgcTexture.createTexture(d3dDevice, texturePath); //Sprite sprite = new TgcSprite(); sprite.Texture = texture; //Calcular valores de frames de la textura textureWidth = texture.Width; textureHeight = texture.Height; framesPerColumn = (int)textureWidth / frameSize.Width; framesPerRow = (int)textureHeight / frameSize.Height; int realTotalFrames = framesPerRow * framesPerColumn; if (realTotalFrames > totalFrames) { throw new Exception("Error en AnimatedSprite. No coinciden la cantidad de frames y el tamaño de la textura: " + totalFrames); } setFrameRate(frameRate); }
public static void cargar() { SpriteDrawer = new Drawer2D(); //AnimatedSprite = new TgcAnimatedSprite(Utiles.getDirExtras("Explosion.png"), new Size(64, 64), 16, 10); //AnimatedSprite.Position = new Vector2(GuiController.Instance.Panel3d.Width - 32*2, 0); //Crear Sprite sprite = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(Utiles.getDirExtras("calabera1.jpg")); //Ubicarlo centrado en la pantalla Size screenSize = GuiController.Instance.Panel3d.Size; Size textureSize = sprite.Texture.Size; sprite.Position = new Vector2(GuiController.Instance.Panel3d.Width - 34 * 2, 0); sprite.Scaling = new Vector2(0.1f, 0.1f); Puntos2d = new TgcText2d(); Puntos2d.Text = puntos.ToString(); Puntos2d.Color = Color.Yellow; Puntos2d.Align = TgcText2d.TextAlign.RIGHT; Puntos2d.Position = new Point(GuiController.Instance.Panel3d.Width - 32, 0); Puntos2d.Size = new Size(30, 20); Puntos2d.changeFont(new System.Drawing.Font("Sans-serif ", 15, FontStyle.Bold)); }
public override void Init() { //Crear Sprite sprite = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(MediaDir + "\\Texturas\\LogoTGC.png"); //Ubicarlo centrado en la pantalla var textureSize = sprite.Texture.Size; sprite.Position = new Vector2(FastMath.Max(D3DDevice.Instance.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(D3DDevice.Instance.Height / 2 - textureSize.Height / 2, 0)); //Modifiers para variar parametros del sprite Modifiers.addVertex2f("position", new Vector2(0, 0), new Vector2(D3DDevice.Instance.Width, D3DDevice.Instance.Height), sprite.Position); Modifiers.addVertex2f("scaling", new Vector2(0, 0), new Vector2(4, 4), sprite.Scaling); Modifiers.addFloat("rotation", 0, 360, 0); //Creamos un Box3D para que se vea como el Sprite es en 2D y se dibuja siempre arriba de la escena 3D box = TgcBox.fromSize(new Vector3(10, 10, 10), TgcTexture.createTexture(MediaDir + "\\Texturas\\pasto.jpg")); //Hacer que la camara se centre en el box3D Camara = new TgcRotationalCamera(box.BoundingBox.calculateBoxCenter(), box.BoundingBox.calculateBoxRadius() * 2); }
public VideoScene(string directory, string format, float fps, int total_frames) { FPS = fps; TotalFrames = total_frames; current_frame = 0; time = 0.0f; frames = new TgcTexture[TotalFrames]; for (int i = 1; i <= TotalFrames; i++) { frames[i - 1] = TgcTexture.createTexture(directory + @"\" + i.ToString("D4") + "." + format); } sprite = new TgcSprite(); sprite.Texture = frames[current_frame]; Size screenSize = GuiController.Instance.Panel3d.Size; Size textureSize = sprite.Texture.Size; sprite.Scaling = new Vector2( (float)screenSize.Width / textureSize.Width, (float)screenSize.Height / textureSize.Height); sprite.Position = new Vector2( FastMath.Max(screenSize.Width / 2 - textureSize.Width * sprite.Scaling.X / 2, 0), FastMath.Max(screenSize.Height / 2 - textureSize.Height * sprite.Scaling.Y / 2, 0)); sound = new TgcStaticSound(); sound.loadSound(directory + @"\sound.wav"); Playing = false; }
public HUD() { screenSize = GuiController.Instance.Panel3d.Size; velocimetro = new TgcSprite(); agujaVelocimetro = new TgcSprite(); barraNitro = new TgcSprite(); llenadoNitro = new TgcSprite(); agujaTacometro = new TgcSprite(); sprites = new List <TgcSprite> { velocimetro, agujaVelocimetro, agujaTacometro, llenadoNitro, barraNitro }; }
private void CargarBarraDeVida() { spriteBarraJugador = new TgcSprite(drawerBarras); spriteBarraJugador.Texture = TgcTexture.createTexture(MediaDir + "Textures\\Sprites\\barraVacia.png"); spriteBarraJugador.Position = new Vector2(D3DDevice.Instance.Width - POSICION_X_BARRA_VIDA, POSICION_Y_BARRA_VIDA + (30 * this.MultiplicadorPos)); spriteBarraJugador.Scaling = new Vector2(0.1f, 0.4f); spriteBarraJugadorLlena = new TgcSprite(drawerBarras); spriteBarraJugadorLlena.Texture = TgcTexture.createTexture(MediaDir + "Textures\\Sprites\\barraLlena.png"); spriteBarraJugadorLlena.Position = new Vector2(D3DDevice.Instance.Width - POSICION_X_BARRA_VIDA, POSICION_Y_BARRA_VIDA + (30 * this.MultiplicadorPos)); spriteBarraJugadorLlena.Scaling = new Vector2(0.1f, 0.4f); spriteBarraJugadorLlena.Color = Color.Blue; }
public void init() { //Crear Sprite de sangre y texto sangre = new TgcSprite(); sangre.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "\\Kamikaze3D\\sangre.png"); texto = new TgcSprite(); texto.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "\\Kamikaze3D\\objetivoCumplido.png"); Size screenSize = GuiController.Instance.Panel3d.Size; Control focusWindows = GuiController.Instance.D3dDevice.CreationParameters.FocusWindow; sangre.Position = new Vector2(screenSize.Width / 2 - sangre.Texture.Size.Width / 2, screenSize.Height / 2 - sangre.Texture.Size.Height / 2); texto.Position = new Vector2(screenSize.Width / 2 - texto.Texture.Size.Width / 2, screenSize.Height / 2 - texto.Texture.Size.Height / 2); Console.WriteLine(sangre.Texture.Size.Width / screenSize.Width); }
//Velocidad del auto public HUDVelocimetro(string MediaDirectory) { this.drawer = new TgcDrawer2D(D3DDevice.Instance.Device); this.Velocidad = 0; spriteVelocimetro = new TgcSprite(drawer); spriteVelocimetro.Texture = TgcTexture.createTexture(MediaDirectory + "Textures\\Sprites\\velocimetro.png"); spriteVelocimetro.Position = new Vector2(D3DDevice.Instance.Width - 260, D3DDevice.Instance.Height - 260); spriteVelocimetro.Scaling = new Vector2(0.1f, 0.1f); spriteAguja = new TgcSprite(drawer); spriteAguja.Texture = TgcTexture.createTexture(MediaDirectory + "Textures\\Sprites\\aguja.png"); spriteAguja.Position = new Vector2(D3DDevice.Instance.Width - 260, D3DDevice.Instance.Height - 260); spriteAguja.Scaling = new Vector2(0.1f, 0.1f); spriteAguja.RotationCenter = new Vector2(100, 100); }
public void init() { //Device d3dDevice = GuiController.Instance.D3dDevice; string alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosDir; //Crear Sprite sprite = new TgcSprite(); spriteAmarillo = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(alumnoMediaFolder + "CucarachaJugosita\\Media\\barraRoja.png"); spriteAmarillo.Texture = TgcTexture.createTexture(alumnoMediaFolder + "CucarachaJugosita\\Media\\barraAmarilla.png"); sprite.Scaling = new Vector2(GuiController.Instance.D3dDevice.PresentationParameters.BackBufferWidth/13000f, GuiController.Instance.D3dDevice.PresentationParameters.BackBufferHeight/ 13000f); //-->> Antes estaba en 0.01f, 0.05f spriteAmarillo.Scaling = new Vector2(GuiController.Instance.D3dDevice.PresentationParameters.BackBufferWidth / 13000f, GuiController.Instance.D3dDevice.PresentationParameters.BackBufferHeight / 13000f); sprite.Position = new Vector2(GuiController.Instance.D3dDevice.PresentationParameters.BackBufferWidth* 4/5, GuiController.Instance.D3dDevice.PresentationParameters.BackBufferHeight * 9/10); spriteAmarillo.Position = new Vector2(GuiController.Instance.D3dDevice.PresentationParameters.BackBufferWidth * 4 / 5, GuiController.Instance.D3dDevice.PresentationParameters.BackBufferHeight * 9 / 10); }
public void init() { //Device d3dDevice = GuiController.Instance.D3dDevice; string alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosDir; //Crear Sprite sprite = new TgcSprite(); spriteAmarillo = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(alumnoMediaFolder + "CucarachaJugosita\\Media\\barraRoja.png"); spriteAmarillo.Texture = TgcTexture.createTexture(alumnoMediaFolder + "CucarachaJugosita\\Media\\barraAmarilla.png"); sprite.Position = new Vector2(900, 550); sprite.Scaling = new Vector2(0.1f, 0.05f); spriteAmarillo.Position = new Vector2(900, 550); spriteAmarillo.Scaling = new Vector2(0.1f, 0.05f); }
public void init() { //Modifiers para desplazamiento del personaje GuiController.Instance.Modifiers.addFloat("VelocidadCaminar", 0, 3f, 1.5f); GuiController.Instance.Modifiers.addFloat("VelocidadRotacion", 40f, 100f, 70f); //GuiController.Instance.Modifiers.addBoolean("HabilitarGravedad", "Habilitar Gravedad", true); //GuiController.Instance.Modifiers.addVertex3f("Gravedad", new Vector3(-50, -50, -50), new Vector3(50, 50, 50), new Vector3(0, -10, 0)); GuiController.Instance.Modifiers.addFloat("SlideFactor", 0f, 2f, 0.5f); GuiController.Instance.UserVars.addVar("Movement"); //Crear Sprite de mira mira = new TgcSprite(); mira.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "\\Kamikaze3D\\mira2.png"); Control focusWindows = GuiController.Instance.D3dDevice.CreationParameters.FocusWindow; mira.Position = new Vector2(focusWindows.Width * 0.4f, focusWindows.Height * 0.18f); }
public override void Init() { mesh.AutoTransformEnable = false; //seteamos la posicion inicial del enemigo mesh.Transform = CreatorMatrixPosition(); mesh.BoundingBox.transform(CreatorMatrixPosition()); Matrix matt = Matrix.Translation(new Vector3(mesh.Transform.M41, mesh.Transform.M42, mesh.Transform.M43)); Matrix matScale = Matrix.Scaling(MESH_SCALE, MESH_SCALE, MESH_SCALE); this.posicionActual = matScale * giroInicial * matt; posicionAnterior = posicionActual; pointer = new TgcSprite(); pointer.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\EnemyPointer.png"); initPointer(); }
internal override void Init() { select = false; selectedText = 0; GuiController.Instance.BackgroundColor = Color.White; logo = new TgcSprite(); TgcTexture texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\logo.png"); logo.Texture = texture; float ScreenWidth = GuiController.Instance.D3dDevice.Viewport.Width; float ScreenHeight = GuiController.Instance.D3dDevice.Viewport.Height; Size tamaño = logo.Texture.Size; float scale = ScreenWidth * (1) / tamaño.Width; logo.Scaling = new Vector2(scale, scale); logo.Position = new Vector2((ScreenWidth - (tamaño.Width * scale)), (ScreenHeight - (tamaño.Height * scale)) / 10); }
private void crearSprites() { boton1 = new TgcSprite(); boton1.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\boton.png"); Size textureSize = boton1.Texture.Size; boton1.Position = new Vector2(screenSize.Width - textureSize.Width, screenSize.Height - textureSize.Height); boton2 = new TgcSprite(); boton2.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\boton2.png"); textureSize = boton2.Texture.Size; boton2.Position = new Vector2((screenSize.Width - boton1.Texture.Size.Width) - textureSize.Width, screenSize.Height - textureSize.Height); timon = new TgcSprite(); timon.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\timon.png"); textureSize = timon.Texture.Size; timon.Position = new Vector2(0, screenSize.Height - textureSize.Height); barra = new TgcSprite(); barra.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\barra.png"); textureSize = barra.Texture.Size; barra.Position = new Vector2(0, screenSize.Height - textureSize.Height); //Crear Sprite animado para la lluvia animatedSprite = new TgcAnimatedSprite( GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\LLUVIA2.png", //Textura de 512 X 512 new Size(128, 128), //Tamaño de un frame (128x128px en este caso) 16, //Cantidad de frames, (son 16 de 128x128px) 20 //Velocidad de animacion, en cuadros x segundo ); animatedSprite.Position = new Vector2(-10, 0); animatedSprite.Scaling = new Vector2(8, 4); //Crear Sprite animado para la gaviota animatedSprite2 = new TgcAnimatedSprite( GuiController.Instance.AlumnoEjemplosMediaDir + "RenderGroup\\texturas\\gaviotas2.png", //Textura de 1024 X 1024 new Size(256, 256), //Tamaño de un frame (128x128px en este caso) 16, //Cantidad de frames, (son 16 de 128x128px) 1 //Velocidad de animacion, en cuadros x segundo ); }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //Iniciar Kinect try { tgcKinect = new TgcKinect(); tgcKinect.init(); tgcKinect.DebugSkeleton.init(); } catch (Exception) { GuiController.Instance.Logger.logError("Kinect not found"); } GuiController.Instance.FpsCamera.Enable = true; GuiController.Instance.FpsCamera.setCamera(new Vector3(-9.1315f, 22.5574f, -41.5821f), new Vector3(-8.9167f, 22.2222f, -40.6648f)); //Centro y tamaño de escena center = TgcBox.fromSize(new Vector3(0, 0, 0), new Vector3(1, 1, 1), Color.Blue); bounds = new TgcBoundingBox(new Vector3(-10, 0, -10), new Vector3(10, 20, 10)); //Imagenes para puntero del mouse leftHandPointer = new TgcSprite(); leftHandPointer.Texture = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "left_pointer.png"); rightHandPointer = new TgcSprite(); rightHandPointer.Texture = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "right_pointer.png"); GuiController.Instance.Modifiers.addFloat("speedX", 0.5f, 10f, 1f); GuiController.Instance.Modifiers.addFloat("speedY", 0.5f, 10f, 1f); GuiController.Instance.Modifiers.addBoolean("showValues", "showValues", false); }
public Imagen(string ruta) { sprite = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(ruta); }
public void crearSprite() { this.sprite = new TgcSprite(); this.sprite.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "barra.jpg"); }
public void render(float elapsedTime) { TgcD3dInput d3dInput = GuiController.Instance.D3dInput; //Calcular proxima posicion de personaje segun Input float moveForward = 0f; float moveSide = 0f; float rotateY = 0; float rotateX = 0; float jump = 0; bool moving = false; bool rotating = false; bool rotatingY = false; bool rotatingX = false; bool running = false; bool jumping = false; string animationAction = "StandBy"; TgcSprite mira; //Crear Sprite de mira mira = new TgcSprite(); mira.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "\\Kamikaze3D\\mira.png"); //Ubicarlo centrado en la pantalla Size screenSize = GuiController.Instance.Panel3d.Size; Size textureSize = mira.Texture.Size; mira.Position = new Vector2(screenSize.Width / 2 - textureSize.Width / 2, screenSize.Height / 2 - textureSize.Height / 2); TgcText2d hitCantTextY = new TgcText2d(); hitCantTextY.Position = new Point(0, 0); hitCantTextY.Color = Color.White; TgcText2d hitCantTextX = new TgcText2d(); hitCantTextX.Position = new Point(0, 20); hitCantTextX.Color = Color.White; //obtener velocidades de Modifiers (no deberia estar porque es fijo) float velocidadCaminar = (float)GuiController.Instance.Modifiers.getValue("VelocidadCaminar"); //float velocidadMoveSide = (float)GuiController.Instance.Modifiers.getValue("velocidadMoveSide"); float velocidadRotacion = (float)GuiController.Instance.Modifiers.getValue("VelocidadRotacion"); //Obtener boolean para saber si hay que mostrar Bounding Box (tampoco deberia estar) bool showBB = (bool)GuiController.Instance.Modifiers.getValue("showBoundingBox"); //Adelante if (d3dInput.keyDown(Key.W)) { moveForward = -velocidadCaminar; moving = true; } //Atras if (d3dInput.keyDown(Key.S)) { moveForward = velocidadCaminar; moving = true; } //Derecha if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && d3dInput.XposRelative > 0) { if (camara.RotationY < (Math.PI)) { rotateY = velocidadRotacion; rotating = true; rotatingY = true; } } //Mover Derecha if (d3dInput.keyDown(Key.D)) { moveSide = -velocidadCaminar; moving = true; } //Izquierda if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && d3dInput.XposRelative < 0) { if (camara.RotationY > -(Math.PI)) { rotateY = -velocidadRotacion; rotating = true; rotatingY = true; } } //Mover Izquierda if (d3dInput.keyDown(Key.A)) { moveSide = velocidadCaminar; moving = true; } //Arriba if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && d3dInput.YposRelative < 0) { if (camara.RotationX > -(Math.PI / 3)) { rotateX = -velocidadRotacion; rotating = true; rotatingX = true; } } //Abajo if (d3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && d3dInput.YposRelative > 0) { if (camara.RotationX < (Math.PI / 3)) { rotateX = velocidadRotacion; rotating = true; rotatingX = true; } } //Jump /* if (d3dInput.keyDown(Key.Space)) * { * jump = 30; * moving = true; * }*/ //Run if (d3dInput.keyDown(Key.LeftShift)) { running = true; moveForward *= 1.5f; } if (d3dInput.keyDown(Key.E)) { animationAction = "WeaponPos"; } //Si hubo rotacion if (rotating) { if (rotatingY) { //Rotar personaje y la camara, hay que multiplicarlo por el tiempo transcurrido para no atarse a la velocidad el hardware float rotAngleY = Geometry.DegreeToRadian(rotateY * elapsedTime); personaje.rotateY(rotAngleY); camara.rotateY(rotAngleY); } if (rotatingX) { //Rotar personaje y la camara, hay que multiplicarlo por el tiempo transcurrido para no atarse a la velocidad el hardware float rotAngleX = Geometry.DegreeToRadian(rotateX * elapsedTime); camara.rotateX(rotAngleX); } } //Si hubo desplazamiento if (moving) { //Activar animacion de caminando if (running) { personaje.playAnimation("Run", true); } else if (jumping) { personaje.playAnimation("Jump", true); } else { personaje.playAnimation("Walk", true); } } //Si no se esta moviendo, activar animationAction else { personaje.playAnimation(animationAction, true); } //Vector de movimiento Vector3 movementVector = Vector3.Empty; if (moving) { //Aplicar movimiento, desplazarse en base a la rotacion actual del personaje //Grupo Kamikaze3D :: Se agrega también al desplazamiento sobre el eje x y eje z, el valor de desplazamiento lateral movementVector = new Vector3( (FastMath.Sin(personaje.Rotation.Y) * moveForward) + (FastMath.Cos(personaje.Rotation.Y) * moveSide), jump, (FastMath.Cos(personaje.Rotation.Y) * moveForward) + (-FastMath.Sin(personaje.Rotation.Y) * moveSide) ); } //Actualizar valores de gravedad collisionManager.GravityEnabled = (bool)GuiController.Instance.Modifiers["HabilitarGravedad"]; collisionManager.GravityForce = (Vector3)GuiController.Instance.Modifiers["Gravedad"]; collisionManager.SlideFactor = (float)GuiController.Instance.Modifiers["SlideFactor"]; //Mover personaje con detección de colisiones, sliding y gravedad Vector3 realMovement = collisionManager.moveCharacter(characterSphere, movementVector, objetosColisionables); personaje.move(realMovement); //Actualizar valores de la linea de movimiento directionArrow.PStart = characterSphere.Center; directionArrow.PEnd = characterSphere.Center + Vector3.Multiply(movementVector, 50); directionArrow.updateValues(); //Cargar desplazamiento realizar en UserVar GuiController.Instance.UserVars.setValue("Movement", TgcParserUtils.printVector3(realMovement)); //Render linea if (renderDirectionArrow) { directionArrow.render(); } //Render personaje personaje.animateAndRender(); /* //Iniciar dibujado de todos los Sprites de la escena (en este caso es solo uno) * GuiController.Instance.Drawer2D.beginDrawSprite(); * * //Dibujar sprite (si hubiese mas, deberian ir todos aquí) * mira.render(); * * //Finalizar el dibujado de Sprites * GuiController.Instance.Drawer2D.endDrawSprite();*/ hitCantTextY.Text = "Y: " + camara.RotationY; hitCantTextX.Text = "X: " + camara.RotationX; hitCantTextY.render(); hitCantTextX.render(); if (showBB) { characterSphere.render(); } }
public Player() { TgcSceneLoader loaderSniper = new TgcSceneLoader(); string media = GuiController.Instance.AlumnoEjemplosMediaDir; TgcScene sniperRifle = loaderSniper.loadSceneFromFile(media + "CEGA\\Sniper-TgcScene.xml"); rifle = sniperRifle.Meshes[0]; rifle.AlphaBlendEnable = true; rifle.AutoTransformEnable = false; rifleBaseTransforms = Matrix.Scaling(new Vector3(0.01f, 0.01f, 0.01f)) * Matrix.RotationY(FastMath.PI - 0.03f) * Matrix.Translation(new Vector3(0.5f, -1.0f, 2.0f)); // Configuracion de la camara // GuiController.Instance.CurrentCamera.Enable = false; camera = new FpsCamera(); GuiController.Instance.CurrentCamera = camera; camera.MovementSpeed = WALKING_SPEED; camera.RotationSpeed = ROTATION_SPEED_NO_SCOPE; posicionSegura = camera.getPosition(); posicionInicial = camera.getPosition(); lookAtInicial = camera.getLookAt(); // Configuracion del stencil para el modo scope // scope_stencil = new TgcSprite(); scope_stencil.Texture = TgcTexture.createTexture(media + @"CEGA\Textures\scope.png"); Size screenSize = GuiController.Instance.Panel3d.Size; Size textureSize = scope_stencil.Texture.Size; float scope_scale = FastMath.Min( (float)screenSize.Width / textureSize.Width, (float)screenSize.Height / textureSize.Height) * 0.9f; scope_stencil.Scaling = new Vector2(scope_scale, scope_scale); scope_stencil.Position = new Vector2( FastMath.Max(screenSize.Width / 2 - textureSize.Width * scope_scale / 2, 0), FastMath.Max(screenSize.Height / 2 - textureSize.Height * scope_scale / 2, 0)); // El radio, ajustado a -1% para cubrir el borde scope_radius = (textureSize.Height * scope_scale / 2.0f) * 0.99f; LoadSounds(media); //Inicializo vidas , balas y puntos. this.vidas = 5; this.ammo = -1; //Por ahora son infinitas this.puntos = 0; //Configuracion de la mira sin scope. float mira_scale = 0.08f; mira = new TgcSprite(); mira.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "CEGA\\Textures\\Mira.png"); mira.Scaling = new Vector2(mira_scale, mira_scale); Size miraSize = mira.Texture.Size; miraSize.Height = (int)(miraSize.Height * mira_scale); miraSize.Width = (int)(miraSize.Width * mira_scale); mira.Position = new Vector2(FastMath.Max(screenSize.Width / 2 - miraSize.Width / 2, 0), FastMath.Max(screenSize.Height / 2 - miraSize.Height / 2, 0)); //Inicialización UI (Texto) LoadUI(screenSize); }
public override void init() { hud = new HUD(); hud.init(); Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice; //Crear Sprite sprite = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Inicio\\imagenInicio.jpg"); //Ubicarlo centrado en la pantalla Size screenSize = GuiController.Instance.Panel3d.Size; Size textureSize = sprite.Texture.Size; sprite.Position = new Vector2(0, 0); sprite.Scaling = new Vector2((float)screenSize.Width / textureSize.Width, (float)screenSize.Height / textureSize.Height + 0.01f); //Texturas para particulas texturaHumo = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Particulas\\Textures\\humo.png"); texturaFuego = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Particulas\\Textures\\fuego.png"); Vector3 centerHumo = new Vector3(0, 0, 0); Vector3 sizeHumo = new Vector3(7, 3, 10); humo = TgcBox.fromSize(centerHumo, sizeHumo, texturaHumo); humo.AlphaBlendEnable = true; fuego = TgcBox.fromSize(centerHumo, sizeHumo, texturaFuego); fuego.AlphaBlendEnable = true; cantidadDeNitro = 100f; // cosas del tiempo tiempoTrans = 100f; //tiempo transcurrido desde el defasaje de rotacion de camara y rotacion del mesh segundosAuxiliares = 1; //En este ejemplo primero cargamos una escena 3D entera. TgcSceneLoader loader = new TgcSceneLoader(); //Luego cargamos otro modelo aparte que va a hacer el objeto que controlamos con el teclado TgcScene scene1 = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Auto\\\\autoRojo-TgcScene.xml"); TgcScene scene2 = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Auto\\\\Auto_Rueda_Derecha-TgcScene.xml"); TgcScene scene3 = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Auto\\\\Auto_Rueda_Derecha-TgcScene.xml"); TgcScene scene4 = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Auto\\\\Auto_Rueda_Izquierda-TgcScene.xml"); TgcScene scene5 = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Auto\\\\Auto_Rueda_Izquierda-TgcScene.xml"); scenePista = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Auto\\\\pistaentera-TgcScene.xml"); TgcScene sceneAutoIA = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "TheC#\\Auto\\\\autoVerde-TgcScene.xml"); //cargo obbs objetosColisionables = new List <TgcObb>(); /* Esto de aca comentado sirve para cuando se agregan nuevos meshes a pistaentera-TgcScene.xml entonces * obtiene su OBB de los AABB de los meshes, esta comentado porque el archivo .xml esta actualizado * y aparte detiene mucho su inicio * foreach (TgcMesh mesh in scenePista.Meshes) * { * if (mesh.Name.Contains("borde") || mesh.Name.Contains("col") || mesh.Name.Contains("Patrullero")) * { * Vector3[] vertices = mesh.getVertexPositions(); * objetosColisionables.Add(TgcObb.computeFromPoints(vertices)); * } * } * guardarObbs(objetosColisionables);*/ objetosColisionables = cargarObbObjetos(); posteDeSemaforoOBB = cargarobbParticular(new Vector3(-1193.647f, -649.2448f, 948.8185f), new Vector3(-1147f, 596.6053f, 1051.182f)); objetosColisionables.Add(posteDeSemaforoOBB); //Solo nos interesa el primer modelo de estas escenas autoMesh = scene1.Meshes[0]; ruedaDerechaDelanteraMesh = scene2.Meshes[0]; ruedaDerechaTraseraMesh = scene3.Meshes[0]; ruedaIzquierdaDelanteraMesh = scene4.Meshes[0]; ruedaIzquierdaTraseraMesh = scene5.Meshes[0]; //creo el mesh del auto de IA meshAutoIA = sceneAutoIA.Meshes[0]; //creo la lista de ruedas ruedas = new List <TgcViewer.Utils.TgcSceneLoader.TgcMesh> { ruedaDerechaDelanteraMesh, ruedaDerechaTraseraMesh, ruedaIzquierdaDelanteraMesh, ruedaIzquierdaTraseraMesh }; //creo la lineas de frenado for (int i = 0; i < 4; i++) { lineaDeFrenado[i] = new LineaDeFrenado(12, 25, 3, 250, Color.Black); } //posicion del auto autoMesh.Position = new Vector3(-278f, 0f, 281f); //posiciones relativas al auto dx = new List <float> { 45, -45, -45, 45 }; dy = new List <float> { -61, 71, -61, 71 }; //posiciones relativas al auto para los box de colision entre autos dxAColision = new List <float> { 20, -20, -20, 20 }; dyAColision = new List <float> { -35, 45, -35, 45 }; //posiciono al autoIA meshAutoIA.Position = new Vector3(211f, 0f, 216f); //Vamos a utilizar la cámara en 3ra persona para que siga al objeto principal a medida que se mueve GuiController.Instance.ThirdPersonCamera.Enable = true; GuiController.Instance.ThirdPersonCamera.RotationY = 300; GuiController.Instance.ThirdPersonCamera.setCamera(autoMesh.Position, 200, 500); GuiController.Instance.BackgroundColor = Color.Black;// Black; //Le asigno su oriented bounding box que me permite rotar la caja de colisiones (no así bounding box) oBBAuto = TgcObb.computeFromAABB(autoMesh.BoundingBox); oBBAutoIa = TgcObb.computeFromAABB(meshAutoIA.BoundingBox); //creo al auto y al jugador auto = new Auto(110, ruedas); jugador = new Jugador(auto); //creo al auto del IA y al IA autoIA = new Auto(110, ruedas); jugadorIA = new IA(autoIA, new Vector3(0, 0, 0)); //Inicializo el circuito, tanto para la persona como para la IA posicionesPuntosDeControl = new List <Vector3> { new Vector3(360, 20, 2634), new Vector3(-1040, 20, 5524), new Vector3(-1749, 20, 11113), new Vector3(-4484, 20, 14460), new Vector3(-7377, 20, 16890), new Vector3(-12790, 20, 17407), new Vector3(-15308, 20, 12649), new Vector3(-15153, 20, 8531), new Vector3(-16068, 20, 7030), new Vector3(-16342, 20, 4149), new Vector3(-16222, 20, -1083), new Vector3(-14986, 20, -3020), new Vector3(-15734, 20, -8568), new Vector3(-15281, 20, -12097), new Vector3(-12022, 20, -15335), new Vector3(-6142, 20, -14446), new Vector3(-4411, 20, -11766), new Vector3(-2016, 20, -8940), new Vector3(-1287, 20, -4142), new Vector3(20, 20, -2566) }; posicionesPuntosDeControlDeIA = new List <Vector3> { new Vector3(360, 20, 2634), new Vector3(-1040, 20, 5524), new Vector3(-1749, 20, 11113), new Vector3(-4484, 20, 14460), new Vector3(-7377, 20, 16890), new Vector3(-12790, 20, 17407), new Vector3(-15308, 20, 12649), new Vector3(-15153, 20, 8531), new Vector3(-16068, 20, 7030), new Vector3(-16342, 20, 4149), new Vector3(-16222, 20, -1083), new Vector3(-14986, 20, -3020), new Vector3(-15734, 20, -8568), new Vector3(-15281, 20, -12097), new Vector3(-12022, 20, -15335), new Vector3(-6142, 20, -14446), new Vector3(-4411, 20, -11766), new Vector3(-2016, 20, -8940), new Vector3(-1287, 20, -4142), new Vector3(20, 20, -2566) }; for (int i = 0; i < posicionesPuntosDeControl.Count; i++) { TgcCylinder unCilindro = new TgcCylinder(posicionesPuntosDeControl[i], 130, 30); trayecto.Add(unCilindro); unCilindro = new TgcCylinder(posicionesPuntosDeControlDeIA[i], 130, 30); trayectoDeIA.Add(unCilindro); } //Asigno los obb que me permiten detectar las colisiones entre los autos obbsAuto.Add(TgcBox.fromSize(new Vector3(autoMesh.Position.X - 100, 15, autoMesh.Position.Z + 100), new Vector3(65, 65, 65), texturaFuego)); obbsAuto.Add(TgcBox.fromSize(new Vector3(autoMesh.Position.X - 100, 15, autoMesh.Position.Z - 100), new Vector3(65, 65, 65), texturaHumo)); obbsAuto.Add(TgcBox.fromSize(new Vector3(autoMesh.Position.X + 100, 15, autoMesh.Position.Z + 100), new Vector3(65, 65, 65), texturaFuego)); obbsAuto.Add(TgcBox.fromSize(new Vector3(autoMesh.Position.X + 100, 15, autoMesh.Position.Z - 100), new Vector3(65, 65, 65), texturaFuego)); obbsOtroAuto.Add(TgcBox.fromSize(new Vector3(meshAutoIA.Position.X - 100, 15, meshAutoIA.Position.Z + 100), new Vector3(65, 65, 65), texturaFuego)); obbsOtroAuto.Add(TgcBox.fromSize(new Vector3(meshAutoIA.Position.X - 100, 15, meshAutoIA.Position.Z - 100), new Vector3(65, 65, 65), texturaHumo)); obbsOtroAuto.Add(TgcBox.fromSize(new Vector3(meshAutoIA.Position.X + 100, 15, meshAutoIA.Position.Z + 100), new Vector3(65, 65, 65), texturaFuego)); obbsOtroAuto.Add(TgcBox.fromSize(new Vector3(meshAutoIA.Position.X + 100, 15, meshAutoIA.Position.Z - 100), new Vector3(65, 65, 65), texturaFuego)); /////////////TEXTOS/////////////////////// textPuntosDeControlAlcanzados = new TgcText2d(); textPuntosDeControlAlcanzados.Position = new Point(0, 50); textPuntosDeControlAlcanzados.Text = "Puntos De Control Alcanzados = "; textPuntosDeControlAlcanzados.Color = Color.White; textFPS = new TgcText2d(); textFPS.Position = new Point((screenSize.Width / (-2)), 0); textFPS.Text = "FPS: "; textFPS.Color = Color.Yellow; textGanaste = new TgcText2d(); textGanaste.Position = new Point(0, 200); textGanaste.Color = Color.LightGreen; textPerdiste = new TgcText2d(); textPerdiste.Position = new Point(0, 200); textPerdiste.Text = "Perdiste y lograste "; textPerdiste.Color = Color.Red; textPerdiste.Size = new Size(900, 700); textPosicionDelAutoActual = new TgcText2d(); textPosicionDelAutoActual.Text = "Posicion del auto actual = "; textPosicionDelAutoActual.Color = Color.White; textPosicionDelAutoActual.Position = new Point(100, 450); this.horaInicio = DateTime.Now; textTiempo = new TgcText2d(); textTiempo.Position = new Point(screenSize.Width / 2 - 50, 20); textTiempo.Text = "10"; textTiempo.changeFont(new System.Drawing.Font("TimesNewRoman", 23, FontStyle.Bold | FontStyle.Bold)); textTiempo.Color = Color.Red; stringTiempo = new TgcText2d(); stringTiempo.Position = new Point(screenSize.Width / 2 - 130, 20); stringTiempo.Text = "Tiempo: "; stringTiempo.changeFont(new System.Drawing.Font("TimesNewRoman", 23, FontStyle.Bold | FontStyle.Bold)); stringTiempo.Color = Color.Red; textIngreseTecla = new TgcText2d(); textIngreseTecla.Text = " Utilize las flechas o W,A,S,D para moverse. \n Shift o control izquierdo para activar el nitro \n M para cambiar la camara \n TAB mirar para atrás \n Ingrese barra espaciadora para comenzar "; textIngreseTecla.Position = new Point(150, 290); textIngreseTecla.Align = TgcText2d.TextAlign.LEFT; textIngreseTecla.changeFont(new System.Drawing.Font("TimesNewRoman", 23, FontStyle.Bold | FontStyle.Bold)); textIngreseTecla.Color = Color.White; textIngreseTeclaSombra = new TgcText2d(); textIngreseTeclaSombra.Text = " Utilize las flechas o W,A,S,D para moverse. \n Shift o control izquierdo para activar el nitro \n M para cambiar la camara \n TAB mirar para atrás \n Ingrese barra espaciadora para comenzar "; textIngreseTeclaSombra.Position = new Point(149, 288); textIngreseTeclaSombra.Align = TgcText2d.TextAlign.LEFT; textIngreseTeclaSombra.changeFont(new System.Drawing.Font("TimesNewRoman", 23, FontStyle.Bold | FontStyle.Bold)); textIngreseTeclaSombra.Color = Color.Black; textoVelocidad.inicializarTextoVelocidad(auto.velocidad); ///////////////MODIFIERS////////////////// GuiController.Instance.Modifiers.addFloat("velocidadMaxima", 1000, 7000, 1800f); GuiController.Instance.Modifiers.addBoolean("jugarConTiempo", "jugar con tiempo:", true); GuiController.Instance.Modifiers.addBoolean("motionBlurFlag", "Motion Blur", false); //////////////Reflejo de luz en auto//////////////// reflejo = new ReflejoLuzEnAuto(autoMesh); //contador de puntos de control contadorDeActivacionesDePuntosDeControl = 0; contadorDeActivacionesDePuntosDeControlDeIA = 0; //flag de victoria gano = false; List <TgcMesh> autoIAList = new List <TgcMesh>(); autoIAList.Add(meshAutoIA); //motionBlur = new MotionBlur(scenePista.Meshes); //motionBlur.motionBlurInit(0); musica.inicializar(); motionBlur = new MotionBlur(scenePista.Meshes); motionBlur.motionBlurInit(0); emisorHumo = new EmisorHumo(); emisorHumo.crearQuads(20); }
internal void Init() { Device d3dDevice = GuiController.Instance.D3dDevice; score = 0; //lleva el score del jugador capturas = 0; WINNER = false; killMultiTracker = 0; KILL_DELAY = 0; SPAWN_TIME_COUNTER = 0f; time = 0; // creo meshes de modelo para clonar y asi optimizar TgcSceneLoader loader2 = new TgcSceneLoader(); TgcScene scene = loader2.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Robot\\Robot-TgcScene.xml"); this.ModeloRobot = scene.Meshes[0]; TgcScene scene2 = loader2.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\StarWars-Speeder\\StarWars-Speeder-TgcScene.xml"); this.ModeloNave = scene2.Meshes[0]; TgcScene scene3 = loader2.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Meshes\\proyectiles\\EnergyBall-TgcScene.xml"); this.ModeloProyectil = scene3.Meshes[0]; //Cargar textura de CubeMap para Environment Map cubeMap = TextureLoader.FromCubeFile(d3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Shaders\\CubemapRobot.dds"); //Cargar Shader de DynamicLights envMap = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\EnvironmentMap.fx"); envMap.Technique = "SimpleEnvironmentMapTechnique"; skeletalEnvMap = TgcShaders.loadEffect(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Shaders\\" + "SkeletalEnvMap.fx"); //Creo skybox skyBox = new CustomSkyBox(); skyBox.Center = new Vector3(0, 0, 0); float farplane = CustomFpsCamera.FAR_PLANE; skyBox.Size = new Vector3(farplane, farplane, farplane); string texturesPath = GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\SkyBox1\\"; skyBox.setFaceTexture(CustomSkyBox.SkyFaces.Up, texturesPath + "phobos_up.jpg"); skyBox.setFaceTexture(CustomSkyBox.SkyFaces.Down, texturesPath + "phobos_dn.jpg"); skyBox.setFaceTexture(CustomSkyBox.SkyFaces.Left, texturesPath + "phobos_lf.jpg"); skyBox.setFaceTexture(CustomSkyBox.SkyFaces.Right, texturesPath + "phobos_rt.jpg"); skyBox.setFaceTexture(CustomSkyBox.SkyFaces.Front, texturesPath + "phobos_bk.jpg"); skyBox.setFaceTexture(CustomSkyBox.SkyFaces.Back, texturesPath + "phobos_ft.jpg"); skyBox.updateValues(); //Creacion del terreno currentHeightmap = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Mapas\\" + "experimento-editando4_3.jpg"; //Seteo de la resolucion del jpg de heightmap para la interpolacion de altura, como es cuadrado se usa una sola variable heightmapResolution = 800; textureResolution = 1600; Vector3 posInicial = new Vector3(0, 0, 0); currentTexture = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Mapas\\" + "grunge.jpg"; terrain = new CustomTerrain(); terrain.loadHeightmap(currentHeightmap, currentScaleXZ, currentScaleY, posInicial, cantidadFilasColumnas); terrain.loadTexture(currentTexture); terrain.Effect = TgcShaders.loadEffect(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Shaders\\RenderTerrain.fx"); terrain.Technique = "RenderTerrain"; //Creacion del shader de viento windShader = TgcShaders.loadEffect(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Shaders\\WindTree.fx"); //Creacion de la Vegetacion this.vegetation = new List <TgcMesh>(); TgcSceneLoader loader = new TgcSceneLoader(); Vegetation = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Mapas\\100x8 v4-TgcScene.xml"); vegetation = Vegetation.Meshes; int i; for (i = 1; i < vegetation.Count; i++) { float randScaleXZ = (float)random.Next(85, 115) / 100; float randScaleY = (float)random.Next(70, 130) / 100; Matrix scale = Matrix.Scaling(new Vector3(0.06f * randScaleXZ, 0.4f * randScaleY, 0.06f * randScaleXZ)); vegetation[i].setColor(Color.Purple); vegetation[i].Effect = windShader; vegetation[i].Technique = "WindTree"; vegetation[i].Scale = new Vector3(randScaleXZ, randScaleY, randScaleXZ); Vector3 center = vegetation[i].BoundingBox.calculateBoxCenter(); float y; interpoledHeight(center.X, center.Z, out y); center.Y = y; Matrix trans = Matrix.Translation(center + new Vector3(-4f, 0, 0)); vegetation[i].BoundingBox.transform(scale * trans); } //Creacion de la Arbustos this.arbustos = new List <TgcMesh>(); TgcSceneLoader loader6 = new TgcSceneLoader(); Arbustos = loader6.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Mapas\\Arbustos-TgcScene.xml"); arbustos = Arbustos.Meshes; for (i = 1; i < arbustos.Count; i++) { float randScaleXZ = (float)random.Next(90, 110) / 100; float randScaleY = (float)random.Next(75, 125) / 100; arbustos[i].Effect = windShader; arbustos[i].Technique = "WindTree"; arbustos[i].setColor(Color.DarkOrange); arbustos[i].Scale = new Vector3(randScaleXZ, randScaleY, randScaleXZ); } //Creacion de la Tesoros this.tesoros = new List <TgcMesh>(); TgcSceneLoader loader5 = new TgcSceneLoader(); Tesoros = loader5.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Mapas\\Tesoros-TgcScene.xml"); tesoros = Tesoros.Meshes; pointerTexture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\TreasurePointer.png"); initPointer(); int k; for (k = 1; k < tesoros.Count; k++) { TgcSprite pointer = new TgcSprite(); pointer.Texture = pointerTexture; pointer.Scaling = pointerScaling; pointers.Add(pointer); } //Creacion de barriles this.meshesBarril = new List <TgcMesh>(); TgcSceneLoader loader4 = new TgcSceneLoader(); Barriles = loader4.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Mapas\\Barriles2-TgcScene.xml"); Barriles.setMeshesEnabled(true); meshesBarril = Barriles.Meshes; int j; //Matrix scale = Matrix.Scaling(new Vector3(0.06f, 0.4f, 0.06f)); for (j = 1; j < meshesBarril.Count; j++) { Barril barril = new Barril(); meshesBarril[j].Scale = new Vector3(0.3f, 0.3f, 0.3f); barril.mesh = meshesBarril[j]; barril.Init(); barriles.Add(barril); //vegetation[i].setColor(Color.SkyBlue); //Vector3 center = vegetation[i].BoundingBox.calculateBoxCenter(); //float y; //interpoledHeight(center.X, center.Z, out y); //center.Y = y; //Matrix trans = Matrix.Translation(center + new Vector3(-4f, 0, 0)); //vegetation[i].BoundingBox.transform(scale * trans); } //inicializamos al player player1.Init(); enemies = new List <Enemy>(); proyectiles = new List <Proyectil>(); ScreenWidth = GuiController.Instance.D3dDevice.Viewport.Width; ScreenHeight = GuiController.Instance.D3dDevice.Viewport.Height; obstaculos = new List <TgcMesh>(); obstaculos.AddRange(vegetation); obstaculos.AddRange(meshesBarril); obstaculos.AddRange(arbustos); quadTree = new Quadtree(); quadTree.create(obstaculos, Vegetation.BoundingBox); quadTree.createDebugQuadtreeMeshes(); //seteamos niebla //d3dDevice.RenderState.FogTableMode = FogMode.Linear; d3dDevice.RenderState.FogTableMode = FogMode.Exp2; d3dDevice.RenderState.FogVertexMode = FogMode.None; d3dDevice.RenderState.FogColor = Color.MediumPurple; //d3dDevice.RenderState.FogStart = 3000f; //d3dDevice.RenderState.FogEnd = farplane; d3dDevice.RenderState.FogDensity = 0.00006f; d3dDevice.RenderState.FogEnable = true; initPastos(); int secuense = 0; int part = 0; Pasto pasto = new Pasto(); foreach (Vector3 pastoCoord in pastosCoords) { pasto.crearPasto(d3dDevice, secuense, pastoCoord); if (part == 5) { pastos.Add(pasto); pasto = new Pasto(); } secuense++; part++; if (secuense > 2) { secuense = 0; } if (part > 5) { part = 0; } } }
public void Init() { GAME_OVER = false; TEXT_DELAY = 0; time = 0; ScreenWidth = GuiController.Instance.D3dDevice.Viewport.Width; ScreenHeight = GuiController.Instance.D3dDevice.Viewport.Height; d3dDevice = GuiController.Instance.D3dDevice; //-------------User Interface------------ //Textos para los Kills specialKillText = new TgcText2d(); specialKillText.Color = Color.Crimson; specialKillText.Align = TgcText2d.TextAlign.CENTER; specialKillText.Position = new Point(0, 100); specialKillText.changeFont(new System.Drawing.Font("TimesNewRoman", 25, FontStyle.Bold)); //texto para el score //cambia de color segun el score scoreText = new TgcText2d(); scoreText.Text = GameManager.Instance.score.ToString(); scoreText.Color = Color.LightBlue; scoreText.changeFont(new System.Drawing.Font("Arial", 20, FontStyle.Bold)); //texto para el capturas captureText = new TgcText2d(); captureText.Text = GameManager.Instance.capturas.ToString() + "/11"; captureText.Color = Color.FloralWhite; captureText.Position = new Point(450, 0); captureText.changeFont(new System.Drawing.Font("Arial", 20, FontStyle.Bold)); // cargamos los sprites screenCovered = SMALL_SCOPE; cross = new TgcSprite(); normalScope = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\normalScope.png"); zoomedScope = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\zoomedScope.png"); cross.Texture = normalScope; refreshScopeTexture(); HudFront = new TgcSprite(); HudFront.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\HudFront.png"); initHudFront(); healthSprite = new TgcSprite(); healthSprite.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\HealthStencil.png"); healthInit(); hudWeapon = new TgcSprite(); sniperTexture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\sniperHUD.png"); launcherTexture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\launcherHUD.png"); refreshMainWeapon(); hudWeaponInit(); scoreSprite = new TgcSprite(); scoreSprite.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\Score.png"); initScoreSprite(); mapBaseSprite = new TgcSprite(); mapBaseSprite.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\MapBase.png"); initMapBase(); playerPointerSprite = new TgcSprite(); playerPointerSprite.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\playerPointer.png"); initPlayerPointer(); highScoreSprite = new TgcSprite(); highScoreSprite.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\highScore.png"); initHighScore(); //inicializo audio sound = new TgcStaticSound(); ambient = new TgcStaticSound(); string dir = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Audio/Ambiente/Deep_space.wav"; ambient.loadSound(dir, -1500); ambient.play(true); reachedHighScore = false; }