mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-25 22:01:33 +00:00
Working towards merging q2 model, sprite, and map support. Check back in a few
years, might be finished. ;)
This commit is contained in:
parent
6880b42182
commit
c4402e07bd
12 changed files with 110 additions and 103 deletions
|
@ -67,9 +67,12 @@
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
// little-endian PACK
|
||||||
|
#define IDPAKHEADER (('K'<<24)+('C'<<16)+('A'<<8)+'P')
|
||||||
|
|
||||||
#define BSPVERSION 29
|
#define BSPVERSION 29
|
||||||
#define TOOLVERSION 2
|
#define Q2BSPVERSION 38
|
||||||
|
#define TOOLVERSION 2
|
||||||
|
|
||||||
typedef struct lump_s {
|
typedef struct lump_s {
|
||||||
int fileofs;
|
int fileofs;
|
||||||
|
@ -91,7 +94,6 @@ typedef struct lump_s {
|
||||||
#define LUMP_EDGES 12
|
#define LUMP_EDGES 12
|
||||||
#define LUMP_SURFEDGES 13
|
#define LUMP_SURFEDGES 13
|
||||||
#define LUMP_MODELS 14
|
#define LUMP_MODELS 14
|
||||||
|
|
||||||
#define HEADER_LUMPS 15
|
#define HEADER_LUMPS 15
|
||||||
|
|
||||||
typedef struct dmodel_s {
|
typedef struct dmodel_s {
|
||||||
|
@ -202,7 +204,6 @@ typedef struct dface_s {
|
||||||
} dface_t;
|
} dface_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define AMBIENT_WATER 0
|
#define AMBIENT_WATER 0
|
||||||
#define AMBIENT_SKY 1
|
#define AMBIENT_SKY 1
|
||||||
#define AMBIENT_SLIME 2
|
#define AMBIENT_SLIME 2
|
||||||
|
|
|
@ -121,7 +121,7 @@ typedef struct glpoly_s
|
||||||
struct glpoly_s *chain;
|
struct glpoly_s *chain;
|
||||||
struct glpoly_s *fb_chain;
|
struct glpoly_s *fb_chain;
|
||||||
int numverts;
|
int numverts;
|
||||||
int flags; // for SURF_UNDERWATER
|
int flags; // for SURF_UNDERWATER
|
||||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||||
} glpoly_t;
|
} glpoly_t;
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ typedef struct msurface_s
|
||||||
|
|
||||||
int firstedge; // look up in model->surfedges[], negative numbers
|
int firstedge; // look up in model->surfedges[], negative numbers
|
||||||
int numedges; // are backwards edges
|
int numedges; // are backwards edges
|
||||||
|
|
||||||
struct surfcache_s *cachespots[MIPLEVELS];
|
struct surfcache_s *cachespots[MIPLEVELS];
|
||||||
|
|
||||||
short texturemins[2];
|
short texturemins[2];
|
||||||
|
@ -144,9 +144,10 @@ typedef struct msurface_s
|
||||||
|
|
||||||
glpoly_t *polys; // multiple if warped
|
glpoly_t *polys; // multiple if warped
|
||||||
struct msurface_s *texturechain;
|
struct msurface_s *texturechain;
|
||||||
|
// struct msurface_s *lightmapchain; // Quake 2 ???
|
||||||
|
|
||||||
mtexinfo_t *texinfo;
|
mtexinfo_t *texinfo;
|
||||||
|
|
||||||
// lighting info
|
// lighting info
|
||||||
int dlightframe;
|
int dlightframe;
|
||||||
int dlightbits;
|
int dlightbits;
|
||||||
|
@ -163,14 +164,14 @@ typedef struct mnode_s
|
||||||
// common with leaf
|
// common with leaf
|
||||||
int contents; // 0, to differentiate from leafs
|
int contents; // 0, to differentiate from leafs
|
||||||
int visframe; // node needs to be traversed if current
|
int visframe; // node needs to be traversed if current
|
||||||
|
|
||||||
float minmaxs[6]; // for bounding box culling
|
float minmaxs[6]; // for bounding box culling
|
||||||
|
|
||||||
struct mnode_s *parent;
|
struct mnode_s *parent;
|
||||||
|
|
||||||
// node specific
|
// node specific
|
||||||
mplane_t *plane;
|
mplane_t *plane;
|
||||||
struct mnode_s *children[2];
|
struct mnode_s *children[2];
|
||||||
|
|
||||||
unsigned short firstsurface;
|
unsigned short firstsurface;
|
||||||
unsigned short numsurfaces;
|
unsigned short numsurfaces;
|
||||||
|
@ -418,7 +419,6 @@ typedef struct model_s
|
||||||
|
|
||||||
// additional model data
|
// additional model data
|
||||||
cache_user_t cache; // only access through Mod_Extradata
|
cache_user_t cache; // only access through Mod_Extradata
|
||||||
|
|
||||||
} model_t;
|
} model_t;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -455,7 +455,10 @@ void Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum);
|
||||||
void Mod_LoadBrushModel (model_t *mod, void *buffer);
|
void Mod_LoadBrushModel (model_t *mod, void *buffer);
|
||||||
void Mod_LoadAliasModel (model_t *mod, void *buffer,
|
void Mod_LoadAliasModel (model_t *mod, void *buffer,
|
||||||
cache_allocator_t allocator);
|
cache_allocator_t allocator);
|
||||||
|
void Mod_LoadAlias2Model (model_t *mod, void *buffer,
|
||||||
|
cache_allocator_t allocator);
|
||||||
void Mod_LoadSpriteModel (model_t *mod, void *buffer);
|
void Mod_LoadSpriteModel (model_t *mod, void *buffer);
|
||||||
|
void Mod_LoadSprite2Model (model_t *mod, void *buffer);
|
||||||
void Mod_SubdivideSurface (msurface_t *fa);
|
void Mod_SubdivideSurface (msurface_t *fa);
|
||||||
|
|
||||||
void Mod_Print (void);
|
void Mod_Print (void);
|
||||||
|
|
|
@ -37,7 +37,8 @@
|
||||||
|
|
||||||
#include "QF/mathlib.h"
|
#include "QF/mathlib.h"
|
||||||
|
|
||||||
#define ALIAS_VERSION 6
|
#define ALIAS_VERSION_MDL 6 // .mdl
|
||||||
|
#define ALIAS_VERSION_MD2 8 // .md2
|
||||||
|
|
||||||
#define ALIAS_ONSEAM 0x0020
|
#define ALIAS_ONSEAM 0x0020
|
||||||
|
|
||||||
|
@ -133,10 +134,13 @@ typedef struct {
|
||||||
aliasskintype_t type;
|
aliasskintype_t type;
|
||||||
} daliasskintype_t;
|
} daliasskintype_t;
|
||||||
|
|
||||||
#define IDPOLYHEADER (('O'<<24)+('P'<<16)+('D'<<8)+'I')
|
// little-endian "IDPO"
|
||||||
// little-endian "IDPO"
|
#define IDHEADER_MDL (('O'<<24)+('P'<<16)+('D'<<8)+'I')
|
||||||
|
|
||||||
|
// little-endian "MD16" -- 16 bit vertices
|
||||||
|
#define HEADER_MDL16 (('6'<<24)+('1'<<16)+('D'<<8)+'M')
|
||||||
|
|
||||||
// special header indicating 16 bit vertices - little-endian "MD16"
|
// little-endian "IDP2"
|
||||||
#define POLYHEADER16 (('6'<<24)+('1'<<16)+('D'<<8)+'M')
|
#define IDHEADER_MD2 (('2'<<24)+('P'<<16)+('D'<<8)+'I')
|
||||||
|
|
||||||
#endif // _MODELGEN_H
|
#endif // _MODELGEN_H
|
||||||
|
|
|
@ -65,10 +65,11 @@ typedef enum {false, true} qboolean;
|
||||||
// From mathlib...
|
// From mathlib...
|
||||||
typedef float vec_t;
|
typedef float vec_t;
|
||||||
typedef vec_t vec3_t[3];
|
typedef vec_t vec3_t[3];
|
||||||
|
typedef vec_t vec4_t[4];
|
||||||
typedef vec_t vec5_t[5];
|
typedef vec_t vec5_t[5];
|
||||||
typedef int fixed4_t;
|
typedef int fixed4_t;
|
||||||
typedef int fixed8_t;
|
typedef int fixed8_t;
|
||||||
typedef int fixed16_t;
|
typedef int fixed16_t;
|
||||||
|
|
||||||
#define SIDE_FRONT 0
|
#define SIDE_FRONT 0
|
||||||
#define SIDE_BACK 1
|
#define SIDE_BACK 1
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
#ifndef _SPRITEGN_H
|
#ifndef _SPRITEGN_H
|
||||||
#define _SPRITEGN_H
|
#define _SPRITEGN_H
|
||||||
|
|
||||||
#define SPRITE_VERSION 1
|
#define SPR_VERSION 1
|
||||||
|
#define SP2_VERSION 2
|
||||||
|
|
||||||
// must match definition in modelgen.h
|
// must match definition in modelgen.h
|
||||||
#ifndef SYNCTYPE_T
|
#ifndef SYNCTYPE_T
|
||||||
|
@ -96,6 +97,10 @@ typedef struct {
|
||||||
spriteframetype_t type;
|
spriteframetype_t type;
|
||||||
} dspriteframetype_t;
|
} dspriteframetype_t;
|
||||||
|
|
||||||
#define IDSPRITEHEADER (('P'<<24)+('S'<<16)+('D'<<8)+'I')
|
// little-endian "IDSP"
|
||||||
// little-endian "IDSP"
|
#define IDHEADER_SPR (('P'<<24)+('S'<<16)+('D'<<8)+'I')
|
||||||
|
|
||||||
|
// little-endian "IDS2"
|
||||||
|
#define IDHEADER_SP2 (('2'<<24)+('S'<<16)+('D'<<8)+'I')
|
||||||
|
|
||||||
#endif // _SPRITEGN_H
|
#endif // _SPRITEGN_H
|
||||||
|
|
|
@ -135,19 +135,18 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
|
||||||
void
|
void
|
||||||
Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
||||||
{
|
{
|
||||||
int i, j, size, version, numframes, start, end, total;
|
int size, version, numframes, start, end, total, i, j;
|
||||||
|
int extra = 0; // extra precision bytes
|
||||||
|
void *mem;
|
||||||
dtriangle_t *pintriangles;
|
dtriangle_t *pintriangles;
|
||||||
daliasframetype_t *pframetype;
|
daliasframetype_t *pframetype;
|
||||||
daliasskintype_t *pskintype;
|
daliasskintype_t *pskintype;
|
||||||
mdl_t *pinmodel, *pmodel;
|
mdl_t *pinmodel, *pmodel;
|
||||||
unsigned short crc;
|
unsigned short crc;
|
||||||
stvert_t *pinstverts;
|
stvert_t *pinstverts;
|
||||||
void *mem;
|
|
||||||
|
|
||||||
int extra = 0; // extra precision bytes
|
if (LittleLong (* (unsigned int *) buffer) == HEADER_MDL16)
|
||||||
|
extra = 1; // extra precision bytes
|
||||||
if (LittleLong (*(unsigned int *) buffer) == POLYHEADER16)
|
|
||||||
extra = 1; // extra precision bytes
|
|
||||||
|
|
||||||
CRC_Init (&crc);
|
CRC_Init (&crc);
|
||||||
CRC_ProcessBlock (buffer, &crc, qfs_filesize);
|
CRC_ProcessBlock (buffer, &crc, qfs_filesize);
|
||||||
|
@ -157,9 +156,9 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
||||||
pinmodel = (mdl_t *) buffer;
|
pinmodel = (mdl_t *) buffer;
|
||||||
|
|
||||||
version = LittleLong (pinmodel->version);
|
version = LittleLong (pinmodel->version);
|
||||||
if (version != ALIAS_VERSION)
|
if (version != ALIAS_VERSION_MDL)
|
||||||
Sys_Error ("%s has wrong version number (%i should be %i)",
|
Sys_Error ("%s has wrong version number (%i should be %i)",
|
||||||
mod->name, version, ALIAS_VERSION);
|
mod->name, version, ALIAS_VERSION_MDL);
|
||||||
|
|
||||||
// allocate space for a working header, plus all the data except the
|
// allocate space for a working header, plus all the data except the
|
||||||
// frames, skin and group info
|
// frames, skin and group info
|
||||||
|
@ -182,7 +181,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
||||||
|
|
||||||
if (pmodel->skinheight > MAX_LBM_HEIGHT)
|
if (pmodel->skinheight > MAX_LBM_HEIGHT)
|
||||||
Sys_Error ("model %s has a skin taller than %d", mod->name,
|
Sys_Error ("model %s has a skin taller than %d", mod->name,
|
||||||
MAX_LBM_HEIGHT);
|
MAX_LBM_HEIGHT);
|
||||||
|
|
||||||
pmodel->numverts = LittleLong (pinmodel->numverts);
|
pmodel->numverts = LittleLong (pinmodel->numverts);
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ Mod_ClearAll (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model_t *
|
model_t *
|
||||||
Mod_FindName (const char *name)
|
Mod_FindName (const char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -173,43 +173,43 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
|
||||||
loadmodel = mod;
|
loadmodel = mod;
|
||||||
|
|
||||||
// fill it in
|
// fill it in
|
||||||
if (strequal (mod->name, "progs/grenade.mdl")) {
|
mod->fullbright = 0;
|
||||||
mod->shadow_alpha = 0;
|
mod->shadow_alpha = 255;
|
||||||
} else {
|
mod->min_light = 0.0;
|
||||||
mod->shadow_alpha = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strnequal (mod->name, "progs/flame", 11)
|
|
||||||
|| strnequal (mod->name, "progs/bolt", 10)) {
|
|
||||||
mod->fullbright = 1;
|
|
||||||
mod->shadow_alpha = 0;
|
|
||||||
} else {
|
|
||||||
mod->fullbright = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strequal (mod->name, "progs/player.mdl")) {
|
|
||||||
mod->min_light = 0.04;
|
|
||||||
} else if (strnequal (mod->name, "progs/v_", 8)) {
|
|
||||||
mod->min_light = 0.12;
|
|
||||||
} else {
|
|
||||||
mod->min_light = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// call the apropriate loader
|
// call the apropriate loader
|
||||||
mod->needload = false;
|
mod->needload = false;
|
||||||
mod->hasfullbrights = false;
|
mod->hasfullbrights = false;
|
||||||
|
|
||||||
switch (LittleLong (*(unsigned int *) buf)) {
|
switch (LittleLong (*(unsigned int *) buf)) {
|
||||||
case IDPOLYHEADER:
|
case IDHEADER_MDL: // Type 6: Quake 1 .mdl
|
||||||
case POLYHEADER16:
|
case HEADER_MDL16: // QF Type 6 extended for 16bit precision
|
||||||
|
if (strequal (mod->name, "progs/grenade.mdl")) {
|
||||||
|
mod->fullbright = 0;
|
||||||
|
mod->shadow_alpha = 0;
|
||||||
|
} else if (strnequal (mod->name, "progs/flame", 11)
|
||||||
|
|| strnequal (mod->name, "progs/bolt", 10)) {
|
||||||
|
mod->fullbright = 1;
|
||||||
|
mod->shadow_alpha = 0;
|
||||||
|
}
|
||||||
|
if (strnequal (mod->name, "progs/v_", 8)) {
|
||||||
|
mod->min_light = 0.12;
|
||||||
|
} else if (strequal (mod->name, "progs/player.mdl")) {
|
||||||
|
mod->min_light = 0.04;
|
||||||
|
}
|
||||||
Mod_LoadAliasModel (mod, buf, allocator);
|
Mod_LoadAliasModel (mod, buf, allocator);
|
||||||
break;
|
break;
|
||||||
|
case IDHEADER_MD2: // Type 8: Quake 2 .md2
|
||||||
case IDSPRITEHEADER:
|
// Mod_LoadMD2 (mod, buf, allocator);
|
||||||
|
break;
|
||||||
|
case IDHEADER_SPR: // Type 1: Quake 1 .spr
|
||||||
Mod_LoadSpriteModel (mod, buf);
|
Mod_LoadSpriteModel (mod, buf);
|
||||||
break;
|
break;
|
||||||
|
case IDHEADER_SP2: // Type 2: Quake 2 .sp2
|
||||||
default:
|
// Mod_LoadSP2 (mod, buf);
|
||||||
|
break;
|
||||||
|
default: // Version 29: Quake 1 .bsp
|
||||||
|
// Version 38: Quake 2 .bsp
|
||||||
Mod_LoadBrushModel (mod, buf);
|
Mod_LoadBrushModel (mod, buf);
|
||||||
|
|
||||||
if (gl_textures_external->int_val)
|
if (gl_textures_external->int_val)
|
||||||
|
@ -258,7 +258,7 @@ Mod_CallbackLoad (void *object, cache_allocator_t allocator)
|
||||||
|
|
||||||
Loads in a model for the given name
|
Loads in a model for the given name
|
||||||
*/
|
*/
|
||||||
model_t *
|
model_t *
|
||||||
Mod_ForName (const char *name, qboolean crash)
|
Mod_ForName (const char *name, qboolean crash)
|
||||||
{
|
{
|
||||||
model_t *mod;
|
model_t *mod;
|
||||||
|
|
|
@ -138,9 +138,9 @@ Mod_LoadSpriteModel (model_t *mod, void *buffer)
|
||||||
pin = (dsprite_t *) buffer;
|
pin = (dsprite_t *) buffer;
|
||||||
|
|
||||||
version = LittleLong (pin->version);
|
version = LittleLong (pin->version);
|
||||||
if (version != SPRITE_VERSION)
|
if (version != SPR_VERSION)
|
||||||
Sys_Error ("%s has wrong version number "
|
Sys_Error ("%s has wrong version number "
|
||||||
"(%i should be %i)", mod->name, version, SPRITE_VERSION);
|
"(%i should be %i)", mod->name, version, SPR_VERSION);
|
||||||
|
|
||||||
numframes = LittleLong (pin->numframes);
|
numframes = LittleLong (pin->numframes);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
gl_mod_alias.c
|
gl_mod_alias.c
|
||||||
|
|
||||||
(description)
|
Draw Alias Model
|
||||||
|
|
||||||
Copyright (C) 1996-1997 Id Software, Inc.
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ static inline void
|
||||||
GL_DrawAliasFrameTri (vert_order_t *vo)
|
GL_DrawAliasFrameTri (vert_order_t *vo)
|
||||||
{
|
{
|
||||||
float color[4];
|
float color[4];
|
||||||
int count;
|
int count;
|
||||||
blended_vert_t *verts;
|
blended_vert_t *verts;
|
||||||
tex_coord_t *tex_coord;
|
tex_coord_t *tex_coord;
|
||||||
|
|
||||||
verts = vo->verts;
|
verts = vo->verts;
|
||||||
tex_coord = vo->tex_coord;
|
tex_coord = vo->tex_coord;
|
||||||
|
@ -119,10 +119,11 @@ GL_DrawAliasFrameTri (vert_order_t *vo)
|
||||||
static inline void
|
static inline void
|
||||||
GL_DrawAliasFrameTri_fb (vert_order_t *vo)
|
GL_DrawAliasFrameTri_fb (vert_order_t *vo)
|
||||||
{
|
{
|
||||||
|
float color[4] = { 1.0, 1.0, 1.0, 0.0};
|
||||||
int count;
|
int count;
|
||||||
float color[4] = { 1.0, 1.0, 1.0, 0.0};
|
|
||||||
blended_vert_t *verts;
|
blended_vert_t *verts;
|
||||||
tex_coord_t *tex_coord;
|
tex_coord_t *tex_coord;
|
||||||
|
|
||||||
verts = vo->verts;
|
verts = vo->verts;
|
||||||
color[3] = modelalpha * 1.0;
|
color[3] = modelalpha * 1.0;
|
||||||
count = vo->count;
|
count = vo->count;
|
||||||
|
@ -145,7 +146,7 @@ GL_DrawAliasFrameTriMulti (vert_order_t *vo)
|
||||||
float color[4];
|
float color[4];
|
||||||
int count;
|
int count;
|
||||||
blended_vert_t *verts;
|
blended_vert_t *verts;
|
||||||
tex_coord_t *tex_coord;
|
tex_coord_t *tex_coord;
|
||||||
|
|
||||||
verts = vo->verts;
|
verts = vo->verts;
|
||||||
tex_coord = vo->tex_coord;
|
tex_coord = vo->tex_coord;
|
||||||
|
@ -688,7 +689,7 @@ R_DrawAliasModel (entity_t *e)
|
||||||
fb_texture = skindesc->fb_texnum;
|
fb_texture = skindesc->fb_texnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paliashdr->mdl.ident == POLYHEADER16) {
|
if (paliashdr->mdl.ident == HEADER_MDL16) {
|
||||||
VectorScale (paliashdr->mdl.scale, e->scale / 256.0, scale);
|
VectorScale (paliashdr->mdl.scale, e->scale / 256.0, scale);
|
||||||
vo = GL_GetAliasFrameVerts16 (e->frame, paliashdr, e);
|
vo = GL_GetAliasFrameVerts16 (e->frame, paliashdr, e);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,7 +39,6 @@ static __attribute__ ((unused)) const char rcsid[] =
|
||||||
|
|
||||||
#include "d_ifacea.h"
|
#include "d_ifacea.h"
|
||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
|
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
#define LIGHT_MIN 5 // lowest light value we'll allow, to
|
#define LIGHT_MIN 5 // lowest light value we'll allow, to
|
||||||
|
@ -89,6 +88,7 @@ float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
||||||
#include "anorms.h"
|
#include "anorms.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
qboolean
|
qboolean
|
||||||
R_AliasCheckBBox (void)
|
R_AliasCheckBBox (void)
|
||||||
{
|
{
|
||||||
|
@ -236,7 +236,6 @@ R_AliasCheckBBox (void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
R_AliasTransformVector (vec3_t in, vec3_t out)
|
R_AliasTransformVector (vec3_t in, vec3_t out)
|
||||||
{
|
{
|
||||||
|
@ -245,7 +244,6 @@ R_AliasTransformVector (vec3_t in, vec3_t out)
|
||||||
out[2] = DotProduct (in, aliastransform[2]) + aliastransform[2][3];
|
out[2] = DotProduct (in, aliastransform[2]) + aliastransform[2][3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_AliasClipAndProjectFinalVert (finalvert_t *fv, auxvert_t *av)
|
R_AliasClipAndProjectFinalVert (finalvert_t *fv, auxvert_t *av)
|
||||||
{
|
{
|
||||||
|
@ -267,7 +265,8 @@ R_AliasClipAndProjectFinalVert (finalvert_t *fv, auxvert_t *av)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_AliasTransformFinalVert16 (finalvert_t *fv, auxvert_t *av, trivertx_t *pverts)
|
R_AliasTransformFinalVert16 (finalvert_t *fv, auxvert_t *av,
|
||||||
|
trivertx_t *pverts)
|
||||||
{
|
{
|
||||||
trivertx_t * pextra;
|
trivertx_t * pextra;
|
||||||
float vextra[3];
|
float vextra[3];
|
||||||
|
@ -315,17 +314,16 @@ R_AliasPreparePoints (void)
|
||||||
fv = pfinalverts;
|
fv = pfinalverts;
|
||||||
av = pauxverts;
|
av = pauxverts;
|
||||||
|
|
||||||
if (pmdl->ident == POLYHEADER16) {
|
if (pmdl->ident == HEADER_MDL16) {
|
||||||
for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
|
for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
|
||||||
pstverts++) {
|
pstverts++) {
|
||||||
R_AliasTransformFinalVert16 (fv, av, r_apverts);
|
R_AliasTransformFinalVert16 (fv, av, r_apverts);
|
||||||
R_AliasTransformFinalVert (fv, av, r_apverts, pstverts);
|
R_AliasTransformFinalVert (fv, av, r_apverts, pstverts);
|
||||||
R_AliasClipAndProjectFinalVert (fv, av);
|
R_AliasClipAndProjectFinalVert (fv, av);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
|
for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
|
||||||
pstverts++) {
|
pstverts++) {
|
||||||
R_AliasTransformFinalVert8 (fv, av, r_apverts);
|
R_AliasTransformFinalVert8 (fv, av, r_apverts);
|
||||||
R_AliasTransformFinalVert (fv, av, r_apverts, pstverts);
|
R_AliasTransformFinalVert (fv, av, r_apverts, pstverts);
|
||||||
R_AliasClipAndProjectFinalVert (fv, av);
|
R_AliasClipAndProjectFinalVert (fv, av);
|
||||||
|
@ -356,7 +354,6 @@ R_AliasPreparePoints (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
R_AliasSetUpTransform (int trivial_accept)
|
R_AliasSetUpTransform (int trivial_accept)
|
||||||
{
|
{
|
||||||
|
@ -416,7 +413,7 @@ R_AliasSetUpTransform (int trivial_accept)
|
||||||
// correspondingly so the projected x and y come out right
|
// correspondingly so the projected x and y come out right
|
||||||
// FIXME: make this work for clipped case too?
|
// FIXME: make this work for clipped case too?
|
||||||
|
|
||||||
if (trivial_accept && pmdl->ident != POLYHEADER16) {
|
if (trivial_accept && pmdl->ident != HEADER_MDL16) {
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
aliastransform[0][i] *= aliasxscale *
|
aliastransform[0][i] *= aliasxscale *
|
||||||
(1.0 / ((float) 0x8000 * 0x10000));
|
(1.0 / ((float) 0x8000 * 0x10000));
|
||||||
|
@ -552,15 +549,13 @@ R_AliasPrepareUnclippedPoints (void)
|
||||||
D_PolysetDraw ();
|
D_PolysetDraw ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_AliasSetupSkin (void)
|
R_AliasSetupSkin (void)
|
||||||
{
|
{
|
||||||
int skinnum;
|
int numskins, skinnum, i;
|
||||||
int i, numskins;
|
|
||||||
maliasskingroup_t *paliasskingroup;
|
|
||||||
float *pskinintervals, fullskininterval;
|
|
||||||
float skintargettime, skintime;
|
float skintargettime, skintime;
|
||||||
|
float *pskinintervals, fullskininterval;
|
||||||
|
maliasskingroup_t *paliasskingroup;
|
||||||
|
|
||||||
skinnum = currententity->skinnum;
|
skinnum = currententity->skinnum;
|
||||||
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
|
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
|
||||||
|
@ -642,7 +637,6 @@ R_AliasSetupLighting (alight_t *plighting)
|
||||||
r_plightvec[2] = DotProduct (plighting->plightvec, alias_up);
|
r_plightvec[2] = DotProduct (plighting->plightvec, alias_up);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
R_AliasSetupFrame
|
R_AliasSetupFrame
|
||||||
|
|
||||||
|
@ -651,10 +645,10 @@ R_AliasSetupLighting (alight_t *plighting)
|
||||||
static void
|
static void
|
||||||
R_AliasSetupFrame (void)
|
R_AliasSetupFrame (void)
|
||||||
{
|
{
|
||||||
int frame;
|
int frame, numframes, i;
|
||||||
int i, numframes;
|
float fullinterval, targettime, time;
|
||||||
|
float *pintervals;
|
||||||
maliasgroup_t *paliasgroup;
|
maliasgroup_t *paliasgroup;
|
||||||
float *pintervals, fullinterval, targettime, time;
|
|
||||||
|
|
||||||
frame = currententity->frame;
|
frame = currententity->frame;
|
||||||
if ((frame >= pmdl->numframes) || (frame < 0)) {
|
if ((frame >= pmdl->numframes) || (frame < 0)) {
|
||||||
|
@ -693,7 +687,7 @@ R_AliasSetupFrame (void)
|
||||||
void
|
void
|
||||||
R_AliasDrawModel (alight_t *plighting)
|
R_AliasDrawModel (alight_t *plighting)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
finalvert_t *finalverts;
|
finalvert_t *finalverts;
|
||||||
|
|
||||||
r_amodels_drawn++;
|
r_amodels_drawn++;
|
||||||
|
@ -702,8 +696,8 @@ R_AliasDrawModel (alight_t *plighting)
|
||||||
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
||||||
|
|
||||||
size = (CACHE_SIZE - 1)
|
size = (CACHE_SIZE - 1)
|
||||||
+ sizeof (finalvert_t) * (pmdl->numverts + 1)
|
+ sizeof (finalvert_t) * (pmdl->numverts + 1)
|
||||||
+ sizeof (auxvert_t) * pmdl->numverts;
|
+ sizeof (auxvert_t) * pmdl->numverts;
|
||||||
finalverts = (finalvert_t *) Hunk_TempAlloc (size);
|
finalverts = (finalvert_t *) Hunk_TempAlloc (size);
|
||||||
if (!finalverts)
|
if (!finalverts)
|
||||||
Sys_Error ("R_AliasDrawModel: out of memory");
|
Sys_Error ("R_AliasDrawModel: out of memory");
|
||||||
|
@ -739,7 +733,7 @@ R_AliasDrawModel (alight_t *plighting)
|
||||||
else
|
else
|
||||||
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
||||||
|
|
||||||
if (currententity->trivial_accept && pmdl->ident != POLYHEADER16)
|
if (currententity->trivial_accept && pmdl->ident != HEADER_MDL16)
|
||||||
R_AliasPrepareUnclippedPoints ();
|
R_AliasPrepareUnclippedPoints ();
|
||||||
else
|
else
|
||||||
R_AliasPreparePoints ();
|
R_AliasPreparePoints ();
|
||||||
|
|
|
@ -315,7 +315,7 @@ R_AliasPreparePoints (void)
|
||||||
fv = pfinalverts;
|
fv = pfinalverts;
|
||||||
av = pauxverts;
|
av = pauxverts;
|
||||||
|
|
||||||
if (pmdl->ident == POLYHEADER16) {
|
if (pmdl->ident == HEADER_MDL16) {
|
||||||
for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
|
for (i = 0; i < r_anumverts; i++, fv++, av++, r_apverts++,
|
||||||
pstverts++) {
|
pstverts++) {
|
||||||
R_AliasTransformFinalVert16 (fv, av, r_apverts);
|
R_AliasTransformFinalVert16 (fv, av, r_apverts);
|
||||||
|
@ -727,7 +727,7 @@ R_AliasDrawModel (alight_t *plighting)
|
||||||
else
|
else
|
||||||
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
ziscale = (float) 0x8000 *(float) 0x10000 *3.0;
|
||||||
|
|
||||||
if (currententity->trivial_accept && pmdl->ident != POLYHEADER16)
|
if (currententity->trivial_accept && pmdl->ident != HEADER_MDL16)
|
||||||
R_AliasPrepareUnclippedPoints ();
|
R_AliasPrepareUnclippedPoints ();
|
||||||
else
|
else
|
||||||
R_AliasPreparePoints ();
|
R_AliasPreparePoints ();
|
||||||
|
|
|
@ -138,9 +138,9 @@ static void
|
||||||
WriteFrame (QFile *modelouthandle, int framenum)
|
WriteFrame (QFile *modelouthandle, int framenum)
|
||||||
{
|
{
|
||||||
int j, k;
|
int j, k;
|
||||||
trivert_t *pframe;
|
|
||||||
daliasframe_t aframe;
|
|
||||||
float v;
|
float v;
|
||||||
|
daliasframe_t aframe;
|
||||||
|
trivert_t *pframe;
|
||||||
|
|
||||||
pframe = verts[framenum];
|
pframe = verts[framenum];
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ WriteFrame (QFile *modelouthandle, int framenum)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < model.numverts; j++) {
|
for (j = 0; j < model.numverts; j++) {
|
||||||
// all of these are byte values, so no need to deal with endianness
|
// all of these are byte values, so no need to deal with endianness
|
||||||
tarray[j].lightnormalindex = pframe[j].lightnormalindex;
|
tarray[j].lightnormalindex = pframe[j].lightnormalindex;
|
||||||
|
|
||||||
if (tarray[j].lightnormalindex > NUMVERTEXNORMALS)
|
if (tarray[j].lightnormalindex > NUMVERTEXNORMALS)
|
||||||
|
@ -173,7 +173,6 @@ WriteFrame (QFile *modelouthandle, int framenum)
|
||||||
}
|
}
|
||||||
|
|
||||||
Qwrite (modelouthandle, &aframe, sizeof (aframe));
|
Qwrite (modelouthandle, &aframe, sizeof (aframe));
|
||||||
|
|
||||||
Qwrite (modelouthandle, &tarray[0], model.numverts * sizeof(tarray[0]));
|
Qwrite (modelouthandle, &tarray[0], model.numverts * sizeof(tarray[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +218,7 @@ WriteModelFile (QFile *modelouthandle)
|
||||||
float dist[3];
|
float dist[3];
|
||||||
mdl_t modeltemp;
|
mdl_t modeltemp;
|
||||||
|
|
||||||
// Calculate the bounding box for this model
|
// Calculate the bounding box for this model
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
printf ("framesmins[%d]: %f, framesmaxs[%d]: %f\n",
|
printf ("framesmins[%d]: %f, framesmaxs[%d]: %f\n",
|
||||||
i, framesmins[i], i, framesmaxs[i]);
|
i, framesmins[i], i, framesmaxs[i]);
|
||||||
|
@ -236,9 +235,9 @@ WriteModelFile (QFile *modelouthandle)
|
||||||
dist[1] * dist[1] +
|
dist[1] * dist[1] +
|
||||||
dist[2] * dist[2]);
|
dist[2] * dist[2]);
|
||||||
|
|
||||||
// write out the model header
|
// write out the model header
|
||||||
modeltemp.ident = LittleLong (IDPOLYHEADER);
|
modeltemp.ident = LittleLong (IDHEADER_MDL);
|
||||||
modeltemp.version = LittleLong (ALIAS_VERSION);
|
modeltemp.version = LittleLong (ALIAS_VERSION_MDL);
|
||||||
modeltemp.boundingradius = LittleFloat (model.boundingradius);
|
modeltemp.boundingradius = LittleFloat (model.boundingradius);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
|
|
Loading…
Reference in a new issue