コード例 #1
0
ファイル: ThreeDeeEditor.cs プロジェクト: RichardBradley/MMEd
        private ThreeDeeEditor(MainForm xiMainForm)
            : base(xiMainForm)
        {
            MoveScale = 100;

            mMainForm.KeyPreview   = true;
            mMainForm.DialogKey   += new KeyEventHandler(MainForm_KeyDown);
            mMainForm.FormClosing += new FormClosingEventHandler(mMainForm_FormClosing);

            mMainForm.ChunkTreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(ChunkTreeView_NodeMouseClick);

            mScene = new MMEdScene();

            Camera lCameraBottomLeft = new Camera(80, 0.1, 1e10);

            lCameraBottomLeft.ProjectionMode = eProjectionMode.Orthographic;
            CreateView(mMainForm.Viewer3DRenderingSurfaceBottomLeft, mScene, lCameraBottomLeft, RenderMode.Wireframe);

            Camera lCameraBottomRight = new Camera(80, 0.1, 1e10);

            lCameraBottomRight.ProjectionMode = eProjectionMode.Orthographic;
            CreateView(mMainForm.Viewer3DRenderingSurfaceBottomRight, mScene, lCameraBottomRight, RenderMode.Wireframe);

            CreateView(mMainForm.Viewer3DRenderingSurfaceTopRight, mScene, new Camera(80, 0.1, 1e10), RenderMode.Undefined);

            Camera lCameraTopLeft = new Camera(80, 0.1, 1e10);

            lCameraTopLeft.ProjectionMode = eProjectionMode.Orthographic;
            CreateView(mMainForm.Viewer3DRenderingSurfaceTopLeft, mScene, lCameraTopLeft, RenderMode.Wireframe);

            //add view mode menus:
            mOptionsMenu = new ToolStripMenuItem("3D");
            //
            PropertyController lMoveCtrl = new PropertyController(this, "MovementMode");

            mOptionsMenu.DropDownItems.AddRange(lMoveCtrl.CreateMenuItems());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            PropertyController lNormCtrl = new PropertyController(this, "DrawNormalsMode");

            mOptionsMenu.DropDownItems.AddRange(lNormCtrl.CreateMenuItems());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            PropertyController lTexModeCtrl = new PropertyController(this, "TextureMode");

            mOptionsMenu.DropDownItems.AddRange(lTexModeCtrl.CreateMenuItems());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            PropertyController lSelMetaCtrl = new PropertyController(this, "SelectedMetadata");

            mOptionsMenu.DropDownItems.Add(lSelMetaCtrl.CreateToolStripComboBox());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            mOptionsMenu.DropDownItems.Add(new ToolStripMenuItem("Hide all invisible Flats", null, new EventHandler(this.HideAllInvisibleFlats)));
            mOptionsMenu.DropDownItems.Add(new ToolStripMenuItem("Refresh View", null, new EventHandler(this.RefreshView)));
            mMainForm.mMenuStrip.Items.Add(mOptionsMenu);

            ResetCamera();

            MovementMode     = eMovementMode.FlyMode;
            DrawNormalsMode  = eDrawNormalsMode.HideNormals;
            TextureMode      = eTextureMode.NormalTextures;
            SelectedMetadata = eTexMetaDataEntries.Waypoint;
        }
コード例 #2
0
ファイル: ThreeDeeViewer.cs プロジェクト: RichardBradley/MMEd
        private ThreeDeeViewer(MainForm xiMainForm)
            : base(xiMainForm)
        {
            mMainForm.KeyPreview   = true;
            mMainForm.KeyPress    += new KeyPressEventHandler(this.KeyPressHandle);
            mMainForm.FormClosing += new FormClosingEventHandler(mMainForm_FormClosing);
            mMainForm.Viewer3DRenderingSurface.MouseDown += new MouseEventHandler(Viewer3DRenderingSurface_MouseDown);
            mMainForm.Viewer3DRenderingSurface.MouseUp   += new MouseEventHandler(Viewer3DRenderingSurface_MouseUp);
            mMainForm.Viewer3DRenderingSurface.MouseMove += new MouseEventHandler(Viewer3DRenderingSurface_MouseMove);
            mMainForm.ChunkTreeView.NodeMouseClick       += new TreeNodeMouseClickEventHandler(ChunkTreeView_NodeMouseClick);

            mRenderer = new ImmediateModeRenderer();
            mRenderer.Attach(mMainForm.Viewer3DRenderingSurface);

            mScene = new Scene();
            // Far distance: 1e3 is half-way along a table, 1e5 seems to include everything on the levels I looked at
            // Near distance: 100 doesn't seem to lose any details until you are right up close to an object, and
            // increases to near distance make a huge improvement in z-clipping.
            // See e.g. https://stackoverflow.com/questions/32938159/how-to-avoid-z-fighting-in-distance
            mCamera = new Camera(80, 100, 1e5);
            mView   = new MMEdViewerView(this, mScene, mCamera, mRenderer);
            mLight  = new Light();
            mLight.DiffuseIntensity  = 0.1;
            mLight.SpecularIntensity = 0.02;

            //add view mode menus:
            mOptionsMenu = new ToolStripMenuItem("3D");
            //
            PropertyController lMoveCtrl = new PropertyController(this, "MovementMode");

            mOptionsMenu.DropDownItems.AddRange(lMoveCtrl.CreateMenuItems());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            PropertyController lLightCtrl = new PropertyController(this, "LightingMode");

            mOptionsMenu.DropDownItems.AddRange(lLightCtrl.CreateMenuItems());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            PropertyController lNormCtrl = new PropertyController(this, "DrawNormalsMode");

            mOptionsMenu.DropDownItems.AddRange(lNormCtrl.CreateMenuItems());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            PropertyController lTexModeCtrl = new PropertyController(this, "TextureMode");

            mOptionsMenu.DropDownItems.AddRange(lTexModeCtrl.CreateMenuItems());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            PropertyController lSelMetaCtrl = new PropertyController(this, "SelectedMetadata");

            mOptionsMenu.DropDownItems.Add(lSelMetaCtrl.CreateToolStripComboBox());
            mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
            //
            mOptionsMenu.DropDownItems.Add(new ToolStripMenuItem("Hide all invisible Flats", null, new EventHandler(this.HideAllFlatsWithoutFlgDClicked)));
            //
            if (DEBUG_ALLOW_LOAD_SAVE_SCENE)
            {
                mOptionsMenu.DropDownItems.Add(new ToolStripSeparator());
                mOptionsMenu.DropDownItems.Add(new ToolStripMenuItem(
                                                   "Save scene to XML...",
                                                   null,
                                                   SaveSceneToXML));
                mOptionsMenu.DropDownItems.Add(new ToolStripMenuItem(
                                                   "Load scene from XML...",
                                                   null,
                                                   LoadSceneFromXML));
            }
            mOptionsMenu.DropDownItems.Add(new ToolStripMenuItem(
                                               "Export scene to VRML...",
                                               null,
                                               ExportSceneToVRML));
            //
            mMainForm.mMenuStrip.Items.Add(mOptionsMenu);
        }