예제 #1
0
void CGizmoTransformRender::DrawTri(const tvector3 &orig, float size, bool bSelected, const tvector3 &axisU, const tvector3 &axisV)
{
    tvector3 pts[3];
    pts[0] = orig;
    pts[1] = axisU;
    pts[2] = axisV;
    pts[1] *= size;
    pts[2] *= size;
    pts[1] += orig;
    pts[2] += orig;
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
    ActivateProgram();
    if (!bSelected) {
        glUniform4f(m_ColorUniform, 1, 1, 0, 0.5f);
    }
    else {
        glUniform4f(m_ColorUniform, 1, 1, 1, 0.6f);
    }
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(pts[0]), pts);
    glDrawArrays(GL_TRIANGLES, 0, sizeof(pts) / sizeof(pts[0]));
    if (!bSelected) {
        glUniform4f(m_ColorUniform, 1, 1, 0.2f, 1);
    }
    else {
        glUniform4f(m_ColorUniform, 1, 1, 1, 0.6f);
    }
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(pts[0]), pts);
    glDrawArrays(GL_LINE_STRIP, 0, sizeof(pts) / sizeof(pts[0]));
    DeactivateProgram();
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
}
예제 #2
0
void CGizmoTransformRender::DrawAxis(const tvector3 &orig, const tvector3 &axis, const tvector3 &vtx, const tvector3 &vty, float fct, float fct2, const tvector3 &col)
{
    tvector3 vertices1[2] = { orig, orig + axis };
    tvector3 vertices2[62];
    int j = 0;
    for (int i = 0; i <= 30; i++) {
        tvector3 pt;
        pt  = vtx * cos(((2 * ZPI) / 30.0f) * i) * fct;
        pt += vty * sin(((2 * ZPI) / 30.0f) * i) * fct;
        pt += axis * fct2;
        pt += orig;
        pt  = vtx * cos(((2 * ZPI) / 30.0f) * (i + 1)) * fct;
        pt += vty * sin(((2 * ZPI) / 30.0f) * (i + 1)) * fct;
        pt += axis * fct2;
        pt += orig;
        vertices2[j++] = pt;
        vertices2[j++] = orig + axis;
    }
    glDisable(GL_DEPTH_TEST);
    ActivateProgram();
    glUniform4f(m_ColorUniform, col.x, col.y, col.z, 1);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vertices1[0]), vertices1);
    glDrawArrays(GL_LINES, 0, 2);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vertices2[0]), vertices2);
    glDrawArrays(GL_TRIANGLE_FAN, 0, j);
    DeactivateProgram();
    glEnable(GL_DEPTH_TEST);
}
예제 #3
0
void CGizmoTransformRender::DrawCircle(const tvector3 &orig, const tvector3 &color, const tvector3 &vtx, const tvector3 &vty)
{
    static const int size = 50;
    tvector3 vertices[size];
    for (int i = 0; i < size; i++) {
        tvector3 vt;
        vt  = vtx * cos((2 * ZPI / size) * i);
        vt += vty * sin((2 * ZPI / size) * i);
        vt += orig;
        vertices[i] = vt;
    }
    glDisable(GL_DEPTH_TEST);
    ActivateProgram();
    glUniform4f(m_ColorUniform, color.x, color.y, color.z, 1);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vertices[0]), vertices);
    glDrawArrays(GL_LINE_LOOP, 0, size);
    DeactivateProgram();
    glEnable(GL_DEPTH_TEST);
}
예제 #4
0
void MaterialShellRenderer::Render(const glm::mat4& view, const glm::mat4& projection, int priority)
{
   if (material_shell_adapters_[priority].size() == 0)
   {
      return;
   }

   ActivateProgram();

   SetProjectionViewMatrixPA(projection * view);
   for (auto material_shell_adapter : material_shell_adapters_[priority])
   {
      glm::mat4 model = material_shell_adapter->GetModelMatrix();
      SetModelMatrixPA(model);
      glm::mat3 normal_model = glm::transpose(glm::inverse(glm::mat3(model)));
      SetNormalModelMatrixPA(normal_model);
      material_shell_adapter->Render();
   }

   DeactivateProgram();
}
예제 #5
0
void CGizmoTransformRender::DrawCircleHalf(const tvector3 &orig, const tvector3 &color, const tvector3 &vtx, const tvector3 &vty, tplane &camPlan)
{
    static const int size = 30;
    tvector3 vertices[size];
    int j = 0;
    for (int i = 0; i < size; i++) {
        tvector3 vt;
        vt  = vtx * cos((ZPI / size) * i);
        vt += vty * sin((ZPI / size) * i);
        vt += orig;
        if (camPlan.DotNormal(vt)) {
            vertices[j++] = vt;
        }
    }
    glDisable(GL_DEPTH_TEST);
    ActivateProgram();
    glUniform4f(m_ColorUniform, color.x, color.y, color.z, 1);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vertices[0]), vertices);
    glDrawArrays(GL_LINE_STRIP, 0, j);
    DeactivateProgram();
    glEnable(GL_DEPTH_TEST);
}
예제 #6
0
void CGizmoTransformRender::DrawCamem(const tvector3 &orig, const tvector3 &vtx, const tvector3 &vty, float ng)
{
    tvector3 vertices[52];
    int j = 0;
    vertices[j++] = orig;
    for (int i = 0 ; i <= 50 ; i++) {
        tvector3 vt;
        vt = vtx * cos((ng / 50) * i);
        vt += vty * sin((ng / 50) * i);
        vt += orig;
        vertices[j++] = vt;
    }
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
    ActivateProgram();
    glUniform4f(m_ColorUniform, 0xf0 / 255.0, 0x12 / 255.0, 0xbe / 255.0, 0.5);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vertices[0]), vertices);
    glDrawArrays(GL_TRIANGLE_FAN, 0, j);
    j = 0;
    vertices[j++] = &orig.x;
    for (int i = 0 ; i <= 50 ; i++) {
        tvector3 vt;
        vt  = vtx * cos(((ng)/50)*i);
        vt += vty * sin(((ng)/50)*i);
        vt += orig;
        vertices[j++] = vt;
    }
    glDisable(GL_BLEND);
    glUniform4f(m_Program, 1, 1, 0.2, 1);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(vertices[0]), vertices);
    glDrawArrays(GL_LINE_LOOP, 0, j);
    DeactivateProgram();
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glEnable(GL_BLEND);
}