示例#1
0
 private void AutoSave_Load(object sender, EventArgs e)
 {
     checkBox1.Checked    = CoreGlobals.getSettingsFile().AutoSaveEnabled;
     groupBox1.Enabled    = checkBox1.Checked;
     radioButton1.Checked = !CoreGlobals.getSettingsFile().AutoSaveToCustom;
     radioButton2.Checked = CoreGlobals.getSettingsFile().AutoSaveToCustom;
 }
示例#2
0
        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                CoreGlobals.getSettingsFile().AutoSaveToCustom = false;
            }
            else
            {
                CoreGlobals.getSettingsFile().AutoSaveToCustom = true;
            }

            CoreGlobals.getSettingsFile().Save();
        }
示例#3
0
 private void InitToolBars()
 {
     mMaskPalette.mButtonSize           = 32;
     mMaskPalette.mbRestrictTextureSize = false;
     if (CoreGlobals.getSettingsFile().ThreadedStart == true)
     {
         mMaskPalette.threadedInit(TerrainGlobals.getTerrainFrontEnd().getMaskTextures());
     }
     else
     {
         mMaskPalette.init(TerrainGlobals.getTerrainFrontEnd().getMaskTextures());
     }
     mMaskPalette.mTextureSelected       += new TexturePalette.TextureSelected(mMaskPalette_mTextureSelected);
     mMaskPalette.OverflowButton.Size     = new Size(100, 100);
     mMaskPalette.OverflowButton.AutoSize = false;
 }
示例#4
0
        //-----------------------------------------------------------------------------
        public void CameraMovement()
        {
            //camera controls
            float incAmt = 2 * SmartSpeedupCamera();

            Dir    = mEye - mLookAt;
            mRight = Vector3.Cross(Dir, mUp);
            mRight = BMathLib.Normalize(mRight);

            Vector3 ndir = -Dir;

            ndir.Y = 0;
            ndir   = BMathLib.Normalize(ndir);

            Vector3 kDir = BMathLib.Normalize(Dir);

            Vector3 inc;
            Matrix  matRotation;

            int   mouseDeltaX = 0;
            int   mouseDeltaY = 0;
            Point currPos     = Point.Empty;

            UIManager.GetCursorPos(ref currPos);


            if (mbFirstMouseIntput)
            {
                mLastMousePosX     = currPos.X;
                mLastMousePosY     = currPos.Y;
                mbFirstMouseIntput = false;
            }
            else
            {
                mouseDeltaX    = mLastMousePosX - currPos.X;
                mouseDeltaY    = mLastMousePosY - currPos.Y;
                mLastMousePosX = currPos.X;
                mLastMousePosY = currPos.Y;
            }



            switch (mCamMode)
            {
            case eCamModes.cCamMode_Free:
            case eCamModes.cCamMode_RTS:

                if (mCamMode == eCamModes.cCamMode_RTS) //EDGE PUSH MODE
                {
                    const int edgeAmt = 20;
                    Point     size    = new Point();

                    BRenderDevice.getParentWindowSize(ref size);

                    Point cursorPos = Point.Empty;
                    UIManager.GetCursorPos(ref cursorPos);

                    if (cursorPos.Y < edgeAmt)
                    {
                        CheckAssignMovement(out inc, mLookAt, ndir * incAmt);
                        mEye    += inc;
                        mLookAt += inc;
                    }
                    else if (cursorPos.Y > size.Y - edgeAmt)
                    {
                        CheckAssignMovement(out inc, mLookAt, -ndir * incAmt);
                        mEye    += inc;
                        mLookAt += inc;
                    }
                    else if (cursorPos.X < edgeAmt)
                    {
                        CheckAssignMovement(out inc, mLookAt, -mRight * incAmt);
                        mEye    += inc;
                        mLookAt += inc;
                    }
                    else if (cursorPos.X > size.X - edgeAmt)
                    {
                        CheckAssignMovement(out inc, mLookAt, mRight * incAmt);
                        mEye    += inc;
                        mLookAt += inc;
                    }
                }


                if (SimGlobals.getSimMain().isUsingDesignerControls())
                {
                    if (UIManager.GetMouseButtonDown(UIManager.eMouseButton.cMiddle) && (UIManager.GetAsyncKeyStateB(Key.LeftAlt) || UIManager.GetAsyncKeyStateB(Key.RightAlt)))
                    {
                        //Rotation!
                        if (mouseDeltaX != 0 || mouseDeltaY != 0)
                        {
                            matRotation = Matrix.RotationAxis(mRight, Geometry.DegreeToRadian((float)-mouseDeltaY / 5.0f));
                            Dir.TransformCoordinate(matRotation);
                            Vector3 t = Vector3.Normalize(Dir);
                            if (Vector3.Dot(t, mUp) < mCamDotLimit && Vector3.Dot(t, mUp) > -mCamDotLimit)
                            {
                                mEye = mLookAt + Dir;
                            }

                            matRotation = Matrix.RotationY(Geometry.DegreeToRadian((float)-mouseDeltaX / 5.0f));
                            Dir.TransformCoordinate(matRotation);
                            t = Vector3.Normalize(Dir);
                            if (Vector3.Dot(t, mUp) < mCamDotLimit && Vector3.Dot(t, mUp) > -mCamDotLimit)
                            {
                                mEye = mLookAt + Dir;
                            }
                        }
                        mTranslationPressed = false;
                    }
                    else if (UIManager.GetMouseButtonDown(UIManager.eMouseButton.cMiddle))
                    {
                        if (mTranslationPressed)
                        {
                            float   yE = mEye.Y;
                            float   yL = mLookAt.Y;
                            Vector3 r0 = TerrainGlobals.getEditor().getRayPosFromMouseCoords(false);
                            Vector3 rD = TerrainGlobals.getEditor().getRayPosFromMouseCoords(true) - r0;
                            rD.Normalize();
                            Vector3          iPt  = new Vector3();
                            BTerrainQuadNode node = null;
                            TerrainGlobals.getTerrain().rayIntersects(ref r0, ref rD, ref iPt, ref node, true);
                            Vector3 diff    = mTranlationInterception - iPt;
                            Vector3 eyeDiff = mLookAt - mEye;

                            mLookAt += diff;
                            mEye    += diff;

                            mLookAt.Y = yL;
                            mEye.Y    = yE;
                        }
                        else
                        {
                            mTranslationPressed = true;
                            Vector3 r0 = TerrainGlobals.getEditor().getRayPosFromMouseCoords(false);
                            Vector3 rD = TerrainGlobals.getEditor().getRayPosFromMouseCoords(true) - r0;
                            rD.Normalize();
                            BTerrainQuadNode node = null;
                            TerrainGlobals.getTerrain().rayIntersects(ref r0, ref rD, ref mTranlationInterception, ref node, true);
                        }

                        /*
                         * //TRANSLATION
                         * float lSq = Eye.Y * 0.3f;
                         * float forwardInc = (float)mouseDeltaY / -20.0f;
                         * float rightInc = (float)mouseDeltaX / 20.0f;
                         *
                         * Vector3 k = ndir * forwardInc + Right * rightInc;
                         *
                         * CheckAssignMovement(out inc, LookAt, k);
                         * Eye += inc;
                         * LookAt += inc;
                         * */
                    }
                    else
                    {
                        mTranslationPressed = false;
                    }

                    if ((UIManager.WheelDelta != 0) && (UIManager.GetAsyncKeyStateB(Key.LeftAlt) || UIManager.GetAsyncKeyStateB(Key.RightAlt)))
                    {
                        //ZOOM
                        int   sign       = UIManager.WheelDelta > 0 ? -1 : 1;
                        float heightDiff = (float)Math.Log(mEye.Y);
                        float lSq        = mEye.Y * 0.3f;

                        Zoom = Math.Abs(lSq * (float)(UIManager.WheelDelta / 120f));

                        kDir.Scale(Zoom * sign);

                        mEye += kDir;
                    }


                    //allow WASD || Arrow keys to translate us...
                    if (UIManager.GetAsyncKeyStateB(Key.W) || UIManager.GetAsyncKeyStateB(Key.UpArrow) || UIManager.GetAsyncKeyStateB(Key.NumPad8))
                    {
                        if (UIManager.GetAsyncKeyStateB(Key.LeftAlt) || UIManager.GetAsyncKeyStateB(Key.RightAlt))
                        {
                            //ZOOM
                            int sign = UIManager.WheelDelta > 0 ? -1 : 1;
                            Zoom = 2 * (float)(UIManager.WheelDelta / 120f);

                            kDir.Scale(Zoom * sign);

                            mEye -= kDir;
                        }
                        else
                        {
                            CheckAssignMovement(out inc, mLookAt, ndir * incAmt);
                            mEye    += inc;
                            mLookAt += inc;
                        }
                    }
                    if (UIManager.GetAsyncKeyStateB(Key.S) || UIManager.GetAsyncKeyStateB(Key.DownArrow) || UIManager.GetAsyncKeyStateB(Key.NumPad2))
                    {
                        if (UIManager.GetAsyncKeyStateB(Key.LeftAlt) || UIManager.GetAsyncKeyStateB(Key.RightAlt))
                        {
                            //ZOOM
                            int sign = UIManager.WheelDelta > 0 ? -1 : 1;
                            Zoom = 2 * (float)(UIManager.WheelDelta / 120f);

                            kDir.Scale(Zoom * sign);

                            mEye += kDir;
                        }
                        else
                        {
                            CheckAssignMovement(out inc, mLookAt, -ndir * incAmt);
                            mEye    += inc;
                            mLookAt += inc;
                        }
                    }
                    if (UIManager.GetAsyncKeyStateB(Key.A) || UIManager.GetAsyncKeyStateB(Key.LeftArrow) || UIManager.GetAsyncKeyStateB(Key.NumPad4))
                    {
                        CheckAssignMovement(out inc, mLookAt, -mRight * incAmt);
                        mEye    += inc;
                        mLookAt += inc;
                    }
                    if (UIManager.GetAsyncKeyStateB(Key.D) || UIManager.GetAsyncKeyStateB(Key.RightArrow) || UIManager.GetAsyncKeyStateB(Key.NumPad6))
                    {
                        CheckAssignMovement(out inc, mLookAt, mRight * incAmt);
                        mEye    += inc;
                        mLookAt += inc;
                    }
                }
                else  //artist camera controls
                {
                    Dir.Scale(Zoom);
                    Zoom = 1;
                    if ((UIManager.GetAsyncKeyStateB(Key.LeftShift)) || (UIManager.GetAsyncKeyStateB(Key.RightShift)) || (CoreGlobals.getSettingsFile().ArtistModePan == false && UIManager.GetMouseButtonDown(UIManager.eMouseButton.cMiddle)))
                    {
                        if (UIManager.GetAsyncKeyStateB(Key.LeftControl) || UIManager.GetAsyncKeyStateB(Key.RightControl))
                        {
                            if (mbInvertZoom == true)
                            {
                                mouseDeltaY = -1 * mouseDeltaY;
                            }

                            Zoom = 1 + mouseDeltaY / 100f;
                            mEye = mLookAt + Dir;
                        }
                        else if (!UIManager.GetMouseButtonDown(UIManager.eMouseButton.cLeft))
                        {
                            //Rotation!

                            if (mouseDeltaX != 0 || mouseDeltaY != 0)
                            {
                                matRotation = Matrix.RotationAxis(mRight, Geometry.DegreeToRadian((float)-mouseDeltaY / 5.0f));
                                Dir.TransformCoordinate(matRotation);
                                Vector3 t = Vector3.Normalize(Dir);
                                if (Vector3.Dot(t, mUp) < mCamDotLimit && Vector3.Dot(t, mUp) > -mCamDotLimit)
                                {
                                    mEye = mLookAt + Dir;
                                }

                                matRotation = Matrix.RotationY(Geometry.DegreeToRadian((float)-mouseDeltaX / 5.0f));
                                Dir.TransformCoordinate(matRotation);
                                t = Vector3.Normalize(Dir);
                                if (Vector3.Dot(t, mUp) < mCamDotLimit && Vector3.Dot(t, mUp) > -mCamDotLimit)
                                {
                                    mEye = mLookAt + Dir;
                                }
                            }
                        }

                        // Do nothing if control key is pressed
                        if (UIManager.GetAsyncKeyStateB(Key.LeftControl) || UIManager.GetAsyncKeyStateB(Key.RightControl))
                        {
                            return;
                        }
                    }

                    else if (UIManager.GetMouseButtonDown(UIManager.eMouseButton.cMiddle))
                    {
                        if (mTranslationPressed)
                        {
                            float   yE = mEye.Y;
                            float   yL = mLookAt.Y;
                            Vector3 r0 = TerrainGlobals.getEditor().getRayPosFromMouseCoords(false);
                            Vector3 rD = TerrainGlobals.getEditor().getRayPosFromMouseCoords(true) - r0;
                            rD.Normalize();
                            Vector3          iPt  = new Vector3();
                            BTerrainQuadNode node = null;
                            TerrainGlobals.getTerrain().rayIntersects(ref r0, ref rD, ref iPt, ref node, true);
                            Vector3 diff    = mTranlationInterception - iPt;
                            Vector3 eyeDiff = mLookAt - mEye;

                            mLookAt += diff;
                            mEye    += diff;

                            mLookAt.Y = yL;
                            mEye.Y    = yE;
                        }
                        else
                        {
                            mTranslationPressed = true;
                            Vector3 r0 = TerrainGlobals.getEditor().getRayPosFromMouseCoords(false);
                            Vector3 rD = TerrainGlobals.getEditor().getRayPosFromMouseCoords(true) - r0;
                            rD.Normalize();
                            BTerrainQuadNode node = null;
                            TerrainGlobals.getTerrain().rayIntersects(ref r0, ref rD, ref mTranlationInterception, ref node, true);
                        }
                    }
                    else
                    {
                        mTranslationPressed = false;
                        if (UIManager.GetAsyncKeyStateB(Key.W) || UIManager.GetAsyncKeyStateB(Key.UpArrow) || UIManager.GetAsyncKeyStateB(Key.NumPad8))
                        {
                            CheckAssignMovement(out inc, mLookAt, ndir * incAmt);
                            mEye    += inc;
                            mLookAt += inc;
                        }
                        if (UIManager.GetAsyncKeyStateB(Key.S) || UIManager.GetAsyncKeyStateB(Key.DownArrow) || UIManager.GetAsyncKeyStateB(Key.NumPad2))
                        {
                            CheckAssignMovement(out inc, mLookAt, -ndir * incAmt);
                            mEye    += inc;
                            mLookAt += inc;
                        }
                        if (UIManager.GetAsyncKeyStateB(Key.A) || UIManager.GetAsyncKeyStateB(Key.LeftArrow) || UIManager.GetAsyncKeyStateB(Key.NumPad4))
                        {
                            CheckAssignMovement(out inc, mLookAt, -mRight * incAmt);
                            mEye    += inc;
                            mLookAt += inc;
                        }
                        if (UIManager.GetAsyncKeyStateB(Key.D) || UIManager.GetAsyncKeyStateB(Key.RightArrow) || UIManager.GetAsyncKeyStateB(Key.NumPad6))
                        {
                            CheckAssignMovement(out inc, mLookAt, mRight * incAmt);
                            mEye    += inc;
                            mLookAt += inc;
                        }
                    }
                }

                if (UIManager.GetAsyncKeyStateB(Key.Space) && (UIManager.GetAsyncKeyStateB(Key.LeftShift) || UIManager.GetAsyncKeyStateB(Key.RightShift)))
                {
                    SimGlobals.getSimMain().LookAtSelectedObject();
                }
                else if (UIManager.GetAsyncKeyStateB(Key.Space))
                {
                    snapCamera(eCamSnaps.cCamSnap_RTS);
                }


                break;


            case eCamModes.cCamMode_ModelView:
            {
                if (UIManager.GetMouseButtonDown(UIManager.eMouseButton.cMiddle) && (UIManager.GetAsyncKeyStateB(Key.LeftAlt) || UIManager.GetAsyncKeyStateB(Key.RightAlt)))
                {
                    // Orbit camera
                    if (mouseDeltaX != 0 || mouseDeltaY != 0)
                    {
                        matRotation = Matrix.RotationAxis(mRight, Geometry.DegreeToRadian((float)-mouseDeltaY / 5.0f));
                        Dir.TransformCoordinate(matRotation);
                        Vector3 t = Vector3.Normalize(Dir);
                        if (Vector3.Dot(t, mUp) < mCamDotLimit && Vector3.Dot(t, mUp) > -mCamDotLimit)
                        {
                            mEye = mLookAt + Dir;
                        }

                        matRotation = Matrix.RotationY(Geometry.DegreeToRadian((float)-mouseDeltaX / 5.0f));
                        Dir.TransformCoordinate(matRotation);
                        t = Vector3.Normalize(Dir);
                        if (Vector3.Dot(t, mUp) < mCamDotLimit && Vector3.Dot(t, mUp) > -mCamDotLimit)
                        {
                            mEye = mLookAt + Dir;
                        }
                    }
                }
                else if (UIManager.GetMouseButtonDown(UIManager.eMouseButton.cMiddle))
                {
                    // Translate (pan)
                    float distFromModel     = Vector3.Length(mEye - mModelBoundingBox.getCenter());
                    float translationFactor = distFromModel / 1400.0f;

                    float upInc    = (float)mouseDeltaY * translationFactor;
                    float rightInc = (float)mouseDeltaX * translationFactor;

                    Vector3 up = Vector3.Cross(Dir, mRight);
                    up = BMathLib.Normalize(up);

                    Vector3 tranlation = up * upInc + mRight * rightInc;


                    mEye    += tranlation;
                    mLookAt += tranlation;
                }

                if (UIManager.WheelDelta != 0)
                {
                    // Zoom
                    float distFromModel     = Vector3.Length(mEye - mModelBoundingBox.getCenter());
                    float translationFactor = -distFromModel / 10.0f;

                    mEye += kDir * (translationFactor * (UIManager.WheelDelta / 120f));
                }

                if (UIManager.GetAsyncKeyStateB(Key.Space))
                {
                    snapCamera(eCamSnaps.cCamSnap_ModelView);
                }
            }
            break;
            }
        }
示例#5
0
 private void numericUpDown1_ValueChanged(object sender, EventArgs e)
 {
     CoreGlobals.getSettingsFile().AutoSaveTimeInMinutes = (int)numericUpDown1.Value;
     CoreGlobals.getSettingsFile().Save();
 }
示例#6
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     CoreGlobals.getSettingsFile().AutoSaveEnabled = checkBox1.Checked;
     groupBox1.Enabled = checkBox1.Checked;
     CoreGlobals.getSettingsFile().Save();
 }