public override void Init() { D3DDevice.Instance.Device.RenderState.AlphaFunction = Compare.Greater; D3DDevice.Instance.Device.RenderState.BlendOperation = BlendOperation.Add; D3DDevice.Instance.Device.RenderState.SourceBlend = Blend.SourceAlpha; D3DDevice.Instance.Device.RenderState.DestinationBlend = Blend.InvSourceAlpha; var texture = TgcTexture.createTexture(D3DDevice.Instance.Device, MediaDir + "ModelosTgc\\BoxAlpha\\Textures\\pruebaAlpha.png"); mesh1 = new TgcPlaneWall(new Vector3(0, 0, -50), new Vector3(50, 50, 50), TgcPlaneWall.Orientations.XYplane, texture); mesh1.AutoAdjustUv = false; mesh1.UTile = 1; mesh1.VTile = 1; mesh1.updateValues(); mesh2 = new TgcPlaneWall(new Vector3(0, 0, 50), new Vector3(50, 50, 50), TgcPlaneWall.Orientations.XYplane, texture); mesh2.AutoAdjustUv = false; mesh2.UTile = 1; mesh2.VTile = 1; mesh2.updateValues(); Camara = new TgcFpsCamera(new Vector3(50.0f, 50.0f, 150.0f)); Modifiers.addBoolean("invertRender", "Invert Render", false); }
private void updateWall() { var origin = (Vector3)Modifiers["origin"]; var dimension = (Vector3)Modifiers["dimension"]; var tiling = (Vector2)Modifiers["tiling"]; var orientation = (string)Modifiers["orientation"]; TgcPlaneWall.Orientations or; if (orientation == "XY") { or = TgcPlaneWall.Orientations.XYplane; } else if (orientation == "XZ") { or = TgcPlaneWall.Orientations.XZplane; } else { or = TgcPlaneWall.Orientations.YZplane; } if (wall == null) { wall = new TgcPlaneWall(origin, dimension, or, currentTexture, tiling.X, tiling.Y); } else { //wall.updateValues(origin, dimension, or, tiling.X, tiling.Y); wall.updateValues(); } }
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); }
private void updateWall() { Vector3 origin = (Vector3)GuiController.Instance.Modifiers["origin"]; Vector3 dimension = (Vector3)GuiController.Instance.Modifiers["dimension"]; Vector2 tiling = (Vector2)GuiController.Instance.Modifiers["tiling"]; string orientation = (string)GuiController.Instance.Modifiers["orientation"]; TgcPlaneWall.Orientations or; if (orientation == "XY") { or = TgcPlaneWall.Orientations.XYplane; } else if (orientation == "XZ") { or = TgcPlaneWall.Orientations.XZplane; } else { or = TgcPlaneWall.Orientations.YZplane; } if (wall == null) { wall = new TgcPlaneWall(origin, dimension, or, currentTexture, tiling.X, tiling.Y); } else { wall.updateValues(origin, dimension, or, tiling.X, tiling.Y); } }
public void renderPasto(float tLeftMoved, float tRightMoved, int parte) { if ((CustomFpsCamera.Instance.eye - partePasto[parte].Origin).Length() < CustomFpsCamera.FAR_PLANE / 4.5) { TgcCollisionUtils.FrustumResult result = TgcCollisionUtils.classifyFrustumAABB(GuiController.Instance.Frustum, partePasto[parte].BoundingBox); if (result != TgcCollisionUtils.FrustumResult.OUTSIDE) { Device d3dDevice = GuiController.Instance.D3dDevice; TgcTexture.Manager texturesManager = GuiController.Instance.TexturesManager; d3dDevice.RenderState.AlphaTestEnable = true; d3dDevice.RenderState.AlphaBlendEnable = true; TgcPlaneWall pastoWall = partePasto[parte]; texturesManager.shaderSet(pastoWall.Effect, "texDiffuseMap", pastoWall.Texture); texturesManager.clear(1); GuiController.Instance.Shaders.setShaderMatrixIdentity(pastoWall.Effect); d3dDevice.VertexDeclaration = GuiController.Instance.Shaders.VdecPositionTextured; pastoWall.Effect.Technique = pastoWall.Technique; //Render con shader pastoWall.Effect.Begin(0); pastoWall.Effect.BeginPass(0); d3dDevice.DrawUserPrimitives(PrimitiveType.TriangleList, 2, actualizarPasto(tLeftMoved, tRightMoved, parte, pastoWall)); pastoWall.Effect.EndPass(); pastoWall.Effect.End(); d3dDevice.RenderState.AlphaTestEnable = false; d3dDevice.RenderState.AlphaBlendEnable = false; } } }
/// <summary> /// Construir plano /// </summary> public override void doCreation() { TgcD3dInput input = GuiController.Instance.D3dInput; //Si hacen clic con el mouse, ver si hay colision con el suelo if (input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Obtener altura en Y segun movimient en Y del mouse float heightY = creatingInitMouseY - input.Ypos; float adjustedHeightY = MeshCreatorUtils.getMouseIncrementHeightSpeed(Control.Camera, this.BoundingBox, heightY); //Determinar posicion X segun la colision con el grid Vector3 collisionPoint = Control.Grid.getPicking(); Vector3 extensionPoint = new Vector3(collisionPoint.X, initSelectionPoint.Y + adjustedHeightY, initSelectionPoint.Z); //Obtener maximo y minimo Vector3 min = Vector3.Minimize(initSelectionPoint, extensionPoint); Vector3 max = Vector3.Maximize(initSelectionPoint, extensionPoint); min.Z = initSelectionPoint.Z; max.Z = initSelectionPoint.Z + 1; //Configurar plano mesh.setExtremes(min, max); mesh.updateValues(); } //Solto el clic del mouse, generar plano definitivo else if (input.buttonUp(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Tiene el tamaño minimo tolerado Vector3 size = mesh.BoundingBox.calculateSize(); if (size.X > 1 && size.Y > 1) { //Guardar size original del plano para hacer Scaling originalSize = mesh.Size; //Dejar cargado para que se pueda crear un nuevo plano Control.CurrentState = MeshCreatorControl.State.CreatePrimitiveSelected; Control.CreatingPrimitive = new PlaneXYPrimitive(Control); //Agregar plano a la lista de modelos Control.addMesh(this); //Seleccionar plano Control.SelectionRectangle.clearSelection(); Control.SelectionRectangle.selectObject(this); Control.updateModifyPanel(); } //Sino, descartar else { Control.CurrentState = MeshCreatorControl.State.CreatePrimitiveSelected; mesh.dispose(); mesh = null; } } }
/// <summary> /// Construir plano /// </summary> public override void doCreation() { TgcD3dInput input = GuiController.Instance.D3dInput; //Si hacen clic con el mouse, ver si hay colision con el suelo if (input.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Determinar el size en XZ del box Vector3 collisionPoint = Control.Grid.getPicking(); //Obtener extremos del rectángulo de selección Vector3 min = Vector3.Minimize(initSelectionPoint, collisionPoint); Vector3 max = Vector3.Maximize(initSelectionPoint, collisionPoint); min.Y = 0; max.Y = 1; //Configurar plano mesh.setExtremes(min, max); mesh.updateValues(); } //Solto el clic del mouse, generar plano definitivo else if (input.buttonUp(TgcD3dInput.MouseButtons.BUTTON_LEFT)) { //Tiene el tamaño minimo tolerado Vector3 size = mesh.BoundingBox.calculateSize(); if (size.X > 1 && size.Z > 1) { //Guardar size original del plano para hacer Scaling originalSize = mesh.Size; //Dejar cargado para que se pueda crear un nuevo plano Control.CurrentState = MeshCreatorControl.State.CreatePrimitiveSelected; Control.CreatingPrimitive = new PlaneXZPrimitive(Control); //Agregar plano a la lista de modelos Control.addMesh(this); //Seleccionar plano Control.SelectionRectangle.clearSelection(); Control.SelectionRectangle.selectObject(this); Control.updateModifyPanel(); } //Sino, descartar else { Control.CurrentState = MeshCreatorControl.State.CreatePrimitiveSelected; mesh.dispose(); mesh = null; } } }
/// <summary> /// Iniciar la creacion /// </summary> public override void initCreation(Vector3 gridPoint) { initSelectionPoint = gridPoint; //Crear plano inicial TgcTexture planeTexture = TgcTexture.createTexture(Control.getCreationTexturePath()); mesh = new TgcPlaneWall(initSelectionPoint, new Vector3(0, 0, 0), TgcPlaneWall.Orientations.XZplane, planeTexture); mesh.AutoAdjustUv = false; mesh.UTile = 1; mesh.VTile = 1; mesh.BoundingBox.setRenderColor(MeshCreatorUtils.UNSELECTED_OBJECT_COLOR); this.Layer = Control.CurrentLayer; }
public Skybox() { string skyTexPath = GuiController.Instance.AlumnoEjemplosMediaDir + "Jet_Pilot\\" + "Skybox\\"; TgcTexture texture; up = new TgcPlaneWall(); texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "up.jpg"); up.setTexture(texture); up.Origin = new Vector3(-size * 0.5f, size * 0.5f, size * 0.5f); up.Size = new Vector3(size, size, -size); up.Orientation = TgcPlaneWall.Orientations.XZplane; //dn = new TgcPlaneWall(); //texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "dn.jpg"); //dn.setTexture(texture); //dn.Origin = new Vector3(-size * 0.5f, -size * 0.5f, -size * 0.5f); //dn.Size = new Vector3(size, size, size); //dn.Orientation = TgcPlaneWall.Orientations.XZplane; lt = new TgcPlaneWall(); texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "bk.jpg"); lt.setTexture(texture); lt.Origin = new Vector3(size * 0.5f, -size * 0.5f, size * 0.5f); lt.Size = new Vector3(size, size, -size); lt.Orientation = TgcPlaneWall.Orientations.YZplane; rt = new TgcPlaneWall(); texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "ft.jpg"); rt.setTexture(texture); rt.Origin = new Vector3(-size * 0.5f, -size * 0.5f, -size * 0.5f); rt.Size = new Vector3(size, size, size); rt.Orientation = TgcPlaneWall.Orientations.YZplane; ft = new TgcPlaneWall(); texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "lf.jpg"); ft.setTexture(texture); ft.Origin = new Vector3(size * 0.5f, -size * 0.5f, -size * 0.5f); ft.Size = new Vector3(-size, size, size); ft.Orientation = TgcPlaneWall.Orientations.XYplane; bk = new TgcPlaneWall(); texture = TgcTexture.createTexture(GuiController.Instance.D3dDevice, skyTexPath + "rt.jpg"); bk.setTexture(texture); bk.Origin = new Vector3(-size * 0.5f, -size * 0.5f, size * 0.5f); bk.Size = new Vector3(size, size, size); bk.Orientation = TgcPlaneWall.Orientations.XYplane; this.Reset(); }
/// <summary> /// Crear paredes 3D para las diferencias de altura entre la pared South de este Room y el resto /// de los Rooms contra los que colisiona /// </summary> private void createSouthWallSegmentsForHeightDiff(Vector3 sceneScale, List <Point> intersectingLines, List <RoomsEditorRoom> intersectingRooms, RoomsEditorWall wall) { Rectangle bounds = roomPanel.Label.Bounds; Point wallSide = new Point(roomPanel.Label.Location.X, roomPanel.Label.Location.X + roomPanel.Label.Width); Point[] supDiffSegments; Point[] infDiffSegments; findSegmentsForHeightDiff(intersectingRooms, out supDiffSegments, out infDiffSegments); for (int i = 0; i < intersectingRooms.Count; i++) { Point fullIntersecLine = intersectingLines[i]; Point intersecLine = intersectLineSegments(fullIntersecLine, wallSide); //Fragmento superior Point supSeg = supDiffSegments[i]; if (supSeg.X != 0 || supSeg.Y != 0) { TgcPlaneWall wall3d = new TgcPlaneWall( new Vector3(intersecLine.X * sceneScale.X, supSeg.X * sceneScale.Y, (bounds.Y + bounds.Height) * sceneScale.Z), new Vector3((intersecLine.Y - intersecLine.X) * sceneScale.X, (supSeg.Y - supSeg.X) * sceneScale.Y, 0), TgcPlaneWall.Orientations.XYplane, wall.Texture, wall.UTile, wall.VTile ); wall.WallSegments.Add(wall3d); } //Fragmento inferior Point infSeg = infDiffSegments[i]; if (infSeg.X != 0 || infSeg.Y != 0) { TgcPlaneWall wall3d = new TgcPlaneWall( new Vector3(intersecLine.X * sceneScale.X, infSeg.X * sceneScale.Y, (bounds.Y + bounds.Height) * sceneScale.Z), new Vector3((intersecLine.Y - intersecLine.X) * sceneScale.X, (infSeg.Y - infSeg.X) * sceneScale.Y, 0), TgcPlaneWall.Orientations.XYplane, wall.Texture, wall.UTile, wall.VTile ); wall.WallSegments.Add(wall3d); } } }
public void crearPasto(Device d3dDevice, int pastoSecuense, Vector3 origen) { string textureName = "pasto1.png"; switch (pastoSecuense) { case 0: textureName = "pasto3.png"; break; case 1: textureName = "pasto2.png"; break; case 2: textureName = "pasto1.png"; break; } string texturePath = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Mapas\\Textures\\" + textureName; TgcTexture pasto_texture = TgcTexture.createTexture(d3dDevice, texturePath); //Crear pared TgcPlaneWall pastoWall = new TgcPlaneWall(); pastoWall.AlphaBlendEnable = true; pastoWall.setTexture(pasto_texture); //Aplicar valores en pared pastoWall.Origin = origen; pastoWall.Size = new Vector3(36, 30, 36); pastoWall.AutoAdjustUv = true; pastoWall.UTile = 1; pastoWall.VTile = 1; pastoWall.updateValues(); partePasto.Add(pastoWall); }
public void crearMuzzle() { Device d3dDevice = GuiController.Instance.D3dDevice; textures_flash.Add("flash1.png"); textures_flash.Add("flash2.png"); textures_flash.Add("flash3.png"); MAX_RENDER = MAX_DELAY + MAX_DELAY / 2; string texturePath = GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Sprites\\" + textures_flash[0]; TgcTexture pasto_texture = TgcTexture.createTexture(d3dDevice, texturePath); //Crear pared muzzleFlash = new TgcPlaneWall(); muzzleFlash.AlphaBlendEnable = true; muzzleFlash.setTexture(pasto_texture); //Aplicar valores en pared //muzzleFlash.Origin = new Vector3(-50, 917.8f, 4.1f); muzzleFlash.Size = new Vector3(14, 14, 14); muzzleFlash.AutoAdjustUv = false; muzzleFlash.UTile = 1; muzzleFlash.VTile = 1; //Offsets /* * BLoffset = new Vector3(-100, -17.7f, 14.7f); * TLoffset = new Vector3(-100, -17.7f, 14.7f + muzzleFlash.Size.Z); * BRoffset = new Vector3(-100, -17.7f + muzzleFlash.Size.Y, 14.7f); * TRoffset = new Vector3(-100, -17.7f + muzzleFlash.Size.Y, 14.7f + muzzleFlash.Size.Z); */ BLoffset = new Vector3(3.5f, -12f, 50); TLoffset = new Vector3(3.5f + muzzleFlash.Size.X, -12f, 50); BRoffset = new Vector3(3.5f, -12f + muzzleFlash.Size.Y, 50); TRoffset = new Vector3(3.5f + muzzleFlash.Size.X, -12f + muzzleFlash.Size.Y, 50); }
public override void Init() { //Modifiers para variar parámetros 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 wall = new TgcPlaneWall(); wall.setTexture(currentTexture); //Actualizar según valores cargados updateWall(); }
/// <summary> /// Actualiza la información de las paredes /// </summary> public void buildWalls(List <RoomsEditorRoom> rooms, Vector3 sceneScale) { Rectangle bounds = roomPanel.Label.Bounds; //roof RoomsEditorWall roof = walls[0]; TgcPlaneWall roofWall3d = new TgcPlaneWall( new Vector3(bounds.X * sceneScale.X, (floorLevel + height) * sceneScale.Y, bounds.Y * sceneScale.Z), new Vector3(bounds.Width * sceneScale.X, 0, bounds.Height * sceneScale.Z), TgcPlaneWall.Orientations.XZplane, roof.Texture, roof.UTile, roof.VTile ); roof.WallSegments.Clear(); roof.WallSegments.Add(roofWall3d); //floor RoomsEditorWall floor = walls[1]; TgcPlaneWall floorWall3d = new TgcPlaneWall( new Vector3(bounds.X * sceneScale.X, floorLevel, bounds.Y * sceneScale.Z), new Vector3(bounds.Width * sceneScale.X, 0, bounds.Height * sceneScale.Z), TgcPlaneWall.Orientations.XZplane, floor.Texture, floor.UTile, floor.VTile ); floor.WallSegments.Clear(); floor.WallSegments.Add(floorWall3d); List <Point> intersectingLines; List <RoomsEditorRoom> intersectingRooms; Point wallSegment; List <Point> finalWallSegments; //east wall RoomsEditorWall eastWall = walls[2]; //buscar colisiones y particionar wallSegment = new Point(bounds.Y, bounds.Y + bounds.Height); findIntersectingEastWall(rooms, out intersectingLines, out intersectingRooms); finalWallSegments = fragmentWall(eastWall, wallSegment, intersectingLines, intersectingRooms); //Crear una una pared 3D por cada segmento final que quedó eastWall.WallSegments.Clear(); foreach (Point seg in finalWallSegments) { TgcPlaneWall wall3d = new TgcPlaneWall( new Vector3((bounds.X + bounds.Width) * sceneScale.X, floorLevel * sceneScale.Y, seg.X * sceneScale.Z), new Vector3(0, height * sceneScale.Y, (seg.Y - seg.X) * sceneScale.Z), TgcPlaneWall.Orientations.YZplane, eastWall.Texture, eastWall.UTile, eastWall.VTile ); eastWall.WallSegments.Add(wall3d); } //Crear paredes para las diferencias de alturas con los otros Rooms createEastWallSegmentsForHeightDiff(sceneScale, intersectingLines, intersectingRooms, eastWall); //west wall RoomsEditorWall westWall = walls[3]; //buscar colisiones y particionar wallSegment = new Point(bounds.Y, bounds.Y + bounds.Height); findIntersectingWestWall(rooms, out intersectingLines, out intersectingRooms); finalWallSegments = fragmentWall(eastWall, wallSegment, intersectingLines, intersectingRooms); //Crear una una pared 3D por cada segmento final que quedó westWall.WallSegments.Clear(); foreach (Point seg in finalWallSegments) { TgcPlaneWall wall3d = new TgcPlaneWall( new Vector3(bounds.X * sceneScale.X, floorLevel * sceneScale.Y, seg.X * sceneScale.Z), new Vector3(0, height * sceneScale.Y, (seg.Y - seg.X) * sceneScale.Z), TgcPlaneWall.Orientations.YZplane, westWall.Texture, westWall.UTile, westWall.VTile ); westWall.WallSegments.Add(wall3d); } //Crear paredes para las diferencias de alturas con los otros Rooms createWestWallSegmentsForHeightDiff(sceneScale, intersectingLines, intersectingRooms, westWall); //north wall RoomsEditorWall northWall = walls[4]; //buscar colisiones y particionar wallSegment = new Point(bounds.X, bounds.X + bounds.Width); findIntersectingNorthWall(rooms, out intersectingLines, out intersectingRooms); finalWallSegments = fragmentWall(eastWall, wallSegment, intersectingLines, intersectingRooms); //Crear una una pared 3D por cada segmento final que quedó northWall.WallSegments.Clear(); foreach (Point seg in finalWallSegments) { TgcPlaneWall wall3d = new TgcPlaneWall( new Vector3(seg.X * sceneScale.X, floorLevel * sceneScale.Y, bounds.Y * sceneScale.Z), new Vector3((seg.Y - seg.X) * sceneScale.X, height * sceneScale.Y, 0), TgcPlaneWall.Orientations.XYplane, northWall.Texture, northWall.UTile, northWall.VTile ); northWall.WallSegments.Add(wall3d); } //Crear paredes para las diferencias de alturas con los otros Rooms createNorthWallSegmentsForHeightDiff(sceneScale, intersectingLines, intersectingRooms, northWall); //south wall RoomsEditorWall southWall = walls[5]; //buscar colisiones y particionar wallSegment = new Point(bounds.X, bounds.X + bounds.Width); findIntersectingSouthWall(rooms, out intersectingLines, out intersectingRooms); finalWallSegments = fragmentWall(eastWall, wallSegment, intersectingLines, intersectingRooms); //Crear una una pared 3D por cada segmento final que quedó southWall.WallSegments.Clear(); foreach (Point seg in finalWallSegments) { TgcPlaneWall wall3d = new TgcPlaneWall( new Vector3(seg.X * sceneScale.X, floorLevel * sceneScale.Y, (bounds.Y + bounds.Height) * sceneScale.Z), new Vector3((seg.Y - seg.X) * sceneScale.X, height * sceneScale.Y, 0), TgcPlaneWall.Orientations.XYplane, southWall.Texture, southWall.UTile, southWall.VTile ); southWall.WallSegments.Add(wall3d); } //Crear paredes para las diferencias de alturas con los otros Rooms createSouthWallSegmentsForHeightDiff(sceneScale, intersectingLines, intersectingRooms, southWall); }
public CustomVertex.PositionTextured[] actualizarPasto(float tLeftMoved, float tRightMoved, int parte, TgcPlaneWall pastoWall) { float autoWidth; float autoHeight; //Calcular los 4 corners de la pared Vector3 bLeft, tLeft, bRight, tRight, Center; bLeft = pastoWall.Origin; tLeft = new Vector3(pastoWall.Origin.X + pastoWall.Size.X, pastoWall.Origin.Y, pastoWall.Origin.Z); bRight = new Vector3(pastoWall.Origin.X - tLeftMoved, pastoWall.Origin.Y + pastoWall.Size.Y, pastoWall.Origin.Z); tRight = new Vector3(pastoWall.Origin.X + pastoWall.Size.X - tRightMoved, pastoWall.Origin.Y + pastoWall.Size.Y, pastoWall.Origin.Z); Center = new Vector3(pastoWall.Origin.X + (pastoWall.Size.X / 2), pastoWall.Origin.Y + (pastoWall.Size.Y / 2), pastoWall.Origin.Z); autoWidth = (pastoWall.Size.X / pastoWall.Texture.Width); autoHeight = (pastoWall.Size.Y / pastoWall.Texture.Height); //Auto ajustar UV if (pastoWall.AutoAdjustUv) { pastoWall.UTile = autoHeight; pastoWall.VTile = autoWidth; } float offsetU = pastoWall.UVOffset.X; float offsetV = pastoWall.UVOffset.Y; //Rotation if (parte == 0) { /*if (pasto.Origin.X > 0) origen.X = pasto.Origin.X + pasto.Size.X / 2; * else origen.X = pasto.Origin.X - pasto.Size.X / 2;*/ Vector3 v1, v2; v1 = tLeft - tRight; v2 = bLeft - tRight; Vector3 normal = Vector3.Cross(v1, v2); normal.Normalize(); Vector3 direccion; direccion.X = CustomFpsCamera.Instance.Position.X - Center.X; direccion.Y = 0; direccion.Z = CustomFpsCamera.Instance.Position.Z - Center.Z; direccion.Normalize(); calcularOrientacion(direccion, Center, normal); } CustomVertex.PositionTextured[] vertices = new CustomVertex.PositionTextured[6]; float d = 0.02f; //Primer triangulo vertices[0] = new CustomVertex.PositionTextured(bLeft, offsetU + pastoWall.UTile + d, offsetV + pastoWall.VTile + d); vertices[1] = new CustomVertex.PositionTextured(tLeft, offsetU + d, offsetV + pastoWall.VTile + d); vertices[2] = new CustomVertex.PositionTextured(tRight, offsetU + d, offsetV + d); //Segundo triangulo vertices[3] = new CustomVertex.PositionTextured(bLeft, offsetU + pastoWall.UTile + d, offsetV + pastoWall.VTile + d); vertices[4] = new CustomVertex.PositionTextured(tRight, offsetU + d, offsetV + d); vertices[5] = new CustomVertex.PositionTextured(bRight, offsetU + pastoWall.UTile + d, offsetV + d); for (int i = 0; i < vertices.Length; i++) { vertices[i].Position = Vector3.TransformCoordinate(vertices[i].Position, m_mRotacion); } //BoundingBox pastoWall.BoundingBox.setExtremes(bLeft, tRight); return(vertices); }