Beispiel #1
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;
        }
Beispiel #2
0
        // custom draw del menu item
        public override void Render(DXGui gui)
        {
            bool sel = gui.sel == nro_item ? true : false;

            gui.DrawLine(rc.Left, rc.Bottom, rc.Left + 30, rc.Top, 5, Color.FromArgb(81, 100, 100));
            gui.DrawLine(rc.Left + 30, rc.Top, rc.Right, rc.Top, 5, Color.FromArgb(81, 100, 100));

            if (sel)
            {
                // boton seleccionado: lleno el interior
                Vector2 [] p = new Vector2[20];
                p[0].X = rc.Left;
                p[0].Y = rc.Bottom;
                p[1].X = rc.Left + 30;
                p[1].Y = rc.Top;
                p[2].X = rc.Right;
                p[2].Y = rc.Top;
                p[3].X = rc.Right;
                p[3].Y = rc.Bottom;
                p[4].X = rc.Left;
                p[4].Y = rc.Bottom;
                p[5]   = p[0];
                gui.DrawGradientPoly(p, 6, Color.White, Color.FromArgb(35, 56, 68));

                // solo si esta seleccionado (hightlighted) muestro la imagen en un lugar fijo
                if (textura != null)
                {
                    gui.sprite.Draw(textura, Rectangle.Empty, Vector3.Empty, pos_imagen,
                                    Color.FromArgb(gui.alpha, 255, 255, 255));
                }
            }
            // Texto del boton
            Rectangle rc2 = new Rectangle(rc.Left + 40, rc.Top + 3, rc.Width, rc.Height - 3);

            font.DrawText(gui.sprite, text, rc2, DrawTextFormat.VerticalCenter | DrawTextFormat.Left, Color.WhiteSmoke);
        }
Beispiel #3
0
 // custom draw
 public override void Render(DXGui gui)
 {
     gui.font.DrawText(gui.sprite, text, rc, DrawTextFormat.Left, Color.WhiteSmoke);
     gui.DrawLine(rc.Left, rc.Bottom, rc.Right, rc.Bottom, 6, Color.FromArgb(131, 108, 34));
     gui.DrawLine(rc.Left, rc.Bottom - 2, rc.Right, rc.Bottom - 2, 2, Color.FromArgb(255, 240, 134));
 }
Beispiel #4
0
        public override void Render()
        {
            Device d3dDevice = D3DDevice.Instance.Device;

            time += ElapsedTime;

            TGCVector3 lightDir = lightDirModifier.Value;

            effect.SetValue("g_LightDir", TGCVector3.TGCVector3ToFloat3Array(lightDir));
            effect.SetValue("min_cant_samples", minSampleModifier.Value);
            effect.SetValue("max_cant_samples", maxSampleModifier.Value);
            effect.SetValue("fHeightMapScale", heightMapScaleModifier.Value);
            effect.SetValue("fvEyePosition", TGCVector3.TGCVector3ToFloat3Array(Camera.Position));

            effect.SetValue("time", time);
            effect.SetValue("aux_Tex", g_pBaseTexture);
            effect.SetValue("height_map", g_pHeightmap);
            effect.SetValue("phong_lighting", true);

            d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            d3dDevice.BeginScene();

            foreach (TgcMesh mesh in scene.Meshes)
            {
                bool va          = true;
                int  nro_textura = 0;
                mesh.Effect = effect;
                if (mesh.Name.Contains("Floor"))
                {
                    effect.SetValue("g_normal", TGCVector3.TGCVector3ToFloat3Array(TGCVector3.Down));
                    effect.SetValue("g_tangent", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(1, 0, 0)));
                    effect.SetValue("g_binormal", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(0, 0, 1)));
                    nro_textura = 0;
                }
                else
                if (mesh.Name.Contains("Roof"))
                {
                    effect.SetValue("g_normal", TGCVector3.TGCVector3ToFloat3Array(TGCVector3.Up));
                    effect.SetValue("g_tangent", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(1, 0, 0)));
                    effect.SetValue("g_binormal", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(0, 0, 1)));
                    nro_textura = 0;

                    va = false;
                }
                else
                if (mesh.Name.Contains("East"))
                {
                    effect.SetValue("g_normal", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(1, 0, 0)));
                    effect.SetValue("g_tangent", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(0, 0, 1)));
                    effect.SetValue("g_binormal", TGCVector3.TGCVector3ToFloat3Array(TGCVector3.Up));
                    nro_textura = 1;
                }
                else
                if (mesh.Name.Contains("West"))
                {
                    effect.SetValue("g_normal", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(-1, 0, 0)));
                    effect.SetValue("g_tangent", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(0, 0, 1)));
                    effect.SetValue("g_binormal", TGCVector3.TGCVector3ToFloat3Array(TGCVector3.Up));
                    nro_textura = 1;
                }
                else
                if (mesh.Name.Contains("North"))
                {
                    effect.SetValue("g_normal", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(0, 0, -1)));
                    effect.SetValue("g_tangent", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(1, 0, 0)));
                    effect.SetValue("g_binormal", TGCVector3.TGCVector3ToFloat3Array(TGCVector3.Up));
                    nro_textura = 1;
                }
                else
                if (mesh.Name.Contains("South"))
                {
                    effect.SetValue("g_normal", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(0, 0, 1)));
                    effect.SetValue("g_tangent", TGCVector3.TGCVector3ToFloat3Array(new TGCVector3(1, 0, 0)));
                    effect.SetValue("g_binormal", TGCVector3.TGCVector3ToFloat3Array(TGCVector3.Up));
                    nro_textura = 1;
                }

                switch (nro_textura)
                {
                case 0:
                default:
                    effect.SetValue("aux_Tex", g_pBaseTexture);
                    effect.SetValue("height_map", g_pHeightmap);
                    break;

                case 1:
                    effect.SetValue("aux_Tex", g_pBaseTexture2);
                    effect.SetValue("height_map", g_pHeightmap2);
                    break;

                case 2:
                    effect.SetValue("aux_Tex", g_pBaseTexture3);
                    effect.SetValue("height_map", g_pHeightmap3);
                    break;

                case 3:
                    effect.SetValue("aux_Tex", g_pBaseTexture4);
                    effect.SetValue("height_map", g_pHeightmap4);
                    break;
                }

                if (va)
                {
                    mesh.Technique = "ParallaxOcclusion2";
                    mesh.Render();
                }
            }

            //Render personames enemigos
            foreach (TgcSkeletalMesh m in enemigos)
            {
                m.Render();
            }

            // Render hud
            renderHUD();

            gui.trapezoidal_style = false;
            //radar de proximidad
            float max_dist = 80;

            foreach (TgcSkeletalMesh m in enemigos)
            {
                TGCVector3 pos_personaje = Camera.Position;
                TGCVector3 pos_enemigo   = m.Position * 1;
                float      dist          = (pos_personaje - pos_enemigo).Length();

                if (dist < max_dist)
                {
                    pos_enemigo.Y = m.BoundingBox.PMax.Y * 0.75f + m.BoundingBox.PMin.Y * 0.25f;
                    pos_enemigo.Project(d3dDevice.Viewport, TGCMatrix.FromMatrix(d3dDevice.Transform.Projection), TGCMatrix.FromMatrix(d3dDevice.Transform.View), TGCMatrix.FromMatrix(d3dDevice.Transform.World));
                    if (pos_enemigo.Z > 0 && pos_enemigo.Z < 1)
                    {
                        float an = (max_dist - dist) / max_dist * 3.1415f * 2.0f;
                        int   d  = (int)dist;
                        gui.DrawArc(new TGCVector2(pos_enemigo.X + 20, pos_enemigo.Y), 40, 0, an, 10, dist < 30 ? Color.Tomato : Color.WhiteSmoke);
                        gui.DrawLine(pos_enemigo.X, pos_enemigo.Y, pos_enemigo.X + 20, pos_enemigo.Y, 3, Color.PowderBlue);
                        gui.DrawLine(pos_enemigo.X + 20, pos_enemigo.Y, pos_enemigo.X + 40, pos_enemigo.Y - 20, 3, Color.PowderBlue);
                        gui.TextOut((int)pos_enemigo.X + 50, (int)pos_enemigo.Y - 20, "Proximidad " + d, Color.PowderBlue);
                    }
                }
            }
            gui.trapezoidal_style = true;

            PostRender();
        }
Beispiel #5
0
        public override void render(float elapsedTime)
        {
            update(elapsedTime);
            Device  device      = GuiController.Instance.D3dDevice;
            Control panel3d     = GuiController.Instance.Panel3d;
            float   aspectRatio = (float)panel3d.Width / (float)panel3d.Height;

            time += elapsedTime;

            Vector3 lightDir = (Vector3)GuiController.Instance.Modifiers["LightDir"];

            effect.SetValue("g_LightDir", TgcParserUtils.vector3ToFloat3Array(lightDir));
            effect.SetValue("min_cant_samples", (float)GuiController.Instance.Modifiers["minSample"]);
            effect.SetValue("max_cant_samples", (float)GuiController.Instance.Modifiers["maxSample"]);
            effect.SetValue("fHeightMapScale", (float)GuiController.Instance.Modifiers["HeightMapScale"]);
            effect.SetValue("fvEyePosition", TgcParserUtils.vector3ToFloat3Array(GuiController.Instance.FpsCamera.getPosition()));

            effect.SetValue("time", time);
            effect.SetValue("aux_Tex", g_pBaseTexture);
            effect.SetValue("height_map", g_pHeightmap);
            effect.SetValue("phong_lighting", true);

            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
            device.BeginScene();

            foreach (TgcMesh mesh in scene.Meshes)
            {
                bool va          = true;
                int  nro_textura = 0;
                mesh.Effect = effect;
                if (mesh.Name.Contains("Floor"))
                {
                    effect.SetValue("g_normal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, -1, 0)));
                    effect.SetValue("g_tangent", TgcParserUtils.vector3ToFloat3Array(new Vector3(1, 0, 0)));
                    effect.SetValue("g_binormal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 0, 1)));
                    nro_textura = 0;
                }
                else
                if (mesh.Name.Contains("Roof"))
                {
                    effect.SetValue("g_normal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 1, 0)));
                    effect.SetValue("g_tangent", TgcParserUtils.vector3ToFloat3Array(new Vector3(1, 0, 0)));
                    effect.SetValue("g_binormal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 0, 1)));
                    nro_textura = 0;

                    va = false;
                }
                else
                if (mesh.Name.Contains("East"))
                {
                    effect.SetValue("g_normal", TgcParserUtils.vector3ToFloat3Array(new Vector3(1, 0, 0)));
                    effect.SetValue("g_tangent", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 0, 1)));
                    effect.SetValue("g_binormal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 1, 0)));
                    nro_textura = 1;
                }
                else
                if (mesh.Name.Contains("West"))
                {
                    effect.SetValue("g_normal", TgcParserUtils.vector3ToFloat3Array(new Vector3(-1, 0, 0)));
                    effect.SetValue("g_tangent", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 0, 1)));
                    effect.SetValue("g_binormal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 1, 0)));
                    nro_textura = 1;
                }
                else
                if (mesh.Name.Contains("North"))
                {
                    effect.SetValue("g_normal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 0, -1)));
                    effect.SetValue("g_tangent", TgcParserUtils.vector3ToFloat3Array(new Vector3(1, 0, 0)));
                    effect.SetValue("g_binormal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 1, 0)));
                    nro_textura = 1;
                }
                else
                if (mesh.Name.Contains("South"))
                {
                    effect.SetValue("g_normal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 0, 1)));
                    effect.SetValue("g_tangent", TgcParserUtils.vector3ToFloat3Array(new Vector3(1, 0, 0)));
                    effect.SetValue("g_binormal", TgcParserUtils.vector3ToFloat3Array(new Vector3(0, 1, 0)));
                    nro_textura = 1;
                }


                switch (nro_textura)
                {
                case 0:
                default:
                    effect.SetValue("aux_Tex", g_pBaseTexture);
                    effect.SetValue("height_map", g_pHeightmap);
                    break;

                case 1:
                    effect.SetValue("aux_Tex", g_pBaseTexture2);
                    effect.SetValue("height_map", g_pHeightmap2);
                    break;

                case 2:
                    effect.SetValue("aux_Tex", g_pBaseTexture3);
                    effect.SetValue("height_map", g_pHeightmap3);
                    break;

                case 3:
                    effect.SetValue("aux_Tex", g_pBaseTexture4);
                    effect.SetValue("height_map", g_pHeightmap4);
                    break;
                }

                if (va)
                {
                    mesh.Technique = "ParallaxOcclusion2";
                    mesh.render();
                }
            }

            //Render personames enemigos
            foreach (TgcSkeletalMesh m in enemigos)
            {
                m.render();
            }

            // Render hud
            renderHUD();


            gui.trapezoidal_style = false;
            //radar de proximidad
            float max_dist = 80;

            foreach (TgcSkeletalMesh m in enemigos)
            {
                Vector3 pos_personaje = GuiController.Instance.FpsCamera.getPosition();
                Vector3 pos_enemigo   = m.Position * 1;
                float   dist          = (pos_personaje - pos_enemigo).Length();

                if (dist < max_dist)
                {
                    pos_enemigo.Y = m.BoundingBox.PMax.Y * 0.75f + m.BoundingBox.PMin.Y * 0.25f;
                    pos_enemigo.Project(device.Viewport, device.Transform.Projection, device.Transform.View, device.Transform.World);
                    if (pos_enemigo.Z > 0 && pos_enemigo.Z < 1)
                    {
                        float an = (max_dist - dist) / max_dist * 3.1415f * 2.0f;
                        int   d  = (int)dist;
                        gui.DrawArc(new Vector2(pos_enemigo.X + 20, pos_enemigo.Y), 40, 0, an, 10, dist < 30 ? Color.Tomato : Color.WhiteSmoke);
                        gui.DrawLine(pos_enemigo.X, pos_enemigo.Y, pos_enemigo.X + 20, pos_enemigo.Y, 3, Color.PowderBlue);
                        gui.DrawLine(pos_enemigo.X + 20, pos_enemigo.Y, pos_enemigo.X + 40, pos_enemigo.Y - 20, 3, Color.PowderBlue);
                        gui.TextOut((int)pos_enemigo.X + 50, (int)pos_enemigo.Y - 20, "Proximidad " + d, Color.PowderBlue);
                    }
                }
            }
            gui.trapezoidal_style = true;


            device.EndScene();
        }