public void init(string text) { TgcBox box = new TgcBox(); box.setExtremes(new Vector3(0, 0, 0), new Vector3(400, 2, 1000)); box.Color = Color.Blue; box.updateValues(); TgcMesh temp = box.toMesh("water"); TgcSceneLoader loader = new TgcSceneLoader(); //Configurar MeshFactory customizado loader.MeshFactory = new ShadedMeshFactory(); mesh = (ShadedMesh)loader.MeshFactory.createNewMesh(temp.D3dMesh, "water", TgcMesh.MeshRenderType.VERTEX_COLOR); mesh.BoundingBox = box.BoundingBox; mesh.loadEffect("Shaders//water.fx", "Basic"); mesh.AutoUpdateBoundingBox = false; TgcTexture t_temp = TgcTexture.createTexture(GuiController.Instance.D3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "RenderizameLaBanera\\waterbump.dds");//"perlin_noise.jpg");//"waterbump.dds"); noise = t_temp.D3dTexture; t_temp = TgcTexture.createTexture(GuiController.Instance.D3dDevice, GuiController.Instance.AlumnoEjemplosMediaDir + "RenderizameLaBanera\\" + text); riverBottom = t_temp.D3dTexture; mesh.Effect.SetValue("xNoiseTex", noise); mesh.Effect.SetValue("xRiverBottom", riverBottom); Surface renderTarget = GuiController.Instance.D3dDevice.GetRenderTarget(0); riverReflex = new Texture(GuiController.Instance.D3dDevice, renderTarget.Description.Width, renderTarget.Description.Height, 1, Usage.RenderTarget, renderTarget.Description.Format, Pool.Default); }
public static void ChangeTextureColor(TgcMesh mesh, string newColor) { TgcTexture[] diffuseMaps = mesh.DiffuseMaps; string newTexturePath = ""; int index = 0; foreach (TgcTexture texture in diffuseMaps) { if (texture.FileName.Contains("Car Material")) { newTexturePath = texture.FilePath; break; } index++; } string oldColor = newTexturePath.Split('\\')[5].Split(' ')[2].Split('.')[0]; newTexturePath = newTexturePath.Replace(oldColor, newColor); var textureAux = TgcTexture.createTexture(D3DDevice.Instance.Device, newTexturePath.Split('\\')[5], newTexturePath); mesh.addDiffuseMap(textureAux); mesh.deleteDiffuseMap(index, diffuseMaps.Length - 1); }
/// <summary> /// Crear un nuevo Sprite animado /// </summary> /// <param name="texturePath">path de la textura animada</param> /// <param name="frameSize">tamaño de un tile de la animacion</param> /// <param name="totalFrames">cantidad de frames que tiene la animacion</param> /// <param name="frameRate">velocidad en cuadros por segundo</param> public TgcAnimatedSprite(string texturePath, Size frameSize, int totalFrames, float frameRate) { this.enabled = true; this.currentFrame = 0; this.frameSize = frameSize; this.totalFrames = totalFrames; this.currentTime = 0; this.playing = true; //Crear textura Device d3dDevice = GuiController.Instance.D3dDevice; TgcTexture texture = TgcTexture.createTexture(d3dDevice, texturePath); //Sprite sprite = new TgcSprite(); sprite.Texture = texture; //Calcular valores de frames de la textura textureWidth = texture.Width; textureHeight = texture.Height; framesPerColumn = (int)textureWidth / frameSize.Width; framesPerRow = (int)textureHeight / frameSize.Height; int realTotalFrames = framesPerRow * framesPerColumn; if (realTotalFrames > totalFrames) { throw new Exception("Error en AnimatedSprite. No coinciden la cantidad de frames y el tamaño de la textura: " + totalFrames); } setFrameRate(frameRate); }
/// <summary> /// Crear un emisor de particulas /// </summary> /// <param name="texturePath">textura a utilizar</param> /// <param name="particlesCount">cantidad maxima de particlas a generar</param> public ParticleEmitter(string texturePath, int particlesCount) { Device device = GuiController.Instance.D3dDevice; //valores default enabled = true; playing = true; random = new Random(0); creationFrecuency = 1.0f; particleTimeToLive = 5.0f; minSizeParticle = 0.25f; maxSizeParticle = 0.5f; dispersion = 100; speed = new Vector3(1, 1, 1); particleVertexArray = new Particle.ParticleVertex[1]; vertexDeclaration = new VertexDeclaration(device, Particle.ParticleVertexElements); position = new Vector3(0, 0, 0); this.particlesCount = particlesCount; this.particles = new Particle[particlesCount]; this.particlesAlive = new ColaDeParticulas(particlesCount); this.particlesDead = new Stack <Particle>(particlesCount); //Creo todas las particulas. Inicialmente estan todas muertas. for (int i = 0; i < particlesCount; i++) { this.particles[i] = new Particle(); this.particlesDead.Push(this.particles[i]); } //Cargo la textura que tendra cada particula this.texture = TgcTexture.createTexture(device, texturePath); }
private void InitEmptyTextures() { if (emptyLightMap != null && emptyTexture != null) { return; } //algunos mesh no tienen textura o lightmap. Por compatibilidad con el exporter es conveniente que todas tengan Una textura //para eso creo una textura vacia de 1x1 negro como textura y una de 1x1 blanco para lightmap. var texture = new Texture(D3DDevice.Instance.Device, 1, 1, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); var graphicsStream = texture.LockRectangle(0, LockFlags.None); uint color = 0x00000000; graphicsStream.Write(color); texture.UnlockRectangle(0); // TextureLoader.Save("emptyTexture.jpg", ImageFileFormat.Jpg, texture); emptyTexture = new TgcTexture("emptyTexture.jpg", "emptyTexture.jpg", texture, false); texture = new Texture(D3DDevice.Instance.Device, 1, 1, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); graphicsStream = texture.LockRectangle(0, LockFlags.None); color = 0x00000000; graphicsStream.Write(color); texture.UnlockRectangle(0); // TextureLoader.Save("emptyLightMap.jpg", ImageFileFormat.Jpg, texture); emptyLightMap = new TgcTexture("emptyLightMap.jpg", "emptyLightMap.jpg", texture, false); }
/// <summary> /// Cargar lightmaps /// </summary> private void loadLightMaps(BspMap bspMap) { const int LIGHTMAP_SIZE = 128 * 128; var cant_lmaps = bspMap.Data.lightBytes.Length / (LIGHTMAP_SIZE * 3); lightMaps = new TgcTexture[cant_lmaps]; var lightInfo = new int[LIGHTMAP_SIZE]; for (var i = 0; i < cant_lmaps; i++) { //transformo de RGB a XRGB agregandole un canal mas for (var j = 0; j < LIGHTMAP_SIZE; j++) { var offset = (i * LIGHTMAP_SIZE + j) * 3; lightInfo[j] = changeGamma(bspMap.Data.lightBytes[offset + 0], bspMap.Data.lightBytes[offset + 1], bspMap.Data.lightBytes[offset + 2]); } var tex = new Texture(D3DDevice.Instance.Device, 128, 128, 0, Usage.None, Format.X8R8G8B8, Pool.Managed); var graphicsStream = tex.LockRectangle(0, LockFlags.None); graphicsStream.Write(lightInfo); tex.UnlockRectangle(0); var filename = "qlight" + i + ".jpg"; //TextureLoader.Save(filename, ImageFileFormat.Jpg, tex); lightMaps[i] = new TgcTexture(filename, filename, tex, false); } }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //Crear Sprite sprite = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "\\Texturas\\LogoTGC.png"); //Ubicarlo centrado en la pantalla Size screenSize = GuiController.Instance.Panel3d.Size; Size textureSize = sprite.Texture.Size; sprite.Position = new Vector2(FastMath.Max(screenSize.Width / 2 - textureSize.Width / 2, 0), FastMath.Max(screenSize.Height / 2 - textureSize.Height / 2, 0)); //Modifiers para variar parametros del sprite GuiController.Instance.Modifiers.addVertex2f("position", new Vector2(0, 0), new Vector2(screenSize.Width, screenSize.Height), sprite.Position); GuiController.Instance.Modifiers.addVertex2f("scaling", new Vector2(0, 0), new Vector2(4, 4), sprite.Scaling); GuiController.Instance.Modifiers.addFloat("rotation", 0, 360, 0); //Creamos un Box3D para que se vea como el Sprite es en 2D y se dibuja siempre arriba de la escena 3D box = TgcBox.fromSize(new Vector3(10, 10, 10), TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "\\Texturas\\pasto.jpg")); //Hacer que la camara se centre en el box3D GuiController.Instance.RotCamera.targetObject(box.BoundingBox); }
public static void cargar() { SpriteDrawer = new Drawer2D(); //AnimatedSprite = new TgcAnimatedSprite(Utiles.getDirExtras("Explosion.png"), new Size(64, 64), 16, 10); //AnimatedSprite.Position = new Vector2(GuiController.Instance.Panel3d.Width - 32*2, 0); //Crear Sprite sprite = new TgcSprite(); sprite.Texture = TgcTexture.createTexture(Utiles.getDirExtras("calabera1.jpg")); //Ubicarlo centrado en la pantalla Size screenSize = GuiController.Instance.Panel3d.Size; Size textureSize = sprite.Texture.Size; sprite.Position = new Vector2(GuiController.Instance.Panel3d.Width - 34 * 2, 0); sprite.Scaling = new Vector2(0.1f, 0.1f); Puntos2d = new TgcText2d(); Puntos2d.Text = puntos.ToString(); Puntos2d.Color = Color.Yellow; Puntos2d.Align = TgcText2d.TextAlign.RIGHT; Puntos2d.Position = new Point(GuiController.Instance.Panel3d.Width - 32, 0); Puntos2d.Size = new Size(30, 20); Puntos2d.changeFont(new System.Drawing.Font("Sans-serif ", 15, FontStyle.Bold)); }
/// <summary> /// Se llama una sola vez, al principio cuando se ejecuta el ejemplo. /// Escribir aquí todo el código de inicialización: cargar modelos, texturas, modifiers, uservars, etc. /// Borrar todo lo que no haga falta. /// </summary> public override void Init() { //Device de DirectX para crear primitivas var d3dDevice = D3DDevice.Instance.Device; //Piso la camara que viene por defecto con la que yo quiero usar. //Configurar centro al que se mira y distancia desde la que se mira Camara = new TgcRotationalCamera(new Vector3(), 50f, Input); //Textura de la carperta Media var pathTexturaCaja = MediaDir + Game.Default.TexturaCaja; //Cargamos una textura var texture = TgcTexture.createTexture(pathTexturaCaja); //Creamos una caja 3D ubicada en (0, 0, 0), dimensiones (5, 10, 5) y la textura como color. var center = new Vector3(0, 0, 0); var size = new Vector3(5, 10, 5); Box = TgcBox.fromSize(center, size, texture); //Cargo el unico mesh que tiene la escena Mesh = new TgcSceneLoader().loadSceneFromFile(MediaDir + "LogoTGC-TgcScene.xml").Meshes[0]; //Escalo el mesh que es muy grande Mesh.Scale = new Vector3(0.5f, 0.5f, 0.5f); }
public PlataformaDesplazante(TGCVector3 pos, TGCVector3 size, TgcTexture textura, TGCVector3 posFinal, TGCVector3 vel) : base(pos, size, textura) { posInicial = pos; this.posFinal = posFinal; this.vel = vel; }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; d3dDevice.RenderState.AlphaFunction = Compare.Greater; d3dDevice.RenderState.BlendOperation = BlendOperation.Add; d3dDevice.RenderState.AlphaBlendEnable = true; d3dDevice.RenderState.AlphaTestEnable = true; d3dDevice.RenderState.SourceBlend = Blend.SourceAlpha; d3dDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha; TgcTexture texture = TgcTexture.createTexture(d3dDevice, GuiController.Instance.ExamplesMediaDir + "ModelosTgc\\BoxAlpha\\Textures\\pruebaAlpha.png"); mesh1 = new TgcPlaneWall(new Vector3(0, 0, 0), new Vector3(100, 100, 0), TgcPlaneWall.Orientations.XYplane, texture); mesh1.AutoAdjustUv = false; mesh1.UTile = 1; mesh1.VTile = 1; mesh1.updateValues(); mesh2 = new TgcPlaneWall(new Vector3(0, 0, 100), new Vector3(100, 100, 0), TgcPlaneWall.Orientations.XYplane, texture); mesh2.AutoAdjustUv = false; mesh2.UTile = 1; mesh2.VTile = 1; mesh2.updateValues(); GuiController.Instance.FpsCamera.Enable = true; GuiController.Instance.Modifiers.addBoolean("invertRender", "Invert Render", false); }
public void Init(string MediaDir) { paredes = new List <TGCBox>(); var diffuseMap = TgcTexture.createTexture(MediaDir + "Textures//Lisas.bmp"); // todo: usar planos para piso y techo? piso = TGCBox.fromExtremes(new TGCVector3(-100, -1, -100), new TGCVector3(100, 0, 100), diffuseMap); piso.Transform = TGCMatrix.Translation(piso.Position); techo = TGCBox.fromExtremes(new TGCVector3(-100, 100, -100), new TGCVector3(100, 101, 100), diffuseMap); techo.Transform = TGCMatrix.Translation(techo.Position); var paredSur = TGCBox.fromExtremes(new TGCVector3(-100, 0, -110), new TGCVector3(100, 100, -100), diffuseMap); paredSur.Transform = TGCMatrix.Translation(paredSur.Position); var paredNorte = TGCBox.fromExtremes(new TGCVector3(-100, 0, 100), new TGCVector3(100, 100, 110), diffuseMap); paredNorte.Transform = TGCMatrix.Translation(paredNorte.Position); var paredOeste = TGCBox.fromExtremes(new TGCVector3(-110, 0, -100), new TGCVector3(-100, 100, 100), diffuseMap); paredOeste.Transform = TGCMatrix.Translation(paredOeste.Position); var paredEste = TGCBox.fromExtremes(new TGCVector3(100, 0, -100), new TGCVector3(110, 100, 100), diffuseMap); paredEste.Transform = TGCMatrix.Translation(paredEste.Position); paredes.Add(paredSur); paredes.Add(paredNorte); paredes.Add(paredEste); paredes.Add(paredOeste); }
public override void init() { Device d3dDevice = GuiController.Instance.D3dDevice; //Cargamos una textura //Una textura es una imágen 2D que puede dibujarse arriba de un polígono 3D para darle color. //Es muy útil para generar efectos de relieves y superficies. //Puede ser cualquier imágen 2D (jpg, png, gif, etc.) y puede ser editada con cualquier editor //normal (photoshop, paint, descargada de goole images, etc). //El framework viene con un montón de texturas incluidas y organizadas en categorias (texturas de //madera, cemento, ladrillo, pasto, etc). Se encuentran en la carpeta del framework: // TgcViewer\Examples\Media\MeshCreator\Textures //Podemos acceder al path de la carpeta "Media" utilizando la variable "GuiController.Instance.ExamplesMediaDir". //Esto evita que tengamos que hardcodear el path de instalación del framework. TgcTexture texture = TgcTexture.createTexture(GuiController.Instance.ExamplesMediaDir + "MeshCreator\\Textures\\Madera\\cajaMadera3.jpg"); //Creamos una caja 3D ubicada en (0, -3, 0), dimensiones (5, 10, 5) y la textura como color. Vector3 center = new Vector3(0, -3, 0); Vector3 size = new Vector3(5, 10, 5); box = TgcBox.fromSize(center, size, texture); GuiController.Instance.RotCamera.targetObject(box.BoundingBox); }
public override void Init() { var sphere = MediaDir + "ModelosTgc\\Sphere\\Sphere-TgcScene.xml"; var loader = new TgcSceneLoader(); //Cargar modelos para el sol, la tierra y la luna. Son esfereas a las cuales le cambiamos la textura sun = loader.loadSceneFromFile(sphere).Meshes[0]; sun.changeDiffuseMaps(new[] { TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SistemaSolar\\SunTexture.jpg") }); earth = loader.loadSceneFromFile(sphere).Meshes[0]; earth.changeDiffuseMaps(new[] { TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SistemaSolar\\EarthTexture.jpg") }); moon = loader.loadSceneFromFile(sphere).Meshes[0]; moon.changeDiffuseMaps(new[] { TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "SistemaSolar\\MoonTexture.jpg") }); //Deshabilitamos el manejo automático de Transformaciones de TgcMesh, para poder manipularlas en forma customizada sun.AutoTransformEnable = false; earth.AutoTransformEnable = false; moon.AutoTransformEnable = false; //Camara en primera persona Camara = new TgcFpsCamera(new Vector3(705.2938f, 305.347f, -888.1567f)); }
protected void configure(float radius, Color color, TgcTexture texture, Vector3 center) { AutoTransformEnable = false; Transform = Matrix.Identity; translation = center; rotation = new Vector3(0, 0, 0); enabled = true; scale = new Vector3(1, 1, 1); alphaBlendEnable = false; uvOffset = new Vector2(0, 0); //BoundingSphere boundingSphere = new TgcBoundingSphere(); //Shader effect = TgcShaders.Instance.VariosShader; //Tipo de vertice y technique if (texture != null) { setTexture(texture); } else { setColor(color); } basePoly = eBasePoly.ICOSAHEDRON; levelOfDetail = 2; inflate = true; ForceUpdate = false; uvTiling = new Vector2(1, 1); }
/// <summary> /// Crea una caja con el centro y tamaño especificado, con la textura especificada /// </summary> /// <param name="center">Centro de la caja</param> /// <param name="size">Tamaño de la caja</param> /// <param name="texture">Textura de la caja</param> /// <returns>Caja creada</returns> public static TgcBox fromSize(Vector3 center, Vector3 size, TgcTexture texture) { TgcBox box = TgcBox.fromSize(center, size); box.setTexture(texture); return(box); }
/// <summary> /// Actualiza los parámetros de la caja en base a lo cargado por el usuario /// </summary> private void updateBox() { //Cambiar textura var texturePath = (string)Modifiers["texture"]; if (texturePath != currentTexture) { currentTexture = texturePath; box.setTexture(TgcTexture.createTexture(D3DDevice.Instance.Device, currentTexture)); } //Tamaño, posición y color box.Size = (Vector3)Modifiers["size"]; box.Position = (Vector3)Modifiers["position"]; box.Color = (Color)Modifiers["color"]; //Rotación, converitr a radianes var rotaion = (Vector3)Modifiers["rotation"]; box.Rotation = new Vector3(Geometry.DegreeToRadian(rotaion.X), Geometry.DegreeToRadian(rotaion.Y), Geometry.DegreeToRadian(rotaion.Z)); //Offset y Tiling de textura box.UVOffset = (Vector2)Modifiers["offset"]; box.UVTiling = (Vector2)Modifiers["tiling"]; //Actualizar valores en la caja. box.updateValues(); }
/// <summary> /// Crea una caja en base al punto minimo y maximo, con el color especificado /// </summary> /// <param name="pMin">Punto mínimo</param> /// <param name="pMax">Punto máximo</param> /// <param name="texture">Textura de la caja</param> /// <returns>Caja creada</returns> public static TgcBox fromExtremes(Vector3 pMin, Vector3 pMax, TgcTexture texture) { TgcBox box = TgcBox.fromExtremes(pMin, pMax); box.setTexture(texture); return(box); }
public void Init(string MediaDir) { //Creamos el mundo fisico por defecto. collisionConfiguration = new DefaultCollisionConfiguration(); dispatcher = new CollisionDispatcher(collisionConfiguration); GImpactCollisionAlgorithm.RegisterAlgorithm(dispatcher); constraintSolver = new SequentialImpulseConstraintSolver(); overlappingPairCache = new DbvtBroadphase(); //AxisSweep3(new BsVector3(-5000f, -5000f, -5000f), new BsVector3(5000f, 5000f, 5000f), 8192); dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, constraintSolver, collisionConfiguration); dynamicsWorld.Gravity = new TGCVector3(0, -100f, 0).ToBulletVector3(); //Creamos el terreno var meshRigidBody = BulletRigidBodyFactory.Instance.CreateSurfaceFromHeighMap(triangleDataVB); dynamicsWorld.AddRigidBody(meshRigidBody); //Creamos la esfera del dragon dragonBall = BulletRigidBodyFactory.Instance.CreateBall(30f, 0.75f, new TGCVector3(100f, 500f, 100f)); dragonBall.SetDamping(0.1f, 0.5f); dragonBall.Restitution = 1f; dragonBall.Friction = 1; dynamicsWorld.AddRigidBody(dragonBall); var textureDragonBall = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + @"Texturas\dragonball.jpg"); sphereMesh = new TGCSphere(1, textureDragonBall, TGCVector3.Empty); sphereMesh.updateValues(); director = new TGCVector3(1, 0, 0); }
public override void Init() { //Modifiers para variar parametros de la pared Modifiers.addVertex3f("origin", new Vector3(-100, -100, -100), new Vector3(100, 100, 100), new Vector3(0, 0, 0)); Modifiers.addVertex3f("dimension", new Vector3(-100, -100, -100), new Vector3(1000, 1000, 100), new Vector3(100, 100, 100)); Modifiers.addInterval("orientation", new[] { "XY", "XZ", "YZ" }, 0); Modifiers.addVertex2f("tiling", new Vector2(0, 0), new Vector2(10, 10), new Vector2(1, 1)); Modifiers.addBoolean("autoAdjust", "autoAdjust", false); //Modifier de textura var texturePath = MediaDir + "Texturas\\Quake\\TexturePack2\\brick1_1.jpg"; currentTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, texturePath); Modifiers.addTexture("texture", currentTexture.FilePath); //Crear pared plane = new TgcPlane(); plane.setTexture(currentTexture); //Actualizar segun valores cargados updatePlane(); //Ajustar camara segun tamano de la pared Camara = new TgcRotationalCamera(plane.BoundingBox.calculateBoxCenter(), plane.BoundingBox.calculateBoxRadius() * 2, Input); }
public override void Init() { var device = D3DDevice.Instance.Device; // Creo una textura, genero sus mipmaps texture = TgcTexture.createTexture(MediaDir + "Textures//perlin1.png"); texture.D3dTexture.GenerateMipSubLevels(); // Creo un vertex buffer, en este caso un full screen quad CustomVertex.PositionTextured[] vertices = { 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) }; fullScreenQuad = new VertexBuffer(typeof(CustomVertex.PositionTextured), 4, device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default); fullScreenQuad.SetData(vertices, 0, LockFlags.None); // Cargo mi efecto, que contiene mis tecnicas (shaders) effect = TGCShaders.Instance.LoadEffect(ShadersDir + "Example.fx"); hotReloadEffect = new HotReloadEffect(effect, ShadersDir + "Example.fx", 0.5f); time = 0f; // Da igual la camara, nuestros vertices no se van // a multiplicar por ninguna matriz var cameraPosition = TGCVector3.Empty; var lookAt = TGCVector3.Empty; Camera.SetCamera(cameraPosition, lookAt); FixedTickEnable = true; TimeBetweenUpdates = 1f / 40f; }
public override void Init() { var d3dDevice = D3DDevice.Instance.Device; var loader = new TgcSceneLoader(); var scene = loader.loadSceneFromFile(MediaDir + "ModelosTgc\\Box\\" + "Box-TgcScene.xml", MediaDir + "ModelosTgc\\Box\\"); mesh = scene.Meshes[0]; mesh.Scale = new Vector3(0.25f, 0.25f, 0.25f); Camara = new TgcFpsCamera(new Vector3(7.9711f, 11.7f, -32.5475f)); Modifiers.addVertex3f("origin", new Vector3(-100, -100, -100), new Vector3(100, 100, 100), new Vector3(0, 0, 0)); Modifiers.addVertex3f("dimension", new Vector3(-100, -100, -100), new Vector3(1000, 1000, 100), new Vector3(10, 10, 10)); Modifiers.addInterval("orientation", new[] { "XY", "XZ", "YZ" }, 0); Modifiers.addVertex2f("tiling", new Vector2(0, 0), new Vector2(10, 10), new Vector2(1, 1)); var texturePath = MediaDir + "Texturas\\Quake\\TexturePack2\\brick1_1.jpg"; currentTexture = TgcTexture.createTexture(d3dDevice, texturePath); Modifiers.addTexture("texture", currentTexture.FilePath); updateWall(); }
public Track(TGCVector3 centro, string pathTextura, int repeticiones) { //var d3dDevice = D3DDevice.Instance.Device; //var shader = Effect.FromFile(d3dDevice, MediaDir + "MotionBlur.fx",null, null, ShaderFlags.PreferFlowControl, null, out compilationErrors); repeat = repeticiones; center = centro; var size_lados = new TGCVector3(0, 320, 640); var size_suelo = new TGCVector3(160, 0, 640); textura = TgcTexture.createTexture(pathTextura); walls_l = new List <TgcMesh>(); walls_r = new List <TgcMesh>(); floors = new List <TgcMesh>(); var plane = new TgcPlane(center, center, TgcPlane.Orientations.YZplane, textura); for (int i = 0; i < repeticiones; i++) { var walll = new TgcPlane(center + new TGCVector3(-80, -160, -320 - (i * 640)), size_lados, TgcPlane.Orientations.YZplane, textura); walls_l.Add(walll.toMesh("wall_l_" + i)); var wallr = new TgcPlane(center + new TGCVector3(80, -160, -320 - (i * 640)), size_lados, TgcPlane.Orientations.YZplane, textura); walls_r.Add(wallr.toMesh("wall_r_" + i)); var floor = new TgcPlane(center + new TGCVector3(-80, -160, -320 - (i * 640)), size_suelo, TgcPlane.Orientations.XZplane, textura); floors.Add(floor.toMesh("floor_" + i)); } }
public override void Init() { //Cargar 25 cajas formando una matriz var loader = new TgcSceneLoader(); boxes = new List <TGCBox>(); var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\granito.jpg"); var boxSize = new TGCVector3(30, 30, 30); for (var i = 0; i < 5; i++) { for (var j = 0; j < 5; j++) { var center = new TGCVector3((boxSize.X + boxSize.X / 2) * i, (boxSize.Y + boxSize.Y / 2) * j, 0); var box = TGCBox.fromSize(center, boxSize, texture); box.Transform = TGCMatrix.Translation(box.Position); boxes.Add(box); } } //Iniciarlizar PickingRay pickingRay = new TgcPickingRay(Input); Camara.SetCamera(new TGCVector3(100f, 100f, -500f), new TGCVector3(100f, 100f, -250f)); //Crear caja para marcar en que lugar hubo colision collisionPointMesh = TGCBox.fromSize(new TGCVector3(3, 3, 3), Color.Red); selected = false; //UserVars para mostrar en que punto hubo colision UserVars.addVar("CollP-X:"); UserVars.addVar("CollP-Y:"); UserVars.addVar("CollP-Z:"); }
public Caja(string mediaDir, TGCVector3 pos, TGCVector3 size) { // TODO: tengo que hacer dispose de esta textura? la hago global? var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, mediaDir + "caja.jpg"); box = TGCBox.fromSize(size, texture); var minInferior = box.BoundingBox.PMin; var maxInferior = box.BoundingBox.PMax; var posInferior = box.BoundingBox.calculateBoxCenter(); maxInferior.Y = minInferior.Y; posInferior.Y = minInferior.Y; var minSuperior = box.BoundingBox.PMin; var maxSuperior = box.BoundingBox.PMax; var posSuperior = box.BoundingBox.calculateBoxCenter(); minSuperior.Y = maxSuperior.Y; posSuperior.Y = maxSuperior.Y; superior = new TgcBoundingAxisAlignBox(minSuperior, maxSuperior, posSuperior, TGCVector3.One); cuerpo = box.BoundingBox; // debug cuerpo.setRenderColor(Color.Yellow); superior.setRenderColor(Color.Red); move(pos); vel = TGCVector3.Empty; }
/// <summary> /// Se llama una sola vez, al principio cuando se ejecuta el ejemplo. /// Escribir aquí todo el código de inicialización: cargar modelos, texturas, estructuras de optimización, todo /// procesamiento que podemos pre calcular para nuestro juego. /// Borrar el codigo ejemplo no utilizado. /// </summary> public override void Init() { var d3dDevice = D3DDevice.Instance.Device; FixedTickEnable = true; var pathTexturaCaja = MediaDir + Game.Default.TexturaCaja; var texture = TgcTexture.createTexture(pathTexturaCaja); var size = new TGCVector3(5, 5, 5); var box = TGCBox.fromSize(size, texture); cajaUno = box.ToMesh("cajaUno"); cajaDos = box.ToMesh("cajaUno"); cajaTres = box.ToMesh("cajaUno"); cajaUno.Transform = TGCMatrix.Translation(10f, 0f, 0f); cajaDos.Transform = TGCMatrix.Translation(0f, 0f, 0f); cajaTres.Transform = TGCMatrix.Translation(-10f, 0f, 0f); //Suelen utilizarse objetos que manejan el comportamiento de la camara. //Lo que en realidad necesitamos gráficamente es una matriz de View. //El framework maneja una cámara estática, pero debe ser inicializada. //Posición de la camara. var cameraPosition = new TGCVector3(25, 25, 50); //Quiero que la camara mire hacia el origen (0,0,0). var lookAt = new TGCVector3(0, 0, -1f); //Configuro donde esta la posicion de la camara y hacia donde mira. Camera.SetCamera(cameraPosition, lookAt); //Internamente el framework construye la matriz de view con estos dos vectores. //Luego en nuestro juego tendremos que crear una cámara que cambie la matriz de view con variables como movimientos o animaciones de escenas. }
/// <summary> /// Crea una caja en base al punto minimo y maximo, con el color especificado /// </summary> /// <param name="pMin">Punto mínimo</param> /// <param name="pMax">Punto máximo</param> /// <param name="texture">Textura de la caja</param> /// <returns>Caja creada</returns> public static TGCBox fromExtremes(TGCVector3 pMin, TGCVector3 pMax, TgcTexture texture) { var box = fromExtremes(pMin, pMax); box.setTexture(texture); return(box); }
/// <summary> /// Crea una caja con el centro y tamaño especificado, con la textura especificada /// </summary> /// <param name="center">Centro de la caja</param> /// <param name="size">Tamaño de la caja</param> /// <param name="texture">Textura de la caja</param> /// <returns>Caja creada</returns> public static TGCBox fromSize(TGCVector3 center, TGCVector3 size, TgcTexture texture) { var box = fromSize(center, size); box.setTexture(texture); return(box); }
public Menu() { fondo.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "Barco-Pirata-Menu.jpg"); fondo.Position = new Vector2(0, 0); fondo.Scaling = new Vector2( (float)GuiController.Instance.Panel3d.Width / fondo.Texture.Width, (float)GuiController.Instance.Panel3d.Height / fondo.Texture.Height); titulo = new TgcText2d(); titulo.Text = "Barco Pirata"; titulo.Color = Color.Gold; titulo.Align = TgcText2d.TextAlign.CENTER; titulo.Position = new Point(200, 100); titulo.Size = new Size(800, 300); titulo.changeFont(new System.Drawing.Font("BlackoakStd", 35, FontStyle.Bold | FontStyle.Italic)); sombra = new TgcText2d(); sombra.Text = "Barco Pirata"; sombra.Color = Color.Chocolate; sombra.Align = TgcText2d.TextAlign.CENTER; sombra.Position = new Point(205, 103); sombra.Size = new Size(800, 300); sombra.changeFont(new System.Drawing.Font("BlackoakStd", 35, FontStyle.Bold | FontStyle.Italic)); textoComplementario = new TgcText2d(); textoComplementario.Text = "Hacé clic para comenzar a jugar." + '\n' + "Apretá I durante el juego para ver las instrucciones."; textoComplementario.Color = Color.Gold; textoComplementario.Align = TgcText2d.TextAlign.CENTER; textoComplementario.Position = new Point(450, 250); textoComplementario.Size = new Size(300, 100); textoComplementario.changeFont(new System.Drawing.Font("BlackoakStd", 18, FontStyle.Bold | FontStyle.Italic)); }
/// <summary> /// Iniciar cliente /// </summary> private void initClient() { //Crear piso var pisoTexture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "Texturas\\Quake\\TexturePack2\\rock_wall.jpg"); piso = TGCBox.fromSize(new TGCVector3(0, -60, 0), new TGCVector3(5000, 5, 5000), pisoTexture); }
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; }
private TgcSkeletalMesh CrearJugador(string pathRecursos, TgcTexture texturaJugador) { //Cargar personaje con animaciones TgcSkeletalMesh personaje = new TgcSkeletalLoader().loadMeshAndAnimationsFromFile( pathRecursos + Settings.Default.meshFolderPlayer + Settings.Default.meshFilePlayer, pathRecursos + Settings.Default.meshFolderPlayer, new string[] { pathRecursos + Settings.Default.meshFolderPlayer + Settings.Default.animationStopFilePlayer }); //TODO cambiar por matrices personaje.AutoTransformEnable = true; //Le cambiamos la textura personaje.changeDiffuseMaps(new TgcTexture[] { texturaJugador }); //Configurar animacion inicial personaje.playAnimation(Settings.Default.animationStopPlayer, true); //Lo Escalo porque es muy grande personaje.Scale = new Vector3(0.018f, 0.018f, 0.018f); return personaje; }