コード例 #1
0
        public void SetupBaseComponents()
        {
            keyboard    = new XKeyboard(ref X);
            mouse       = new XMouse(ref X);
            mouse.Reset = false;

            mInput = new WinFormsInput(this);

            mManipulator = new Manipulator(this.graphicsDeviceService, camera, mInput);
            mManipulator.EnabledModes = TransformationMode.TranslationAxis;

            mPickBuffer = new XPickBuffer(this.graphicsDeviceService);
        }
コード例 #2
0
ファイル: Manipulator.cs プロジェクト: bondjames12/spheregame
        /// <summary>
        /// Creates a new instance of Manipulator
        /// </summary>
        /// <param name="graphics">The IGraphicsDeviceService with which drawing will be performed</param>
        /// <param name="camera">A provider for camera view and projection data</param>
        /// <param name="input">A provider for input data</param>
        public Manipulator(IGraphicsDeviceService graphics, XICamera camera, XIInputProvider input)
        {
            mGraphics = graphics;
            mCamera   = camera;

            mInput = input;

            mSelectedAxes = AxisFlags.None;
            mActiveMode   = TransformationMode.None;
            mEnabledModes = TransformationMode.None;
            mVectorSpace  = VectorSpace.World;

            mPickBuffer = new XPickBuffer(graphics);

            mSettings = new ManipulatorSettings();
            mSettings.RestoreDefaults();

            mGraphics.DeviceCreated   += new EventHandler(OnDeviceCreated);
            mGraphics.DeviceReset     += new EventHandler(CreateDepthBuffer);
            mGraphics.DeviceResetting += new EventHandler(DisposeDepthBuffer);
            mGraphics.DeviceDisposing += new EventHandler(OnDeviceDisposing);

            if ((mGraphics.GraphicsDevice != null) && !mGraphics.GraphicsDevice.IsDisposed)
            {
                OnDeviceCreated(this, null);
                CreateDepthBuffer(this, null);
            }

            mUndoStack = new Stack <TransformState>();
            mRedoStack = new Stack <TransformState>();

            mDrawFunctions  = new DrawFunctions();
            mManipFunctions = new ManipFunctions();

            mDrawFunctions[TransformationMode.None][AxisFlags.X]
                    = mDrawFunctions[TransformationMode.None][AxisFlags.Y]
                    = mDrawFunctions[TransformationMode.None][AxisFlags.Z]
                    = delegate(AxisFlags axis)
                {
                Vector3 unit = GetUnitAxis(axis);
                XPrimitives.DrawLine(mGraphics.GraphicsDevice, Vector3.Zero, unit);
                };

            InitTranslation();
            InitRotation();
            InitScale();
        }