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 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); }