public void Init() { TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene2 = loader.loadSceneFromFile(mediaDir + "Xwing\\Turbolaser-TgcScene.xml"); //Solo nos interesa el primer modelo de esta escena (tiene solo uno) mainMesh = scene2.Meshes[0]; mainMesh.Position = posicionInicial; baseQuaternionTranslation = TGCMatrix.Translation(posicionInicial); baseScaleRotation = TGCMatrix.Scaling(new TGCVector3(0.1f, 0.1f, 0.1f)); mainMesh.Transform = TGCMatrix.Scaling(0.1f, 0.1f, 0.1f); }
public void init() { string alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosDir; var loader = new TgcSceneLoader(); trofeo = loader.loadSceneFromFile(alumnoMediaFolder + "CucarachaJugosita\\Media\\COPA-TgcScene.xml"); meshTrofeo = trofeo.Meshes[0]; meshTrofeo.Scale = (new Vector3(0.2f, 0.2f, 0.2f)); mesa = loader.loadSceneFromFile(alumnoMediaFolder + "CucarachaJugosita\\Media\\mesaRedonda-TgcScene.xml"); meshMesa = mesa.Meshes[0]; meshMesa.Scale = (new Vector3(0.9f, 0.9f, 0.9f)); }
public Torre(string MediaDir) { this.Scene = new TgcSceneLoader().loadSceneFromFile(MediaDir + "XWing/" + modelosDisponibles[new Random().Next(modelosDisponibles.Count)], MediaDir + "XWing/"); ScaleFactor = new TGCVector3(5f, 5f, 5f); posicionArma.TryGetValue(new Tuple <string, float>(this.Scene.SceneName, 0), out posicionInicialArma); arma = new Arma(turretShotSize, Color.DarkGreen, 10, 250, posicionInicialArma); this.ActionOnTorre(mesh => { mesh.AutoTransform = false; }); }
public override void Init() { //En este ejemplo no cargamos un solo modelo 3D sino una escena completa, compuesta por varios modelos. //El framework posee varias escenas ya hechas en la carpeta TgcViewer\Examples\Media\MeshCreator\Scenes. var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Iglesia\\Iglesia-TgcScene.xml"); //Hacemos que la cámara esté centrada sobre la escena Camara = new TgcRotationalCamera(scene.BoundingBox.calculateBoxCenter(), scene.BoundingBox.calculateBoxRadius() * 2); }
public override void Init() { time = 0f; var d3dDevice = D3DDevice.Instance.Device; var MyShaderDir = ShadersDir + "WorkshopShaders\\"; //Crear loader var loader = new TgcSceneLoader(); // parallax oclussion scene = loader.loadSceneFromFile(MediaDir + "ModelosTgc\\Piso\\Piso-Custom-TgcScene.xml"); g_pBaseTexture = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\wood.bmp"); g_pHeightmap = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_four_height.tga"); g_pBaseTexture2 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\stones.bmp"); g_pHeightmap2 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_height_stones.tga"); g_pBaseTexture3 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\rocks.jpg"); g_pHeightmap3 = TextureLoader.FromFile(d3dDevice, MediaDir + "Texturas\\NM_height_rocks.tga"); mesh = scene.Meshes[0]; var adj = new int[mesh.D3dMesh.NumberFaces * 3]; mesh.D3dMesh.GenerateAdjacency(0, adj); mesh.D3dMesh.ComputeNormals(adj); //Cargar Shader string compilationErrors; effect = Effect.FromFile(d3dDevice, MyShaderDir + "Parallax.fx", null, null, ShaderFlags.None, null, out compilationErrors); if (effect == null) { throw new Exception("Error al cargar shader. Errores: " + compilationErrors); } lightDirModifier = AddVertex3f("LightDir", new TGCVector3(-1, -1, -1), TGCVector3.One, TGCVector3.Down); minSampleModifier = AddFloat("minSample", 1f, 10f, 10f); maxSampleModifier = AddFloat("maxSample", 11f, 50f, 50f); heightMapScaleModifier = AddFloat("HeightMapScale", 0.001f, 0.5f, 0.1f); //Centrar camara rotacional respecto a este mesh var rotCamera = new TgcRotationalCamera(mesh.BoundingBox.calculateBoxCenter(), mesh.BoundingBox.calculateBoxRadius() * 2, Input); rotCamera.CameraCenter = rotCamera.CameraCenter + new TGCVector3(0, 20f, 0); rotCamera.CameraDistance = 75; rotCamera.RotationSpeed = 50f; Camara = rotCamera; pom = false; phong = true; nro_textura = 0; }
public override void Init() { //Cargar escenario var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml"); //Camara en 1ra persona Camara = new TgcFpsCamera(new Vector3(260f, 170f, 390f), 400f, 300f, Input); //Cargar Shader personalizado de MultiDiffuseLights /* * Cargar Shader personalizado de MultiDiffuseLights * Este Shader solo soporta TgcMesh con RenderType DIFFUSE_MAP (que son las unicas utilizadas en este ejemplo) * El shader toma 4 luces a la vez para iluminar un mesh. * Pero como hacer 4 veces los calculos en el shader es costoso, de cada luz solo calcula el componente Diffuse. */ effect = TgcShaders.loadEffect(ShadersDir + "MultiDiffuseLights.fx"); //Crear 4 mesh para representar las 4 para la luces. Las ubicamos en distintas posiciones del escenario, cada una con un color distinto. lightMeshes = new TgcBox[4]; origLightPos = new Vector3[lightMeshes.Length]; var c = new Color[4] { Color.Red, Color.Blue, Color.Green, Color.Yellow }; for (var i = 0; i < lightMeshes.Length; i++) { var co = c[i % c.Length]; lightMeshes[i] = TgcBox.fromSize(new Vector3(10, 10, 10), co); lightMeshes[i].AutoTransformEnable = true; origLightPos[i] = new Vector3(-40, 20 + i * 20, 400); } //Modifiers Modifiers.addBoolean("lightEnable", "lightEnable", true); Modifiers.addBoolean("lightMove", "lightMove", true); Modifiers.addFloat("lightIntensity", 0, 150, 38); Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.15f); Modifiers.addColor("mEmissive", Color.Black); Modifiers.addColor("mDiffuse", Color.White); //Interpolador para mover las luces de un lado para el otro interp = new InterpoladorVaiven(); interp.Min = -200f; interp.Max = 200f; interp.Speed = 100f; interp.Current = 0f; }
public ShipObject(EnumShipType shipType, Vector3 initialPosition) { this.initialPosition = initialPosition; TgcScene scene = null; string urlMesh = ""; TgcSceneLoader loader = new TgcSceneLoader(); switch (shipType) { case EnumShipType.Standard: { //se crea un barco standard (el que usamos hasta ahora) this.shipType = shipType; urlMesh = Path.Combine(GuiController.Instance.AlumnoEjemplosMediaDir, @"BarcoPirata\BarcoPirata2-TgcScene.xml"); scene = loader.loadSceneFromFile(urlMesh); Scale(0.05f); } break; case EnumShipType.SS_Holigan: { this.shipType = shipType; urlMesh = Path.Combine(GuiController.Instance.AlumnoEjemplosMediaDir, @"BarcoPirata\SS Holigan-TgcScene.xml"); scene = loader.loadSceneFromFile(urlMesh); Scale(0.05f); } break; case EnumShipType.BlackPearl: { this.shipType = shipType; } break; default: break; } try { this.ship = scene.Meshes[0]; this.canon1 = scene.Meshes[1]; this.canon2 = scene.Meshes[2]; this.canon3 = scene.Meshes[3]; this.canon4 = scene.Meshes[4]; Position(initialPosition); RotateY((float)Math.PI / 2); } catch (Exception) { throw new Exception(); } }
public override void Init() { /* Cargar ecena que tiene un modelo configurado con AlphaBlending * Los modelos fueron exportados en 3Ds MAX con el mapa "Opacity" cargado en el "Material Editor" * Entonces el TgcSceneLoader automáticamente hace mesh.AlphaBlendEnable(true); */ var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Meshes\\Vegetacion\\Pino\\Pino-TgcScene.xml"); Camara = new TgcRotationalCamera(scene.BoundingBox.calculateBoxCenter(), scene.BoundingBox.calculateBoxRadius() * 2); }
/// <summary> /// Crear Mesh para el nuevo cliente conectado /// </summary> private void crearMeshOtroCliente(VehiculoData vehiculoData) { //Cargar mesh TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile(vehiculoData.meshPath); TgcMesh mesh = scene.Meshes[0]; otrosMeshes.Add(vehiculoData.playerID, mesh); //Ubicarlo en escenario mesh.AutoTransformEnable = false; mesh.Transform = Matrix.Translation(vehiculoData.initialPos); }
public void Iniciar(TgcScene naves, Vector3 posicionObjetivo) { this.Modelo = naves.Meshes[0]; this.Modelo.Position = new Vector3(499, 100, 499); posicionInicial = this.Modelo.Position; RotacionOriginal = new Vector3(0, 0, -1); MatrizRotacion = Matrix.Identity; TiempoParado = 0F; TiempoRecarga = 1f; }
public override void Init() { //Carga del mesh del arma TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Meshes\\svd\\svd-TgcScene.xml"); mesh = scene.Meshes[0]; weaponSoundDir = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Audio/Armas/Sniper.wav"; WEAPON_OFFSET = new Vector3(5f, -10.2f, 0.8f); WEAPON_ORIENTATION_Y = 0.1f; scaleMuzzle = new Vector3(0.0002f, 0.0002f, 0.0002f); base.Init(); }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //En este ejemplo no cargamos un solo modelo 3D sino una escena completa, compuesta por varios modelos. //El framework posee varias escenas ya hechas en la carpeta TgcViewer\Examples\Media\MeshCreator\Scenes. TgcSceneLoader loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Iglesia\\Iglesia-TgcScene.xml"); //Hacemos que la cámara esté centrada sobre la escena GuiController.Instance.RotCamera.targetObject(scene.BoundingBox); }
public override void Init() { //Cargar escenario var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml"); //Cargar mesh con animaciones var skeletalLoader = new TgcSkeletalLoader(); skeletalMesh = skeletalLoader.loadMeshAndAnimationsFromFile( MediaDir + "SkeletalAnimations\\Robot\\Robot-TgcSkeletalMesh.xml", new[] { MediaDir + "SkeletalAnimations\\Robot\\Parado-TgcSkeletalAnim.xml" }); //Configurar animacion inicial skeletalMesh.playAnimation("Parado", true); //Corregir normales skeletalMesh.computeNormals(); //Pongo al mesh en posicion, activo e AutoTransform skeletalMesh.AutoTransformEnable = true; skeletalMesh.Position = new Vector3(0, 0, 100); skeletalMesh.rotateY(FastMath.PI); //Camara en 1ra persona Camara = new TgcFpsCamera(new Vector3(250, 140, 150), Input); //Mesh para la luz lightMesh = TgcBox.fromSize(new Vector3(10, 10, 10)); //Pongo al mesh en posicion, activo e AutoTransform lightMesh.AutoTransformEnable = true; lightMesh.Position = new Vector3(0, 150, 150); //Modifiers de la luz Modifiers.addBoolean("lightEnable", "lightEnable", lightMesh.Enabled); Modifiers.addVertex3f("lightPos", new Vector3(-200, -100, -200), new Vector3(200, 200, 300), lightMesh.Position); Modifiers.addColor("lightColor", lightMesh.Color); Modifiers.addFloat("lightIntensity", 0, 150, 20); Modifiers.addFloat("lightAttenuation", 0.1f, 2, 0.3f); Modifiers.addFloat("specularEx", 0, 20, 9f); //Modifiers de material Modifiers.addColor("mEmissive", Color.Black); Modifiers.addColor("mAmbient", Color.White); Modifiers.addColor("mDiffuse", Color.White); Modifiers.addColor("mSpecular", Color.White); }
public ElementoMapa(String escena, Vector3 posicion, Vector3 direccion) { var loader = new TgcSceneLoader(); string alumnoMediaFolder = GuiController.Instance.AlumnoEjemplosDir; this.escena = loader.loadSceneFromFile(alumnoMediaFolder + "CucarachaJugosita\\Media\\" + escena); mesh = this.escena.Meshes[0]; mesh.Position = posicion; Vector3 direc = direccion - posicion; direc.Y = 0; direc.Normalize(); mesh.rotateY((float)Math.Atan2(direc.X, direc.Z) - mesh.Rotation.Y - Geometry.DegreeToRadian(180f)); }
public void Init(TgcScene _escenaNave, float nivelDelAgua) { escenaNave = _escenaNave; //escalaBase = TGCMatrix.Scaling(new TGCVector3(0.2f, 0.2f, 0.2f)); foreach (var mesh in escenaNave.Meshes) { if (mesh == null) { break; } mesh.Position += new TGCVector3(0, nivelDelAgua - 10, 0); mesh.Transform = TGCMatrix.Translation(mesh.Position); } }
/// <summary> /// Recibe el nombre de un mesh original y retorna una instancia. Si ese mesh no esta cargado, /// lo busca en [Location]\[name]\[name]-TgcScene.xml /// </summary> /// <param name="name"></param> /// <returns></returns> public TgcMesh newMeshInstanceOf(string name) { if (!meshes.ContainsKey(name)) { string path = Location + name + "\\" + name + "-TgcScene.xml"; TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile(path); scene.Meshes[0].Name = name; meshes.Add(name, scene.Meshes[0]); } return(instanceOf(meshes[name])); }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //Crear loader TgcSceneLoader loader = new TgcSceneLoader(); //Configurar MeshFactory customizado loader.MeshFactory = new CustomMeshShaderFactory(); //Cargar mesh //TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Olla\\Olla-TgcScene.xml"); //mesh = (TgcMeshShader)scene.Meshes[0]; //Cargar mesh TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Kamikaze3D\\Patrulla\\autoPoliciaEnEscenario-TgcScene.xml"); mesh = (TgcMeshShader)scene.Meshes[0]; //Cargar Shader de PhonhShading string compilationErrors; mesh.Effect = Effect.FromFile(d3dDevice, GuiController.Instance.ExamplesMediaDir + "Shaders\\PhongShading.fx", null, null, ShaderFlags.None, null, out compilationErrors); if (mesh.Effect == null) { throw new Exception("Error al cargar shader. Errores: " + compilationErrors); } //Configurar Technique mesh.Effect.Technique = "DefaultTechnique"; //Agregar evento para cargar valores de shader mesh.ShaderBegin += new TgcMeshShader.ShaderBeginHandler(mesh_ShaderBegin); //Modifier para variables de shader GuiController.Instance.Modifiers.addVertex3f("LightPosition", new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000), new Vector3(0, 400, 0)); GuiController.Instance.Modifiers.addColor("AmbientColor", Color.White); GuiController.Instance.Modifiers.addColor("DiffuseColor", Color.Green); GuiController.Instance.Modifiers.addColor("SpecularColor", Color.Red); GuiController.Instance.Modifiers.addFloat("SpecularPower", 1, 100, 16); GuiController.Instance.Modifiers.addVertex3f("MeshPos", new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000), new Vector3(0, 0, 0)); //Crear caja para indicar ubicacion de la luz lightBox = TgcBox.fromSize(new Vector3(50, 50, 50), Color.Yellow); //Centrar camara rotacional respecto a este mesh GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox); }
public Light(string path) { TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile(path); meshes = scene.Meshes; foreach (TgcMesh mesh in meshes) { mesh.AutoTransform = false; mesh.Effect = TgcShaders.loadEffect(GlobalConcepts.GetInstance().GetShadersDir() + "Faros.fx"); mesh.Technique = "Normal"; } this.matrix = TGCMatrix.Identity; }
public void Init(TgcScene escena) { escenaMesa = escena; foreach (var mesh in escenaMesa.Meshes) { if (mesh == null) { break; } mesh.Scale = new TGCVector3(0.07f, 0.07f, 0.07f); mesh.Position = new TGCVector3(0, 15, 97); mesh.Transform = TGCMatrix.Scaling(mesh.Scale) * TGCMatrix.Translation(mesh.Position); } }
/// ///////////////////////////////////////////////////////////////////// /// ////////////////////////////INIT///////////////////////////////////// /// ///////////////////////////////////////////////////////////////////// public void init(string MediaDir, string shaderDir, TgcCamera camara) { var d3dDevice = D3DDevice.Instance.Device; resolucionX = d3dDevice.PresentationParameters.BackBufferWidth; resolucionY = d3dDevice.PresentationParameters.BackBufferHeight; var loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(MediaDir + "ParadigmasEscena\\nivelParadigmas-TgcScene.xml"); pathDeLaCancion = MediaDir + "Musica\\FeverTime.mp3"; var skeletalLoader = new TgcSkeletalLoader(); personajePrincipal = skeletalLoader.loadMeshAndAnimationsFromFile( MediaDir + "Robot\\Robot-TgcSkeletalMesh.xml", MediaDir + "Robot\\", new[] { MediaDir + "Robot\\Caminando-TgcSkeletalAnim.xml", MediaDir + "Robot\\Parado-TgcSkeletalAnim.xml", }); personajePrincipal.playAnimation("Parado", true); personajePrincipal.Position = new TGCVector3(210, 1, 310); personajePrincipal.RotateY(Geometry.DegreeToRadian(180)); camaraInterna = new TgcThirdPersonCamera(personajePrincipal.Position, 250, 500); camaraInterna.rotateY(Geometry.DegreeToRadian(180)); HUD = new Sprite(D3DDevice.Instance.Device); vida = TgcTexture.createTexture(MediaDir + "Textures\\vida.png"); mumuki = TgcTexture.createTexture(MediaDir + "Textures\\iconoMumuki.png"); coleccionablesAdquiridos = new Boton(cantidadColeccionablesAgarrados.ToString(), 0.9f, 0.88f, null); SetearListas(); AplicarShaders(shaderDir); scene.Meshes.Add(charcoEstatic1); scene.Meshes.Add(charcoEstatic2); scene.Meshes.Add(charcoEstatic3); reproductorMp3.FileName = pathDeLaCancion; reproductorMp3.play(true); AdministradorDeEscenarios.getSingleton().SetCamara(camaraInterna); }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; MyMediaDir = GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Media\\"; MyShaderDir = GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Shaders\\"; GuiController.Instance.CustomRenderEnabled = true; //Crear loader TgcSceneLoader loader = new TgcSceneLoader(); // ------------------------------------------------------------ //Cargar la escena scene = loader.loadSceneFromFile(MyMediaDir + "shadowTest\\ShadowTest-TgcScene.xml"); scene2 = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\AvionCaza\\AvionCaza-TgcScene.xml"); avion = scene2.Meshes[0]; avion.Scale = new Vector3(0.1f, 0.1f, 0.1f); avion.Position = new Vector3(100f, 100f, 0f); avion.AutoTransformEnable = false; dir_avion = new Vector3(0, 0, 1); GuiController.Instance.RotCamera.CameraCenter = new Vector3(0, 0, 0); GuiController.Instance.RotCamera.CameraDistance = 50; GuiController.Instance.RotCamera.RotationSpeed = 50f; GuiController.Instance.RotCamera.updateCamera(); //Cargar Shader personalizado effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesDir + "Shaders\\WorkshopShaders\\Shaders\\PlanarShadows.fx"); // le asigno el efecto a las mallas foreach (TgcMesh T in scene.Meshes) { T.Scale = new Vector3(1f, 1f, 1f); T.Effect = effect; } avion.Effect = effect; box = new TgcBox(); box.Color = Color.Yellow; GuiController.Instance.RotCamera.targetObject(scene.Meshes[0].BoundingBox); float K = 300; GuiController.Instance.Modifiers.addVertex3f("LightLookFrom", new Vector3(-K, -K, -K), new Vector3(K, K, K), new Vector3(80, 120, 0)); }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //Activamos el renderizado customizado. De esta forma el framework nos delega control total sobre como dibujar en pantalla //La responsabilidad cae toda de nuestro lado GuiController.Instance.CustomRenderEnabled = true; //Creamos un FullScreen Quad screenQuad = new TgcScreenQuad(); //Creamos un Render Targer sobre el cual se va a dibujar toda la escena original int backBufferWidth = d3dDevice.PresentationParameters.BackBufferWidth; int backBufferHeight = d3dDevice.PresentationParameters.BackBufferHeight; sceneRT = new Texture(d3dDevice, backBufferWidth, backBufferHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); //Definimos el tamaño de una textura que sea de 1/4 x 1/4 de la original, y que sean divisibles por 8 para facilitar los calculos de sampleo int cropWidth = (backBufferWidth - backBufferWidth % 8) / 4; int cropHeight = (backBufferHeight - backBufferHeight % 8) / 4; //Creamos un Render Target para auxiliar para almacenar la pasada horizontal de blur blurTempRT = new Texture(d3dDevice, cropWidth, cropHeight, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default); //Cargar shader con efectos de Post-Procesado effect = TgcShaders.loadEffect(GuiController.Instance.ExamplesMediaDir + "Shaders\\GaussianBlur.fx"); //Configurar Technique dentro del shader effect.Technique = "GaussianBlurPass"; //Cargamos un escenario TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Scenes\\Deposito\\Deposito-TgcScene.xml"); meshes = scene.Meshes; //Camara en primera personas GuiController.Instance.FpsCamera.Enable = true; GuiController.Instance.FpsCamera.MovementSpeed *= 2; GuiController.Instance.FpsCamera.setCamera(new Vector3(-182.3816f, 82.3252f, -811.9061f), new Vector3(-182.0957f, 82.3147f, -810.9479f)); //Modifier para activar/desactivar efecto GuiController.Instance.Modifiers.addBoolean("activar_efecto", "Activar efecto", true); GuiController.Instance.Modifiers.addFloat("deviation", 1, 5, 1); }
private void initMeshes() { //Crear SkyBox skyBox = new TgcSkyBox(); skyBox.Center = new TGCVector3(0, 500, 0); skyBox.Size = new TGCVector3(10000, 10000, 10000); var texturesPath = MediaDir + "Textures\\SkyBox LostAtSea" + (dia ? "Day\\" : "Night\\"); skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Up, texturesPath + "lostatseaday_up.jpg"); skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Down, texturesPath + "lostatseaday_dn.jpg"); skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Left, texturesPath + "lostatseaday_lf.jpg"); skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Right, texturesPath + "lostatseaday_rt.jpg"); skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Front, texturesPath + "lostatseaday_bk.jpg"); skyBox.setFaceTexture(TgcSkyBox.SkyFaces.Back, texturesPath + "lostatseaday_ft.jpg"); skyBox.Init(); Microsoft.DirectX.Direct3D.Effect customShaders = TGCShaders.Instance.LoadEffect(ShadersDir + "CustomShaders.fx"); //cargar escena escena = new TgcSceneLoader().loadSceneFromFile(MediaDir + "Cancha-TgcScene.xml"); pasto = new Pasto(escena.Meshes[0], customShaders.Clone(D3DDevice.Instance.Device), 20, .5f); TgcMesh meshTurbo = escena.getMeshByName("Turbo"); turbos = new List <Turbo>() { new Turbo(meshTurbo, new TGCVector3(80, -.2f, 100)), new Turbo(meshTurbo, new TGCVector3(-80, -.2f, -100)), new Turbo(meshTurbo, new TGCVector3(80, -.2f, -100)), new Turbo(meshTurbo, new TGCVector3(-80, -.2f, 100)), new Turbo(meshTurbo, new TGCVector3(0, -.2f, 130)), new Turbo(meshTurbo, new TGCVector3(0, -.2f, -130)), new Turbo(meshTurbo, new TGCVector3(0, -.2f, 250)), new Turbo(meshTurbo, new TGCVector3(0, -.2f, -250)), new Turbo(meshTurbo, new TGCVector3(220, -.2f, 0), 100), new Turbo(meshTurbo, new TGCVector3(-220, -.2f, 0), 100), new Turbo(meshTurbo, new TGCVector3(220, -.2f, 300), 100), new Turbo(meshTurbo, new TGCVector3(-220, -.2f, -300), 100), new Turbo(meshTurbo, new TGCVector3(-220, -.2f, 300), 100), new Turbo(meshTurbo, new TGCVector3(220, -.2f, -300), 100) }; foreach (TgcMesh mesh in escena.Meshes) { mesh.Effect = customShaders.Clone(D3DDevice.Instance.Device); mesh.Technique = "BlinnPhong"; } }
public void init(TgcThirdPersonCamera camara, Personaje personaje) { this.camara = camara; this.personaje = personaje; //Crear loader TgcSceneLoader loader = new TgcSceneLoader(); this.scene = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Kamikaze3D\\Explosion\\Explosion-TgcScene.xml"); foreach (TgcMesh mesh in this.scene.Meshes) { mesh.Scale = new Vector3(0, 0, 0); } }
public Niebla(GameModel gm) { effect = TgcShaders.loadEffect(gm.ShadersDir + "TgcFogShader.fx"); fog = new TgcFog(); fog.Enabled = true; fog.StartDistance = 500f; fog.EndDistance = 2000f; fog.Density = 0.025f; fog.Color = Color.Gray; fogShader = false; skyBox = gm.SkyBox; mapScene = gm.MapScene; //bosqueScene = gm.BosqueScene; //ahora cargo todo en el efecto de directX }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; for (int i = 0; i < 100; i++) { TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vegetacion\\Palmera\\Palmera-TgcScene.xml"); scene.disposeAll(); } TgcSceneLoader loader1 = new TgcSceneLoader(); scene1 = loader1.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vegetacion\\Palmera\\Palmera-TgcScene.xml"); }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //Cargar modelo estatico TgcSceneLoader loader = new TgcSceneLoader(); TgcScene scene = loader.loadSceneFromFile( GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vehiculos\\Buggy\\Buggy-TgcScene.xml"); mesh = scene.Meshes[0]; //Alejar camara rotacional segun tamaño del BoundingBox del objeto GuiController.Instance.RotCamera.targetObject(mesh.BoundingBox); }
public Puerta(String alumnoMediaFolder, Vector3 posicion, Vector3 escala, Vector3 rotation) { this.girando = false; this.loader = new TgcSceneLoader(); this.angulo = 1.6f; this.abierta = false; TgcScene escena = loader.loadSceneFromFile(alumnoMediaFolder + "GODMODE\\Media\\puerta-TgcScene.xml", alumnoMediaFolder + "GODMODE\\Media\\"); anguloOriginal = rotation.Y; this.mesh = escena.Meshes[0]; this.mesh.Position = posicion; this.mesh.Scale = escala; this.mesh.Rotation = rotation; }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; /* Cargar ecena que tiene un modelo configurado con AlphaBlending * Los modelos fueron exportados en 3Ds MAX con el mapa "Opacity" cargado en el "Material Editor" * Entonces el TgcSceneLoader automáticamente hace mesh.AlphaBlendEnable(true); */ TgcSceneLoader loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Meshes\\Vegetacion\\Pino\\Pino-TgcScene.xml"); GuiController.Instance.RotCamera.targetObject(scene.BoundingBox); }
private TGCVector3 PlaceSceneLine(TgcScene escena, TGCVector3 posicion, TGCVector3 escalador, int repeticiones, int mesh_pivot, float distancia_extra, TGCVector3 rotacion, bool shader, bool escenaBomba, bool escenaBombaRotada)//agrega la scene al render //la rotacion es muy limitada solo queda bien en pi/2 o pi y aun asi solo en ciertos casos, estoy trabajando en un nuevo metodo //el mesh pivot es para elegir cual de las meshes es el que va a usar de separador { List <ListaMeshPosicionada> todas_escenas = new List <ListaMeshPosicionada>();//tengo que devolverlos como list de list ya que tgcscene no soporta que le agregue meshes for (int i = 0; i < repeticiones; i++) { todas_escenas.Add(new ListaMeshPosicionada()); TGCVector3 nuevaPosicion = posicion; for (int j = 0; j < escena.Meshes.Count; j++) { TgcMesh mesh = escena.Meshes[j]; TgcMesh meshClonado = mesh.clone(mesh.Name); todas_escenas[i].lista.Add(meshClonado); meshClonado.AutoTransformEnable = false; TGCMatrix matrizRotacion = TGCMatrix.RotationYawPitchRoll(rotacion.Y, rotacion.X, rotacion.Z); TGCMatrix matrizPosicion = TGCMatrix.Translation(posicion); meshClonado.Transform = TGCMatrix.Scaling(escalador) * matrizRotacion * matrizPosicion; if (j == mesh_pivot) { todas_escenas[i].posicion = posicion; nuevaPosicion = new TGCVector3(posicion.X, posicion.Y, posicion.Z - meshClonado.BoundingBox.calculateSize().Z *escalador.Z - distancia_extra); } } if (escenaBomba) { CollisionObjectsPrincipales(posicion.Z, escenaBombaRotada); } posicion = nuevaPosicion; } //Shader if (shader) { AddListListMeshToMainShadow(todas_escenas); } else { AddListListMeshToMain(todas_escenas); } return(posicion); }