Exemplo n.º 1
0
 //
 //////////////////////////////////////////////////////////////////////
 public DiabolicalModel(Shapes sharedShapes)
 {
     debugShapes = sharedShapes;
     PreProcessSetup();
 }
 public DiabolicalManager(MainForm parent, Shapes sharedShapes)
 {
     form = parent;
     debugShapes = sharedShapes;
     modelAsset = new DiabolicalModel(debugShapes);
 }
        //
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        // == Setup ==
        //
        /// <summary>
        /// Initializes the control.
        /// </summary>
        protected override void Initialize()
        {
            // Hook the idle event to constantly redraw our animation.
            Application.Idle += delegate { Invalidate(); };

            // Get the same background used by the control in a format usable by the game
            gameBackColor = new Color(BackColor.R, BackColor.G, BackColor.B);
            aspectRatio = GraphicsDevice.Viewport.AspectRatio;

            // Setup the shapes
            debugShapes = new Shapes(GraphicsDevice);
            axes = new Axes3D(GraphicsDevice);

            RasterWireFrame.CullMode = CullMode.CullCounterClockwiseFace;
            RasterWireFrame.FillMode = FillMode.WireFrame;
            RasterWireFrame.MultiSampleAntiAlias = true;

            RasterSolid.CullMode = CullMode.CullCounterClockwiseFace;
            RasterSolid.FillMode = FillMode.Solid;
            RasterSolid.MultiSampleAntiAlias = true;

            // Initialise mouse and keyboard
            // For the scroll wheel to work the Mouse.WindowHandle must be set to this control
            Mouse.WindowHandle = Handle;
            currentKeyboardState = Keyboard.GetState();
            previousKeyboardState = currentKeyboardState;
            currentMouseState = Mouse.GetState();
            previousMouseState = currentMouseState;
            // A few pixel in from the top left
            // Once the WindowHandlw was set on the mouse this became relative to itself.
            mouseX = GlobalSettings.mouseZeroX;
            mouseY = GlobalSettings.mouseZeroY;
            Mouse.SetPosition(mouseX, mouseY);
        }