60 float* inmat = (
float*) ((
byte*) pintag + pheader.
ofs_tags);
63 Com_Error(
ERR_FATAL,
"R_ModLoadTags: tagfile %s is broken - expected: %i, offsets tell us to read: %i",
67 Com_Printf(
"R_ModLoadTags: found %i frames in %s but model has %i frames\n",
84 for (
int j = 0; j < pheader.
num_tags; j++, pouttag++) {
87 for (
int i = 0;
i < pheader.
num_frames;
i++, pouttagorient++) {
88 for (
int k = 0; k < 3; k++) {
111 int frameSize, numVerts;
148 for (i = 0; i < outMesh->
num_skins; i++) {
174 for (i = 0; i < outMesh->
num_tris; i++) {
175 for (j = 0; j < 3; j++) {
176 tempIndex[i * 3 + j] = (int32_t)
LittleShort(pintri[i].index_verts[j]);
177 tempSTIndex[i * 3 + j] = (int32_t)
LittleShort(pintri[i].index_st[j]);
190 if (indRemap[i] != -1)
195 if (tempIndex[j] != tempIndex[i])
197 if (pincoord[tempSTIndex[j]].s != pincoord[tempSTIndex[i]].s
198 || pincoord[tempSTIndex[j]].t != pincoord[tempSTIndex[i]].t)
202 outIndex[j] = numVerts;
207 outIndex[
i] = numVerts++;
210 if (numVerts >= 4096)
211 Com_Printf(
"model %s has more than 4096 verts (original verts: %i and tris: %i)\n",
216 Com_Error(
ERR_DROP,
"R_ModLoadAliasMD2Mesh: invalid amount of verts for model '%s' (verts: %i, tris: %i)\n",
220 if (indRemap[i] == i)
223 outIndex[
i] = outIndex[indRemap[
i]];
228 outCoord[outIndex[j]][0] = (float)(((
double)
LittleShort(pincoord[tempSTIndex[indRemap[j]]].s) + 0.5) * isw);
229 outCoord[outIndex[j]][1] = (float)(((
double)
LittleShort(pincoord[tempSTIndex[indRemap[j]]].t) + 0.5) * isw);
238 Com_Error(
ERR_DROP,
"R_ModLoadAliasMD2Mesh: invalid amount of frames for lod model for '%s'\n", mod->
name);
240 for (i = 0; i < mod->
alias.
num_frames; i++, outFrame++, outVertex += numVerts) {
243 for (j = 0; j < 3; j++)
247 for (j = 0; j < 3; j++)
250 VectorCopy(outFrame->translate, outFrame->fBox.mins);
251 VectorMA(outFrame->translate, 255, outFrame->scale, outFrame->fBox.maxs);
257 const int index = tempIndex[indRemap[j]];
259 float* ov = outVertex[outIndex[j]].point;
260 ov[0] = (int16_t)v->
v[0] * outFrame->scale[0];
261 ov[1] = (int16_t)v->
v[1] * outFrame->scale[1];
262 ov[2] = (int16_t)v->
v[2] * outFrame->scale[2];
288 int frameSize, numIndexes, numVerts;
309 Com_Error(
ERR_DROP,
"R_ModLoadAliasMD2Mesh: invalid amount of verts for model '%s' (verts: %i, tris: %i)",
320 for (i = 0; i < outMesh->
num_skins; i++) {
345 for (i = 0; i < outMesh->
num_tris; i++) {
346 for (j = 0; j < 3; j++) {
347 tempIndex[i * 3 + j] = (int32_t)
LittleShort(pintri[i].index_verts[j]);
348 tempSTIndex[i * 3 + j] = (int32_t)
LittleShort(pintri[i].index_st[j]);
362 const int32_t
index = outIndex[j];
363 outCoord[
index][0] = (float)(((
double)
LittleShort(pincoord[tempSTIndex[j]].s) + 0.5) * isw);
364 outCoord[
index][1] = (float)(((
double)
LittleShort(pincoord[tempSTIndex[j]].t) + 0.5) * isw);
373 Com_Error(
ERR_DROP,
"R_ModLoadAliasMD2Mesh: invalid amount of frames for lod model for '%s'\n", mod->
name);
375 for (i = 0; i < mod->
alias.
num_frames; i++, outFrame++, outVertex += numVerts) {
378 for (j = 0; j < 3; j++)
382 for (j = 0; j < 3; j++)
385 VectorCopy(outFrame->translate, outFrame->fBox.mins);
386 VectorMA(outFrame->translate, 255, outFrame->scale, outFrame->fBox.maxs);
392 const int index = tempIndex[j];
394 float* ov = outVertex[outIndex[j]].point;
395 ov[0] = (int16_t)v->
v[0] * outFrame->scale[0];
396 ov[1] = (int16_t)v->
v[1] * outFrame->scale[1];
397 ov[2] = (int16_t)v->
v[2] * outFrame->scale[2];
457 for (i = 1; i <= 3; i++) {
466 Com_sprintf(fileName,
sizeof(fileName),
"%s-lod%02i.md2", base, i);
488 byte* tagbuf =
nullptr;
#define VectorCopy(src, dest)
void setNegativeVolume()
Sets mins and maxs to their starting points before using addPoint.
#define Mem_ReAlloc(ptr, size)
bool R_ModLoadMDX(model_t *mod)
Tries to load a mdx file that contains the normals and the tangents for a model.
#define VectorSet(v, x, y, z)
int FS_CheckFile(const char *fmt,...)
Just returns the filelength and -1 if the file wasn't found.
memPool_t * vid_modelPool
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb)
image_t * R_AliasModelGetSkin(const char *modelFileName, const char *skin)
#define MD2_ALIAS_VERSION
mAliasVertex_t * vertexes
is a variable sized structure, however all frame_t structures within the same file will have the same...
mAliasTagOrientation_t * orient
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.
These two shorts are used to map a vertex onto a skin The horizontal axis position is given by s...
struct mAliasMesh_s mAliasMesh_t
#define Mem_PoolAlloc(size, pool, tagNum)
static void R_ModLoadAliasMD2MeshIndexed(model_t *mod, const dMD2Model_t *md2, int bufSize)
Assume that the indexArray is already filled, and load data for the model accordingly.
Tag file header structure - 32 byte A tag for a model must have the same amount of frames as the mode...
local graphics definitions
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
void Com_Printf(const char *const fmt,...)
static void R_ModLoadAliasMD2Mesh(model_t *mod, const dMD2Model_t *md2, int bufSize, bool loadNormals)
See if the model has an MDX file, and then load the model data appropriately for either case...
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.
char name[MODEL_MAX_PATH]
char name[MODEL_MAX_PATH]
void R_ModCalcUniqueNormalsAndTangents(mAliasMesh_t *mesh, int nFrames, float smoothness)
Calculates normals and tangents for all frames and does vertex merging based on smoothness.
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
void R_ModLoadAliasMD2Model(model_t *mod, byte *buffer, int bufSize, bool loadNormals)
Load MD2 models from file.
static void R_ModLoadAliasMD2MeshUnindexed(model_t *mod, const dMD2Model_t *md2, int bufSize, bool loadNormals)
Assume that the indexArray is NOT filled, and load data for the model accordingly.
#define Mem_PoolAllocTypeN(type, n, pool)
void Com_DefaultExtension(char *path, size_t len, const char *extension)
Sets a default extension if there is none.
the glcmd format: a positive integer starts a tristrip command, followed by that many vertex structur...
static void R_ModLoadTags(model_t *mod, void *buffer, int bufSize)
#define MD2_MAX_TRIANGLES
QGL_EXTERN int GLboolean GLfloat * v
static void R_ModLoadLevelOfDetailData(model_t *mod, bool loadNormals)
Adds new meshes to md2 models for different level of detail meshes.
QGL_EXTERN GLuint GLsizei bufSize
void R_ModLoadArrayData(mAliasModel_t *mod, mAliasMesh_t *mesh, bool loadNormals)
Allocates data arrays for animated models. Only called once at loading time.
void FS_FreeFile(void *buffer)
void R_LoadActorSkinsFromModel(mAliasMesh_t *outMesh, image_t *defaultSkin)
Load actor skins from a default skin to a a mesh.
dMD2TriangleVertex_t verts[1]
bool R_UseActorSkin(void)