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 |
Defines | |
#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. | |
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. | |
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. | |
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. | |
void | R_LoadObjModel (model_t *mod, byte *buffer, int bufSize) |
obj model loading
Definition in file r_model_obj.c.
#define MAX_OBJ_FACE_VERTS 128 |
Definition at line 102 of file r_model_obj.c.
Referenced by R_LoadObjModelFace(), and R_LoadObjModelTris().
typedef struct mobjvert_s mobjvert_t |
Definition at line 324 of file r_model_obj.c.
References AddPointToBounds(), model_s::alias, Com_Error(), ERR_DROP, i, model_s::maxs, Mem_Free, Mem_PoolAlloc, mAliasModel_s::meshes, model_s::mins, mod_obj, model_s::name, mobj_s::normals, mAliasModel_s::num_frames, mAliasModel_s::num_meshes, mobj_s::num_normals, mobj_s::num_texcoords, mobj_s::num_tris, mobj_s::num_verts, R_LoadObjModel_(), R_LoadObjModelVertexArrays(), R_LoadObjSkin(), mobj_s::texcoords, mobj_s::tris, model_s::type, mobj_s::verts, and vid_modelPool.
Referenced by LoadModel(), and R_ModForName().
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 290 of file r_model_obj.c.
References byte, Com_Trim(), i, MAX_STRING_CHARS, qfalse, qtrue, and R_LoadObjModelLine().
Referenced by R_LoadObjModel().
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.
Definition at line 140 of file r_model_obj.c.
References Com_Error(), Com_Parse(), ERR_DROP, i, MAX_OBJ_FACE_VERTS, model_s::name, mobjvert_s::normal, qtrue, R_LoadObjModelTris(), mobjvert_s::texcoord, mobj_s::tris, and mobjvert_s::vert.
Referenced by R_LoadObjModelLine().
Parse the object file line. If the structures have been allocated, populate them. Otherwise simply accumulate counts.
Definition at line 223 of file r_model_obj.c.
References Com_DPrintf(), Com_Error(), DEBUG_RENDERER, ERR_DROP, f, model_s::name, mobj_s::normals, mobj_s::num_normals, mobj_s::num_normals_parsed, mobj_s::num_texcoords, mobj_s::num_texcoords_parsed, mobj_s::num_tris, mobj_s::num_tris_parsed, mobj_s::num_verts, mobj_s::num_verts_parsed, R_LoadObjModelFace(), mobj_s::texcoords, mobj_s::tris, and mobj_s::verts.
Referenced by R_LoadObjModel_().
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 107 of file r_model_obj.c.
References i, MAX_OBJ_FACE_VERTS, mobj_s::num_tris_parsed, mobj_s::tris, and mobjtri_s::verts.
Referenced by R_LoadObjModelFace().
Definition at line 58 of file r_model_obj.c.
References model_s::alias, i, Mem_PoolAlloc, mAliasModel_s::meshes, mobjvert_s::normal, mobj_s::normals, mAliasMesh_s::normals, mAliasMesh_s::num_tris, mobj_s::num_tris, mobj_s::num_verts, mAliasMesh_s::num_verts, st, mobjvert_s::texcoord, mobj_s::texcoords, mAliasMesh_s::texcoords, mobj_s::tris, VectorCopy, mobjvert_s::vert, mobj_s::verts, mobjtri_s::verts, mAliasMesh_s::verts, and vid_modelPool.
Referenced by R_LoadObjModel().
static void R_LoadObjSkin | ( | model_t * | mod | ) | [static] |
Definition at line 273 of file r_model_obj.c.
References model_s::alias, Com_StripExtension(), MAX_QPATH, Mem_PoolAlloc, mAliasModel_s::meshes, image_s::name, mAliasSkin_s::name, model_s::name, mAliasMesh_s::num_skins, Q_strncpyz(), R_AliasModelGetSkin(), mAliasSkin_s::skin, mAliasMesh_s::skins, and vid_modelPool.
Referenced by R_LoadObjModel().