Home > Software engineering >  Opengl import obj file
Opengl import obj file

Time:11-25

3 ds Max is used to derive the obj files triangle curl is the clockwise order, but the opengl USES is the crimp counter-clockwise order, it is how to solve? Only at the time of loading manual change to come over? 3 ds Max have any export option can become a counterclockwise in export?

CodePudding user response:

Refer to the "spacesimulator.net - tutorial6"

CodePudding user response:

 
/*
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- www.spacesimulator.net -- -- -- -- -- -- -- -- -- -- -- -- -- --
* - Space simulators and 3 d engine tutorials -
*
* the Author: Damiano Vitulli & lt; [email protected] & gt;
*
* ALL RIGHTS RESERVED
*
*
* Object functions provides
*
* the File header
*
*/

# # ifndef _OBJECT_H
# define _OBJECT_H

# include "mat_vect. H"
# include "mat_matr. H"

10000//# define MAX_VERTICES Max number of are (for each object)
10000//# define MAX_POLYGONS Max number of polygons (for each object)
100//# define MAX_OBJECTS 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 are
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].//the Name of the object

Int vertices_qty;//Number of are
Int polygons_qty;//Number of polygons

Vertex_type vertex [MAX_VERTICES];//an Array of are
Vertex_type normal [MAX_VERTICES];//an Array of the normals are '
Polygon_type polygon [MAX_POLYGONS];//an Array of polygons (Numbers that point to the are 'list)
Mapcoord_type mapcoord [MAX_VERTICES];//an Array of U, V coordinates for texture mapping

Int id_texture;//the Number of the texture

Matrix_4x4_type matrix;//the Object matrix

} obj_type, * obj_type_ptr;



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

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



/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* FUNCTIONS provides 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 pressure, float p_y, float p_z);
Extern void ObjTranslate (obj_type_ptr p_object, float pressure, float p_y, float p_z);
Extern void ObjTranslateW (obj_type_ptr p_object, float pressure, 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
  • Related