public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int? paintColor = GetPaintColor(value); Color color2 = paintColor.HasValue ? (color * SubsystemPalette.GetColor(environmentData, paintColor)) : (1.25f * WireColor * color); BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color2, 2f * size, ref matrix, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int?paintColor = PaintableItemBlock.GetColor(Terrain.ExtractData(value)); BlocksManager.DrawMeshBlock(primitivesRenderer, ElementBlock.WireBlock.m_standaloneBlockMesh, (paintColor.HasValue ? SubsystemPalette.GetColor(environmentData, paintColor) : 1.25f * WireBlock.WireColor) * color, 2f * size, ref matrix, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { if ((Terrain.ExtractData(value) >> 10) != 0) { base.DrawBlock(primitivesRenderer, value, color, size, ref matrix, environmentData); return; } int bulletType = (int)GetBulletType(Terrain.ExtractData(value)); float size2 = (bulletType >= 0 && bulletType < m_sizes.Length) ? (size * m_sizes[bulletType]) : size; ItemBlock.DrawFlatBlock(primitivesRenderer, value, size2, ref matrix, ItemBlock.Texture, color, false, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { base.DrawBlock(primitivesRenderer, value, Terrain.ExtractData(value) >> 10 != 0 ? color * Color.LightGray : color, size, ref matrix, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { float num = 8f; if (environmentData != null && environmentData.SubsystemTerrain != null) { Vector3 translation = environmentData.InWorldMatrix.Translation; int num2 = Terrain.ToCell(translation.X); int num3 = Terrain.ToCell(translation.Z); float f = translation.X - (float)num2; float f2 = translation.Z - (float)num3; float x = environmentData.SubsystemTerrain.Terrain.GetSeasonalTemperature(num2, num3); float x2 = environmentData.SubsystemTerrain.Terrain.GetSeasonalTemperature(num2, num3 + 1); float x3 = environmentData.SubsystemTerrain.Terrain.GetSeasonalTemperature(num2 + 1, num3); float x4 = environmentData.SubsystemTerrain.Terrain.GetSeasonalTemperature(num2 + 1, num3 + 1); float x5 = MathUtils.Lerp(x, x2, f2); float x6 = MathUtils.Lerp(x3, x4, f2); num = MathUtils.Lerp(x5, x6, f); } float y = MathUtils.Lerp(1f, 4f, num / 15f); Matrix matrix2 = Matrix.CreateScale(3f * size) * Matrix.CreateTranslation(0f, -0.15f, 0f) * matrix; Matrix matrix3 = Matrix.CreateTranslation(0f, 0f - m_fluidBottomPosition, 0f) * Matrix.CreateScale(1f, y, 1f) * Matrix.CreateTranslation(0f, m_fluidBottomPosition, 0f) * matrix2; BlocksManager.DrawMeshBlock(primitivesRenderer, m_caseMesh, color, 1f, ref matrix2, environmentData); BlocksManager.DrawMeshBlock(primitivesRenderer, m_fluidMesh, color, 1f, ref matrix3, environmentData); }
public override float GetIconViewScale(int value, DrawBlockEnvironmentData environmentData) => 0.5f;
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { ItemBlock.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, ItemBlock.Texture, Color, false, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int value2 = Terrain.ExtractData(value); BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, null, color * SubsystemPalette.GetColor(environmentData, value2), isEmissive: false, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int data = Terrain.ExtractData(value); color *= SubsystemPalette.GetColor(environmentData, GetColor(data)); BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, color, color, environmentData); }
public static void DrawMeshBlock(PrimitivesRenderer3D primitivesRenderer, BlockMesh blockMesh, Texture2D texture, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { environmentData = environmentData ?? m_defaultEnvironmentData; var num1 = LightingManager.LightIntensityByLightValue[environmentData.Light]; var vector4 = new Vector4(color); vector4.X *= num1; vector4.Y *= num1; vector4.Z *= num1; var flag1 = vector4 == Vector4.One; var texturedBatch3D = primitivesRenderer.TexturedBatch(texture, true, 0, null, RasterizerState.CullCounterClockwiseScissor, null, SamplerState.PointClamp); var flag2 = false; var m = !environmentData.ViewProjectionMatrix.HasValue ? matrix : matrix * environmentData.ViewProjectionMatrix.Value; if (size != 1.0) { m = Matrix.CreateScale(size) * m; } flag2 |= m.M14 != 0.0 || m.M24 != 0.0 || m.M34 != 0.0 || m.M44 != 1.0; var count1 = blockMesh.Vertices.Count; var array1 = blockMesh.Vertices.Array; var count2 = blockMesh.Indices.Count; var array2 = blockMesh.Indices.Array; var triangleVertices = texturedBatch3D.TriangleVertices; var count3 = triangleVertices.Count; var count4 = triangleVertices.Count; triangleVertices.Count += count1; for (var index = 0; index < count1; ++index) { var blockMeshVertex = array1[index]; if (flag2) { var result = new Vector4(blockMeshVertex.Position, 1f); Vector4.Transform(ref result, ref m, out result); var num2 = 1f / result.W; blockMeshVertex.Position = new Vector3(result.X * num2, result.Y * num2, result.Z * num2); } else { Vector3.Transform(ref blockMeshVertex.Position, ref m, out blockMeshVertex.Position); } if (flag1 || blockMeshVertex.IsEmissive) { triangleVertices.Array[count4++] = new VertexPositionColorTexture(blockMeshVertex.Position, blockMeshVertex.Color, blockMeshVertex.TextureCoordinates); } else { var color1 = new Color((byte)(blockMeshVertex.Color.R * (double)vector4.X), (byte)(blockMeshVertex.Color.G * (double)vector4.Y), (byte)(blockMeshVertex.Color.B * (double)vector4.Z), (byte)(blockMeshVertex.Color.A * (double)vector4.W)); triangleVertices.Array[count4++] = new VertexPositionColorTexture(blockMeshVertex.Position, color1, blockMeshVertex.TextureCoordinates); } } var triangleIndices = texturedBatch3D.TriangleIndices; var count5 = triangleIndices.Count; triangleIndices.Count += count2; for (var index = 0; index < count2; ++index) { triangleIndices.Array[count5++] = (ushort)((uint)count3 + array2[index]); } }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { color *= m_blockColorsMap.Lookup(environmentData.Temperature, environmentData.Humidity); BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, color, color, environmentData); }
public static void DrawFlatBlock(PrimitivesRenderer3D primitivesRenderer, int value, float size, ref Matrix matrix, Texture2D texture, Color color, bool isEmissive, DrawBlockEnvironmentData environmentData) { environmentData = environmentData ?? m_defaultEnvironmentData; if (!isEmissive) { color = Color.MultiplyColorOnly(color, LightingManager.LightIntensityByLightValue[environmentData.Light]); } var translation = matrix.Translation; Vector3 v2; Vector3 vector3; if (environmentData.BillboardDirection.HasValue) { v2 = Vector3.Normalize(Vector3.Cross(environmentData.BillboardDirection.Value, Vector3.UnitY)); vector3 = -Vector3.Normalize(Vector3.Cross(environmentData.BillboardDirection.Value, v2)); } else { v2 = matrix.Right; vector3 = matrix.Up; } var result1 = translation + 0.85f * size * (-v2 - vector3); var result2 = translation + 0.85f * size * (v2 - vector3); var result3 = translation + 0.85f * size * (-v2 + vector3); var result4 = translation + 0.85f * size * (v2 + vector3); if (environmentData.ViewProjectionMatrix.HasValue) { var m = environmentData.ViewProjectionMatrix.Value; Vector3.Transform(ref result1, ref m, out result1); Vector3.Transform(ref result2, ref m, out result2); Vector3.Transform(ref result3, ref m, out result3); Vector3.Transform(ref result4, ref m, out result4); } var block = Blocks[Terrain.ExtractContents(value)]; Vector4 vector4; if (texture == null) { texture = environmentData.SubsystemTerrain != null ? environmentData.SubsystemTerrain.SubsystemAnimatedTextures.AnimatedBlocksTexture : BlocksTexturesManager.DefaultBlocksTexture; vector4 = m_slotTexCoords[block.GetFaceTextureSlot(-1, value)]; } else { vector4 = new Vector4(0.0f, 0.0f, 1f, 1f); } var texturedBatch3D = primitivesRenderer.TexturedBatch(texture, true, 0, null, RasterizerState.CullCounterClockwiseScissor, null, SamplerState.PointClamp); texturedBatch3D.QueueQuad(result1, result3, result4, result2, new Vector2(vector4.X, vector4.W), new Vector2(vector4.X, vector4.Y), new Vector2(vector4.Z, vector4.Y), new Vector2(vector4.Z, vector4.W), color); if (environmentData.BillboardDirection.HasValue) { return; } texturedBatch3D.QueueQuad(result1, result2, result4, result3, new Vector2(vector4.X, vector4.W), new Vector2(vector4.Z, vector4.W), new Vector2(vector4.Z, vector4.Y), new Vector2(vector4.X, vector4.Y), color); }
public static void DrawCubeBlock(PrimitivesRenderer3D primitivesRenderer, int value, Vector3 size, ref Matrix matrix, Color color, Color topColor, DrawBlockEnvironmentData environmentData) { environmentData = environmentData ?? m_defaultEnvironmentData; var texture = environmentData.SubsystemTerrain != null ? environmentData.SubsystemTerrain.SubsystemAnimatedTextures.AnimatedBlocksTexture : BlocksTexturesManager.DefaultBlocksTexture; var texturedBatch3D = primitivesRenderer.TexturedBatch(texture, true, 0, null, RasterizerState.CullCounterClockwiseScissor, null, SamplerState.PointClamp); var s = LightingManager.LightIntensityByLightValue[environmentData.Light]; color = Color.MultiplyColorOnly(color, s); topColor = Color.MultiplyColorOnly(topColor, s); var translation = matrix.Translation; var vector3_1 = matrix.Right * size.X; var vector3_2 = matrix.Up * size.Y; var vector3_3 = matrix.Forward * size.Z; var result1 = translation + 0.5f * (-vector3_1 - vector3_2 - vector3_3); var result2 = translation + 0.5f * (vector3_1 - vector3_2 - vector3_3); var result3 = translation + 0.5f * (-vector3_1 + vector3_2 - vector3_3); var result4 = translation + 0.5f * (vector3_1 + vector3_2 - vector3_3); var result5 = translation + 0.5f * (-vector3_1 - vector3_2 + vector3_3); var result6 = translation + 0.5f * (vector3_1 - vector3_2 + vector3_3); var result7 = translation + 0.5f * (-vector3_1 + vector3_2 + vector3_3); var result8 = translation + 0.5f * (vector3_1 + vector3_2 + vector3_3); if (environmentData.ViewProjectionMatrix.HasValue) { var m = environmentData.ViewProjectionMatrix.Value; Vector3.Transform(ref result1, ref m, out result1); Vector3.Transform(ref result2, ref m, out result2); Vector3.Transform(ref result3, ref m, out result3); Vector3.Transform(ref result4, ref m, out result4); Vector3.Transform(ref result5, ref m, out result5); Vector3.Transform(ref result6, ref m, out result6); Vector3.Transform(ref result7, ref m, out result7); Vector3.Transform(ref result8, ref m, out result8); } var block = Blocks[Terrain.ExtractContents(value)]; var slotTexCoord1 = m_slotTexCoords[block.GetFaceTextureSlot(0, value)]; var color1 = Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Forward)); texturedBatch3D.QueueQuad(result1, result3, result4, result2, new Vector2(slotTexCoord1.X, slotTexCoord1.W), new Vector2(slotTexCoord1.X, slotTexCoord1.Y), new Vector2(slotTexCoord1.Z, slotTexCoord1.Y), new Vector2(slotTexCoord1.Z, slotTexCoord1.W), color1); var slotTexCoord2 = m_slotTexCoords[block.GetFaceTextureSlot(2, value)]; var color2 = Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(matrix.Forward)); texturedBatch3D.QueueQuad(result5, result6, result8, result7, new Vector2(slotTexCoord2.Z, slotTexCoord2.W), new Vector2(slotTexCoord2.X, slotTexCoord2.W), new Vector2(slotTexCoord2.X, slotTexCoord2.Y), new Vector2(slotTexCoord2.Z, slotTexCoord2.Y), color2); var slotTexCoord3 = m_slotTexCoords[block.GetFaceTextureSlot(5, value)]; var color3 = Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Up)); texturedBatch3D.QueueQuad(result1, result2, result6, result5, new Vector2(slotTexCoord3.X, slotTexCoord3.Y), new Vector2(slotTexCoord3.Z, slotTexCoord3.Y), new Vector2(slotTexCoord3.Z, slotTexCoord3.W), new Vector2(slotTexCoord3.X, slotTexCoord3.W), color3); var slotTexCoord4 = m_slotTexCoords[block.GetFaceTextureSlot(4, value)]; var color4 = Color.MultiplyColorOnly(topColor, LightingManager.CalculateLighting(matrix.Up)); texturedBatch3D.QueueQuad(result3, result7, result8, result4, new Vector2(slotTexCoord4.X, slotTexCoord4.W), new Vector2(slotTexCoord4.X, slotTexCoord4.Y), new Vector2(slotTexCoord4.Z, slotTexCoord4.Y), new Vector2(slotTexCoord4.Z, slotTexCoord4.W), color4); var slotTexCoord5 = m_slotTexCoords[block.GetFaceTextureSlot(1, value)]; var color5 = Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Right)); texturedBatch3D.QueueQuad(result1, result5, result7, result3, new Vector2(slotTexCoord5.Z, slotTexCoord5.W), new Vector2(slotTexCoord5.X, slotTexCoord5.W), new Vector2(slotTexCoord5.X, slotTexCoord5.Y), new Vector2(slotTexCoord5.Z, slotTexCoord5.Y), color5); var slotTexCoord6 = m_slotTexCoords[block.GetFaceTextureSlot(3, value)]; var color6 = Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(matrix.Right)); texturedBatch3D.QueueQuad(result2, result4, result8, result6, new Vector2(slotTexCoord6.X, slotTexCoord6.W), new Vector2(slotTexCoord6.X, slotTexCoord6.Y), new Vector2(slotTexCoord6.Z, slotTexCoord6.Y), new Vector2(slotTexCoord6.Z, slotTexCoord6.W), color6); }
public override Vector3 GetIconBlockOffset(int value, DrawBlockEnvironmentData environmentData) => new Vector3(0f, -0.2f, 0f);
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, null, color * new Color(248, 255, 232), isEmissive: false, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int color2 = GetColor(Terrain.ExtractData(value)); BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshesByColor[color2], color, 2f * size, ref matrix, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int bulletType = (int)GetBulletType(Terrain.ExtractData(value)); float size2 = (bulletType >= 0 && bulletType < m_sizes.Length) ? (size * m_sizes[bulletType]) : size; BlocksManager.DrawFlatBlock(primitivesRenderer, value, size2, ref matrix, null, color, isEmissive: false, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, null, color * BlockColorsMap.SeagrassColorsMap.Lookup(environmentData.Temperature, environmentData.Humidity), isEmissive: false, environmentData); }
public override Vector3 GetIconBlockOffset(int value, DrawBlockEnvironmentData environmentData) => new Vector3 { Y = 0.45f };
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { }
public override Vector3 GetIconViewOffset(int value, DrawBlockEnvironmentData environmentData) => new Vector3(-1, 0.5f, 0);
public static void DrawCubeBlock(PrimitivesRenderer3D primitivesRenderer, int value, Vector3 size, ref Matrix matrix, Color color, Color topColor, DrawBlockEnvironmentData environmentData) { environmentData = (environmentData ?? m_defaultEnvironmentData); Texture2D texture = (environmentData.SubsystemTerrain != null) ? environmentData.SubsystemTerrain.SubsystemAnimatedTextures.AnimatedBlocksTexture : BlocksTexturesManager.DefaultBlocksTexture; TexturedBatch3D texturedBatch3D = primitivesRenderer.TexturedBatch(texture, useAlphaTest: true, 0, null, RasterizerState.CullCounterClockwiseScissor, null, SamplerState.PointClamp); float s = LightingManager.LightIntensityByLightValue[environmentData.Light]; color = Color.MultiplyColorOnly(color, s); topColor = Color.MultiplyColorOnly(topColor, s); Vector3 translation = matrix.Translation; Vector3 vector = matrix.Right * size.X; Vector3 v = matrix.Up * size.Y; Vector3 v2 = matrix.Forward * size.Z; Vector3 v3 = translation + 0.5f * (-vector - v - v2); Vector3 v4 = translation + 0.5f * (vector - v - v2); Vector3 v5 = translation + 0.5f * (-vector + v - v2); Vector3 v6 = translation + 0.5f * (vector + v - v2); Vector3 v7 = translation + 0.5f * (-vector - v + v2); Vector3 v8 = translation + 0.5f * (vector - v + v2); Vector3 v9 = translation + 0.5f * (-vector + v + v2); Vector3 v10 = translation + 0.5f * (vector + v + v2); if (environmentData.ViewProjectionMatrix.HasValue) { Matrix m = environmentData.ViewProjectionMatrix.Value; Vector3.Transform(ref v3, ref m, out v3); Vector3.Transform(ref v4, ref m, out v4); Vector3.Transform(ref v5, ref m, out v5); Vector3.Transform(ref v6, ref m, out v6); Vector3.Transform(ref v7, ref m, out v7); Vector3.Transform(ref v8, ref m, out v8); Vector3.Transform(ref v9, ref m, out v9); Vector3.Transform(ref v10, ref m, out v10); } int num = Terrain.ExtractContents(value); Block block = Blocks[num]; Vector4 vector2 = m_slotTexCoords[block.GetFaceTextureSlot(0, value)]; texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Forward)), p1: v3, p2: v5, p3: v6, p4: v4, texCoord1: new Vector2(vector2.X, vector2.W), texCoord2: new Vector2(vector2.X, vector2.Y), texCoord3: new Vector2(vector2.Z, vector2.Y), texCoord4: new Vector2(vector2.Z, vector2.W)); vector2 = m_slotTexCoords[block.GetFaceTextureSlot(2, value)]; texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(matrix.Forward)), p1: v7, p2: v8, p3: v10, p4: v9, texCoord1: new Vector2(vector2.Z, vector2.W), texCoord2: new Vector2(vector2.X, vector2.W), texCoord3: new Vector2(vector2.X, vector2.Y), texCoord4: new Vector2(vector2.Z, vector2.Y)); vector2 = m_slotTexCoords[block.GetFaceTextureSlot(5, value)]; texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Up)), p1: v3, p2: v4, p3: v8, p4: v7, texCoord1: new Vector2(vector2.X, vector2.Y), texCoord2: new Vector2(vector2.Z, vector2.Y), texCoord3: new Vector2(vector2.Z, vector2.W), texCoord4: new Vector2(vector2.X, vector2.W)); vector2 = m_slotTexCoords[block.GetFaceTextureSlot(4, value)]; texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(topColor, LightingManager.CalculateLighting(matrix.Up)), p1: v5, p2: v9, p3: v10, p4: v6, texCoord1: new Vector2(vector2.X, vector2.W), texCoord2: new Vector2(vector2.X, vector2.Y), texCoord3: new Vector2(vector2.Z, vector2.Y), texCoord4: new Vector2(vector2.Z, vector2.W)); vector2 = m_slotTexCoords[block.GetFaceTextureSlot(1, value)]; texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(-matrix.Right)), p1: v3, p2: v7, p3: v9, p4: v5, texCoord1: new Vector2(vector2.Z, vector2.W), texCoord2: new Vector2(vector2.X, vector2.W), texCoord3: new Vector2(vector2.X, vector2.Y), texCoord4: new Vector2(vector2.Z, vector2.Y)); vector2 = m_slotTexCoords[block.GetFaceTextureSlot(3, value)]; texturedBatch3D.QueueQuad(color: Color.MultiplyColorOnly(color, LightingManager.CalculateLighting(matrix.Right)), p1: v4, p2: v6, p3: v10, p4: v8, texCoord1: new Vector2(vector2.X, vector2.W), texCoord2: new Vector2(vector2.X, vector2.Y), texCoord3: new Vector2(vector2.Z, vector2.Y), texCoord4: new Vector2(vector2.Z, vector2.W)); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { color *= SubsystemPalette.GetColor(environmentData, GetPaintColor(value)) * new Color(255, 153, 18); BlocksManager.DrawCubeBlock(primitivesRenderer, value, new Vector3(size), ref matrix, color, color, environmentData); }
public static void DrawFlatBlock(PrimitivesRenderer3D primitivesRenderer, int value, float size, ref Matrix matrix, Texture2D texture, Color color, bool isEmissive, DrawBlockEnvironmentData environmentData) { environmentData = (environmentData ?? m_defaultEnvironmentData); if (!isEmissive) { float s = LightingManager.LightIntensityByLightValue[environmentData.Light]; color = Color.MultiplyColorOnly(color, s); } Vector3 translation = matrix.Translation; Vector3 vector; Vector3 v; if (environmentData.BillboardDirection.HasValue) { vector = Vector3.Normalize(Vector3.Cross(environmentData.BillboardDirection.Value, Vector3.UnitY)); v = -Vector3.Normalize(Vector3.Cross(environmentData.BillboardDirection.Value, vector)); } else { vector = matrix.Right; v = matrix.Up; } Vector3 v2 = translation + 0.85f * size * (-vector - v); Vector3 v3 = translation + 0.85f * size * (vector - v); Vector3 v4 = translation + 0.85f * size * (-vector + v); Vector3 v5 = translation + 0.85f * size * (vector + v); if (environmentData.ViewProjectionMatrix.HasValue) { Matrix m = environmentData.ViewProjectionMatrix.Value; Vector3.Transform(ref v2, ref m, out v2); Vector3.Transform(ref v3, ref m, out v3); Vector3.Transform(ref v4, ref m, out v4); Vector3.Transform(ref v5, ref m, out v5); } int num = Terrain.ExtractContents(value); Block block = Blocks[num]; Vector4 vector2; if (texture != null) { vector2 = new Vector4(0f, 0f, 1f, 1f); } else { texture = ((environmentData.SubsystemTerrain != null) ? environmentData.SubsystemTerrain.SubsystemAnimatedTextures.AnimatedBlocksTexture : BlocksTexturesManager.DefaultBlocksTexture); vector2 = m_slotTexCoords[block.GetFaceTextureSlot(-1, value)]; } TexturedBatch3D texturedBatch3D = primitivesRenderer.TexturedBatch(texture, useAlphaTest: true, 0, null, RasterizerState.CullCounterClockwiseScissor, null, SamplerState.PointClamp); texturedBatch3D.QueueQuad(v2, v4, v5, v3, new Vector2(vector2.X, vector2.W), new Vector2(vector2.X, vector2.Y), new Vector2(vector2.Z, vector2.Y), new Vector2(vector2.Z, vector2.W), color); if (!environmentData.BillboardDirection.HasValue) { texturedBatch3D.QueueQuad(v2, v3, v5, v4, new Vector2(vector2.X, vector2.W), new Vector2(vector2.Z, vector2.W), new Vector2(vector2.Z, vector2.Y), new Vector2(vector2.X, vector2.Y), color); } }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { if (GetIsWild(Terrain.ExtractData(value))) { color *= BlockColorsMap.GrassColorsMap.Lookup(environmentData.Temperature, environmentData.Humidity); BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, null, color, isEmissive: false, environmentData); } else { BlocksManager.DrawFlatBlock(primitivesRenderer, value, size, ref matrix, null, color, isEmissive: false, environmentData); } }
public static void DrawMeshBlock(PrimitivesRenderer3D primitivesRenderer, BlockMesh blockMesh, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { environmentData = (environmentData ?? m_defaultEnvironmentData); Texture2D texture = (environmentData.SubsystemTerrain != null) ? environmentData.SubsystemTerrain.SubsystemAnimatedTextures.AnimatedBlocksTexture : BlocksTexturesManager.DefaultBlocksTexture; DrawMeshBlock(primitivesRenderer, blockMesh, texture, color, size, ref matrix, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int?color2 = GetColor(Terrain.ExtractData(value)); if (color2.HasValue) { BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneColoredBlockMesh, color * SubsystemPalette.GetColor(environmentData, color2), size, ref matrix, environmentData); } else { BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneUncoloredBlockMesh, color, size, ref matrix, environmentData); } }
public static void DrawMeshBlock(PrimitivesRenderer3D primitivesRenderer, BlockMesh blockMesh, Texture2D texture, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { environmentData = (environmentData ?? m_defaultEnvironmentData); float num = LightingManager.LightIntensityByLightValue[environmentData.Light]; Vector4 v = new Vector4(color); v.X *= num; v.Y *= num; v.Z *= num; bool flag = v == Vector4.One; TexturedBatch3D texturedBatch3D = primitivesRenderer.TexturedBatch(texture, useAlphaTest: true, 0, null, RasterizerState.CullCounterClockwiseScissor, null, SamplerState.PointClamp); bool flag2 = false; Matrix m = (!environmentData.ViewProjectionMatrix.HasValue) ? matrix : (matrix * environmentData.ViewProjectionMatrix.Value); if (size != 1f) { m = Matrix.CreateScale(size) * m; } if (m.M14 != 0f || m.M24 != 0f || m.M34 != 0f || m.M44 != 1f) { flag2 = true; } int count = blockMesh.Vertices.Count; BlockMeshVertex[] array = blockMesh.Vertices.Array; int count2 = blockMesh.Indices.Count; ushort[] array2 = blockMesh.Indices.Array; DynamicArray <VertexPositionColorTexture> triangleVertices = texturedBatch3D.TriangleVertices; int count3 = triangleVertices.Count; int count4 = triangleVertices.Count; triangleVertices.Count += count; for (int i = 0; i < count; i++) { BlockMeshVertex blockMeshVertex = array[i]; if (flag2) { Vector4 v2 = new Vector4(blockMeshVertex.Position, 1f); Vector4.Transform(ref v2, ref m, out v2); float num2 = 1f / v2.W; blockMeshVertex.Position = new Vector3(v2.X * num2, v2.Y * num2, v2.Z * num2); } else { Vector3.Transform(ref blockMeshVertex.Position, ref m, out blockMeshVertex.Position); } if (flag || blockMeshVertex.IsEmissive) { triangleVertices.Array[count4++] = new VertexPositionColorTexture(blockMeshVertex.Position, blockMeshVertex.Color, blockMeshVertex.TextureCoordinates); continue; } Color color2 = new Color((byte)((float)(int)blockMeshVertex.Color.R * v.X), (byte)((float)(int)blockMeshVertex.Color.G * v.Y), (byte)((float)(int)blockMeshVertex.Color.B * v.Z), (byte)((float)(int)blockMeshVertex.Color.A * v.W)); triangleVertices.Array[count4++] = new VertexPositionColorTexture(blockMeshVertex.Position, color2, blockMeshVertex.TextureCoordinates); } DynamicArray <ushort> triangleIndices = texturedBatch3D.TriangleIndices; int count5 = triangleIndices.Count; triangleIndices.Count += count2; for (int j = 0; j < count2; j++) { triangleIndices.Array[count5++] = (ushort)(count3 + array2[j]); } }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneMesh, color, size, ref matrix, environmentData); }
public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData) { int mode = (int)GetMode(Terrain.ExtractData(value)); if (mode < m_standaloneBlockMeshes.Length && m_standaloneBlockMeshes[mode] != null) { BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMeshes[mode], color, 1f * size, ref matrix, environmentData); } }