예제 #1
0
        public LucesAuto(Auto auto, Ruedas r1, Ruedas r2, TgcCamera cam)
        {
            camara    = cam;
            lightMesh = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);

            //lista para todos los meshes
            lstMeshes = new List <TgcMesh>();
            var scene = auto.ciudadScene;

            //agrego meshes del scene a la lista
            foreach (var mesh in scene.Meshes)
            {
                lstMeshes.Add(mesh);
            }

            //agrego auto
            //lstMeshes.Add(auto);


            //agrego ruedas
            lstMeshes.Add(r1.RuedaMeshDer);
            lstMeshes.Add(r1.RuedaMeshIzq);
            lstMeshes.Add(r2.RuedaMeshIzq);
            lstMeshes.Add(r2.RuedaMeshDer);
        }
예제 #2
0
        public override void Init()
        {
            //Cargar 25 cajas formando una matriz
            var loader = new TgcSceneLoader();

            boxes = new List <TgcBox>();
            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                   MediaDir + "Texturas\\granito.jpg");
            var boxSize = new Vector3(30, 30, 30);

            for (var i = 0; i < 5; i++)
            {
                for (var j = 0; j < 5; j++)
                {
                    var center = new Vector3((boxSize.X + boxSize.X / 2) * i, (boxSize.Y + boxSize.Y / 2) * j, 0);
                    var box    = TgcBox.fromSize(center, boxSize, texture);
                    boxes.Add(box);
                }
            }

            //Iniciarlizar PickingRay
            pickingRay = new TgcPickingRay();

            Camara = new TgcRotationalCamera(new Vector3(100f, 100f, -250f), 600f);
            //FIXME esta camara deberi ser estatica y no rotacional, ya que sino trae problemas con el picking.

            //Crear caja para marcar en que lugar hubo colision
            collisionPointMesh = TgcBox.fromSize(new Vector3(3, 3, 3), Color.Red);
            selected           = false;

            //UserVars para mostrar en que punto hubo colision
            UserVars.addVar("CollP-X:");
            UserVars.addVar("CollP-Y:");
            UserVars.addVar("CollP-Z:");
        }
예제 #3
0
        //*********************************************
        /* Carga el tanque de Guerra */
        //*********************************************
        public void CargarTanque()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            TgcSceneLoader loader7 = new TgcSceneLoader();

            loader7.MeshFactory = new CustomMeshShaderFactory();
            TgcScene scene7 = loader7.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\TanqueFuturistaRuedas\\TanqueFuturistaRuedas-TgcScene.xml");

            mesh4 = (TgcMeshShader)scene7.Meshes[0];


            mesh4.Position   = C_PosicionActual;
            mesh4.Scale      = new Vector3(0.2f, 0.2f, 0.2f);
            C_PosicionAnt    = C_PosicionActual;
            C_PosicionActual = mesh4.Position;
            C_Estado         = "Vivo";

            //Cargar Shader de PhonhShading
            string compilationErrors;

            mesh4.Effect = Effect.FromFile(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Shaders\\PhongShading.fx", null, null, ShaderFlags.None, null, out compilationErrors);
            if (mesh4.Effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            //Configurar Technique
            mesh4.Effect.Technique = "DefaultTechnique";

            //Crear caja para indicar ubicacion de la luz
            lightBox = TgcBox.fromSize(new Vector3(50, 50, 50), Color.Yellow);
        }
예제 #4
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Iniciar kinect
            tgcKinect = new TgcKinect();
            tgcKinect.init();
            tgcKinect.DebugSkeleton.init();

            //Analizador de gestos
            gestureAnalizer = new GestureAnalizer();
            sceneBounds     = new TgcBoundingBox(new Vector3(-50, -40, 230), new Vector3(80, 50, 290));
            gestureAnalizer.setSceneBounds(sceneBounds);
            sceneCenter = sceneBounds.calculateBoxCenter();

            sceneCenterBox = TgcBox.fromSize(sceneCenter, new Vector3(30, 30, 30), Color.Blue);

            //Crear mueble de fondo
            mueble          = TgcBox.fromSize(new Vector3(200, 100, 50), Color.SandyBrown);
            mueble.Position = new Vector3(20, 20, 200);

            //Crear puerta
            door               = new GestureDoorLeft();
            door.Mesh          = TgcBox.fromSize(new Vector3(30, 40, 4), Color.Green).toMesh("door");
            door.Mesh.Position = mueble.Position + new Vector3(-30, 20, 25);


            GuiController.Instance.FpsCamera.Enable = true;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(1.5467f, 54.7247f, 401.1074f), new Vector3(1.4672f, 54.4561f, 400.1474f));
        }
예제 #5
0
        public override void Init()
        {
            //Color de fondo
            //GuiController.Instance.BackgroundColor = Color.DarkGray;

            //Camara en 1ra persona
            //GuiController.Instance.FpsCamera.Enable = true;
            //GuiController.Instance.FpsCamera.MovementSpeed = 100f;
            //GuiController.Instance.FpsCamera.JumpSpeed = 50f;
            //GuiController.Instance.FpsCamera.setCamera(new Vector3(40, 30, 35), new Vector3(0, 0, 0));

            this.effect = TgcShaders.loadEffect(this.pathRecursos + "Shaders\\ParcialPixelShader.fx");

            //Piso
            this.boxFloor        = TgcBox.fromSize(new Vector3(0, 0, 0), new Vector3(30, 0, 30), Color.DarkSeaGreen);
            this.boxFloor.Effect = this.effect;

            //Pared
            this.boxWall        = TgcBox.fromSize(new Vector3(0, 10, -15), new Vector3(30, 20, 0), Color.Red);
            this.boxWall.Effect = this.effect;

            //Figura
            this.boxFigure        = TgcBox.fromSize(new Vector3(0, 5, 0), new Vector3(10, 10, 5), Color.SteelBlue);
            this.boxFigure.Effect = this.effect;

            //Luz
            this.boxLuz = TgcBox.fromSize(new Vector3(0, 20, 20), new Vector3(2, 2, 2), Color.LightYellow);

            this.CrearTetera();
            this.CrearBuggy();
        }
예제 #6
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Crear loader
            TgcSceneLoader loader = new TgcSceneLoader();

            //Cargar mesh
            TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Olla\\Olla-TgcScene.xml");

            mesh = scene.Meshes[0];


            //Crear caja para indicar ubicacion de la luz
            lightMesh = TgcBox.fromSize(new Vector3(20, 20, 20), Color.Yellow);


            //Modifiers de la luz
            GuiController.Instance.Modifiers.addBoolean("lightEnable", "lightEnable", true);
            GuiController.Instance.Modifiers.addVertex3f("lightPos", new Vector3(-500, -500, -500), new Vector3(500, 800, 500), new Vector3(0, 500, 0));
            GuiController.Instance.Modifiers.addColor("ambient", Color.Gray);
            GuiController.Instance.Modifiers.addColor("diffuse", Color.Blue);
            GuiController.Instance.Modifiers.addColor("specular", Color.White);
            GuiController.Instance.Modifiers.addFloat("specularEx", 0, 40, 20f);



            //Centrar camara rotacional respecto a este mesh
            GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox);
        }
        public override void init()
        {
            Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cuerpo principal que se controla con el teclado
            box = TgcBox.fromSize(new Vector3(0, 10, 0), new Vector3(10, 10, 10), Color.Blue);

            //triangulo
            triangle    = new CustomVertex.PositionColored[3];
            triangle[0] = new CustomVertex.PositionColored(-100, 0, 0, Color.Red.ToArgb());
            triangle[1] = new CustomVertex.PositionColored(0, 0, 50, Color.Green.ToArgb());
            triangle[2] = new CustomVertex.PositionColored(0, 100, 0, Color.Blue.ToArgb());
            triagleAABB = TgcBoundingBox.computeFromPoints(new Vector3[] { triangle[0].Position, triangle[1].Position, triangle[2].Position });

            //box2
            box2 = TgcBox.fromSize(new Vector3(-50, 10, -20), new Vector3(15, 15, 15), Color.Violet);

            //sphere
            sphere = new TgcBoundingSphere(new Vector3(30, 20, -20), 15);

            //OBB: computar OBB a partir del AABB del mesh.
            TgcSceneLoader loader  = new TgcSceneLoader();
            TgcMesh        meshObb = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\StarWars-ATST\\StarWars-ATST-TgcScene.xml").Meshes[0];

            obb = TgcObb.computeFromAABB(meshObb.BoundingBox);
            meshObb.dispose();
            obb.move(new Vector3(100, 0, 30));
            obb.setRotation(new Vector3(0, FastMath.PI / 4, 0));


            //Configurar camara en Tercer Persona
            GuiController.Instance.ThirdPersonCamera.Enable = true;
            GuiController.Instance.ThirdPersonCamera.setCamera(box.Position, 30, -75);
        }
예제 #8
0
        public override void Init()
        {
            //Cargar escenario
            var loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new Vector3(-20, 80, 450), 400f, 300f);

            //Mesh para la luz
            lightMesh = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);

            //Modifiers de la luz
            Modifiers.addBoolean("lightEnable", "lightEnable", true);
            Modifiers.addVertex3f("lightPos", new Vector3(-200, -100, -200),
                                  new Vector3(200, 200, 300), new Vector3(60, 35, 250));
            Modifiers.addColor("lightColor", Color.White);
            Modifiers.addFloat("lightIntensity", 0, 150, 20);
            Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.3f);
            Modifiers.addFloat("specularEx", 0, 20, 9f);

            //Modifiers de material
            Modifiers.addColor("mEmissive", Color.Black);
            Modifiers.addColor("mAmbient", Color.White);
            Modifiers.addColor("mDiffuse", Color.White);
            Modifiers.addColor("mSpecular", Color.White);
        }
        public override void Init()
        {
            //Crear Sprite animado
            animatedSprite = new TgcAnimatedSprite(MediaDir + "\\Texturas\\Sprites\\Explosion.png", //Textura de 256x256
                                                   new Size(64, 64),                                //Tamaño de un frame (64x64px en este caso)
                                                   16,                                              //Cantidad de frames, (son 16 de 64x64px)
                                                   10                                               //Velocidad de animacion, en cuadros x segundo
                                                   );

            //Ubicarlo centrado en la pantalla
            var textureSize = animatedSprite.Sprite.Texture.Size;

            animatedSprite.Position = new Vector2(D3DDevice.Instance.Width / 2 - textureSize.Width / 2,
                                                  D3DDevice.Instance.Height / 2 - textureSize.Height / 2);

            //Modifiers para variar parametros del sprite
            Modifiers.addFloat("frameRate", 1, 30, 10);
            Modifiers.addVertex2f("position", new Vector2(0, 0),
                                  new Vector2(D3DDevice.Instance.Width, D3DDevice.Instance.Height), animatedSprite.Position);
            Modifiers.addVertex2f("scaling", new Vector2(0, 0), new Vector2(4, 4), animatedSprite.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);
        }
예제 #10
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Crear suelo
            TgcTexture pisoTexture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack2\\rock_floor1.jpg");

            suelo = TgcBox.fromSize(new Vector3(500, 0, 500), new Vector3(2000, 0, 2000), pisoTexture);


            //Cargar malla original
            TgcSkeletalLoader loader    = new TgcSkeletalLoader();
            string            pathMesh  = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";
            string            mediaPath = GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\";

            original = loader.loadMeshFromFile(pathMesh, mediaPath);

            //Agregar animación a original
            loader.loadAnimationFromFile(original, mediaPath + "Patear-TgcSkeletalAnim.xml");

            //Agregar attachment a original
            TgcSkeletalBoneAttach attachment = new TgcSkeletalBoneAttach();
            TgcBox attachmentBox             = TgcBox.fromSize(new Vector3(3, 60, 3), Color.Green);

            attachment.Mesh   = attachmentBox.toMesh("attachment");
            attachment.Bone   = original.getBoneByName("Bip01 L Hand");
            attachment.Offset = Matrix.Translation(10, -40, 0);
            attachment.updateValues();
            original.Attachments.Add(attachment);


            //Crear 9 instancias mas de este modelo, pero sin volver a cargar el modelo entero cada vez
            float offset         = 200;
            int   cantInstancias = 4;

            instances = new List <TgcSkeletalMesh>();
            for (int i = 0; i < cantInstancias; i++)
            {
                TgcSkeletalMesh instance = original.createMeshInstance(original.Name + i);

                instance.move(i * offset, 0, 0);
                instances.Add(instance);
            }


            //Especificar la animación actual para todos los modelos
            original.playAnimation("Patear");
            foreach (TgcSkeletalMesh instance in instances)
            {
                instance.playAnimation("Patear");
            }


            //Camara en primera persona
            GuiController.Instance.FpsCamera.Enable        = true;
            GuiController.Instance.FpsCamera.MovementSpeed = 400;
            GuiController.Instance.FpsCamera.JumpSpeed     = 400;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(293.201f, 291.0797f, -604.6647f), new Vector3(299.1028f, -63.9185f, 330.1836f));
        }
예제 #11
0
 public FarolRecarga(Vector3 pos, Farol farol)
 {
     this.init();
     this.farol           = farol;
     this.posicion        = pos;
     this.colision        = TgcBox.fromSize(posicion, new Vector3(30, 200, 30));
     this.meshLR.Position = posicion;
 }
예제 #12
0
 public VelaRecarga(Vector3 pos, Vela vela)
 {
     this.init();
     this.vela            = vela;
     this.posicion        = pos;
     this.colision        = TgcBox.fromSize(posicion, new Vector3(30, 100, 30));
     this.meshLR.Position = posicion;
 }
예제 #13
0
 public LinternaRecarga(Vector3 pos, Linterna linterna)
 {
     this.init();
     this.linterna        = linterna;
     this.posicion        = pos;
     this.colision        = TgcBox.fromSize(posicion, new Vector3(30, 100, 30));
     this.meshLR.Position = posicion;
 }
예제 #14
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            box = TgcBox.fromSize(new Vector3(0, 0, 0), new Vector3(20, 20, 20), Color.Red);

            GuiController.Instance.RotCamera.targetObject(box.BoundingBox);
        }
예제 #15
0
 public Llave(Vector3 pos)
 {
     this.init();
     this.posicion           = pos;
     this.colision           = TgcBox.fromSize(posicion, new Vector3(30, 100, 30));
     this.meshLlave.Position = posicion;
     this.meshLlave.Scale    = new Vector3(0.5f, 0.5f, 0.5f);
 }
예제 #16
0
        public PrimitiveRenderer(EditablePoly editablePoly)
        {
            this.editablePoly  = editablePoly;
            this.batchRenderer = new TrianglesBatchRenderer();

            this.vertexBox         = TgcBox.fromSize(new Vector3(1, 1, 1), Color.Blue);
            this.selectedVertexBox = TgcBox.fromSize(new Vector3(1, 1, 1), Color.Red);
        }
예제 #17
0
 public Recursos(float x, float z, float y, string textura, int check)
 {
     this.box = TgcBox.fromSize(
         new Vector3(x, y, z),        //posicion
         new Vector3(50, 150, 150),   //tamaño
         TgcTexture.createTexture(textura));
     this.box.rotateX(Geometry.DegreeToRadian(45));
     this.checkpoint = check;
 }
예제 #18
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Cargar escenario
            TgcSceneLoader loader = new TgcSceneLoader();

            scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Camara en 1ra persona
            GuiController.Instance.FpsCamera.Enable        = true;
            GuiController.Instance.FpsCamera.MovementSpeed = 400f;
            GuiController.Instance.FpsCamera.JumpSpeed     = 300f;
            GuiController.Instance.FpsCamera.setCamera(new Vector3(-210.0958f, 114.911f, -109.2159f), new Vector3(-209.559f, 114.8029f, -108.3791f));

            //Cargar Shader personalizado de MultiDiffuseLights

            /*
             * Cargar Shader personalizado de MultiDiffuseLights
             * Este Shader solo soporta TgcMesh con RenderType DIFFUSE_MAP (que son las unicas utilizadas en este ejemplo)
             * El shader toma 4 luces a la vez para iluminar un mesh.
             * Pero como hacer 4 veces los calculos en el shader es costoso, de cada luz solo calcula el componente Diffuse.
             */
            effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\MultiDiffuseLights.fx");


            //Crear 4 mesh para representar las 4 para la luces. Las ubicamos en distintas posiciones del escenario, cada una con un color distinto.
            lightMeshes  = new TgcBox[4];
            origLightPos = new Vector3[lightMeshes.Length];
            Color[] c = new Color[4] {
                Color.Red, Color.Blue, Color.Green, Color.Yellow
            };
            for (int i = 0; i < lightMeshes.Length; i++)
            {
                Color co = c[i % c.Length];
                lightMeshes[i]  = TgcBox.fromSize(new Vector3(10, 10, 10), co);
                origLightPos[i] = new Vector3(-40, 20 + i * 20, 400);
            }

            //Modifiers
            GuiController.Instance.Modifiers.addBoolean("lightEnable", "lightEnable", true);
            GuiController.Instance.Modifiers.addBoolean("lightMove", "lightMove", true);
            GuiController.Instance.Modifiers.addFloat("lightIntensity", 0, 150, 38);
            GuiController.Instance.Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.15f);

            GuiController.Instance.Modifiers.addColor("mEmissive", Color.Black);
            GuiController.Instance.Modifiers.addColor("mDiffuse", Color.White);


            //Interpolador para mover las luces de un lado para el otro
            interp         = new InterpoladorVaiven();
            interp.Min     = -200f;
            interp.Max     = 200f;
            interp.Speed   = 100f;
            interp.Current = 0f;
        }
예제 #19
0
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            TgcBox box = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);

            boxMesh = box.toMesh("box");
            box.dispose();
            time = 0;
        }
예제 #20
0
        /// <summary>
        /// Crea el menu-caja, recibe el input :P
        /// </summary>
        /// <param name="input"></param>
        public MenuCaja(TgcD3dInput input)
        {
            Input = input;

            var size = new Vector3(100, 100, 100);

            MenuBox = TgcBox.fromSize(size, Color.Black);
            MenuBox.AutoTransformEnable = true;
            MenuBox.Position            = new Vector3(0, 2000, 0);
        }
예제 #21
0
 public Trofeo(Vector3 pos)
 {
     this.init();
     this.posicion            = pos;
     this.colision            = TgcBox.fromSize(posicion, new Vector3(300, 100, 300));
     this.meshTrofeo.Position = posicion;
     this.meshMesa.Position   = posicion;
     meshMesa.move(new Vector3(0, -8f, 0));
     this.meshTrofeo.move(new Vector3(0, 55f, 0));
 }
예제 #22
0
        public override void Init()
        {
            var box = TgcBox.fromSize(new Vector3(10, 10, 10), Color.Red);

            boxMesh = box.toMesh("box");
            box.dispose();
            time = 0;

            Camara = new TgcRotationalCamera(box.BoundingBox.calculateBoxCenter(),
                                             box.BoundingBox.calculateBoxRadius() * 2);
        }
예제 #23
0
        public TerrainBrush()
        {
            SoundEnabled = true;
            text         = new TgcText2d();
            text.Align   = TgcText2d.TextAlign.RIGHT;
            text.changeFont(new System.Drawing.Font("Arial", 12, FontStyle.Bold));

            bBrush = TgcBox.fromSize(new Vector3(10, 100, 10));
            sound  = new TgcStaticSound();
            sound.loadSound(GuiController.Instance.ExamplesMediaDir + "Sound\\tierra.wav");
        }
예제 #24
0
        // Constructor
        public ObstaculoRigido(float _x, float _z, float _y, float ancho, float alto, float largo, string textura)
        {
            TgcBox box = TgcBox.fromSize(
                new Vector3(_x, _z, _y),           //posicion
                new Vector3(ancho, alto, largo),   //tamaño
                TgcTexture.createTexture(textura));

            //Computar OBB a partir del AABB del mesh. Inicialmente genera el mismo volumen que el AABB, pero luego te permite rotarlo (cosa que el AABB no puede)
            this.obb  = TgcObb.computeFromAABB(box.BoundingBox);
            this.mesh = box.toMesh("caja");
        }
예제 #25
0
        public PointLight2(GameModel gm, Vector3 Posicion)
        {
            gameModel = gm;
            lighthPos = Posicion;
            float t = 10f;

            lightMesh = TgcBox.fromSize(lighthPos, new Vector3(t, t, t), Color.White);
            lightMesh.AutoTransformEnable = false;
            lightMesh.updateValues();
            currentShader = TgcShaders.Instance.TgcMeshPointLightShader;
        }
예제 #26
0
        /// <summary>
        /// Creo los limites de la cancha
        /// </summary>
        /// <returns> Lista con los limites de la cancha</returns>
        private List <LimiteCancha> CrearLimitesCancha(TgcBox cancha)
        {
            int altoLimite = 600;
            List <LimiteCancha> limites = new List <LimiteCancha>();

            limites.Add(new LimiteCancha(TgcBox.fromSize(new Vector3(cancha.Position.X, cancha.Position.Y + altoLimite / 2, cancha.Size.Z / 2 - 22), new Vector3(cancha.Size.X, altoLimite, 0))));
            limites.Add(new LimiteCancha(TgcBox.fromSize(new Vector3(cancha.Position.X, cancha.Position.Y + altoLimite / 2, -cancha.Size.Z / 2 + 22), new Vector3(cancha.Size.X, altoLimite, 0))));
            limites.Add(new LimiteCancha(TgcBox.fromSize(new Vector3(cancha.Size.X / 2 - 100, cancha.Position.Y + altoLimite / 2, cancha.Position.Z), new Vector3(0, altoLimite, cancha.Size.Z))));
            limites.Add(new LimiteCancha(TgcBox.fromSize(new Vector3(-cancha.Size.X / 2 + 100, cancha.Position.Y + altoLimite / 2, cancha.Position.Z), new Vector3(0, altoLimite, cancha.Size.Z))));

            return(limites);
        }
예제 #27
0
        public override void Init()
        {
            var texture = TgcTexture.createTexture(MediaDir + "MeshCreator\\Textures\\Metal\\floor1.jpg");
            var center  = new Vector3(0, 0, 0);
            var size    = new Vector3(1f, 1f, 1f);

            box = TgcBox.fromSize(center, size, texture);
            //Por defecto se deshabilito esto, cada uno debe implementar su modelo de transformaciones.
            //box.AutoTransformEnable = false;
            box.Transform = Matrix.Identity;
            Camara        = new TgcRotationalCamera(new Vector3(0f, 1.5f, 0f), 20f, Input);
        }
        public PuntoDeLuz(TwistedMetal env, Vector3 Posicion)
        {
            this.env  = env;
            lighthPos = Posicion;
            float t = 10f;

            lightMesh = TgcBox.fromSize(lighthPos, new Vector3(t, t, t), Color.White);
            lightMesh.AutoTransformEnable = false;
            lightMesh.updateValues();
            //currentShader = TgcShaders.Instance.TgcMeshPointLightShader;
            currentShader = TgcShaders.loadEffect(this.env.ShadersDir + "TgcMeshSpotLightShader.fx");
        }
예제 #29
0
        public EnemigoAnimacion(Vector3 cercania, Vector3 dimensionesCaja)
        {
            string pathSonido = alumnoMediaFolder + "CucarachaJugosita\\Media\\Juego felipe sonido ambiente terror.wav";

            sonidoPreSusto = new TgcStaticSound();
            sonidoPreSusto.loadSound(pathSonido);
            this.cercania    = cercania;
            animada          = false;
            activarAnimacion = false;
            //Paths para archivo XML de la malla
            pathMesh = alumnoMediaFolder + "CucarachaJugosita\\Media\\SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";

            //Path para carpeta de texturas de la malla
            mediaPath = alumnoMediaFolder + "CucarachaJugosita\\Media\\SkeletalAnimations\\Robot\\";

            //Lista de animaciones disponibles
            animationList = new string[] {
                "Parado",
                "Caminando",
                "Correr",
                "PasoDerecho",
                "PasoIzquierdo",
                "Empujar",
                "Patear",
                "Pegar",
                "Arrojar",
            };

            //Crear rutas con cada animacion
            animationsPath = new string[animationList.Length];
            for (int i = 0; i < animationList.Length; i++)
            {
                animationsPath[i] = mediaPath + animationList[i] + "-TgcSkeletalAnim.xml";
            }

            //Cargar mesh y animaciones
            TgcSkeletalLoader loader2 = new TgcSkeletalLoader();

            mesh = loader2.loadMeshAndAnimationsFromFile(pathMesh, mediaPath, animationsPath);
            //mesh.Position = new Vector3(105, 5.06f, 660);
            mesh.Scale = new Vector3(0.5f, 0.5f, 0.5f);
            //Crear esqueleto a modo Debug
            mesh.buildSkletonMesh();
            //Elegir animacion Caminando
            // mesh.BoundingBox.move(new Vector3(15,0,-170));
            //mesh.BoundingBox.scaleTranslate(mesh.BoundingBox.Position, new Vector3(4f,0.8f,4f)); // este sera el rango de vision
            bounding = new TgcBox();
            bounding = TgcBox.fromSize(mesh.Position, new Vector3(100f, 100f, 300f));
            bounding.move(new Vector3(15, 0, -170));
            box          = new TgcBox();
            box.Position = cercania;
            box.Size     = dimensionesCaja;
        }
예제 #30
0
        public override void Init()
        {
            //Cargar escenario
            var loader = new TgcSceneLoader();

            scene =
                loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml");

            //Camara en 1ra persona
            Camara = new TgcFpsCamera(new Vector3(260f, 170f, 390f), 400f, 300f, Input);

            //Cargar Shader personalizado de MultiDiffuseLights

            /*
             * Cargar Shader personalizado de MultiDiffuseLights
             * Este Shader solo soporta TgcMesh con RenderType DIFFUSE_MAP (que son las unicas utilizadas en este ejemplo)
             * El shader toma 4 luces a la vez para iluminar un mesh.
             * Pero como hacer 4 veces los calculos en el shader es costoso, de cada luz solo calcula el componente Diffuse.
             */
            effect = TgcShaders.loadEffect(ShadersDir + "MultiDiffuseLights.fx");

            //Crear 4 mesh para representar las 4 para la luces. Las ubicamos en distintas posiciones del escenario, cada una con un color distinto.
            lightMeshes  = new TgcBox[4];
            origLightPos = new Vector3[lightMeshes.Length];
            var c = new Color[4] {
                Color.Red, Color.Blue, Color.Green, Color.Yellow
            };

            for (var i = 0; i < lightMeshes.Length; i++)
            {
                var co = c[i % c.Length];
                lightMeshes[i] = TgcBox.fromSize(new Vector3(10, 10, 10), co);
                lightMeshes[i].AutoTransformEnable = true;
                origLightPos[i] = new Vector3(-40, 20 + i * 20, 400);
            }

            //Modifiers
            Modifiers.addBoolean("lightEnable", "lightEnable", true);
            Modifiers.addBoolean("lightMove", "lightMove", true);
            Modifiers.addFloat("lightIntensity", 0, 150, 38);
            Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.15f);

            Modifiers.addColor("mEmissive", Color.Black);
            Modifiers.addColor("mDiffuse", Color.White);

            //Interpolador para mover las luces de un lado para el otro
            interp         = new InterpoladorVaiven();
            interp.Min     = -200f;
            interp.Max     = 200f;
            interp.Speed   = 100f;
            interp.Current = 0f;
        }