예제 #1
0
        public override void Init()
        {
            //Crear esfera
            sphere = new TGCSphere();
            //No recomendamos utilizar AutoTransformEnable, con juegos complejos se pierde el control.
            sphere.AutoTransform = true;
            currentTexture       = null;

            //Modifiers para vararis sus parametros
            baseModifier          = AddEnum("base", typeof(TGCSphere.eBasePoly), TGCSphere.eBasePoly.ICOSAHEDRON);
            inflateModifier       = AddBoolean("inflate", "yes", true);
            levelOfDetailModifier = AddInterval("level of detail", new object[] { 0, 1, 2, 3, 4 }, 2);
            edgesModifier         = AddBoolean("edges", "show", false);
            radiusModifier        = AddFloat("radius", 0, 100, 10);
            positionModifier      = AddVertex3f("position", new TGCVector3(-100, -100, -100), new TGCVector3(100, 100, 100), TGCVector3.Empty);
            rotationModifier      = AddVertex3f("rotation", new TGCVector3(-180, -180, -180), new TGCVector3(180, 180, 180), TGCVector3.Empty);
            useTextureModifier    = AddBoolean("Use texture", "yes", true);
            textureModifier       = AddTexture("texture", MediaDir + "\\Texturas\\madera.jpg");
            offsetModifier        = AddVertex2f("offset", new TGCVector2(-0.5f, -0.5f), new TGCVector2(0.9f, 0.9f), TGCVector2.Zero);
            tilingModifier        = AddVertex2f("tiling", new TGCVector2(0.1f, 0.1f), new TGCVector2(4, 4), TGCVector2.One);

            colorModifier          = AddColor("color", Color.White);
            boundingsphereModifier = AddBoolean("boundingsphere", "show", false);

            UserVars.addVar("Vertices");
            UserVars.addVar("Triangulos");

            Camara = new TgcRotationalCamera(TGCVector3.Empty, 50f, Input);
        }
예제 #2
0
        /// <summary>
        /// Modificador para valores floats (X,Y) o (U,V) de un vertice.
        /// </summary>
        /// <param name="varName">Nombre del modificador.</param>
        /// <param name="minValue">Valor minimo.</param>
        /// <param name="maxValue">Valor maximo.</param>
        /// <param name="defaultValue">Valor default.</param>
        /// <returns>Modificador que se agrego.</returns>
        public TGCVertex2fModifier AddVertex2f(string varName, TGCVector2 minValue, TGCVector2 maxValue, TGCVector2 defaultValue)
        {
            var vertex2Modifier = new TGCVertex2fModifier(varName, minValue, maxValue, defaultValue);

            AddModifier(vertex2Modifier);
            return(vertex2Modifier);
        }
예제 #3
0
        public override void Init()
        {
            //Modifiers para variar parametros de la pared
            originModifier      = AddVertex3f("origin", new TGCVector3(-100, -100, -100), new TGCVector3(100, 100, 100), TGCVector3.Empty);
            dimensionModifier   = AddVertex3f("dimension", new TGCVector3(-100, -100, -100), new TGCVector3(1000, 1000, 100), new TGCVector3(100, 100, 100));
            orientationModifier = AddInterval("orientation", new[] { "XY", "XZ", "YZ" }, 0);
            tilingModifier      = AddVertex2f("tiling", TGCVector2.Zero, new TGCVector2(10, 10), TGCVector2.One);
            autoAdjustModifier  = AddBoolean("autoAdjust", "autoAdjust", false);

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

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

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

            //Actualizar segun valores cargados
            updateTGCPlane();

            //Ajustar camara segun tamano de la pared
            Camara = new TgcRotationalCamera(plane.BoundingBox.calculateBoxCenter(), plane.BoundingBox.calculateBoxRadius() * 2, Input);
        }
        public override void Init()
        {
            //Triangulo 1.
            //Definir array de vertices para el triangulo, del tipo Coordendas (X,Y,Z) + Color
            simpleTriangleData = new CustomVertex.PositionColored[3];

            //Cargar informacion de vertices. Nesitamos 3 vertices para crear un triangulo
            simpleTriangleData[0] = new CustomVertex.PositionColored(-1, 0, 0, Color.Red.ToArgb());
            simpleTriangleData[1] = new CustomVertex.PositionColored(1, 0, 0, Color.Green.ToArgb());
            simpleTriangleData[2] = new CustomVertex.PositionColored(0, 1, 0, Color.Blue.ToArgb());

            //Cargar variables de usuario con alguna informacion util para ver en pantalla
            UserVars.addVar("Triangle 1 vertices", simpleTriangleData.Length);

            //Triangulo 2.
            //Current texture
            currentTexurePah = MediaDir + "Texturas\\baldosaFacultad.jpg";
            texture          = TextureLoader.FromFile(D3DDevice.Instance.Device, currentTexurePah);

            //Modifiers
            vertex1Modifier   = AddVertex3f("vertex1", new TGCVector3(-3, -3, -3), new TGCVector3(3, 3, 3), new TGCVector3(-1, 0, 0));
            texCoord1Modifier = AddVertex2f("texCoord1", TGCVector2.Zero, TGCVector2.One, new TGCVector2(1, 0));
            color1Modifier    = AddColor("color1", Color.White);

            vertex2Modifier   = AddVertex3f("vertex2", new TGCVector3(-3, -3, -3), new TGCVector3(3, 3, 3), new TGCVector3(1, 0, 0));
            texCoord2Modifier = AddVertex2f("texCoord2", TGCVector2.Zero, TGCVector2.One, new TGCVector2(0, 1));
            color2Modifier    = AddColor("color2", Color.White);

            vertex3Modifier   = AddVertex3f("vertex3", new TGCVector3(-3, -3, -3), new TGCVector3(3, 3, 3), TGCVector3.Up);
            texCoord3Modifier = AddVertex2f("texCoord3", TGCVector2.Zero, TGCVector2.One, TGCVector2.One);
            color3Modifier    = AddColor("color3", Color.White);

            rotationModifier      = AddFloat("rotation", -2, 2f, 0f);
            textureEnableModifier = AddBoolean("TextureEnable", "Con textura", true);
            textureImageModifier  = AddTexture("Texture image", currentTexurePah);

            //Triangulo 3.
            //Crear vertexBuffer
            vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColored), 3, D3DDevice.Instance.Device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default);

            //Cargar informacion de vertices: (X,Y,Z) + Color
            var data = new CustomVertex.PositionColored[3];

            data[0] = new CustomVertex.PositionColored(-1, 0, 0, Color.Red.ToArgb());
            data[1] = new CustomVertex.PositionColored(1, 0, 0, Color.Green.ToArgb());
            data[2] = new CustomVertex.PositionColored(0, 1, 0, Color.Blue.ToArgb());

            //Almacenar informacion en VertexBuffer
            vertexBuffer.SetData(data, 0, LockFlags.None);

            //User Vars
            UserVars.addVar("Triangle 3 vertices");
            UserVars.setValue("Triangle 3 vertices", data.Length);

            //Configurar camara en rotacion
            Camara = new TgcRotationalCamera(new TGCVector3(0, 0.5f, 0), 7.5f, Input);
        }
        public override void Init()
        {
            //Objetos en movimiento.
            colliderCylinder = new TgcBoundingCylinder(TGCVector3.Empty, 2, 4);
            colliderCylinder.setRenderColor(Color.LimeGreen);
            colliderCylinderFixedY = new TgcBoundingCylinderFixedY(TGCVector3.Empty, 2, 4);
            colliderCylinderFixedY.setRenderColor(Color.LimeGreen);
            //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.Scale = new TGCVector3(0.04f, 0.04f, 0.04f);

            //El personaje esta en el 0,0,0 hay que bajarlo
            var size = personaje.BoundingBox.PMax.Y - personaje.BoundingBox.PMin.Y;

            personaje.Position = new TGCVector3(0, -3f, 0);
            //Rotarlo 180° porque esta mirando para el otro lado
            personaje.Rotation  = new TGCVector3(0, FastMath.PI, 0);
            personaje.Transform = TGCMatrix.RotationY(personaje.Rotation.Y) * TGCMatrix.Translation(personaje.Position);

            //Objetos estaticos, pueden ser mesh o objetos simplificados.
            var loader = new TgcSceneLoader();
            var scene  = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\Patrullero\\Patrullero-TgcScene.xml");

            collisionableMeshAABB          = scene.Meshes[0];
            collisionableMeshAABB.Scale    = new TGCVector3(0.1f, 0.1f, 0.1f);
            collisionableMeshAABB.Position = new TGCVector3(6, 0, -2);
            collisionableCylinder          = new TgcBoundingCylinderFixedY(new TGCVector3(-6, 0, 0), 2, 2);
            collisionableSphere            = new TgcBoundingSphere(new TGCVector3(-3, 0, 10), 3);

            fixedYModifier = AddBoolean("fixedY", "use fixed Y", true);
            //Modifier para ver BoundingBox del personaje
            showBoundingBoxModifier = AddBoolean("showBoundingBox", "Personaje Bouding Box", false);
            sizeModifier            = AddVertex2f("size", TGCVector2.One, new TGCVector2(5, 10), new TGCVector2(2, 5));
            var angle = FastMath.TWO_PI;

            rotationModifier = AddVertex3f("rotation", new TGCVector3(-angle, -angle, -angle), new TGCVector3(angle, angle, angle), new TGCVector3(FastMath.TWO_PI / 8, 0, FastMath.TWO_PI / 8));

            //Configurar camara en Tercer Persona
            camaraInterna = new TgcThirdPersonCamera(personaje.Position, 25, -45);
            Camera        = camaraInterna;
        }
예제 #6
0
        public override void Init()
        {
            //Crear Quad vacio
            quad = new TGCQuad();

            //Modifiers para vararia sus parametros
            sizeModifier   = AddVertex2f("size", TGCVector2.Zero, new TGCVector2(100, 100), new TGCVector2(20, 20));
            normalModifier = AddVertex3f("normal", new TGCVector3(-10, -10, -10), new TGCVector3(10, 10, 10), new TGCVector3(0, 1, 0));
            centerModifier = AddVertex3f("center", new TGCVector3(-10, -10, -10), new TGCVector3(10, 10, 10), TGCVector3.Empty);
            colorModifier  = AddColor("color", Color.Coral);

            //Flecha para mostrar el sentido del vector normal
            normalArrow        = new TgcArrow();
            showNormalModifier = AddBoolean("showNormal", "Show normal", true);

            Camera = new TgcRotationalCamera(new TGCVector3(0, 5, 0), 50f, Input);
        }
예제 #7
0
        public override void Init()
        {
            drawer2D = new Drawer2D();

            //Crear Sprite
            sprite        = new CustomSprite();
            sprite.Bitmap = new CustomBitmap(MediaDir + "\\Texturas\\LogoTGC.png", D3DDevice.Instance.Device);

            //Ubicarlo centrado en la pantalla
            var textureSize = sprite.Bitmap.Size;

            sprite.Position = new TGCVector2(FastMath.Max(D3DDevice.Instance.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(D3DDevice.Instance.Height / 2 - textureSize.Height / 2, 0));

            //Crear Sprite animado
            animatedSprite = new AnimatedSprite(MediaDir + "\\Texturas\\Sprites\\Explosion.png", //Textura de 256x256
                                                new Size(64, 64),                                //Tamaño de un frame (64x64px en este caso)
                                                16,                                              //Cantidad de frames, (son 16 de 64x64px)
                                                10);                                             //Velocidad de animacion, en cuadros x segundo,

            //Ubicarlo centrado en la pantalla
            var textureSizeAnimado = animatedSprite.Bitmap.Size;

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

            //Modifiers para variar parametros del sprite
            positionModifier = AddVertex2f("position", TGCVector2.Zero, new TGCVector2(D3DDevice.Instance.Width, D3DDevice.Instance.Height), sprite.Position);
            scalingModifier  = AddVertex2f("scaling", TGCVector2.Zero, new TGCVector2(4, 4), sprite.Scaling);
            rotationModifier = AddFloat("rotation", 0, 360, 0);

            //Modifiers para variar parametros del sprite
            frameRateAnimatedModifier = AddFloat("frameRateAnimated", 1, 30, 10);
            positionAnimatedModifier  = AddVertex2f("positionAnimated", TGCVector2.Zero, new TGCVector2(D3DDevice.Instance.Width, D3DDevice.Instance.Height), animatedSprite.Position);
            scalingAnimatedModifier   = AddVertex2f("scalingAnimated", TGCVector2.Zero, new TGCVector2(4, 4), animatedSprite.Scaling);
            rotationAnimatedModifier  = AddFloat("rotationAnimated", 0, 360, 0);

            //Creamos un Box3D para que se vea como el Sprite es en 2D y se dibuja siempre arriba de la escena 3D
            box           = TGCBox.fromSize(new TGCVector3(10, 10, 10), TgcTexture.createTexture(MediaDir + "\\Texturas\\pasto.jpg"));
            box.Transform = TGCMatrix.RotationX(FastMath.QUARTER_PI);

            //Hacer que la camara se centre en el box3D
            Camara = new TgcRotationalCamera(box.BoundingBox.calculateBoxCenter(), box.BoundingBox.calculateBoxRadius() * 2, Input);
        }
예제 #8
0
        public override void Init()
        {
            //Crea flecha generica
            arrow = new TgcArrow();

            //Crear modifiers
            startModifier     = AddVertex3f("start", new TGCVector3(-50, -50, -50), new TGCVector3(50, 50, 50), TGCVector3.Empty);
            endModifier       = AddVertex3f("end", new TGCVector3(-50, -50, -50), new TGCVector3(50, 50, 50), new TGCVector3(0, 10, 0));
            thicknessModifier = AddFloat("thickness", 0.01f, 1, 0.06f);
            headSizeModifier  = AddVertex2f("headSize", new TGCVector2(0.01f, 0.01f), TGCVector2.One, new TGCVector2(0.3f, 0.6f));
            bodyColorModifier = AddColor("bodyColor", Color.Blue);
            headColorModifier = AddColor("headColor", Color.LightBlue);

            //Crea linea generica
            box = new TgcBoxDebug();

            //Crear modifiers
            boxColorModifier = AddColor("boxColor", Color.Red);

            //Camera FPS
            Camera = new TgcRotationalCamera(new TGCVector3(0, 10f, 0), 30f, Input);
        }
예제 #9
0
        public override void Init()
        {
            //Crear caja vacia
            box = new TGCBox();
            //Crear caja debug vacia
            debugBox       = new TgcBoxDebug();
            currentTexture = null;

            //Modifiers para vararis sus parametros
            boxModifier         = AddBoolean("box", "box", true);
            boundingBoxModifier = AddBoolean("boundingBox", "BoundingBox", false);
            debugBoxModifier    = AddBoolean("debugBox", "debugBox", true);
            thicknessModifier   = AddFloat("thickness", 0.1f, 5, 0.2f);
            textureModifier     = AddTexture("texture", MediaDir + "\\Texturas\\madera.jpg");
            offsetModifier      = AddVertex2f("offset", new TGCVector2(-0.5f, -0.5f), new TGCVector2(0.9f, 0.9f), TGCVector2.Zero);
            tilingModifier      = AddVertex2f("tiling", new TGCVector2(0.1f, 0.1f), new TGCVector2(4, 4), TGCVector2.One);
            colorModifier       = AddColor("color", Color.BurlyWood);
            sizeModifier        = AddVertex3f("size", TGCVector3.Empty, new TGCVector3(100, 100, 100), new TGCVector3(20, 20, 20));
            positionModifier    = AddVertex3f("position", new TGCVector3(-100, -100, -100), new TGCVector3(100, 100, 100), TGCVector3.Empty);
            rotationModifier    = AddVertex3f("rotation", new TGCVector3(-180, -180, -180), new TGCVector3(180, 180, 180), TGCVector3.Empty);

            Camera = new TgcRotationalCamera(TGCVector3.Empty, 200f, Input);
        }
예제 #10
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));
        }