56 #include "../../shared/parse.h"
62 const int st = obj->
num_tris * 3 * 2;
73 int vertind = 0, coordind = 0;
78 for (
int j = 0; j < 3; j++, v++) {
79 assert(v->
vert - 1 >= 0);
83 assert(v->
normal - 1 >= 0);
98 #define MAX_OBJ_FACE_VERTS 128
112 const int v1 = 1 +
i;
113 const int v2 = 2 +
i;
118 t->
verts[0] = verts[v0];
119 t->
verts[1] = verts[v1];
120 t->
verts[2] = verts[v2];
167 while (d[0] !=
'\0') {
222 if (!strncmp(line,
"v ", 2)) {
226 if (sscanf(line + 2,
"%f %f %f", &f[0], &f[2], &f[1]) != 3)
233 }
else if (!strncmp(line,
"vn ", 3)) {
237 if (sscanf(line + 3,
"%f %f %f", &f[0], &f[1], &f[2]) != 3)
244 }
else if (!strncmp(line,
"vt ", 3)) {
248 if (sscanf(line + 3,
"%f %f", &f[0], &f[1]) != 2)
256 }
else if (!strncmp(line,
"f ", 2)) {
280 buffer = (
const char*)buf;
283 if (token[0] ==
'\0')
286 if (
Q_streq(token,
"map_Kd")) {
292 buffer = (
const char*)buf;
296 if (token[0] ==
'\0')
299 if (
Q_streq(token,
"map_Kd")) {
303 Com_sprintf(skinPath,
sizeof(skinPath),
".%s", skin);
325 const byte* c = buffer;
326 bool comment =
false;
330 while (c[0] !=
'\0') {
337 if (c[0] ==
'\r' || c[0] ==
'\n') {
368 Com_Error(
ERR_DROP,
"R_LoadObjModel: Failed to resolve model data: %s (%i %i %i %i)\n",
381 const float*
v = obj.
verts;
bool Q_strnull(const char *string)
#define VectorCopy(src, dest)
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
memPool_t * vid_modelPool
image_t * R_AliasModelGetSkin(const char *modelFileName, const char *skin)
void R_LoadObjModel(model_t *mod, byte *buffer, int bufSize)
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
local graphics definitions
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
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 ac...
char * Com_Trim(char *s)
Removed leading and trailing whitespaces.
void Com_Error(int code, const char *fmt,...)
char name[MODEL_MAX_PATH]
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void add(const vec3_t point)
If the point is outside the box, expand the box to accommodate it.
struct mobjtri_s mobjtri_t
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
#define MAX_OBJ_FACE_VERTS
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 count...
#define Mem_PoolAllocTypeN(type, n, pool)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
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 void R_LoadObjModelVertexArrays(mobj_t *obj, model_t *mod)
static void R_LoadObjSkin(model_t *mod)
struct mobjvert_s mobjvert_t
#define Mem_PoolAllocType(type, pool)
QGL_EXTERN int GLboolean GLfloat * v
QGL_EXTERN GLuint GLsizei bufSize
void FS_FreeFile(void *buffer)