use of jake2.util.Vargs in project narchy by automenta.
the class Model method Mod_LoadAliasModel.
/*
==============================================================================
ALIAS MODELS
==============================================================================
*/
/*
=================
Mod_LoadAliasModel
=================
*/
void Mod_LoadAliasModel(model_t mod, ByteBuffer buffer) {
int i;
qfiles.dmdl_t pheader;
qfiles.dstvert_t[] poutst;
qfiles.dtriangle_t[] pouttri;
qfiles.daliasframe_t[] poutframe;
int[] poutcmd;
pheader = new qfiles.dmdl_t(buffer);
if (pheader.version != qfiles.ALIAS_VERSION)
Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", new Vargs(3).add(mod.name).add(pheader.version).add(qfiles.ALIAS_VERSION));
if (pheader.skinheight > MAX_LBM_HEIGHT)
Com.Error(Defines.ERR_DROP, "model " + mod.name + " has a skin taller than " + MAX_LBM_HEIGHT);
if (pheader.num_xyz <= 0)
Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no vertices");
if (pheader.num_xyz > qfiles.MAX_VERTS)
Com.Error(Defines.ERR_DROP, "model " + mod.name + " has too many vertices");
if (pheader.num_st <= 0)
Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no st vertices");
if (pheader.num_tris <= 0)
Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no triangles");
if (pheader.num_frames <= 0)
Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no frames");
//
// load base s and t vertices (not used in gl version)
//
poutst = new qfiles.dstvert_t[pheader.num_st];
buffer.position(pheader.ofs_st);
for (i = 0; i < pheader.num_st; i++) {
poutst[i] = new qfiles.dstvert_t(buffer);
}
//
// load triangle lists
//
pouttri = new qfiles.dtriangle_t[pheader.num_tris];
buffer.position(pheader.ofs_tris);
for (i = 0; i < pheader.num_tris; i++) {
pouttri[i] = new qfiles.dtriangle_t(buffer);
}
//
// load the frames
//
poutframe = new qfiles.daliasframe_t[pheader.num_frames];
buffer.position(pheader.ofs_frames);
for (i = 0; i < pheader.num_frames; i++) {
poutframe[i] = new qfiles.daliasframe_t(buffer);
// verts are all 8 bit, so no swapping needed
poutframe[i].verts = new int[pheader.num_xyz];
for (int k = 0; k < pheader.num_xyz; k++) {
poutframe[i].verts[k] = buffer.getInt();
}
}
mod.type = mod_alias;
//
// load the glcmds
//
poutcmd = new int[pheader.num_glcmds];
buffer.position(pheader.ofs_glcmds);
for (i = 0; i < pheader.num_glcmds; i++) // LittleLong (pincmd[i]);
poutcmd[i] = buffer.getInt();
// register all skins
String[] skinNames = new String[pheader.num_skins];
byte[] nameBuf = new byte[qfiles.MAX_SKINNAME];
buffer.position(pheader.ofs_skins);
for (i = 0; i < pheader.num_skins; i++) {
buffer.get(nameBuf);
skinNames[i] = new String(nameBuf).trim();
mod.skins[i] = GL_FindImage(skinNames[i], it_skin);
}
// set the model arrays
// skin names
pheader.skinNames = skinNames;
// textur koordinaten
pheader.stVerts = poutst;
// dreiecke
pheader.triAngles = pouttri;
// STRIP or FAN
pheader.glCmds = poutcmd;
// frames mit vertex array
pheader.aliasFrames = poutframe;
mod.extradata = pheader;
mod.mins[0] = -32;
mod.mins[1] = -32;
mod.mins[2] = -32;
mod.maxs[0] = 32;
mod.maxs[1] = 32;
mod.maxs[2] = 32;
}
use of jake2.util.Vargs in project narchy by automenta.
the class CM method CMod_LoadBrushSides.
/**
* Loads brush sides.
*/
public static void CMod_LoadBrushSides(lump_t l) {
Com.DPrintf("CMod_LoadBrushSides()\n");
int i, j;
cbrushside_t out;
qfiles.dbrushside_t in;
int count;
int num;
if ((l.filelen % qfiles.dbrushside_t.SIZE) != 0)
Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size");
count = l.filelen / qfiles.dbrushside_t.SIZE;
// need to save space for box planes
if (count > Defines.MAX_MAP_BRUSHSIDES)
Com.Error(Defines.ERR_DROP, "Map has too many planes");
numbrushsides = count;
Com.DPrintf(" numbrushsides=" + count + '\n');
if (debugloadmap) {
Com.DPrintf("brushside(planenum, surfacenum):\n");
}
for (i = 0; i < count; i++) {
in = new qfiles.dbrushside_t(ByteBuffer.wrap(cmod_base, i * qfiles.dbrushside_t.SIZE + l.fileofs, qfiles.dbrushside_t.SIZE));
out = map_brushsides[i];
num = in.planenum;
// pointer
out.plane = map_planes[num];
j = in.texinfo;
if (j >= numtexinfo)
Com.Error(Defines.ERR_DROP, "Bad brushside texinfo");
// java specific handling of -1
if (j == -1)
// just for safety
out.surface = new mapsurface_t();
else
out.surface = map_surfaces[j];
if (debugloadmap) {
Com.DPrintf("| %6i| %6i|\n", new Vargs().add(num).add(j));
}
}
}
use of jake2.util.Vargs in project narchy by automenta.
the class CM method CMod_LoadSurfaces.
/**
* Loads surfaces.
*/
public static void CMod_LoadSurfaces(lump_t l) {
Com.DPrintf("CMod_LoadSurfaces()\n");
texinfo_t in;
mapsurface_t out;
int i, count;
if ((l.filelen % texinfo_t.SIZE) != 0)
Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size");
count = l.filelen / texinfo_t.SIZE;
if (count < 1)
Com.Error(Defines.ERR_DROP, "Map with no surfaces");
if (count > Defines.MAX_MAP_TEXINFO)
Com.Error(Defines.ERR_DROP, "Map has too many surfaces");
numtexinfo = count;
Com.DPrintf(" numtexinfo=" + count + '\n');
if (debugloadmap)
Com.DPrintf("surfaces:\n");
for (i = 0; i < count; i++) {
out = map_surfaces[i] = new mapsurface_t();
in = new texinfo_t(cmod_base, l.fileofs + i * texinfo_t.SIZE, texinfo_t.SIZE);
out.c.name = in.texture;
out.rname = in.texture;
out.c.flags = in.flags;
out.c.value = in.value;
if (debugloadmap) {
Com.DPrintf("|%20s|%20s|%6i|%6i|\n", new Vargs().add(out.c.name).add(out.rname).add(out.c.value).add(out.c.flags));
}
}
}
use of jake2.util.Vargs in project narchy by automenta.
the class CM method CMod_LoadAreas.
/**
* Loads areas.
*/
public static void CMod_LoadAreas(lump_t l) {
Com.DPrintf("CMod_LoadAreas()\n");
int i;
carea_t out;
qfiles.darea_t in;
int count;
if ((l.filelen % qfiles.darea_t.SIZE) != 0)
Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size");
count = l.filelen / qfiles.darea_t.SIZE;
if (count > Defines.MAX_MAP_AREAS)
Com.Error(Defines.ERR_DROP, "Map has too many areas");
Com.DPrintf(" numareas=" + count + '\n');
numareas = count;
if (debugloadmap) {
Com.DPrintf("areas(numportals, firstportal)\n");
}
for (i = 0; i < count; i++) {
in = new qfiles.darea_t(ByteBuffer.wrap(cmod_base, i * qfiles.darea_t.SIZE + l.fileofs, qfiles.darea_t.SIZE));
out = map_areas[i];
out.numareaportals = in.numareaportals;
out.firstareaportal = in.firstareaportal;
out.floodvalid = 0;
out.floodnum = 0;
if (debugloadmap) {
Com.DPrintf("| %6i| %6i|\n", new Vargs().add(out.numareaportals).add(out.firstareaportal));
}
}
}
use of jake2.util.Vargs in project narchy by automenta.
the class CM method CMod_LoadSubmodels.
/**
* Loads Submodels.
*/
public static void CMod_LoadSubmodels(lump_t l) {
Com.DPrintf("CMod_LoadSubmodels()\n");
qfiles.dmodel_t in;
cmodel_t out;
int i, j, count;
if ((l.filelen % qfiles.dmodel_t.SIZE) != 0)
Com.Error(Defines.ERR_DROP, "CMod_LoadBmodel: funny lump size");
count = l.filelen / qfiles.dmodel_t.SIZE;
if (count < 1)
Com.Error(Defines.ERR_DROP, "Map with no models");
if (count > Defines.MAX_MAP_MODELS)
Com.Error(Defines.ERR_DROP, "Map has too many models");
Com.DPrintf(" numcmodels=" + count + '\n');
numcmodels = count;
if (debugloadmap) {
Com.DPrintf("submodles(headnode, <origin>, <mins>, <maxs>)\n");
}
for (i = 0; i < count; i++) {
in = new qfiles.dmodel_t(ByteBuffer.wrap(cmod_base, i * qfiles.dmodel_t.SIZE + l.fileofs, qfiles.dmodel_t.SIZE));
out = map_cmodels[i];
for (j = 0; j < 3; j++) {
// spread the mins / maxs by a pixel
out.mins[j] = in.mins[j] - 1;
out.maxs[j] = in.maxs[j] + 1;
out.origin[j] = in.origin[j];
}
out.headnode = in.headnode;
if (debugloadmap) {
Com.DPrintf("|%6i|%8.2f|%8.2f|%8.2f| %8.2f|%8.2f|%8.2f| %8.2f|%8.2f|%8.2f|\n", new Vargs().add(out.headnode).add(out.origin[0]).add(out.origin[1]).add(out.origin[2]).add(out.mins[0]).add(out.mins[1]).add(out.mins[2]).add(out.maxs[0]).add(out.maxs[1]).add(out.maxs[2]));
}
}
}
Aggregations