资源简介
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参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
-
AutoCAD ob
jectARX二次开发实例-状态栏 - 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- objc-io中文书籍6本全集2019epud.zip
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
评论
共有 条评论