• 大小: 8.93MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-10
  • 语言: 其他
  • 标签: OpenGl;obj  

资源简介

可以通过OPENGL打开obj格式的文件,运行之后按“o”或者“O”选择相应的obj文件,按小键盘的“+”和“-”放大缩小图像

资源截图

代码片段和文件信息

/*    
 *  GLM library.  Wavefront .obj file format reader/writer/manipulator.
 *
 *  Written by Nate Robins 1997.
 *  email: ndr@pobox.com
 *  www: http://www.pobox.com/~ndr
 */

/* includes */
#include 
using namespace std;

#include 
#include 
#include 
#include 
#include “glm.h“

/* Some  files do not define M_PI... */
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

/* defines */
#define T(x) model->triangles[(x)]

/* enums */
enum { X Y Z W };      /* elements of a vertex */

/* global variables */
/*
GLubyte *_teximage_new;
static int _teximageWidth_new = 1 _teximageHeight_new = 1;
*/

#define MAX_TEXTURES 100
static GLuint textureArray[MAX_TEXTURES] = {0};

/* typedefs */

/* _GLMnode: general purpose node
 */
typedef struct _GLMnode {
  GLuint           index;
  GLboolean        averaged;
  struct _GLMnode* next;
} GLMnode;

/* strdup is actually not a standard ANSI C or POSIX routine
   so implement a private one.  OpenVMS does not have a strdup; Linux‘s
   standard libc doesn‘t declare strdup by default (unless BSD or SVID
   interfaces are requested). */
  static char *
stralloc(const char *string)
{
  char *copy;

  copy = (char*) malloc(strlen(string) + 1);
  if (copy == NULL)
    return NULL;
  strcpy(copy string);
  return copy;
}

/* 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. A

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     160256  2013-08-12 14:26  OpenGLDemo\Debug\glut32.dll

     文件      89088  2016-06-02 18:00  OpenGLDemo\Debug\OpenGLDemo.exe

     文件     464564  2016-06-02 18:00  OpenGLDemo\Debug\OpenGLDemo.ilk

     文件     724992  2016-06-02 18:00  OpenGLDemo\Debug\OpenGLDemo.pdb

     文件    2646136  2006-03-12 08:47  OpenGLDemo\Model\bunny.obj

     文件     200151  2006-03-12 08:47  OpenGLDemo\Model\cow.obj

     文件    3506958  2006-03-12 08:47  OpenGLDemo\Model\dinosaur.obj

     文件     919720  2016-06-02 16:44  OpenGLDemo\Model\Hand2.obj

     文件     109386  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\glm.obj

     文件      31017  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\LoadFileDlg.obj

     文件       1506  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.log

     文件      49419  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.obj

     文件       2598  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.tlog\cl.command.1.tlog

     文件      42446  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.tlog\CL.read.1.tlog

     文件       2220  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.tlog\CL.write.1.tlog

     文件       1486  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.tlog\link.command.1.tlog

     文件       2894  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.tlog\link.read.1.tlog

     文件        856  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.tlog\link.write.1.tlog

     文件        167  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\OpenGLDemo.tlog\OpenGLDemo.lastbuildstate

     文件      28757  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\trackball.obj

     文件     691200  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\vc120.idb

     文件     176128  2016-06-02 18:00  OpenGLDemo\OpenGLDemo\Debug\vc120.pdb

     文件      65180  2013-10-12 17:30  OpenGLDemo\OpenGLDemo\glm.cpp

     文件       8982  2013-10-12 17:29  OpenGLDemo\OpenGLDemo\glm.h

     文件     531058  2013-06-06 22:00  OpenGLDemo\OpenGLDemo\include\OpenGL\glew.h

     文件      27670  2013-06-06 22:00  OpenGLDemo\OpenGLDemo\include\OpenGL\glut.h

     文件      42822  2013-06-06 22:00  OpenGLDemo\OpenGLDemo\include\OpenGL\wglew.h

     文件      28728  2013-06-06 22:00  OpenGLDemo\OpenGLDemo\lib\OpenGL\glut32.lib

     文件       1426  2013-10-12 17:14  OpenGLDemo\OpenGLDemo\LoadFileDlg.cpp

     文件        267  2013-09-24 21:38  OpenGLDemo\OpenGLDemo\LoadFileDlg.h

............此处省略24个文件信息

评论

共有 条评论

相关资源