1

How to remove this redbox in the scene? I use SharpGL. If it is default box and I can't remove it? Need your help, guys.

Code of program is here. It should rotate and scale .obj file. All work's correctly but I need to remove this redbox. Maybe there's any function for deleting this redbox?

using System;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using SharpGL.SceneGraph.Effects;
using SharpGL.SceneGraph.Primitives;
using SharpGL.Serialization.Wavefront;

namespace WindowsFormsApp1
{
    public partial class MainForm : Form
    {
        private readonly ArcBallEffect arcBallEffect = new ArcBallEffect();
        public MainForm()
        {
            InitializeComponent();
            InitializeScene();
        }
        private void InitializeScene()
        {
            sceneControl.MouseDown += new MouseEventHandler(sceneControl_MouseDown);
            sceneControl.MouseMove += new MouseEventHandler(sceneControl_MouseMove);
            sceneControl.MouseUp += new MouseEventHandler(sceneControl_MouseUp);

            sceneControl.Scene.SceneContainer.AddChild(new Grid());
            sceneControl.Scene.SceneContainer.AddChild(new Axies());

            // Загрузка объекта 
            var objec = new ObjFileFormat();
            var objScene = objec.LoadData(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data", "Raptor.obj"));

            // Заполнение сцены
            foreach (var asset in objScene.Assets)
                sceneControl.Scene.Assets.Add(asset);

            // Работа с полигонами
            var polygons = objScene.SceneContainer.Traverse<Polygon>().ToList();

            foreach (var polygon in polygons)
            {
                polygon.Name = "Polygon";
                polygon.Transformation.RotateX = 90f;// положение при старте
                //  Границы полигона.
                var boundingVolume = polygon.BoundingVolume;
                var extent = new float[3];
                polygon.BoundingVolume.GetBoundDimensions(out extent[0], out extent[1], out extent[2]);
                var maxExtent = extent.Max();
                // Скалирование.
                var scaleFactor = maxExtent > 10 ? 7.0f / maxExtent : 1;
                polygon.Parent.RemoveChild(polygon);
                polygon.Transformation.ScaleX = scaleFactor;
                polygon.Transformation.ScaleY = scaleFactor;
                polygon.Transformation.ScaleZ = scaleFactor;
                polygon.Freeze(sceneControl.OpenGL);
                sceneControl.Scene.SceneContainer.AddChild(polygon);
                // Эффекты.
                polygon.AddEffect(new OpenGLAttributesEffect());
                polygon.AddEffect(arcBallEffect);
            }
        }
        //Движения Мыши
        private void sceneControl_MouseDown(object sender, MouseEventArgs e)
        {
            arcBallEffect.ArcBall.SetBounds(sceneControl.Width, sceneControl.Height);
            arcBallEffect.ArcBall.MouseDown(e.X, e.Y);
        }

        private void sceneControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
                arcBallEffect.ArcBall.MouseMove(e.X, e.Y);
        }

        private void sceneControl_MouseUp(object sender, MouseEventArgs e)
        {
            arcBallEffect.ArcBall.MouseUp(e.X, e.Y);
        }
    }
}
Rabbid76
  • 202,892
  • 27
  • 131
  • 174

1 Answers1

1

Just set the Scene's RenderBoundingVolumes property to false:

sceneControl.Scene.RenderBoundingVolumes = false;

Rabbid76
  • 202,892
  • 27
  • 131
  • 174