Exemplo n.º 1
0
void CShortcut::DrawVertex(int icon, float zoom)
{
    Gfx::CDevice* device;
    Gfx::Vertex  vertex[4];  // 2 triangles
    Math::Point     p1, p2, c;
    Math::Vector    n;
    float       u1, u2, v1, v2, dp;

    device = m_engine->GetDevice();

    p1.x = m_pos.x;
    p1.y = m_pos.y;
    p2.x = m_pos.x + m_dim.x;
    p2.y = m_pos.y + m_dim.y;

    c.x = (p1.x+p2.x)/2.0f;
    c.y = (p1.y+p2.y)/2.0f;  // center

    p1.x = (p1.x-c.x)*zoom + c.x;
    p1.y = (p1.y-c.y)*zoom + c.y;

    p2.x = (p2.x-c.x)*zoom + c.x;
    p2.y = (p2.y-c.y)*zoom + c.y;

    u1 = (32.0f/256.0f)*(icon%8);
    v1 = (32.0f/256.0f)*(icon/8);  // u-v texture
    u2 = (32.0f/256.0f)+u1;
    v2 = (32.0f/256.0f)+v1;

    dp = 0.5f/256.0f;
    u1 += dp;
    v1 += dp;
    u2 -= dp;
    v2 -= dp;

    n = Math::Vector(0.0f, 0.0f, -1.0f);  // normal

    vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(u1, v2));
    vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(u1, v1));
    vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(u2, v2));
    vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(u2, v1));

    device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
    m_engine->AddStatisticTriangle(2);
}
Exemplo n.º 2
0
void CCompass::Draw()
{
    Gfx::CDevice* device;
    Gfx::Vertex   vertex[4];  // 2 triangles
    Math::Point   p1, p2, p3, c, uv1, uv2;
    Math::Vector  n;
    float        dp;

    if ( (m_state & STATE_VISIBLE) == 0 )  return;

    device = m_engine->GetDevice();

    m_engine->SetTexture("textures/interface/button2.png");
    m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);

    p1.x = m_pos.x;
    p1.y = m_pos.y;
    p2.x = m_pos.x + m_dim.x;
    p2.y = m_pos.y + m_dim.y;

    c.x = (p1.x + p2.x) / 2.0f;
    c.y = (p1.y + p2.y) / 2.0f;  // center

    uv1.x = 64.0f / 256.0f;
    uv1.y = 32.0f / 256.0f;
    uv2.x = 96.0f / 256.0f;
    uv2.y = 64.0f / 256.0f;

    dp = 0.5f / 256.0f;
    uv1.x += dp;
    uv1.y += dp;
    uv2.x -= dp;
    uv2.y -= dp;

    n = Math::Vector(0.0f, 0.0f, -1.0f);  // normal

    vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y));
    vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y));
    vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y));
    vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y));

    device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
    m_engine->AddStatisticTriangle(2);

    if ( m_state & STATE_ENABLE )
    {
        p1.x = c.x;
        p1.y = c.y + m_dim.x * 0.40f;
        p1 = Math::RotatePoint(c, m_dir, p1);
        p1.x = c.x + (p1.x - c.x) * (m_dim.x / m_dim.y);

        p2.x = c.x + m_dim.x * 0.20f;
        p2.y = c.y - m_dim.x * 0.40f;
        p2 = Math::RotatePoint(c, m_dir, p2);
        p2.x = c.x + (p2.x - c.x) * (m_dim.x / m_dim.y);

        p3.x = c.x - m_dim.x * 0.20f;
        p3.y = c.y - m_dim.x * 0.40f;
        p3 = Math::RotatePoint(c, m_dir, p3);
        p3.x = c.x + (p3.x - c.x) * (m_dim.x / m_dim.y);

        uv1.x =  96.0f / 256.0f;
        uv1.y =  32.0f / 256.0f;
        uv2.x = 104.0f / 256.0f;
        uv2.y =  64.0f / 256.0f;

        uv1.x += dp;
        uv1.y += dp;
        uv2.x -= dp;
        uv2.y -= dp;

        vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv1.y));
        vertex[1] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv2.y));
        vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y));

        device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3);
        m_engine->AddStatisticTriangle(1);
    }
}
Exemplo n.º 3
0
void CColor::Draw()
{
    Gfx::CDevice* device;
    Gfx::VertexCol  vertex[4];  // 2 triangles
    Gfx::Color   color;
    Math::Point     p1, p2;

    if ( (m_state & STATE_VISIBLE) == 0 )  return;

    if ( m_state & STATE_SHADOW )
    {
        DrawShadow(m_pos, m_dim);
    }

    m_engine->SetTexture("button1.png");
    m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
    CControl::Draw();

#if _TEEN
//    color = GetColor(m_color);
    color = GetColor();

    m_engine->SetTexture("");  // no texture
    m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);

    device = m_engine->GetDevice();

    p1.x = m_pos.x + (4.0f / 640.0f);
    p1.y = m_pos.y + (4.0f / 480.0f);
    p2.x = m_pos.x + m_dim.x - (4.0f / 640.0f);
    p2.y = m_pos.y + m_dim.y - (4.0f / 480.0f);
    vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
    vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
    vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
    vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
    device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);

    p1.x = m_pos.x + (5.0f / 640.0f);
    p1.y = m_pos.y + (5.0f / 480.0f);
    p2.x = m_pos.x + m_dim.x - (5.0f / 640.0f);
    p2.y = m_pos.y + m_dim.y - (5.0f / 480.0f);
    vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
    vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
    vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
    vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
    device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);

    m_engine->AddStatisticTriangle(4);
#else
    p1.x = m_pos.x + (3.0f / 640.0f);
    p1.y = m_pos.y + (3.0f / 480.0f);
    p2.x = m_pos.x + m_dim.x - (3.0f / 640.0f);
    p2.y = m_pos.y + m_dim.y - (3.0f / 480.0f);

    color = GetColor();

    m_engine->SetTexture("");  // no texture
    m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);

    vertex[0] = Gfx::VertexCol(Math::Vector(p1.x, p1.y, 0.0f), color);
    vertex[1] = Gfx::VertexCol(Math::Vector(p1.x, p2.y, 0.0f), color);
    vertex[2] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color);
    vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color);

    device = m_engine->GetDevice();
    device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
    m_engine->AddStatisticTriangle(2);
#endif
}