/* =================== idRestoreGame::ReadTraceModel =================== */ void idRestoreGame::ReadTraceModel( idTraceModel &trace ) { int j, k; ReadInt( (int&)trace.type ); ReadInt( trace.numVerts ); for ( j = 0; j < MAX_TRACEMODEL_VERTS; j++ ) { ReadVec3( trace.verts[j] ); } ReadInt( trace.numEdges ); for ( j = 0; j < (MAX_TRACEMODEL_EDGES+1); j++ ) { ReadInt( trace.edges[j].v[0] ); ReadInt( trace.edges[j].v[1] ); ReadVec3( trace.edges[j].normal ); } ReadInt( trace.numPolys ); for ( j = 0; j < MAX_TRACEMODEL_POLYS; j++ ) { ReadVec3( trace.polys[j].normal ); ReadFloat( trace.polys[j].dist ); ReadBounds( trace.polys[j].bounds ); ReadInt( trace.polys[j].numEdges ); for ( k = 0; k < MAX_TRACEMODEL_POLYEDGES; k++ ) { ReadInt( trace.polys[j].edges[k] ); } } ReadVec3( trace.offset ); ReadBounds( trace.bounds ); ReadBool( trace.isConvex ); // padding win32 native structs char tmp[3]; file->Read( tmp, 3 ); }
/* ================ idRestoreGame::ReadRenderEntity ================ */ void idRestoreGame::ReadRenderEntity( renderEntity_t& renderEntity ) { int i; int index; ReadModel( renderEntity.hModel ); ReadInt( renderEntity.entityNum ); ReadInt( renderEntity.bodyId ); ReadBounds( renderEntity.bounds ); // callback is set by class's Restore function renderEntity.callback = NULL; renderEntity.callbackData = NULL; ReadInt( renderEntity.suppressSurfaceInViewID ); ReadInt( renderEntity.suppressShadowInViewID ); ReadInt( renderEntity.suppressShadowInLightID ); ReadInt( renderEntity.allowSurfaceInViewID ); ReadVec3( renderEntity.origin ); ReadMat3( renderEntity.axis ); ReadMaterial( renderEntity.customShader ); ReadMaterial( renderEntity.referenceShader ); ReadSkin( renderEntity.customSkin ); ReadInt( index ); renderEntity.referenceSound = gameSoundWorld->EmitterForIndex( index ); for( i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) { ReadFloat( renderEntity.shaderParms[ i ] ); } for( i = 0; i < MAX_RENDERENTITY_GUI; i++ ) { ReadUserInterface( renderEntity.gui[ i ] ); } // idEntity will restore "cameraTarget", which will be used in idEntity::Present to restore the remoteRenderView renderEntity.remoteRenderView = NULL; renderEntity.joints = NULL; renderEntity.numJoints = 0; ReadFloat( renderEntity.modelDepthHack ); ReadBool( renderEntity.noSelfShadow ); ReadBool( renderEntity.noShadow ); ReadBool( renderEntity.noDynamicInteractions ); ReadBool( renderEntity.weaponDepthHack ); ReadInt( renderEntity.forceUpdate ); ReadInt( renderEntity.timeGroup ); ReadInt( renderEntity.xrayIndex ); }
/** Parses an LP file to build an LPModel instance. \param filename Filename to read data from. \return true model is read successfully. */ bool LPModel::ReadModel(std::string filename) { if (!boost::filesystem::exists(filename)) { cout << "File not found: " << filename; return false; } boost::iostreams::stream<boost::iostreams::mapped_file_source> file(filename); if (!file){ cout << "Cannot open file: " << filename; return false; } std::string *line = new std::string(); bool reconsider; getline(file, *line); linesRead = 0; while (!file.eof()){ reconsider = false; IncLineCount(); if (line->length() == 0 || (line->length() > 0 && ((*line)[0] == ' ' || (*line)[0] == '\\'))) { getline(file, *line); continue; } trim(*line); if (boost::iequals(*line, "Generals") || boost::iequals(*line, "General") || boost::iequals(*line, "Gen")) { line = ReadGenerals(file); reconsider = true; } else if (boost::iequals(*line, "Bounds") || boost::iequals(*line, "Bound")) { line = ReadBounds(file); reconsider = true; } else if (boost::iequals(*line, "Binaries") || boost::iequals(*line, "Binary") || boost::iequals(*line, "Bin")) { line = ReadBinaries(file); reconsider = true; } else if (boost::iequals(*line, "SOS")) { line = ReadSosVars(file); reconsider = true; } else if (boost::iequals(*line, "Subject To") || boost::iequals(*line, "such that") || boost::iequals(*line, "st") || boost::iequals(*line, "S.T.") || boost::iequals(*line, "ST.")) { line = ReadConstraints(file); reconsider = true; } if (!reconsider) { getline(file, *line); } } return true; }