Exemplo n.º 1
0
        public override void Render(DXGui gui)
        {
            bool sel = gui.sel == nro_item ? true : false;
            Color clr = Color.FromArgb(Math.Min(gui.alpha, c_fondo.A), c_fondo);
            switch (borde)
            {
                case frameBorder.sin_borde:
                    // dibujo solo interior
                    gui.DrawRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 1, clr, true);
                    break;

                case frameBorder.redondeado:
                    // Interior
                    gui.RoundRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 30, 6, clr, true);
                    // Contorno
                    gui.RoundRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 30, 6, Color.FromArgb(gui.alpha, DXGui.c_frame_border));
                    break;

                case frameBorder.solapa:
                    {
                        float r = 40;
                        TGCVector2[] pt = new TGCVector2[10];
                        pt[0].X = rc.X;
                        pt[0].Y = rc.Y + rc.Height;
                        pt[1].X = rc.X;
                        pt[1].Y = rc.Y;
                        pt[2].X = rc.X + rc.Width - r;
                        pt[2].Y = rc.Y;
                        pt[3].X = rc.X + rc.Width;
                        pt[3].Y = rc.Y + r;
                        pt[4].X = rc.X + rc.Width;
                        pt[4].Y = rc.Y + rc.Height;
                        pt[5].X = rc.X;
                        pt[5].Y = rc.Y + rc.Height;
                        pt[6] = pt[0];

                        gui.DrawSolidPoly(pt, 7, clr, false);
                        gui.DrawPoly(pt, 5, 6, DXGui.c_frame_border);
                    }

                    break;

                case frameBorder.rectangular:
                default:

                    // interior
                    gui.DrawRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 1, Color.FromArgb(gui.alpha, c_fondo), true);
                    // contorno
                    gui.DrawRect(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height, 6, Color.FromArgb(gui.alpha, DXGui.c_frame_border));
                    break;
            }

            // Texto del frame
            Rectangle rc2 = new Rectangle(rc.X, rc.Y, rc.X + rc.Width, rc.Y + rc.Height);
            rc2.Y += 30;
            rc2.X += 30;
            Color color = sel ? c_selected : c_font;
            gui.font.DrawText(gui.sprite, text, rc2, DrawTextFormat.NoClip | DrawTextFormat.Top, Color.FromArgb(gui.alpha, color));
        }
Exemplo n.º 2
0
        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;

            // pongo la matriz identidad
            Matrix matAnt = gui.sprite.Transform * Matrix.Identity;

            gui.sprite.Transform = Matrix.Identity;

            float ant_ox = gui.ox;
            float ant_oy = gui.oy;

            gui.oy = gui.ox = 0;
            bool ant_trap = gui.trapezoidal_style;

            gui.trapezoidal_style = false;

            gui.DrawRect(rc.Left, rc.Top, rc.Right, rc.Bottom, 1, Color.FromArgb(0, 0, 0), true);

            Rectangle rc2 = new Rectangle(rc.Left + margen, rc.Top + margen, rc.Width - 2 * +margen, rc.Height - 2 * +margen);

            // Dibujo los huesos
            for (int t = 0; t < cant_huesos; ++t)
            {
                int   i  = hueso_desde[t];
                int   j  = hueso_hasta[t];
                float x0 = (joints[i].X - min_x) * escala + rc2.X;
                float y0 = rc2.Y + rc2.Height - (joints[i].Y - min_y) * escala;
                float x1 = (joints[j].X - min_x) * escala + rc2.X;
                float y1 = rc2.Y + rc2.Height - (joints[j].Y - min_y) * escala;
                gui.DrawLine(x0, y0, x1, y1, 3, Color.Blue);
            }

            // Dibujo las articulaciones
            for (int i = 0; i < cant_joints; ++i)
            {
                float x = (joints[i].X - min_x) * escala + rc2.X;
                float y = rc2.Y + rc2.Height - (joints[i].Y - min_y) * escala;
                int   r = importante[i] ? 4 : 2;
                gui.DrawRect((int)x - r, (int)y - r, (int)x + r, (int)y + r, 1, Color.WhiteSmoke, true);
            }

            // Area de interaccion fisica de la kinect
            gui.DrawRect((int)((-pir_min_x + head_pos.X - min_x) * escala + rc2.X),
                         (int)(rc2.Y + rc2.Height - (-pir_min_y + head_pos.Y - min_y) * escala),
                         (int)((-pir_max_x + head_pos.X - min_x) * escala + rc2.X),
                         (int)(rc2.Y + rc2.Height - (-pir_max_y + head_pos.Y - min_y) * escala),
                         1, Color.FromArgb(100, 240, 255, 120), true);

            gui.ox = ant_ox;
            gui.oy = ant_oy;
            gui.trapezoidal_style = ant_trap;
            // Restauro la transformacion del sprite
            gui.sprite.Transform = matAnt;
        }
Exemplo n.º 3
0
        public override void Render(DXGui gui)
        {
            float k = (float)(pos - desde) / (float)(hasta - desde);
            gui.DrawRect(rc.Left, rc.Top, rc.Right, rc.Bottom, 1, Color.FromArgb(240, 240, 240), true);
            gui.DrawRect(rc.Left, rc.Top, rc.Right, rc.Bottom, 1, Color.FromArgb(0, 0, 0));
            gui.DrawRect(rc.Left, rc.Top, rc.Left + (int)(rc.Width * k), rc.Bottom, 1, Color.FromArgb(0, 100, 255), true);
            gui.DrawRect(rc.Left, rc.Top, rc.Left + (int)(rc.Width * k), rc.Bottom, 1, Color.FromArgb(0, 0, 0));

            Rectangle rc2 = new Rectangle(rc.Left, rc.Top - 50, rc.Width, 50);
            gui.font.DrawText(gui.sprite, text, rc2, DrawTextFormat.NoClip | DrawTextFormat.Top, Color.FromArgb(0, 0, 0));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        public override void Render(DXGui gui)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;
            bool   sel       = state == itemState.hover;
            float  tr        = (float)(4 * (gui.delay_sel0 - gui.delay_sel));
            float  k         = 1;

            float ox = gui.ox;
            float oy = gui.oy;
            float ex = gui.ex;
            float ey = gui.ey;

            if (scrolleable)
            {
                // como este boton es un item scrolleable, tiene que aplicar tambien el origen sox,soy
                ox += gui.sox;
                oy += gui.soy;
            }

            if (sel)
            {
                // aumento las escala
                k = 1 + (gui.delay_sel0 - gui.delay_sel) * 1.0f;
            }

            // Determino el rectangulo
            float xm = (rc.Left + rc.Right) * 0.5f;
            float ym = (rc.Top + rc.Bottom) * 0.5f;
            float rx = rc.Width * k * 0.5f;
            float ry = rc.Height * k * 0.5f;

            float x0 = xm - rx + ox;
            float y0 = ym - ry + oy;

            // El dx no deja poner viewport con origen negativo (pero si me puedo pasar por la derecha o por abajo)
            if (x0 < 0)
            {
                x0 = 0;
            }
            if (y0 < 0)
            {
                y0 = 0;
            }
            float x1 = x0 + 2 * rx;
            float y1 = y0 + 2 * ry;

            // Y roto la vista
            float   an      = sel ? ftime * 1.5f : 0;
            Vector3 viewDir = new Vector3((float)Math.Sin(an), 0.3f, (float)Math.Cos(an));

            viewDir.Normalize();
            Vector3 LA          = mesh.Position;
            float   dist        = size.Length() * (sel ? 1.5f : 2f);
            Vector3 LF          = mesh.Position + viewDir * dist;
            Matrix  ant_matView = d3dDevice.Transform.View * Matrix.Identity;

            d3dDevice.Transform.View = Matrix.LookAtLH(LF, LA, new Vector3(0, 1, 0));

            Matrix ant_matProj  = d3dDevice.Transform.Projection * Matrix.Identity;
            float  W            = (float)GuiController.Instance.Panel3d.Width;
            float  H            = (float)GuiController.Instance.Panel3d.Height;
            float  aspect_ratio = W / H;

            d3dDevice.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, aspect_ratio, 1f, 1000f);

            Effect currentShader = GuiController.Instance.Shaders.TgcMeshShader;

            mesh.Effect    = currentShader;
            mesh.Technique = GuiController.Instance.Shaders.getTgcMeshTechnique(mesh.RenderType);

            Viewport ant_viewport = d3dDevice.Viewport;
            Viewport btn_viewport = new Viewport();

            btn_viewport.X      = (int)(x0 * ex);
            btn_viewport.Y      = (int)(y0 * ey);
            btn_viewport.Width  = (int)((x1 - x0) * ex);
            btn_viewport.Height = (int)((y1 - y0) * ey);
            d3dDevice.Viewport  = btn_viewport;

            d3dDevice.EndScene();
            d3dDevice.Clear(ClearFlags.ZBuffer | ClearFlags.Target, sel ? Color.FromArgb(240, 250, 240) : Color.FromArgb(192, 192, 192), 1.0f, 0);
            d3dDevice.BeginScene();
            d3dDevice.SetRenderState(RenderStates.ZEnable, true);
            mesh.render();

            d3dDevice.Viewport = ant_viewport;
            d3dDevice.SetRenderState(RenderStates.ZEnable, false);
            d3dDevice.Transform.View       = ant_matView * Matrix.Identity;
            d3dDevice.Transform.Projection = ant_matProj * Matrix.Identity;

            // Dibujo un rectangulo
            gui.DrawRect((int)x0, (int)y0, (int)x1, (int)y1, sel?5:2, Color.FromArgb(gui.alpha, 32, 140, 55));
        }
Exemplo n.º 6
0
        public void renderHUD()
        {
            Device d3dDevice = D3DDevice.Instance.Device;

            d3dDevice.RenderState.ZBufferEnable = false;
            int W = D3DDevice.Instance.Width;
            int H = D3DDevice.Instance.Height;

            // Elapsed time
            int   an    = (int)(time * 10) % 360;
            float hasta = an / 180.0f * (float)Math.PI;

            gui.DrawArc(new TGCVector2(40, H - 100), 25, 0, hasta, 8, Color.Yellow);
            gui.TextOut(20, H - 140, "Elapsed Time:" + Math.Round(time), Color.LightSteelBlue);

            // dibujo los enemigos
            TGCVector3 pos_personaje = Camera.Position;
            TGCVector3 dir_view      = Camera.LookAt - pos_personaje;
            TGCVector2 dir_v         = new TGCVector2(dir_view.X, dir_view.Z);

            dir_v.Normalize();
            TGCVector2 dir_w = new TGCVector2(dir_v.Y, -dir_v.X);

            int   dx = 1000;
            int   dy = 1000;
            int   dW = 200;
            int   dH = 200;
            float ex = dW / (float)dx;
            float ey = dH / (float)dy;
            int   ox = 10 + dW / 2;
            int   oy = 10 + dH / 2;

            for (int t = 0; t < cant_enemigos; ++t)
            {
                TGCVector3 pos = enemigos[t].Position - pos_personaje;
                TGCVector2 p   = new TGCVector2(pos.X, pos.Z);
                float      x   = TGCVector2.Dot(dir_w, p);
                float      y   = TGCVector2.Dot(dir_v, p);
                int        xm  = (int)(ox + x * ex);
                int        ym  = (int)(oy + y * ey);

                if (Math.Abs(xm - ox) < dW / 2 - 10 && Math.Abs(ym - oy) < dH / 2 - 10)
                {
                    gui.DrawRect(xm - 2, ym - 2, xm + 2, ym + 2, 1, Color.WhiteSmoke);
                }
            }

            TGCVector2[] P = new TGCVector2[20];
            P[0] = new TGCVector2(ox - 5, oy + 5);
            P[1] = new TGCVector2(ox + 5, oy + 5);
            P[2] = new TGCVector2(ox, oy - 10);
            P[3] = P[0];
            gui.DrawSolidPoly(P, 4, Color.Tomato, false);
            gui.DrawCircle(new TGCVector2(ox, oy), 14, 3, Color.Yellow);

            foreach (TgcBoundingAxisAlignBox room in rooms)
            {
                TGCVector2[] Q  = new TGCVector2[4];
                TGCVector2[] Qp = new TGCVector2[5];

                float xm = 0;
                float ym = 0;
                Q[0] = new TGCVector2(room.PMin.X - pos_personaje.X, room.PMin.Z - pos_personaje.Z);
                Q[1] = new TGCVector2(room.PMin.X - pos_personaje.X, room.PMax.Z - pos_personaje.Z);
                Q[2] = new TGCVector2(room.PMax.X - pos_personaje.X, room.PMax.Z - pos_personaje.Z);
                Q[3] = new TGCVector2(room.PMax.X - pos_personaje.X, room.PMin.Z - pos_personaje.Z);
                for (int t = 0; t < 4; ++t)
                {
                    float x = TGCVector2.Dot(dir_w, Q[t]);
                    float y = TGCVector2.Dot(dir_v, Q[t]);
                    Qp[t] = new TGCVector2(ox + x * ex, oy + y * ey);
                    xm   += x * ex;
                    ym   += y * ey;
                }
                Qp[4] = Qp[0];
                xm   /= 4;
                ym   /= 4;

                if (Math.Abs(xm) < dW / 2 - 10 && Math.Abs(ym) < dH / 2 - 10)
                {
                    gui.DrawPoly(Qp, 5, 1, Color.Tomato);
                }
            }

            // posicion X,Z
            float kx = pos_personaje.X * ex;

            P[0] = new TGCVector2(10, H - 10);
            P[1] = new TGCVector2(15, H - 30);
            P[2] = new TGCVector2(5 + kx, H - 30);
            P[3] = new TGCVector2(25 + kx, H - 10);
            P[4] = P[0];
            gui.DrawSolidPoly(P, 5, Color.Tomato);
            gui.DrawPoly(P, 5, 2, Color.HotPink);

            float kz = pos_personaje.Z * ey;

            P[0] = new TGCVector2(10, H - 40);
            P[1] = new TGCVector2(15, H - 60);
            P[2] = new TGCVector2(5 + kz, H - 60);
            P[3] = new TGCVector2(25 + kz, H - 40);
            P[4] = P[0];
            gui.DrawSolidPoly(P, 5, Color.Green);
            gui.DrawPoly(P, 5, 2, Color.YellowGreen);

            d3dDevice.RenderState.ZBufferEnable = true;
            gui.Render();
        }