2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-11-21 19:13:53 +00:00
|
|
|
sw_model_alias.c
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-08-25 14:25:38 +00:00
|
|
|
alias model loading and caching for the software renderer
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
// models are the only shared resource between a client and server running
|
|
|
|
// on the same machine.
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
2001-08-25 02:47:11 +00:00
|
|
|
# include <string.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
2001-08-25 02:47:11 +00:00
|
|
|
# include <strings.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/qendian.h"
|
|
|
|
#include "QF/sys.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-31 18:11:05 +00:00
|
|
|
#include "compat.h"
|
2001-05-10 06:01:11 +00:00
|
|
|
#include "d_iface.h"
|
2012-02-14 12:25:19 +00:00
|
|
|
#include "mod_internal.h"
|
2001-05-10 06:01:11 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// a pose is a single set of vertexes. a frame may be
|
|
|
|
// an animating sequence of poses
|
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void *
|
2012-02-23 03:55:50 +00:00
|
|
|
sw_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
|
|
|
|
qboolean group, maliasskindesc_t *skindesc)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-08-25 14:25:38 +00:00
|
|
|
byte *pskin;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
pskin = Hunk_AllocName (skinsize, loadname);
|
2001-11-21 08:14:05 +00:00
|
|
|
skindesc->skin = (byte *) pskin - (byte *) pheader;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
memcpy (pskin, skin, skinsize);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
return skin + skinsize;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2011-12-25 01:31:35 +00:00
|
|
|
static void
|
|
|
|
process_frame (maliasframedesc_t *frame, int posenum, int extra)
|
|
|
|
{
|
|
|
|
int size = pheader->mdl.numverts * sizeof (trivertx_t);
|
|
|
|
trivertx_t *frame_verts;
|
|
|
|
|
|
|
|
if (extra)
|
|
|
|
size *= 2;
|
|
|
|
|
|
|
|
frame_verts = Hunk_AllocName (size, loadname);
|
|
|
|
frame->frame = (byte *) frame_verts - (byte *) pheader;
|
|
|
|
|
2012-01-05 03:48:15 +00:00
|
|
|
// The low-order 8 bits (actually, fractional) are completely separate
|
|
|
|
// from the high-order bits (see R_AliasTransformFinalVert16 in
|
|
|
|
// sw_ralias.c), but in adjacant arrays. This means we can get away with
|
|
|
|
// just one memcpy as there are non endian issues.
|
2011-12-25 01:31:35 +00:00
|
|
|
memcpy (frame_verts, poseverts[posenum], size);
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
2012-02-23 03:55:50 +00:00
|
|
|
sw_Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
|
|
|
|
int _s, int extra)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-08-25 14:25:38 +00:00
|
|
|
int i, j;
|
2011-12-25 01:31:35 +00:00
|
|
|
int posenum = 0;
|
2002-08-25 14:25:38 +00:00
|
|
|
int numv = hdr->mdl.numverts, numt = hdr->mdl.numtris;
|
|
|
|
stvert_t *pstverts;
|
2001-02-19 21:15:25 +00:00
|
|
|
mtriangle_t *ptri;
|
|
|
|
|
2001-11-21 19:13:53 +00:00
|
|
|
pstverts = (stvert_t *) Hunk_AllocName (numv * sizeof (stvert_t),
|
|
|
|
loadname);
|
|
|
|
ptri = (mtriangle_t *) Hunk_AllocName (numt * sizeof (mtriangle_t),
|
|
|
|
loadname);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
hdr->stverts = (byte *) pstverts - (byte *) hdr;
|
|
|
|
hdr->triangles = (byte *) ptri - (byte *) hdr;
|
|
|
|
|
|
|
|
for (i = 0; i < numv; i++) {
|
|
|
|
pstverts[i].onseam = stverts[i].onseam;
|
|
|
|
pstverts[i].s = stverts[i].s << 16;
|
|
|
|
pstverts[i].t = stverts[i].t << 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < numt; i++) {
|
|
|
|
ptri[i].facesfront = triangles[i].facesfront;
|
2011-12-25 01:31:35 +00:00
|
|
|
VectorCopy (triangles[i].vertindex, ptri[i].vertindex);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < pheader->mdl.numframes; i++) {
|
|
|
|
maliasframedesc_t *frame = pheader->frames + i;
|
|
|
|
if (frame->type) {
|
|
|
|
maliasgroup_t *group;
|
|
|
|
group = (maliasgroup_t *) ((byte *) pheader + frame->frame);
|
|
|
|
for (j = 0; j < group->numframes; j++)
|
|
|
|
process_frame ((maliasframedesc_t *) &group->frames[j],
|
|
|
|
posenum++, extra);
|
|
|
|
} else {
|
|
|
|
process_frame (frame, posenum++, extra);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-20 08:02:35 +00:00
|
|
|
void
|
2012-02-23 03:55:50 +00:00
|
|
|
sw_Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
|
2001-11-20 08:02:35 +00:00
|
|
|
{
|
|
|
|
}
|
2002-01-16 20:32:39 +00:00
|
|
|
|
|
|
|
void
|
2012-02-23 03:55:50 +00:00
|
|
|
sw_Mod_LoadExternalSkins (model_t *mod)
|
2002-01-16 20:32:39 +00:00
|
|
|
{
|
|
|
|
}
|