Exemple #1
0
Mesh* CreateWireframeBox(float width, float height, float depth, const glm::mat4& transform)
{
    float x1 = -0.5f * width;
    float x2 =  0.5f * width ;
    float y1 = -0.5f * height;
    float y2 =  0.5f * height;
    float z1 = -0.5f * depth;
    float z2 =  0.5f * depth;

    VertexPosition verts[] = {
        VertexPosition(x1, y1, z1),  // 0 (left-bottom-back)
        VertexPosition(x1, y1, z2),  // 1 (left-bottom-front)
        VertexPosition(x1, y2, z1),  // 2 (left-top-back)
        VertexPosition(x1, y2, z2),  // 3 (left-top-front)
        VertexPosition(x2, y1, z1),  // 4 (right-bottom-back)
        VertexPosition(x2, y1, z2),  // 5 (right-bottom-front)
        VertexPosition(x2, y2, z1),  // 6 (right-top-back)
        VertexPosition(x2, y2, z2),  // 7 (right-top-front)
    };

    // line segments
    unsigned char inds[] = {
        // back-to-front
        0, 1,
        2, 3,
        4, 5,
        6, 7,
        // bottom-to-top
        0, 2,
        1, 3,
        4, 6,
        5, 7,
        // left-to-right
        0, 4,
        1, 5,
        2, 6,
        3, 7,
    };

    unsigned numVerts = sizeof(verts) / sizeof(verts[0]);
    unsigned numInds = sizeof(inds) / sizeof(inds[0]);

    // transform the vertices using the user-supplied transformation matrix
    TransformPositions(verts, numVerts, transform);

    return CreateMesh(GL_LINES, verts, numVerts, inds, numInds);
}
Exemple #2
0
Mesh* CreateFullAxes(float length, const glm::mat4& transform)
{
    VertexPositionColor verts[] = {
        VertexPositionColor(-length,   0.0f,     0.0f,   0.0f, 0.0f, 1.0f, 1.0f),
        VertexPositionColor( length,   0.0f,     0.0f,   0.0f, 0.0f, 1.0f, 1.0f),
        VertexPositionColor(   0.0f, -length,    0.0f,   0.0f, 1.0f, 0.0f, 1.0f),
        VertexPositionColor(   0.0f,  length,    0.0f,   0.0f, 1.0f, 0.0f, 1.0f),
        VertexPositionColor(   0.0f,    0.0f, -length,   1.0f, 0.0f, 0.0f, 1.0f),
        VertexPositionColor(   0.0f,    0.0f,  length,   1.0f, 0.0f, 0.0f, 1.0f),
    };

    unsigned numVerts = sizeof(verts) / sizeof(verts[0]);

    // transform the vertices using the user-supplied transformation matrix
    TransformPositions(verts, numVerts, transform);

    return CreateMesh(GL_LINES, verts, numVerts);
}
Exemple #3
0
Mesh* CreateWireframePlane(float xSize, float zSize, int xSegments, int zSegments, const glm::mat4& transform)
{
    // sanity check
    if (xSegments < 1 || zSegments < 1) {
        return NULL;
    }

    float y = 0;
    float x = -0.5f * xSize;
    float z = -0.5f * zSize;

    float x1 = -0.5f * xSize;
    float x2 =  0.5f * xSize;
    float z1 = -0.5f * zSize;
    float z2 =  0.5f * zSize;

    float xSpacing = xSize / xSegments;
    float zSpacing = zSize / zSegments;

    // define world grid mesh data
    std::vector<VertexPosition> verts;
    // add back-to-front segments
    for (int i = 0; i <= xSegments; i++) {
        float x = x1 + i * xSpacing;
        verts.push_back(VertexPosition(x, y, z1));
        verts.push_back(VertexPosition(x, y, z2));
    }
    // add left-to-right segments
    for (int i = 0; i <= zSegments; i++) {
        float z = z1 + i * zSpacing;
        verts.push_back(VertexPosition(x1, y, z));
        verts.push_back(VertexPosition(x2, y, z));
    }

    // transform the vertices using the user-supplied transformation matrix
    TransformPositions(verts, transform);

    return CreateMesh(GL_LINES, verts);
}
Exemple #4
0
void TestSoftbody::Tick(const float /*dTime*/)
{
    TransformPositions();
}