public GameFrame(Game pmGame) { game= pmGame; frame= new GameWindow(); viewport= new Viewport(); resizeComponents= defaultResizeComponents; frame.setDoubleBuffered(true); viewport.clearColor= new Color(224, 224, 224); viewport.initContexts(); viewport.isGraphics3D= true; frame.Text= "Game"; frame.Size= new Sdx.Size(800, 640); frame.Resize+= frameResize; frame.Controls.Add(viewport); }
internal MouseHelper(Viewport pmViewport) { viewport= pmViewport; held= new bool[]{false, false, false, false, false}; lastPosition= Point2f.ORIGIN; currPosition= Point2f.ORIGIN; movement= Vector2.ZERO; bLockToCenter= false; bPrevLock= false; tick= 0; mouseWheel= 0; viewport.LostFocus+= onLostFocus; viewport.MouseDown+= onMouseDown; viewport.MouseUp+= onMouseUp; viewport.MouseLeave+= onMouseLeave; viewport.MouseHover+= onMouseHover; viewport.MouseWheel+= onMouseWheelMoved; viewport.GotFocus+= onGotFocus; }
internal KeyboardHelper(Viewport pmViewport) { keysHeld= new FList<KKL>(); keyProc= new FList<int> ( (int)KKL.LEFT, (int)KKL.UP, (int)KKL.RIGHT, (int)KKL.DOWN, (int)KKL.LEFT_ALT, (int)KKL.LEFT_CTRL, (int)KKL.LEFT_SHIFT, (int)KKL.RIGHT_ALT, (int)KKL.RIGHT_CTRL, (int)KKL.RIGHT_SHIFT, (int)KKL.TAB ); viewport= pmViewport; viewport.KeyDown+= onKeyDown; viewport.KeyUp+= onKeyUp; }
// Gets the picking ray public static Ray getPickingRay(ref BasicCamera cam, ref Viewport viewport) { // Variables double[] mdlv= new double[16]; double[] proj= new double[16]; int[] v= new int[4]; double mx, my; double nx, ny, nz; double fx, fy, fz; MouseState mouse= GameInput.getMouseState(); Ray ray; Gl.glGetDoublev(Gl.GL_PROJECTION_MATRIX, proj); Gl.glGetDoublev(Gl.GL_MODELVIEW_MATRIX, mdlv); Gl.glGetIntegerv(Gl.GL_VIEWPORT, v); mx= (double)mouse.x; my= (double)v[3]-(double)mouse.y; Glu.gluUnProject(mx, my, 0f, mdlv, proj, v, out nx, out ny, out nz); Glu.gluUnProject(mx, my, 1f, mdlv, proj, v, out fx, out fy, out fz); ray= new Ray(new Point3f((float)nx, (float)ny, (float)nz), new Point3f((float)fx, (float)fy, (float)fz)); return ray; }