public override void Initialize() { Model model = ContentManager.Get <Model>("Models/Arrows"); foreach (int enumValue in EnumUtils.GetEnumValues(typeof(ArrowType))) { if (enumValue > 15) { throw new InvalidOperationException("Too many arrow types."); } Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(m_shaftNames[enumValue]).ParentBone); Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(m_stabilizerNames[enumValue]).ParentBone); Matrix boneAbsoluteTransform3 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(m_tipNames[enumValue]).ParentBone); BlockMesh blockMesh = new BlockMesh(); blockMesh.AppendModelMeshPart(model.FindMesh(m_tipNames[enumValue]).MeshParts[0], boneAbsoluteTransform3 * Matrix.CreateTranslation(0f, m_offsets[enumValue], 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); blockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_tipTextureSlots[enumValue] % 16) / 16f, (float)(m_tipTextureSlots[enumValue] / 16) / 16f, 0f)); BlockMesh blockMesh2 = new BlockMesh(); blockMesh2.AppendModelMeshPart(model.FindMesh(m_shaftNames[enumValue]).MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, m_offsets[enumValue], 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); blockMesh2.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_shaftTextureSlots[enumValue] % 16) / 16f, (float)(m_shaftTextureSlots[enumValue] / 16) / 16f, 0f)); BlockMesh blockMesh3 = new BlockMesh(); blockMesh3.AppendModelMeshPart(model.FindMesh(m_stabilizerNames[enumValue]).MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, m_offsets[enumValue], 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White); blockMesh3.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_stabilizerTextureSlots[enumValue] % 16) / 16f, (float)(m_stabilizerTextureSlots[enumValue] / 16) / 16f, 0f)); BlockMesh blockMesh4 = new BlockMesh(); blockMesh4.AppendBlockMesh(blockMesh); blockMesh4.AppendBlockMesh(blockMesh2); blockMesh4.AppendBlockMesh(blockMesh3); m_standaloneBlockMeshes.Add(blockMesh4); } base.Initialize(); }
public override void Initialize() { Model model = ContentManager.Get <Model>(m_modelName); Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Keg").ParentBone); FuseOffset = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Fuse").ParentBone).Translation + new Vector3(0.5f, 0f, 0.5f); BlockMesh blockMesh = new BlockMesh(); blockMesh.AppendModelMeshPart(model.FindMesh("Keg").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_blockMesh.AppendBlockMesh(blockMesh); if (m_isIncendiary) { m_blockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(-0.25f, 0f, 0f)); } m_collisionBoxes = new BoundingBox[1] { blockMesh.CalculateBoundingBox() }; m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Keg").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); if (m_isIncendiary) { m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(-0.25f, 0f, 0f)); } base.Initialize(); }
public override void Initialize() { Model model = ContentManager.Get <Model>(m_modelName); Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Sign").ParentBone); Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Surface").ParentBone); for (int i = 0; i < 4; i++) { float radians = (float)Math.PI / 2f * (float)i; Matrix m = Matrix.CreateTranslation(0f, 0f, -15f / 32f) * Matrix.CreateRotationY(radians) * Matrix.CreateTranslation(0.5f, -0.3125f, 0.5f); BlockMesh blockMesh = new BlockMesh(); blockMesh.AppendModelMeshPart(model.FindMesh("Sign").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_blockMeshes[i] = new BlockMesh(); m_blockMeshes[i].AppendBlockMesh(blockMesh); m_coloredBlockMeshes[i] = new BlockMesh(); m_coloredBlockMeshes[i].AppendBlockMesh(m_blockMeshes[i]); m_blockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f)); m_coloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f)); m_collisionBoxes[i] = new BoundingBox[1]; m_collisionBoxes[i][0] = blockMesh.CalculateBoundingBox(); m_surfaceMeshes[i] = new BlockMesh(); m_surfaceMeshes[i].AppendModelMeshPart(model.FindMesh("Surface").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_surfaceNormals[i] = -m.Forward; } m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Sign").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.6f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_standaloneColoredBlockMesh.AppendBlockMesh(m_standaloneBlockMesh); m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f)); m_standaloneColoredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f)); base.Initialize(); }
public override void Initialize() { Model model = ContentManager.Get <Model>("Models/Axe"); Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Handle").ParentBone); Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Head").ParentBone); BlockMesh blockMesh = new BlockMesh(); blockMesh.AppendModelMeshPart(model.FindMesh("Handle").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); blockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_handleTextureSlot % 16) / 16f, (float)(m_handleTextureSlot / 16) / 16f, 0f)); BlockMesh blockMesh2 = new BlockMesh(); blockMesh2.AppendModelMeshPart(model.FindMesh("Head").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); blockMesh2.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_headTextureSlot % 16) / 16f, (float)(m_headTextureSlot / 16) / 16f, 0f)); m_standaloneBlockMesh.AppendBlockMesh(blockMesh); m_standaloneBlockMesh.AppendBlockMesh(blockMesh2); base.Initialize(); }
public override void Initialize() { Model model = ContentManager.Get <Model>(m_modelName); Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Post").ParentBone); Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Planks").ParentBone); for (int i = 0; i < 16; i++) { int rotation = GetRotation(i); bool open = GetOpen(i); bool rightHanded = GetRightHanded(i); float num = (!rightHanded) ? 1 : (-1); Matrix identity = Matrix.Identity; identity *= Matrix.CreateScale(0f - num, 1f, 1f); identity *= Matrix.CreateTranslation((0.5f - m_pivotDistance) * num, 0f, 0f) * Matrix.CreateRotationY(open ? (num * (float)Math.PI / 2f) : 0f) * Matrix.CreateTranslation((0f - (0.5f - m_pivotDistance)) * num, 0f, 0f); identity *= Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY((float)rotation * (float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f); m_blockMeshes[i] = new BlockMesh(); m_blockMeshes[i].AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform * identity, makeEmissive: false, !rightHanded, doubleSided: false, flipNormals: false, m_postColor); m_blockMeshes[i].AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * identity, makeEmissive: false, !rightHanded, doubleSided: false, flipNormals: false, Color.White); if (m_doubleSided) { m_blockMeshes[i].AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * identity, makeEmissive: false, rightHanded, doubleSided: false, flipNormals: true, Color.White); } m_coloredBlockMeshes[i] = new BlockMesh(); m_coloredBlockMeshes[i].AppendBlockMesh(m_blockMeshes[i]); m_blockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f)); m_coloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f)); BoundingBox boundingBox = m_blockMeshes[i].CalculateBoundingBox(); boundingBox.Min.X = MathUtils.Saturate(boundingBox.Min.X); boundingBox.Min.Y = MathUtils.Saturate(boundingBox.Min.Y); boundingBox.Min.Z = MathUtils.Saturate(boundingBox.Min.Z); boundingBox.Max.X = MathUtils.Saturate(boundingBox.Max.X); boundingBox.Max.Y = MathUtils.Saturate(boundingBox.Max.Y); boundingBox.Max.Z = MathUtils.Saturate(boundingBox.Max.Z); m_collisionBoxes[i] = new BoundingBox[1] { boundingBox }; } m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, m_postColor); m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); if (m_doubleSided) { m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, Color.White); } m_standaloneColoredBlockMesh.AppendBlockMesh(m_standaloneBlockMesh); m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f)); m_standaloneColoredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f)); base.Initialize(); }
public override void Initialize() { Model model = ContentManager.Get <Model>(m_modelName); Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Sign").ParentBone); Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Post").ParentBone); Matrix boneAbsoluteTransform3 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Surface").ParentBone); for (int i = 0; i < 16; i++) { bool hanging = GetHanging(i); Matrix m = Matrix.CreateRotationY((float)GetDirection(i) * (float)Math.PI / 4f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f); if (hanging) { m *= Matrix.CreateScale(1f, -1f, 1f) * Matrix.CreateTranslation(0f, 1f, 0f); } m_directions[i] = m.Forward; BlockMesh blockMesh = new BlockMesh(); blockMesh.AppendModelMeshPart(model.FindMesh("Sign").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, hanging, doubleSided: false, flipNormals: false, Color.White); BlockMesh blockMesh2 = new BlockMesh(); blockMesh2.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: false, hanging, doubleSided: false, flipNormals: false, Color.White); m_blockMeshes[i] = new BlockMesh(); m_blockMeshes[i].AppendBlockMesh(blockMesh); m_blockMeshes[i].AppendBlockMesh(blockMesh2); m_coloredBlockMeshes[i] = new BlockMesh(); m_coloredBlockMeshes[i].AppendBlockMesh(m_blockMeshes[i]); m_blockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f)); m_coloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f)); m_collisionBoxes[i] = new BoundingBox[2]; m_collisionBoxes[i][0] = blockMesh.CalculateBoundingBox(); m_collisionBoxes[i][1] = blockMesh2.CalculateBoundingBox(); m_surfaceMeshes[i] = new BlockMesh(); m_surfaceMeshes[i].AppendModelMeshPart(model.FindMesh("Surface").MeshParts[0], boneAbsoluteTransform3 * m, makeEmissive: false, hanging, doubleSided: false, flipNormals: false, Color.White); m_surfaceNormals[i] = -m.Forward; if (hanging) { for (int j = 0; j < m_surfaceMeshes[i].Vertices.Count; j++) { Vector2 textureCoordinates = m_surfaceMeshes[i].Vertices.Array[j].TextureCoordinates; textureCoordinates.Y = 1f - textureCoordinates.Y; m_surfaceMeshes[i].Vertices.Array[j].TextureCoordinates = textureCoordinates; } } } m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Sign").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.6f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -0.6f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_standaloneColoredBlockMesh.AppendBlockMesh(m_standaloneBlockMesh); m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f)); m_standaloneColoredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f)); base.Initialize(); }
public override void Initialize() { Model model = ContentManager.Get <Model>(m_modelName); Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Post").ParentBone); Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Planks").ParentBone); for (int i = 0; i < 16; i++) { bool num = (i & 1) != 0; bool flag = (i & 2) != 0; bool flag2 = (i & 4) != 0; bool flag3 = (i & 8) != 0; List <BoundingBox> list = new List <BoundingBox>(); Matrix m = Matrix.CreateTranslation(0.5f, 0f, 0.5f); BlockMesh blockMesh = new BlockMesh(); blockMesh.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); BoundingBox item = blockMesh.CalculateBoundingBox(); item.Min.X -= 0.1f; item.Min.Z -= 0.1f; item.Max.X += 0.1f; item.Max.Z += 0.1f; list.Add(item); BlockMesh blockMesh2 = new BlockMesh(); if (num) { BlockMesh blockMesh3 = new BlockMesh(); Matrix m2 = Matrix.CreateRotationY(0f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f); blockMesh3.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * m2, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); if (m_doubleSidedPlanks) { blockMesh3.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * m2, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, Color.White); } blockMesh2.AppendBlockMesh(blockMesh3); BoundingBox item2 = blockMesh3.CalculateBoundingBox(); list.Add(item2); } if (flag) { BlockMesh blockMesh4 = new BlockMesh(); Matrix m3 = Matrix.CreateRotationY((float)Math.PI) * Matrix.CreateTranslation(0.5f, 0f, 0.5f); blockMesh4.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * m3, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); if (m_doubleSidedPlanks) { blockMesh4.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * m3, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, Color.White); } blockMesh2.AppendBlockMesh(blockMesh4); BoundingBox item3 = blockMesh4.CalculateBoundingBox(); list.Add(item3); } if (flag2) { BlockMesh blockMesh5 = new BlockMesh(); Matrix m4 = Matrix.CreateRotationY(4.712389f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f); blockMesh5.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * m4, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); if (m_doubleSidedPlanks) { blockMesh5.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * m4, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, Color.White); } blockMesh2.AppendBlockMesh(blockMesh5); BoundingBox item4 = blockMesh5.CalculateBoundingBox(); list.Add(item4); } if (flag3) { BlockMesh blockMesh6 = new BlockMesh(); Matrix m5 = Matrix.CreateRotationY((float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f); blockMesh6.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * m5, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); if (m_doubleSidedPlanks) { blockMesh6.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * m5, makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, Color.White); } blockMesh2.AppendBlockMesh(blockMesh6); BoundingBox item5 = blockMesh6.CalculateBoundingBox(); list.Add(item5); } blockMesh.ModulateColor(m_postColor); m_blockMeshes[i] = new BlockMesh(); m_blockMeshes[i].AppendBlockMesh(blockMesh); m_blockMeshes[i].AppendBlockMesh(blockMesh2); m_blockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f)); m_blockMeshes[i].GenerateSidesData(); m_coloredBlockMeshes[i] = new BlockMesh(); m_coloredBlockMeshes[i].AppendBlockMesh(blockMesh); m_coloredBlockMeshes[i].AppendBlockMesh(blockMesh2); m_coloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f)); m_coloredBlockMeshes[i].GenerateSidesData(); m_collisionBoxes[i] = list.ToArray(); } m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(-0.5f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0.5f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateRotationY(0f) * Matrix.CreateTranslation(-0.5f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); if (m_doubleSidedPlanks) { m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateRotationY(0f) * Matrix.CreateTranslation(-0.5f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, Color.White); } m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateRotationY((float)Math.PI) * Matrix.CreateTranslation(0.5f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White); if (m_doubleSidedPlanks) { m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateRotationY((float)Math.PI) * Matrix.CreateTranslation(0.5f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, Color.White); } m_standaloneColoredBlockMesh.AppendBlockMesh(m_standaloneBlockMesh); m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f)); m_standaloneColoredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f)); base.Initialize(); }
public override void Initialize() { base.Initialize(); var mesh = new BlockMesh(); var vertices = new[] { new BlockMeshVertex { Color = Color.White, TextureCoordinates = new Vector2(0, 0.0625f), Position = new Vector3(0, 0.01f, 1) }, new BlockMeshVertex { Color = Color.White, TextureCoordinates = new Vector2(0.0625f, 0.0625f), Position = new Vector3(1, 0.01f, 1) }, new BlockMeshVertex { Color = Color.White, TextureCoordinates = new Vector2(0.0625f, 0), Position = new Vector3(1, 0.01f, 0) }, new BlockMeshVertex { Color = Color.White, TextureCoordinates = new Vector2(0, 0), Position = new Vector3(0, 0.01f, 0) } }; var indices = new ushort[] { 2, 1, 0, 0, 3, 2 }; mesh.Vertices.AddRange(vertices); mesh.Indices.AddRange(indices); var flatMesh = new BlockMesh(); flatMesh.AppendBlockMesh(mesh); flatMesh.TransformTextureCoordinates(Matrix.CreateTranslation(new Vector3(238 % 16 / 16f, 238 / 16 / 16f, 0f))); var center = Matrix.CreateTranslation(new Vector3(0.5f, 0, 0.5f)); var reverseCenter = Matrix.CreateTranslation(new Vector3(-0.5f, 0, -0.5f)); for (int i = 0; i < 4; i++) { m_blockMeshes[i] = new BlockMesh(); m_blockMeshes[i].AppendBlockMesh(flatMesh); m_blockMeshes[i].TransformPositions(reverseCenter * Matrix.CreateRotationY(MathUtils.PI * 0.5f * i) * center); m_blockMeshes[i].GenerateSidesData(); } flatMesh = new BlockMesh(); flatMesh.AppendBlockMesh(mesh); flatMesh.TransformTextureCoordinates(Matrix.CreateTranslation(new Vector3(237 % 16 / 16f, 237 / 16 / 16f, 0f))); m_blockMeshes[4] = new BlockMesh(); m_blockMeshes[4].AppendBlockMesh(flatMesh); m_blockMeshes[4].GenerateSidesData(); m_blockMeshes[5] = new BlockMesh(); m_blockMeshes[5].AppendBlockMesh(flatMesh); m_blockMeshes[5].TransformPositions(reverseCenter * Matrix.CreateRotationY(MathUtils.PI * 0.5f) * center); m_blockMeshes[5].GenerateSidesData(); mesh = new BlockMesh(); vertices = new BlockMeshVertex[] { new BlockMeshVertex { Color = Color.White, TextureCoordinates = new Vector2(0, 0.0625f), Position = new Vector3(0, 0.01f, 1) }, new BlockMeshVertex { Color = Color.White, TextureCoordinates = new Vector2(0.0625f, 0.0625f), Position = new Vector3(1, 0.01f, 1) }, new BlockMeshVertex { Color = Color.White, TextureCoordinates = new Vector2(0.0625f, 0), Position = new Vector3(1, 1.01f, 0) }, new BlockMeshVertex { Color = Color.White, TextureCoordinates = new Vector2(0, 0), Position = new Vector3(0, 1.01f, 0) } }; indices = new ushort[] { 2, 1, 0, 0, 1, 2, 0, 3, 2, 2, 3, 0 }; mesh.Vertices.AddRange(vertices); mesh.Indices.AddRange(indices); mesh.TransformTextureCoordinates(Matrix.CreateTranslation(new Vector3(237 % 16 / 16f, 237 / 16 / 16f, 0f))); for (int i = 6; i < 10; i++) { m_blockMeshes[i] = new BlockMesh(); m_blockMeshes[i].AppendBlockMesh(mesh); m_blockMeshes[i].TransformPositions(reverseCenter * Matrix.CreateRotationY(MathUtils.PI * 0.5f * i) * center); } var boxes = new [] { new BoundingBox(0, 0, 0, 1, 0.01f, 1) }; for (int i = 0; i < 6; i++) { boundingBoxes[i] = boxes; } boundingBoxes[6] = new BoundingBox[] { new BoundingBox(0, 0, 0, 1, 0.01f, 1), new BoundingBox(0, 0, 0.25f, 1, 0.25f, 1), new BoundingBox(0, 0, 0.5f, 1, 0.5f, 1), new BoundingBox(0, 0, 0.75f, 1, 0.75f, 1) }; boundingBoxes[7] = new BoundingBox[] { new BoundingBox(0, 0, 0, 1, 0.01f, 1), new BoundingBox(0.25f, 0, 0, 1, 0.25f, 1), new BoundingBox(0.5f, 0, 0, 1, 0.5f, 1), new BoundingBox(0.75f, 0, 0, 1, 0.75f, 1) }; boundingBoxes[8] = new BoundingBox[] { new BoundingBox(0, 0, 0, 1, 0.01f, 1), new BoundingBox(0, 0, 0, 1, 0.25f, 0.75f), new BoundingBox(0, 0, 0, 1, 0.5f, 0.5f), new BoundingBox(0, 0, 0, 1, 0.75f, 0.25f) }; boundingBoxes[9] = new BoundingBox[] { new BoundingBox(0, 0, 0, 1, 0.01f, 1), new BoundingBox(0, 0, 0, 0.75f, 0.25f, 1), new BoundingBox(0, 0, 0, 0.5f, 0.5f, 1), new BoundingBox(0, 0, 0, 0.25f, 0.75f, 1) }; }