亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? glm.cpp

?? 詳細(xì)介紹c++編程
?? CPP
?? 第 1 頁 / 共 4 頁
字號:

      if(y == 0.0)
	theta = 3.141592365f / 2.0f;
      else
	theta = fasin(y / r) + (3.14159265f / 2.0f);
    }
    
    model->texcoords[2 * i + 0] = theta / 3.14159265f;
    model->texcoords[2 * i + 1] = phi / 3.14159265f;
  }
  
  /* go through and put texcoord indices in all the triangles */
  group = model->groups;
  while(group) {
    for (i = 0; i < group->numtriangles; i++) {
      T(group->triangles[i]).tindices[0] = T(group->triangles[i]).nindices[0];
      T(group->triangles[i]).tindices[1] = T(group->triangles[i]).nindices[1];
      T(group->triangles[i]).tindices[2] = T(group->triangles[i]).nindices[2];
    }
    group = group->next;
  }
}

/* glmDelete: Deletes a GLMmodel structure.
 *
 * model - initialized GLMmodel structure
 */
GLvoid glmDelete(GLMmodel* model)
{
  GLMgroup* group;
  GLuint i;

  assert(model);

  if (model->pathname)   free(model->pathname);
  if (model->mtllibname) free(model->mtllibname);
  if (model->vertices)   free(model->vertices);
  if (model->normals)    free(model->normals);
  if (model->texcoords)  free(model->texcoords);
  if (model->facetnorms) free(model->facetnorms);
  if (model->triangles)  free(model->triangles);
  if (model->materials) {
    for (i = 0; i < model->nummaterials; i++)
      free(model->materials[i].name);
  }
  free(model->materials);
  while(model->groups) {
    group = model->groups;
    model->groups = model->groups->next;
    free(group->name);
    free(group->triangles);
    free(group);
  }

  free(model);
}

/* glmReadOBJ: Reads a model description from a Wavefront .OBJ file.
 * Returns a pointer to the created object which should be free'd with
 * glmDelete().
 *
 * filename - name of the file containing the Wavefront .OBJ format data.  
 */
GLMmodel* glmReadOBJ(char* filename)
{
  GLMmodel* model;
  FILE*     file;

  /* open the file */
  file = fopen(filename, "r");
  if (!file) {
    fprintf(stderr, "glmReadOBJ() failed: can't open data file \"%s\".\n",
	    filename);
    exit(1);
  }

  /* allocate a new model */
  model = (GLMmodel*)malloc(sizeof(GLMmodel));
  model->pathname      = strdup(filename);
  model->mtllibname    = NULL;
  model->numvertices   = 0;
  model->vertices      = NULL;
  model->numnormals    = 0;
  model->normals       = NULL;
  model->numtexcoords  = 0;
  model->texcoords     = NULL;
  model->numfacetnorms = 0;
  model->facetnorms    = NULL;
  model->numtriangles  = 0;
  model->triangles     = NULL;
  model->nummaterials  = 0;
  model->materials     = NULL;
  model->numgroups     = 0;
  model->groups        = NULL;
  model->position[0]   = 0.0;
  model->position[1]   = 0.0;
  model->position[2]   = 0.0;

  /* make a first pass through the file to get a count of the number
     of vertices, normals, texcoords & triangles */
  glmFirstPass(model, file);

  /* allocate memory */
  model->vertices = (GLfloat*)malloc(sizeof(GLfloat) *
				     3 * (model->numvertices + 1));
  model->triangles = (GLMtriangle*)malloc(sizeof(GLMtriangle) *
					  model->numtriangles);
  if (model->numnormals) {
    model->normals = (GLfloat*)malloc(sizeof(GLfloat) *
				      3 * (model->numnormals + 1));
  }
  if (model->numtexcoords) {
    model->texcoords = (GLfloat*)malloc(sizeof(GLfloat) *
					2 * (model->numtexcoords + 1));
  }

  /* rewind to beginning of file and read in the data this pass */
  rewind(file);

  glmSecondPass(model, file);

  /* close the file */
  fclose(file);

  return model;
}

/* glmDraw: Renders the model to the current OpenGL context using the
 * mode specified.
 *
 * model    - initialized GLMmodel structure
 * mode     - a bitwise OR of values describing what is to be rendered.
 *            GLM_NONE     -  render with only vertices
 *            GLM_FLAT     -  render with facet normals
 *            GLM_SMOOTH   -  render with vertex normals
 *            GLM_TEXTURE  -  render with texture coords
 *            GLM_COLOR    -  render with colors (color material)
 *            GLM_MATERIAL -  render with materials
 *            GLM_COLOR and GLM_MATERIAL should not both be specified.  
 *            GLM_FLAT and GLM_SMOOTH should not both be specified.  
 */
GLvoid glmDraw(GLMmodel* model, GLuint mode)
{
  static GLuint i;
  static GLMgroup* group;
  static GLMtriangle* triangle;
  static GLMmaterial* material;

  assert(model);
  assert(model->vertices);

  /* do a bit of warning */
  if (mode & GLM_FLAT && !model->facetnorms) {
    mode &= ~GLM_FLAT;
  }
  if (mode & GLM_SMOOTH && !model->normals) {
    mode &= ~GLM_SMOOTH;
  }
  if (mode & GLM_TEXTURE && !model->texcoords) {
    mode &= ~GLM_TEXTURE;
  }
  if (mode & GLM_FLAT && mode & GLM_SMOOTH) {
    mode &= ~GLM_FLAT;
  }
  if (mode & GLM_COLOR && !model->materials) {
    mode &= ~GLM_COLOR;
  }
  if (mode & GLM_MATERIAL && !model->materials) {
    mode &= ~GLM_MATERIAL;
  }
  if (mode & GLM_COLOR && mode & GLM_MATERIAL) {
    mode &= ~GLM_COLOR;
  }
  if (mode & GLM_COLOR)
    glEnable(GL_COLOR_MATERIAL);
  else if (mode & GLM_MATERIAL)
    glDisable(GL_COLOR_MATERIAL);

  /* perhaps this loop should be unrolled into material, color, flat,
     smooth, etc. loops?  since most cpu's have good branch prediction
     schemes (and these branches will always go one way), probably
     wouldn't gain too much?  */

  group = model->groups;
  while (group) {
    if (mode & GLM_MATERIAL) {
      material = &model->materials[group->material];
      glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, material->ambient);
      glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material->diffuse);
      glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material->specular);
      glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material->shininess);
    }

    if (mode & GLM_COLOR) {
      material = &model->materials[group->material];
      glColor3fv(material->diffuse);
    }

    glBegin(GL_TRIANGLES);
    for (i = 0; i < group->numtriangles; i++) {
      triangle = &T(group->triangles[i]);

      if (mode & GLM_FLAT)
	glNormal3fv(&model->facetnorms[3 * triangle->findex]);
      
      if (mode & GLM_SMOOTH)
	glNormal3fv(&model->normals[3 * triangle->nindices[0]]);
      if (mode & GLM_TEXTURE)
	glTexCoord2fv(&model->texcoords[2 * triangle->tindices[0]]);
      glVertex3fv(&model->vertices[3 * triangle->vindices[0]]);
      
      if (mode & GLM_SMOOTH)
	glNormal3fv(&model->normals[3 * triangle->nindices[1]]);
      if (mode & GLM_TEXTURE)
	glTexCoord2fv(&model->texcoords[2 * triangle->tindices[1]]);
      glVertex3fv(&model->vertices[3 * triangle->vindices[1]]);
      
      if (mode & GLM_SMOOTH)
	glNormal3fv(&model->normals[3 * triangle->nindices[2]]);
      if (mode & GLM_TEXTURE)
	glTexCoord2fv(&model->texcoords[2 * triangle->tindices[2]]);
      glVertex3fv(&model->vertices[3 * triangle->vindices[2]]);
      
    }
    glEnd();

    group = group->next;
  }
}

/* glmList: Generates and returns a display list for the model using
 * the mode specified.
 *
 * model    - initialized GLMmodel structure
 * mode     - a bitwise OR of values describing what is to be rendered.
 *            GLM_NONE     -  render with only vertices
 *            GLM_FLAT     -  render with facet normals
 *            GLM_SMOOTH   -  render with vertex normals
 *            GLM_TEXTURE  -  render with texture coords
 *            GLM_COLOR    -  render with colors (color material)
 *            GLM_MATERIAL -  render with materials
 *            GLM_COLOR and GLM_MATERIAL should not both be specified.  
 * GLM_FLAT and GLM_SMOOTH should not both be specified.  */
GLuint glmList(GLMmodel* model, GLuint mode)
{
  GLuint list;

  list = glGenLists(1);
  glNewList(list, GL_COMPILE);
  glmDraw(model, mode);
  glEndList();

  return list;
}

/* glmWeld: eliminate (weld) vectors that are within an epsilon of
 * each other.
 *
 * model      - initialized GLMmodel structure
 * epsilon    - maximum difference between vertices
 *              ( 0.00001 is a good start for a unitized model)
 *
 */
GLuint glmWeld(GLMmodel* model, GLfloat epsilon)
{
  GLfloat* vectors;
  GLfloat* copies;
  GLuint   numvectors;
  GLuint   i, welded;

  /* vertices */
  numvectors = model->numvertices;
  vectors    = model->vertices;
  copies = glmWeldVectors(vectors, &numvectors, epsilon);
  welded = model->numvertices - numvectors - 1;

  for (i = 0; i < model->numtriangles; i++) {
    T(i).vindices[0] = (GLuint)vectors[3 * T(i).vindices[0] + 0];
    T(i).vindices[1] = (GLuint)vectors[3 * T(i).vindices[1] + 0];
    T(i).vindices[2] = (GLuint)vectors[3 * T(i).vindices[2] + 0];
  }

  /* free space for old vertices */
  free(vectors);

  /* allocate space for the new vertices */
  model->numvertices = numvectors;
  model->vertices = (GLfloat*)malloc(sizeof(GLfloat) * 
				     3 * (model->numvertices + 1));

  /* copy the optimized vertices into the actual vertex list */
  for (i = 1; i <= model->numvertices; i++) {
    model->vertices[3 * i + 0] = copies[3 * i + 0];
    model->vertices[3 * i + 1] = copies[3 * i + 1];
    model->vertices[3 * i + 2] = copies[3 * i + 2];
  }

  free(copies);

  return welded;
}

#if 0
  /* normals */
  if (model->numnormals) {
  numvectors = model->numnormals;
  vectors    = model->normals;
  copies = glmOptimizeVectors(vectors, &numvectors);

  printf("glmOptimize(): %d redundant normals.\n", 
	 model->numnormals - numvectors);

  for (i = 0; i < model->numtriangles; i++) {
    T(i).nindices[0] = (GLuint)vectors[3 * T(i).nindices[0] + 0];
    T(i).nindices[1] = (GLuint)vectors[3 * T(i).nindices[1] + 0];
    T(i).nindices[2] = (GLuint)vectors[3 * T(i).nindices[2] + 0];
  }

  /* free space for old normals */
  free(vectors);

  /* allocate space for the new normals */
  model->numnormals = numvectors;
  model->normals = (GLfloat*)malloc(sizeof(GLfloat) * 
				    3 * (model->numnormals + 1));

  /* copy the optimized vertices into the actual vertex list */
  for (i = 1; i <= model->numnormals; i++) {
    model->normals[3 * i + 0] = copies[3 * i + 0];
    model->normals[3 * i + 1] = copies[3 * i + 1];
    model->normals[3 * i + 2] = copies[3 * i + 2];
  }

  free(copies);
  }

  /* texcoords */
  if (model->numtexcoords) {
  numvectors = model->numtexcoords;
  vectors    = model->texcoords;
  copies = glmOptimizeVectors(vectors, &numvectors);

  printf("glmOptimize(): %d redundant texcoords.\n", 
	 model->numtexcoords - numvectors);

  for (i = 0; i < model->numtriangles; i++) {
    for (j = 0; j < 3; j++) {
      T(i).tindices[j] = (GLuint)vectors[3 * T(i).tindices[j] + 0];
    }
  }

  /* free space for old texcoords */
  free(vectors);

  /* allocate space for the new texcoords */
  model->numtexcoords = numvectors;
  model->texcoords = (GLfloat*)malloc(sizeof(GLfloat) * 
				      2 * (model->numtexcoords + 1));

  /* copy the optimized vertices into the actual vertex list */
  for (i = 1; i <= model->numtexcoords; i++) {
    model->texcoords[2 * i + 0] = copies[2 * i + 0];
    model->texcoords[2 * i + 1] = copies[2 * i + 1];
  }

  free(copies);
  }
#endif

#if 0
  /* look for unused vertices */
  /* look for unused normals */
  /* look for unused texcoords */
  for (i = 1; i <= model->numvertices; i++) {
    for (j = 0; j < model->numtriangles; i++) {
      if (T(j).vindices[0] == i || 
	  T(j).vindices[1] == i || 
	  T(j).vindices[1] == i)
	break;
    }
  }
#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国精品自拍自在线| 久久精品久久99精品久久| 国产精品一区二区三区四区| 日本电影欧美片| 最新国产精品久久精品| 蜜桃av一区二区在线观看 | 天堂成人免费av电影一区| 91一区二区三区在线观看| 中文字幕精品一区二区三区精品| 韩国一区二区视频| 国产无人区一区二区三区| 久久国产精品一区二区| 精品国产3级a| 国产a视频精品免费观看| 久久精品水蜜桃av综合天堂| 久久不见久久见中文字幕免费| 欧美亚洲综合久久| 日韩激情中文字幕| 久久久久久免费毛片精品| 色婷婷激情一区二区三区| 亚洲精品精品亚洲| 91麻豆精品国产91久久久资源速度 | 欧美精品自拍偷拍| 无码av免费一区二区三区试看| 国产日韩欧美亚洲| 欧洲一区二区三区在线| 日韩av中文在线观看| 久久综合九色综合欧美98| 成人夜色视频网站在线观看| 亚洲精选在线视频| 精品区一区二区| 色婷婷av一区二区三区软件| 免费看精品久久片| 中文字幕一区二区视频| 日韩欧美区一区二| 欧洲激情一区二区| 国产成人在线视频网址| ...av二区三区久久精品| 日韩亚洲欧美成人一区| av不卡一区二区三区| 国产中文字幕精品| 亚洲成人三级小说| 亚洲最新视频在线观看| 久久久久国产精品麻豆ai换脸 | 67194成人在线观看| 99精品久久免费看蜜臀剧情介绍| 激情六月婷婷久久| 青青草成人在线观看| 亚洲精品中文字幕乱码三区| 国产亚洲成av人在线观看导航| 91精品国产乱码久久蜜臀| 精品视频资源站| 欧美性猛交一区二区三区精品| 成年人午夜久久久| 久久国产福利国产秒拍| 毛片一区二区三区| 激情综合色播五月| 国产精品自拍毛片| 懂色av中文一区二区三区| 国产91精品精华液一区二区三区 | 中文无字幕一区二区三区| 欧美电影精品一区二区| 91麻豆精品国产自产在线| 91精品国产免费| 欧美国产日韩一二三区| 久久久精品国产免大香伊| 国产精品久久久99| 一区2区3区在线看| 日韩电影在线免费| 丁香婷婷综合激情五月色| 91麻豆国产自产在线观看| 欧美视频自拍偷拍| 欧美国产日产图区| 国产精品久久久一区麻豆最新章节| 亚洲日本韩国一区| 日本大胆欧美人术艺术动态| 国产69精品一区二区亚洲孕妇| voyeur盗摄精品| 国产偷v国产偷v亚洲高清| 国产精品丝袜久久久久久app| 亚洲色图在线视频| 国产高清久久久| 欧美日韩国产a| 亚洲男人都懂的| 国产中文字幕一区| 欧美成人一区二区三区在线观看| 国产精品久久久久婷婷| 亚洲免费色视频| 成人18精品视频| 久久新电视剧免费观看| 日本欧美加勒比视频| 欧美自拍偷拍一区| 1000精品久久久久久久久| 热久久免费视频| 在线播放中文字幕一区| 亚洲图片一区二区| 在线视频国内一区二区| 亚洲免费在线看| 91看片淫黄大片一级| 国产精品久久99| 99麻豆久久久国产精品免费优播| 欧美精品一区二区三区高清aⅴ| 中文字幕国产一区| 成人午夜激情在线| 亚洲婷婷在线视频| 91浏览器入口在线观看| 亚洲综合清纯丝袜自拍| 欧美日韩一区二区在线视频| 亚洲高清久久久| 日韩精品一区二区三区视频播放 | 国产乱码精品一品二品| 日韩欧美的一区二区| 国产一区二区三区在线看麻豆| 欧美精品一区二| 成人一区二区三区视频| 亚洲色图视频网| 欧美性色aⅴ视频一区日韩精品| 亚洲亚洲人成综合网络| 6080日韩午夜伦伦午夜伦| 精品一区二区三区视频在线观看| 国产日韩欧美不卡在线| 成人av资源网站| 爽好多水快深点欧美视频| 欧美精品一区二区三区很污很色的| 国产成人aaaa| 午夜伦欧美伦电影理论片| wwwwww.欧美系列| 欧美性生活久久| 粉嫩aⅴ一区二区三区四区五区 | 欧美激情一区二区三区不卡| 不卡的av电影| 青娱乐精品视频在线| 日韩美女啊v在线免费观看| 91麻豆精品国产91久久久资源速度 | 亚洲老妇xxxxxx| 欧美不卡视频一区| 欧美精品在线一区二区三区| 国产精品66部| 亚洲va欧美va人人爽| 亚洲视频香蕉人妖| 国产亚洲一区二区在线观看| 91精品国产91热久久久做人人 | 日本电影欧美片| 99视频国产精品| 懂色av一区二区夜夜嗨| 国产成人精品免费一区二区| 久久国产乱子精品免费女| 蜜臀av一区二区| 免费美女久久99| 国产在线播精品第三| 国内精品嫩模私拍在线| 精品无人码麻豆乱码1区2区 | 日韩国产欧美视频| 亚洲午夜一二三区视频| 亚洲一区二区3| 石原莉奈一区二区三区在线观看 | 国产精品成人一区二区三区夜夜夜| 久久综合999| 国产精品高潮久久久久无| 中文字幕日韩一区| 亚洲二区视频在线| 蜜桃视频在线观看一区| 国内精品免费在线观看| 成人黄色av网站在线| 欧美少妇性性性| 日韩女优电影在线观看| 日韩丝袜美女视频| 亚洲欧美韩国综合色| 亚洲综合免费观看高清完整版在线 | 成人午夜免费视频| 欧美日韩精品综合在线| 久久久美女毛片| 亚洲高清免费在线| 不卡影院免费观看| 日韩视频永久免费| 国产精品久久久久永久免费观看| 亚洲综合av网| 国产精品综合av一区二区国产馆| 成人动漫视频在线| 日韩午夜在线影院| 一区二区视频在线| 国产精品99久久久| 欧美一区二区三区在线观看视频| 国产日韩欧美麻豆| 久久成人精品无人区| 欧美日韩国产一级| 夜夜嗨av一区二区三区网页| 国产精品77777竹菊影视小说| 91精品欧美久久久久久动漫| 一区二区三区四区在线| 国产白丝精品91爽爽久久| 日韩精品综合一本久道在线视频| 亚洲综合激情网| 在线亚洲欧美专区二区| 亚洲精品成人a在线观看| 国产经典欧美精品| 精品国产一区二区三区四区四| 日韩一区精品字幕| 欧美久久久久久蜜桃| 视频在线在亚洲|