Esempio n. 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            EditableObject obj;

            #region Create scene and add objects to it
            scene = new EditorScene();

            scene.objects.Add(obj = new ExampleObject(new Vector3(0, -4, 0)));

            List <PathPoint> pathPoints = new List <PathPoint>
            {
                new PathPoint(
                    new Vector3(0, 0, 0),
                    new Vector3(0, 0, 0),
                    new Vector3(2, 0, 0)
                    ),
                new PathPoint(
                    new Vector3(8, 4, 2),
                    new Vector3(-4, 0, 4),
                    new Vector3(4, 0, -4)
                    ),
                new PathPoint(
                    new Vector3(4, 2, -6),
                    new Vector3(0, 0, 0),
                    new Vector3(0, 0, 0)
                    )
            };

            scene.objects.Add(obj = new Path(pathPoints));

            for (int i = 0; i < 20; i++)
            {
                pathPoints = new List <PathPoint>
                {
                    new PathPoint(
                        new Vector3(-3, 6 + i * 2, 0),
                        new Vector3(0, 0, -1.75f),
                        new Vector3(0, 0, 1.75f)
                        ),
                    new PathPoint(
                        new Vector3(0, 6 + i * 2, 3),
                        new Vector3(-1.75f, 0, 0),
                        new Vector3(1.75f, 0, 0)
                        ),
                    new PathPoint(
                        new Vector3(3, 6 + i * 2, 0),
                        new Vector3(0, 0, 1.75f),
                        new Vector3(0, 0, -1.75f)
                        ),
                    new PathPoint(
                        new Vector3(0, 6 + i * 2, -3),
                        new Vector3(1.75f, 0, 0),
                        new Vector3(-1.75f, 0, 0)
                        )
                };

                scene.objects.Add(obj = new Path(pathPoints)
                {
                    Closed = true
                });
            }

            for (int i = 5; i < 10000; i++)
            {
                scene.objects.Add(obj = new TransformableObject(new Vector3(i, 0, 0), Vector3.Zero, Vector3.One));
            }
            #endregion

            //setup the gl controls
            gL_Control.MainDrawable = scene;
            gL_Control.ActiveCamera = new GL_EditorFramework.StandardCameras.InspectCamera(1f);

            gL_ControlLegacy1.MainDrawable = new SingleObject(new Vector3());
            gL_Control.CameraDistance      = 20;

            //add event handlers to scene and gl control
            scene.SelectionChanged += Scene_SelectionChanged;
            scene.ObjectsMoved     += Scene_ObjectsMoved;
            scene.ListChanged      += Scene_ListChanged;
            scene.ListEntered      += Scene_ListEntered;
            scene.ListInvalidated  += Scene_ListInvalidated;
            gL_Control.KeyDown     += GL_ControlModern1_KeyDown;

            //add categories to sceneListView (in this case 15 references to the same list,
            //which should never be done and only serves for demonstration purposes)
            for (int i = 0; i < 15; i++)
            {
                sceneListView1.RootLists.Add("Test" + i, scene.objects);
            }

            sceneListView1.UpdateComboBoxItems();

            //link the scenes selected objs to sceneListView
            sceneListView1.SelectedItems = scene.SelectedObjects;
            //set current category (highly recommended to do once all categories are added
            sceneListView1.SetRootList("Test0");

            //add event handlers to sceneListView
            sceneListView1.SelectionChanged += SceneListView1_SelectionChanged;
            sceneListView1.ItemsMoved       += SceneListView1_ItemsMoved;
            sceneListView1.ListExited       += SceneListView1_ListExited;

            //auto select the 5th object for testing purposes
            scene.ToogleSelected(scene.objects[4], true);
            Scene_SelectionChanged(this, null);
        }