コード例 #1
0
    inline plane_orientation classify_simplex_to_plane(const Simplex& smplx, const Hyperplane& plane, const NumberComparisonPolicy& cmp)
    {
        // Loop over all polygon vertices and count how many vertices
        // lie in front of and how many lie behind of the thickened plane
        auto numInFront = 0, numBehind = 0;
        auto numVerts = number_vertices(smplx);
        for (auto i = 0; i < numVerts; ++i)
        {
            auto p = get_vertex(smplx, i);
            switch (classify_point_to_plane(p, plane, cmp))
            {
            case plane_orientation::in_front_of_plane:
                ++numInFront;
                break;
            case plane_orientation::in_back_of_plane:
                ++numBehind;
                break;
            }
        }

        // If vertices on both sides of the plane, the polygon is straddling
        if (numBehind != 0 && numInFront != 0)
            return plane_orientation::straddling_plane;
        // If one or more vertices in front of the plane and no vertices behind
        // the plane, the polygon lies in front of the plane
        if (numInFront != 0)
            return plane_orientation::in_front_of_plane;
        // Ditto, the polygon lies behind the plane if no vertices in front of
        // the plane, and one or more vertices behind the plane
        if (numBehind != 0)
            return plane_orientation::in_back_of_plane;
        // All vertices lie on the plane so the polygon is coplanar with the plane
        return plane_orientation::coplanar_with_plane;
    }
コード例 #2
0
ファイル: game.c プロジェクト: rlt3/fast
void
cleanup_game(struct Game *game)
{
  SDL_Quit();
  destroy_vertices_array(screen_vertices(), 4);
  destroy_vertices_array(number_vertices(), 4);
  deconstruct_polygon(game->player);
  deconstruct_polygon_array(game->asteroids, MAX_ASTEROIDS);
  deconstruct_polygon_array(game->stars,     MAX_STARS);
}
コード例 #3
0
ファイル: game.c プロジェクト: rlt3/fast
void
display_number(struct Game *game, int number)
{
  char string[8];

  sprintf(string, "%d", number);

  int i;
  int digit;
  int offset;
  float kerning;

  int length = strlen(string);

  for (i = 0; i < length; i++) {
    digit   = (int) string[i] - 48;
    kerning = 1.5 + (float) i;

    glPushMatrix();
    glTranslatef(kerning, 0.6f, 0.0f);
    display_quad(game->graphics.number_textures[digit], 0, 0, number_vertices());
    glPopMatrix();
  }
}