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);
        }
Esempio n. 2
0
        /// <summary>
        /// Modificador para un intervalo discreto de valores.
        /// </summary>
        /// <param name="varName">Nombre del modificador.</param>
        /// <param name="values">Array de valores discretos.</param>
        /// <param name="defaultIndex">Indice default del array.</param>
        /// <returns>Modificador que se agrego.</returns>
        public TGCIntervalModifier AddInterval(string varName, object[] values, int defaultIndex)
        {
            var intervalModifier = new TGCIntervalModifier(varName, values, defaultIndex);

            AddModifier(intervalModifier);
            return(intervalModifier);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public override void Init()
        {
            //Crear loader
            var loader = new TgcSceneLoader();

            //Cargar los mesh:
            scene         = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\TanqueFuturistaRuedas\\TanqueFuturistaRuedas-TgcScene.xml");
            mesh          = scene.Meshes[0];
            mesh.Scale    = new TGCVector3(0.5f, 0.5f, 0.5f);
            mesh.Position = TGCVector3.Empty;

            //Cargar Shader personalizado
            effect = TGCShaders.Instance.LoadEffect(ShadersDir + "WorkshopShaders\\BasicShader.fx");

            //Le asigno el efecto a la malla
            mesh.Effect = effect;

            //Selecciona la tecnica del shader.
            shaderEffectModifier = AddInterval("Effect", new[] { "RenderScene", "RenderScene2" }, 1);

            //Indico que tecnica voy a usar
            // Hay effectos que estan organizados con mas de una tecnica.
            mesh.Technique = shaderEffectModifier.Value.ToString();

            //Centrar camara rotacional respecto a este mesh

            Camera = new TgcRotationalCamera(mesh.BoundingBox.calculateBoxCenter(), mesh.BoundingBox.calculateBoxRadius() * 5, Input);

            time = 0;
        }
Esempio n. 5
0
        public override void Init()
        {
            //Paths para archivo XML de la malla
            var pathMesh = MediaDir + "KeyframeAnimations\\Robot\\Robot-TgcKeyFrameMesh.xml";

            //Path para carpeta de texturas de la malla
            var mediaPath = MediaDir + "KeyframeAnimations\\Robot\\";

            //Lista de animaciones disponibles
            string[] animationList =
            {
                "Parado",
                "Caminando",
                "Correr",
                "PasoDerecho",
                "PasoIzquierdo",
                "Empujar",
                "Patear",
                "Pegar",
                "Arrojar"
            };

            //Crear rutas con cada animacion
            var animationsPath = new string[animationList.Length];

            for (var i = 0; i < animationList.Length; i++)
            {
                animationsPath[i] = mediaPath + animationList[i] + "-TgcKeyFrameAnim.xml";
            }

            //Cargar mesh y animaciones
            var loader = new TgcKeyFrameLoader();

            mesh = loader.loadMeshAndAnimationsFromFile(pathMesh, mediaPath, animationsPath);

            //Agregar combo para elegir animacion
            selectedAnim      = animationList[0];
            animationModifier = AddInterval("animation", animationList, 0);

            //Modifier para especificar si la animacion se anima con loop
            animateWithLoop = true;
            loopModifier    = AddBoolean("loop", "Loop anim:", animateWithLoop);

            //Modifier para color
            currentColor  = Color.White;
            colorModifier = AddColor("Color", currentColor);

            //Modifier para BoundingBox
            boundingBoxModifier = AddBoolean("BoundingBox", "BoundingBox:", false);

            //Elegir animacion Caminando
            mesh.playAnimation(selectedAnim, true);

            //Configurar camara
            Camera = new TgcRotationalCamera(new TGCVector3(0, 70, 0), 200, Input);
        }
Esempio n. 6
0
        public override void Init()
        {
            createMeshes();

            //Crear Material
            material = new Material();

            //Crear una fuente de luz direccional en la posicion 0.
            D3DDevice.Instance.Device.Lights[0].Type     = LightType.Directional;
            D3DDevice.Instance.Device.Lights[0].Diffuse  = Color.White;
            D3DDevice.Instance.Device.Lights[0].Ambient  = Color.White;
            D3DDevice.Instance.Device.Lights[0].Specular = Color.White;
            D3DDevice.Instance.Device.Lights[0].Range    = 1000;
            D3DDevice.Instance.Device.Lights[0].Enabled  = true;

            //Habilitar esquema de Iluminacion Dinamica
            D3DDevice.Instance.Device.RenderState.Lighting = true;

            //Configurar camara rotacional
            Camera = new TgcRotationalCamera(TGCVector3.Empty, 15f, Input);

            //El tipo de mesh para seleccionar.
            selectedMeshModifier = AddInterval("SelectedMesh", new[] { "Teapot", "Face" }, 0);

            //Selecciona el modo de shading.
            shaderModeModifier = AddInterval("ShaderMode", new[] { "Gouraud", "Flat" }, 1);

            //Habilito o deshabilito mostrar las normales
            normalesModifier = AddBoolean("Normales", "Mostrar normales", false);

            //El exponente del nivel de brillo de la iluminacion especular.
            specularSharpnessModifier = AddFloat("SpecularSharpness", 0, 500f, 100.00f);

            //Habilita o deshabilita el brillo especular.
            specularEnabledModifier = AddBoolean("SpecularEnabled", "Enable Specular", true);

            //Los distintos colores e intensidades de cada uno de los tipos de iluminacion.
            ambientModifier  = AddColor("Ambient", Color.LightSlateGray);
            diffuseModifier  = AddColor("Diffuse", Color.Gray);
            specularModifier = AddColor("Specular", Color.LightSteelBlue);

            //Habilita o deshabilita el remarcado de los bordes de cada triangulo.
            wireframeModifier = AddBoolean("Wireframe", "Enable Wireframe", false);

            //Habilita o deshabilita el back face culling
            backFaceCullModifier = AddBoolean("BackFaceCull", "Enable BackFaceCulling", false);

            //Modifiers para angulos de rotacion de la luz
            angleXModifier = AddFloat("angleX", 0, 0.005f, 0.0f);
            angleYModifier = AddFloat("angleY", 0, 0.005f, 0.0f);
            angleZModifier = AddFloat("angleZ", 0, 0.005f, 0.0f);

            //Pongo el fondo negro
            BackgroundColor = Color.Black;
        }
Esempio n. 7
0
        public override void Init()
        {
            //Directorio de texturas
            texturePath = MediaDir + "Texturas\\Particles\\";

            //Texturas de particulas a utilizar
            textureNames = new[]
            {
                "pisada.png",
                "fuego.png",
                "humo.png",
                "hoja.png",
                "agua.png",
                "nieve.png"
            };

            //Modifiers
            textureModifier    = AddInterval("texture", textureNames, 0);
            cantidadModifier   = AddInt("cantidad", 1, 30, 10);
            minSizeModifier    = AddFloat("minSize", 0.25f, 10, 4);
            maxSizeModifier    = AddFloat("maxSize", 0.25f, 10, 6);
            timeToLiveModifier = AddFloat("timeToLive", 0.25f, 2, 1);
            frecuenciaModifier = AddFloat("frecuencia", 0.25f, 4, 1);
            dispersionModifier = AddInt("dispersion", 50, 400, 100);
            speedDirModifier   = AddVertex3f("speedDir", new TGCVector3(-50, -50, -50), new TGCVector3(50, 50, 50), new TGCVector3(30, 30, 30));

            //Crear emisor de particulas
            selectedTextureName   = textureNames[0];
            selectedParticleCount = 10;
            emitter          = new ParticleEmitter(texturePath + selectedTextureName, selectedParticleCount);
            emitter.Position = TGCVector3.Empty;

            box = TGCBox.fromSize(new TGCVector3(0, -30, 0), new TGCVector3(10, 10, 10), Color.Blue);

            Camara = new TgcRotationalCamera(TGCVector3.Empty, 300f, Input);
        }
        public override void Init()
        {
            //Crear loader
            var loader = new TgcSceneLoader();

            //Cargar mesh
            var scene =
                loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vehiculos\\GruaExcavadora\\GruaExcavadora-TgcScene.xml");

            mesh = scene.Meshes[0];

            //Cargar Shader personalizado
            mesh.Effect = TgcShaders.loadEffect(ShadersDir + "Ejemplo1.fx");

            //Modifier para Technique de shader
            techniqueModifier = AddInterval("Technique", new[]
            {
                "OnlyTexture",
                "OnlyColor",
                "Darkening",
                "Complementing",
                "MaskRedOut",
                "RedOnly",
                "RandomTexCoord",
                "RandomColorVS",
                "TextureOffset"
            }, 0);

            //Modifier para variables de shader
            darkFactorModifier    = AddFloat("darkFactor", 0f, 1f, 0.5f);
            textureOffsetModifier = AddFloat("textureOffset", 0f, 1f, 0.5f);
            r = new Random();

            //Centrar camara rotacional respecto a este mesh
            Camara = new TgcRotationalCamera(mesh.BoundingBox.calculateBoxCenter(), mesh.BoundingBox.calculateBoxRadius() * 2, Input);
        }
Esempio n. 9
0
        public override void Init()
        {
            Device d3dDevice = D3DDevice.Instance.Device;

            //Cargamos un escenario
            TgcSceneLoader loader = new TgcSceneLoader();

            TgcScene scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Selva\\Selva-TgcScene.xml");

            meshes = scene.Meshes;
            TgcScene scene2 = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vegetacion\\Pasto\\Pasto-TgcScene.xml");

            pasto = scene2.Meshes[0];
            TgcScene scene3 = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vegetacion\\ArbolSelvatico\\ArbolSelvatico-TgcScene.xml");

            arbol = scene3.Meshes[0];

            arbol.Transform = TGCMatrix.Scaling(1, 3, 1);
            TgcScene scene4 = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vegetacion\\Arbusto2\\Arbusto2-TgcScene.xml");

            arbusto = scene4.Meshes[0];

            //Cargar terreno: cargar heightmap y textura de color
            terrain = new TgcSimpleTerrain();
            terrain.loadHeightmap(MediaDir + "Heighmaps\\" + "TerrainTexture2.jpg", 20, 0.3f, new TGCVector3(0, -115, 0));
            terrain.loadTexture(MediaDir + "Heighmaps\\" + "grass.jpg");

            //Crear SkyBox
            skyBox        = new TgcSkyBox();
            skyBox.Center = new TGCVector3(0, 500, 0);
            skyBox.Size   = new TGCVector3(10000, 10000, 10000);
            string texturesPath = MediaDir + "Texturas\\Quake\\SkyBox2\\";

            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Up, texturesPath + "lun4_up.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Down, texturesPath + "lun4_dn.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Left, texturesPath + "lun4_lf.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Right, texturesPath + "lun4_rt.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Front, texturesPath + "lun4_bk.jpg");
            skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Back, texturesPath + "lun4_ft.jpg");
            skyBox.Init();

            //Cargar Shader personalizado
            string compilationErrors;

            effect = Effect.FromFile(d3dDevice, ShadersDir + "WorkshopShaders\\GaussianBlur.fx", null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors);
            if (effect == null)
            {
                throw new Exception("Error al cargar shader. Errores: " + compilationErrors);
            }
            //Configurar Technique dentro del shader
            effect.Technique = "DefaultTechnique";

            //Camara en primera persona
            TGCVector3 positionEye = new TGCVector3(-944.1269f, 100f, -1033.307f);

            Camera = new TgcFpsCamera(positionEye, 300, 10, Input);

            g_pDepthStencil = d3dDevice.CreateDepthStencilSurface(d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, DepthFormat.D24S8, MultiSampleType.None, 0, true);

            // inicializo el render target
            g_pRenderTarget = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default);

            g_pGlowMap = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth, d3dDevice.PresentationParameters.BackBufferHeight, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default);

            g_pRenderTarget4 = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4, d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default);

            g_pRenderTarget4Aux = new Texture(d3dDevice, d3dDevice.PresentationParameters.BackBufferWidth / 4, d3dDevice.PresentationParameters.BackBufferHeight / 4, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default);

            // Para computar el promedio de Luminance
            int tx_size = 1;

            for (int i = 0; i < NUM_REDUCE_TX; ++i)
            {
                g_pLuminance[i] = new Texture(d3dDevice, tx_size, tx_size, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default);
                tx_size        *= 4;
            }

            g_pLuminance_ant = new Texture(d3dDevice, 1, 1, 1, Usage.RenderTarget, Format.A16B16G16R16F, Pool.Default);

            effect.SetValue("g_RenderTarget", g_pRenderTarget);

            // Resolucion de pantalla
            effect.SetValue("screen_dx", d3dDevice.PresentationParameters.BackBufferWidth);
            effect.SetValue("screen_dy", d3dDevice.PresentationParameters.BackBufferHeight);

            CustomVertex.PositionTextured[] vertices = new CustomVertex.PositionTextured[]
            {
                new CustomVertex.PositionTextured(-1, 1, 1, 0, 0),
                new CustomVertex.PositionTextured(1, 1, 1, 1, 0),
                new CustomVertex.PositionTextured(-1, -1, 1, 0, 1),
                new CustomVertex.PositionTextured(1, -1, 1, 1, 1)
            };
            //vertex buffer de los triangulos
            g_pVBV3D = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, d3dDevice, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default);
            g_pVBV3D.SetData(vertices, 0, LockFlags.None);

            activarGlowModifier      = AddBoolean("activar_glow", "Activar Glow", true);
            pantallaCompletaModifier = AddBoolean("pantalla_completa", "Pant.completa", true);
            tmIzqModifier            = AddEnum("tm_izq", typeof(ToneMapping), ToneMapping.MiddleGray);
            tmDerModifier            = AddEnum("tm_der", typeof(ToneMapping), ToneMapping.Nada);
            adaptacionPupilaModifier = AddInterval("adaptacion_pupila", new object[] { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }, 2);
        }
Esempio n. 10
0
        public override void Init()
        {
            //Paths para archivo XML de la malla
            var pathMesh = MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml";

            //Path para carpeta de texturas de la malla
            var mediaPath = MediaDir + "SkeletalAnimations\\Robot\\";

            //Lista de animaciones disponibles
            string[] animationList =
            {
                "Parado",
                "Caminando",
                "Correr",
                "PasoDerecho",
                "PasoIzquierdo",
                "Empujar",
                "Patear",
                "Pegar",
                "Arrojar"
            };

            //Crear rutas con cada animacion
            var animationsPath = new string[animationList.Length];

            for (var i = 0; i < animationList.Length; i++)
            {
                animationsPath[i] = mediaPath + animationList[i] + "-TgcSkeletalAnim.xml";
            }

            //Cargar mesh y animaciones
            var loader = new TgcSkeletalLoader();

            mesh = loader.loadMeshAndAnimationsFromFile(pathMesh, mediaPath, animationsPath);

            //Crear esqueleto a modo Debug
            mesh.buildSkletonMesh();

            //Agregar combo para elegir animacion
            selectedAnim      = animationList[0];
            animationModifier = AddInterval("animation", animationList, 0);

            //Modifier para especificar si la animacion se anima con loop
            var animateWithLoop = true;

            loopModifier = AddBoolean("loop", "Loop anim:", animateWithLoop);

            //Modifier para renderizar el esqueleto
            var renderSkeleton = false;

            renderSkeletonModifier = AddBoolean("renderSkeleton", "Show skeleton:", renderSkeleton);

            //Modifier para FrameRate
            frameRateModifier = AddFloat("frameRate", 0, 100, 30);

            //Modifier para color
            currentColor  = Color.White;
            colorModifier = AddColor("Color", currentColor);

            //Modifier para BoundingBox
            boundingBoxModifier = AddBoolean("BoundingBox", "BoundingBox:", false);

            //Modifier para habilitar attachment
            showAttachment     = false;
            attachmentModifier = AddBoolean("Attachment", "Attachment:", showAttachment);

            //Elegir animacion Caminando
            mesh.playAnimation(selectedAnim, true);

            //Crear caja como modelo de Attachment del hueso "Bip01 L Hand"
            attachment = new TgcSkeletalBoneAttach();
            var attachmentBox = TGCBox.fromSize(new TGCVector3(5, 100, 5), Color.Blue);

            attachment.Mesh   = attachmentBox.ToMesh("attachment");
            attachment.Bone   = mesh.getBoneByName("Bip01 L Hand");
            attachment.Offset = TGCMatrix.Translation(10, -40, 0);
            attachment.updateValues();

            //Configurar camara
            Camera = new TgcRotationalCamera(new TGCVector3(0, 70, 0), 200, Input);
        }