예제 #1
0
static void visit(bd_tree_handle_t *handle,
		  int k, int tag)

{

  int i;
  bd_tree_vertex_t *v;

  push_vertex(handle, handle->vertices + k);
  
  while (!vertex_stack_empty(handle)) {
    v = pop_vertex(handle);
    if (v == NULL) {
      fprintf(stderr, "ERROR - tree:visit, popped NULL v\n");
      return;
    }
    if (!v->visited) {
      v->tag = tag;
      v->visited = 1;
      for (i = 0; i < v->nadjacent; i++) {
	if (v->adjacent[i] > handle->n_index_alloc - 1) {
	  fprintf(stderr, "ALLOC ERROR - tree.c:visit()\n");
	  fprintf(stderr, "n_alloc: %d, n_needed: %d\n",
		  handle->n_index_alloc, v->adjacent[i]);
	}
	if (handle->index[v->adjacent[i]] >= 0) {
	  push_vertex(handle, (handle->vertices +
			       handle->index[v->adjacent[i]]));
	}
      } /* i */
    }
  } /* while */

}
예제 #2
0
int init( )
{
    // etape 1 : decrire le triangle, les coordonnees des 3 sommets.
    
    // creer un mesh pour stocker les coordonnees des sommets du triangle
    triangle= create_mesh(GL_TRIANGLES);
    
    // choisir une couleur pour les sommets, rouge + vert = jaune
    vertex_color(triangle, make_color(1, 1, 0));
    
    // donner les positions des 3 sommets, entre -1 1 sur x, y, z
    push_vertex(triangle, -0.5, -0.5, 0);
    push_vertex(triangle,  0.5,  0.5, 0);
    push_vertex(triangle, -0.5,  0.5, 0);
    
    return 0;   // ras, pas d'erreur
    
// on peut aussi donner des couleurs differentes aux sommets du triangle :
/*
    vertex_color(triangle, make_color(1, 0, 0));
    push_vertex(triangle, -0.5, -0.5, 0);
    
    vertex_color(triangle, make_color(0, 1, 0));
    push_vertex(triangle,  0.5,  0.5, 0);
    
    vertex_color(triangle, make_color(0, 0, 1));
    push_vertex(triangle, -0.5,  0.5, 0);
    
    return 0;   // ras, pas d'erreur
 */
}
예제 #3
0
int init( )
{
    // etape 1 : decrire le triangle, les coordonnees des 3 sommets.

    // creer un mesh pour stocker les coordonnees des sommets du triangle
    triangle= create_mesh(GL_TRIANGLES);

    vertex_color(triangle, make_color(1, 0, 0));
    push_vertex(triangle, -0.5, -0.5, 0);

    vertex_color(triangle, make_color(0, 1, 0));
    push_vertex(triangle,  0.5,  0.5, 0);

    vertex_color(triangle, make_color(0, 0, 1));
    push_vertex(triangle, -0.5,  0.5, 0);

    return 0;   // ras, pas d'erreur
}
예제 #4
0
int init( )
{
    // etape 1 : decrire le triangle, les coordonnees des 3 sommets.
    
    // creer un mesh pour stocker les coordonnees des sommets du triangle
    triangle= create_mesh(GL_TRIANGLES);
    
    vertex_color(triangle, make_color(1, 0, 0));
    push_vertex(triangle, -0.5, -0.5, 0);
    
    vertex_color(triangle, make_color(0, 1, 0));
    push_vertex(triangle,  0.5,  0.5, 0);
    
    vertex_color(triangle, make_color(0, 0, 1));
    push_vertex(triangle, -0.5,  0.5, 0);
    
    // etape 2 : creer une camera par defaut, elle est placee en 0, 0, 5 et regarde les objets situes en 0, 0, 0
    camera= make_orbiter();
    
    return 0;   // ras, pas d'erreur
}
예제 #5
0
static void visit(int k,
		  tree_vertex_t *vertices,
		  si32 tag)

{

  int i;
  tree_vertex_t *v;

  push_vertex(vertices + k);

  while (!vertex_stack_empty()) {
    v = pop_vertex();
    if (!v->visited) {
      v->tag = tag;
      v->visited = 1;
      for (i = 0; i < v->nadjacent; i++) {
	push_vertex(vertices + vertex_index(v->adjacent[i]));
      }
    } /* i */
  } /* while */

}
예제 #6
0
static void DFS_visit(struct vertex_s *u) {
    int j;
    struct listnode_s *n;
    struct vertex_s *v;

    u->color = GRAY;
    u->dt = ++dfs_time;

    for (n = u->adj; n; n = n->next) {
        v = n->v;
        if (v->color == WHITE) {
            v->predecessor = u;
            DFS_visit(v);
        }
    }

    u->color = BLACK;
    u->ft = ++dfs_time;

    push_vertex(&toplist, u);
}
예제 #7
0
 void line_to(value_type x,value_type y)
 {
     push_vertex(x,y,SEG_LINETO);
 }
예제 #8
0
파일: path.hpp 프로젝트: CartoDB/mapnik
 void move_to(coordinate_type x,coordinate_type y)
 {
     push_vertex(x,y,SEG_MOVETO);
 }
예제 #9
0
파일: path.hpp 프로젝트: CartoDB/mapnik
 void line_to(coordinate_type x,coordinate_type y)
 {
     push_vertex(x,y,SEG_LINETO);
 }
예제 #10
0
파일: path.hpp 프로젝트: CartoDB/mapnik
 void close_path()
 {
     push_vertex(0,0,SEG_CLOSE);
 }
예제 #11
0
static struct graph_s *dag_init(void) {
    int i;
    struct graph_s *graph;

    graph = (struct graph_s *)malloc(sizeof(struct graph_s));
    graph->vertices = (struct vertex_s **)malloc(sizeof(struct vertex_s)*DAG_N);
    graph->num_vertices = DAG_N;
    //graph->num_vertices = N;

    for (i = 0; i < graph->num_vertices; ++i) {
        graph->vertices[i] = (struct vertex_s *)malloc(sizeof(struct vertex_s));
        graph->vertices[i]->adj = NULL;
        graph->vertices[i]->value = i;
    }

/*
    graph->vertices[0]->value = 7;
    graph->vertices[1]->value = 5;
    graph->vertices[2]->value = 3;
    graph->vertices[3]->value = 11;
    graph->vertices[4]->value = 8;
    graph->vertices[5]->value = 2;
    graph->vertices[6]->value = 9;
    graph->vertices[7]->value = 10;

    push_vertex(&graph->vertices[0]->adj, graph->vertices[4]);
    push_vertex(&graph->vertices[0]->adj, graph->vertices[3]);

    push_vertex(&graph->vertices[1]->adj, graph->vertices[3]);

    push_vertex(&graph->vertices[2]->adj, graph->vertices[7]);
    push_vertex(&graph->vertices[2]->adj, graph->vertices[4]);

    push_vertex(&graph->vertices[3]->adj, graph->vertices[7]);
    push_vertex(&graph->vertices[3]->adj, graph->vertices[6]);
    push_vertex(&graph->vertices[3]->adj, graph->vertices[5]);

    push_vertex(&graph->vertices[4]->adj, graph->vertices[6]);
*/

    /*
     * Clothing example in CLRS -- uses DAG_N
     *
     * 0 -> 1, 7        (boxers -> pants, shoes)
     * 1 -> 2, 7        (pants -> belt, shoes)
     * 2 -> 5           (belt -> jacket)
     * 3 -> 2, 4        (shirt -> belt, tie)
     * 4 -> 5           (tie -> jacket)
     * 5 -> NULL        (jacket -> NULL)
     * 6 -> 7           (socks -> shoes)
     * 7 -> NULL        (shoes -> NULL)
     * 8 -> NULL        (watch -> NULL)
     */

    push_vertex(&graph->vertices[0]->adj, graph->vertices[7]);
    push_vertex(&graph->vertices[0]->adj, graph->vertices[1]);

    push_vertex(&graph->vertices[1]->adj, graph->vertices[7]);
    push_vertex(&graph->vertices[1]->adj, graph->vertices[2]);

    push_vertex(&graph->vertices[2]->adj, graph->vertices[5]);

    push_vertex(&graph->vertices[3]->adj, graph->vertices[4]);
    push_vertex(&graph->vertices[3]->adj, graph->vertices[2]);

    push_vertex(&graph->vertices[4]->adj, graph->vertices[5]);

    push_vertex(&graph->vertices[6]->adj, graph->vertices[7]);

    return graph;
}
예제 #12
0
unsigned int push_vertex( Mesh& m, const Point& position, const float u, const float v, const Vector& normal )
{
    vertex_texcoord(m, u, v);
    vertex_normal(m, normal);
    return push_vertex(m, position);
}
예제 #13
0
//torch
void MechListMeshRenderer::push_render_mesh(const struct Mech &m)
{

/*
    static const float vin[72] =
    {
        1,1,1, 0,1,1, 0,0,1, 1,0,1, //top
        0,1,0, 1,1,0, 1,0,0, 0,0,0, //bottom
        1,0,1, 1,0,0, 1,1,0, 1,1,1, //north
        0,1,1, 0,1,0, 0,0,0, 0,0,1, //south
        1,1,1, 1,1,0, 0,1,0, 0,1,1, //west
        0,0,1, 0,0,0, 1,0,0, 1,0,1  //east
    };
*/

    static class MeshInstance* MI; // load_mesh(const char* filename)
    static class MeshLoader* ML = NULL;
    if(ML == NULL)
    {
        printf("loading mesh: \n");
        ML = new MeshLoader;
        MI = ML->load_mesh(MEDIA_PATH "sprites/mech/mesh/light_rod.mesh");
    }

#if !PRODUCTION
    static int _counter = 0;
    _counter++;

    if(_counter % 60 == 1)
    {
        delete MI;
        MI = NULL;
        MI = ML->load_mesh(MEDIA_PATH "sprites/mech/mesh/light_rod.mesh");
    }
#endif

    float wx = m.position.x + 0.001f;
    float wy = m.position.y + 0.001;
    float wz = m.position.z + 0.0f;

    //fulstrum test
    const float cx = current_camera_position.x;
    const float cy = current_camera_position.y;

    wx = quadrant_translate_f(cx, wx);
    wy = quadrant_translate_f(cy, wy);

    if (!sphere_fulstrum_test(wx, wy, wz, 0.6f))
        return;

    int env_light = t_map::get_envlight(m.position);
    int sky_light = t_map::get_skylight(m.position);
    vertex_list.light(sky_light, env_light);

    const int imax = MI->van;
    const MeshInstance::Vertex* va = MI->va;
    for(int i=0; i<imax; i++)
    {
        vertex_list.vertex3f(wx+va[i].x, wy+va[i].y, wz+va[i].z);
        vertex_list.tex2f(va[i].tx, va[i].ty);
        vertex_list.push_vertex();
    }

}
예제 #14
0
unsigned int push_vertex( Mesh& m, const Point& position, const float u, const float v )
{
    vertex_texcoord(m, u ,v);
    return push_vertex(m, position);
}
예제 #15
0
unsigned int push_vertex( Mesh& m, const float x, const float y, const float z )
{
    return push_vertex(m, make_vec3(x, y, z));
}
예제 #16
0
unsigned int push_vertex( Mesh& m, const Point& p )
{
    return push_vertex(m, make_vec3(p.x, p.y, p.z));
}
예제 #17
0
unsigned int push_vertex( Mesh& m, const Point& position, const Vector& normal )
{
    vertex_normal(m, normal);
    return push_vertex(m, position);
}
예제 #18
0
unsigned int push_vertex( Mesh& m, const vec3& position, const vec3& normal )
{
    vertex_normal(m, normal);
    return push_vertex(m, position);
}
예제 #19
0
 void move_to(value_type x,value_type y)
 {
     push_vertex(x,y,SEG_MOVETO);
 }
예제 #20
0
static struct graph_s *graph_init(void) {
    /*
     * 0 --- 1     2 --- 3
     * |     |   / |   / |
     * |     |  /  |  /  |
     * |     | /   | /   |
     * 4     5 --- 6 --- 7
     */

    int i;
    struct graph_s *graph;

    graph = (struct graph_s *)malloc(sizeof(struct graph_s));
    graph->vertices = (struct vertex_s **)malloc(sizeof(struct vertex_s)*N);
    graph->num_vertices = N;

    for (i = 0; i < graph->num_vertices; ++i) {
        graph->vertices[i] = (struct vertex_s *)malloc(sizeof(struct vertex_s));
        graph->vertices[i]->adj = NULL;
        graph->vertices[i]->value = i;
    }

    push_vertex(&graph->vertices[0]->adj, graph->vertices[1]);
    push_vertex(&graph->vertices[0]->adj, graph->vertices[4]);

    push_vertex(&graph->vertices[1]->adj, graph->vertices[0]);
    push_vertex(&graph->vertices[1]->adj, graph->vertices[5]);

    push_vertex(&graph->vertices[2]->adj, graph->vertices[3]);
    push_vertex(&graph->vertices[2]->adj, graph->vertices[6]);
    push_vertex(&graph->vertices[2]->adj, graph->vertices[5]);

    push_vertex(&graph->vertices[3]->adj, graph->vertices[2]);
    push_vertex(&graph->vertices[3]->adj, graph->vertices[6]);
    push_vertex(&graph->vertices[3]->adj, graph->vertices[7]);

    push_vertex(&graph->vertices[4]->adj, graph->vertices[0]);

    push_vertex(&graph->vertices[5]->adj, graph->vertices[1]);
    push_vertex(&graph->vertices[5]->adj, graph->vertices[2]);
    push_vertex(&graph->vertices[5]->adj, graph->vertices[6]);

    push_vertex(&graph->vertices[6]->adj, graph->vertices[5]);
    push_vertex(&graph->vertices[6]->adj, graph->vertices[2]);
    push_vertex(&graph->vertices[6]->adj, graph->vertices[7]);
    push_vertex(&graph->vertices[6]->adj, graph->vertices[3]);

    push_vertex(&graph->vertices[7]->adj, graph->vertices[3]);
    push_vertex(&graph->vertices[7]->adj, graph->vertices[6]);

    return graph;
}