public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            d3dDevice.RenderState.AlphaFunction = Compare.Greater;
            d3dDevice.RenderState.BlendOperation = BlendOperation.Add;
            d3dDevice.RenderState.AlphaBlendEnable = true;
            d3dDevice.RenderState.AlphaTestEnable = true;
            d3dDevice.RenderState.SourceBlend = Blend.SourceAlpha;
            d3dDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha;

            TgcTexture texture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\BoxAlpha\\Textures\\pruebaAlpha.png");

            mesh1 = new TgcPlaneWall(new Vector3(0,0,0), new Vector3(100, 100, 0), TgcPlaneWall.Orientations.XYplane, texture);
            mesh1.AutoAdjustUv = false;
            mesh1.UTile = 1;
            mesh1.VTile = 1;
            mesh1.updateValues();

            mesh2 = new TgcPlaneWall(new Vector3(0,0,100), new Vector3(100, 100, 0), TgcPlaneWall.Orientations.XYplane, texture);
            mesh2.AutoAdjustUv = false;
            mesh2.UTile = 1;
            mesh2.VTile = 1;
            mesh2.updateValues();

            GuiController.Instance.FpsCamera.Enable = true;

            GuiController.Instance.Modifiers.addBoolean("invertRender", "Invert Render", false);
        }
Example #2
0
        /// <summary>
        /// Iniciar la creacion
        /// </summary>
        public override void initCreation(Vector3 gridPoint)
        {
            initSelectionPoint = gridPoint;

            //Crear plano inicial
            TgcTexture planeTexture = TgcTexture.createTexture(Control.getCreationTexturePath());
            mesh = new TgcPlaneWall(initSelectionPoint, new Vector3(0, 0, 0), TgcPlaneWall.Orientations.XZplane, planeTexture);
            mesh.AutoAdjustUv = false;
            mesh.UTile = 1;
            mesh.VTile = 1;
            mesh.BoundingBox.setRenderColor(MeshCreatorUtils.UNSELECTED_OBJECT_COLOR);
            this.Layer = Control.CurrentLayer;
        }
Example #3
0
        public Skybox()
        {
            string skyTexPath = GuiController.Instance.AlumnoEjemplosMediaDir + "Jet_Pilot\\" + "Skybox\\";

            TgcTexture texture;

            up = new TgcPlaneWall();
            texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "up.jpg");
            up.setTexture(texture);
            up.Origin = new Vector3(-size * 0.5f, size * 0.5f, size * 0.5f);
            up.Size = new Vector3(size, size, -size);
            up.Orientation = TgcPlaneWall.Orientations.XZplane;

            //dn = new TgcPlaneWall();
            //texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "dn.jpg");
            //dn.setTexture(texture);
            //dn.Origin = new Vector3(-size * 0.5f, -size * 0.5f, -size * 0.5f);
            //dn.Size = new Vector3(size, size, size);
            //dn.Orientation = TgcPlaneWall.Orientations.XZplane;

            lt = new TgcPlaneWall();
            texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "bk.jpg");
            lt.setTexture(texture);
            lt.Origin = new Vector3(size * 0.5f, -size * 0.5f, size * 0.5f);
            lt.Size = new Vector3(size, size, -size);
            lt.Orientation = TgcPlaneWall.Orientations.YZplane;

            rt = new TgcPlaneWall();
            texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "ft.jpg");
            rt.setTexture(texture);
            rt.Origin = new Vector3(-size * 0.5f, -size * 0.5f, -size * 0.5f);
            rt.Size = new Vector3(size, size, size);
            rt.Orientation = TgcPlaneWall.Orientations.YZplane;

            ft = new TgcPlaneWall();
            texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "lf.jpg");
            ft.setTexture(texture);
            ft.Origin = new Vector3(size * 0.5f, -size * 0.5f, -size * 0.5f);
            ft.Size = new Vector3(-size, size, size);
            ft.Orientation = TgcPlaneWall.Orientations.XYplane;

            bk = new TgcPlaneWall();
            texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "rt.jpg");
            bk.setTexture(texture);
            bk.Origin = new Vector3(-size * 0.5f, -size * 0.5f, size * 0.5f);
            bk.Size = new Vector3(size, size, size);
            bk.Orientation = TgcPlaneWall.Orientations.XYplane;

            this.Reset();
        }
Example #4
0
        /// <summary>
        /// Crear un nuevo Wall igual a este
        /// </summary>
        /// <returns>Wall clonado</returns>
        public TgcPlaneWall clone()
        {
            TgcPlaneWall cloneWall = new TgcPlaneWall();

            cloneWall.origin           = this.origin;
            cloneWall.size             = this.size;
            cloneWall.orientation      = this.orientation;
            cloneWall.autoAdjustUv     = this.autoAdjustUv;
            cloneWall.uTile            = this.uTile;
            cloneWall.vTile            = this.vTile;
            cloneWall.alphaBlendEnable = this.alphaBlendEnable;
            cloneWall.uvOffset         = this.uvOffset;
            cloneWall.setTexture(this.texture.clone());

            updateValues();
            return(cloneWall);
        }
        private void updateWall()
        {
            Vector3 origin = (Vector3)GuiController.Instance.Modifiers["origin"];
            Vector3 dimension = (Vector3)GuiController.Instance.Modifiers["dimension"];
            Vector2 tiling = (Vector2)GuiController.Instance.Modifiers["tiling"];

            string orientation = (string)GuiController.Instance.Modifiers["orientation"];
            TgcPlaneWall.Orientations or;
            if(orientation == "XY") or = TgcPlaneWall.Orientations.XYplane;
            else if(orientation == "XZ") or = TgcPlaneWall.Orientations.XZplane;
            else or = TgcPlaneWall.Orientations.YZplane;

            if (wall == null)
            {
                wall = new TgcPlaneWall(origin, dimension, or, currentTexture, tiling.X, tiling.Y);
            }
            else
            {
                wall.updateValues(origin, dimension, or, tiling.X, tiling.Y);
            }
            
        }
        public override void init()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Modifiers para variar parámetros de la pared
            GuiController.Instance.Modifiers.addVertex3f("origin", new Vector3(-100, -100, -100), new Vector3(100, 100, 100), new Vector3(0, 0, 0));
            GuiController.Instance.Modifiers.addVertex3f("dimension", new Vector3(-100, -100, -100), new Vector3(1000, 1000, 100), new Vector3(100, 100, 100));
            GuiController.Instance.Modifiers.addInterval("orientation", new string[] { "XY", "XZ", "YZ" }, 0);
            GuiController.Instance.Modifiers.addVertex2f("tiling", new Vector2(0,0), new Vector2(10,10),new Vector2(1,1));
            GuiController.Instance.Modifiers.addBoolean("autoAdjust", "autoAdjust", false);

            //Modifier de textura
            string texturePath = GuiController.Instance.ExamplesMediaDir + "Texturas\\Quake\\TexturePack2\\brick1_1.jpg";
            currentTexture = TgcTexture.createTexture(d3dDevice, texturePath);
            GuiController.Instance.Modifiers.addTexture("texture", currentTexture.FilePath);

            //Crear pared
            wall = new TgcPlaneWall();
            wall.setTexture(currentTexture);

            //Actualizar según valores cargados
            updateWall();
        }
Example #7
0
        /// <summary>
        /// Crear un nuevo Wall igual a este
        /// </summary>
        /// <returns>Wall clonado</returns>
        public TgcPlaneWall clone()
        {
            TgcPlaneWall cloneWall = new TgcPlaneWall();
            cloneWall.origin = this.origin;
            cloneWall.size = this.size;
            cloneWall.orientation = this.orientation;
            cloneWall.autoAdjustUv = this.autoAdjustUv;
            cloneWall.uTile = this.uTile;
            cloneWall.vTile = this.vTile;
            cloneWall.alphaBlendEnable = this.alphaBlendEnable;
            cloneWall.uvOffset = this.uvOffset;
            cloneWall.setTexture(this.texture.clone());

            updateValues();
            return cloneWall;
        }
Example #8
0
        /// <summary>
        /// Construir plano
        /// </summary>
        public override void doCreation()
        {
            TgcD3dInput input = GuiController.Instance.D3dInput;

            //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
                float heightY = creatingInitMouseY - input.Ypos;
                float adjustedHeightY = MeshCreatorUtils.getMouseIncrementHeightSpeed(Control.Camera, this.BoundingBox, heightY);

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

                //Obtener maximo y minimo
                Vector3 min = Vector3.Minimize(initSelectionPoint, extensionPoint);
                Vector3 max = Vector3.Maximize(initSelectionPoint, extensionPoint);
                min.Z = initSelectionPoint.Z;
                max.Z = initSelectionPoint.Z + 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
                Vector3 size = mesh.BoundingBox.calculateSize();
                if (size.X > 1 && size.Y > 1)
                {
                    //Guardar size original del plano para hacer Scaling
                    originalSize = mesh.Size;

                    //Dejar cargado para que se pueda crear un nuevo plano
                    Control.CurrentState = MeshCreatorControl.State.CreatePrimitiveSelected;
                    Control.CreatingPrimitive = new PlaneXYPrimitive(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 = MeshCreatorControl.State.CreatePrimitiveSelected;
                    mesh.dispose();
                    mesh = null;
                }
            }

        }
Example #9
0
        /// <summary>
        /// Construir plano
        /// </summary>
        public override void doCreation()
        {
            TgcD3dInput input = GuiController.Instance.D3dInput;

            //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
                Vector3 collisionPoint = Control.Grid.getPicking();

                //Obtener extremos del rectángulo de selección
                Vector3 min = Vector3.Minimize(initSelectionPoint, collisionPoint);
                Vector3 max = Vector3.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
                Vector3 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 = MeshCreatorControl.State.CreatePrimitiveSelected;
                    Control.CreatingPrimitive = new PlaneXZPrimitive(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 = MeshCreatorControl.State.CreatePrimitiveSelected;
                    mesh.dispose();
                    mesh = null;
                }
            }

        }
Example #10
0
        public CustomVertex.PositionTextured[] actualizarPasto(float tLeftMoved, float tRightMoved, int parte, TgcPlaneWall pastoWall)
        {
            float autoWidth;
            float autoHeight;

            //Calcular los 4 corners de la pared
            Vector3 bLeft, tLeft, bRight, tRight, Center;
            bLeft = pastoWall.Origin;
            tLeft = new Vector3(pastoWall.Origin.X + pastoWall.Size.X, pastoWall.Origin.Y, pastoWall.Origin.Z);
            bRight = new Vector3(pastoWall.Origin.X - tLeftMoved, pastoWall.Origin.Y + pastoWall.Size.Y, pastoWall.Origin.Z);
            tRight = new Vector3(pastoWall.Origin.X + pastoWall.Size.X - tRightMoved, pastoWall.Origin.Y + pastoWall.Size.Y, pastoWall.Origin.Z);
            Center = new Vector3(pastoWall.Origin.X + (pastoWall.Size.X / 2), pastoWall.Origin.Y + (pastoWall.Size.Y / 2), pastoWall.Origin.Z);

            autoWidth = (pastoWall.Size.X / pastoWall.Texture.Width);
            autoHeight = (pastoWall.Size.Y / pastoWall.Texture.Height);

            //Auto ajustar UV
            if (pastoWall.AutoAdjustUv)
            {
                pastoWall.UTile = autoHeight;
                pastoWall.VTile = autoWidth;
            }
            float offsetU = pastoWall.UVOffset.X;
            float offsetV = pastoWall.UVOffset.Y;

            //Rotation
            if (parte == 0)
            {
                /*if (pasto.Origin.X > 0) origen.X = pasto.Origin.X + pasto.Size.X / 2;
                else origen.X = pasto.Origin.X - pasto.Size.X / 2;*/
                Vector3 v1, v2;
                v1 = tLeft - tRight;
                v2 = bLeft - tRight;
                Vector3 normal = Vector3.Cross(v1, v2);
                normal.Normalize();

                Vector3 direccion;
                direccion.X = CustomFpsCamera.Instance.Position.X - Center.X;
                direccion.Y = 0;
                direccion.Z = CustomFpsCamera.Instance.Position.Z - Center.Z;
                direccion.Normalize();

                calcularOrientacion(direccion, Center, normal);
            }

            CustomVertex.PositionTextured[] vertices = new CustomVertex.PositionTextured[6];
            float d = 0.02f;
            //Primer triangulo
            vertices[0] = new CustomVertex.PositionTextured(bLeft, offsetU + pastoWall.UTile + d, offsetV + pastoWall.VTile +d);
            vertices[1] = new CustomVertex.PositionTextured(tLeft, offsetU + d, offsetV + pastoWall.VTile + d);
            vertices[2] = new CustomVertex.PositionTextured(tRight, offsetU + d, offsetV + d);

            //Segundo triangulo
            vertices[3] = new CustomVertex.PositionTextured(bLeft, offsetU + pastoWall.UTile + d, offsetV + pastoWall.VTile + d);
            vertices[4] = new CustomVertex.PositionTextured(tRight, offsetU + d, offsetV + d);
            vertices[5] = new CustomVertex.PositionTextured(bRight, offsetU + pastoWall.UTile + d, offsetV + d);

            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i].Position = Vector3.TransformCoordinate(vertices[i].Position, m_mRotacion);
            }

            //BoundingBox
            pastoWall.BoundingBox.setExtremes(bLeft, tRight);

            return vertices;
        }
Example #11
0
        public void crearPasto(Device d3dDevice, int pastoSecuense, Vector3 origen)
        {
            string textureName = "pasto1.png";
            switch(pastoSecuense)
            {
                case 0:
                    textureName = "pasto3.png";
                    break;
                case 1:
                    textureName = "pasto2.png";
                    break;
                case 2:
                    textureName = "pasto1.png";
                    break;
            }

            string texturePath = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Mapas\\Textures\\" + textureName;
            TgcTexture pasto_texture = TgcTexture.createTexture(d3dDevice, texturePath);

            //Crear pared
            TgcPlaneWall pastoWall = new TgcPlaneWall();
            pastoWall.AlphaBlendEnable = true;
            pastoWall.setTexture(pasto_texture);

            //Aplicar valores en pared
            pastoWall.Origin = origen;
            pastoWall.Size = new Vector3(36, 30, 36);
            pastoWall.AutoAdjustUv = true;
            pastoWall.UTile = 1;
            pastoWall.VTile = 1;
            pastoWall.updateValues();

            partePasto.Add(pastoWall);
        }
        public void crearMuzzle()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;
            textures_flash.Add("flash1.png");
            textures_flash.Add("flash2.png");
            textures_flash.Add("flash3.png");
            MAX_RENDER = MAX_DELAY + MAX_DELAY / 2;

            string texturePath = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\" + textures_flash[0];
            TgcTexture pasto_texture = TgcTexture.createTexture(d3dDevice, texturePath);

            //Crear pared
            muzzleFlash = new TgcPlaneWall();
            muzzleFlash.AlphaBlendEnable = true;
            muzzleFlash.setTexture(pasto_texture);

            //Aplicar valores en pared
            //muzzleFlash.Origin = new Vector3(-50, 917.8f, 4.1f);
            muzzleFlash.Size = new Vector3(14, 14, 14);
            muzzleFlash.AutoAdjustUv = false;
            muzzleFlash.UTile = 1;
            muzzleFlash.VTile = 1;

            //Offsets

            /*
            BLoffset = new Vector3(-100, -17.7f, 14.7f);
            TLoffset = new Vector3(-100, -17.7f, 14.7f + muzzleFlash.Size.Z);
            BRoffset = new Vector3(-100, -17.7f + muzzleFlash.Size.Y, 14.7f);
            TRoffset = new Vector3(-100, -17.7f + muzzleFlash.Size.Y, 14.7f + muzzleFlash.Size.Z);
            */

            BLoffset = new Vector3( 3.5f, -12f, 50);
            TLoffset = new Vector3(3.5f + muzzleFlash.Size.X, -12f, 50);
            BRoffset = new Vector3(3.5f, -12f + muzzleFlash.Size.Y, 50);
            TRoffset = new Vector3(3.5f + muzzleFlash.Size.X, -12f + muzzleFlash.Size.Y, 50);
        }