コード例 #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 elegir una textura.
        /// </summary>
        /// <param name="varName">Nombre del modificador.</param>
        /// <param name="defaultPath">Path de la textura default.</param>
        /// <returns>Modificador que se agrego.</returns>
        public TGCTextureModifier AddTexture(string varName, string defaultPath)
        {
            var textureModifier = new TGCTextureModifier(varName, defaultPath);

            AddModifier(textureModifier);
            return(textureModifier);
        }
コード例 #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);
        }
コード例 #4
0
        public override void Init()
        {
            //Path de Heightmap default del terreno y Modifier para cambiarla
            currentHeightmap  = MediaDir + "Heighmaps\\" + "Heightmap3.jpg";
            heightmapModifier = AddTexture("heightmap", currentHeightmap);

            //Modifiers para variar escala del mapa
            currentScaleXZ  = 50f;
            scaleXZModifier = AddFloat("scaleXZ", 0.1f, 100f, currentScaleXZ);
            currentScaleY   = 1.5f;
            scaleYModifier  = AddFloat("scaleY", 0.1f, 10f, currentScaleY);
            createHeightMapMesh(D3DDevice.Instance.Device, currentHeightmap, currentScaleXZ, currentScaleY);

            //Path de Textura default del terreno y Modifier para cambiarla
            currentTexture  = MediaDir + "Heighmaps\\" + "TerrainTexture3.jpg";
            textureModifier = AddTexture("texture", currentTexture);
            loadTerrainTexture(D3DDevice.Instance.Device, currentTexture);

            //Configurar FPS Camara
            Camara = new TgcFpsCamera(new TGCVector3(3200f, 450f, 1500f), Input);

            //UserVars para cantidad de vertices
            UserVars.addVar("Vertices", totalVertices);
            UserVars.addVar("Triangles", totalVertices / 3);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public override void Init()
        {
            cylinder = new TgcCylinder(TGCVector3.Empty, 2, 4);

            cylinder.AlphaBlendEnable = true;

            boundingCylinderModifier = AddBoolean("boundingCylinder", "boundingCylinder", false);
            colorModifier            = AddColor("color", Color.White);
            alphaModifier            = AddInt("alpha", 0, 255, 255);
            textureModifier          = AddTexture("texture", MediaDir + "\\Texturas\\madera.jpg");
            useTextureModifier       = AddBoolean("useTexture", "useTexture", true);

            sizeModifier     = AddVertex3f("size", new TGCVector3(-3, -3, 1), new TGCVector3(7, 7, 10), new TGCVector3(2, 2, 5));
            positionModifier = AddVertex3f("position", new TGCVector3(-20, -20, -20), new TGCVector3(20, 20, 20), TGCVector3.Empty);
            var angle = FastMath.TWO_PI;

            rotationModifier = AddVertex3f("rotation", new TGCVector3(-angle, -angle, -angle), new TGCVector3(angle, angle, angle), TGCVector3.Empty);

            Camara = new TgcRotationalCamera(Input);
        }
コード例 #7
0
ファイル: EjemploCajas.cs プロジェクト: Farabute/tgc-viewer
        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);
        }