public List<TransparentSquare> GetMapBlockHelper(Vector3 adjustedSize, Color shellColor) { List<VertexPositionColorNormalTexture> translucentTriangleList = new List<VertexPositionColorNormalTexture>(); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitX, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitY, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitZ, -.5f)); translucentTriangleList.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), shellColor, -Vector3.UnitZ, -.5f)); foreach (Doodad d in doodads) { // Jump Gates if ((d.type == VL.DoodadType.JumpStation || d.type == VL.DoodadType.JumpPad || d.type == VL.DoodadType.BridgeGate) && d.targetRoom != null) { Vector3 startLowerLeft = d.position.position + d.left + d.down; Vector3 startLowerRight = d.position.position + d.right + d.down; Vector3 startUpperLeft = d.position.position + d.left + d.up; Vector3 startUpperRight = d.position.position + d.right + d.up; float roomSize = Math.Abs(Vector3.Dot(d.targetRoom.size / 2, d.position.normal)); float distanceToEnd = ((d.position.position - d.targetRoom.center).Length() - roomSize) / 2; Vector3 endLowerLeft = d.position.position + d.left + d.down + d.position.normal * distanceToEnd; Vector3 endLowerRight = d.position.position + d.right + d.down + d.position.normal * distanceToEnd; Vector3 endUpperLeft = d.position.position + d.left + d.up + d.position.normal * distanceToEnd; Vector3 endUpperRight = d.position.position + d.right + d.up + d.position.normal * distanceToEnd; if (d.type == VL.DoodadType.BridgeGate) { Vector3 bridgeSrcDirection = d.targetDoodad.position.position - d.position.position; bridgeSrcDirection.Normalize(); Vector3 bridgeSrcLeft = .5f * Vector3.Cross(d.position.normal,bridgeSrcDirection); Vector3 bridgeSrcUp = .5f * Vector3.Cross(bridgeSrcDirection, bridgeSrcLeft); startLowerLeft = d.position.position + bridgeSrcLeft - bridgeSrcUp; startLowerRight = d.position.position - bridgeSrcLeft - bridgeSrcUp; startUpperLeft = d.position.position + bridgeSrcLeft + bridgeSrcUp; startUpperRight = d.position.position - bridgeSrcLeft + bridgeSrcUp; distanceToEnd = (d.position.position - d.targetDoodad.position.position).Length() / 2; endLowerLeft = d.position.position + bridgeSrcLeft - bridgeSrcUp + bridgeSrcDirection * distanceToEnd; endLowerRight = d.position.position - bridgeSrcLeft - bridgeSrcUp + bridgeSrcDirection * distanceToEnd; endUpperLeft = d.position.position + bridgeSrcLeft + bridgeSrcUp + bridgeSrcDirection * distanceToEnd; endUpperRight = d.position.position - bridgeSrcLeft + bridgeSrcUp + bridgeSrcDirection * distanceToEnd; } translucentTriangleList.Add(new VertexPositionColorNormalTexture(startLowerLeft, shellColor, d.left, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startUpperLeft, shellColor, d.left, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endLowerLeft, shellColor, d.left, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startUpperLeft, shellColor, d.left, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endUpperLeft, shellColor, d.left, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endLowerLeft, shellColor, d.left, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startLowerRight, shellColor, d.right, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startUpperRight, shellColor, d.right, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endLowerRight, shellColor, d.right, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startUpperRight, shellColor, d.right, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endUpperRight, shellColor, d.right, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endLowerRight, shellColor, d.right, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startUpperLeft, shellColor, d.up, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startUpperRight, shellColor, d.up, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endUpperRight, shellColor, d.up, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startUpperLeft, shellColor, d.up, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endUpperLeft, shellColor, d.up, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endUpperRight, shellColor, d.up, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startLowerLeft, shellColor, d.down, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startLowerRight, shellColor, d.down, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endLowerRight, shellColor, d.down, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(startLowerLeft, shellColor, d.down, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endLowerLeft, shellColor, d.down, new Vector2(.5f, .5f))); translucentTriangleList.Add(new VertexPositionColorNormalTexture(endLowerRight, shellColor, d.down, new Vector2(.5f, .5f))); } } List<TransparentSquare> squareList = new List<TransparentSquare>(); for (int i = 0; i < translucentTriangleList.Count(); i += 6) { TransparentSquare t = new TransparentSquare(translucentTriangleList[i], translucentTriangleList[i + 1], translucentTriangleList[i + 2], translucentTriangleList[i + 3], translucentTriangleList[i + 4], translucentTriangleList[i + 5]); squareList.Add(t); } return squareList; }
public void Draw() { if (fullRender) { if (dynamicFancyPlateTriangleArray == null) { int fancyPlateCount = 0; foreach (Doodad d in doodads) { d.cacheOffset = fancyPlateCount; fancyPlateCount += d.cacheSize; } dynamicFancyPlateTriangleArray = new VertexPositionColorNormalTexture[fancyPlateCount]; } if (dynamicBrickTriangleArray == null) { int fancyBrickCount = 0; foreach (Doodad d in doodads) { d.cacheOffsetBrick = fancyBrickCount; fancyBrickCount += d.cacheSizeBrick; } dynamicBrickTriangleArray = new VertexPositionColorNormalTexture[fancyBrickCount]; } if (masterBlockArray == null) { int[] arraySizes = new int[Block.maxWallTextureTypes]; foreach (Block b in blocks) { if (b.scales) { // 54 per face, 18 per side, 180 per block if (b.wallType == VL.WallType.Plate || b.wallType == VL.WallType.Crate || b.wallType == VL.WallType.Cargo) { b.cacheOffset[(int)VL.WallType.Plate] = arraySizes[(int)b.wallType]; b.cacheOffset[(int)VL.WallType.FancyPlate] = arraySizes[(int)VL.WallType.FancyPlate]; arraySizes[(int)VL.WallType.Plate] += 108; arraySizes[(int)VL.WallType.FancyPlate] += 72; } else if (b.wallType == VL.WallType.Gearslot) { b.cacheOffset[(int)VL.WallType.FancyPlate] = arraySizes[(int)VL.WallType.FancyPlate]; b.cacheOffset[(int)VL.WallType.Gearslot] = arraySizes[(int)VL.WallType.Gearslot]; arraySizes[(int)VL.WallType.FancyPlate] += 108; arraySizes[(int)VL.WallType.Gearslot] += 72; } else { b.cacheOffset[(int)b.wallType] = arraySizes[(int)b.wallType]; arraySizes[(int)b.wallType] += 180; } } else { if (b.wallType == VL.WallType.Plate || b.wallType == VL.WallType.Crate || b.wallType == VL.WallType.Cargo) { b.cacheOffset[(int)b.wallType] = arraySizes[(int)b.wallType]; b.cacheOffset[(int)VL.WallType.FancyPlate] = arraySizes[(int)VL.WallType.FancyPlate]; arraySizes[(int)b.wallType] += 12; arraySizes[(int)VL.WallType.FancyPlate] += 24; } else if (b.wallType == VL.WallType.Gearslot) { b.cacheOffset[(int)VL.WallType.FancyPlate] = arraySizes[(int)VL.WallType.FancyPlate]; b.cacheOffset[(int)b.wallType] = arraySizes[(int)b.wallType]; arraySizes[(int)VL.WallType.FancyPlate] += 12; arraySizes[(int)b.wallType] += 24; } else { b.cacheOffset[(int)b.wallType] = arraySizes[(int)b.wallType]; arraySizes[(int)b.wallType] += 36; } } } masterBlockArray = new VertexPositionColorNormalTexture[Block.maxWallTextureTypes][]; for (int i = 0; i < Block.maxWallTextureTypes; i++) { masterBlockArray[i] = new VertexPositionColorNormalTexture[arraySizes[i]]; } } float cameraLineDistance = Vector3.Dot(center - Engine.player.center.position, Vector3.Normalize(Engine.player.cameraTarget - Engine.player.cameraPos)); #region Blocks if (staticFancyPlate == null || refreshVertices == true) { staticFancyPlate = new List<VertexPositionColorNormalTexture>(); staticCircuit = new List<VertexPositionColorNormalTexture>(); staticVines = new List<VertexPositionColorNormalTexture>(); staticPlate = new List<VertexPositionColorNormalTexture>(); staticCrate = new List<VertexPositionColorNormalTexture>(); staticCargo = new List<VertexPositionColorNormalTexture>(); staticCrystal = new List<VertexPositionColorNormalTexture>(); staticIce = new List<VertexPositionColorNormalTexture>(); staticCobblestone = new List<VertexPositionColorNormalTexture>(); staticGearslot = new List<VertexPositionColorNormalTexture>(); staticRings = new List<VertexPositionColorNormalTexture>(); } foreach (Block b in blocks) { List<Vertex> vList = new List<Vertex>(); vList.Add(b.edges[0].start); vList.Add(b.edges[1].start); vList.Add(b.edges[2].start); vList.Add(b.edges[3].start); b.UpdateVertexData(this); b.Draw(this); } foreach (JumpRing j in jumpRings) { j.Draw(this); } foreach (Tunnel t in tunnels) { t.Draw(this); } if (fancyPlateTriangleArray == null || refreshVertices == true) { fancyPlateTriangleArray = staticFancyPlate.ToArray(); circuitTriangleArray = staticCircuit.ToArray(); vinesTriangleArray = staticVines.ToArray(); plateTriangleArray = staticPlate.ToArray(); cargoTriangleArray = staticCargo.ToArray(); crateTriangleArray = staticCrate.ToArray(); gearslotTriangleArray = staticGearslot.ToArray(); crystalTriangleArray = staticCrystal.ToArray(); cobblestoneTriangleArray = staticCobblestone.ToArray(); iceTriangleArray = staticIce.ToArray(); ringTriangleArray = staticRings.ToArray(); } if (ringTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.fancyPlateTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, ringTriangleArray, 0, ringTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } /*if (fancyPlateTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.fancyPlateTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, fancyPlateTriangleArray, 0, fancyPlateTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (vinesTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.vineTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vinesTriangleArray, 0, vinesTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (plateTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.wallTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, plateTriangleArray, 0, plateTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (circuitTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.circuitTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, circuitTriangleArray, 0, circuitTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (cargoTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.cargoTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, cargoTriangleArray, 0, cargoTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (cobblestoneTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.cobblestoneTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, cobblestoneTriangleArray, 0, cobblestoneTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (gearslotTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.gearslotTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, gearslotTriangleArray, 0, gearslotTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (crateTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.crateTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, crateTriangleArray, 0, crateTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (iceTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.iceTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, iceTriangleArray, 0, iceTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (crystalTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.crystalTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, crystalTriangleArray, 0, crystalTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); }*/ for (int i = 0; i < Block.maxWallTextureTypes; i++) { if (masterBlockArray[i].Count() > 0) { Engine.playerTextureEffect.Texture = Block.masterTextureList[i]; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, masterBlockArray[i], 0, masterBlockArray[i].Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } } foreach (Block b in blocks) { foreach (Edge e in b.edges) { e.UpdateVertexData(this, !b.staticObject); e.Draw(this); } } #endregion #region Doodads dynamicFancyPlate = new List<VertexPositionColorNormalTexture>(); dynamicBrick = new List<VertexPositionColorNormalTexture>(); dynamicPlate = new List<VertexPositionColorNormalTexture>(); foreach (Doodad d in doodads) { d.DrawSolids(this); } if (dynamicFancyPlateTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.fancyPlateTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, dynamicFancyPlateTriangleArray, 0, dynamicFancyPlateTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } if (dynamicBrickTriangleArray.Count() > 0) { Engine.playerTextureEffect.Texture = Block.crackedTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, dynamicBrickTriangleArray, 0, dynamicBrickTriangleArray.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); } foreach (Doodad d in doodads) { d.DrawDecals(this); } #endregion } #region innerBlock Color interiorColor = new Color(20, 20, 20); if (innerBlockMode == 2) interiorColor.A = 90; Vector3 adjustedSize = new Vector3(size.X - .1f, size.Y - .1f, size.Z - .1f); if (translucentBoxVertices == null) { translucentBoxVertices = new List<VertexPositionColorNormalTexture>(); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitX, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitY, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitZ, -.5f)); translucentBoxVertices.Add(GenerateTexturedVertex(center + new Vector3(-adjustedSize.X / 2, -adjustedSize.Y / 2, -adjustedSize.Z / 2), new Vector2(.5f, .5f), interiorColor, -Vector3.UnitZ, -.5f)); transparentSquareList = new List<TransparentSquare>(); for (int i = 0; i < translucentBoxVertices.Count(); i += 6) { TransparentSquare t = new TransparentSquare(translucentBoxVertices[i], translucentBoxVertices[i + 1], translucentBoxVertices[i + 2], translucentBoxVertices[i + 3], translucentBoxVertices[i + 4], translucentBoxVertices[i + 5]); transparentSquareList.Add(t); } } if (Engine.staticObjectsInitialized == false) { for (int i = 0; i < transparentSquareList.Count(); i++) { Engine.staticTranslucentObjects.Add(transparentSquareList[i]); } } #endregion #region outerBlock Vector3 outerAdjustedSize = new Vector3(size.X + 5f, size.Y + 5f, size.Z + 5f); if (innerBlockMode > 0) { Engine.mapShellObjects.AddRange(GetMapBlock(outerAdjustedSize, currentColor)); } #endregion if (refreshVertices == true) refreshVertices = false; }