本文整理汇总了C++中LittleFloat函数的典型用法代码示例。如果您正苦于以下问题:C++ LittleFloat函数的具体用法?C++ LittleFloat怎么用?C++ LittleFloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LittleFloat函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Mod_LoadSpriteModel
/*
=================
Mod_LoadSpriteModel
=================
*/
void Mod_LoadSpriteModel(model_t *mod, void *buffer, const char *loadname)
{
int i;
msprite_t *psprite;
int numframes;
int size;
dspriteframetype_t *pframetype;
dsprite_t *pin = (dsprite_t *)buffer;
#ifdef MSB_FIRST
int version = LittleLong(pin->version);
#else
int version = (pin->version);
#endif
if (version != SPRITE_VERSION)
Sys_Error("%s: %s has wrong version number (%i should be %i)",
__func__, mod->name, version, SPRITE_VERSION);
#ifdef MSB_FIRST
numframes = LittleLong(pin->numframes);
#else
numframes = (pin->numframes);
#endif
size = sizeof(*psprite) + numframes * sizeof(psprite->frames[0]);
psprite = (msprite_t*)Hunk_AllocName(size, loadname);
mod->cache.data = psprite;
#ifdef MSB_FIRST
psprite->type = LittleLong(pin->type);
psprite->maxwidth = LittleLong(pin->width);
psprite->maxheight = LittleLong(pin->height);
psprite->beamlength = LittleFloat(pin->beamlength);
mod->synctype = (synctype_t)LittleLong(pin->synctype);
#else
psprite->type = (pin->type);
psprite->maxwidth = (pin->width);
psprite->maxheight = (pin->height);
psprite->beamlength = (pin->beamlength);
mod->synctype = (synctype_t)(pin->synctype);
#endif
psprite->numframes = numframes;
mod->mins[0] = mod->mins[1] = -psprite->maxwidth / 2;
mod->maxs[0] = mod->maxs[1] = psprite->maxwidth / 2;
mod->mins[2] = -psprite->maxheight / 2;
mod->maxs[2] = psprite->maxheight / 2;
//
// load the frames
//
if (numframes < 1)
Sys_Error("%s: Invalid # of frames: %d", __func__, numframes);
mod->numframes = numframes;
mod->flags = 0;
pframetype = (dspriteframetype_t *)(pin + 1);
for (i = 0; i < numframes; i++) {
spriteframetype_t frametype;
#ifdef MSB_FIRST
frametype = (spriteframetype_t)LittleLong(pframetype->type);
#else
frametype = (spriteframetype_t)(pframetype->type);
#endif
psprite->frames[i].type = frametype;
if (frametype == SPR_SINGLE) {
pframetype = (dspriteframetype_t *)
Mod_LoadSpriteFrame(pframetype + 1,
&psprite->frames[i].frameptr, loadname, i);
} else {
pframetype = (dspriteframetype_t *)
Mod_LoadSpriteGroup(pframetype + 1,
&psprite->frames[i].frameptr, loadname, i);
}
}
mod->type = mod_sprite;
}
开发者ID:leilei-,项目名称:tyrquake,代码行数:86,代码来源:sprite_model.c
示例2: Mod_LoadAliasModel
/*
=================
Mod_LoadAliasModel
=================
*/
void Mod_LoadAliasModel (model_t *mod, void *buffer)
{
int i, j;
dmdl_t *pinmodel, *pheader;
dstvert_t *pinst, *poutst;
dtriangle_t *pintri, *pouttri;
daliasframe_t *pinframe, *poutframe;
int *pincmd, *poutcmd;
int version;
pinmodel = (dmdl_t *)buffer;
version = LittleLong (pinmodel->version);
if (version != ALIAS_VERSION)
ri.Sys_Error (ERR_DROP, "%s has wrong version number (%i should be %i)",
mod->name, version, ALIAS_VERSION);
pheader = Hunk_Alloc (LittleLong(pinmodel->ofs_end));
// byte swap the header fields and sanity check
for (i=0 ; i<sizeof(dmdl_t)/4 ; i++)
((int *)pheader)[i] = LittleLong (((int *)buffer)[i]);
if (pheader->skinheight > MAX_LBM_HEIGHT)
ri.Sys_Error (ERR_DROP, "model %s has a skin taller than %d", mod->name,
MAX_LBM_HEIGHT);
if (pheader->num_xyz <= 0)
ri.Sys_Error (ERR_DROP, "model %s has no vertices", mod->name);
if (pheader->num_xyz > MAX_VERTS)
ri.Sys_Error (ERR_DROP, "model %s has too many vertices", mod->name);
if (pheader->num_st <= 0)
ri.Sys_Error (ERR_DROP, "model %s has no st vertices", mod->name);
if (pheader->num_tris <= 0)
ri.Sys_Error (ERR_DROP, "model %s has no triangles", mod->name);
if (pheader->num_frames <= 0)
ri.Sys_Error (ERR_DROP, "model %s has no frames", mod->name);
//
// load base s and t vertices (not used in gl version)
//
pinst = (dstvert_t *) ((byte *)pinmodel + pheader->ofs_st);
poutst = (dstvert_t *) ((byte *)pheader + pheader->ofs_st);
for (i=0 ; i<pheader->num_st ; i++)
{
poutst[i].s = LittleShort (pinst[i].s);
poutst[i].t = LittleShort (pinst[i].t);
}
//
// load triangle lists
//
pintri = (dtriangle_t *) ((byte *)pinmodel + pheader->ofs_tris);
pouttri = (dtriangle_t *) ((byte *)pheader + pheader->ofs_tris);
for (i=0 ; i<pheader->num_tris ; i++)
{
for (j=0 ; j<3 ; j++)
{
pouttri[i].index_xyz[j] = LittleShort (pintri[i].index_xyz[j]);
pouttri[i].index_st[j] = LittleShort (pintri[i].index_st[j]);
}
}
//
// load the frames
//
for (i=0 ; i<pheader->num_frames ; i++)
{
pinframe = (daliasframe_t *) ((byte *)pinmodel
+ pheader->ofs_frames + i * pheader->framesize);
poutframe = (daliasframe_t *) ((byte *)pheader
+ pheader->ofs_frames + i * pheader->framesize);
memcpy (poutframe->name, pinframe->name, sizeof(poutframe->name));
for (j=0 ; j<3 ; j++)
{
poutframe->scale[j] = LittleFloat (pinframe->scale[j]);
poutframe->translate[j] = LittleFloat (pinframe->translate[j]);
}
// verts are all 8 bit, so no swapping needed
memcpy (poutframe->verts, pinframe->verts,
pheader->num_xyz*sizeof(dtrivertx_t));
}
mod->type = mod_alias;
//
// load the glcmds
//.........这里部分代码省略.........
开发者ID:dschimmer,项目名称:omega-q2-engine,代码行数:101,代码来源:gles_model.c
示例3: Mod_LoadSpriteModel
/*
=================
Mod_LoadSpriteModel
=================
*/
void Mod_LoadSpriteModel (model_t *mod, void *buffer)
{
int i;
int version;
dsprite_t *pin;
msprite_t *psprite;
int numframes;
int size;
dspriteframetype_t *pframetype;
pin = (dsprite_t *)buffer;
version = LittleLong (pin->version);
if (version != SPRITE_VERSION)
Sys_Error ("%s has wrong version number "
"(%i should be %i)", mod->name, version, SPRITE_VERSION);
numframes = LittleLong (pin->numframes);
size = sizeof (msprite_t) + (numframes - 1) * sizeof (psprite->frames);
psprite = Hunk_AllocName (size, loadname);
mod->cache.data = psprite;
psprite->type = LittleLong (pin->type);
psprite->maxwidth = LittleLong (pin->width);
psprite->maxheight = LittleLong (pin->height);
psprite->beamlength = LittleFloat (pin->beamlength);
mod->synctype = LittleLong (pin->synctype);
psprite->numframes = numframes;
mod->mins[0] = mod->mins[1] = -psprite->maxwidth/2;
mod->maxs[0] = mod->maxs[1] = psprite->maxwidth/2;
mod->mins[2] = -psprite->maxheight/2;
mod->maxs[2] = psprite->maxheight/2;
//
// load the frames
//
if (numframes < 1)
Sys_Error ("Mod_LoadSpriteModel: Invalid # of frames: %d\n", numframes);
mod->numframes = numframes;
pframetype = (dspriteframetype_t *)(pin + 1);
for (i=0 ; i<numframes ; i++)
{
spriteframetype_t frametype;
frametype = LittleLong (pframetype->type);
psprite->frames[i].type = frametype;
if (frametype == SPR_SINGLE)
{
pframetype = (dspriteframetype_t *)
Mod_LoadSpriteFrame (pframetype + 1,
&psprite->frames[i].frameptr, i);
}
else
{
pframetype = (dspriteframetype_t *)
Mod_LoadSpriteGroup (pframetype + 1,
&psprite->frames[i].frameptr, i);
}
}
mod->type = mod_sprite;
}
开发者ID:ACIIL,项目名称:Quake,代码行数:75,代码来源:gl_model.c
示例4: ParseTriSurf
/*
===============
ParseTriSurf
===============
*/
static void ParseTriSurf( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, int *indexes, world_t &worldData, int index ) {
srfTriangles_t *tri;
int i, j, k;
int numVerts, numIndexes;
// get fog volume
surf->fogIndex = LittleLong( ds->fogNum ) + 1;
if (index && !surf->fogIndex && tr.world && tr.world->globalFog != -1)
{
surf->fogIndex = worldData.globalFog;
}
// get shader
surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles, worldData );
if ( r_singleShader->integer && !surf->shader->sky ) {
surf->shader = tr.defaultShader;
}
numVerts = LittleLong( ds->numVerts );
numIndexes = LittleLong( ds->numIndexes );
if ( numVerts >= SHADER_MAX_VERTEXES ) {
Com_Error(ERR_DROP, "ParseTriSurf: verts > MAX (%d > %d) on misc_model %s", numVerts, SHADER_MAX_VERTEXES, surf->shader->name );
}
if ( numIndexes >= SHADER_MAX_INDEXES ) {
Com_Error(ERR_DROP, "ParseTriSurf: indices > MAX (%d > %d) on misc_model %s", numIndexes, SHADER_MAX_INDEXES, surf->shader->name );
}
tri = (srfTriangles_t *) Z_Malloc( sizeof( *tri ) + numVerts * sizeof( tri->verts[0] ) + numIndexes * sizeof( tri->indexes[0] ), TAG_HUNKMISCMODELS, qfalse );
tri->dlightBits = 0; //JIC
tri->surfaceType = SF_TRIANGLES;
tri->numVerts = numVerts;
tri->numIndexes = numIndexes;
tri->verts = (drawVert_t *)(tri + 1);
tri->indexes = (int *)(tri->verts + tri->numVerts );
surf->data = (surfaceType_t *)tri;
// copy vertexes
verts += LittleLong( ds->firstVert );
ClearBounds( tri->bounds[0], tri->bounds[1] );
for ( i = 0 ; i < numVerts ; i++ ) {
for ( j = 0 ; j < 3 ; j++ ) {
tri->verts[i].xyz[j] = LittleFloat( verts[i].xyz[j] );
tri->verts[i].normal[j] = LittleFloat( verts[i].normal[j] );
}
AddPointToBounds( tri->verts[i].xyz, tri->bounds[0], tri->bounds[1] );
for ( j = 0 ; j < 2 ; j++ ) {
tri->verts[i].st[j] = LittleFloat( verts[i].st[j] );
for(k=0;k<MAXLIGHTMAPS;k++)
{
tri->verts[i].lightmap[k][j] = LittleFloat( verts[i].lightmap[k][j] );
}
}
for(k=0;k<MAXLIGHTMAPS;k++)
{
R_ColorShiftLightingBytes( verts[i].color[k], tri->verts[i].color[k] );
}
}
// copy indexes
indexes += LittleLong( ds->firstIndex );
for ( i = 0 ; i < numIndexes ; i++ ) {
tri->indexes[i] = LittleLong( indexes[i] );
if ( tri->indexes[i] < 0 || tri->indexes[i] >= numVerts ) {
Com_Error( ERR_DROP, "Bad index in triangle surface" );
}
}
}
开发者ID:Delfin1,项目名称:OpenJK,代码行数:74,代码来源:tr_bsp.cpp
示例5: R_LoadMDR
static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char *mod_name )
{
int i, j, k, l;
mdrHeader_t *pinmodel, *mdr;
mdrFrame_t *frame;
mdrLOD_t *lod, *curlod;
mdrSurface_t *surf, *cursurf;
mdrTriangle_t *tri, *curtri;
mdrVertex_t *v, *curv;
mdrWeight_t *weight, *curweight;
mdrTag_t *tag, *curtag;
int size;
shader_t *sh;
pinmodel = (mdrHeader_t *)buffer;
pinmodel->version = LittleLong(pinmodel->version);
if (pinmodel->version != MDR_VERSION)
{
ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has wrong version (%i should be %i)\n", mod_name, pinmodel->version, MDR_VERSION);
return qfalse;
}
size = LittleLong(pinmodel->ofsEnd);
if(size > filesize)
{
ri.Printf(PRINT_WARNING, "R_LoadMDR: Header of %s is broken. Wrong filesize declared!\n", mod_name);
return qfalse;
}
mod->type = MOD_MDR;
pinmodel->numFrames = LittleLong(pinmodel->numFrames);
pinmodel->numBones = LittleLong(pinmodel->numBones);
pinmodel->ofsFrames = LittleLong(pinmodel->ofsFrames);
// This is a model that uses some type of compressed Bones. We don't want to uncompress every bone for each rendered frame
// over and over again, we'll uncompress it in this function already, so we must adjust the size of the target md4.
if(pinmodel->ofsFrames < 0)
{
// mdrFrame_t is larger than mdrCompFrame_t:
size += pinmodel->numFrames * sizeof(frame->name);
// now add enough space for the uncompressed bones.
size += pinmodel->numFrames * pinmodel->numBones * ((sizeof(mdrBone_t) - sizeof(mdrCompBone_t)));
}
mod->dataSize += size;
mod->md4 = mdr = ri.Hunk_Alloc( size, h_low );
// Copy all the values over from the file and fix endian issues in the process, if necessary.
mdr->ident = LittleLong(pinmodel->ident);
mdr->version = pinmodel->version; // Don't need to swap byte order on this one, we already did above.
Q_strncpyz(mdr->name, pinmodel->name, sizeof(mdr->name));
mdr->numFrames = pinmodel->numFrames;
mdr->numBones = pinmodel->numBones;
mdr->numLODs = LittleLong(pinmodel->numLODs);
mdr->numTags = LittleLong(pinmodel->numTags);
// We don't care about offset values, we'll generate them ourselves while loading.
mod->numLods = mdr->numLODs;
if ( mdr->numFrames < 1 )
{
ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name);
return qfalse;
}
/* The first frame will be put into the first free space after the header */
frame = (mdrFrame_t *)(mdr + 1);
mdr->ofsFrames = (int)((byte *) frame - (byte *) mdr);
if (pinmodel->ofsFrames < 0)
{
mdrCompFrame_t *cframe;
// compressed model...
cframe = (mdrCompFrame_t *)((byte *) pinmodel - pinmodel->ofsFrames);
for(i = 0; i < mdr->numFrames; i++)
{
for(j = 0; j < 3; j++)
{
frame->bounds[0][j] = LittleFloat(cframe->bounds[0][j]);
frame->bounds[1][j] = LittleFloat(cframe->bounds[1][j]);
frame->localOrigin[j] = LittleFloat(cframe->localOrigin[j]);
}
frame->radius = LittleFloat(cframe->radius);
frame->name[0] = '\0'; // No name supplied in the compressed version.
for(j = 0; j < mdr->numBones; j++)
{
for(k = 0; k < (sizeof(cframe->bones[j].Comp) / 2); k++)
{
// Do swapping for the uncompressing functions. They seem to use shorts
// values only, so I assume this will work. Never tested it on other
// platforms, though.
//.........这里部分代码省略.........
开发者ID:AlienHoboken,项目名称:Tremulous-W-Server,代码行数:101,代码来源:tr_model.c
示例6: SwapBSPFile
/*
=============
SwapBSPFile
Byte swaps all data in a bsp file.
=============
*/
void SwapBSPFile( void ) {
int i;
// models
SwapBlock( (int *)dmodels, nummodels * sizeof( dmodels[0] ) );
// shaders (don't swap the name)
for ( i = 0 ; i < numShaders ; i++ ) {
dshaders[i].contentFlags = LittleLong( dshaders[i].contentFlags );
dshaders[i].surfaceFlags = LittleLong( dshaders[i].surfaceFlags );
}
// planes
SwapBlock( (int *)dplanes, numplanes * sizeof( dplanes[0] ) );
// nodes
SwapBlock( (int *)dnodes, numnodes * sizeof( dnodes[0] ) );
// leafs
SwapBlock( (int *)dleafs, numleafs * sizeof( dleafs[0] ) );
// leaffaces
SwapBlock( (int *)dleafsurfaces, numleafsurfaces * sizeof( dleafsurfaces[0] ) );
// leafbrushes
SwapBlock( (int *)dleafbrushes, numleafbrushes * sizeof( dleafbrushes[0] ) );
// brushes
SwapBlock( (int *)dbrushes, numbrushes * sizeof( dbrushes[0] ) );
// brushsides
SwapBlock( (int *)dbrushsides, numbrushsides * sizeof( dbrushsides[0] ) );
// vis
((int *)&visBytes)[0] = LittleLong( ((int *)&visBytes)[0] );
((int *)&visBytes)[1] = LittleLong( ((int *)&visBytes)[1] );
// drawverts (don't swap colors )
for ( i = 0 ; i < numDrawVerts ; i++ ) {
drawVerts[i].lightmap[0] = LittleFloat( drawVerts[i].lightmap[0] );
drawVerts[i].lightmap[1] = LittleFloat( drawVerts[i].lightmap[1] );
drawVerts[i].st[0] = LittleFloat( drawVerts[i].st[0] );
drawVerts[i].st[1] = LittleFloat( drawVerts[i].st[1] );
drawVerts[i].xyz[0] = LittleFloat( drawVerts[i].xyz[0] );
drawVerts[i].xyz[1] = LittleFloat( drawVerts[i].xyz[1] );
drawVerts[i].xyz[2] = LittleFloat( drawVerts[i].xyz[2] );
drawVerts[i].normal[0] = LittleFloat( drawVerts[i].normal[0] );
drawVerts[i].normal[1] = LittleFloat( drawVerts[i].normal[1] );
drawVerts[i].normal[2] = LittleFloat( drawVerts[i].normal[2] );
}
// drawindexes
SwapBlock( (int *)drawIndexes, numDrawIndexes * sizeof( drawIndexes[0] ) );
// drawsurfs
SwapBlock( (int *)drawSurfaces, numDrawSurfaces * sizeof( drawSurfaces[0] ) );
// fogs
for ( i = 0 ; i < numFogs ; i++ ) {
dfogs[i].brushNum = LittleLong( dfogs[i].brushNum );
dfogs[i].visibleSide = LittleLong( dfogs[i].visibleSide );
}
// TODO: swap MoHAA structs
}
开发者ID:kingtiger01,项目名称:OpenMOHAA,代码行数:72,代码来源:bspfile.c
示例7: ParseFace
/*
===============
ParseFace
===============
*/
static void ParseFace( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, int *indexes, byte *&pFaceDataBuffer, world_t &worldData, int index )
{
int i, j, k;
srfSurfaceFace_t *cv;
int numPoints, numIndexes;
int lightmapNum[MAXLIGHTMAPS];
int sfaceSize, ofsIndexes;
for(i=0;i<MAXLIGHTMAPS;i++)
{
lightmapNum[i] = LittleLong( ds->lightmapNum[i] );
if (lightmapNum[i] >= 0)
{
lightmapNum[i] += worldData.startLightMapIndex;
}
}
// get fog volume
surf->fogIndex = LittleLong( ds->fogNum ) + 1;
if (index && !surf->fogIndex && tr.world && tr.world->globalFog != -1)
{
surf->fogIndex = worldData.globalFog;
}
// get shader value
surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapNum, ds->lightmapStyles, ds->vertexStyles, worldData );
if ( r_singleShader->integer && !surf->shader->sky ) {
surf->shader = tr.defaultShader;
}
numPoints = LittleLong( ds->numVerts );
numIndexes = LittleLong( ds->numIndexes );
// create the srfSurfaceFace_t
sfaceSize = ( intptr_t ) &((srfSurfaceFace_t *)0)->points[numPoints];
ofsIndexes = sfaceSize;
sfaceSize += sizeof( int ) * numIndexes;
cv = (srfSurfaceFace_t *) pFaceDataBuffer;//Hunk_Alloc( sfaceSize );
pFaceDataBuffer += sfaceSize; // :-)
cv->surfaceType = SF_FACE;
cv->numPoints = numPoints;
cv->numIndices = numIndexes;
cv->ofsIndices = ofsIndexes;
verts += LittleLong( ds->firstVert );
for ( i = 0 ; i < numPoints ; i++ ) {
for ( j = 0 ; j < 3 ; j++ ) {
cv->points[i][j] = LittleFloat( verts[i].xyz[j] );
}
for ( j = 0 ; j < 2 ; j++ ) {
cv->points[i][3+j] = LittleFloat( verts[i].st[j] );
for(k=0;k<MAXLIGHTMAPS;k++)
{
cv->points[i][VERTEX_LM+j+(k*2)] = LittleFloat( verts[i].lightmap[k][j] );
}
}
for(k=0;k<MAXLIGHTMAPS;k++)
{
R_ColorShiftLightingBytes( verts[i].color[k], (byte *)&cv->points[i][VERTEX_COLOR+k] );
}
}
indexes += LittleLong( ds->firstIndex );
for ( i = 0 ; i < numIndexes ; i++ ) {
((int *)((byte *)cv + cv->ofsIndices ))[i] = LittleLong( indexes[ i ] );
}
// take the plane information from the lightmap vector
for ( i = 0 ; i < 3 ; i++ ) {
cv->plane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
}
cv->plane.dist = DotProduct( cv->points[0], cv->plane.normal );
SetPlaneSignbits( &cv->plane );
cv->plane.type = PlaneTypeForNormal( cv->plane.normal );
surf->data = (surfaceType_t *)cv;
}
开发者ID:Delfin1,项目名称:OpenJK,代码行数:84,代码来源:tr_bsp.cpp
示例8: R_LoadMDM
/*
=================
R_LoadMDM
=================
*/
qboolean R_LoadMDM( model_t *mod, void *buffer, const char *modName )
{
int i, j, k;
mdmHeader_t *mdm;
// mdmFrame_t *frame;
mdmSurface_t *mdmSurf;
mdmTriangle_t *mdmTri;
mdmVertex_t *mdmVertex;
mdmTag_t *mdmTag;
int version;
// int size;
shader_t *sh;
int32_t *collapseMap, *collapseMapOut, *boneref, *bonerefOut;
mdmModel_t *mdmModel;
mdmTagIntern_t *tag;
mdmSurfaceIntern_t *surf;
srfTriangle_t *tri;
md5Vertex_t *v;
mdm = ( mdmHeader_t * ) buffer;
version = LittleLong( mdm->version );
if ( version != MDM_VERSION )
{
ri.Printf( PRINT_WARNING, "R_LoadMDM: %s has wrong version (%i should be %i)\n", modName, version, MDM_VERSION );
return qfalse;
}
mod->type = MOD_MDM;
// size = LittleLong(mdm->ofsEnd);
mod->dataSize += sizeof( mdmModel_t );
//mdm = mod->mdm = ri.Hunk_Alloc(size, h_low);
//memcpy(mdm, buffer, LittleLong(pinmodel->ofsEnd));
mdmModel = mod->mdm = ri.Hunk_Alloc( sizeof( mdmModel_t ), h_low );
LL( mdm->ident );
LL( mdm->version );
// LL(mdm->numFrames);
LL( mdm->numTags );
LL( mdm->numSurfaces );
// LL(mdm->ofsFrames);
LL( mdm->ofsTags );
LL( mdm->ofsEnd );
LL( mdm->ofsSurfaces );
mdmModel->lodBias = LittleFloat( mdm->lodBias );
mdmModel->lodScale = LittleFloat( mdm->lodScale );
/* mdm->skel = RE_RegisterModel(mdm->bonesfile);
if ( !mdm->skel ) {
ri.Error (ERR_DROP, "R_LoadMDM: %s skeleton not found", mdm->bonesfile );
}
if ( mdm->numFrames < 1 ) {
ri.Printf( PRINT_WARNING, "R_LoadMDM: %s has no frames\n", modName );
return qfalse;
}*/
// swap all the frames
/*frameSize = (int) ( sizeof( mdmFrame_t ) );
for ( i = 0 ; i < mdm->numFrames ; i++, frame++) {
frame = (mdmFrame_t *) ( (byte *)mdm + mdm->ofsFrames + i * frameSize );
frame->radius = LittleFloat( frame->radius );
for ( j = 0 ; j < 3 ; j++ ) {
frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] );
frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] );
frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] );
frame->parentOffset[j] = LittleFloat( frame->parentOffset[j] );
}
} */
// swap all the tags
mdmModel->numTags = mdm->numTags;
mdmModel->tags = tag = ri.Hunk_Alloc( sizeof( *tag ) * mdm->numTags, h_low );
mdmTag = ( mdmTag_t * )( ( byte * ) mdm + mdm->ofsTags );
for ( i = 0; i < mdm->numTags; i++, tag++ )
{
int ii;
Q_strncpyz( tag->name, mdmTag->name, sizeof( tag->name ) );
for ( ii = 0; ii < 3; ii++ )
{
tag->axis[ ii ][ 0 ] = LittleFloat( mdmTag->axis[ ii ][ 0 ] );
tag->axis[ ii ][ 1 ] = LittleFloat( mdmTag->axis[ ii ][ 1 ] );
tag->axis[ ii ][ 2 ] = LittleFloat( mdmTag->axis[ ii ][ 2 ] );
}
//.........这里部分代码省略.........
开发者ID:ghostmod,项目名称:Unvanquished,代码行数:101,代码来源:tr_model_mdm.c
示例9: Mod_LoadAliasModel
/*
=================
Mod_LoadAliasModel
=================
*/
void Mod_LoadAliasModel (model_t *mod, void *buffer)
{
int i;
mdl_t *pmodel, *pinmodel;
stvert_t *pstverts, *pinstverts;
aliashdr_t *pheader;
mtriangle_t *ptri;
dtriangle_t *pintriangles;
int version, numframes, numskins;
int size;
daliasframetype_t *pframetype;
daliasskintype_t *pskintype;
maliasskindesc_t *pskindesc;
int skinsize;
int start, end, total;
start = Hunk_LowMark ();
pinmodel = (mdl_t *)buffer;
version = LittleLong (pinmodel->version);
if (version != ALIAS_VERSION)
Sys_Error ("%s has wrong version number (%i should be %i)",
mod->name, version, ALIAS_VERSION);
//
// allocate space for a working header, plus all the data except the frames,
// skin and group info
//
size = sizeof (aliashdr_t) + (LittleLong (pinmodel->numframes) - 1) *
sizeof (pheader->frames[0]) +
sizeof (mdl_t) +
LittleLong (pinmodel->numverts) * sizeof (stvert_t) +
LittleLong (pinmodel->numtris) * sizeof (mtriangle_t);
pheader = Hunk_AllocName (size, loadname);
pmodel = (mdl_t *) ((byte *)&pheader[1] +
(LittleLong (pinmodel->numframes) - 1) *
sizeof (pheader->frames[0]));
// mod->cache.data = pheader;
mod->flags = LittleLong (pinmodel->flags);
//
// endian-adjust and copy the data, starting with the alias model header
//
pmodel->boundingradius = LittleFloat (pinmodel->boundingradius);
pmodel->numskins = LittleLong (pinmodel->numskins);
pmodel->skinwidth = LittleLong (pinmodel->skinwidth);
pmodel->skinheight = LittleLong (pinmodel->skinheight);
if (pmodel->skinheight > MAX_LBM_HEIGHT)
Sys_Error ("model %s has a skin taller than %d", mod->name,
MAX_LBM_HEIGHT);
pmodel->numverts = LittleLong (pinmodel->numverts);
if (pmodel->numverts <= 0)
Sys_Error ("model %s has no vertices", mod->name);
if (pmodel->numverts > MAXALIASVERTS)
Sys_Error ("model %s has too many vertices", mod->name);
pmodel->numtris = LittleLong (pinmodel->numtris);
if (pmodel->numtris <= 0)
Sys_Error ("model %s has no triangles", mod->name);
pmodel->numframes = LittleLong (pinmodel->numframes);
pmodel->size = LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO;
mod->synctype = LittleLong (pinmodel->synctype);
mod->numframes = pmodel->numframes;
for (i=0 ; i<3 ; i++)
{
pmodel->scale[i] = LittleFloat (pinmodel->scale[i]);
pmodel->scale_origin[i] = LittleFloat (pinmodel->scale_origin[i]);
pmodel->eyeposition[i] = LittleFloat (pinmodel->eyeposition[i]);
}
numskins = pmodel->numskins;
numframes = pmodel->numframes;
if (pmodel->skinwidth & 0x03)
Sys_Error ("Mod_LoadAliasModel: skinwidth not multiple of 4");
pheader->model = (byte *)pmodel - (byte *)pheader;
//
// load the skins
//
skinsize = pmodel->skinheight * pmodel->skinwidth;
if (numskins < 1)
Sys_Error ("Mod_LoadAliasModel: Invalid # of skins: %d\n", numskins);
//.........这里部分代码省略.........
开发者ID:Izhido,项目名称:qrevpak,代码行数:101,代码来源:model.c
示例10: R_LoadMd3Lod
static bool R_LoadMd3Lod( idRenderModel* mod, int lod, const void* buffer, const char* mod_name ) {
md3Header_t* pinmodel = ( md3Header_t* )buffer;
int version = LittleLong( pinmodel->version );
if ( version != MD3_VERSION ) {
common->Printf( S_COLOR_YELLOW "R_LoadMD3: %s has wrong version (%i should be %i)\n",
mod_name, version, MD3_VERSION );
return false;
}
mod->type = MOD_MESH3;
int size = LittleLong( pinmodel->ofsEnd );
mod->q3_dataSize += size;
mod->q3_md3[ lod ].header = ( md3Header_t* )Mem_Alloc( size );
Com_Memcpy( mod->q3_md3[ lod ].header, buffer, LittleLong( pinmodel->ofsEnd ) );
LL( mod->q3_md3[ lod ].header->ident );
LL( mod->q3_md3[ lod ].header->version );
LL( mod->q3_md3[ lod ].header->numFrames );
LL( mod->q3_md3[ lod ].header->numTags );
LL( mod->q3_md3[ lod ].header->numSurfaces );
LL( mod->q3_md3[ lod ].header->ofsFrames );
LL( mod->q3_md3[ lod ].header->ofsTags );
LL( mod->q3_md3[ lod ].header->ofsSurfaces );
LL( mod->q3_md3[ lod ].header->ofsEnd );
if ( mod->q3_md3[ lod ].header->numFrames < 1 ) {
common->Printf( S_COLOR_YELLOW "R_LoadMD3: %s has no frames\n", mod_name );
return false;
}
bool fixRadius = false;
if ( GGameType & ( GAME_WolfSP | GAME_WolfMP | GAME_ET ) &&
( strstr( mod->name,"sherman" ) || strstr( mod->name, "mg42" ) ) ) {
fixRadius = true;
}
// swap all the frames
md3Frame_t* frame = ( md3Frame_t* )( ( byte* )mod->q3_md3[ lod ].header + mod->q3_md3[ lod ].header->ofsFrames );
for ( int i = 0; i < mod->q3_md3[ lod ].header->numFrames; i++, frame++ ) {
frame->radius = LittleFloat( frame->radius );
if ( fixRadius ) {
frame->radius = 256;
for ( int j = 0; j < 3; j++ ) {
frame->bounds[ 0 ][ j ] = 128;
frame->bounds[ 1 ][ j ] = -128;
frame->localOrigin[ j ] = LittleFloat( frame->localOrigin[ j ] );
}
}
// Hack for Bug using plugin generated model
else if ( GGameType & ( GAME_WolfSP | GAME_WolfMP | GAME_ET ) && frame->radius == 1 ) {
frame->radius = 256;
for ( int j = 0; j < 3; j++ ) {
frame->bounds[ 0 ][ j ] = 128;
frame->bounds[ 1 ][ j ] = -128;
frame->localOrigin[ j ] = LittleFloat( frame->localOrigin[ j ] );
}
} else {
for ( int j = 0; j < 3; j++ ) {
frame->bounds[ 0 ][ j ] = LittleFloat( frame->bounds[ 0 ][ j ] );
frame->bounds[ 1 ][ j ] = LittleFloat( frame->bounds[ 1 ][ j ] );
frame->localOrigin[ j ] = LittleFloat( frame->localOrigin[ j ] );
}
}
}
// swap all the tags
md3Tag_t* tag = ( md3Tag_t* )( ( byte* )mod->q3_md3[ lod ].header + mod->q3_md3[ lod ].header->ofsTags );
for ( int i = 0; i < mod->q3_md3[ lod ].header->numTags * mod->q3_md3[ lod ].header->numFrames; i++, tag++ ) {
for ( int j = 0; j < 3; j++ ) {
tag->origin[ j ] = LittleFloat( tag->origin[ j ] );
tag->axis[ 0 ][ j ] = LittleFloat( tag->axis[ 0 ][ j ] );
tag->axis[ 1 ][ j ] = LittleFloat( tag->axis[ 1 ][ j ] );
tag->axis[ 2 ][ j ] = LittleFloat( tag->axis[ 2 ][ j ] );
}
}
// swap all the surfaces
mod->q3_md3[ lod ].surfaces = new idSurfaceMD3[ mod->q3_md3[ lod ].header->numSurfaces ];
md3Surface_t* surf = ( md3Surface_t* )( ( byte* )mod->q3_md3[ lod ].header + mod->q3_md3[ lod ].header->ofsSurfaces );
for ( int i = 0; i < mod->q3_md3[ lod ].header->numSurfaces; i++ ) {
mod->q3_md3[ lod ].surfaces[ i ].SetMd3Data( surf );
LL( surf->ident );
LL( surf->flags );
LL( surf->numFrames );
LL( surf->numShaders );
LL( surf->numTriangles );
LL( surf->ofsTriangles );
LL( surf->numVerts );
LL( surf->ofsShaders );
LL( surf->ofsSt );
LL( surf->ofsXyzNormals );
LL( surf->ofsEnd );
if ( surf->numVerts > SHADER_MAX_VERTEXES ) {
common->Error( "R_LoadMD3: %s has more than %i verts on a surface (%i)",
mod_name, SHADER_MAX_VERTEXES, surf->numVerts );
}
if ( surf->numTriangles * 3 > SHADER_MAX_INDEXES ) {
//.........这里部分代码省略.........
开发者ID:janisl,项目名称:jlquake,代码行数:101,代码来源:RenderModelMD3.cpp
示例11: MapFile_ReduxDecodeMapData
//.........这里部分代码省略.........
// Ceiling Colour
ceiling = LittleLong( ceiling );
fwrite( &ceiling, sizeof( W32 ), 1, fout );
// Floor Colour
floor = LittleLong( floor );
fwrite( &floor, sizeof( W32 ), 1, fout );
// Length of layers
temp = LittleShort( length[ 0 ] );
fwrite( &temp, sizeof( W16 ), 1, fout ); // Length One
temp = LittleShort( length[ 1 ] );
fwrite( &temp, sizeof( W16 ), 1, fout ); // Length Two
temp = LittleShort( length[ 2 ] );
fwrite( &temp, sizeof( W16 ), 1, fout ); // Length Three
jmp = ftell( fout );
temp = 0;
fwrite( &temp, sizeof( W32 ), 1, fout ); // Offset One
fwrite( &temp, sizeof( W32 ), 1, fout ); // Offset Two
fwrite( &temp, sizeof( W32 ), 1, fout ); // Offset Three
// Map name length
temp = strlen( name );
fwrite( &temp, sizeof( W16 ), 1, fout );
// Music name length
temp = strlen( musicName );
fwrite( &temp, sizeof( W16 ), 1, fout );
// Par time Float
ftime = LittleFloat( ftime );
fwrite( &ftime, sizeof( float ), 1, fout );
// Par time string
fwrite( stime, sizeof( W8 ), 5 , fout );
// Map name
fwrite( name, sizeof( W8 ), strlen( name ), fout );
// Music file name
fwrite( musicName, sizeof( W8 ), strlen( musicName ), fout );
data = (PW8) MM_MALLOC( length[ 0 ] );
if( data == NULL )
{
continue;
}
offset[ 0 ] = ftell( fout );
fseek( map_file_handle, offsetin[ 0 ], SEEK_SET );
fread( data, 1, length[ 0 ], map_file_handle );
fwrite( data, 1, length[ 0 ], fout );
MM_FREE( data );
data = (PW8) MM_MALLOC( length[ 1 ] );
开发者ID:MichaelLiebscher,项目名称:Wolfenstein3D_Redux,代码行数:67,代码来源:wolfcore_map.c
示例12: WriteModelFile
//.........这里部分代码省略.........
model.version = ALIAS_VERSION;
model.framesize = (int)&((daliasframe_t *)0)->verts[model.num_xyz];
model.num_glcmds = numcommands;
model.ofs_skins = sizeof(dmdl_t);
model.ofs_st = model.ofs_skins + model.num_skins * MAX_SKINNAME;
model.ofs_tris = model.ofs_st + model.num_st*sizeof(dstvert_t);
model.ofs_frames = model.ofs_tris + model.num_tris*sizeof(dtriangle_t);
model.ofs_glcmds = model.ofs_frames + model.num_frames*model.framesize;
model.ofs_end = model.ofs_glcmds + model.num_glcmds*4;
//
// write out the model header
//
for (i=0 ; i<sizeof(dmdl_t)/4 ; i++)
((int *)&modeltemp)[i] = LittleLong (((int *)&model)[i]);
SafeWrite (modelouthandle, &modeltemp, sizeof(modeltemp));
//
// write out the skin names
//
SafeWrite (modelouthandle, g_skins, model.num_skins * MAX_SKINNAME);
//
// write out the texture coordinates
//
c_on = c_off = 0;
for (i=0 ; i<model.num_st ; i++)
{
base_st[i].s = LittleShort (base_st[i].s);
base_st[i].t = LittleShort (base_st[i].t);
}
SafeWrite (modelouthandle, base_st, model.num_st * sizeof(base_st[0]));
//
// write out the triangles
//
for (i=0 ; i<model.num_tris ; i++)
{
int j;
dtriangle_t tri;
for (j=0 ; j<3 ; j++)
{
tri.index_xyz[j] = LittleShort (triangles[i].index_xyz[j]);
tri.index_st[j] = LittleShort (triangles[i].index_st[j]);
}
SafeWrite (modelouthandle, &tri, sizeof(tri));
}
//
// write out the frames
//
for (i=0 ; i<model.num_frames ; i++)
{
in = &g_frames[i];
out = (daliasframe_t *)buffer;
strcpy (out->name, in->name);
for (j=0 ; j<3 ; j++)
{
out->scale[j] = (in->maxs[j] - in->mins[j])/255;
out->translate[j] = in->mins[j];
}
for (j=0 ; j<model.num_xyz ; j++)
{
// all of these are byte values, so no need to deal with endianness
out->verts[j].lightnormalindex = in->v[j].lightnormalindex;
for (k=0 ; k<3 ; k++)
{
// scale to byte values & min/max check
v = Q_rint ( (in->v[j].v[k] - out->translate[k]) / out->scale[k] );
// clamp, so rounding doesn't wrap from 255.6 to 0
if (v > 255.0)
v = 255.0;
if (v < 0)
v = 0;
out->verts[j].v[k] = v;
}
}
for (j=0 ; j<3 ; j++)
{
out->scale[j] = LittleFloat (out->scale[j]);
out->translate[j] = LittleFloat (out->translate[j]);
}
SafeWrite (modelouthandle, out, model.framesize);
}
//
// write out glcmds
//
SafeWrite (modelouthandle, commands, numcommands*4);
}
开发者ID:ChunHungLiu,项目名称:GtkRadiant,代码行数:101,代码来源:models.c
示例13: Mod_LoadAliasModel
/*
=================
Mod_LoadAliasModel
=================
*/
void Mod_LoadAliasModel (model_t *mod, void *buffer)
{
int i, j;
mdl_t *pinmodel;
stvert_t *pinstverts;
dtriangle_t *pintriangles;
int version, numframes, numskins;
int size;
daliasframetype_t *pframetype;
daliasskintype_t *pskintype;
int start, end, total;
start = Hunk_LowMark ();
pinmodel = (mdl_t *)buffer;
version = LittleLong (pinmodel->version);
if (version != ALIAS_VERSION)
Sys_Error ("%s has wrong version number (%i should be %i)",
mod->name, version, ALIAS_VERSION);
//
// allocate space for a working header, plus all the data except the frames,
// skin and group info
//
size = sizeof (aliashdr_t)
+ (LittleLong (pinmodel->numframes) - 1) *
sizeof (pheader->frames[0]);
pheader = (aliashdr_t*) Hunk_AllocName (size, loadname);
mod->flags = LittleLong (pinmodel->flags);
//
// endian-adjust and copy the data, starting with the alias model header
//
pheader->boundingradius = LittleFloat (pinmodel->boundingradius);
pheader->numskins = LittleLong (pinmodel->numskins);
pheader->skinwidth = LittleLong (pinmodel->skinwidth);
pheader->skinheight = LittleLong (pinmodel->skinheight);
if (pheader->skinheight > MAX_LBM_HEIGHT)
Sys_Error ("model %s has a skin taller than %d", mod->name,
MAX_LBM_HEIGHT);
pheader->numverts = LittleLong (pinmodel->numverts);
if (pheader->numverts <= 0)
Sys_Error ("model %s has no vertices", mod->name);
if (pheader->numverts > MAXALIASVERTS)
Sys_Error ("model %s has too many vertices", mod->name);
pheader->numtris = LittleLong (pinmodel->numtris);
if (pheader->numtris <= 0)
Sys_Error ("model %s has no triangles", mod->name);
pheader->numframes = LittleLong (pinmodel->numframes);
numframes = pheader->numframes;
if (numframes < 1)
Sys_Error ("Mod_LoadAliasModel: Invalid # of frames: %d\n", numframes);
pheader->size = LittleFloat (pinmodel->size) * ALIAS_BASE_SIZE_RATIO;
mod->synctype = (synctype_t) LittleLong (pinmodel->synctype);
mod->numframes = pheader->numframes;
for (i=0 ; i<3 ; i++)
{
pheader->scale[i] = LittleFloat (pinmodel->scale[i]);
pheader->scale_origin[i] = LittleFloat (pinmodel->scale_origin[i]);
pheader->eyeposition[i] = LittleFloat (pinmodel->eyeposition[i]);
}
//
// load the skins
//
pskintype = (daliasskintype_t *)&pinmodel[1];
pskintype = (daliasskintype_t*) Mod_LoadAllSkins (pheader->numskins, pskintype);
//
// load base s and t vertices
//
pinstverts = (stvert_t *)pskintype;
for (i=0 ; i<pheader->numverts ; i++)
{
stverts[i].onseam = LittleLong (pinstverts[i].onseam);
stverts[i].s = LittleLong (pinstverts[i].s);
stverts[i].t = LittleLong (pinstverts[i].t);
}
//
// load triangle lists
//
//.........这里部分代码省略.........
开发者ID:TeamNyx,项目名称:gdk,代码行数:101,代码来源:gl_model.cpp
示例14: R_LoadMDC
/*
=================
R_LoadMDC
=================
*/
qboolean R_LoadMDC(model_t * mod, int lod, void *buffer, int bufferSize, const char *modName)
{
int i, j, k, l;
mdcHeader_t *mdcModel;
md3Frame_t *mdcFrame;
mdcSurface_t *mdcSurf;
md3Shader_t *mdcShader;
md3Triangle_t *mdcTri;
md3St_t *mdcst;
md3XyzNormal_t *mdcxyz;
mdcXyzCompressed_t *mdcxyzComp;
mdcTag_t *mdcTag;
mdcTagName_t *mdcTagName;
mdvModel_t *mdvModel;
mdvFrame_t *frame;
mdvSurface_t *surf, *surface;
srfTriangle_t *tri;
mdvVertex_t *v;
mdvSt_t *st;
mdvTag_t *tag;
mdvTagName_t *tagName;
short *ps;
int version;
int size;
mdcModel = (mdcHeader_t *) buffer;
version = LittleLong(mdcModel->version);
if(version != MDC_VERSION)
{
ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)\n", modName, version, MDC_VERSION);
return qfalse;
}
mod->type = MOD_MESH;
size = LittleLong(mdcModel->ofsEnd);
mod->dataSize += size;
mdvModel = mod->mdv[lod] = ri.Hunk_Alloc(sizeof(mdvModel_t), h_low);
LL(mdcModel->ident);
LL(mdcModel->version);
LL(mdcModel->numFrames);
LL(mdcModel->numTags);
LL(mdcModel->numSurfaces);
LL(mdcModel->ofsFrames);
LL(mdcModel->ofsTags);
LL(mdcModel->ofsSurfaces);
LL(mdcModel->ofsEnd);
LL(mdcModel->ofsEnd);
LL(mdcModel->flags);
LL(mdcModel->numSkins);
if(mdcModel->numFrames < 1)
{
ri.Printf(PRINT_WARNING, "R_LoadMDC: '%s' has no frames\n", modName);
return qfalse;
}
// swap all the frames
mdvModel->numFrames = mdcModel->numFrames;
mdvModel->frames = frame = ri.Hunk_Alloc(sizeof(*frame) * mdcModel->numFrames, h_low);
mdcFrame = (md3Frame_t *) ((byte *) mdcModel + mdcModel->ofsFrames);
for(i = 0; i < mdcModel->numFrames; i++, frame++, mdcFrame++)
{
#if 1
// RB: ET HACK
if(strstr(mod->name, "sherman") || strstr(mod->name, "mg42"))
{
frame->radius = 256;
for(j = 0; j < 3; j++)
{
frame->bounds[0][j] = 128;
frame->bounds[1][j] = -128;
frame->localOrigin[j] = LittleFloat(mdcFrame->localOrigin[j]);
}
}
else
#endif
{
frame->radius = LittleFloat(mdcFrame->radius);
for(j = 0; j < 3; j++)
{
frame->bounds[0][j] = LittleFloat(mdcFrame->bounds[0][j]);
frame->bounds[1][j] = LittleFloat(mdcFrame->bounds[1][j]);
frame->localOrigin[j] = LittleFloat(mdcFrame->localOrigin[j]);
}
}
}
//.........这里部分代码省略.........
开发者ID:kingtiger01,项目名称:OpenMOHAA,代码行数:101,代码来源:tr_model_mdc.c
示例15: AnalyzeBSP
int AnalyzeBSP( int argc, char **argv )
{
abspHeader_t *header;
int size, i, version, offset, length, lumpInt, count;
char ident[ 5 ];
void *lump;
float lumpFloat;
char lumpString[ 1024 ], source[ 1024 ];
qboolean lumpSwap = qfalse;
abspLumpTest_t *lumpTest;
static abspLumpTest_t lumpTests[] =
{
{ sizeof( bspPlane_t ), 6, "IBSP LUMP_PLANES" },
{ sizeof( bspBrush_t ), 1, "IBSP LUMP_BRUSHES" },
{ 8, 6, "IBSP LUMP_BRUSHSIDES" },
{ sizeof( bspBrushSide_t ), 6, "RBSP LUMP_BRUSHSIDES" },
{ sizeof( bspModel_t ), 1, "IBSP LUMP_MODELS" },
{ sizeof( bspNode_t ), 2, "IBSP LUMP_NODES" },
{ sizeof( bspLeaf_t ), 1, "IBSP LUMP_LEAFS" },
{ 104, 3, "IBSP LUMP_DRAWSURFS" },
{ 44, 3, "IBSP LUMP_DRAWVERTS" },
{ 4, 6, "IBSP LUMP_DRAWINDEXES" },
{ 128 * 128 * 3, 1, "IBSP LUMP_LIGHTMAPS" },
{ 256 * 256 * 3, 1, "IBSP LUMP_LIGHTMAPS (256 x 256)" },
{ 512 * 512 * 3, 1, "IBSP LUMP_LIGHTMAPS (512 x 512)" },
{ 0, 0, NULL }
};
/* arg checking */
if( argc < 1 )
{
Sys_Printf( "Usage: q3map -analyze [-lumpswap] [-v] <mapname>\n" );
return 0;
}
/* process arguments */
for( i = 1; i < (argc - 1); i++ )
{
/* -format map|ase|... */
if( !strcmp( argv[ i ], "-lumpswap" ) )
{
Sys_Printf( "Swapped lump structs enabled\n" );
lumpSwap = qtrue;
}
}
/* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) );
Sys_Printf( "Loading %s\n", source );
/* load the file */
size = LoadFile( source, (void**) &header );
if( size == 0 || header == NULL )
{
Sys_Printf( "Unable to load %s.\n", source );
return -1;
}
/* analyze ident/version */
memcpy( ident, header->ident, 4 );
ident[ 4 ] = '\0';
version = LittleLong( header->version );
Sys_Printf( "Identity: %s\n", ident );
Sys_Printf( "Version: %d\n", version );
Sys_Printf( "---------------------------------------\n" );
/* analyze each lump */
for( i = 0; i < 100; i++ )
{
/* call of duty swapped lump pairs */
if( lumpSwap )
{
offset = LittleLong( header->lumps[ i ].length );
length = LittleLong( header->lumps[ i ].offset );
}
/* standard lump pairs */
else
{
offset = LittleLong( header->lumps[ i ].offset );
length = LittleLong( header->lumps[ i ].length );
}
/* extract data */
lump = (byte*) header + offset;
lumpInt = LittleLong( (int) *((int*) lump) );
lumpFloat = LittleFloat( (float) *((float*) lump) );
memcpy( lumpString, (char*) lump, (length < 1024 ? length : 1024) );
lumpString[ 1024 ] = '\0';
/* print basic lump info */
Sys_Printf( "Lump: %d\n", i );
Sys_Printf( "Offset: %d bytes\n", offset );
Sys_Printf( "Length: %d bytes\n", length );
/* only operate on valid lumps */
|
请发表评论