public override void Render(DXGui gui) { Device d3dDevice = GuiController.Instance.D3dDevice; float W = (float)GuiController.Instance.Panel3d.Width; float H = (float)GuiController.Instance.Panel3d.Height; float aspect_ratio = W / H; float vel = 5f; // milimetros x pixel float vel_an = 0.001f; // radioanes x pixel int dm = 150; float xm = gui.kinect.right_hand.position.X; float ym = gui.kinect.right_hand.position.Y; float zm = gui.kinect.right_hand.position.Z; // Verifico si esta en modo navegacion // Para ello la mano izquierda tiene que estar abajo a la derecha bool navegar = false; float xmi = gui.kinect.left_hand.position.X; float ymi = gui.kinect.left_hand.position.Y; if (xmi > W / 2 && ymi > H / 2) { // modo navegacion navegar = true; //vel = 20f + (0.5f + ymi / H) * 200.0f; } // si la pos. del mouse esta en el area de interaccion de navegacion if (navegar && ant_xm != float.MaxValue) { // actualizo la posicion de la camara desde el input de la kinect if (modo_pan) { // modo pan ORTOGONAL Vector3 dp = new Vector3(xm - ant_xm, 0, ym - ant_ym) * vel; Vector3 LFcam = GuiController.Instance.FpsCamera.getPosition(); Vector3 LAcam = GuiController.Instance.FpsCamera.getLookAt(); gui.camera.setCamera(LFcam + dp, LAcam + dp); } else { // modo rotar camara y move hacia adelate / atras Vector3 viewDir = gui.camera.getLookAt() - gui.camera.getPosition(); float an = (xm - ant_xm) * vel_an; viewDir.TransformNormal(Matrix.RotationY(an)); Vector3 newPos = GuiController.Instance.FpsCamera.getPosition() + viewDir * (ant_ym - ym) * vel; gui.camera.setCamera(newPos, newPos + viewDir); } } gui.camera.updateCamera(); ant_xm = xm; ant_ym = ym; ant_zm = zm; float fov = (float)Math.PI / 4.0f * aspect_ratio; Vector3 LA = gui.camera.getLookAt(); Vector3 LF = gui.camera.getPosition(); Vector2 lf = new Vector2(LF.X, LF.Z); Vector2 la = new Vector2(LA.X, LA.Z); // Dibujo un rectangulo que representa toda la cocina gui.DrawRect(rc.Left, rc.Top, (int)(rc.X + wdx * ex), (int)(rc.Y + wdz * ey), 4, Color.FromArgb(gui.alpha, 32, 140, 55)); // Dibujo el look from gui.DrawDisc(new Vector2(rc.X + (lf.X - min_x) * ex, rc.Y + (wdz - lf.Y + min_z) * ey), 10, Color.FromArgb(0, 0, 0)); Vector2[] pt = new Vector2[100]; int cant_p = 1; pt[0].X = rc.X + (lf.X - min_x) * ex; pt[0].Y = rc.Y + (wdz - lf.Y + min_z) * ey; for (int i = 0; i < 50; ++i) { Matrix rot = Matrix.RotationY(-fov / 2.0f + (float)i / 50.0f * fov); Vector3 A = LA - LF; A.TransformNormal(rot); Vector2 a = new Vector2(A.X, A.Z); a.Normalize(); a = a * 3000 + lf; pt[cant_p].X = rc.X + (a.X - min_x) * ex; pt[cant_p].Y = rc.Y + (wdz - a.Y + min_z) * ey; ++cant_p; } pt[cant_p++] = pt[0]; gui.DrawSolidPoly(pt, cant_p, Color.FromArgb(100, 100, 255, 100)); }