Example #1
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 #2
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;
                }
            }
        }
        private void updateWall()
        {
            var origin    = (Vector3)Modifiers["origin"];
            var dimension = (Vector3)Modifiers["dimension"];
            var tiling    = (Vector2)Modifiers["tiling"];

            var orientation = (string)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);
                wall.updateValues();
            }
        }
Example #4
0
        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 #5
0
        public override void Init()
        {
            D3DDevice.Instance.Device.RenderState.AlphaFunction    = Compare.Greater;
            D3DDevice.Instance.Device.RenderState.BlendOperation   = BlendOperation.Add;
            D3DDevice.Instance.Device.RenderState.SourceBlend      = Blend.SourceAlpha;
            D3DDevice.Instance.Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;

            var texture = TgcTexture.createTexture(D3DDevice.Instance.Device,
                                                   MediaDir + "ModelosTgc\\BoxAlpha\\Textures\\pruebaAlpha.png");

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

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

            Camara = new TgcFpsCamera(new Vector3(50.0f, 50.0f, 150.0f));

            Modifiers.addBoolean("invertRender", "Invert Render", false);
        }
        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);
            }
        }
Example #7
0
        /// <summary>
        /// Actualizar parámetros de la pared según los valores cargados
        /// </summary>
        private void updateWall()
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Origen, dimensiones, tiling y AutoAdjust
            Vector3 origin     = (Vector3)GuiController.Instance.Modifiers["origin"];
            Vector3 dimension  = (Vector3)GuiController.Instance.Modifiers["dimension"];
            Vector2 tiling     = (Vector2)GuiController.Instance.Modifiers["tiling"];
            bool    autoAdjust = (bool)GuiController.Instance.Modifiers["autoAdjust"];

            //Cambiar orienación
            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;
            }

            //Cambiar textura
            string text = (string)GuiController.Instance.Modifiers["texture"];

            if (text != currentTexture.FilePath)
            {
                currentTexture = TgcTexture.createTexture(d3dDevice, text);
                wall.setTexture(currentTexture);
            }

            //Aplicar valores en pared
            wall.Origin       = origin;
            wall.Size         = dimension;
            wall.Orientation  = or;
            wall.AutoAdjustUv = autoAdjust;
            wall.UTile        = tiling.X;
            wall.VTile        = tiling.Y;

            //Es necesario ejecutar updateValues() para que los cambios tomen efecto
            wall.updateValues();


            //Ajustar camara segun tamaño de la pared
            GuiController.Instance.RotCamera.targetObject(wall.BoundingBox);
        }
Example #8
0
        /// <summary>
        ///     Actualizar parámetros de la pared según los valores cargados
        /// </summary>
        private void updateWall()
        {
            //Origen, dimensiones, tiling y AutoAdjust
            var origin     = (Vector3)Modifiers["origin"];
            var dimension  = (Vector3)Modifiers["dimension"];
            var tiling     = (Vector2)Modifiers["tiling"];
            var autoAdjust = (bool)Modifiers["autoAdjust"];

            //Cambiar orienación
            var orientation = (string)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;
            }

            //Cambiar textura
            var text = (string)Modifiers["texture"];

            if (text != currentTexture.FilePath)
            {
                currentTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, text);
                wall.setTexture(currentTexture);
            }

            //Aplicar valores en pared
            wall.Origin       = origin;
            wall.Size         = dimension;
            wall.Orientation  = or;
            wall.AutoAdjustUv = autoAdjust;
            wall.UTile        = tiling.X;
            wall.VTile        = tiling.Y;

            //Es necesario ejecutar updateValues() para que los cambios tomen efecto
            wall.updateValues();

            //Ajustar camara segun tamaño de la pared
            Camara = new TgcRotationalCamera(wall.BoundingBox.calculateBoxCenter(),
                                             wall.BoundingBox.calculateBoxRadius() * 2);
        }
Example #9
0
        public void SetCenter(Vector3 center)
        {
            up.Origin = center + new Vector3(-size * 0.5f, size * 0.5f, size * 0.5f);
            //dn.Origin = center + new Vector3(-size * 0.5f, -size * 0.5f, -size * 0.5f);
            lt.Origin = center + new Vector3(size * 0.5f, -size * 0.5f, size * 0.5f);
            rt.Origin = center + new Vector3(-size * 0.5f, -size * 0.5f, -size * 0.5f);
            ft.Origin = center + new Vector3(size * 0.5f, -size * 0.5f, -size * 0.5f);
            bk.Origin = center + new Vector3(-size * 0.5f, -size * 0.5f, size * 0.5f);

            up.updateValues();
            //dn.updateValues();
            lt.updateValues();
            rt.updateValues();
            ft.updateValues();
            bk.updateValues();
        }
Example #10
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);
        }