这篇教程C++ LittleFloat函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中LittleFloat函数的典型用法代码示例。如果您正苦于以下问题:C++ LittleFloat函数的具体用法?C++ LittleFloat怎么用?C++ LittleFloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了LittleFloat函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,
示例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,
示例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,
示例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,
示例5: R_LoadMDRstatic 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,
示例6: SwapBSPFile/*=============SwapBSPFileByte 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,
示例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,
示例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,
示例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,
示例10: R_LoadMd3Lodstatic 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,
示例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,
示例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,
示例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,
示例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,
示例15: AnalyzeBSPint 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 */ if( length > 0 ) {//.........这里部分代码省略.........
开发者ID:ChunHungLiu,项目名称:GtkRadiant,代码行数:101,
示例16: R_LoadMDXstatic qboolean R_LoadMDX( model_t *mod, void *buffer, const char *mod_name ){ int i, j; mdxHeader_t *pinmodel, *mdx; mdxFrame_t *frame; short *bframe; mdxBoneInfo_t *bi; int version; int size; int frameSize; pinmodel = ( mdxHeader_t * ) buffer; version = LittleLong( pinmodel->version ); if ( version != MDX_VERSION ) { ri.Printf( PRINT_WARNING, "R_LoadMDX: %s has wrong version (%i should be %i)/n", mod_name, version, MDX_VERSION ); return qfalse; } mod->type = MOD_MDX; size = LittleLong( pinmodel->ofsEnd ); mod->dataSize += size; mdx = mod->mdx = ri.Hunk_Alloc( size, h_low ); memcpy( mdx, buffer, LittleLong( pinmodel->ofsEnd ) ); LL( mdx->ident ); LL( mdx->version ); LL( mdx->numFrames ); LL( mdx->numBones ); LL( mdx->ofsFrames ); LL( mdx->ofsBones ); LL( mdx->ofsEnd ); LL( mdx->torsoParent ); if ( LittleLong( 1 ) != 1 ) { // swap all the frames frameSize = ( int )( sizeof( mdxBoneFrameCompressed_t ) ) * mdx->numBones; for ( i = 0; i < mdx->numFrames; i++ ) { frame = ( mdxFrame_t * )( ( byte * ) mdx + mdx->ofsFrames + i * frameSize + i * sizeof( mdxFrame_t ) ); 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 ] ); } bframe = ( short * )( ( byte * ) mdx + mdx->ofsFrames + i * frameSize + ( ( i + 1 ) * sizeof( mdxFrame_t ) ) ); for ( j = 0; j < mdx->numBones * sizeof( mdxBoneFrameCompressed_t ) / sizeof( short ); j++ ) { ( ( short * ) bframe ) [ j ] = LittleShort( ( ( short * ) bframe ) [ j ] ); } } // swap all the bones for ( i = 0; i < mdx->numBones; i++ ) { bi = ( mdxBoneInfo_t * )( ( byte * ) mdx + mdx->ofsBones + i * sizeof( mdxBoneInfo_t ) ); LL( bi->parent ); bi->torsoWeight = LittleFloat( bi->torsoWeight ); bi->parentDist = LittleFloat( bi->parentDist ); LL( bi->flags ); } } return qtrue;}
开发者ID:Sixthly,项目名称:Unvanquished,代码行数:76,
示例17: LittleLong/*=================idRenderModelMD3::InitFromFile=================*/void idRenderModelMD3::InitFromFile( const char *fileName ) { int i, j; md3Header_t *pinmodel; md3Frame_t *frame; md3Surface_t *surf; md3Shader_t *shader; md3Triangle_t *tri; md3St_t *st; md3XyzNormal_t *xyz; md3Tag_t *tag; void *buffer; int version; int size; name = fileName; size = fileSystem->ReadFile( fileName, &buffer, NULL ); if (!size || size<0 ) { return; } pinmodel = (md3Header_t *)buffer; version = LittleLong (pinmodel->version); if (version != MD3_VERSION) { fileSystem->FreeFile( buffer ); common->Warning( "InitFromFile: %s has wrong version (%i should be %i)", fileName, version, MD3_VERSION); return; } size = LittleLong(pinmodel->ofsEnd); dataSize += size; md3 = (md3Header_t *)Mem_Alloc( size ); memcpy (md3, buffer, LittleLong(pinmodel->ofsEnd) ); LL(md3->ident); LL(md3->version); LL(md3->numFrames); LL(md3->numTags); LL(md3->numSurfaces); LL(md3->ofsFrames); LL(md3->ofsTags); LL(md3->ofsSurfaces); LL(md3->ofsEnd); if ( md3->numFrames < 1 ) { common->Warning( "InitFromFile: %s has no frames", fileName ); fileSystem->FreeFile( buffer ); return; } // swap all the frames frame = (md3Frame_t *) ( (byte *)md3 + md3->ofsFrames ); for ( i = 0 ; i < md3->numFrames ; i++, frame++) { 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] ); } } // swap all the tags tag = (md3Tag_t *) ( (byte *)md3 + md3->ofsTags ); for ( i = 0 ; i < md3->numTags * md3->numFrames ; i++, tag++) { for ( 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 surf = (md3Surface_t *) ( (byte *)md3 + md3->ofsSurfaces ); for ( i = 0 ; i < md3->numSurfaces ; i++) { 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( "InitFromFile: %s has more than %i verts on a surface (%i)", fileName, SHADER_MAX_VERTEXES, surf->numVerts );//.........这里部分代码省略.........
开发者ID:4DA,项目名称:doom3.gpl,代码行数:101,
示例18: CL_GetMessage/*====================CL_GetMessageHandles recording and playback of demos, on top of NET_ code====================*/int CL_GetMessage (void){ int r, i; float f; if (cls.demoplayback) { // decide if it is time to grab the next message if (cls.signon == SIGNONS) // allways grab until fully connected { if (cls.timedemo) { if (host_framecount == cls.td_lastframe) return 0; // allready read this frame's message cls.td_lastframe = host_framecount; // if this is the second frame, grab the real td_starttime // so the bogus time on the first frame doesn't count if (host_framecount == cls.td_startframe + 1) cls.td_starttime = realtime; } else if ( /* cl.time > 0 && */ cl.time <= cl.mtime[0]) { return 0; // don't need another message yet } } // get the next message// if(intro_playing&&num_intro_msg>0&&num_intro_msg<21)// V_DarkFlash_f();//Fade into demo/* if(skip_start&&num_intro_msg>3) { while(num_intro_msg<1110) { fread (&net_message.cursize, 4, 1, cls.demofile); VectorCopy (cl.mviewangles[0], cl.mviewangles[1]); for (i=0 ; i<3 ; i++) { r = fread (&f, 4, 1, cls.demofile); cl.mviewangles[0][i] = LittleFloat (f); } net_message.cursize = LittleLong (net_message.cursize); num_intro_msg++; if (net_message.cursize > MAX_MSGLEN) Sys_Error ("Demo message > MAX_MSGLEN"); r = fread (net_message.data, net_message.cursize, 1, cls.demofile); if (r != 1) { CL_StopPlayback (); return 0; } if(num_intro_msg==174|| num_intro_msg==178|| num_intro_msg==428|| num_intro_msg==553|| num_intro_msg==1012) break; } if(num_intro_msg==1110) skip_start=false; } else {*/ fread (&net_message.cursize, 4, 1, cls.demofile); VectorCopy (cl.mviewangles[0], cl.mviewangles[1]); for (i=0 ; i<3 ; i++) { r = fread (&f, 4, 1, cls.demofile); cl.mviewangles[0][i] = LittleFloat (f); } net_message.cursize = LittleLong (net_message.cursize); num_intro_msg++; if (net_message.cursize > MAX_MSGLEN) Sys_Error ("Demo message > MAX_MSGLEN"); r = fread (net_message.data, net_message.cursize, 1, cls.demofile); if (r != 1) { CL_StopPlayback (); return 0; }// }// if (cls.demorecording)// CL_WriteDemoMessage (); return 1; } while (1) { r = NET_GetMessage (cls.netcon);//.........这里部分代码省略.........
开发者ID:elhobbs,项目名称:hexen2,代码行数:101,
示例19: Mod_Sprite_SharedSetupstatic void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version, const unsigned int *palette, qboolean additive){ int i, j, groupframes, realframes, x, y, origin[2], width, height; qboolean fullbright; dspriteframetype_t *pinframetype; dspriteframe_t *pinframe; dspritegroup_t *pingroup; dspriteinterval_t *pinintervals; skinframe_t *skinframe; float modelradius, interval; char name[MAX_QPATH], fogname[MAX_QPATH]; const void *startframes; int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | ((gl_texturecompression.integer && gl_texturecompression_sprites.integer) ? TEXF_COMPRESS : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_ALPHA | TEXF_CLAMP; modelradius = 0; if (loadmodel->numframes < 1) Host_Error ("Mod_Sprite_SharedSetup: Invalid # of frames: %d", loadmodel->numframes); // LordHavoc: hack to allow sprites to be non-fullbright fullbright = true; for (i = 0;i < MAX_QPATH && loadmodel->name[i];i++) if (loadmodel->name[i] == '!') fullbright = false;//// load the frames// startframes = datapointer; realframes = 0; for (i = 0;i < loadmodel->numframes;i++) { pinframetype = (dspriteframetype_t *)datapointer; datapointer += sizeof(dspriteframetype_t); if (LittleLong (pinframetype->type) == SPR_SINGLE) groupframes = 1; else { pingroup = (dspritegroup_t *)datapointer; datapointer += sizeof(dspritegroup_t); groupframes = LittleLong(pingroup->numframes); datapointer += sizeof(dspriteinterval_t) * groupframes; } for (j = 0;j < groupframes;j++) { pinframe = (dspriteframe_t *)datapointer; if (version == SPRITE32_VERSION) datapointer += sizeof(dspriteframe_t) + LittleLong(pinframe->width) * LittleLong(pinframe->height) * 4; else //if (version == SPRITE_VERSION || version == SPRITEHL_VERSION) datapointer += sizeof(dspriteframe_t) + LittleLong(pinframe->width) * LittleLong(pinframe->height); } realframes += groupframes; } loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); loadmodel->sprite.sprdata_frames = (mspriteframe_t *)Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * realframes); loadmodel->num_textures = realframes; loadmodel->num_texturesperskin = 1; loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, sizeof(texture_t) * loadmodel->num_textures); datapointer = (unsigned char *)startframes; realframes = 0; for (i = 0;i < loadmodel->numframes;i++) { pinframetype = (dspriteframetype_t *)datapointer; datapointer += sizeof(dspriteframetype_t); if (LittleLong (pinframetype->type) == SPR_SINGLE) { groupframes = 1; interval = 0.1f; } else { pingroup = (dspritegroup_t *)datapointer; datapointer += sizeof(dspritegroup_t); groupframes = LittleLong(pingroup->numframes); pinintervals = (dspriteinterval_t *)datapointer; datapointer += sizeof(dspriteinterval_t) * groupframes; interval = LittleFloat(pinintervals[0].interval); if (interval < 0.01f) Host_Error("Mod_Sprite_SharedSetup: invalid interval"); } dpsnprintf(loadmodel->animscenes[i].name, sizeof(loadmodel->animscenes[i].name), "frame %i", i); loadmodel->animscenes[i].firstframe = realframes; loadmodel->animscenes[i].framecount = groupframes; loadmodel->animscenes[i].framerate = 1.0f / interval; loadmodel->animscenes[i].loop = true; for (j = 0;j < groupframes;j++) { pinframe = (dspriteframe_t *)datapointer; datapointer += sizeof(dspriteframe_t);//.........这里部分代码省略.........
开发者ID:CyberSys,项目名称:darkplaces,代码行数:101,
示例20: ParseMesh/*===============ParseMesh===============*/static void ParseMesh ( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, world_t &worldData, int index) { srfGridMesh_t *grid; int i, j, k; int width, height, numPoints; MAC_STATIC drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE]; int lightmapNum[MAXLIGHTMAPS]; vec3_t bounds[2]; vec3_t tmpVec; static surfaceType_t skipData = SF_SKIP; 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; } // we may have a nodraw surface, because they might still need to // be around for movement clipping if ( worldData.shaders[ LittleLong( ds->shaderNum ) ].surfaceFlags & SURF_NODRAW ) { surf->data = &skipData; return; } width = LittleLong( ds->patchWidth ); height = LittleLong( ds->patchHeight ); verts += LittleLong( ds->firstVert ); numPoints = width * height; for ( i = 0 ; i < numPoints ; i++ ) { for ( j = 0 ; j < 3 ; j++ ) { points[i].xyz[j] = LittleFloat( verts[i].xyz[j] ); points[i].normal[j] = LittleFloat( verts[i].normal[j] ); } for ( j = 0 ; j < 2 ; j++ ) { points[i].st[j] = LittleFloat( verts[i].st[j] ); for(k=0;k<MAXLIGHTMAPS;k++) { points[i].lightmap[k][j] = LittleFloat( verts[i].lightmap[k][j] ); } } for(k=0;k<MAXLIGHTMAPS;k++) { R_ColorShiftLightingBytes( verts[i].color[k], points[i].color[k] ); } } // pre-tesseleate grid = R_SubdividePatchToGrid( width, height, points ); surf->data = (surfaceType_t *)grid; // copy the level of detail origin, which is the center // of the group of all curves that must subdivide the same // to avoid cracking for ( i = 0 ; i < 3 ; i++ ) { bounds[0][i] = LittleFloat( ds->lightmapVecs[0][i] ); bounds[1][i] = LittleFloat( ds->lightmapVecs[1][i] ); } VectorAdd( bounds[0], bounds[1], bounds[1] ); VectorScale( bounds[1], 0.5f, grid->lodOrigin ); VectorSubtract( bounds[0], grid->lodOrigin, tmpVec ); grid->lodRadius = VectorLength( tmpVec );}
开发者ID:Delfin1,项目名称:OpenJK,代码行数:83,
示例21: R_LoadMD3/*=================R_LoadMD3=================*/static qboolean R_LoadMD3 (model_t *mod, int lod, void *buffer, const char *mod_name ) { int i, j; md3Header_t *pinmodel; md3Frame_t *frame; md3Surface_t *surf; md3Shader_t *shader; md3Triangle_t *tri; md3St_t *st; md3XyzNormal_t *xyz; md3Tag_t *tag; int version; int size; pinmodel = (md3Header_t *)buffer; version = LittleLong (pinmodel->version); if (version != MD3_VERSION) { ri.Printf( PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)/n", mod_name, version, MD3_VERSION); return qfalse; } mod->type = MOD_MESH; size = LittleLong(pinmodel->ofsEnd); mod->dataSize += size; mod->md3[lod] = ri.Hunk_Alloc( size, h_low ); Com_Memcpy (mod->md3[lod], buffer, LittleLong(pinmodel->ofsEnd) ); LL(mod->md3[lod]->ident); LL(mod->md3[lod]->version); LL(mod->md3[lod]->numFrames); LL(mod->md3[lod]->numTags); LL(mod->md3[lod]->numSurfaces); LL(mod->md3[lod]->ofsFrames); LL(mod->md3[lod]->ofsTags); LL(mod->md3[lod]->ofsSurfaces); LL(mod->md3[lod]->ofsEnd); if ( mod->md3[lod]->numFrames < 1 ) { ri.Printf( PRINT_WARNING, "R_LoadMD3: %s has no frames/n", mod_name ); return qfalse; } // swap all the frames frame = (md3Frame_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsFrames ); for ( i = 0 ; i < mod->md3[lod]->numFrames ; i++, frame++) { 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] ); } } // swap all the tags tag = (md3Tag_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsTags ); for ( i = 0 ; i < mod->md3[lod]->numTags * mod->md3[lod]->numFrames ; i++, tag++) { for ( 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 surf = (md3Surface_t *) ( (byte *)mod->md3[lod] + mod->md3[lod]->ofsSurfaces ); for ( i = 0 ; i < mod->md3[lod]->numSurfaces ; i++) { 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 ) { ri.Error (ERR_DROP, "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 ) { ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)", mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles ); } // change to surface identifier surf->ident = SF_MD3; // lowercase the surface name so skin compares are faster//.........这里部分代码省略.........
开发者ID:AlienHoboken,项目名称:Tremulous-W-Server,代码行数:101,
示例22: R_LoadMD4static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { int i, j, k, lodindex; md4Header_t *pinmodel, *md4; md4Frame_t *frame; md4LOD_t *lod; md4Surface_t *surf; md4Triangle_t *tri; md4Vertex_t *v; int version; int size; shader_t *sh; int frameSize; pinmodel = (md4Header_t *)buffer; version = LittleLong (pinmodel->version); if (version != MD4_VERSION) { ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has wrong version (%i should be %i)/n", mod_name, version, MD4_VERSION); return qfalse; } mod->type = MOD_MD4; size = LittleLong(pinmodel->ofsEnd); mod->dataSize += size; md4 = mod->md4 = ri.Hunk_Alloc( size, h_low ); Com_Memcpy(md4, buffer, size); LL(md4->ident); LL(md4->version); LL(md4->numFrames); LL(md4->numBones); LL(md4->numLODs); LL(md4->ofsFrames); LL(md4->ofsLODs); md4->ofsEnd = size; if ( md4->numFrames < 1 ) { ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has no frames/n", mod_name ); return qfalse; } // we don't need to swap tags in the renderer, they aren't used // swap all the frames frameSize = (size_t)( &((md4Frame_t *)0)->bones[ md4->numBones ] ); for ( i = 0 ; i < md4->numFrames ; i++, frame++) { frame = (md4Frame_t *) ( (byte *)md4 + md4->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] ); } for ( j = 0 ; j < md4->numBones * sizeof( md4Bone_t ) / 4 ; j++ ) { ((float *)frame->bones)[j] = LittleFloat( ((float *)frame->bones)[j] ); } } // swap all the LOD's lod = (md4LOD_t *) ( (byte *)md4 + md4->ofsLODs ); for ( lodindex = 0 ; lodindex < md4->numLODs ; lodindex++ ) { // swap all the surfaces surf = (md4Surface_t *) ( (byte *)lod + lod->ofsSurfaces ); for ( i = 0 ; i < lod->numSurfaces ; i++) { LL(surf->ident); LL(surf->numTriangles); LL(surf->ofsTriangles); LL(surf->numVerts); LL(surf->ofsVerts); LL(surf->ofsEnd); if ( surf->numVerts > SHADER_MAX_VERTEXES ) { ri.Error (ERR_DROP, "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 ) { ri.Error (ERR_DROP, "R_LoadMD3: %s has more than %i triangles on a surface (%i)", mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles ); } // change to surface identifier surf->ident = SF_MD4; // lowercase the surface name so skin compares are faster Q_strlwr( surf->name ); // register the shaders sh = R_FindShader( surf->shader, LIGHTMAP_NONE, qtrue ); if ( sh->defaultShader ) { surf->shaderIndex = 0; } else { surf->shaderIndex = sh->index; } // swap all the triangles tri = (md4Triangle_t *) ( (byte *)surf + surf->ofsTriangles ); for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) {//.........这里部分代码省略.........
开发者ID:AlienHoboken,项目名称:Tremulous-W-Server,代码行数:101,
示例23: CL_GetMessage/*====================CL_GetMessageHandles recording and playback of demos, on top of NET_ code====================*/int CL_GetMessage (void){ int r, i; float f; if (cls.demoplayback) { // decide if it is time to grab the next message if (cls.signon == SIGNONS) // allways grab until fully connected { if (cls.timedemo) { if (host_framecount == cls.td_lastframe) return 0; // allready read this frame's message cls.td_lastframe = host_framecount; // if this is the second frame, grab the real td_starttime // so the bogus time on the first frame doesn't count if (host_framecount == cls.td_startframe + 1) cls.td_starttime = realtime; } else if ( /* cl.time > 0 && */ cl.time <= cl.mtime[0]) { return 0; // don't need another message yet } } // get the next message Sys_FileRead(cls.demofile, &net_message.cursize, 4); VectorCopy (cl.mviewangles[0], cl.mviewangles[1]); for (i=0 ; i<3 ; i++) { r = Sys_FileRead(cls.demofile, &f, 4) / 4; cl.mviewangles[0][i] = LittleFloat (f); } net_message.cursize = LittleLong (net_message.cursize); if (net_message.cursize > MAX_MSGLEN) Sys_Error ("Demo message (0x%08x) > MAX_MSGLEN (%d)", net_message.cursize, MAX_MSGLEN); r = Sys_FileRead(cls.demofile, net_message.data, net_message.cursize) / net_message.cursize; if (r != 1) { CL_StopPlayback (); return 0; } return 1; } while (1) { r = NET_GetMessage (cls.netcon); if (r != 1 && r != 2) return r; // discard nop keepalive message if (net_message.cursize == 1 && net_message.data[0] == svc_nop) Con_Printf ("<-- server to client keepalive/n"); else break; } if (cls.demorecording) CL_WriteDemoMessage (); return r;}
开发者ID:atphalix,项目名称:PSPCube,代码行数:74,
示例24: 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; int size; daliasframetype_t *pframetype; daliasskintype_t *pskintype; int start, end, total; if (!strcmp(loadmodel->name, "progs/player.mdl") || !strcmp(loadmodel->name, "progs/eyes.mdl")) { unsigned short crc; byte *p; int len; char st[40]; CRC_Init(&crc); for (len = com_filesize, p = buffer; len; len--, p++) CRC_ProcessByte(&crc, *p); sprintf(st, "%d", (int) crc); Info_SetValueForKey (cls.userinfo, !strcmp(loadmodel->name, "progs/player.mdl") ? pmodel_name : emodel_name, st, MAX_INFO_STRING); if (cls.state >= ca_connected) { MSG_WriteByte (&cls.netchan.message, clc_stringcmd); sprintf(st, "setinfo %s %d", !strcmp(loadmodel->name, "progs/player.mdl") ? pmodel_name : emodel_name, (int)crc); SZ_Print (&cls.netchan.message, st); } } 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 = 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 = 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]);//.........这里部分代码省略.........
开发者ID:ACIIL,项目名称:Quake,代码行数:101,
示例25: SwapBSPFile/*=============SwapBSPFileByte swaps all data in a bsp file.=============*/void SwapBSPFile (qboolean todisk){ int i, j, c; dmodel_t *d; dmiptexlump_t *mtl; // models for (i=0 ; i<nummodels ; i++) { d = &dmodels[i]; for (j=0 ; j<MAX_MAP_HULLS ; j++) d->headnode[j] = LittleLong (d->headnode[j]); d->visleafs = LittleLong (d->visleafs); d->firstface = LittleLong (d->firstface); d->numfaces = LittleLong (d->numfaces); for (j=0 ; j<3 ; j++) { d->mins[j] = LittleFloat(d->mins[j]); d->maxs[j] = LittleFloat(d->maxs[j]); d->origin[j] = LittleFloat(d->origin[j]); } }//// vertexes// for (i=0 ; i<numvertexes ; i++) { for (j=0 ; j<3 ; j++) dvertexes[i].point[j] = LittleFloat (dvertexes[i].point[j]); } //// planes// for (i=0 ; i<numplanes ; i++) { for (j=0 ; j<3 ; j++) dplanes[i].normal[j] = LittleFloat (dplanes[i].normal[j]); dplanes[i].dist = LittleFloat (dplanes[i].dist); dplanes[i].type = LittleLong (dplanes[i].type); } //// texinfos// for (i=0 ; i<numtexinfo ; i++) { for (j=0 ; j<8 ; j++) texinfo[i].vecs[0][j] = LittleFloat (texinfo[i].vecs[0][j]); texinfo[i].miptex = LittleLong (texinfo[i].miptex); texinfo[i].flags = LittleLong (texinfo[i].flags); } //// faces// for (i=0 ; i<numfaces ; i++) { dfaces[i].texinfo = LittleShort (dfaces[i].texinfo); dfaces[i].planenum = LittleShort (dfaces[i].planenum); dfaces[i].side = LittleShort (dfaces[i].side); dfaces[i].lightofs = LittleLong (dfaces[i].lightofs); dfaces[i].firstedge = LittleLong (dfaces[i].firstedge); dfaces[i].numedges = LittleShort (dfaces[i].numedges); }//// nodes// for (i=0 ; i<numnodes ; i++) { dnodes[i].planenum = LittleLong (dnodes[i].planenum); for (j=0 ; j<3 ; j++) { dnodes[i].mins[j] = LittleShort (dnodes[i].mins[j]); dnodes[i].maxs[j] = LittleShort (dnodes[i].maxs[j]); } dnodes[i].children[0] = LittleShort (dnodes[i].children[0]); dnodes[i].children[1] = LittleShort (dnodes[i].children[1]); dnodes[i].firstface = LittleShort (dnodes[i].firstface); dnodes[i].numfaces = LittleShort (dnodes[i].numfaces); }//// leafs// for (i=0 ; i<numleafs ; i++) {//.........这里部分代码省略.........
开发者ID:aniruddha-loya,项目名称:NS,代码行数:101,
示例26: CL_ReadDemoMessage/*====================CL_ReadDemoMessageHandles playback of demos====================*/void CL_ReadDemoMessage(void){ int i; float f; if (!cls.demoplayback) return; // LordHavoc: pausedemo if (cls.demopaused) return; for (;;) { // decide if it is time to grab the next message // always grab until fully connected if (cls.signon == SIGNONS) { if (cls.timedemo) { cls.td_frames++; cls.td_onesecondframes++; // if this is the first official frame we can now grab the real // td_starttime so the bogus time on the first frame doesn't // count against the final report if (cls.td_frames == 0) { cls.td_starttime = realtime; cls.td_onesecondnexttime = cl.time + 1; cls.td_onesecondrealtime = realtime; cls.td_onesecondframes = 0; cls.td_onesecondminfps = 0; cls.td_onesecondmaxfps = 0; cls.td_onesecondavgfps = 0; cls.td_onesecondavgcount = 0; } if (cl.time >= cls.td_onesecondnexttime) { double fps = cls.td_onesecondframes / (realtime - cls.td_onesecondrealtime); if (cls.td_onesecondavgcount == 0) { cls.td_onesecondminfps = fps; cls.td_onesecondmaxfps = fps; } cls.td_onesecondrealtime = realtime; cls.td_onesecondminfps = min(cls.td_onesecondminfps, fps); cls.td_onesecondmaxfps = max(cls.td_onesecondmaxfps, fps); cls.td_onesecondavgfps += fps; cls.td_onesecondavgcount++; cls.td_onesecondframes = 0; cls.td_onesecondnexttime++; } } else if (cl.time <= cl.mtime[0]) { // don't need another message yet return; } } // get the next message FS_Read(cls.demofile, &cl_message.cursize, 4); cl_message.cursize = LittleLong(cl_message.cursize); if(cl_message.cursize & DEMOMSG_CLIENT_TO_SERVER) // This is a client->server message! Ignore for now! { // skip over demo packet FS_Seek(cls.demofile, 12 + (cl_message.cursize & (~DEMOMSG_CLIENT_TO_SERVER)), SEEK_CUR); continue; } if (cl_message.cursize > cl_message.maxsize) { Con_Printf("Demo message (%i) > cl_message.maxsize (%i)", cl_message.cursize, cl_message.maxsize); cl_message.cursize = 0; CL_Disconnect(); return; } VectorCopy(cl.mviewangles[0], cl.mviewangles[1]); for (i = 0;i < 3;i++) { FS_Read(cls.demofile, &f, 4); cl.mviewangles[0][i] = LittleFloat(f); } if (FS_Read(cls.demofile, cl_message.data, cl_message.cursize) == cl_message.cursize) { MSG_BeginReading(&cl_message); CL_ParseServerMessage(); if (cls.signon != SIGNONS) Cbuf_Execute(); // immediately execute svc_stufftext if in the demo before connect! // In case the demo contains a "svc_disconnect" message if (!cls.demoplayback)//.........这里部分代码省略.........
开发者ID:chekoopa,项目名称:darkplaces-rus,代码行数:101,
示例27: Mod_LoadSkeletalModel//.........这里部分代码省略......... break; } } if( !vposition || !vtexcoord || !(vblendindices_byte || vblendindexes_int) || !(vblendweights_byte || vblendweights_float) ) { ri.Com_Printf( S_COLOR_RED "ERROR: %s is missing vertex array data/n", mod->name ); goto error; } // load joints memsize = 0; memsize += sizeof( bonepose_t ) * header->num_joints; pmem = Mod_Malloc( mod, memsize ); baseposes = ( void * )pmem; pmem += sizeof( *baseposes ); memsize = 0; memsize += sizeof( mskbone_t ) * header->num_joints; memsize += sizeof( bonepose_t ) * header->num_joints; pmem = Mod_Malloc( mod, memsize ); poutmodel->numbones = header->num_joints; poutmodel->bones = ( void * )pmem; pmem += sizeof( *poutmodel->bones ) * poutmodel->numbones; poutmodel->invbaseposes = ( void * )pmem; pmem += sizeof( *poutmodel->invbaseposes ) * poutmodel->numbones; joints = ( iqmjoint_t * )( pbase + header->ofs_joints ); for( i = 0; i < poutmodel->numbones; i++ ) { joints[i].name = LittleLong( joints[i].name ); joints[i].parent = LittleLong( joints[i].parent ); for( j = 0; j < 3; j++ ) { joints[i].translate[j] = LittleFloat( joints[i].translate[j] ); joints[i].rotate[j] = LittleFloat( joints[i].rotate[j] ); joints[i].scale[j] = LittleFloat( joints[i].scale[j] ); } if( joints[i].parent >= (int)i ) { ri.Com_Printf( S_COLOR_RED "ERROR: %s bone[%i].parent(%i) >= %i/n", mod->name, i, joints[i].parent, i ); goto error; } poutmodel->bones[i].name = texts + joints[i].name; poutmodel->bones[i].parent = joints[i].parent; DualQuat_FromQuat3AndVector( joints[i].rotate, joints[i].translate, baseposes[i].dualquat ); // scale is unused // reconstruct invserse bone pose if( joints[i].parent >= 0 ) { bonepose_t bp, *pbp; bp = baseposes[i]; pbp = &baseposes[joints[i].parent]; DualQuat_Multiply( pbp->dualquat, bp.dualquat, baseposes[i].dualquat ); } DualQuat_Copy( baseposes[i].dualquat, poutmodel->invbaseposes[i].dualquat ); DualQuat_Invert( poutmodel->invbaseposes[i].dualquat ); }
开发者ID:codetwister,项目名称:qfusion,代码行数:65,
注:本文中的LittleFloat函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ LittleShort函数代码示例 C++ Listen函数代码示例 |