예제 #1
0
        private void CheckProjection()
        {
            var weldBlock = GetTargetBlock();

            if (weldBlock != null && CanWeld(weldBlock))
            {
                m_targetProjectionGrid = null;
                return;
            }

            var info = FindProjectedBlock();

            if (info.raycastResult != MyProjectorBase.BuildCheckResult.NotFound)
            {
                if (info.raycastResult == MyProjectorBase.BuildCheckResult.OK)
                {
                    MyCubeBuilder.DrawSemiTransparentBox(info.hitCube.CubeGrid, info.hitCube, Color.Green.ToVector4(), true);
                    m_targetProjectionCube = info.hitCube.Position;
                    m_targetProjectionGrid = info.hitCube.CubeGrid;

                    return;
                }
                else if (info.raycastResult == MyProjectorBase.BuildCheckResult.IntersectedWithGrid || info.raycastResult == MyProjectorBase.BuildCheckResult.IntersectedWithSomethingElse)
                {
                    MyCubeBuilder.DrawSemiTransparentBox(info.hitCube.CubeGrid, info.hitCube, Color.Red.ToVector4(), true);
                }
                else if (info.raycastResult == MyProjectorBase.BuildCheckResult.NotConnected)
                {
                    MyCubeBuilder.DrawSemiTransparentBox(info.hitCube.CubeGrid, info.hitCube, Color.Yellow.ToVector4(), true);
                }
            }

            m_targetProjectionGrid = null;
        }
        private void UpdatePreview()
        {
            if (PreviewGrids == null)
            {
                return;
            }

            if (m_visible == false || HasPreviewBBox == false)
            {
                return;
            }

            // Switch off shadows - does not work
            //foreach (var grid in PreviewGrids)
            //{
            //    grid.Render.CastShadows = false;
            //    foreach (var block in grid.GetBlocks())
            //    {
            //        if (block.FatBlock != null)
            //        {
            //            block.FatBlock.Render.CastShadows = false;
            //        }
            //    }
            //}

            string lineMaterial = m_canBePlaced ? "GizmoDrawLine" : "GizmoDrawLineRed";
            Color  white        = Color.White;

            foreach (var grid in PreviewGrids)
            {
                BoundingBoxD localAABB  = (BoundingBoxD)grid.PositionComp.LocalAABB;
                MatrixD      drawMatrix = grid.PositionComp.WorldMatrix;
                MySimpleObjectDraw.DrawTransparentBox(ref drawMatrix, ref localAABB, ref white, MySimpleObjectRasterizer.Wireframe, 1, 0.04f, lineMaterial: lineMaterial);

                //foreach (var block in grid.GetBlocks())
                //{
                //    if (block.FatBlock != null)
                //        MyEntities.EnableEntityBoundingBoxDraw(block.FatBlock, true, color, lineWidth: 0.04f);
                //}
            }

            if (RemoveBlock != null)
            {
                Vector4 red = new Vector4(Color.Red.ToVector3() * 0.8f, 1);
                MyCubeBuilder.DrawSemiTransparentBox(RemoveBlock.CubeGrid, RemoveBlock, red, lineMaterial: "GizmoDrawLineRed");
            }
        }
예제 #3
0
 private void UpdatePreview()
 {
     if ((base.PreviewGrids != null) && (base.m_visible && this.HasPreviewBBox))
     {
         Vector4?   nullable2;
         MyStringId id    = base.m_canBePlaced ? MyGridClipboard.ID_GIZMO_DRAW_LINE : MyGridClipboard.ID_GIZMO_DRAW_LINE_RED;
         Color      white = Color.White;
         foreach (MyCubeGrid local1 in base.PreviewGrids)
         {
             BoundingBoxD localAABB    = local1.PositionComp.LocalAABB;
             MatrixD      worldMatrix  = local1.PositionComp.WorldMatrix;
             MyStringId?  faceMaterial = null;
             MySimpleObjectDraw.DrawTransparentBox(ref worldMatrix, ref localAABB, ref white, MySimpleObjectRasterizer.Wireframe, 1, 0.04f, faceMaterial, new MyStringId?(id), false, -1, MyBillboard.BlendTypeEnum.Standard, 1f, null);
         }
         Vector4 color = new Vector4(Color.Red.ToVector3() * 0.8f, 1f);
         if (this.RemoveBlocksInMultiBlock.Count <= 0)
         {
             if (this.RemoveBlock != null)
             {
                 nullable2 = null;
                 MyCubeBuilder.DrawSemiTransparentBox(this.RemoveBlock.CubeGrid, this.RemoveBlock, color, false, new MyStringId?(MyGridClipboard.ID_GIZMO_DRAW_LINE_RED), nullable2);
             }
         }
         else
         {
             this.m_tmpBlockPositionsSet.Clear();
             MyCubeBuilder.GetAllBlocksPositions(this.RemoveBlocksInMultiBlock, this.m_tmpBlockPositionsSet);
             foreach (Vector3I local2 in this.m_tmpBlockPositionsSet)
             {
                 nullable2 = null;
                 MyCubeBuilder.DrawSemiTransparentBox(local2, local2, this.RemoveBlock.CubeGrid, color, false, new MyStringId?(MyGridClipboard.ID_GIZMO_DRAW_LINE_RED), nullable2);
             }
             this.m_tmpBlockPositionsSet.Clear();
         }
     }
 }