资源简介
opengl读取obj文件时可以使用的库
代码片段和文件信息
/*
* Wavefront .obj file format reader.
*
* author: Nate Robins
* email: ndr@pobox.com
* www: http://www.pobox.com/~ndr
*/
/* includes */
#include “stdafx.h“
#include
#include
#include
#include
#include “glm.h“
/* defines */
#define T(x) model->triangles[(x)]
/* enums */
enum { X Y Z W }; /* elements of a vertex */
/* typedefs */
/* _GLMnode: general purpose node
*/
typedef struct _GLMnode {
GLuint index;
GLboolean averaged;
struct _GLMnode* next;
} GLMnode;
/* private functions */
/* _glmMax: returns the maximum of two floats */
static GLfloat
_glmMax(GLfloat a GLfloat b)
{
if (a > b)
return a;
return b;
}
/* _glmAbs: returns the absolute value of a float */
static GLfloat
_glmAbs(GLfloat f)
{
if (f < 0)
return -f;
return f;
}
/* _glmDot: compute the dot product of two vectors
*
* u - array of 3 GLfloats (GLfloat u[3])
* v - array of 3 GLfloats (GLfloat v[3])
*/
static GLfloat
_glmDot(GLfloat* u GLfloat* v)
{
assert(u);
assert(v);
/* compute the dot product */
return u[X] * v[X] + u[Y] * v[Y] + u[Z] * v[Z];
}
/* _glmCross: compute the cross product of two vectors
*
* u - array of 3 GLfloats (GLfloat u[3])
* v - array of 3 GLfloats (GLfloat v[3])
* n - array of 3 GLfloats (GLfloat n[3]) to return the cross product in
*/
static GLvoid
_glmCross(GLfloat* u GLfloat* v GLfloat* n)
{
assert(u);
assert(v);
assert(n);
/* compute the cross product (u x v for right-handed [ccw]) */
n[X] = u[Y] * v[Z] - u[Z] * v[Y];
n[Y] = u[Z] * v[X] - u[X] * v[Z];
n[Z] = u[X] * v[Y] - u[Y] * v[X];
}
/* _glmNormalize: normalize a vector
*
* n - array of 3 GLfloats (GLfloat n[3]) to be normalized
*/
static GLvoid
_glmNormalize(GLfloat* n)
{
GLfloat l;
assert(n);
/* normalize */
l = (GLfloat)sqrt(n[X] * n[X] + n[Y] * n[Y] + n[Z] * n[Z]);
n[0] /= l;
n[1] /= l;
n[2] /= l;
}
/* _glmEqual: compares two vectors and returns GL_TRUE if they are
* equal (within a certain threshold) or GL_FALSE if not. An epsilon
* that works fairly well is 0.000001.
*
* u - array of 3 GLfloats (GLfloat u[3])
* v - array of 3 GLfloats (GLfloat v[3])
*/
static GLboolean
_glmEqual(GLfloat* u GLfloat* v GLfloat epsilon)
{
if (_glmAbs(u[0] - v[0]) < epsilon &&
_glmAbs(u[1] - v[1]) < epsilon &&
_glmAbs(u[2] - v[2]) < epsilon)
{
return GL_TRUE;
}
return GL_FALSE;
}
/* _glmWeldVectors: eliminate (weld) vectors that are within an
* epsilon of each other.
*
* vectors - array of GLfloat[3]‘s to be welded
* numvectors - number of GLfloat[3]‘s in vectors
* epsilon - maximum difference between vectors
*
*/
GLfloat*
_glmWeldVectors(GLfloat* vectors GLuint* numvectors GLfloat epsilon)
{
GLfloat* copies;
GLuint copied;
GLuint i j;
copies = (GLfloat*)malloc(sizeof(GLfloat) * 3 * (*numvectors + 1));
memcpy(copies vectors (sizeof(GLfloat) * 3 * (*numvectors + 1)));
copied = 1
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8451 1997-07-17 23:27 glm.h
文件 54878 2000-04-23 17:27 glm.cpp
- 上一篇:ttf格式转bdf格式
- 下一篇:二叉树的构造与遍历
相关资源
- OPENGL可一走动的人
-
ob
jectarx wizard 2012配置与helloworld - opengl实现多边形绘制删除和移动 有保
- OpenGL实现3DS文件中的模型自由旋转
- opengl画球,递归细分
- OpenGL教室
- 3DS文件导入OpenGL并动态显示源码
- OpenGL使用Window API绘制矢量字体非常简
- 计算机图形学四面体几何变换.doc
- 交互式计算机图形学-基于OpenGL的自顶
- 《实战OPENGL三维可视化系统开发与源
- Qt加OpenGL实现鼠标控制视角
-
Jsonob
ject.dll - OpenGLSETest.zip
- QTopengl模块使用demo
- QT使用openglES模块做的立方体程序
- OpenGL坦克大战2D游戏文档包含所有模块
- opengl下的贪吃蛇
- 华南理工大学实验——OpenGL Shader导入
- OpenGL透视投影小程序源码
- OpenGL纹理贴图.jpg格式图片小程序源码
-
Keygen Sap R3 License And ob
ject Key Genera - QT5.7+OPENGL画正方体
- OpenGL实现多边形扫描转换的扫描线算
- OpenGL鼠标点选平移物体
- 基于opengl es 的显示gif的
- OpenGL编程指南(第八版)中文高清晰
- OpenGL精美房屋,落雪其上
- OpenGL光照,多种情况下的建立
- 兔子obj模型
评论
共有 条评论