UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
r_model_obj.cpp File Reference

obj model loading More...

#include "r_local.h"
#include "../../shared/parse.h"

Go to the source code of this file.

Data Structures

struct  mobjvert_s
 
struct  mobjtri_s
 
struct  mobj_s
 

Macros

#define MAX_OBJ_FACE_VERTS   128
 

Typedefs

typedef struct mobjvert_s mobjvert_t
 
typedef struct mobjtri_s mobjtri_t
 
typedef struct mobj_s mobj_t
 

Functions

static void R_LoadObjModelVertexArrays (mobj_t *obj, model_t *mod)
 
static void R_LoadObjModelTris (mobj_t *obj, const mobjvert_t *verts, int count)
 Assembles count tris on the model from the specified array of verts. More...
 
static int R_LoadObjModelFace (const model_t *mod, mobj_t *obj, const char *line)
 Each line consists of 3 or more vertex definitions, e.g. More...
 
static void R_LoadObjModelLine (model_t *mod, mobj_t *obj, char *line)
 Parse the object file line. If the structures have been allocated, populate them. Otherwise simply accumulate counts. More...
 
static void R_LoadObjSkin (model_t *mod)
 
static void R_LoadObjModel_ (model_t *mod, mobj_t *obj, const byte *buffer, int bufSize)
 Drives the actual parsing of the object file. The file is read twice: once to acquire primitive counts, and a second time to load them. More...
 
void R_LoadObjModel (model_t *mod, byte *buffer, int bufSize)
 

Detailed Description

obj model loading

Definition in file r_model_obj.cpp.

Macro Definition Documentation

#define MAX_OBJ_FACE_VERTS   128

Definition at line 98 of file r_model_obj.cpp.

Referenced by R_LoadObjModelFace(), and R_LoadObjModelTris().

Typedef Documentation

typedef struct mobj_s mobj_t
typedef struct mobjtri_s mobjtri_t
typedef struct mobjvert_s mobjvert_t

Function Documentation

static void R_LoadObjModel_ ( model_t mod,
mobj_t obj,
const byte buffer,
int  bufSize 
)
static

Drives the actual parsing of the object file. The file is read twice: once to acquire primitive counts, and a second time to load them.

Definition at line 323 of file r_model_obj.cpp.

References Com_Trim(), i, MAX_STRING_CHARS, and R_LoadObjModelLine().

Referenced by R_LoadObjModel().

static int R_LoadObjModelFace ( const model_t mod,
mobj_t obj,
const char *  line 
)
static

Each line consists of 3 or more vertex definitions, e.g.

1 57/13/31 58/14/32 59/15/33 21/15/19

Tokenize the line with Com_Parse, and parse each vertex definition. Faces with more than 3 vertices must be broken down into triangles.

Returns
the number of triangles produced for the specified line.

Definition at line 134 of file r_model_obj.cpp.

References Com_Error(), Com_Parse(), ERR_DROP, i, MAX_OBJ_FACE_VERTS, model_s::name, mobjvert_s::normal, OBJZERO, R_LoadObjModelTris(), mobjvert_s::texcoord, mobj_s::tris, v, and mobjvert_s::vert.

Referenced by R_LoadObjModelLine().

static void R_LoadObjModelLine ( model_t mod,
mobj_t obj,
char *  line 
)
static
static void R_LoadObjModelTris ( mobj_t obj,
const mobjvert_t verts,
int  count 
)
static

Assembles count tris on the model from the specified array of verts.

Definition at line 103 of file r_model_obj.cpp.

References count, i, MAX_OBJ_FACE_VERTS, mobj_s::num_tris_parsed, mobj_s::tris, and mobjtri_s::verts.

Referenced by R_LoadObjModelFace().