Exemplo n.º 1
0
        public Track(TGCVector3 centro, string pathTextura, int repeticiones)
        {
            //var d3dDevice = D3DDevice.Instance.Device;
            //var shader = Effect.FromFile(d3dDevice, MediaDir + "MotionBlur.fx",null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);

            repeat = repeticiones;
            center = centro;

            var size_lados = new TGCVector3(0, 320, 640);
            var size_suelo = new TGCVector3(160, 0, 640);

            textura = TgcTexture.createTexture(pathTextura);


            walls_l = new List <TgcMesh>();
            walls_r = new List <TgcMesh>();
            floors  = new List <TgcMesh>();

            var plane = new TgcPlane(center, center, TgcPlane.Orientations.YZplane, textura);


            for (int i = 0; i < repeticiones; i++)
            {
                var walll = new TgcPlane(center + new TGCVector3(-80, -160, -320 - (i * 640)), size_lados, TgcPlane.Orientations.YZplane, textura);
                walls_l.Add(walll.toMesh("wall_l_" + i));
                var wallr = new TgcPlane(center + new TGCVector3(80, -160, -320 - (i * 640)), size_lados, TgcPlane.Orientations.YZplane, textura);
                walls_r.Add(wallr.toMesh("wall_r_" + i));
                var floor = new TgcPlane(center + new TGCVector3(-80, -160, -320 - (i * 640)), size_suelo, TgcPlane.Orientations.XZplane, textura);
                floors.Add(floor.toMesh("floor_" + i));
            }
        }
Exemplo n.º 2
0
        public List <TgcMesh> CreateColumn(TgcPlane columnPlaneX, TgcPlane columnPlaneZ, TGCVector3 offset)
        {
            List <TgcMesh> columna = new List <TgcMesh>();

            var baseWall = columnPlaneX;

            var wallMesh = baseWall.toMesh("Column1V1");

            wallMesh.Position = new TGCVector3(Position.X + 5 + offset.X, Position.Y, Position.Z + offset.Z);
            wallMesh.UpdateMeshTransform();
            columna.Add(wallMesh);

            wallMesh          = baseWall.toMesh("Column1V2");
            wallMesh.Position = new TGCVector3(Position.X + offset.X, Position.Y, Position.Z + offset.Z);
            wallMesh.UpdateMeshTransform();
            columna.Add(wallMesh);

            baseWall = columnPlaneZ;

            wallMesh          = baseWall.toMesh("Column1H1");
            wallMesh.Position = new TGCVector3(Position.X + offset.X, Position.Y, Position.Z + 5 + offset.Z);
            wallMesh.UpdateMeshTransform();
            columna.Add(wallMesh);

            wallMesh          = baseWall.toMesh("Column1H2");
            wallMesh.Position = new TGCVector3(Position.X + offset.X, Position.Y, Position.Z + offset.Z);
            wallMesh.UpdateMeshTransform();
            columna.Add(wallMesh);

            return(columna);
        }
Exemplo n.º 3
0
        private void InitializeMeshes()
        {
            TgcTexture tiles, lava, stones, water;

            tiles  = TgcTexture.createTexture(MediaDir + "Textures/tiles.jpg");
            lava   = TgcTexture.createTexture(MediaDir + "Textures/lava.jpg");
            stones = TgcTexture.createTexture(MediaDir + "Textures/stones.bmp");
            water  = TgcTexture.createTexture(MediaDir + "Textures/water.bmp");

            TGCSphere baseSphere = new TGCSphere(1f, Color.White, TGCVector3.Empty);

            baseSphere.setTexture(lava);
            baseSphere.updateValues();
            sphereOne = baseSphere.toMesh("sphereOne");
            meshes.Add(sphereOne);
            baseSphere.setTexture(stones);
            sphereTwo = baseSphere.toMesh("sphereTwo");
            meshes.Add(sphereTwo);
            baseSphere.setTexture(water);
            sphereThree = baseSphere.toMesh("sphereThree");
            meshes.Add(sphereThree);

            TgcSceneLoader loader = new TgcSceneLoader();
            var            scene  = loader.loadSceneFromFile(MediaDir + "Robot2-TgcScene.xml");

            robot           = scene.Meshes[0];
            robot.Transform = TGCMatrix.Scaling(0.1f, 0.1f, 0.1f) * TGCMatrix.RotationY(FastMath.PI) * TGCMatrix.Translation(TGCVector3.Up * 40f);
            meshes.Add(robot);

            TgcPlane tgcPlane = new TgcPlane(TGCVector3.Empty, TGCVector3.One * 100f, TgcPlane.Orientations.XZplane, tiles, 10f, 10f);

            plane = tgcPlane.toMesh("plane");
            meshes.Add(plane);
        }
Exemplo n.º 4
0
        public override void Init()
        {
            //Modifiers para variar parametros de la pared
            Modifiers.addVertex3f("origin", new Vector3(-100, -100, -100), new Vector3(100, 100, 100),
                                  new Vector3(0, 0, 0));
            Modifiers.addVertex3f("dimension", new Vector3(-100, -100, -100), new Vector3(1000, 1000, 100),
                                  new Vector3(100, 100, 100));
            Modifiers.addInterval("orientation", new[] { "XY", "XZ", "YZ" }, 0);
            Modifiers.addVertex2f("tiling", new Vector2(0, 0), new Vector2(10, 10), new Vector2(1, 1));
            Modifiers.addBoolean("autoAdjust", "autoAdjust", false);

            //Modifier de textura
            var texturePath = MediaDir + "Texturas\\Quake\\TexturePack2\\brick1_1.jpg";

            currentTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, texturePath);
            Modifiers.addTexture("texture", currentTexture.FilePath);

            //Crear pared
            plane = new TgcPlane();
            plane.setTexture(currentTexture);

            //Actualizar segun valores cargados
            updatePlane();

            //Ajustar camara segun tamano de la pared
            Camara = new TgcRotationalCamera(plane.BoundingBox.calculateBoxCenter(),
                                             plane.BoundingBox.calculateBoxRadius() * 2, Input);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Construir plano
        /// </summary>
        public override void doCreation()
        {
            var input = Control.creator.Input;

            //Si hacen clic con el mouse, ver si hay colision con el suelo
            if (input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT))
            {
                //Obtener altura en Y segun movimient en Y del mouse
                var heightY         = creatingInitMouseY - input.Ypos;
                var adjustedHeightY = MeshCreatorUtils.getMouseIncrementHeightSpeed(Control.Camera, BoundingBox, heightY);

                //Determinar posicion Z segun la colision con el grid
                var collisionPoint = Control.Grid.getPicking();
                var extensionPoint = new TGCVector3(initSelectionPoint.X, initSelectionPoint.Y + adjustedHeightY,
                                                    collisionPoint.Z);

                //Obtener maximo y minimo
                var min = TGCVector3.Minimize(initSelectionPoint, extensionPoint);
                var max = TGCVector3.Maximize(initSelectionPoint, extensionPoint);
                min.X = initSelectionPoint.X;
                max.X = initSelectionPoint.X + 1;

                //Configurar plano
                mesh.setExtremes(min, max);
                mesh.updateValues();
            }
            //Solto el clic del mouse, generar plano definitivo
            else if (input.buttonUp(TgcD3dInput.MouseButtons.BUTTON_LEFT))
            {
                //Tiene el tamaño minimo tolerado
                var size = mesh.BoundingBox.calculateSize();
                if (size.Y > 1 && size.Z > 1)
                {
                    //Guardar size original del plano para hacer Scaling
                    originalSize = mesh.Size;

                    //Dejar cargado para que se pueda crear un nuevo plano
                    Control.CurrentState      = MeshCreatorModifier.State.CreatePrimitiveSelected;
                    Control.CreatingPrimitive = new PlaneYZPrimitive(Control);

                    //Agregar plano a la lista de modelos
                    Control.AddMesh(this);

                    //Seleccionar plano
                    Control.SelectionRectangle.clearSelection();
                    Control.SelectionRectangle.selectObject(this);
                    Control.UpdateModifyPanel();
                }
                //Sino, descartar
                else
                {
                    Control.CurrentState = MeshCreatorModifier.State.CreatePrimitiveSelected;
                    mesh.Dispose();
                    mesh = null;
                }
            }
        }
Exemplo n.º 6
0
        public override void Init(BulletExampleWall ctx)
        {
            base.Init(ctx);

            //Creamos shapes y bodies.

            //El piso es un plano estatico se dice que si tiene masa 0 es estatico.
            var floorShape       = new StaticPlaneShape(TGCVector3.Up.ToBulletVector3(), 0);
            var floorMotionState = new DefaultMotionState();
            var floorInfo        = new RigidBodyConstructionInfo(0, floorMotionState, floorShape);

            floorBody = new RigidBody(floorInfo);
            dynamicsWorld.AddRigidBody(floorBody);

            //Se crea una caja de tamaño 20 con rotaciones y origien en 10,100,10 y 1kg de masa.
            var boxShape     = new BoxShape(10, 10, 10);
            var boxTransform = TGCMatrix.RotationYawPitchRoll(MathUtil.SIMD_HALF_PI, MathUtil.SIMD_QUARTER_PI, MathUtil.SIMD_2_PI).ToBsMatrix;

            boxTransform.Origin = new TGCVector3(10, 100, 10).ToBulletVector3();
            DefaultMotionState boxMotionState = new DefaultMotionState(boxTransform);
            //Es importante calcular la inercia caso contrario el objeto no rotara.
            var boxLocalInertia = boxShape.CalculateLocalInertia(1f);
            var boxInfo         = new RigidBodyConstructionInfo(1f, boxMotionState, boxShape, boxLocalInertia);

            boxBody = new RigidBody(boxInfo);
            dynamicsWorld.AddRigidBody(boxBody);

            //Crea una bola de radio 10 origen 50 de 1 kg.
            var ballShape     = new SphereShape(10);
            var ballTransform = TGCMatrix.Identity;

            ballTransform.Origin = new TGCVector3(0, 50, 0);
            var ballMotionState = new DefaultMotionState(ballTransform.ToBsMatrix);
            //Podriamos no calcular la inercia para que no rote, pero es correcto que rote tambien.
            var ballLocalInertia = ballShape.CalculateLocalInertia(1f);
            var ballInfo         = new RigidBodyConstructionInfo(1, ballMotionState, ballShape, ballLocalInertia);

            ballBody = new RigidBody(ballInfo);
            dynamicsWorld.AddRigidBody(ballBody);

            //Cargamos objetos de render del framework.
            var floorTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"Texturas\granito.jpg");

            floorMesh = new TgcPlane(new TGCVector3(-200, 0, -200), new TGCVector3(400, 0f, 400), TgcPlane.Orientations.XZplane, floorTexture);

            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"Texturas\madera.jpg");

            //Es importante crear todos los mesh con centro en el 0,0,0 y que este coincida con el centro de masa definido caso contrario rotaria de otra forma diferente a la dada por el motor de fisica.
            boxMesh = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture);
            //Se crea una esfera de tamaño 1 para escalarla luego (en render)
            sphereMesh = new TGCSphere(1, texture.Clone(), TGCVector3.Empty);
            //Tgc no crea el vertex buffer hasta invocar a update values.
            sphereMesh.updateValues();
        }
Exemplo n.º 7
0
        public void Init()
        {
            LoadShip();
            TransformMesh(OutdoorMesh, Constants.PositionOutdoorShip, Constants.Scale, Constants.Rotation);
            TransformMesh(IndoorMesh, Constants.PositionIndoorShip, Constants.Scale, Constants.Rotation);
            BodyOutdoorShip = TransformRigidBody(OutdoorMesh, Constants.PositionOutdoorShip, Constants.Scale, Constants.Rotation);
            BodyIndoorShip  = TransformRigidBody(IndoorMesh, Constants.PositionIndoorShip, Constants.Scale, Constants.Rotation);
            var texture = TgcTexture.createTexture(MediaDir + @"Textures\fondo_plano.png");

            Plane = new TgcPlane(origin: Constants.PositionIndoorShip + Constants.HACHT_POSITION, size: new TGCVector3(200, 0, 200), TgcPlane.Orientations.XZplane, texture: texture);;
        }
Exemplo n.º 8
0
        private void LoadShipHelmPoster()
        {
            var posterTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "\\Bitmaps\\" + "shipHelmPoster.png");

            var posterPosition = new TGCVector3(5984, 4200, 6836);
            var posterSize     = new TGCVector3(120, 70, 120);

            shipHelmPoster = new TgcPlane(posterPosition, posterSize, TgcPlane.Orientations.YZplane, posterTexture);

            collectModel.ShipHelmPosterPosition = new TGCVector3(6114, 4060, 6887);
        }
Exemplo n.º 9
0
        public void RenderObject(TgcPlane x)
        {
            var t = x.Technique;

            if (useShadows)
            {
                x.Effect    = shadowEffect;
                x.Technique = doingShadowRender ? "RenderShadow" : "RenderScene";
            }
            x.Render();
            x.Technique = t;
        }
Exemplo n.º 10
0
        private void InitializeFloor()
        {
            var floor     = TgcTexture.createTexture(MediaDir + "Texturas\\tierra.jpg");
            var planeSize = new TGCVector3(200f, 0f, 200f);
            var planeMesh = new TgcPlane(TGCVector3.Scale(planeSize, -0.5f), planeSize, TgcPlane.Orientations.XZplane, floor, 5f, 5f);

            planeMesh.updateValues();

            plane           = planeMesh.toMesh("floor");
            plane.Transform = TGCMatrix.RotationX(FastMath.PI) * plane.Transform;
            plane.Effect    = effect;
            plane.Technique = "Blinn";
        }
Exemplo n.º 11
0
        private void LoadFatherNote()
        {
            var noteTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "\\Level1\\Textures\\" + "noteTexture.png");

            var notePosition = new TGCVector3(9820, 30, 880);
            var noteSize     = new TGCVector3(20, 40, 20);

            TgcPlane note = new TgcPlane(notePosition, noteSize, TgcPlane.Orientations.XYplane, noteTexture);

            collectModel.CollisionMeshes.Add(new ItemModel {
                Mesh = note.toMesh("fatherNote"), IsCollectable = true, CollectablePosition = notePosition
            });
        }
Exemplo n.º 12
0
        /// <summary>
        /// Construir plano
        /// </summary>
        public override void doCreation()
        {
            var input = Control.creator.Input;

            //Si hacen clic con el mouse, ver si hay colision con el suelo
            if (input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT))
            {
                //Determinar el size en XZ del box
                var collisionPoint = Control.Grid.getPicking();

                //Obtener extremos del rectángulo de selección
                var min = TGCVector3.Minimize(initSelectionPoint, collisionPoint);
                var max = TGCVector3.Maximize(initSelectionPoint, collisionPoint);
                min.Y = 0;
                max.Y = 1;

                //Configurar plano
                mesh.setExtremes(min, max);
                mesh.updateValues();
            }
            //Solto el clic del mouse, generar plano definitivo
            else if (input.buttonUp(TgcD3dInput.MouseButtons.BUTTON_LEFT))
            {
                //Tiene el tamaño minimo tolerado
                var size = mesh.BoundingBox.calculateSize();
                if (size.X > 1 && size.Z > 1)
                {
                    //Guardar size original del plano para hacer Scaling
                    originalSize = mesh.Size;

                    //Dejar cargado para que se pueda crear un nuevo plano
                    Control.CurrentState      = MeshCreatorModifier.State.CreatePrimitiveSelected;
                    Control.CreatingPrimitive = new TGCPlaneXZPrimitive(Control);

                    //Agregar plano a la lista de modelos
                    Control.AddMesh(this);

                    //Seleccionar plano
                    Control.SelectionRectangle.clearSelection();
                    Control.SelectionRectangle.selectObject(this);
                    Control.UpdateModifyPanel();
                }
                //Sino, descartar
                else
                {
                    Control.CurrentState = MeshCreatorModifier.State.CreatePrimitiveSelected;
                    mesh.Dispose();
                    mesh = null;
                }
            }
        }
Exemplo n.º 13
0
        public override void Init(BulletExampleWall ctx)
        {
            base.Init(ctx);

            //Creamos shapes y bodies.

            //El piso es un plano estatico se dice que si tiene masa 0 es estatico.
            var floorShape       = new StaticPlaneShape(TGCVector3.Up.ToBsVector, 0);
            var floorMotionState = new DefaultMotionState();
            var floorInfo        = new RigidBodyConstructionInfo(0, floorMotionState, floorShape);

            floorBody                 = new RigidBody(floorInfo);
            floorBody.Friction        = 1;
            floorBody.RollingFriction = 1;
            // ballBody.SetDamping(0.1f, 0.9f);
            floorBody.Restitution = 1f;
            floorBody.UserObject  = "floorBody";
            dynamicsWorld.AddRigidBody(floorBody);

            for (var i = -10; i < 10; i++)
            {
                for (var j = 0; j < 10; j++)
                {
                    var boxBody = BulletRigidBodyConstructor.CreateBox(new TGCVector3(10, 10, 10), 1, new TGCVector3(i * 20f + 5f, j * 20f + 5f, 0f), 0, 0, 0, 0.5f);
                    boxBodys.Add(boxBody);
                    dynamicsWorld.AddRigidBody(boxBody);
                }
            }

            //Cargamos objetos de render del framework.
            var floorTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"Texturas\granito.jpg");

            floorMesh = new TgcPlane(new TGCVector3(-2000, 0, -2000), new TGCVector3(4000, 0f, 4000), TgcPlane.Orientations.XZplane, floorTexture);

            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box1.jpg");

            //Es importante crear todos los mesh con centro en el 0,0,0 y que este coincida con el centro de masa definido caso contrario rotaria de otra forma diferente a la dada por el motor de fisica.
            boxMesh1 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture);
            texture  = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box4.jpg");
            boxMesh2 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture);
            texture  = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box3.jpg");
            boxMesh3 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture);
            texture  = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\MeshCreator\Scenes\Deposito\Textures\box4.jpg");
            boxMesh4 = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture);

            texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx.MediaDir + @"\Texturas\pokeball.jpg");
            //Se crea una esfera de tamaño 1 para escalarla luego (en render)
            sphereMesh = new TGCSphere(1, texture, TGCVector3.Empty);
            //Tgc no crea el vertex buffer hasta invocar a update values.
            sphereMesh.updateValues();
        }
Exemplo n.º 14
0
 public Plane(TGCVector3 minPoint, TGCVector3 maxPoint, TGCVector3 orientation, string fileName, float UCoordinate, float VCoordinate)
 {
     orientation.Normalize();
     this.plane = new TgcPlane(new TGCVector3(0, 0, 0), new TGCVector3(0, 0, 0), this.GetPlaneOrientation(orientation), TgcTexture.createTexture(GlobalConcepts.GetInstance().GetMediaDir() + "MeshCreator\\Meshes\\" + fileName), UCoordinate, VCoordinate);
     this.plane.setExtremes(minPoint, maxPoint);
     this.plane.updateValues();
     this.mesh          = this.plane.toMesh("plane");
     mesh.AutoTransform = false;
     //negrada atomica
     InvertNormals(orientation);
     this.realPlane = TGCPlane.FromPointNormal(minPoint, orientation);
     mesh.Effect    = TgcShaders.Instance.TgcMeshPointLightShader;
     mesh.Technique = "DIFFUSE_MAP";
 }
Exemplo n.º 15
0
        /// <summary>
        /// Iniciar la creacion
        /// </summary>
        public override void initCreation(TGCVector3 gridPoint)
        {
            initSelectionPoint = gridPoint;
            creatingInitMouseY = Control.creator.Input.Ypos;

            //Crear plano inicial
            var TGCPlaneTexture = TgcTexture.createTexture(Control.CreationTexturePath());

            mesh = new TgcPlane(initSelectionPoint, TGCVector3.Empty, TgcPlane.Orientations.XYplane, TGCPlaneTexture);
            mesh.AutoAdjustUv = false;
            mesh.UTile        = 1;
            mesh.VTile        = 1;
            mesh.BoundingBox.setRenderColor(MeshCreatorUtils.UNSELECTED_OBJECT_COLOR);
            Layer = Control.CurrentLayer;
        }
        public override void Init(GameModel _env)
        {
            Env = _env;
            string compilationErrors;

            var d3dDevice = D3DDevice.Instance.Device;

            EfectoRender3D = Effect.FromFile(d3dDevice, Env.ShadersDir + "render3D.fx",
                                             null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (EfectoRender3D == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            EfectoRender2D = Effect.FromFile(d3dDevice, Env.ShadersDir + "render2D.fx",
                                             null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (EfectoRender2D == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            EfectoRender2D.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            EfectoRender2D.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);
            try
            {
                texturaVida = TextureLoader.FromFile(d3dDevice, Env.MediaDir + "\\Menu\\heart.png");
            }
            catch
            {
                throw new Exception(string.Format("Error at loading texture: {0}", Env.MediaDir + "\\Menu\\heart.png"));
            }
            Reset();



            // Cargar escena
            Loader = new TgcSceneLoader();
            Scene  = Loader.loadSceneFromFile(Env.MediaDir + "\\" + "Escenario1\\escenarioSubterraneo-TgcScene.xml");


            // Setear cancion
            cancionPcpal.FileName = Env.MediaDir + "\\Sound\\crash.mp3";

            //piso
            var PisoSelvaTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "pasto.jpg");

            PisoSelva = new TgcPlane(new TGCVector3(-200f, 0f, -100f), new TGCVector3(50, 5f, 200), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
        }
Exemplo n.º 17
0
        /// <summary>
        ///     Crear paredes 3D para las diferencias de altura entre la pared South de este Room y el resto
        ///     de los Rooms contra los que colisiona
        /// </summary>
        private void createSouthWallSegmentsForHeightDiff(TGCVector3 sceneScale, List <Point> intersectingLines,
                                                          List <RoomsEditorRoom> intersectingRooms, RoomsEditorWall wall)
        {
            var bounds   = RoomPanel.Label.Bounds;
            var wallSide = new Point(RoomPanel.Label.Location.X, RoomPanel.Label.Location.X + RoomPanel.Label.Width);

            Point[] supDiffSegments;
            Point[] infDiffSegments;
            findSegmentsForHeightDiff(intersectingRooms, out supDiffSegments, out infDiffSegments);
            for (var i = 0; i < intersectingRooms.Count; i++)
            {
                var fullIntersecLine = intersectingLines[i];
                var intersecLine     = intersectLineSegments(fullIntersecLine, wallSide);

                //Fragmento superior
                var supSeg = supDiffSegments[i];
                if (supSeg.X != 0 || supSeg.Y != 0)
                {
                    var wall3d = new TgcPlane(
                        new TGCVector3(intersecLine.X * sceneScale.X, supSeg.X * sceneScale.Y,
                                       (bounds.Y + bounds.Height) * sceneScale.Z),
                        new TGCVector3((intersecLine.Y - intersecLine.X) * sceneScale.X, (supSeg.Y - supSeg.X) * sceneScale.Y,
                                       0),
                        TgcPlane.Orientations.XYplane,
                        wall.Texture, wall.UTile, wall.VTile
                        );
                    wall.WallSegments.Add(wall3d);
                }

                //Fragmento inferior
                var infSeg = infDiffSegments[i];
                if (infSeg.X != 0 || infSeg.Y != 0)
                {
                    var wall3d = new TgcPlane(
                        new TGCVector3(intersecLine.X * sceneScale.X, infSeg.X * sceneScale.Y,
                                       (bounds.Y + bounds.Height) * sceneScale.Z),
                        new TGCVector3((intersecLine.Y - intersecLine.X) * sceneScale.X, (infSeg.Y - infSeg.X) * sceneScale.Y,
                                       0),
                        TgcPlane.Orientations.XYplane,
                        wall.Texture, wall.UTile, wall.VTile
                        );
                    wall.WallSegments.Add(wall3d);
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        ///     Crea el mapa
        /// </summary>
        private void CreateMap()
        {
            //las cantidades base se pensaron para un escenario de 2000, por lo que divido la longitud actual por eso y multiplico los valores base
            int multiplier = MapLength / 2000;

            //armo el piso con un plano
            var floorTexture = TgcTexture.createTexture(Device, MediaDir + "Textures\\tierra.jpg");

            Floor = new TgcPlane(new Vector3(-(MapLength / 2), 0, -(MapLength / 2)), new Vector3(MapLength, 0, MapLength), TgcPlane.Orientations.XZplane, floorTexture, 70f * multiplier, 70f * multiplier);

            //creo los árboles
            CreateTrees(500 * multiplier);
            //creo rocas
            CreateRocks(200 * multiplier);
            //creo pasto
            CreateGrass(1000 * multiplier);
            //creo otros objetos
            CreateObjects(20 * multiplier);
        }
Exemplo n.º 19
0
        public override void Init()
        {
            //Crear suelo
            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                   MediaDir + "Texturas\\Quake\\quakeWall3.jpg");

            suelo = new TgcPlane(new Vector3(-500, 0, -500), new Vector3(1000, 0f, 1000), TgcPlane.Orientations.XZplane, texture);

            //Iniciarlizar PickingRay
            pickingRay = new TgcPickingRay(Input);

            //Cargar modelos que se pueden seleccionar
            modelos = new List <TgcMesh>();
            modelosSeleccionados = new List <TgcMesh>();

            //Modelo 1, original
            var loader = new TgcSceneLoader();
            var scene  =
                loader.loadSceneFromFile(MediaDir +
                                         "MeshCreator\\Meshes\\Vehiculos\\Carretilla\\Carretilla-TgcScene.xml");
            var modeloOrignal = scene.Meshes[0];

            modelos.Add(modeloOrignal);

            //Modelos instancias del original
            modelos.Add(modeloOrignal.createMeshInstance("Carretilla2", new Vector3(100, 0, 0), Vector3.Empty,
                                                         new Vector3(1, 1, 1)));
            modelos.Add(modeloOrignal.createMeshInstance("Carretilla3", new Vector3(50, 0, -70), Vector3.Empty,
                                                         new Vector3(1, 1, 1)));
            modelos.Add(modeloOrignal.createMeshInstance("Carretilla4", new Vector3(-100, 0, -30), Vector3.Empty,
                                                         new Vector3(1, 1, 1)));
            modelos.Add(modeloOrignal.createMeshInstance("Carretilla5", new Vector3(-70, 0, -80), Vector3.Empty,
                                                         new Vector3(1, 1, 1)));

            //Crear caja para marcar en que lugar hubo colision
            selectionBox = TgcBox.fromSize(new Vector3(3, SELECTION_BOX_HEIGHT, 3), Color.Red);
            selectionBox.BoundingBox.setRenderColor(Color.Red);
            selecting = false;

            Camara.SetCamera(new Vector3(250f, 250f, 250f), new Vector3(0f, 0f, 0f));
        }
Exemplo n.º 20
0
        public override void Init()
        {
            //Cargar suelo
            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\granito.jpg");

            suelo = new TgcPlane(new TGCVector3(-5000, 0, -5000), new TGCVector3(10000, 0f, 10000), TgcPlane.Orientations.XZplane, texture);

            //Iniciarlizar PickingRay
            pickingRay = new TgcPickingRay(Input);

            //Cargar nave
            var loader = new TgcSceneLoader();
            var scene  =
                loader.loadSceneFromFile(MediaDir +
                                         "MeshCreator\\Meshes\\Vehiculos\\NaveEspacial\\NaveEspacial-TgcScene.xml");

            mesh = scene.Meshes[0];

            //Rotación original de la malla, hacia -Z
            originalMeshRot = new TGCVector3(0, 0, -1);

            //Manipulamos los movimientos del mesh a mano
            mesh.AutoTransform = false;
            meshRotationMatrix = TGCMatrix.Identity;

            newPosition   = mesh.Position;
            applyMovement = false;

            //Crear caja para marcar en que lugar hubo colision
            collisionPointMesh = TGCBox.fromSize(new TGCVector3(3, 100, 3), Color.Red);

            //Flecha para marcar la dirección
            directionArrow           = new TgcArrow();
            directionArrow.Thickness = 5;
            directionArrow.HeadSize  = new TGCVector2(10, 10);

            //Camara en tercera persona
            camaraInterna = new TgcThirdPersonCamera(mesh.Position, 800, 1500);
            Camara        = camaraInterna;
            speedModifier = AddFloat("speed", 1000, 5000, 2500);
        }
Exemplo n.º 21
0
        public override void Init(BulletExampleBasic ctx)
        {
            base.Init(ctx);

            //Creamos shapes y bodies.

            //El piso es un plano estatico se dice que si tiene masa 0 es estatico.
            var floorShape       = new StaticPlaneShape(TGCVector3.Up.ToBulletVector3(), 0);
            var floorMotionState = new DefaultMotionState();
            var floorInfo        = new RigidBodyConstructionInfo(0, floorMotionState, floorShape);

            floorBody = new RigidBody(floorInfo);
            dynamicsWorld.AddRigidBody(floorBody);

            var boxBody = BulletRigidBodyFactory.Instance.CreateBox(new TGCVector3(10, 10, 10), 1f, new TGCVector3(10f, 100f, 10f), MathUtil.SIMD_HALF_PI, MathUtil.SIMD_QUARTER_PI, MathUtil.SIMD_2_PI, 0, true);

            boxBodys.Add(boxBody);
            dynamicsWorld.AddRigidBody(boxBody);

            var ballBody = BulletRigidBodyFactory.Instance.CreateBall(10f, 1f, new TGCVector3(0f, 50f, 0f));

            ballBodys.Add(ballBody);
            dynamicsWorld.AddRigidBody(ballBody);

            //Cargamos objetos de render del framework.
            var floorTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx2.MediaDir + @"Texturas\granito.jpg");

            floorMesh = new TgcPlane(new TGCVector3(-2000, 0, -2000), new TGCVector3(4000, 0f, 4000), TgcPlane.Orientations.XZplane, floorTexture);

            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx2.MediaDir + @"MeshCreator\Scenes\Deposito\Textures\boxMetal.jpg");

            //Es importante crear todos los mesh con centro en el 0,0,0 y que este coincida con el centro de masa definido caso contrario rotaria de otra forma diferente a la dada por el motor de fisica.
            boxMesh = TGCBox.fromSize(new TGCVector3(20, 20, 20), texture);

            texture = TgcTexture.createTexture(D3DDevice.Instance.Device, Ctx2.MediaDir + @"Texturas\pokeball.jpg");
            //Se crea una esfera de tamaño 1 para escalarla luego (en render)
            sphereMesh = new TGCSphere(1, texture, TGCVector3.Empty);
            //Tgc no crea el vertex buffer hasta invocar a update values.
            sphereMesh.updateValues();
        }
        public override void Init()
        {
            //Crear suelo
            var pisoTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\pasto.jpg");

            suelo = new TgcPlane(new TGCVector3(-500, 0, -500), new TGCVector3(2000, 0, 2000), TgcPlane.Orientations.XZplane, pisoTexture, 10f, 10f);

            //Cargar modelo de palmera original
            var loader = new TgcSceneLoader();
            var scene  =
                loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vegetacion\\Palmera\\Palmera-TgcScene.xml");

            palmeraOriginal = scene.Meshes[0];

            //Crear varias instancias del modelo original, pero sin volver a cargar el modelo entero cada vez
            var   rows   = 5;
            var   cols   = 6;
            float offset = 250;

            meshes = new List <TgcMesh>();
            for (var i = 0; i < rows; i++)
            {
                for (var j = 0; j < cols; j++)
                {
                    //Crear instancia de modelo
                    var instance = palmeraOriginal.createMeshInstance(palmeraOriginal.Name + i + "_" + j);
                    //No recomendamos utilizar AutoTransform, en juegos complejos se pierde el control. mejor utilizar Transformaciones con matrices.
                    instance.AutoTransform = true;
                    //Desplazarlo
                    instance.Move(i * offset, 0, j * offset);
                    //instance.Scale = new TGCVector3(0.25f, 0.25f, 0.25f);

                    meshes.Add(instance);
                }
            }

            //Camara en primera persona
            Camara = new TgcFpsCamera(new TGCVector3(900f, 400f, 900f), Input);
        }
Exemplo n.º 23
0
        public override void Init()
        {
            //Crear piso
            var pisoTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\tierra.jpg");

            piso = new TgcPlane(TGCVector3.Empty, new TGCVector3(2000, 0, 2000), TgcPlane.Orientations.XZplane, pisoTexture, 50f, 50f);
            //Cargar obstaculos y posicionarlos. Los obstáculos se crean con TgcBox en lugar de cargar un modelo.
            obstaculos = new List <TGCBox>();
            TGCBox obstaculo;

            float wallSize   = 1000;
            float wallHeight = 500;

            //Obstaculo 1
            obstaculo = TGCBox.fromExtremes(TGCVector3.Empty, new TGCVector3(wallSize, wallHeight, 10),
                                            TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\baldosaFacultad.jpg"));
            obstaculo.Transform = TGCMatrix.Translation(obstaculo.Position);
            obstaculos.Add(obstaculo);

            //Obstaculo 2
            obstaculo = TGCBox.fromExtremes(TGCVector3.Empty, new TGCVector3(10, wallHeight, wallSize),
                                            TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\madera.jpg"));
            obstaculo.Transform = TGCMatrix.Translation(obstaculo.Position);
            obstaculos.Add(obstaculo);

            //Obstaculo 3
            obstaculo = TGCBox.fromExtremes(new TGCVector3(0, 0, wallSize),
                                            new TGCVector3(wallSize, wallHeight, wallSize + 10),
                                            TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\granito.jpg"));
            obstaculo.Transform = TGCMatrix.Translation(obstaculo.Position);
            obstaculos.Add(obstaculo);

            //Obstaculo 4
            obstaculo = TGCBox.fromExtremes(new TGCVector3(wallSize, 0, 0),
                                            new TGCVector3(wallSize + 10, wallHeight, wallSize),
                                            TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\granito.jpg"));
            obstaculo.Transform = TGCMatrix.Translation(obstaculo.Position);
            obstaculos.Add(obstaculo);

            //Obstaculo 5
            obstaculo = TGCBox.fromExtremes(new TGCVector3(wallSize / 2, 0, wallSize - 400),
                                            new TGCVector3(wallSize + 10, wallHeight, wallSize - 400 + 10),
                                            TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\granito.jpg"));
            obstaculo.Transform = TGCMatrix.Translation(obstaculo.Position);
            obstaculos.Add(obstaculo);

            //Cargar personaje con animaciones
            var skeletalLoader = new TgcSkeletalLoader();

            personaje = skeletalLoader.loadMeshAndAnimationsFromFile(
                MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml",
                MediaDir + "SkeletalAnimations\\Robot\\",
                new[]
            {
                MediaDir + "SkeletalAnimations\\Robot\\Caminando-TgcSkeletalAnim.xml",
                MediaDir + "SkeletalAnimations\\Robot\\Parado-TgcSkeletalAnim.xml"
            });

            //Configurar animacion inicial
            personaje.playAnimation("Parado", true);
            //Escalarlo porque es muy grande
            personaje.Position = new TGCVector3(100, 0, 100);
            personaje.Scale    = new TGCVector3(0.75f, 0.75f, 0.75f);
            //Rotarlo 180° porque esta mirando para el otro lado
            personaje.RotateY(Geometry.DegreeToRadian(180f));

            //Configurar camara en Tercera Persona y la asigno al TGC.
            camaraInterna = new TgcThirdPersonCamera(personaje.Position, 200, -300);
            Camara        = camaraInterna;

            //Modifiers para modificar propiedades de la camara
            offsetHeightModifier  = AddFloat("offsetHeight", 0, 300, 100);
            offsetForwardModifier = AddFloat("offsetForward", -400, 0, -220);
            displacementModifier  = AddVertex2f("displacement", TGCVector2.Zero, new TGCVector2(100, 200), new TGCVector2(0, 100));
        }
        public override void Init()
        {
            //Crear piso
            var pisoTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\tierra.jpg");

            piso = new TgcPlane(new TGCVector3(-500, -60, -500), new TGCVector3(1000, 0, 1000), TgcPlane.Orientations.XZplane, pisoTexture);

            //Cargar obstaculos y posicionarlos. Los obstáculos se crean con TgcBox en lugar de cargar un modelo.
            obstaculos = new List <TGCBox>();
            TGCBox obstaculo;

            //Obstaculo 1
            obstaculo = TGCBox.fromSize(new TGCVector3(-100, 0, 0), new TGCVector3(80, 150, 80), TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\baldosaFacultad.jpg"));
            //No es recomendado utilizar autotransform en casos mas complicados, se pierde el control.
            obstaculo.AutoTransform = true;
            obstaculos.Add(obstaculo);

            //Obstaculo 2
            obstaculo = TGCBox.fromSize(new TGCVector3(50, 0, 200), new TGCVector3(80, 300, 80), TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\madera.jpg"));
            //No es recomendado utilizar autotransform en casos mas complicados, se pierde el control.
            obstaculo.AutoTransform = true;
            obstaculos.Add(obstaculo);

            //Obstaculo 3
            obstaculo = TGCBox.fromSize(new TGCVector3(300, 0, 100), new TGCVector3(80, 100, 150), TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\granito.jpg"));
            //No es recomendado utilizar autotransform en casos mas complicados, se pierde el control.
            obstaculo.AutoTransform = true;
            obstaculos.Add(obstaculo);

            //Cargar personaje con animaciones
            var skeletalLoader = new TgcSkeletalLoader();

            personaje =
                skeletalLoader.loadMeshAndAnimationsFromFile(
                    MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml",
                    MediaDir + "SkeletalAnimations\\Robot\\",
                    new[]
            {
                MediaDir + "SkeletalAnimations\\Robot\\Caminando-TgcSkeletalAnim.xml",
                MediaDir + "SkeletalAnimations\\Robot\\Parado-TgcSkeletalAnim.xml"
            });

            //Le cambiamos la textura para diferenciarlo un poco
            personaje.changeDiffuseMaps(new[]
            {
                TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SkeletalAnimations\\Robot\\Textures\\uvwGreen.jpg")
            });

            //Configurar animacion inicial
            personaje.playAnimation("Parado", true);
            //No es recomendado utilizar autotransform en casos mas complicados, se pierde el control.
            personaje.AutoTransform = true;

            //Escalarlo porque es muy grande
            personaje.Position = new TGCVector3(0, -45, 0);
            personaje.Scale    = new TGCVector3(0.75f, 0.75f, 0.75f);
            //Rotarlo 180° porque esta mirando para el otro lado
            personaje.RotateY(Geometry.DegreeToRadian(180f));

            //Configurar camara en Tercer Persona
            camaraInterna = new TgcThirdPersonCamera(personaje.Position, 200, -300);
            Camara        = camaraInterna;

            //Modifier para ver BoundingBox
            showBoundingBoxModifier = AddBoolean("showBoundingBox", "Bouding Box", false);
            activateSlidingModifier = AddBoolean("activateSliding", "Activate Sliding", false);

            //Modifiers para desplazamiento del personaje
            velocidadCaminarModifier  = AddFloat("VelocidadCaminar", 1f, 400f, 250f);
            velocidadRotacionModifier = AddFloat("VelocidadRotacion", 1f, 360f, 120f);
        }
Exemplo n.º 25
0
        public override void Init(GameModel _env)
        {
            //useShadows = false;
            Env = _env;
            string compilationErrors;
            var    d3dDevice = D3DDevice.Instance.Device;

            shadowEffect         = TgcShaders.loadEffect(Env.ShadersDir + "ShadowMap.fx");
            skeletalShadowEffect = TgcShaders.loadEffect(Env.ShadersDir + "TgcSkeletalShadowMapMeshShader.fx");

            shaderArbustos = TgcShaders.loadEffect(Env.ShadersDir + "movimientoArbustos.fx");

            shaderLiquidos = TgcShaders.loadEffect(Env.ShadersDir + "movimientoLiquidos.fx");

            shaderAceites = TgcShaders.loadEffect(Env.ShadersDir + "movimientoLiquidos.fx");

            time = 0;

            var dir = new TGCVector3(0, -1, 0);

            dir.Normalize();
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(0, 80, 100), dir));
            dir = new TGCVector3(1, -2, 0);
            dir.Normalize();
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(220, 80, 390), dir));
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(1370, 80, 57), new TGCVector3(0, -1, 0)));
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(842, 80, -327), new TGCVector3(0, -1, 0)));
            Lights.Add(new Tuple <float, TGCVector3, TGCVector3>(0.05f, new TGCVector3(1050, 80, -110), new TGCVector3(0, -1, 0)));
            g_LightPos     = new TGCVector3(140, 40, 390);
            EfectoRender2D = Effect.FromFile(d3dDevice, Env.ShadersDir + "render2D.fx",
                                             null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (EfectoRender2D == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            EfectoRender2D.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            EfectoRender2D.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);
            try
            {
                texturaVida = TextureLoader.FromFile(d3dDevice, Env.MediaDir + "\\Menu\\heart.png");
                texturaLogo = TextureLoader.FromFile(d3dDevice, Env.MediaDir + "\\Menu\\LogoTGC.png");
            }
            catch
            {
                throw new Exception(string.Format("Error at loading texture: {0}", Env.MediaDir + "\\Menu\\heart.png"));
            }

            TextoLogo.Align = TgcText2D.TextAlign.LEFT;
            TextoLogo.changeFont(new System.Drawing.Font("Comic Sans MS", 24, FontStyle.Bold));
            TextoLogo.Position = new Point(D3DDevice.Instance.Width - 70, D3DDevice.Instance.Height - 65);
            TextoLogo.Color    = Color.White;


            var PisoSelvaTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "pasto.jpg");

            PisoSelva1 = new TgcPlane(new TGCVector3(-81f, 0f, -74f), new TGCVector3(168f, 5f, 161f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva1);
            PisoSelva2 = new TgcPlane(new TGCVector3(-81f, 0f, 150f), new TGCVector3(168f, 5f, 110f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva2);
            PisoSelva3 = new TgcPlane(new TGCVector3(-81f, 0f, 278f), new TGCVector3(302f, 5f, 247f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva3);
            PisoSelva4 = new TgcPlane(new TGCVector3(309f, 0f, 278f), new TGCVector3(111f, 5f, 247f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva4);
            PisoSelva5 = new TgcPlane(new TGCVector3(595f, 0f, 236f), new TGCVector3(387f, 5f, 350f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva5);
            PisoSelva6 = new TgcPlane(new TGCVector3(707f, 0f, -50f), new TGCVector3(259f, 5f, 77f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva6);
            PisoSelva7 = new TgcPlane(new TGCVector3(834f, 0f, 49f), new TGCVector3(132f, 5f, 48f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva7);
            PisoSelva8 = new TgcPlane(new TGCVector3(707f, 0f, 147.5f), new TGCVector3(130f, 5f, 38f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva8);
            PisoSelva9 = new TgcPlane(new TGCVector3(707f, -0.1f, 0f), new TGCVector3(81f, 5f, 148f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva9);
            PisoSelva10 = new TgcPlane(new TGCVector3(881f, -0.1f, -0.2f), new TGCVector3(79.5f, 5f, 50f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva10);
            PisoSelva11 = new TgcPlane(new TGCVector3(883f, -0.1f, 96f), new TGCVector3(83f, 5f, 145f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva11);
            PisoSelva12 = new TgcPlane(new TGCVector3(43.7f, -0.1f, 219f), new TGCVector3(552f, 5f, 133.5f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva12);
            PisoSelva13 = new TgcPlane(new TGCVector3(218f, -0.1f, 432f), new TGCVector3(379f, 5f, 148.5f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva13);
            PisoSelva14 = new TgcPlane(new TGCVector3(-81f, -0.1f, 86f), new TGCVector3(40f, 5f, 193f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva14);
            PisoSelva15 = new TgcPlane(new TGCVector3(41f, -0.1f, 82f), new TGCVector3(46f, 5f, 70f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva15);
            PisoSelva16 = new TgcPlane(new TGCVector3(705f, -0.1f, 185f), new TGCVector3(84f, 5f, 58f), TgcPlane.Orientations.XZplane, PisoSelvaTexture, 15, 15);
            ListaPlanos.Add(PisoSelva16);

            var PisoCastilloTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "rockfloor.jpg");

            PisoCastillo1 = new TgcPlane(new TGCVector3(791f, 21f, -155.4f), new TGCVector3(91f, 5f, 27.7f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo1);
            PisoCastillo2 = new TgcPlane(new TGCVector3(776f, 21f, -604f), new TGCVector3(218.2f, 5f, 331.3f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo2);
            PisoCastillo3 = new TgcPlane(new TGCVector3(1088.4f, 21f, -607.2f), new TGCVector3(158.8f, 5f, 118f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo3);
            PisoCastillo4 = new TgcPlane(new TGCVector3(1436.2f, 21f, -611.2f), new TGCVector3(270.4f, 5f, 331.4f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo4);
            PisoCastillo5 = new TgcPlane(new TGCVector3(1614.6f, 21f, -279.9f), new TGCVector3(87.65f, 5f, 97.9f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo5);
            PisoCastillo6 = new TgcPlane(new TGCVector3(1538.2f, 21f, -182.5f), new TGCVector3(169f, 5f, 58.6f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo6);
            PisoCastillo7 = new TgcPlane(new TGCVector3(1485f, 21f, -75.5f), new TGCVector3(228f, 5f, 192.2f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo7);
            PisoCastillo8 = new TgcPlane(new TGCVector3(1540f, 21f, -124.36f), new TGCVector3(58.35f, 5f, 49.16f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo8);
            PisoCastillo9 = new TgcPlane(new TGCVector3(986f, 21f, -108.7603f), new TGCVector3(134.15f, 5f, 223.6003f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo9);
            PisoCastillo10 = new TgcPlane(new TGCVector3(951f, 21f, -225f), new TGCVector3(130f, 5f, 116.2397f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo10);
            PisoCastillo11 = new TgcPlane(new TGCVector3(1080f, 21f, -185f), new TGCVector3(50f, 5f, 80f), TgcPlane.Orientations.XZplane, PisoCastilloTexture, 15, 15);
            ListaPlanos.Add(PisoCastillo11);
            var Acido = TgcTexture.createTexture(D3DDevice.Instance.Device, Env.MediaDir + "slime7.jpg");

            PisoAcido = new TgcPlane(new TGCVector3(1427f, -228.4502f, -1000f), new TGCVector3(400f, 5f, 450f), TgcPlane.Orientations.XZplane, Acido, 15, 15);
            ListaPlanoAcido.Add(PisoAcido);

            //Crear SkyBox
            CreateSkyBox(TGCVector3.Empty, new TGCVector3(10000, 10000, 10000), "SkyBox1");

            // Cargar escena
            Loader = new TgcSceneLoader();
            Scene  = Loader.loadSceneFromFile(Env.MediaDir + "\\" + "Escenario1\\escenarioConLogos-TgcScene.xml");

            Reset();
            ///////////agrego pisos subterraneos

            ListaPisosSubterraneos = Scene.Meshes.FindAll(m => m.Name.Contains("Floor"));

            foreach (var piso in ListaPisosSubterraneos)
            {
                Scene.Meshes.Remove(piso);
            }

            // Paredes
            ListaParedesCastillo = Scene.Meshes.FindAll(m => m.Name.Contains("ParedCastillo"));
            TgcMesh paredSinBB = Scene.Meshes.Find(m => m.Name.Contains("ParedCastillo441"));

            foreach (var m in ListaParedesCastillo)
            {
                m.AutoTransform = false;
                var p = (m.BoundingBox.PMax + m.BoundingBox.PMin) * 0.5f;
                var t = new TGCVector3(0, 20.8f, 0);
                m.Transform = TGCMatrix.Translation(-1 * p) * TGCMatrix.Translation(t + p);
                m.BoundingBox.scaleTranslate(new TGCVector3(0, 21, 0), new TGCVector3(1, 1, 1));
            }
            ListaParedesCastillo.Remove(paredSinBB); //elimino la pared que no necesita agrandar su BB
            foreach (var m in ListaParedesCastillo)
            {
                m.BoundingBox = new TgcBoundingAxisAlignBox(m.BoundingBox.PMin - new TGCVector3(5, 0, 5), m.BoundingBox.PMax + new TGCVector3(5, 0, 5));
            }
            // Paredes envolventes
            ListaParedesEnvolventes = Scene.Meshes.FindAll(m => m.Name.Contains("ParedEnvolvente") || m.Name.Contains("Room"));
            foreach (var m in ListaParedesEnvolventes)
            {
                m.BoundingBox = new TgcBoundingAxisAlignBox(m.BoundingBox.PMin - new TGCVector3(5, 0, 5), m.BoundingBox.PMax + new TGCVector3(5, 0, 5));
            }
            // Paredes de caida
            ListaParedesCaida = Scene.Meshes.FindAll(m => m.Name.Contains("Plane"));
            foreach (var m in ListaParedesCaida)
            {
                var agregado = new TGCVector3(3, -0.8f, 3);
                m.BoundingBox = new TgcBoundingAxisAlignBox(m.BoundingBox.PMin - agregado, m.BoundingBox.PMax + agregado);
            }

            // Pozos
            ListaPozos = Scene.Meshes.FindAll(m => m.Name.Contains("Pozo"));
            foreach (var mesh in ListaPozos)
            {
                Scene.Meshes.Remove(mesh);
            }

            // Logos
            ListaLogos = Scene.Meshes.FindAll(m => m.Name.Contains("LogoTGC"));
            CantLogos  = ListaLogos.Count;

            // Alargar algunas AABB
            var r = new Random();

            foreach (var mesh in Scene.Meshes.FindAll(m => m.Name.Contains("Arbusto")))
            {
                mesh.BoundingBox.scaleTranslate(new TGCVector3(0, 0, 0), new TGCVector3(1, 10, 1));
                mesh.AutoTransform = false;
                var ang   = r.Next(0, 360);
                var p     = (mesh.BoundingBox.PMax + mesh.BoundingBox.PMin) * 0.5f;
                var s     = new TGCVector3(((float)r.Next(90, 110)) / 100f, 1, ((float)r.Next(90, 110)) / 100f);
                var rango = 6;
                var t     = new TGCVector3(((float)r.Next(-rango * 100, rango * 100)) / 100f, 0, ((float)r.Next(-rango * 100, rango * 100)) / 100f);
                mesh.Transform = TGCMatrix.Translation(-1 * p) * TGCMatrix.Scaling(s) * TGCMatrix.RotationY(ang) * TGCMatrix.Translation(t + p);
            }
            foreach (var mesh in Scene.Meshes.FindAll(m => m.Name.Contains("Flores")))
            {
                mesh.BoundingBox.scaleTranslate(new TGCVector3(0, 0, 0), new TGCVector3(1, 10, 1));
            }
            ListaPisosResbalosos = Scene.Meshes.FindAll(m => m.Name.Contains("PisoResbaloso"));
            ListaMeshesSinColision.Add(Scene.Meshes.Find(m => m.Name.Contains("ParedEnvolvente001233")));
            ListaMeshesSinColision.Add(Scene.Meshes.Find(m => m.Name.Contains("ParedEnvolvente001248")));

            // Cajas Empujables

            /*TgcMesh MeshEmpujable = Scene.Meshes.Find(m => m.Name.Contains("Caja3"));
             * Scene.Meshes.Remove(Scene.Meshes.Find(m => m.Name.Contains("Caja3")));
             * TGCVector3 PosicionMeshEmpujable = MeshEmpujable.Position;
             * CajaEmpujable CajaEmpujable = new CajaEmpujable(MeshEmpujable, new TGCVector3(0f, 0f, 0f));
             * ListaCajasEmpujables.Add(CajaEmpujable);*/
            foreach (var mesh in Scene.Meshes.FindAll(m => m.Name.Contains("Caja3")))
            {
                Scene.Meshes.Remove(mesh);
                TGCVector3    PosicionMeshEmpujable = mesh.Position;
                CajaEmpujable CajaEmpujable         = new CajaEmpujable(mesh, new TGCVector3(0f, 0f, 0f));
                ListaCajasEmpujables.Add(CajaEmpujable);
            }

            // Setear cancion
            cancionPcpal.FileName = Env.MediaDir + "\\Sound\\crash.mp3";

            // Setear plataformas
            Plataformas = new List <Plataforma>();
            List <TgcMesh> ListaPlataformaEstatica = new List <TgcMesh>();
            List <TgcMesh> ListaPlataformaX        = new List <TgcMesh>();
            // TgcMesh PlataformaY;
            List <TgcMesh> ListaPlataformaZ = new List <TgcMesh>();
            List <TgcMesh> ListaMovibles    = new List <TgcMesh>();
            List <TgcMesh> Escalones        = new List <TgcMesh>();

            ListaPlataformaEstatica = Scene.Meshes.FindAll(m => m.Name.Contains("Box_0"));
            ListaPlataformaX        = Scene.Meshes.FindAll(m => m.Name.Contains("Box_1"));
            ListaPlataformaZ        = Scene.Meshes.FindAll(m => m.Name.Contains("Box_2"));
            PlataformaY             = Scene.Meshes.Find(Mesh => Mesh.Name.Contains("SubeBaja"));
            ListaMovibles           = Scene.Meshes.FindAll(m => m.Name.Contains("Box_M"));
            Escalones = Scene.Meshes.FindAll(m => m.Name.Contains("Escalon"));

            //agrego plataforma que se mueven en X
            foreach (var p in ListaPlataformaX)
            {
                Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, 0f), 25f, true, false, 12f, false));
            }

            //agrego plataforma que se mueven en Z
            foreach (var p in ListaPlataformaZ)
            {
                //-20f es para que este centrado en el camino
                if (p.Name == "Box_202" || p.Name == "Box_204")
                {
                    Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, -20f), 25f, false, false, 12f, true));
                }
                else
                {
                    Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, -20f), 25f, false, false, 12f, false));
                }
            }

            Plataformas.Add(new PlataformaLineal(PlataformaY, new TGCVector3(0f, -90f, 0f), 90f, false, true, 15f, true));

            //agrego objetos moviles
            foreach (var p in ListaMovibles)
            {
                Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, 0f), 0f, false, false, 0f, false));
            }

            //agrego objetos estaticos
            foreach (var p in ListaPlataformaEstatica)
            {
                Plataformas.Add(new PlataformaLineal(p, new TGCVector3(0f, 0f, 0f), 0f, false, false, 0f, false));
            }

            //se agregan plataformas giratorias
            var meshGiratorio = Plataformas[0].Mesh.clone("pGira");

            Plataformas.Add(new PlataformaGiratoria(15, meshGiratorio, new TGCVector3(260f, 0f, 275f), 5f));
            Scene.Meshes.Add(meshGiratorio);
            var meshGiratorio2 = ListaPlataformaZ[4].clone("pGira2");

            Plataformas.Add(new PlataformaGiratoria(28, meshGiratorio2, new TGCVector3(75f, 0f, -20f), 5f));
            Scene.Meshes.Add(meshGiratorio2);
            var meshGiratorio3 = ListaPlataformaZ[4].clone("pGira3");

            Plataformas.Add(new PlataformaGiratoria(28, meshGiratorio3, new TGCVector3(-135f, 0f, 575f), 5f));
            Scene.Meshes.Add(meshGiratorio3);

            foreach (var plataforma in Plataformas)
            {
                ListaPlataformas.Add(plataforma.Mesh);
                MeshConMovimiento.Add(plataforma.Mesh);
                Scene.Meshes.Remove(plataforma.Mesh);
            }
            //agrego escalones


            foreach (var escalon in Escalones)
            {
                ListaEscalones.Add(escalon);
            }

            Grilla.create(Scene.Meshes.FindAll(m => !m.Name.Contains("Box")), Scene.BoundingBox);
            Grilla.createDebugMeshes();
        }
Exemplo n.º 26
0
        public Tower(Vector3 newPosition, string wallTexture, string columnTexture)
        {
            this.position = newPosition;

            //Armamos muros a partir de un Plano y lo convertimos a Mesh
            var baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(40, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(wallTexture), 2, 4);

            var wallMesh = baseWall.toMesh("WallHA");

            wallMesh.Position = new TGCVector3(position.X + 5, position.Y, position.Z + 5);
            wallMesh.UpdateMeshTransform();

            towerWalls.Add(wallMesh);

            wallMesh          = baseWall.toMesh("WallHA");
            wallMesh.Position = new TGCVector3(position.X + 5, position.Y, position.Z + 45);
            wallMesh.UpdateMeshTransform();

            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 40), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(wallTexture), 2, 4);

            wallMesh          = baseWall.toMesh("WallHA");
            wallMesh.Position = new TGCVector3(position.X + 5, position.Y, position.Z + 5);
            wallMesh.UpdateMeshTransform();

            towerWalls.Add(wallMesh);

            wallMesh          = baseWall.toMesh("WallHA");
            wallMesh.Position = new TGCVector3(position.X + 45, position.Y, position.Z + 5);
            wallMesh.UpdateMeshTransform();

            towerWalls.Add(wallMesh);

            //Columnas
            //1
            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 5), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1V1");
            wallMesh.Position = new TGCVector3(position.X + 5, position.Y, position.Z);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 5), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1V1");
            wallMesh.Position = new TGCVector3(position.X, position.Y, position.Z);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(5, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1H1");
            wallMesh.Position = new TGCVector3(position.X, position.Y, position.Z + 5);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(5, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1H2");
            wallMesh.Position = new TGCVector3(position.X, position.Y, position.Z);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            //2
            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 5), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1V1");
            wallMesh.Position = new TGCVector3(position.X + 45, position.Y, position.Z);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 5), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1V1");
            wallMesh.Position = new TGCVector3(position.X + 50, position.Y, position.Z);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(5, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1H1");
            wallMesh.Position = new TGCVector3(position.X + 45, position.Y, position.Z);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(5, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1H2");
            wallMesh.Position = new TGCVector3(position.X + 45, position.Y, position.Z + 5);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            //3
            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 5), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1V1");
            wallMesh.Position = new TGCVector3(position.X + 45, position.Y, position.Z + 45);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 5), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1V1");
            wallMesh.Position = new TGCVector3(position.X + 50, position.Y, position.Z + 45);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(5, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1H1");
            wallMesh.Position = new TGCVector3(position.X + 45, position.Y, position.Z + 45);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(5, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1H2");
            wallMesh.Position = new TGCVector3(position.X + 45, position.Y, position.Z + 50);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            //4
            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 5), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1V1");
            wallMesh.Position = new TGCVector3(position.X + 5, position.Y, position.Z + 45);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 80, 5), TgcPlane.Orientations.YZplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1V1");
            wallMesh.Position = new TGCVector3(position.X, position.Y, position.Z + 45);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(5, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1H1");
            wallMesh.Position = new TGCVector3(position.X, position.Y, position.Z + 45);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);

            baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(5, 80, 0), TgcPlane.Orientations.XYplane, TgcTexture.createTexture(columnTexture), 1, 4);

            wallMesh          = baseWall.toMesh("Column1H2");
            wallMesh.Position = new TGCVector3(position.X, position.Y, position.Z + 50);
            wallMesh.UpdateMeshTransform();
            towerWalls.Add(wallMesh);
        }
Exemplo n.º 27
0
        public Pit(TGCVector3 newPosition, TgcPlane grassPlane, TgcPlane wallPlaneX, TgcPlane wallPlaneZ, TgcPlane wallPlaneVertX, TgcPlane columnPlaneX, TgcPlane columnPlaneZ, TgcPlane topPlane)
        {
            this.Position = newPosition;

            //Se define el terrno de la parcela
            var grassMesh = grassPlane.toMesh("floor");

            grassMesh.Position  = new TGCVector3(this.Position.X, this.Position.Y - 20, this.Position.Z);
            grassMesh.Transform = TGCMatrix.Translation(grassMesh.Position);
            meshes.Add(grassMesh);

            //Armamos muros a partir de un Plano y lo convertimos a Mesh
            var baseTriangleWallH = wallPlaneZ;

            var wallMesh = baseTriangleWallH.toMesh("WallHA");

            wallMesh.RotateX(-FastMath.ToRad(2 * 7.125f));
            wallMesh.Position = new TGCVector3(newPosition.X, newPosition.Y - 20, newPosition.Z + 5);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh = wallMesh.clone("WallHB");
            wallMesh.RotateX(FastMath.ToRad(4 * 7.125f));
            wallMesh.Position = new TGCVector3(newPosition.X, newPosition.Y - 20, newPosition.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            var baseWall = wallPlaneX;

            wallMesh = baseWall.toMesh("WallVA");
            wallMesh.RotateZ(FastMath.ToRad(2 * 7.125f));
            wallMesh.Position = new TGCVector3(newPosition.X + 5, newPosition.Y - 20, newPosition.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh = wallMesh.clone("WallVB");

            wallMesh.RotateZ(-FastMath.ToRad(4 * 7.125f));
            wallMesh.Position = new TGCVector3(newPosition.X + 45, newPosition.Y - 20, newPosition.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            baseWall = wallPlaneVertX;

            wallMesh           = baseWall.toMesh("WallVA");
            wallMesh.Position  = new TGCVector3(newPosition.X, newPosition.Y, newPosition.Z);
            wallMesh.Transform = TGCMatrix.Translation(wallMesh.Position);
            meshes.Add(wallMesh);

            wallMesh           = baseWall.toMesh("WallVA");
            wallMesh.Position  = new TGCVector3(newPosition.X + 50, newPosition.Y, newPosition.Z);
            wallMesh.Transform = TGCMatrix.Translation(wallMesh.Position);
            meshes.Add(wallMesh);

            //Columnas
            var column = new Column
            {
                Position = new TGCVector3(this.Position.X, this.Position.Y - 20, this.Position.Z)
            };

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, TGCVector3.Empty));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(0, 0, 45)));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(45, 0, 0)));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(45, 0, 45)));

            //Tapas de columnas
            baseWall = topPlane;

            wallMesh          = baseWall.toMesh("TopColumn1");
            wallMesh.Position = new TGCVector3(newPosition.X, newPosition.Y + 20, newPosition.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn2");
            wallMesh.Position = new TGCVector3(newPosition.X + 45, newPosition.Y + 20, newPosition.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn3");
            wallMesh.Position = new TGCVector3(newPosition.X + 45, newPosition.Y + 20, newPosition.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn4");
            wallMesh.Position = new TGCVector3(newPosition.X, newPosition.Y + 20, newPosition.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);
        }
Exemplo n.º 28
0
        //TODO: manejar todos los mesh de cada parcela en una una coleccion
        public SideLeft(TGCVector3 Position, TgcPlane grassPlane, TgcTexture wallTexture, TgcPlane columnPlaneX, TgcPlane columnPlaneZ, TgcPlane topPlane, TgcMesh plantModel)
        {
            this.Position = Position;

            //Se define el terrno de la parcela
            var grassMesh = grassPlane.toMesh("floor");

            grassMesh.Position  = this.Position;
            grassMesh.Transform = TGCMatrix.Translation(grassMesh.Position);
            meshes.Add(grassMesh);

            //Variable temporal que contiene el modelo
            var basePlant = plantModel;

            basePlant.Position = new TGCVector3(Position.X + 45, Position.Y, Position.Z);
            basePlant.Scale    = new TGCVector3(0.5f, 0.5f, 0.5f);
            var random = new Random();
            var ran    = random.Next(0, 100);

            basePlant.RotateY(ran);
            basePlant.Enabled = true;
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaabajo2");
            basePlant.Position = new TGCVector3(Position.X + 25, Position.Y, Position.Z + 5);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaabajo4");
            basePlant.Position = new TGCVector3(Position.X + 5, Position.Y, Position.Z + 5);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaarriba1");
            basePlant.Position = new TGCVector3(Position.X + 45, Position.Y, Position.Z + 45);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaarriba3");
            basePlant.Position = new TGCVector3(Position.X + 25, Position.Y, Position.Z + 45);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaarriba5");
            basePlant.Position = new TGCVector3(Position.X + 5, Position.Y, Position.Z + 45);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            //Armamos muros a partir de un Plano y lo convertimos a Mesh
            var baseTriangleWallH = new TgcPlane(new TGCVector3(), new TGCVector3(50, 20.62f, 0), TgcPlane.Orientations.XYplane, wallTexture, 2, 1);

            var wallMesh = baseTriangleWallH.toMesh("WallHA");

            wallMesh.RotateX(-FastMath.ToRad(2 * 7.125f));
            wallMesh.Position = new TGCVector3(Position.X, Position.Y, Position.Z + 5);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh = wallMesh.clone("WallHB");
            wallMesh.RotateX(FastMath.ToRad(4 * 7.125f));
            wallMesh.Position = new TGCVector3(Position.X, Position.Y, Position.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            var baseWall = new TgcPlane(new TGCVector3(), new TGCVector3(0, 20.62f, 50), TgcPlane.Orientations.YZplane, wallTexture, 2, 1);

            wallMesh = baseWall.toMesh("WallVA");
            wallMesh.RotateZ(FastMath.ToRad(2 * 7.125f));
            wallMesh.Position = new TGCVector3(Position.X + 5, Position.Y, Position.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            //Columnas
            var column = new Column
            {
                Position = this.Position
            };

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, TGCVector3.Empty));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(0, 0, 45)));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(45, 0, 0)));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(45, 0, 45)));

            //Tapas de columnas
            baseWall = topPlane;

            wallMesh          = baseWall.toMesh("TopColumn1");
            wallMesh.Position = new TGCVector3(Position.X, Position.Y + 20, Position.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn2");
            wallMesh.Position = new TGCVector3(Position.X + 45, Position.Y + 20, Position.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn3");
            wallMesh.Position = new TGCVector3(Position.X + 45, Position.Y + 20, Position.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn4");
            wallMesh.Position = new TGCVector3(Position.X, Position.Y + 20, Position.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);
        }
Exemplo n.º 29
0
        //TODO: manejar todos los mesh de cada parcela en una una coleccion
        public SuperiorLeft(TGCVector3 Position, TgcPlane grassPlane, TgcPlane wallPlaneX, TgcPlane wallPlaneZ, TgcPlane columnPlaneX, TgcPlane columnPlaneZ, TgcPlane topPlane, TgcMesh plantModel)
        {
            this.Position = Position;

            //Se define el terrno de la parcela
            var grassMesh = grassPlane.toMesh("floor");

            grassMesh.Position  = this.Position;
            grassMesh.Transform = TGCMatrix.Translation(grassMesh.Position);
            meshes.Add(grassMesh);

            //Variable temporal que contiene el modelo
            var basePlant = plantModel;

            basePlant.Position = new TGCVector3(Position.X + 5, Position.Y, Position.Z + 45);
            basePlant.Scale    = new TGCVector3(0.5f, 0.5f, 0.5f);
            var random = new Random();
            var ran    = random.Next(0, 100);

            basePlant.RotateY(ran);
            basePlant.Enabled = true;
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaizquierda2");
            basePlant.Position = new TGCVector3(Position.X + 5, Position.Y, Position.Z + 25);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaizquierda4");
            basePlant.Position = new TGCVector3(Position.X + 5, Position.Y, Position.Z + 5);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaarriba1");
            basePlant.Position = new TGCVector3(Position.X + 45, Position.Y, Position.Z + 45);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaarriba3");
            basePlant.Position = new TGCVector3(Position.X + 25, Position.Y, Position.Z + 45);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            basePlant          = basePlant.clone("plantaarriba5");
            basePlant.Position = new TGCVector3(Position.X + 5, Position.Y, Position.Z + 45);
            ran = random.Next(0, 100);
            basePlant.RotateY(ran);
            basePlant.UpdateMeshTransform();
            plantas.Add(basePlant);

            var baseWall = wallPlaneX;
            var wallMesh = baseWall.toMesh("WallVA");

            wallMesh.RotateZ(FastMath.ToRad(2 * 7.125f));
            wallMesh.Position = new TGCVector3(Position.X + 5, Position.Y, Position.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            baseWall = wallPlaneZ;
            wallMesh = baseWall.toMesh("WallB");
            wallMesh.RotateX(FastMath.ToRad(2 * 7.125f));
            wallMesh.Position = new TGCVector3(Position.X, Position.Y, Position.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            //Columnas
            var column = new Column
            {
                Position = this.Position
            };

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, TGCVector3.Empty));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(0, 0, 45)));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(45, 0, 0)));

            meshes.AddRange(column.CreateColumn(columnPlaneX, columnPlaneZ, new TGCVector3(45, 0, 45)));

            //Tapas de columnas
            baseWall = topPlane;

            wallMesh          = baseWall.toMesh("TopColumn1");
            wallMesh.Position = new TGCVector3(Position.X, Position.Y + 20, Position.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn2");
            wallMesh.Position = new TGCVector3(Position.X + 45, Position.Y + 20, Position.Z);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn3");
            wallMesh.Position = new TGCVector3(Position.X + 45, Position.Y + 20, Position.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);

            wallMesh          = wallMesh.clone("TopColumn4");
            wallMesh.Position = new TGCVector3(Position.X, Position.Y + 20, Position.Z + 45);
            wallMesh.UpdateMeshTransform();
            meshes.Add(wallMesh);
        }
Exemplo n.º 30
0
        public void Init()
        {
            var loader = new TgcSceneLoader();

            Items                = new List <Recolectable>();
            Piezas               = new List <Pieza>();
            Objetos              = new List <Colisionable>();
            MeshARenderizar      = new List <TgcMesh>();
            meshFogatas          = new List <TgcMesh>();
            IluminacionEscenario = new List <Fogata>();



            //Instancia de skybox
            skyBox        = new TgcSkyBox();
            skyBox.Center = TGCVector3.Empty;
            skyBox.Size   = new TGCVector3(9000, 9000, 9000);

            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Up, MediaDir + "cielo.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Down, MediaDir + "cielo.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Left, MediaDir + "cielo.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Right, MediaDir + "cielo.jpg");

            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Front, MediaDir + "cielo.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Back, MediaDir + "cielo.jpg");
            skyBox.SkyEpsilon = 25f;

            skyBox.Init();

            //Instancio la vegetacion
            var scene        = loader.loadSceneFromFile(MediaDir + @"Pino-TgcScene.xml");
            var PinoOriginal = scene.Meshes[0];
            List <TGCVector3> posicionesArboles = new List <TGCVector3>();

            posicionesArboles.Add(new TGCVector3(1, 1, 1));
            posicionesArboles.Add(new TGCVector3(-3442, 1, -2736));
            posicionesArboles.Add(new TGCVector3(-3689, 1, -3039));
            posicionesArboles.Add(new TGCVector3(-3799, 1, -2719));
            posicionesArboles.Add(new TGCVector3(-3417, 1, -2480));
            posicionesArboles.Add(new TGCVector3(-2917, 1, -2433));
            posicionesArboles.Add(new TGCVector3(-3668, 1, -2025));
            posicionesArboles.Add(new TGCVector3(-3362, 1, -2009));
            posicionesArboles.Add(new TGCVector3(-3451, 1, -3786));
            posicionesArboles.Add(new TGCVector3(-4037, 1, -2329));
            posicionesArboles.Add(new TGCVector3(-2885, 1, -1826));
            posicionesArboles.Add(new TGCVector3(-4123, 1, -1581));
            posicionesArboles.Add(new TGCVector3(-3289, 1, -909));
            posicionesArboles.Add(new TGCVector3(-4261, 1, -435));
            posicionesArboles.Add(new TGCVector3(-2883, 1, -655));
            posicionesArboles.Add(new TGCVector3(-3352, 1, -1761));
            posicionesArboles.Add(new TGCVector3(-3244, 1, -2394));
            posicionesArboles.Add(new TGCVector3(-3978, 1, -2572));
            posicionesArboles.Add(new TGCVector3(-3517, 1, -1982));
            posicionesArboles.Add(new TGCVector3(-3118, 1, -1524));
            posicionesArboles.Add(new TGCVector3(-3349, 1, -980));
            posicionesArboles.Add(new TGCVector3(-4110, 1, -407));
            posicionesArboles.Add(new TGCVector3(-3304, 1, -1774));
            posicionesArboles.Add(new TGCVector3(-3139, 1, -1269));
            posicionesArboles.Add(new TGCVector3(-2140, 1, -562));
            posicionesArboles.Add(new TGCVector3(-4094, 1, -145));
            posicionesArboles.Add(new TGCVector3(-3103, 1, -1337));
            posicionesArboles.Add(new TGCVector3(-2896, 1, -1087));
            posicionesArboles.Add(new TGCVector3(-2529, 1, 10));
            posicionesArboles.Add(new TGCVector3(-3917, 1, 772));
            posicionesArboles.Add(new TGCVector3(746, 1, 157));
            posicionesArboles.Add(new TGCVector3(951, 1, 637));
            posicionesArboles.Add(new TGCVector3(1361, 1, 404));
            posicionesArboles.Add(new TGCVector3(1361, 1, 440));
            posicionesArboles.Add(new TGCVector3(-3877, 1, -678));
            posicionesArboles.Add(new TGCVector3(-3997, 1, -1079));
            posicionesArboles.Add(new TGCVector3(-3996, 1, -1617));
            posicionesArboles.Add(new TGCVector3(-3701, 1, -1505));
            posicionesArboles.Add(new TGCVector3(-3761, 1, -1069));
            posicionesArboles.Add(new TGCVector3(-3968, 1, -1952));
            posicionesArboles.Add(new TGCVector3(-3550, 1, -1562));
            posicionesArboles.Add(new TGCVector3(-3557, 1, -1192));
            posicionesArboles.Add(new TGCVector3(-3938, 1, -1048));
            posicionesArboles.Add(new TGCVector3(-3148, 1, -268));
            posicionesArboles.Add(new TGCVector3(-4120, 1, 433));
            posicionesArboles.Add(new TGCVector3(-3136, 1, -135));
            posicionesArboles.Add(new TGCVector3(-2793, 1, -476));


            var indiceArbolDirectorio = (new Random()).Next(posicionesArboles.Count, posicionesArboles.Count + 100);

            arbolesMesh = new List <TgcMesh>();
            Colisionable Arbol;

            for (var i = 0; i < posicionesArboles.Count; i++)
            {
                var Instance = PinoOriginal.createMeshInstance("Pino" + i);
                Arbol = new SinEfecto(Instance);
                Arbol.mesh.Move(0, 0, 0);
                Arbol.mesh.Scale = new TGCVector3(0.05f * i, 0.05f * i, 0.05f * i);
                Arbol.mesh.Move(posicionesArboles[i]);
                Arbol.mesh.Transform = TGCMatrix.Translation(posicionesArboles[i]);
                Objetos.Add(Arbol);
                MeshARenderizar.Add(Arbol.mesh);
                arbolesMesh.Add(Arbol.mesh);
            }

            for (var i = posicionesArboles.Count; i < posicionesArboles.Count + 100; i++)
            {
                var Instance = PinoOriginal.createMeshInstance("Pino" + i);
                if (i == indiceArbolDirectorio)
                {
                    Arbol = new ArbolDirectorio(MediaDir);
                }
                else
                {
                    Arbol = new SinEfecto(Instance);
                }

                Arbol.mesh.Move(0, 0, 0);
                Arbol.mesh.Scale = new TGCVector3(0.01f * i, 0.01f * i, 0.01f * i);
                Arbol.mesh.Move(new TGCVector3(((float)Math.Pow(i, Math.PI) % 2066) + 98, 1, ((float)Math.Pow(i, Math.E) % 3136) - 1339));
                Arbol.mesh.Transform = TGCMatrix.Translation(new TGCVector3(((float)Math.Pow(i, Math.PI) % 2066) + 98, 1, ((float)Math.Pow(i, Math.E) % 3136) - 1339));
                Objetos.Add(Arbol);
                MeshARenderizar.Add(Arbol.mesh);
                arbolesMesh.Add(Arbol.mesh);
            }
            foreach (var mesh in arbolesMesh)
            {
                mesh.AlphaBlendEnable = true;
            }

            //Instancio el terreno (Heigthmap)
            terreno = new TgcSimpleTerrain();
            var pathTextura  = MediaDir + "Textures\\mapa1.jpg";
            var pathHeighmap = MediaDir + "mapa1.jpg";

            currentScaleXZ = 100f;
            currentScaleY  = 3f;
            terreno.loadHeightmap(pathHeighmap, currentScaleXZ, currentScaleY, new TGCVector3(0, -30, 0));
            terreno.loadTexture(pathTextura);

            //Instancio el piso
            var pisoTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Textures\\water2.jpg");

            Plano     = new TgcPlane(new TGCVector3(-tamanioMapa / 2, 0, -tamanioMapa / 2), new TGCVector3(tamanioMapa, 0, tamanioMapa), TgcPlane.Orientations.XZplane, pisoTexture, 50f, 50f);
            MeshPlano = Plano.toMesh("MeshPlano");
            Objetos.Add(new SinEfecto(MeshPlano));
            MeshARenderizar.Add(MeshPlano);
            piezaAsociadaLago = new Pieza(2, "Pieza 2", MediaDir + "\\2D\\windows\\windows_2.png", null);
            pistaAsociadaLago = new Pista(null, MediaDir + "\\2D\\pista_hacha.png", null);

            //Instancio la Cabania
            var sceneCabania = loader.loadSceneFromFile(MediaDir + @"cabania-TgcScene.xml");

            foreach (var Mesh in sceneCabania.Meshes)
            {
                Mesh.Move(-500, 20, 500);
                Mesh.Scale = new TGCVector3(4.5f, 4.5f, 4.5f);

                Mesh.Transform = TGCMatrix.Scaling(Mesh.Scale);

                Objetos.Add(new SinEfecto(Mesh));
                MeshARenderizar.Add(Mesh);
            }
            cabaniaBoundingBox = new TgcBoundingAxisAlignBox(new TGCVector3(-500, 20, 500), new TGCVector3(0, 1001, 1080));

            var sceneBridge = loader.loadSceneFromFile(MediaDir + @"Bridge-TgcScene.xml");

            foreach (var Mesh in sceneBridge.Meshes)
            {
                Mesh.Move(-2561, 12, 159);
                Mesh.Scale = new TGCVector3(4.5f, .75f, 1.35f);

                Mesh.Transform = TGCMatrix.Scaling(Mesh.Scale);

                Objetos.Add(new SinEfecto(Mesh));
                MeshARenderizar.Add(Mesh);
            }

            var sceneCanoa = loader.loadSceneFromFile(MediaDir + @"Canoa-TgcScene.xml");

            foreach (var Mesh in sceneCanoa.Meshes)
            {
                Mesh.Move(-482, 20, -3110);
                Mesh.Scale = new TGCVector3(1.5f, 1.5f, 1.5f);

                Mesh.Transform = TGCMatrix.Scaling(Mesh.Scale);

                Objetos.Add(new SinEfecto(Mesh));
                MeshARenderizar.Add(Mesh);
            }

            //Cabania es lugar seguro

            if (TgcCollisionUtils.testAABBAABB(personaje.mesh.BoundingBox, cabaniaBoundingBox))
            {
                personaje.tiempoDesprotegido = 0;
            }
        }