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); }
/// <summary> /// Modificador para un intervalo discreto de valores creados con una estructura Enum. /// </summary> /// <param name="varName">Nombre del modificador.</param> /// <param name="enumType">Tipo del Enum a utilizar. Se obtiene con typeof(MyEnum).</param> /// <param name="defaultValue">Variable del Enum que se carga como default. Ejemplo MyEnum.OpcionA.</param> /// <returns>Modificador que se agrego.</returns> public TGCEnumModifier AddEnum(string varName, Type enumType, object defaultValue) { var enumModifier = new TGCEnumModifier(varName, enumType, defaultValue); AddModifier(enumModifier); return(enumModifier); }
public override void Init() { time = 0; Device d3dDevice = D3DDevice.Instance.Device; //Cargamos un escenario TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml"); meshes = scene.Meshes; //Cargar Shader personalizado string compilationErrors; effect = Effect.FromFile(d3dDevice, ShadersDir + "WorkshopShaders\\FullQuad.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 personas Camara = new TgcFpsCamera(new TGCVector3(-182.3816f, 82.3252f, -811.9061f), 100, 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.X8R8G8B8, 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); distorcionadorModifier = AddEnum("distorcionador", typeof(Distorciones), Distorciones.Pincushion); gridModifier = AddBoolean("grid", "mostrar grilla", false); kuModifier = AddFloat("Ku", 0, 1, 0.1f); kvModifier = AddFloat("Kv", 0, 1, 0.1f); ocScaleInModifier = AddFloat("oc_scale_in", 0.1f, 4, 2.5f); ocScaleModifier = AddFloat("oc_scale", 0.01f, 1f, 0.35f); }
public override void Init() { box1Texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\pasto.jpg"); box2Texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\tierra.jpg"); box3Texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\madera.jpg"); renderMethodModifier = AddEnum("Render Method", typeof(RenderMethod), RenderMethod.Unsorted); createMeshes(D3DDevice.Instance.Device); Camara.SetCamera(new TGCVector3(40f, 20f, -70f), new TGCVector3(40f, 20f, -60f)); }
public override void Init() { this.time = 0; this.techniques = AddEnum("Tecnica", typeof(Techniques), Techniques.RenderMesh); this.rotation = AddFloat("Rotacion", 0, FastMath.TWO_PI, 0); this.factor = AddFloat("Factor", 0, 1, 0.5f); this.effectVector = AddVertex3f("Vector", new TGCVector3(-20, -20, -20), new TGCVector3(20, 20, 20), TGCVector3.Empty); this.center = AddVertex3f("Centro", new TGCVector3(-10, -10, -10), new TGCVector3(10, 10, 10), TGCVector3.Empty); this.wireframe = AddBoolean("Wireframe", "Prende el efecto wireframe", false); this.showArrow = AddBoolean("Vector del Efecto", "Muestra el vector del efecto", false); this.CreateEffect(); this.CreateMesh(); this.CreateArrow(); this.scale = TGCMatrix.Scaling(20, 20, 20); var cameraPosition = new TGCVector3(0, 0, 125); var lookAt = TGCVector3.Empty; Camara.SetCamera(cameraPosition, lookAt); }
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); }
private void InitializeMaterials() { materials = AddEnum("Material", typeof(Material), Material.RUSTED_METAL); }