UFO: Alien Invasion
r_model_obj.cpp File Reference

obj model loading More...

#include "r_local.h"
#include "../../shared/parse.h"
Include dependency graph for r_model_obj.cpp:

Go to the source code of this file.

Data Structures

struct  mobjvert_t
 
struct  mobjtri_t
 
struct  mobj_t
 

Macros

#define MAX_OBJ_FACE_VERTS   128
 

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

◆ MAX_OBJ_FACE_VERTS

#define MAX_OBJ_FACE_VERTS   128

Definition at line 98 of file r_model_obj.cpp.

Function Documentation

◆ R_LoadObjModel()

◆ R_LoadObjModel_()

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().

◆ R_LoadObjModelFace()

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.

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_t::name, OBJZERO, R_LoadObjModelTris(), mobj_t::tris, and v.

Referenced by R_LoadObjModelLine().

◆ R_LoadObjModelLine()

static void R_LoadObjModelLine ( model_t mod,
mobj_t obj,
char *  line 
)
static

◆ R_LoadObjModelTris()

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_t::num_tris_parsed, mobj_t::tris, and mobjtri_t::verts.

Referenced by R_LoadObjModelFace().

◆ R_LoadObjModelVertexArrays()

◆ R_LoadObjSkin()