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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? glm.cpp

?? 詳細介紹c++編程
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
  for (i = 1; i <= model->numvertices; i++) {
    if (maxx < model->vertices[3 * i + 0])
      maxx = model->vertices[3 * i + 0];
    if (minx > model->vertices[3 * i + 0])
      minx = model->vertices[3 * i + 0];

    if (maxy < model->vertices[3 * i + 1])
      maxy = model->vertices[3 * i + 1];
    if (miny > model->vertices[3 * i + 1])
      miny = model->vertices[3 * i + 1];

    if (maxz < model->vertices[3 * i + 2])
      maxz = model->vertices[3 * i + 2];
    if (minz > model->vertices[3 * i + 2])
      minz = model->vertices[3 * i + 2];
  }

  /* calculate model width, height, and depth */
  dimensions[0] = glmAbs(maxx) + glmAbs(minx);
  dimensions[1] = glmAbs(maxy) + glmAbs(miny);
  dimensions[2] = glmAbs(maxz) + glmAbs(minz);
}

/* glmScale: Scales a model by a given amount.
 * 
 * model - properly initialized GLMmodel structure
 * scale - scalefactor (0.5 = half as large, 2.0 = twice as large)
 */
GLvoid glmScale(GLMmodel* model, GLfloat scale)
{
  GLuint i;

  for (i = 1; i <= model->numvertices; i++) {
    model->vertices[3 * i + 0] *= scale;
    model->vertices[3 * i + 1] *= scale;
    model->vertices[3 * i + 2] *= scale;
  }
}

/* glmReverseWinding: Reverse the polygon winding for all polygons in
 * this model.  Default winding is counter-clockwise.  Also changes
 * the direction of the normals.
 * 
 * model - properly initialized GLMmodel structure 
 */
GLvoid glmReverseWinding(GLMmodel* model)
{
  GLuint i, swap;

  assert(model);

  for (i = 0; i < model->numtriangles; i++) {
    swap = T(i).vindices[0];
    T(i).vindices[0] = T(i).vindices[2];
    T(i).vindices[2] = swap;

    if (model->numnormals) {
      swap = T(i).nindices[0];
      T(i).nindices[0] = T(i).nindices[2];
      T(i).nindices[2] = swap;
    }

    if (model->numtexcoords) {
      swap = T(i).tindices[0];
      T(i).tindices[0] = T(i).tindices[2];
      T(i).tindices[2] = swap;
    }
  }

  /* reverse facet normals */
  for (i = 1; i <= model->numfacetnorms; i++) {
    model->facetnorms[3 * i + 0] = -model->facetnorms[3 * i + 0];
    model->facetnorms[3 * i + 1] = -model->facetnorms[3 * i + 1];
    model->facetnorms[3 * i + 2] = -model->facetnorms[3 * i + 2];
  }

  /* reverse vertex normals */
  for (i = 1; i <= model->numnormals; i++) {
    model->normals[3 * i + 0] = -model->normals[3 * i + 0];
    model->normals[3 * i + 1] = -model->normals[3 * i + 1];
    model->normals[3 * i + 2] = -model->normals[3 * i + 2];
  }
}

/* glmFacetNormals: Generates facet normals for a model (by taking the
 * cross product of the two vectors derived from the sides of each
 * triangle).  Assumes a counter-clockwise winding.
 *
 * model - initialized GLMmodel structure
 */
GLvoid glmFacetNormals(GLMmodel* model)
{
  GLuint  i;
  GLfloat u[3];
  GLfloat v[3];
  
  assert(model);
  assert(model->vertices);

  /* clobber any old facetnormals */
  if (model->facetnorms)
    free(model->facetnorms);

  /* allocate memory for the new facet normals */
  model->numfacetnorms = model->numtriangles;
  model->facetnorms = (GLfloat*)malloc(sizeof(GLfloat) *
				       3 * (model->numfacetnorms + 1));

  for (i = 0; i < model->numtriangles; i++) {
    model->triangles[i].findex = i+1;

    u[0] = model->vertices[3 * T(i).vindices[1] + 0] -
           model->vertices[3 * T(i).vindices[0] + 0];
    u[1] = model->vertices[3 * T(i).vindices[1] + 1] -
           model->vertices[3 * T(i).vindices[0] + 1];
    u[2] = model->vertices[3 * T(i).vindices[1] + 2] -
           model->vertices[3 * T(i).vindices[0] + 2];

    v[0] = model->vertices[3 * T(i).vindices[2] + 0] -
           model->vertices[3 * T(i).vindices[0] + 0];
    v[1] = model->vertices[3 * T(i).vindices[2] + 1] -
           model->vertices[3 * T(i).vindices[0] + 1];
    v[2] = model->vertices[3 * T(i).vindices[2] + 2] -
           model->vertices[3 * T(i).vindices[0] + 2];

    glmCross(u, v, &model->facetnorms[3 * (i+1)]);
    glmNormalize(&model->facetnorms[3 * (i+1)]);
  }
}

/* glmVertexNormals: Generates smooth vertex normals for a model.
 * First builds a list of all the triangles each vertex is in.  Then
 * loops through each vertex in the the list averaging all the facet
 * normals of the triangles each vertex is in.  Finally, sets the
 * normal index in the triangle for the vertex to the generated smooth
 * normal.  If the dot product of a facet normal and the facet normal
 * associated with the first triangle in the list of triangles the
 * current vertex is in is greater than the cosine of the angle
 * parameter to the function, that facet normal is not added into the
 * average normal calculation and the corresponding vertex is given
 * the facet normal.  This tends to preserve hard edges.  The angle to
 * use depends on the model, but 90 degrees is usually a good start.
 *
 * model - initialized GLMmodel structure
 * angle - maximum angle (in degrees) to smooth across
 */
GLvoid glmVertexNormals(GLMmodel* model, GLfloat angle)
{
  GLMnode*  node;
  GLMnode*  tail;
  GLMnode** members;
  GLfloat*  normals;
  GLuint    numnormals;
  GLfloat   average[3];
  GLfloat   dot, cos_angle;
  GLuint    i, avg;

  assert(model);
  assert(model->facetnorms);

  /* calculate the cosine of the angle (in degrees) */
  cos_angle = fcos(angle * M_PI / 180.0f);

  /* nuke any previous normals */
  if (model->normals)
    free(model->normals);

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

  /* allocate a structure that will hold a linked list of triangle
     indices for each vertex */
  members = (GLMnode**)malloc(sizeof(GLMnode*) * (model->numvertices + 1));
  for (i = 1; i <= model->numvertices; i++)
    members[i] = NULL;
  
  /* for every triangle, create a node for each vertex in it */
  for (i = 0; i < model->numtriangles; i++) {
    node = (GLMnode*)malloc(sizeof(GLMnode));
    node->index = i;
    node->next  = members[T(i).vindices[0]];
    members[T(i).vindices[0]] = node;

    node = (GLMnode*)malloc(sizeof(GLMnode));
    node->index = i;
    node->next  = members[T(i).vindices[1]];
    members[T(i).vindices[1]] = node;

    node = (GLMnode*)malloc(sizeof(GLMnode));
    node->index = i;
    node->next  = members[T(i).vindices[2]];
    members[T(i).vindices[2]] = node;
  }

  /* calculate the average normal for each vertex */
  numnormals = 1;
  for (i = 1; i <= model->numvertices; i++) {
    /* calculate an average normal for this vertex by averaging the
       facet normal of every triangle this vertex is in */
    node = members[i];
    if (!node)
      fprintf(stderr, "glmVertexNormals(): vertex w/o a triangle\n");
    average[0] = 0.0; average[1] = 0.0; average[2] = 0.0;
    avg = 0;
    while (node) {
      /* only average if the dot product of the angle between the two
         facet normals is greater than the cosine of the threshold
         angle -- or, said another way, the angle between the two
         facet normals is less than (or equal to) the threshold angle */
      dot = glmDot(&model->facetnorms[3 * T(node->index).findex],
 		    &model->facetnorms[3 * T(members[i]->index).findex]);
      if (dot > cos_angle) {
	node->averaged = GL_TRUE;
	average[0] += model->facetnorms[3 * T(node->index).findex + 0];
	average[1] += model->facetnorms[3 * T(node->index).findex + 1];
	average[2] += model->facetnorms[3 * T(node->index).findex + 2];
	avg = 1;			/* we averaged at least one normal! */
      } else {
	node->averaged = GL_FALSE;
      }
      node = node->next;
    }

    if (avg) {
      /* normalize the averaged normal */
      glmNormalize(average);

      /* add the normal to the vertex normals list */
      model->normals[3 * numnormals + 0] = average[0];
      model->normals[3 * numnormals + 1] = average[1];
      model->normals[3 * numnormals + 2] = average[2];
      avg = numnormals;
      numnormals++;
    }

    /* set the normal of this vertex in each triangle it is in */
    node = members[i];
    while (node) {
      if (node->averaged) {
	/* if this node was averaged, use the average normal */
	if (T(node->index).vindices[0] == i)
	  T(node->index).nindices[0] = avg;
	else if (T(node->index).vindices[1] == i)
	  T(node->index).nindices[1] = avg;
	else if (T(node->index).vindices[2] == i)
	  T(node->index).nindices[2] = avg;
      } else {
	/* if this node wasn't averaged, use the facet normal */
	model->normals[3 * numnormals + 0] = 
	  model->facetnorms[3 * T(node->index).findex + 0];
	model->normals[3 * numnormals + 1] = 
	  model->facetnorms[3 * T(node->index).findex + 1];
	model->normals[3 * numnormals + 2] = 
	  model->facetnorms[3 * T(node->index).findex + 2];
	if (T(node->index).vindices[0] == i)
	  T(node->index).nindices[0] = numnormals;
	else if (T(node->index).vindices[1] == i)
	  T(node->index).nindices[1] = numnormals;
	else if (T(node->index).vindices[2] == i)
	  T(node->index).nindices[2] = numnormals;
	numnormals++;
      }
      node = node->next;
    }
  }
  
  model->numnormals = numnormals - 1;

  /* free the member information */
  for (i = 1; i <= model->numvertices; i++) {
    node = members[i];
    while (node) {
      tail = node;
      node = node->next;
      free(tail);
    }
  }
  free(members);

  /* pack the normals array (we previously allocated the maximum
     number of normals that could possibly be created (numtriangles *
     3), so get rid of some of them (usually alot unless none of the
     facet normals were averaged)) */
  normals = model->normals;
  model->normals = (GLfloat*)malloc(sizeof(GLfloat)* 3* (model->numnormals+1));
  for (i = 1; i <= model->numnormals; i++) {
    model->normals[3 * i + 0] = normals[3 * i + 0];
    model->normals[3 * i + 1] = normals[3 * i + 1];
    model->normals[3 * i + 2] = normals[3 * i + 2];
  }
  free(normals);
}


/* glmLinearTexture: Generates texture coordinates according to a
 * linear projection of the texture map.  It generates these by
 * linearly mapping the vertices onto a square.
 *
 * model - pointer to initialized GLMmodel structure
 */
GLvoid glmLinearTexture(GLMmodel* model)
{
  GLMgroup *group;
  GLfloat dimensions[3];
  GLfloat x, y, scalefactor;
  GLuint i;
  
  assert(model);

  if (model->texcoords)
    free(model->texcoords);
  model->numtexcoords = model->numvertices;
  model->texcoords=(GLfloat*)malloc(sizeof(GLfloat)*2*(model->numtexcoords+1));
  
  glmDimensions(model, dimensions);
  scalefactor = 2.0f / 
    glmAbs(glmMax(glmMax(dimensions[0], dimensions[1]), dimensions[2]));

  /* do the calculations */
  for(i = 1; i <= model->numvertices; i++) {
    x = model->vertices[3 * i + 0] * scalefactor;
    y = model->vertices[3 * i + 2] * scalefactor;
    model->texcoords[2 * i + 0] = (x + 1.0f) / 2.0f;
    model->texcoords[2 * i + 1] = (y + 1.0f) / 2.0f;
  }
  
  /* go through and put texture coordinate 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]).vindices[0];
      T(group->triangles[i]).tindices[1] = T(group->triangles[i]).vindices[1];
      T(group->triangles[i]).tindices[2] = T(group->triangles[i]).vindices[2];
    }    
    group = group->next;
  }

#if 0
  printf("glmLinearTexture(): generated %d linear texture coordinates\n",
	  model->numtexcoords);
#endif
}

/* glmSpheremapTexture: Generates texture coordinates according to a
 * spherical projection of the texture map.  Sometimes referred to as
 * spheremap, or reflection map texture coordinates.  It generates
 * these by using the normal to calculate where that vertex would map
 * onto a sphere.  Since it is impossible to map something flat
 * perfectly onto something spherical, there is distortion at the
 * poles.  This particular implementation causes the poles along the X
 * axis to be distorted.
 *
 * model - pointer to initialized GLMmodel structure
 */
GLvoid glmSpheremapTexture(GLMmodel* model)
{
  GLMgroup* group;
  GLfloat theta, phi, rho, x, y, z, r;
  GLuint i;
  
  assert(model);
  assert(model->normals);

  if (model->texcoords)
    free(model->texcoords);
  model->numtexcoords = model->numnormals;
  model->texcoords=(GLfloat*)malloc(sizeof(GLfloat)*2*(model->numtexcoords+1));
     
  for (i = 1; i <= model->numnormals; i++) {
    z = model->normals[3 * i + 0];	/* re-arrange for pole distortion */
    y = model->normals[3 * i + 1];
    x = model->normals[3 * i + 2];
    r = fsqrt((x * x) + (y * y));
    rho = fsqrt((r * r) + (z * z));
      
    if(r == 0.0f) {
	theta = 0.0f;
	phi = 0.0f;
    } else {
      if(z == 0.0f)
	phi = 3.14159265f / 2.0f;
      else
	phi = facos(z / rho);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产喂奶挤奶一区二区三区| 久久亚洲欧美国产精品乐播| 91精品福利在线一区二区三区| 精品精品欲导航| 精品久久久久久无| 亚洲欧美中日韩| 日韩电影一区二区三区四区| 国产精品自拍av| 色女孩综合影院| 久久精品亚洲麻豆av一区二区| 亚洲欧美日韩国产中文在线| 久久不见久久见免费视频1| 99re这里都是精品| 日韩欧美一区电影| 亚洲综合区在线| 成人午夜精品在线| 3atv在线一区二区三区| 欧美激情一区二区三区全黄| 亚洲123区在线观看| 成人免费看的视频| 精品欧美一区二区三区精品久久 | 欧美v日韩v国产v| 亚洲综合一区二区精品导航| 激情综合网激情| 91精品国产入口在线| 亚洲女与黑人做爰| 成人性生交大片免费看中文| 7777精品伊人久久久大香线蕉超级流畅 | 中文成人av在线| 麻豆专区一区二区三区四区五区| 91福利国产成人精品照片| 欧美激情一区二区三区全黄| 蜜臀av亚洲一区中文字幕| 色综合 综合色| 亚洲欧美在线视频| 国产精品12区| 精品国产亚洲一区二区三区在线观看| 亚洲综合激情网| 91香蕉国产在线观看软件| 久久久久国产成人精品亚洲午夜| 亚洲一区二区三区中文字幕在线| 94色蜜桃网一区二区三区| 久久久久国产精品免费免费搜索| 久久99久久精品| 中文字幕第一页久久| 日韩欧美一区二区不卡| 日韩一区二区精品在线观看| 国产夜色精品一区二区av| 老鸭窝一区二区久久精品| 美女视频黄 久久| 欧美日韩国产综合一区二区| 欧美一区二区在线看| 欧美大片免费久久精品三p| 午夜视频一区二区| 69p69国产精品| 免费成人在线影院| 日韩欧美在线不卡| 国产在线精品视频| 久久精品在这里| 成人高清免费观看| 亚洲人成影院在线观看| av在线一区二区三区| 成人国产精品视频| 亚洲色大成网站www久久九九| 91美女在线观看| 亚洲一区二区三区三| 欧美精品一二三区| 六月婷婷色综合| 国产精品久久久久久妇女6080| 福利一区二区在线观看| 一区二区三区四区激情| 欧美日韩国产小视频在线观看| 日本美女一区二区三区视频| 久久久综合网站| 91丝袜高跟美女视频| 亚洲高清免费观看| 在线不卡的av| 国产精品系列在线观看| 中文字幕在线观看一区| 欧美日本不卡视频| 国内欧美视频一区二区| 国产欧美精品在线观看| 99re免费视频精品全部| 一区二区三区在线看| 亚洲精品国产一区二区三区四区在线| 国产在线麻豆精品观看| 国产欧美精品区一区二区三区 | 91麻豆精品国产91久久久| 国产福利91精品| 中文在线免费一区三区高中清不卡| 日本韩国欧美三级| 国产精品一区在线观看你懂的| 亚洲制服丝袜av| 久久久精品免费观看| 成人综合日日夜夜| 日本sm残虐另类| 亚洲免费在线观看| 精品国产免费人成电影在线观看四季| 丁香五精品蜜臀久久久久99网站| 丝袜亚洲精品中文字幕一区| 亚洲欧洲精品一区二区精品久久久 | 免费看欧美女人艹b| 亚洲国产另类av| 亚洲欧美日韩中文字幕一区二区三区| 久久久久国产精品厨房| 2020国产精品| 久久品道一品道久久精品| 欧美成人官网二区| 日韩美女视频在线| 欧美一卡2卡3卡4卡| 欧美色区777第一页| 欧美日韩精品一区二区天天拍小说| 色综合久久88色综合天天6| 成人av网站在线观看免费| 丁香六月久久综合狠狠色| 国产精品亚洲人在线观看| 国产精品18久久久久| 国产综合色产在线精品| 国产美女一区二区三区| 国产一区二区三区四区五区入口| 国产自产视频一区二区三区| 国产一区二区三区蝌蚪| 春色校园综合激情亚洲| 岛国av在线一区| 色综合色狠狠综合色| 欧美吞精做爰啪啪高潮| 欧美人牲a欧美精品| 日韩一区二区三区免费观看| 日韩欧美不卡一区| 亚洲国产成人午夜在线一区| 亚洲欧洲无码一区二区三区| 亚洲精品久久久蜜桃| 日韩国产在线观看一区| 日韩成人av影视| 国内久久精品视频| 成人午夜电影网站| 欧美中文字幕一区二区三区亚洲| 欧美一区二区网站| 久久亚区不卡日本| 中文字幕一区av| 亚洲电影第三页| 国产久卡久卡久卡久卡视频精品| 成人白浆超碰人人人人| 精品视频全国免费看| 2021中文字幕一区亚洲| ...xxx性欧美| 青草国产精品久久久久久| 国产成人av电影在线观看| 91影院在线免费观看| 欧美一级日韩免费不卡| 国产精品入口麻豆原神| 亚洲1区2区3区4区| 岛国精品在线观看| 欧美人xxxx| 国产精品女主播av| 免费在线观看日韩欧美| 不卡在线观看av| 欧美成人r级一区二区三区| 欧美经典三级视频一区二区三区| 亚洲国产毛片aaaaa无费看| 国产美女精品在线| 这里只有精品视频在线观看| 国产精品久久久99| 美女被吸乳得到大胸91| 色婷婷亚洲一区二区三区| 久久只精品国产| 视频在线观看91| 91麻豆免费视频| 国产亚洲一区字幕| 免费在线看一区| 欧美影院一区二区三区| 国产精品亲子乱子伦xxxx裸| 狠狠色综合色综合网络| 精品视频在线看| 一区二区三区蜜桃| 成人av综合一区| 久久亚洲一级片| 免费成人在线观看视频| 欧美性生活一区| 亚洲天堂av老司机| 成人高清视频在线观看| 久久综合色8888| 久久精品国内一区二区三区| 欧美疯狂性受xxxxx喷水图片| 亚洲乱码精品一二三四区日韩在线| 国产成人午夜精品影院观看视频| 精品福利一区二区三区免费视频| 肉色丝袜一区二区| 欧美午夜精品一区二区三区| 亚洲摸摸操操av| 日本韩国一区二区三区| 亚洲欧美欧美一区二区三区| 成人动漫一区二区| 亚洲欧洲一区二区三区| 成人精品鲁一区一区二区| 国产精品网站在线| 波多野结衣中文字幕一区二区三区 | 26uuu久久天堂性欧美| 麻豆91精品视频| 日韩精品中文字幕在线一区|