Beispiel #1
0
	Cuboid::Cuboid(const Vector3Df& extent)
	{
		CreateCuboid(extent.x * 2.0f, extent.y * 2.0f, extent.z * 2.0f);
	}
Beispiel #2
0
	Cuboid::Cuboid(float width, float height, float depth)
	{
		CreateCuboid(width, height, depth);
	}
Beispiel #3
0
void KPboardView::Initialize(const std::string &TextureDirectory,
                             const std::string &TextureName,
                             unsigned int TextureSize /*=1*/,
                             bool Nearest /*=true*/)
{
    InitializeTextures(TextureDirectory, TextureName, TextureSize, Nearest);

    glNewList(DisplayList + BRONZE_MATERIAL, GL_COMPILE);
    {
        GLfloat mat_ambient[]  = {0.50f, 0.50f, 0.50f, 1.0f};
        GLfloat mat_diffuse[]  = {0.60f, 0.60f, 0.60f, 1.0f};
        GLfloat mat_specular[] = {0.15f, 0.15f, 0.15f, 1.0f};
        auto mat_shininess  = 20.0f;

        glDisable(GL_TEXTURE_2D);

        glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
        glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
        glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
        glMaterialf(GL_FRONT, GL_SHININESS, mat_shininess);

        glEnable(GL_TEXTURE_2D);
    }
    glEndList();

    // define a Display List BOARD containing the Khun Phan board
    glNewList(DisplayList + BOARD, GL_COMPILE);

    // Front end (with gap for Khun Phan to escape :-)
    CreateCuboid(
        DBOXW + DX + DGAP, DBOXW, DBOXH,
        -((HORIZONTAL_MAX * (DX + DGAP) - DGAP) / 2) - DGAP - DBOXW,
        ((VERTICAL_MAX   * (DY + DGAP) - DGAP) / 2) + DGAP, 0);
    CreateCuboid(
        2 * (DX + DGAP) + DGAP, DBOXW, DBOXH - (DZ * 2 / 3) - DGAP,
        -((2 * (DX + DGAP) - DGAP) / 2) - DGAP,
        ((VERTICAL_MAX   * (DY + DGAP) - DGAP) / 2) + DGAP,
        (DZ * 2 / 3) + DGAP);
    CreateCuboid(
        DBOXW + DX + DGAP, DBOXW, DBOXH,
        ((2 * (DX + DGAP) - DGAP) / 2) + DGAP,
        ((VERTICAL_MAX   * (DY + DGAP) - DGAP) / 2) + DGAP, 0);
    // Back end
    CreateCuboid(
        2 * DBOXW + DGAP + (HORIZONTAL_MAX * (DX + DGAP)), DBOXW, DBOXH,
        -((HORIZONTAL_MAX * (DX + DGAP) - DGAP) / 2) - DGAP - DBOXW,
        -((VERTICAL_MAX   * (DY + DGAP) - DGAP) / 2) - DGAP - DBOXW, 0);
    // Left end
    CreateCuboid(
        DBOXW, VERTICAL_MAX * (DY + DGAP) + DGAP, DBOXH,
        -((HORIZONTAL_MAX * (DX + DGAP) - DGAP) / 2) - DGAP - DBOXW,
        -((VERTICAL_MAX   * (DY + DGAP) + DGAP) / 2), 0);
    // Right end
    CreateCuboid(
        DBOXW, VERTICAL_MAX * (DY + DGAP) + DGAP, DBOXH,
        ((HORIZONTAL_MAX  * (DX + DGAP) - DGAP) / 2) + DGAP,
        -((VERTICAL_MAX    * (DY + DGAP) - DGAP) / 2) - DGAP, 0);
    // Bottom end
    CreateCuboid(
        2 * DBOXW + DGAP + (HORIZONTAL_MAX * (DX + DGAP)),
        2 * DBOXW + DGAP + VERTICAL_MAX * (DY + DGAP), DBOXW,
        -(HORIZONTAL_MAX * (DX + DGAP) / 2) - DGAP - DBOXW,
        -(VERTICAL_MAX * (DY + DGAP) / 2) - DGAP - DBOXW, -DBOXW);

    glEndList();

    // define a Display List CUBOID_1X1 containing a cuboid with size 1 x 1

    glNewList(DisplayList + CUBOID_1X1_1, GL_COMPILE);
    CreateCuboid(DX, DY, DZ, 0, 0, 0, true);
    glEndList();
    glNewList(DisplayList + CUBOID_1X1_2, GL_COMPILE);
    CreateCuboid(DX, DY, DZ, 0, 0, 0, true);
    glEndList();
    glNewList(DisplayList + CUBOID_1X1_3, GL_COMPILE);
    CreateCuboid(DX, DY, DZ, 0, 0, 0, true);
    glEndList();
    glNewList(DisplayList + CUBOID_1X1_4, GL_COMPILE);
    CreateCuboid(DX, DY, DZ, 0, 0, 0, true);
    glEndList();

    // define a Display List CUBOID_1X2 containing a cuboid with size 1 x 2

    glNewList(DisplayList + CUBOID_1X2_1, GL_COMPILE);
    CreateCuboid(DX, 2 * DY + DGAP, DZ, 0, 0, 0, true);
    glEndList();
    glNewList(DisplayList + CUBOID_1X2_2, GL_COMPILE);
    CreateCuboid(DX, 2 * DY + DGAP, DZ, 0, 0, 0, true);
    glEndList();
    glNewList(DisplayList + CUBOID_1X2_3, GL_COMPILE);
    CreateCuboid(DX, 2 * DY + DGAP, DZ, 0, 0, 0, true);
    glEndList();
    glNewList(DisplayList + CUBOID_1X2_4, GL_COMPILE);
    CreateCuboid(DX, 2 * DY + DGAP, DZ, 0, 0, 0, true);
    glEndList();

    // define a Display List CUBOID_2X1 containing a cuboid with size 2 x 1

    glNewList(DisplayList + CUBOID_2X1, GL_COMPILE);
    CreateCuboid(2 * DX + DGAP, DY, DZ, 0, 0, 0, true);
    glEndList();

    // define a Display List CUBOID_2X2 containing a cuboid with size 2 x 2

    glNewList(DisplayList + CUBOID_2X2, GL_COMPILE);
    CreateCuboid(2 * DX + DGAP, 2 * DY + DGAP, DZ * 2 / 3, 0, 0, 0, true);
    glEndList();
}