public void DrawAngryEyes(Room currentRoom) { Vector3 center = currentRoom.center; Vector3 outDirection = Engine.player.center.position - center; Vector3 up = Engine.player.cameraUp; outDirection.Normalize(); up.Normalize(); Vector3 right = Vector3.Cross(up, outDirection); VertexPositionColorNormalTexture[] eyeVertices = new VertexPositionColorNormalTexture[6]; eyeVertices[0] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 2f * right, Color.White, outDirection, Room.plateTexCoords[2]); eyeVertices[1] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 1f * right + .2f * up, Color.White, outDirection, Room.plateTexCoords[3]); eyeVertices[2] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 2f * right + up, Color.White, outDirection, Room.plateTexCoords[1]); eyeVertices[3] = new VertexPositionColorNormalTexture(center + outDirection * 6 - 2 * right, Color.White, outDirection, Room.plateTexCoords[2]); eyeVertices[4] = new VertexPositionColorNormalTexture(center + outDirection * 6 - 1 * right + .2f * up, Color.White, outDirection, Room.plateTexCoords[3]); eyeVertices[5] = new VertexPositionColorNormalTexture(center + outDirection * 6 - 2f * right + up, Color.White, outDirection, Room.plateTexCoords[1]); Engine.playerTextureEffect.Texture = Monster.monsterTextures[(int)MonsterTextureId.FaceAngryEye]; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, eyeVertices, 0, eyeVertices.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); }
public void DrawMapDecal(Vector3 cameraUp, Vector3 cameraRight, Texture2D decalTexture, Vertex v, bool objective, float decalSize, Color color) { float iconDistance = 3f; float iconSize = decalSize; if (objective == true) { iconDistance = 5f; iconSize = 3f + ObjectiveControl.oscillate * 3f / ObjectiveControl.maxOscillate; } if (WorldMap.state == ZoomState.Objectives || WorldMap.state == ZoomState.World || WorldMap.state == ZoomState.ZoomFromWorld || WorldMap.state == ZoomState.ZoomToWorld) { iconDistance *= 1f * (3 * WorldMap.worldZoomLevel); iconSize *= 1f + (2 * WorldMap.worldZoomLevel); } Vector3 offset = Vector3.Zero; Vector3 lowerLeft = v.position + iconSize * -cameraRight + iconSize * -cameraUp + v.normal * iconDistance; Vector3 lowerRight = v.position + iconSize * cameraRight + iconSize * -cameraUp + v.normal * iconDistance; Vector3 upperLeft = v.position + iconSize * -cameraRight + iconSize * cameraUp + v.normal * iconDistance; Vector3 upperRight = v.position + iconSize * cameraRight + iconSize * cameraUp + v.normal * iconDistance; VertexPositionColorNormalTexture[] mapDecalList = new VertexPositionColorNormalTexture[6]; mapDecalList[0] = (new VertexPositionColorNormalTexture(lowerLeft, color, v.normal, Room.plateTexCoords[2])); mapDecalList[1] = (new VertexPositionColorNormalTexture(lowerRight, color, v.normal, Room.plateTexCoords[3])); mapDecalList[2] = (new VertexPositionColorNormalTexture(upperLeft, color, v.normal, Room.plateTexCoords[1])); mapDecalList[3] = (new VertexPositionColorNormalTexture(lowerRight, color, v.normal, Room.plateTexCoords[3])); mapDecalList[4] = (new VertexPositionColorNormalTexture(upperLeft, color, v.normal, Room.plateTexCoords[1])); mapDecalList[5] = (new VertexPositionColorNormalTexture(upperRight, color, v.normal, Room.plateTexCoords[0])); Engine.playerTextureEffect.Texture = decalTexture; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, mapDecalList, 0, mapDecalList.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); }
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; }
public void DrawNormalEyes(Room currentRoom) { Vector3 center = currentRoom.center; Vector3 outDirection = Engine.player.center.position - center; Vector3 up = Engine.player.cameraUp; outDirection.Normalize(); up.Normalize(); Vector3 right = Vector3.Cross(up, outDirection); VertexPositionColorNormalTexture[] eyeVertices = new VertexPositionColorNormalTexture[12]; Color eyeColor = Color.White; if (salvoCooldown < 800) { eyeColor.G = (Byte)(255f - (800f - 1f*salvoCooldown) / 800f * 150f); eyeColor.B = (Byte)(255f - (800f - 1f*salvoCooldown) / 800f * 150f); } eyeVertices[0] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 2f * right, eyeColor, outDirection, Room.plateTexCoords[2]); eyeVertices[1] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 1f * right + .2f * up, eyeColor, outDirection, Room.plateTexCoords[3]); eyeVertices[2] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 2f * right + up, eyeColor, outDirection, Room.plateTexCoords[1]); eyeVertices[3] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 1f * right + .2f * up, eyeColor, outDirection, Room.plateTexCoords[3]); eyeVertices[4] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 2f * right + up, eyeColor, outDirection, Room.plateTexCoords[1]); eyeVertices[5] = new VertexPositionColorNormalTexture(center + outDirection * 6 + 1f * right + up, eyeColor, outDirection, Room.plateTexCoords[0]); eyeVertices[6] = new VertexPositionColorNormalTexture(center + outDirection * 6 - 2 * right, eyeColor, outDirection, Room.plateTexCoords[2]); eyeVertices[7] = new VertexPositionColorNormalTexture(center + outDirection * 6 - 1 * right + .2f * up, eyeColor, outDirection, Room.plateTexCoords[3]); eyeVertices[8] = new VertexPositionColorNormalTexture(center + outDirection * 6 - 2f * right + up, eyeColor, outDirection, Room.plateTexCoords[1]); eyeVertices[9] = eyeVertices[7]; eyeVertices[10] = eyeVertices[8]; eyeVertices[11] = new VertexPositionColorNormalTexture(center + outDirection * 6 - 1f * right + up, eyeColor, outDirection, Room.plateTexCoords[0]); Engine.playerTextureEffect.Texture = Monster.monsterTextures[(int)MonsterTextureId.FaceNormalEye]; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, eyeVertices, 0, eyeVertices.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration); }
public void DrawSphere(Room currentRoom, bool armor) { int numThetaSides = 10; int numPhiSides = 8; float horizontalRadius = 5f; float verticalRadius = 5f; VertexPositionColorNormalTexture[] vertices = new VertexPositionColorNormalTexture[numThetaSides * 6 * (numPhiSides + 1)]; int index = 0; for (int i = 0; i < numThetaSides; ++i) { float theta1 = ((float)i / (float)numThetaSides) * MathHelper.ToRadians(360f); float theta2 = ((float)(i + 1) / (float)numThetaSides) * MathHelper.ToRadians(360f); for (int j = -1; j < numPhiSides; ++j) { float phi_a = ((float)j / (float)numPhiSides) * MathHelper.ToRadians(180f); float x1_a = (float)(Math.Sin(phi_a) * Math.Cos(theta1)) * horizontalRadius; float z1_a = (float)(Math.Sin(phi_a) * Math.Sin(theta1)) * horizontalRadius; float x2_a = (float)(Math.Sin(phi_a) * Math.Cos(theta2)) * horizontalRadius; float z2_a = (float)(Math.Sin(phi_a) * Math.Sin(theta2)) * horizontalRadius; float y_a = (float)Math.Cos(phi_a) * verticalRadius; float phi_b = ((float)(j+1) / (float)numPhiSides) * MathHelper.ToRadians(180f); float x1_b = (float)(Math.Sin(phi_b) * Math.Cos(theta1)) * horizontalRadius; float z1_b = (float)(Math.Sin(phi_b) * Math.Sin(theta1)) * horizontalRadius; float x2_b = (float)(Math.Sin(phi_b) * Math.Cos(theta2)) * horizontalRadius; float z2_b = (float)(Math.Sin(phi_b) * Math.Sin(theta2)) * horizontalRadius; float y_b = (float)Math.Cos(phi_b) * verticalRadius; Vector3 position1 = currentRoom.center + new Vector3(x1_a, y_a, z1_a); Vector3 position2 = currentRoom.center + new Vector3(x2_a, y_a, z2_a); Vector3 position3 = currentRoom.center + new Vector3(x1_b, y_b, z1_b); Vector3 position4 = currentRoom.center + new Vector3(x2_b, y_b, z2_b); Vector3 offset = (position1 + position2 + position3 + position4)/4 - currentRoom.center; offset.Normalize(); offset *= 20f * armorExplodeTime / armorExplodeMaxTime; if (armor == true) { vertices[index] = new VertexPositionColorNormalTexture(position1 + offset, Color.White, position1 - currentRoom.center, Room.plateTexCoords[0]); vertices[index + 1] = new VertexPositionColorNormalTexture(position2 + offset, Color.White, position2 - currentRoom.center, Room.plateTexCoords[1]); vertices[index + 2] = new VertexPositionColorNormalTexture(position3 + offset, Color.White, position3 - currentRoom.center, Room.plateTexCoords[3]); vertices[index + 3] = new VertexPositionColorNormalTexture(position2 + offset, Color.White, position2 - currentRoom.center, Room.plateTexCoords[1]); vertices[index + 4] = new VertexPositionColorNormalTexture(position3 + offset, Color.White, position3 - currentRoom.center, Room.plateTexCoords[3]); vertices[index + 5] = new VertexPositionColorNormalTexture(position4 + offset, Color.White, position4 - currentRoom.center, Room.plateTexCoords[2]); } else { Color bodyColor = Color.Red; bodyColor.G = (Byte)(damageCooldown * 255 / damageCooldownMax); vertices[index] = new VertexPositionColorNormalTexture(position1, bodyColor, position1 - currentRoom.center, Room.plateTexCoords[0]); vertices[index + 1] = new VertexPositionColorNormalTexture(position2, bodyColor, position2 - currentRoom.center, Room.plateTexCoords[1]); vertices[index + 2] = new VertexPositionColorNormalTexture(position3, bodyColor, position3 - currentRoom.center, Room.plateTexCoords[3]); vertices[index + 3] = new VertexPositionColorNormalTexture(position2, bodyColor, position2 - currentRoom.center, Room.plateTexCoords[1]); vertices[index + 4] = new VertexPositionColorNormalTexture(position3, bodyColor, position3 - currentRoom.center, Room.plateTexCoords[3]); vertices[index + 5] = new VertexPositionColorNormalTexture(position4, bodyColor, position4 - currentRoom.center, Room.plateTexCoords[2]); } index+=6; } } if (armor == true) { Engine.playerTextureEffect.Texture = Monster.monsterTextures[(int)MonsterTextureId.FacePlate]; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); } else { Engine.playerTextureEffect.Texture = Monster.monsterTextures[(int)MonsterTextureId.FaceWhite]; Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply(); } Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Count()/3, VertexPositionColorNormalTexture.VertexDeclaration); }