public override void Init() { //Crear esfera sphere = new TgcSphere(); //No recomendamos utilizar AutoTransformEnable, con juegos complejos se pierde el control. sphere.AutoTransformEnable = true; currentTexture = null; //Modifiers para vararis sus parametros Modifiers.addEnum("base", typeof(TgcSphere.eBasePoly), TgcSphere.eBasePoly.ICOSAHEDRON); Modifiers.addBoolean("inflate", "yes", true); Modifiers.addInterval("level of detail", new object[] { 0, 1, 2, 3, 4 }, 2); Modifiers.addBoolean("edges", "show", false); Modifiers.addFloat("radius", 0, 100, 10); Modifiers.addVertex3f("position", new Vector3(-100, -100, -100), new Vector3(100, 100, 100), new Vector3(0, 0, 0)); Modifiers.addVertex3f("rotation", new Vector3(-180, -180, -180), new Vector3(180, 180, 180), new Vector3(0, 0, 0)); Modifiers.addBoolean("Use texture", "yes", true); Modifiers.addTexture("texture", MediaDir + "\\Texturas\\madera.jpg"); Modifiers.addVertex2f("offset", new Vector2(-0.5f, -0.5f), new Vector2(0.9f, 0.9f), new Vector2(0, 0)); Modifiers.addVertex2f("tiling", new Vector2(0.1f, 0.1f), new Vector2(4, 4), new Vector2(1, 1)); Modifiers.addColor("color", Color.White); Modifiers.addBoolean("boundingsphere", "show", false); UserVars.addVar("Vertices"); UserVars.addVar("Triangulos"); Camara = new TgcRotationalCamera(Vector3.Empty, 50f, Input); }
public override void init() { TgcSceneLoader loader = new TgcSceneLoader(); scene = loader.loadSceneFromFile(sceneFolder + "PuebloJapones\\PuebloJapones-TgcScene.xml"); //mainCarMesh = loader.loadSceneFromFile(mediaFolder + "meshes\\objects\\Auto\\Auto-TgcScene.xml").Meshes[0]; //mainCar = new Auto(mainCarMesh); objetosColisionables.Clear(); foreach (TgcMesh mesh in scene.Meshes) { objetosColisionables.Add(mesh.BoundingBox); } collisionManager = new SphereCollisionManager(); collisionManager.GravityEnabled = true; collisionManager.GravityForce = new Vector3(0, -1, 0); sphere = new TgcSphere(); sphere.Radius = 5; sphere.Position = new Vector3(0, 10, 0); sphere.setColor(Color.Blue); Vector3 movementVector = Vector3.Empty; //GuiController.Instance: acceso principal a todas las herramientas del Framework //Device de DirectX para crear primitivas Device d3dDevice = GuiController.Instance.D3dDevice; GuiController.Instance.RotCamera.CameraDistance = 100; //initCarCamera(); }
public void initializeEnviroment() { //Acceso a Device de DirectX. Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice; totalTime = 0; //OCEAN ocean = new TgcEditableLand(); ocean.setTexture(TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Textures\\environment\\water_texture.jpg")); ocean.Position = oceanPosition; ocean.Scale = new Vector3(20, 20, 20); //SUN sun = new TgcSphere(); sun.Radius = 20; sun.setColor(Color.Yellow); sun.setTexture(TgcTexture.createTexture(d3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "Textures\\environment\\sun.jpg")); sun.Position = new Vector3(0, 300, 0); sun.LevelOfDetail = 4; sun.updateValues(); //SKY TgcTexture skyTexture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "Textures\\environment\\sky_patten.jpg"); skyBox = new TgcSphere(); skyBox.Radius = (int)GuiController.Instance.Modifiers["skyRadius"]; skyBox.setTexture(skyTexture); skyBox.Position = (Vector3)GuiController.Instance.Modifiers["skyPosition"]; skyBox.LevelOfDetail = 4; skyBox.updateValues(); }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //Crear esfera sphere = new TgcSphere(); currentTexture = null; //Modifiers para vararis sus parametros GuiController.Instance.Modifiers.addEnum("base", typeof(TgcSphere.eBasePoly), TgcSphere.eBasePoly.ICOSAHEDRON); GuiController.Instance.Modifiers.addBoolean("inflate", "yes", true); GuiController.Instance.Modifiers.addInterval("level of detail", new object[] { 0, 1, 2, 3, 4 }, 2); GuiController.Instance.Modifiers.addBoolean("edges", "show", false); GuiController.Instance.Modifiers.addFloat("radius", 0, 100, 10); GuiController.Instance.Modifiers.addVertex3f("position", new Vector3(-100, -100, -100), new Vector3(100, 100, 100), new Vector3(0, 0, 0)); GuiController.Instance.Modifiers.addVertex3f("rotation", new Vector3(-180, -180, -180), new Vector3(180, 180, 180), new Vector3(0, 0, 0)); GuiController.Instance.Modifiers.addBoolean("Use texture", "yes", true); GuiController.Instance.Modifiers.addTexture("texture", GuiController.Instance.ExamplesMediaDir + "\\Texturas\\madera.jpg"); GuiController.Instance.Modifiers.addVertex2f("offset", new Vector2(-0.5f, -0.5f), new Vector2(0.9f, 0.9f), new Vector2(0, 0)); GuiController.Instance.Modifiers.addVertex2f("tiling", new Vector2(0.1f, 0.1f), new Vector2(4, 4), new Vector2(1, 1)); GuiController.Instance.Modifiers.addColor("color", Color.White); GuiController.Instance.Modifiers.addBoolean("boundingsphere", "show", false); GuiController.Instance.UserVars.addVar("Vertices"); GuiController.Instance.UserVars.addVar("Triangulos"); GuiController.Instance.RotCamera.CameraDistance = 50; }
public void IniciarAlcanceInteraccionEsfera() { alcanceInteraccionEsfera = new TgcSphere(); alcanceInteraccionEsfera.setColor(Color.White); alcanceInteraccionEsfera.Radius = 70; alcanceInteraccionEsfera.Position = mesh.Position; alcanceInteraccionEsfera.updateValues(); }
public void IniciarBoundingEsfera() { //Esta esfera seria el "bounding box" del personaje boundingEsfera = new TgcSphere(); boundingEsfera.setColor(Color.SkyBlue); boundingEsfera.Radius = 60; boundingEsfera.Position = mesh.Position; boundingEsfera.updateValues(); }
public Pelota(TgcSphere sphere) { this.sphere = sphere; //apago el auto transformado, ya que la pelota lo maneja solo this.sphere.AutoTransformEnable = false; this.sphere.Transform = this.getScalingMatrix() * Matrix.Translation(this.sphere.Position); this.sphere.updateValues(); this.box = TgcBox.fromSize(sphere.Position, new Vector3(this.Diametro, this.Diametro, this.Diametro)); this.posicionOriginalSphere = new Vector3(this.sphere.Position.X, this.sphere.Position.Y, this.sphere.Position.Z); this.posicionOriginalBox = new Vector3(this.box.Position.X, this.box.Position.Y, this.box.Position.Z); }
public Pelota CrearPelota(string pathRecursos) { int radio = 10; //Crear esfera TgcSphere sphere = new TgcSphere(); sphere.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall)); sphere.Radius = radio; sphere.Position = new Vector3(50, 25, 0); sphere.updateValues(); return new Pelota(sphere); }
/// <summary> /// Iniciar la creacion /// </summary> public override void initCreation(Vector3 gridPoint) { initSelectionPoint = gridPoint; //Crear caja inicial TgcTexture sphereTexture = TgcTexture.createTexture(Control.getCreationTexturePath()); mesh = new TgcSphere(); mesh.setTexture(sphereTexture); // mesh.BoundingSphere.setRenderColor(MeshCreatorUtils.UNSELECTED_OBJECT_COLOR); bb.setRenderColor(MeshCreatorUtils.UNSELECTED_OBJECT_COLOR); this.Layer = Control.CurrentLayer; }
public Pelota CrearPelota(string pathRecursos) { int radio = 10; //Crear esfera TgcSphere sphere = new TgcSphere(); sphere.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall)); sphere.Radius = radio; sphere.Position = new Vector3(50, 25, 0); sphere.updateValues(); return(new Pelota(sphere)); }
public MenuInicial(string pathRecursos, TgcThirdPersonCamera camara, EjemploAlumno main) { this.main = main; this.camara = camara; this.drawer2D = new Drawer2D(); //Titulo this.titulo = new TgcText2D(); this.titulo.Text = "Socketes"; this.titulo.Color = Color.White; this.titulo.Align = TgcText2D.TextAlign.CENTER; this.titulo.Position = new Point(280, 0); this.titulo.Size = new Size(400, 100); this.titulo.changeFont(new System.Drawing.Font("Arial", 35)); //Brazuca this.pelota = new TgcSphere(); //TODO cambiar por matrices this.pelota.AutoTransformEnable = true; this.pelota.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall)); this.pelota.Radius = 2.5f; this.pelota.LevelOfDetail = 4; this.pelota.Position = new Vector3(3, 0, -4); this.pelota.updateValues(); //Cancha donde esta la pelota this.cancha = TgcBox.fromSize(new Vector3(20, 0, 20), TgcTexture.createTexture(pathRecursos + Settings.Default.textureMenuField)); //TODO cambiar por matrices this.cancha.AutoTransformEnable = true; this.cancha.Position = new Vector3(0, -2.5f, 0); //Menu this.menus = new List <MenuItem>(); this.menus.Add(new MenuItem("picadito", new Vector3(-5, 2, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.texturePicadito1, pathRecursos + Settings.Default.texturePicadito2)); this.menus.Add(new MenuItem("configuracion", new Vector3(-5, 0.8f, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.textureControles1, pathRecursos + Settings.Default.textureControles2)); this.menus.Add(new MenuItem("salir", new Vector3(-5, -0.4f, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.textureSalir1, pathRecursos + Settings.Default.textureSalir2)); this.menus[0].Select(); //Menu de configuracion //Crear Sprite this.panelConfiguracion = new CustomSprite(); this.panelConfiguracion.Bitmap = new CustomBitmap(pathRecursos + Settings.Default.texturePanelcontroles, D3DDevice.Instance.Device); this.panelConfiguracion.Scaling = new Vector2(0.75f, 0.75f); Size textureSize = this.panelConfiguracion.Bitmap.Size; this.panelConfiguracion.Position = new Vector2(FastMath.Max(D3DDevice.Instance.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(D3DDevice.Instance.Height / 2 - textureSize.Height / 2, 0)); }
public static bool EsferaColisionaCuadrado(TgcSphere esfera, TgcBoundingBox cuadrado) { // Hacemos el test float s = 0; float d = 0; // Comprobamos si el centro de la esfera está dentro del AABB if (IsPointInsideAABB(esfera.Position, cuadrado)) { return(true); } // Comprobamos si la esfera y el AABB se intersectan if (esfera.Position.X < cuadrado.PMin.X) { s = esfera.Position.X - cuadrado.PMin.X; d += s * s; } else if (esfera.Position.X > cuadrado.PMax.X) { s = esfera.Position.X - cuadrado.PMax.X; d += s * s; } if (esfera.Position.Y < cuadrado.PMin.Y) { s = esfera.Position.Y - cuadrado.PMin.Y; d += s * s; } else if (esfera.Position.Y > cuadrado.PMax.Y) { s = esfera.Position.Y - cuadrado.PMax.Y; d += s * s; } if (esfera.Position.Z < cuadrado.PMin.Z) { s = esfera.Position.Z - cuadrado.PMin.Z; d += s * s; } else if (esfera.Position.Z > cuadrado.PMax.Z) { s = esfera.Position.Z - cuadrado.PMax.Z; d += s * s; } return(d <= esfera.Radius * esfera.Radius); }
public MenuInicial(string pathRecursos, TgcThirdPersonCamera camara, EjemploAlumno main) { this.main = main; this.camara = camara; this.drawer2D = new Drawer2D(); //Titulo this.titulo = new TgcText2D(); this.titulo.Text = "Socketes"; this.titulo.Color = Color.White; this.titulo.Align = TgcText2D.TextAlign.CENTER; this.titulo.Position = new Point(280, 0); this.titulo.Size = new Size(400, 100); this.titulo.changeFont(new System.Drawing.Font("Arial", 35)); //Brazuca this.pelota = new TgcSphere(); //TODO cambiar por matrices this.pelota.AutoTransformEnable = true; this.pelota.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall)); this.pelota.Radius = 2.5f; this.pelota.LevelOfDetail = 4; this.pelota.Position = new Vector3(3, 0, -4); this.pelota.updateValues(); //Cancha donde esta la pelota this.cancha = TgcBox.fromSize(new Vector3(20, 0, 20), TgcTexture.createTexture(pathRecursos + Settings.Default.textureMenuField)); //TODO cambiar por matrices this.cancha.AutoTransformEnable = true; this.cancha.Position = new Vector3(0, -2.5f, 0); //Menu this.menus = new List<MenuItem>(); this.menus.Add(new MenuItem("picadito", new Vector3(-5, 2, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.texturePicadito1, pathRecursos + Settings.Default.texturePicadito2)); this.menus.Add(new MenuItem("configuracion", new Vector3(-5, 0.8f, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.textureControles1, pathRecursos + Settings.Default.textureControles2)); this.menus.Add(new MenuItem("salir", new Vector3(-5, -0.4f, 0), new Vector3(8, 1, 0), pathRecursos + Settings.Default.textureSalir1, pathRecursos + Settings.Default.textureSalir2)); this.menus[0].Select(); //Menu de configuracion //Crear Sprite this.panelConfiguracion = new CustomSprite(); this.panelConfiguracion.Bitmap = new CustomBitmap(pathRecursos + Settings.Default.texturePanelcontroles, D3DDevice.Instance.Device); this.panelConfiguracion.Scaling = new Vector2(0.75f, 0.75f); Size textureSize = this.panelConfiguracion.Bitmap.Size; this.panelConfiguracion.Position = new Vector2(FastMath.Max(D3DDevice.Instance.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(D3DDevice.Instance.Height / 2 - textureSize.Height / 2, 0)); }
public TgcSphere CrearPelota(string pathRecursos, Vector3 position, TgcTexture texturaPelota) { float radio = 1; //Crear esfera TgcSphere sphere = new TgcSphere(); //TODO cambiar por matrices sphere.AutoTransformEnable = true; sphere.setTexture(texturaPelota); sphere.Radius = radio; sphere.Position = position; sphere.updateValues(); return(sphere); }
public Municion(Vector3 barcoPos, Vector3 barcoFrente) { //Crear la esfera Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice; TgcSceneLoader loader = new TgcSceneLoader(); municion = new TgcSphere(); //string sphere = GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\Sphere\\Sphere-TgcScene.xml"; //esfera = loader.loadSceneFromFile(sphere).Meshes[0]; //esfera.changeDiffuseMaps(new TgcTexture[] { TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesDir + "Transformations\\SistemaSolar\\SunTexture.jpg") }); //updateSphere(); lifeTime = LIFETIME; sonidoShoot = (bool)Parametros.getModificador("sonidoCañon"); posicionDisparo(barcoPos, barcoFrente); setPosicionInicial(GuiController.Instance.ThirdPersonCamera.getPosition()); inicioDisparo = barcoPos; }
/// <summary> /// Creo la pelota en el centro de la cancha /// </summary> /// <param name="pathRecursos"> De donde saco la textura</param> /// <returns> Una pelota</returns> private Pelota CrearPelota(string pathRecursos, Cancha cancha) { //int radio = 10; Original int radio = 6; //Crear esfera TgcSphere sphere = new TgcSphere(); //TODO cambiar por matrices sphere.AutoTransformEnable = true; //sphere.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall)); sphere.Radius = radio; sphere.Position = new Vector3(cancha.Position.X, cancha.Position.Y + radio, cancha.Position.Z); sphere.updateValues(); Pelota pelota = new Pelota(sphere); pelota.ShadowEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshPlanarShadows.fx"); pelota.LightEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshMultiplePointLight.fx"); return(pelota); }
private void CrearEsferas() { this.esfera1 = new TgcSphere(); this.esfera1.setColor(Color.DarkSeaGreen); this.esfera1.Radius = 20; this.esfera1.Position = new Vector3(-40, 20, 100); //this.esfera.LevelOfDetail = 4; this.esfera1.Effect = this.effect; this.esfera1.Effect.SetValue("height_map", this.heightMap); this.esfera1.Technique = "VS2"; this.esfera1.updateValues(); this.esfera2 = new TgcSphere(); this.esfera2.setColor(Color.DarkSeaGreen); this.esfera2.Radius = 20; this.esfera2.Position = new Vector3(-40, 20, 10); //this.esfera.LevelOfDetail = 4; this.esfera2.Effect = this.effect; this.esfera2.Effect.SetValue("height_map", this.heightMap); this.esfera2.Technique = "VSP"; this.esfera2.updateValues(); }
public PowerUp(Vector3 pos) { interpolador = new InterpoladorVaiven(); interpolador.Current = 8; interpolador.Min = 7; interpolador.Max = 28; interpolador.Speed = 40f; esfera = new TgcSphere(); esfera.Position = pos; esfera.setColor(Color.Red); esfera.Radius = 10; esfera.LevelOfDetail = 3; esfera.AutoTransformEnable = true; esfera.updateValues(); tiempo = 10f; moto = null; }
public Bala(Vector3 pos, float anguloRotacion, float anguloElevacion, Canion canion, bool soyPlayer, float velBala, float g) { bullet = new TgcSphere(); bullet.setColor(Color.Black); bullet.Radius = RADIO; bullet.Position = pos; posicion = pos; bullet.LevelOfDetail = 1; this.anguloRotacion = anguloRotacion; this.anguloElevacion = anguloElevacion; this.speed = velBala; this.verticalAcceleration = g; bullet.updateValues(); bullet.AutoTransformEnable = false; this.canion = canion; canion.agregarBalaEnElAire(this); sombra = new TgcSphere(RADIO, Color.Black, new Vector3(pos.X, EjemploAlumno.Instance.alturaOla(pos), pos.Z)); sombra.updateValues(); sombra.AutoTransformEnable = false; sombra.Effect = EjemploAlumno.Instance.efectoSombra; sombra.Technique = "SombraBala"; //sombra.AlphaBlendEnable = true; salpicadura = new TgcCylinder(pos, RADIO, 10); salpicadura.Color = Color.White; salpicadura.UseTexture = true; salpicadura.setTexture(TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "4141-diffuse.jpg"));//"el-agua-cae-textura-del-fondo-11558332.jpg")); salpicadura.updateValues(); salpicadura.AutoTransformEnable = false; salpicadura.Effect = TgcShaders.loadEffect(GuiController.Instance.AlumnoEjemplosMediaDir + "shader agua.fx"); salpicadura.Technique = "SalpicaduraBala"; this.soyPlayer = soyPlayer; verticalSpeed = speed * (float)Math.Sin(anguloElevacion); }
/// <summary> /// Creo la pelota en el centro de la cancha /// </summary> /// <param name="pathRecursos"> De donde saco la textura</param> /// <returns> Una pelota</returns> private Pelota CrearPelota(string pathRecursos, Cancha cancha) { //int radio = 10; Original int radio = 6; //Crear esfera TgcSphere sphere = new TgcSphere(); //TODO cambiar por matrices sphere.AutoTransformEnable = true; //sphere.setTexture(TgcTexture.createTexture(pathRecursos + Settings.Default.textureBall)); sphere.Radius = radio; sphere.Position = new Vector3(cancha.Position.X, cancha.Position.Y + radio, cancha.Position.Z); sphere.updateValues(); Pelota pelota = new Pelota(sphere); pelota.ShadowEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshPlanarShadows.fx"); pelota.LightEffect = TgcShaders.loadEffect(pathRecursos + "Shaders\\MeshMultiplePointLight.fx"); return pelota; }
public TgcSphere CrearPelota(string pathRecursos, Vector3 position, TgcTexture texturaPelota) { float radio = 1; //Crear esfera TgcSphere sphere = new TgcSphere(); //TODO cambiar por matrices sphere.AutoTransformEnable = true; sphere.setTexture(texturaPelota); sphere.Radius = radio; sphere.Position = position; sphere.updateValues(); return sphere; }