Esempio n. 1
0
int main()
{
	glm::mat4 MVP;
	GLFWwindow* window; // (Dans le code joint, cette variable est globale)
	// Ceci identifiera notre tampon de sommets
	GLuint vertexbuffer;

	init_window(&window);
	init_vertex(&window, &vertexbuffer);

	// Crée et compile notre programme GLSL à partir des shaders
	GLuint programID = LoadShaders( "src/SimpleVertexShader.vertexshader", "src/SimpleFragmentShader.fragmentshader" );
	init_matrix(&MVP);
	do{
		// N'affiche rien, à bientôt dans le deuxième tutoriel !
		render_vertex(programID, vertexbuffer);
		render_matrix(programID, MVP);
//#ifdef	__APPLE__// Linux compile quand même mais le clavier n'est pas pris en charge
		glfwPollEvents();
//#endif
		// Échange les tampons
		glfwSwapBuffers(window);

	} // Vérifie si la touche échap a été appuyée ou si la fenêtre a été fermée
	while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
			glfwWindowShouldClose(window) == 0 );
}
Esempio n. 2
0
Graph init_graph()
{
    Graph *g = (Graph *)malloc(sizeof(Graph));
    g->vexnum = 0;
    g->edgnum = 0;
    init_vertex(g);
    init_edge(g);
    return *g;
}
Esempio n. 3
0
int add_vertex(char *name, network *net) {
	vertex *vrtx = init_vertex(name, net->num_of_vertices);
	if (vrtx == NULL) {
		send_perror("malloc");
		return 2;
	}

	return add_vertex_to_network(&net, vrtx);

	//	printf("%s",net->vertices[0].name);
}
Esempio n. 4
0
cfg_t* new_cfg(size_t nvertex, size_t nsymbol, size_t max_succ)
{
        size_t                i;
        cfg_t*                cfg;

        cfg = calloc(1, sizeof(cfg_t));
        if (cfg == NULL)
                error("out of memory");

        cfg->nvertex = nvertex;
        cfg->nsymbol = nsymbol;

        cfg->vertex = calloc(nvertex, sizeof(vertex_t));
        if (cfg->vertex == NULL)
                error("out of memory");

        for (i = 0; i < nvertex; i += 1)
                init_vertex(&cfg->vertex[i], i, nsymbol, max_succ);

        return cfg;
}
Esempio n. 5
0
void drawTooth()
{
        int i, j;
        Vertex3D vl, vr, vx;
        Vector3D v;

        glPushMatrix();
        glRotatef(Radians2Degrees(PSI), 0.0f, 0.0f, 1.0f);
        drawEvolvent(1);	// draw left side surface of the tooth
        glPopMatrix();

        glPushMatrix();
        glRotatef(Radians2Degrees(-PSI), 0.0f, 0.0f, 1.0f);
        drawEvolvent(0);	// draw right side surface of the tooth
        glPopMatrix();

        // draw tooth top surface
        for (i = 0; i < TOP_STEPS; ++i) {
                glBegin(GL_QUAD_STRIP);
                for (j = 0; j <= PHI1_STEPS; ++j) {
                        vl = l_evolventa(PHI_MAX, PHI1_I(j));
                        vr = r_evolventa(PHI_MAX, PHI1_I(j));

                        vl = init_vertex(vl.x*cosf(PSI) + vl.y*sinf(PSI), -vl.x*sinf(PSI) + vl.y*cosf(PSI), vl.z);
                        vr = init_vertex(vr.x*cosf(PSI) - vr.y*sinf(PSI), vr.x*sinf(PSI) + vr.y*cosf(PSI), vr.z);

                        v = point_sub(&vl, &vr);
                        v = vector_mul(&v, (float)i / TOP_STEPS);
                        vx = point_add_vector(&vr, &v);

                        glNormal3f(0.0f, -1.0f, 0.0f);
                        glVertex3f(vx.x, vx.y, vx.z);

                        v = point_sub(&vl, &vr);
                        v = vector_mul(&v, (float)(i + 1) / TOP_STEPS);
                        vx = point_add_vector(&vr, &v);

                        glNormal3f(0.0f, -1.0f, 0.0f);
                        glVertex3f(vx.x, vx.y, vx.z);
                }
                glEnd();
        }

        // draw tooth front and back surfaces
        /*
        for (i = 0; i < TOP_STEPS; ++i) {
                glBegin(GL_QUAD_STRIP);
                for (j = 0; j <= PHI_STEPS; ++j) {
                        vl = l_evolventa(PHI_I(j), PHI1_I(0));
                        vr = r_evolventa(PHI_I(j), PHI1_I(0));

                        vl = init_vertex(vl.x*cosf(PSI) + vl.y*sinf(PSI), -vl.x*sinf(PSI) + vl.y*cosf(PSI), vl.z);
                        vr = init_vertex(vr.x*cosf(PSI) - vr.y*sinf(PSI), vr.x*sinf(PSI) + vr.y*cosf(PSI), vr.z);

                        v = point_sub(&vl, &vr);
                        v = vector_mul(&v, (float)i / TOP_STEPS);
                        vx = point_add_vector(&vr, &v);

                        glNormal3f(0.0f, 0.0f, -1.0f);
                        glVertex3f(vx.x, vx.y, vx.z);

                        v = point_sub(&vl, &vr);
                        v = vector_mul(&v, (float)(i + 1) / TOP_STEPS);
                        vx = point_add_vector(&vr, &v);

                        glNormal3f(0.0f, 0.0f, -1.0f);
                        glVertex3f(vx.x, vx.y, vx.z);
                }
                glEnd();
        }

        for (i = 0; i < TOP_STEPS; ++i) {
                glBegin(GL_QUAD_STRIP);
                for (j = 0; j <= PHI_STEPS; ++j) {
                        vl = l_evolventa(PHI_I(j), PHI1_MAX);
                        vr = r_evolventa(PHI_I(j), PHI1_MAX);

                        vl = init_vertex(vl.x*cosf(PSI) + vl.y*sinf(PSI), -vl.x*sinf(PSI) + vl.y*cosf(PSI), vl.z);
                        vr = init_vertex(vr.x*cosf(PSI) - vr.y*sinf(PSI), vr.x*sinf(PSI) + vr.y*cosf(PSI), vr.z);

                        v = point_sub(&vl, &vr);
                        v = vector_mul(&v, (float)i / TOP_STEPS);
                        vx = point_add_vector(&vr, &v);

                        glNormal3f(0.0f, 0.0f, 1.0f);
                        glVertex3f(vx.x, vx.y, vx.z);

                        v = point_sub(&vl, &vr);
                        v = vector_mul(&v, (float)(i + 1) / TOP_STEPS);
                        vx = point_add_vector(&vr, &v);

                        glNormal3f(0.0f, 0.0f, 1.0f);
                        glVertex3f(vx.x, vx.y, vx.z);
                }
                glEnd();
        }
        */

        glPushMatrix();
        glRotatef(Radians2Degrees(PSI + 0.024), 0.0f, 0.0f, 1.0f);
        drawTransitionSurface(1);
        glPopMatrix();

        glPushMatrix();
        glRotatef(Radians2Degrees(-PSI - 0.024), 0.0f, 0.0f, 1.0f);
        drawTransitionSurface(0);
        glPopMatrix();
}
Esempio n. 6
0
int AD_Object3D::init(void)
{
//  AD_Lod lodder;
  int k;
  AD_Quaternion q;
  AD_Matrix M;
  //AD_Vect3D v;
  float x1, y1, z1, x2, y2, z2;
  AD_OSMObject *OSMaux[100];

// ############  INIZIALIZZAZIONI DELLE KEYFRAMER  ############
  if (positiontrack.init()==-1) return(-1);
  if (rotationtrack.init()==-1) return(-1);
  if (scaletrack.init()==-1)    return(-1);
  
  // cistruisco le quantita' che mi permettono di costruire una
  // eventuale matrice di skin se questo oggetto fosse usato come
  // osso
  if (rotationtrack.numkey>0)
  {
     rotationtrack.get_data(0, &q);
     quat_rotquat_to_matrix(&q, &M);
	 mat_transpose(&M, &rot0);
  }else mat_identity(&rot0);
  if (scaletrack.numkey>0) scaletrack.get_data(0, &scale0);
  else vect_set(&scale0, 1, 1, 1);
  if (positiontrack.numkey>0) positiontrack.get_data(0, &pos0);
  else vect_set(&pos0, 0, 0, 0);

/*
  if ((positiontrack.numkey==1) && (positiontrack.posizioni[0].posintrack==0) &&
	  (father==(AD_Object3D *)NULL) && (have_childrens<=0))
  {
	currentpos=positiontrack.posizioni[0].p;
	positiontrack.numkey=0;
  }
*/

  if (type==DUMMY)
  {
  // sistemo il flare connesso; devo creare i 2 triangoli,
  // i vertici 2D, 3D (solo per linkare i v2D), il materiale
  // trasparente
    if (flare!=(texture *)NULL)
	{
	  latoX=(float)flare->dimx;
	  latoY=(float)flare->dimy;

	  // setto le uv dei vertici per il flare; i vertici sono cosi'
	  // disposti
	  // 0----1
	  // |    |
	  // |    |
	  // 2----3

	  vertex2D[0].u=0.0f*TEXTURE_PRECISION;
	  vertex2D[0].v=0.0f*TEXTURE_PRECISION;
	  vertex2D[1].u=0.99f*TEXTURE_PRECISION;
	  vertex2D[1].v=0.0f*TEXTURE_PRECISION;
	  vertex2D[2].u=0.0f*TEXTURE_PRECISION;
	  vertex2D[2].v=0.99f*TEXTURE_PRECISION;
	  vertex2D[3].u=0.99f*TEXTURE_PRECISION;
	  vertex2D[3].v=0.99f*TEXTURE_PRECISION;

	
	  // i vertici 3D li setto sempre da non clippare visto
	  // che quando devo disegnare i flare sono sicuro che non
	  // devo clipparli e solo quando disegno li inserisco nella
	  // lista dei triangoli trasparenti
	  vertex3D[0].flags=0;
	  vertex3D[1].flags=0;
	  vertex3D[2].flags=0;
	  vertex3D[3].flags=0;
	
	  // setto il materiale
	  matflare.texture_ptr=flare;
	  matflare.flags=(0 | PAINT_TEXTURE | IS_TRASPARENT);
	  matflare.trasparencytype=MIXTYPE_ADD;
	  AddUpdate_Material(&matflare);

      // ATTENZIONE: non cambiare gli indici perche' a causa
	  // del settaggio di cull2D della scheda3D i triangoli
	  // devono essere in senso antiorario
	  // setto i triangoli
	  tria[0].materiale=&matflare;
	  tria[0].v1=&vertex3D[0];
	  tria[0].v2=&vertex3D[2];
	  tria[0].v3=&vertex3D[3];
	  tria[0].sp1=&vertex2D[0];
	  tria[0].sp2=&vertex2D[2];
	  tria[0].sp3=&vertex2D[3];
	  tria[1].materiale=&matflare;
	  tria[1].v1=&vertex3D[3];
	  tria[1].v2=&vertex3D[1];
	  tria[1].v3=&vertex3D[0];
	  tria[1].sp1=&vertex2D[3];
	  tria[1].sp2=&vertex2D[1];
	  tria[1].sp3=&vertex2D[0];
	}
	return(0);
  }
  if (type==BONE) return(0);

/* NON PIU' FATTIBILE A CAUSA DEGLI OSM
------------------------------------------
-----------------------------------------
  // OTTIMIZAZIONE !!!
  if ((rotationtrack.numkey==1) && (rotationtrack.rotazioni[0].posintrack==0) &&
	  (father==(AD_Object3D *)NULL) && (have_childrens<=0))
  {
	q=rotationtrack.rotazioni[0].rotquat;
    quat_rotquat_to_matrix(&q, &M);
	rotationtrack.numkey=0;
    mat_identity(&currentmatrix_rot);
	for (k=0; k<num_vertex; k++)
	{
	  mat_mulvect(&M, &points[k], &v);
	  vect_copy(&v, &points[k]);
	}
  }
  if ((scaletrack.numkey==1) && (scaletrack.posizioni[0].posintrack==0) &&
	  (father==(AD_Object3D *)NULL) && (have_childrens<=0))
  {
	for (k=0; k<num_vertex; k++)
	{
	  points[k].x*=scaletrack.posizioni[0].p.x;
	  points[k].y*=scaletrack.posizioni[0].p.y;
	  points[k].z*=scaletrack.posizioni[0].p.z;
	}
	scaletrack.numkey=0;
  }
*/

  // calcolo bounding box per poi settarla negli OSM
  x1=y1=z1=1E10;
  x2=y2=z2=-1E10;
  for (k=0; k<num_vertex3D; k++)
  {
	 if (vertex3D[k].point.x < x1) x1 = vertex3D[k].point.x;
	 if (vertex3D[k].point.y < y1) y1 = vertex3D[k].point.y;
	 if (vertex3D[k].point.z < z1) z1 = vertex3D[k].point.z;
	 if (vertex3D[k].point.x > x2) x2 = vertex3D[k].point.x;
	 if (vertex3D[k].point.y > y2) y2 = vertex3D[k].point.y;
	 if (vertex3D[k].point.z > z2) z2 = vertex3D[k].point.z;
  }

  // inverto l'ordine degli OSM perche' vanno applicati
  // al contrario
  for (k=0; k<(int)num_OSMmods; k++)
    OSMaux[k]=OSMmods[k];

  for (k=0; k<(int)num_OSMmods; k++)
    OSMmods[num_OSMmods-k-1]=OSMaux[k];

  // Inizializzazione OSM modifiers
  for (k=0; k<(int)num_OSMmods; k++)
  {
	OSMmods[k]->init();
	OSMmods[k]->set_bbox(x1, y1, z1, x2, y2, z2);
  }

  precalc_radius();  // precalcola raggio sfera circoscritta
  init_tria();       // calcola: normale, punto medio e raggio circoscritto
  init_texture_coordinate(); // rende positive le uv
  init_vertex();  // alloca e prepara le normali ai vertici tenendo
                  // conto degli smoothing groups; inoltre setta
                  // opportunamente i campi n1, n2, n3, sp1, sp2, sp3
                  // dei triangoli
  if (vertexUV!=(AD_VectUV *)NULL) delete [] vertexUV;
  
  if (bones_matrix!=(AD_Matrix **)NULL)
  for (k=0; k<num_vertex3D; k++)
  {
     // questo perchè in fase di lettura (UtilsA3D) i punti nello
	 // spazio delle bonez vengono messi in points_tr
	 vect_copy(&vertex3D[k].tpoint, &vertex3D[k].point);
  }


// NB: IL LOD VA INSERITO IN QUESTO PUNTO !!!!
// NE' PRIMA (perche' le uv ai vertici devono essere sistemate)
// NE' DOPO (perche' i tringoli devono eseere inizializzati
// tutti (anche quelli del modello semplificato) dopo)
// [ad]TURBO ROXXXXXXXXXXXXXXXXX   
/*
  lodder.apply_lod(vertex3D, num_vertex,
	                tria, num_tria,
					70,
					&vertex3D, &num_vertex,
					&tria, &num_tria,
					GEOMETRIC_LOD);
*/
  split_tria_list();
  return(0);
}
Esempio n. 7
0
File: al3d.c Progetto: bjorndm/ekq
int main(void) {
  ALLEGRO_VERTEX        v[8];
  ALLEGRO_DISPLAY     * display;
  ALLEGRO_TRANSFORM     perst;
  ALLEGRO_TRANSFORM     camt;
  ALLEGRO_BITMAP      * texture, * texture2;
  ALLEGRO_EVENT_QUEUE * queue;
  ALLEGRO_EVENT         event;
  ALLEGRO_FONT        * font;
  int                   busy  = 1;
  float                 cx    = 0;
  float                 cy    = -2; // 128;
  float                 cz    = 0;
  int                   face  = 0; 
  int                   hori  = 0;
  float                 angle = 0;
  float                 theta = 0;  
  float                 near  = 2;
  float                 far   = 8192;
  float                 zoom  = 1;
  float                 scale = 1.0;
  float                 us    = 20; 
  float                 ratio = 480.0 / 640.0;
  al_init();  
  al_init_image_addon();
  al_init_font_addon();
  al_install_keyboard();
  font  = al_create_builtin_font();
  
  queue = al_create_event_queue();  
  al_set_new_display_option(ALLEGRO_DEPTH_SIZE, 16, ALLEGRO_SUGGEST);
  
  display  = al_create_display(640, 480);
  al_register_event_source(queue, al_get_keyboard_event_source());  
  texture  = al_load_bitmap("tile_1.png");
  texture2 = al_load_bitmap("tile_2.png");
  
  /* Allegro coordinates: +Y is down, +X is to the right, 
   * and +Z comes "out of" the screen.
   * 
   */
  
  
  while (busy) {
    init_vertex(v+0,   0,   0,   0,   0,   0, 1, 0, 0, 1);
    init_vertex(v+1,   0,   0,  us,   0, 256, 0, 1, 0, 1);
    init_vertex(v+2,  us,   0,  us, 256, 256, 0, 0, 1, 1);
    init_vertex(v+3,  us,   0,   0, 256,   0, 1, 1, 0, 1);
    init_vertex(v+4,  us, -us,   0, 256, 256, 1, 0, 1, 1);
    init_vertex(v+5,   0, -us,   0, 256,   0, 0, 1, 1, 1); 
    init_vertex(v+6,   0, -us,  us, 256, 256, 0, 0, 0, 1); 
    init_vertex(v+7,   0,   0,  us,   0, 256, 1, 1, 1, 1); 
  
  
    al_identity_transform(&camt);
    al_scale_transform_3d(&camt, scale, scale, scale);
    al_translate_transform_3d(&camt, cx, cy, cz);
  
    angle = face * 0.125 * ALLEGRO_PI;
    al_rotate_transform_3d(&camt, 0, -1, 0, angle); 
    theta = hori * 0.125 * ALLEGRO_PI;
    al_rotate_transform_3d(&camt, -1, 0, 0, theta); 
    
    al_use_transform(&camt);
    // al_set_projection_transform(display, &perst);

  
    al_clear_to_color(al_map_rgb_f(0.75, 0.75, 0.95));
    al_set_render_state(ALLEGRO_DEPTH_TEST, 1);
    al_clear_depth_buffer(far);

    
    
    al_identity_transform(&perst);
    al_perspective_transform(&perst, -1, ratio, near, 
                                      1,  -ratio, far);
    al_use_projection_transform(&perst);

    al_draw_filled_rectangle(0, 0, 4, 5, al_map_rgb_f(0, 0.25, 0.25));
    
        
    al_draw_prim(v, NULL, texture, 0, 8, ALLEGRO_PRIM_TRIANGLE_FAN);
    
    draw_textured_colored_rectangle_3d(0 , -us, 0, us, us, 0, 
                                       1.0, 1.0, texture2, al_map_rgb_f(1,1,1));
    
    draw_textured_colored_rectangle_3d(0 , -us, 0, 0, us, us, 
                                       1.0, 1.0, texture2, al_map_rgb_f(1,1,1));

    draw_textured_colored_rectangle_3d(0 , 0, 0, us, 0, us,
                                       1.0, 1.0, texture2, al_map_rgb_f(1,1,1));
     
    
    al_identity_transform(&perst);
    al_orthographic_transform(&perst, 0, 0, -1.0, 640, 480, 1.0);
 
    al_identity_transform(&camt);
    al_use_projection_transform(&perst);
    al_use_transform(&camt);
    al_draw_filled_rectangle(111, 22, 133, 44, al_map_rgb_f(0.25, 0.25, 0));

    
    al_draw_multiline_textf(font, al_map_rgb_f(1,1,1), 10, 10, 620, 0, 0,
      "Coords: (%f %f %f)\nAngle: (%f %f)\nView: [%f %f %f %f]\nScale: %f", 
               cx, cy, cz,        angle, theta,   near, far, zoom, scale); 
    
    
    
    al_flip_display();  
    al_wait_for_event(queue, &event);
    
    if (event.type == ALLEGRO_EVENT_KEY_DOWN) { 
      switch (event.keyboard.keycode) {
        case ALLEGRO_KEY_RIGHT:
          cx += 8;
          break;

        case ALLEGRO_KEY_LEFT:
          cx -= 8;
          break;
          
        case ALLEGRO_KEY_UP:
          cy += 8;
          break;
          
        case ALLEGRO_KEY_DOWN:
          cy -= 8;
          break;  
        
        case ALLEGRO_KEY_HOME:
          cz += 8;
          break;
          
        case ALLEGRO_KEY_END:
          cz -= 8;
          break;  
          
        case ALLEGRO_KEY_R:
          face++;
          break;
      
        case ALLEGRO_KEY_L:
          face--;
          break;
          
        case ALLEGRO_KEY_H:
          hori++;
          break;
      
        case ALLEGRO_KEY_G:
          hori--;
          break;
  
          
        case ALLEGRO_KEY_N:
          near *= 2.0;
          break;
          
        case ALLEGRO_KEY_M:
          near /= 2.0;
          break;

        case ALLEGRO_KEY_F:
          far += 64;
          break;
          
        case ALLEGRO_KEY_V:
          far -= 64;
          break;
        
        case ALLEGRO_KEY_Z:
          zoom *= 2.0f;
          break;
          
        case ALLEGRO_KEY_S:
          zoom /= 2.0f;
          break;
        
        case ALLEGRO_KEY_A:
          scale *= 2.0f;
          break;
          
        case ALLEGRO_KEY_Q:
          scale /= 2.0f;
          break;
          
        case ALLEGRO_KEY_ESCAPE:
          busy = 0 ;
          break;
  
        default:
          break;
      }
    }
  }
  
  al_destroy_bitmap(texture);
  al_destroy_bitmap(texture2);
  
  
  return 0;  
}
Esempio n. 8
0
File: al3d.c Progetto: bjorndm/ekq
int stamod_new_vertex(struct Stamod * me, float x, float y, float z, 
                      float u, float v, float r, float g, float b, float a) {
    ALLEGRO_VERTEX vert;
    init_vertex(&vert, x, y, z, u, v, r, g, b, a);
    return stamod_add_vertex(me, &vert);
}
Esempio n. 9
0
bool si3::SealData::load(
	LPDIRECT3DDEVICE9 device,			// in
	const TCHAR * path,					// in
	LPDIRECT3DTEXTURE9 * texture,		// out
	IDirect3DVertexBuffer9 ** vertbuff,	// out
	IDirect3DIndexBuffer9 ** indexbuff,	// out
	int * index_num,					// out
	int * triangle_num,					// out
	float piece_size,					// in
	uint & width,						// out
	uint & height)					// out
{

	dxsaferelease(*texture);
	dxsaferelease(*vertbuff);
	dxsaferelease(*indexbuff);

	HRESULT hr;

	// テクスチャのサイズを調べて記憶する
	D3DXIMAGE_INFO info;
	hr = D3DXGetImageInfoFromFile(path, &info);
	if (FAILED(hr)) return false;
	width = info.Width;
	height = info.Height;

	int piece_num_x = static_cast<int>(width / piece_size + 1);	// 板ポリゴンを格子状に分割管理したときの列数
	int piece_num_y = static_cast<int>(height / piece_size + 1);	// 板ポリゴンを格子状に分割管理したときの行数
	int piece_num = piece_num_x * piece_num_y;	// 板ポリゴンを格子状に分割管理したときの断片の個数

	int top_num_x = piece_num_x + 1;			// 板ポリゴンを格子状に分割管理したときの頂点の列数
	int top_num_y = piece_num_y + 1;			// 板ポリゴンを格子状に分割管理したときの頂点の行数
	int top_num = top_num_x*top_num_y;			// 板ポリゴンを格子状に分割管理したときの頂点の個数

	const int top_per_row = 2 * top_num_x;				// 一行につき何個の頂点情報を使用するか
	const int top_of_grid = top_per_row * piece_num_y;	// 格子状の頂点情報の合計
	const int top_for_degen_per_row = 2;				// 一行につき必要な縮退ポリゴン用の頂点情報の数
	const int top_for_degen = top_for_degen_per_row * (piece_num_y - 1);// 縮退ポリゴン用の頂点情報の合計
	*index_num = top_of_grid + top_for_degen;			// 頂点インデックス情報の個数
	*triangle_num = *index_num - 2;						// 三角ポリゴンの合計

	// テクスチャ作成
	hr = D3DXCreateTextureFromFileEx(
		device,
		path,
		D3DX_DEFAULT_NONPOW2,
		D3DX_DEFAULT_NONPOW2,
		0,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		0,
		NULL,
		NULL,
		texture);
	if (FAILED(hr))
	{
		return false;
	}

	bool result;

	// 頂点バッファ作成、頂点データ設定
	result = init_vertex(
		device,
		top_num_x,
		top_num_y,
		top_num,
		static_cast<int>(width),
		static_cast<int>(height),
		piece_num_x,
		piece_num_y,
		vertbuff);
	if (result == false) return false;

	hr = device->CreateVertexBuffer(
		sizeof(DxTop2D)* top_num,
		D3DUSAGE_WRITEONLY,
		LAND_FVF,
		D3DPOOL_MANAGED,
		&converted_vertbuff,
		NULL);
	if (FAILED(hr)) return false;

	DxTop2D * vert_arr = nullptr;
	hr = (**vertbuff).Lock(0, 0, fw::pointer_cast<void **>(&vert_arr), 0);
	if (FAILED(hr)) return false;
	DxTop2D * converted_vert_arr = nullptr;
	hr = converted_vertbuff->Lock(0, 0, fw::pointer_cast<void **>(&converted_vert_arr), 0);
	if (FAILED(hr)) return false;

	memcpy(converted_vert_arr, vert_arr, sizeof(DxTop2D)*get_vertex_num());

	(**vertbuff).Unlock();
	converted_vertbuff->Unlock();

	// 頂点インデックスバッファ作成、頂点インデックスデータ設定
	result = init_index(
		device,
		*index_num,
		indexbuff,
		top_num_x,
		top_num_y,
		top_num,
		piece_num_x,
		piece_num_y);
	if (result == false) return false;

	return true;
}
Esempio n. 10
0
MxVertexID MxBlockModel::add_vertex(double x, double y, double z)
{
    MxVertexID id = alloc_vertex(x,y,z);
    init_vertex(id);
    return id;
}