コード例 #1
0
        public override MyShape Clone()
        {
            MyShapeBox box1 = new MyShapeBox();

            box1.Transformation = base.Transformation;
            box1.Boundaries     = this.Boundaries;
            return(box1);
        }
コード例 #2
0
        private MyBrushBox()
        {
            m_shape = new MyShapeBox();
            m_transform = MatrixD.Identity;

            m_width = new MyBrushGUIPropertyNumberSlider(
                MinScale, MinScale, MaxScale,
                MySessionComponentVoxelHand.VOXEL_HALF,
                MyVoxelBrushGUIPropertyOrder.First, MyCommonTexts.VoxelHandProperty_Box_Width
            );
            m_width.ValueChanged += RecomputeShape;

            m_height = new MyBrushGUIPropertyNumberSlider(
                MinScale, MinScale, MaxScale,
                MySessionComponentVoxelHand.VOXEL_HALF,
                MyVoxelBrushGUIPropertyOrder.Second, MyCommonTexts.VoxelHandProperty_Box_Height
            );
            m_height.ValueChanged += RecomputeShape;

            m_depth = new MyBrushGUIPropertyNumberSlider(
                MinScale, MinScale, MaxScale,
                MySessionComponentVoxelHand.VOXEL_HALF,
                MyVoxelBrushGUIPropertyOrder.Third, MyCommonTexts.VoxelHandProperty_Box_Depth
            );
            m_depth.ValueChanged += RecomputeShape;

            m_list = new List<MyGuiControlBase>();
            m_width.AddControlsToList(m_list);
            m_height.AddControlsToList(m_list);
            m_depth.AddControlsToList(m_list);

            RecomputeShape();
        }
コード例 #3
0
        private MyBrushAutoLevel()
        {
            m_shape = new MyShapeBox();
            m_transform = MatrixD.Identity;

            m_axis = new MyBrushGUIPropertyNumberCombo(
                MyVoxelBrushGUIPropertyOrder.First, MyCommonTexts.VoxelHandProperty_AutoLevel_Axis
            );
            m_axis.AddItem(X_ASIS, MyCommonTexts.VoxelHandProperty_AutoLevel_AxisX);
            m_axis.AddItem(Y_ASIS, MyCommonTexts.VoxelHandProperty_AutoLevel_AxisY);
            m_axis.AddItem(Z_ASIS, MyCommonTexts.VoxelHandProperty_AutoLevel_AxisZ);
            m_axis.SelectItem(Y_ASIS);

            m_area = new MyBrushGUIPropertyNumberSlider(
                MinScale*2f, MinScale, MaxScale,
                MySessionComponentVoxelHand.VOXEL_HALF,
                MyVoxelBrushGUIPropertyOrder.Second, MyCommonTexts.VoxelHandProperty_AutoLevel_Area
            );
            m_area.ValueChanged += RecomputeShape;

            m_height = new MyBrushGUIPropertyNumberSlider(
                MinScale, MinScale, MaxScale,
                MySessionComponentVoxelHand.VOXEL_HALF,
                MyVoxelBrushGUIPropertyOrder.Third, MyCommonTexts.VoxelHandProperty_Box_Height
            );
            m_height.ValueChanged += RecomputeShape;

            m_list = new List<MyGuiControlBase>();
            m_axis.AddControlsToList(m_list);
            m_area.AddControlsToList(m_list);
            m_height.AddControlsToList(m_list);

            RecomputeShape();
        }
コード例 #4
0
        private static void VoxelPlacement()
        {
            var camera = MySector.MainCamera;
            if (camera == null)
                return;

            var offset = 0; // MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF;
            var targetPosition = camera.Position + (Vector3D)camera.ForwardVector * 4.5f - offset;
            MyVoxelBase targetVoxelMap = null;
            foreach (var voxelMap in MySession.Static.VoxelMaps.Instances)
            {
                if (voxelMap.PositionComp.WorldAABB.Contains(targetPosition) == ContainmentType.Contains)
                {
                    targetVoxelMap = voxelMap;
                    break;
                }
            }
            if (targetVoxelMap == null)
                return;

            Vector3I targetVoxel;
            MyVoxelCoordSystems.WorldPositionToVoxelCoord(targetVoxelMap.PositionLeftBottomCorner, ref targetPosition, out targetVoxel);
            MyVoxelCoordSystems.VoxelCoordToWorldPosition(targetVoxelMap.PositionLeftBottomCorner, ref targetVoxel, out targetPosition);
            targetPosition += offset;
            var size = 3.0f;
            const int shapeType = 0;

            {
                BoundingBoxD aabb;
                MyVoxelCoordSystems.VoxelCoordToWorldAABB(targetVoxelMap.PositionLeftBottomCorner, ref targetVoxel, out aabb);
                VRageRender.MyRenderProxy.DebugDrawAABB(aabb, Color.Blue, 1f, 1f, true);
            }

            BoundingSphereD sphere;
            BoundingBoxD box;
            if (shapeType == 0)
            {
                sphere = new BoundingSphereD(targetPosition, size * 0.5f);
                VRageRender.MyRenderProxy.DebugDrawSphere(targetPosition, size * 0.5f, Color.White, 1f, true);
            }
            else if (shapeType == 1)
            {
                box = new BoundingBoxD(
                    targetPosition - size * 0.5f,
                    targetPosition + size * 0.5f);
                VRageRender.MyRenderProxy.DebugDrawAABB(box, Color.White, 1f, 1f, true);
            }
            else if (shapeType == 2)
            {
                MyVoxelCoordSystems.WorldPositionToVoxelCoord(targetVoxelMap.PositionLeftBottomCorner, ref targetPosition, out targetVoxel);
                //targetVoxel = Vector3I.Zero;
                MyVoxelCoordSystems.VoxelCoordToWorldAABB(targetVoxelMap.PositionLeftBottomCorner, ref targetVoxel, out box);
                VRageRender.MyRenderProxy.DebugDrawAABB(box, Vector3.One, 1f, 1f, true);
            }

            bool leftPressed = MyInput.Static.IsLeftMousePressed();
            if (leftPressed)
            {
                MyShape shape;
                if (shapeType == 0)
                {
                    shape = new MyShapeSphere()
                    {
                        Center = sphere.Center,
                        Radius = (float)sphere.Radius,
                    };
                }
                else if (shapeType == 1 || shapeType == 2)
                {
                    shape = new MyShapeBox()
                    {
                        Boundaries = box,
                    };
                }
                if (shape != null)
                {
                    float dummy;
                    MyVoxelMaterialDefinition dummy2;
                    MyVoxelGenerator.CutOutShapeWithProperties(targetVoxelMap, shape, out dummy, out dummy2);
                }
            }
        }