opengl导入obj文件问题

纵横车 2019-09-16 01:49:08
用3dsmax导出的obj文件三角形卷曲顺序是顺时针的,但是opengl用的是逆时针的卷曲顺序,大家是怎么解决的?只能在加载的时候手动换过来吗?3dsmax有没有什么导出选项可以在导出的时候变成逆时针的?
...全文
133 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2019-09-16
  • 打赏
  • 举报
回复

/*
* ---------------- www.spacesimulator.net --------------
* ---- Space simulators and 3d engine tutorials ----
*
* Author: Damiano Vitulli <info@spacesimulator.net>
*
* ALL RIGHTS RESERVED
*
*
* Object functions
*
* File header
*
*/

#ifndef _OBJECT_H
#define _OBJECT_H

#include "mat_vect.h"
#include "mat_matr.h"

#define MAX_VERTICES 10000 // Max number of vertices (for each object)
#define MAX_POLYGONS 10000 // Max number of polygons (for each object)
#define MAX_OBJECTS 100 // Max number of objects



/**********************************************************
*
* TYPES DECLARATION
*
*********************************************************/

// Our vertex type
typedef struct{
float x,y,z;
}vertex_type;

// The polygon (triangle), 3 numbers that aim 3 vertices
typedef struct{
int a,b,c;
}polygon_type;

// The mapcoord type, 2 texture coordinates for each vertex
typedef struct{
float u,v;
}mapcoord_type;

// The object type
typedef struct {

char name[20]; // Name of the object

int vertices_qty; // Number of vertices
int polygons_qty; // Number of polygons

vertex_type vertex[MAX_VERTICES]; // Array of vertices
vertex_type normal[MAX_VERTICES]; // Array of the vertices' normals
polygon_type polygon[MAX_POLYGONS]; // Array of polygons (numbers that point to the vertices' list)
mapcoord_type mapcoord[MAX_VERTICES]; // Array of U,V coordinates for texture mapping

int id_texture; // Number of the texture

matrix_4x4_type matrix; // Object matrix

} obj_type, *obj_type_ptr;



/**********************************************************
*
* VARIABLES DECLARATION
*
*********************************************************/

extern obj_type object[MAX_OBJECTS];
extern int obj_qty;
extern int obj_control;



/**********************************************************
*
* FUNCTIONS DECLARATION
*
*********************************************************/

extern char ObjLoad(char *p_object_name, char *p_texture_name, float p_pos_x, float p_pos_y, float p_pos_z, int p_rot_x, int p_rot_y, int p_rot_z);
extern void ObjCalcNormals(obj_type_ptr p_object);
extern void ObjPosition (obj_type_ptr p_object,float p_x,float p_y,float p_z);
extern void ObjTranslate (obj_type_ptr p_object,float p_x,float p_y,float p_z);
extern void ObjTranslateW (obj_type_ptr p_object,float p_x,float p_y,float p_z);
extern void ObjRotate (obj_type_ptr p_object,int p_angle_x,int p_angle_y,int p_angle_z);

#endif
schlafenhamster 2019-09-16
  • 打赏
  • 举报
回复
参考“spacesimulator.net-tutorial6”

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧