/* ================ idRestoreGame::ReadRefSound ================ */ void idRestoreGame::ReadRefSound( refSound_t &refSound ) { int index; ReadInt( index ); refSound.referenceSound = gameSoundWorld->EmitterForIndex( index ); ReadVec3( refSound.origin ); ReadInt( refSound.listenerId ); ReadSoundShader( refSound.shader ); ReadFloat( refSound.diversity ); ReadBool( refSound.waitfortrigger ); ReadFloat( refSound.parms.minDistance ); ReadFloat( refSound.parms.maxDistance ); ReadFloat( refSound.parms.volume ); ReadFloat( refSound.parms.shakes ); ReadInt( refSound.parms.soundShaderFlags ); ReadInt( refSound.parms.soundClass ); }
void KfmEvent::Read( istream & in, unsigned int version ) { id = ReadUInt(in); type = ReadUInt(in); if ( type != 5 ) { unk_float = ReadFloat(in); event_strings.resize(ReadUInt(in)); for ( vector<KfmEventString>::iterator it = event_strings.begin(); it != event_strings.end(); it++ ) it->Read(in, version); unk_int3 = ReadUInt(in); }; };
void Serializer::InitForReading(void *data, int data_size) { ASSERT(mode==SERIALIZE_NONE); mode=SERIALIZE_READ; buffer=data; buffer_size=data_size; ReadFloat(ver); //shrugs }
static void ProcessTriangles() { int numvertices; float x, y, z; numvertices = ReadInt(); glBegin(GL_TRIANGLES); while (numvertices) { x = ReadFloat(); y = ReadFloat(); z = ReadFloat(); glVertex3f(x, y, z); numvertices--; } glEnd(); }
float readTeleopForwards() { TFileHandle hFileHandle; TFileIOResult nIoResult; float result=0; short nFileSize=sizeof(baseHeading); OpenRead(hFileHandle, nIoResult, TELEOPFORWARDSDAT, nFileSize); ReadFloat(hFileHandle, nIoResult, result); Close(hFileHandle, nIoResult); return result; }
//----------------------------------------------------------------------------------------------- Vector2 ResourceStream::ReadVector2() { Vector2 returnValue; if( m_internalFormat == RESOURCE_STREAM_FORMAT_BINARY ) { ReadType( returnValue ); // DEBUGGING - { int q = 5; } //ConsolePrintf( "ReadVector2 at offset %d, value was (%g,%g)\n", m_currentReadOffset, returnValue.x, returnValue.y ); return returnValue; } ReadExpectedToken( "Vector2" ); ReadExpectedToken( '(' ); returnValue.x = ReadFloat(); ReadExpectedToken( ',' ); returnValue.y = ReadFloat(); ReadExpectedToken( ')' ); return returnValue; }
/// Read SMFHeader head from file void CSMFMapFile::ReadMapHeader(SMFHeader& head, CFileHandler& file) { file.Read(head.magic,sizeof(head.magic)); head.version = ReadInt(file); head.mapid = ReadInt(file); head.mapx = ReadInt(file); head.mapy = ReadInt(file); head.squareSize = ReadInt(file); head.texelPerSquare = ReadInt(file); head.tilesize = ReadInt(file); head.minHeight = ReadFloat(file); head.maxHeight = ReadFloat(file); head.heightmapPtr = ReadInt(file); head.typeMapPtr = ReadInt(file); head.tilesPtr = ReadInt(file); head.minimapPtr = ReadInt(file); head.metalmapPtr = ReadInt(file); head.featurePtr = ReadInt(file); head.numExtraHeaders = ReadInt(file); }
/* =================== idRestoreGame::ReadContactInfo =================== */ void idRestoreGame::ReadContactInfo( contactInfo_t &contactInfo ) { ReadInt( (int &)contactInfo.type ); ReadVec3( contactInfo.point ); ReadVec3( contactInfo.normal ); ReadFloat( contactInfo.dist ); ReadInt( contactInfo.contents ); ReadMaterial( contactInfo.material ); ReadInt( contactInfo.modelFeature ); ReadInt( contactInfo.trmFeature ); ReadInt( contactInfo.entityNum ); ReadInt( contactInfo.id ); }
/****************************************************************************** * read point information and load it * point information will be read as x,y,z float coordinates *****************************************************************************/ int ReadPoint(point *p) { if (!ReadFloat(&p->x)) { PrintError("Number expected"); return 0; } SkipWhitespace(); if (!ReadFloat(&p->y)) { PrintError("Number expected"); return 0; } SkipWhitespace(); if (!ReadFloat(&p->z)) { PrintError("Number expected"); return 0; } return 1; }
void L3DS::ReadMap(const LChunk &chunk, LMap& map) { LChunk child; char str[20]; GotoChunk(chunk); child = ReadChunk(); while (child.end <= chunk.end) { switch (child.id) { case INT_PERCENTAGE: map.strength = ReadPercentage(child); break; case MAT_MAPNAME: ReadASCIIZ(str, 20); strcpy(map.mapName, str); break; case MAT_MAP_TILING: map.tiling = ReadShort(); break; case MAT_MAP_USCALE: map.uScale = ReadFloat(); break; case MAT_MAP_VSCALE: map.vScale = ReadFloat(); break; case MAT_MAP_UOFFSET: map.uOffset = ReadFloat(); break; case MAT_MAP_VOFFSET: map.vOffset = ReadFloat(); break; case MAT_MAP_ANG: map.angle = ReadFloat(); break; } SkipChunk(child); child = ReadChunk(); } }
LColor3 L3DS::ReadColor(const LChunk &chunk) { LColor3 col = black; GotoChunk(chunk); switch (chunk.id) { case COLOR_F: col.r = ReadFloat(); col.g = ReadFloat(); col.b = ReadFloat(); break; case COLOR_24: col.r = ReadByte()/255.0f; col.g = ReadByte()/255.0f; col.b = ReadByte()/255.0f; break; case LIN_COLOR_F: col.r = ReadFloat(); col.g = ReadFloat(); col.b = ReadFloat(); break; case LIN_COLOR_24: col.r = ReadByte()/255.0f; col.g = ReadByte()/255.0f; col.b = ReadByte()/255.0f; break; default: fprintf(stderr, "L3DS::ReadColor - error this is not a color chunk"); } return col; }
/* ================ idRestoreGame::ReadRenderView ================ */ void idRestoreGame::ReadRenderView( renderView_t &view ) { int i; ReadInt( view.viewID ); ReadInt( view.x ); ReadInt( view.y ); ReadInt( view.width ); ReadInt( view.height ); ReadFloat( view.fov_x ); ReadFloat( view.fov_y ); ReadVec3( view.vieworg ); ReadMat3( view.viewaxis ); ReadBool( view.cramZNear ); ReadInt( view.time ); for( i = 0; i < MAX_GLOBAL_SHADER_PARMS; i++ ) { ReadFloat( view.shaderParms[ i ] ); } }
void VFSPlugin_LWO::read_diff(long length) { // Get a ptr to the last surface (hence the current one) Material *m = m_vb->GetMaterial(); // Read the diffuse value m->diffuse = ReadFloat(); // Read the envelope long vxlength; long envelope = ReadVariableLength(&vxlength); length -= (vxlength + sizeof(float)*3); }
void VFSPlugin_LWO::read_shrp(long length) { // Get a ptr to the last surface (hence the current one) Material *m = m_vb->GetMaterial(); // Read how sharp the surface is m->sharpness = ReadFloat(); // Read the envelope long vxlength; long envelope = ReadVariableLength(&vxlength); length -= (vxlength + sizeof(float)*3); }
//--------------------------------------------------------------------- // Read all parameters //--------------------------------------------------------------------- int CNeedleMark::Read(SStream *stream, Tag tag) { if (0 == mgg) gtfo("<CNeedleMark: need mother gauge"); switch (tag) { case 'bmap': nedl.SetGauge(mgg); nedl.ReadBMAP(stream); return TAG_READ; //--- rotation center -------------- case 'rotc': nedl.ReadROTC(stream); return TAG_READ; //--- minimum value ---------------- case 'dmin': ReadFloat(&dmin, stream); return TAG_READ; //--- maximum value ---------------- case 'dmax': ReadFloat(&dmax, stream); return TAG_READ; //--- Clamp values ----------------- case 'clmp': ReadFloat(&dmin,stream); ReadFloat(&dmax,stream); return TAG_READ; //--- Current value ---------------- case 'sang': case 'dval': ReadFloat(&dval,stream); SaveValue(dval); return TAG_READ; //--- Knob ------------------------- case 'knob': ReadKNOB(stream); return TAG_READ; } WARNINGLOG("CNeedleMark: tag %s unknowned",TagToString(tag)); return TAG_IGNORED; }
float L3DS::ReadPercentage(const LChunk &chunk) { GotoChunk(chunk); switch (chunk.id) { case INT_PERCENTAGE: return (ReadShort()/100.0f); case FLOAT_PERCENTAGE: return ReadFloat(); } fprintf(stderr, "L3DS::ReadPercentage - error, the chunk is not a percentage chunk"); return 0; }
void VFSPlugin_LWO::read_bump(long length) { // Get a ptr to the last surface (hence the current one) Material *m = m_vb->GetMaterial(); // Read the bump intensity of the surface m->bump = ReadFloat(); // Read the envelope long vxlength; long envelope = ReadVariableLength(&vxlength); length -= (vxlength + sizeof(float)*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 ); }
/************* * DESCRIPTION: read a color * INPUT: color pointer to color * OUTPUT: - *************/ static void ParseColor(HANDLER_DATA *data, COLOR *color) { CHUNK chunk; UBYTE c[3]; BeginChunk(data, &chunk); switch (chunk.id) { case ID_COLOR1: ReadFloat(data, &color->r, 1); ReadFloat(data, &color->g, 1); ReadFloat(data, &color->b, 1); break; case ID_COLOR255: ReadChunkBytes(data, &c, 3); color->r = c[0]/255.0f; color->g = c[1]/255.0f; color->b = c[2]/255.0f; break; } EndChunk(data, &chunk); }
/* EXPORT->LoadStatsFile: load the statistics file output by HERest */ void LoadStatsFile(char *statfile,HMMSet *hset,Boolean otrace) { Source src; char hname[256]; int i,idx,count,N,lnum = 0; float x; HMMDef *hmm; MLink ml; LabId hmmId; double occSum = 0.0; long occN = 0; StateInfo *si; Boolean bin=FALSE; if(InitSource(statfile,&src,NoFilter)<SUCCESS) HError(7210,"LoadStatsFile: Can't open file %s", statfile); while(ReadInt(&src,&idx,1,bin)) { ++lnum; if (!ReadString(&src,hname) || !ReadInt(&src,&count,1,bin)) HError(7250,"LoadStatsFile: Format error in file %s line %d", statfile,lnum); /* look up hname and find num states N */ if ((hmmId = GetLabId(hname,FALSE))==NULL) HError(7251,"LoadStatsFile: unknown name %s at line %d", hname,lnum); if ((ml = FindMacroName(hset,'l',hmmId))==NULL) HError(7251,"LoadStatsFile: unknown model %s at line %d", hname,lnum); hmm = (HMMDef *) ml->structure; N = hmm->numStates; for (i=2; i<N; i++) { if (!ReadFloat(&src,&x,1,bin)) HError(7250,"LoadStatsFile: Float format error file %s line %d\n", statfile,lnum); si = hmm->svec[i].info; si->stateCounter = count;/* load the # of times the state occurred */ memcpy(&(si->hook),&x,sizeof(float)); /* !! */ occSum += x; ++occN; } } CloseSource(&src); if (otrace || (trace & T_OCC)) { printf(" Stats loaded for %d models\n",lnum); printf(" Mean Occupation Count = %f\n",occSum/occN); fflush(stdout); } }
/* ================ idRestoreGame::ReadRenderLight ================ */ void idRestoreGame::ReadRenderLight( renderLight_t &renderLight ) { int index; int i; ReadMat3( renderLight.axis ); ReadVec3( renderLight.origin ); ReadInt( renderLight.suppressLightInViewID ); ReadInt( renderLight.allowLightInViewID ); ReadBool( renderLight.noShadows ); ReadBool( renderLight.pointLight ); ReadBool( renderLight.parallel ); ReadVec3( renderLight.lightRadius ); ReadVec3( renderLight.lightCenter ); ReadVec3( renderLight.target ); ReadVec3( renderLight.right ); ReadVec3( renderLight.up ); ReadVec3( renderLight.start ); ReadVec3( renderLight.end ); ReadBool( renderLight.ambient ); // sikk - Ambient Light Flag // ---> sikk - Ambient Light Color ReadVec3( renderLight.ambColor_X_Neg ); ReadVec3( renderLight.ambColor_X_Pos ); ReadVec3( renderLight.ambColor_Y_Neg ); ReadVec3( renderLight.ambColor_Y_Pos ); ReadVec3( renderLight.ambColor_Z_Neg ); ReadVec3( renderLight.ambColor_Z_Pos ); // <--- sikk - Ambient Light Color ReadVec3( renderLight.ambRotation ); // sikk - Ambient Light Rotation // only idLight has a prelightModel and it's always based on the entityname, so we'll restore it there // ReadModel( renderLight.prelightModel ); renderLight.prelightModel = NULL; ReadInt( renderLight.lightId ); ReadMaterial( renderLight.shader ); for( i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) { ReadFloat( renderLight.shaderParms[ i ] ); } ReadInt( index ); renderLight.referenceSound = gameSoundWorld->EmitterForIndex( index ); }
void Wheel::LoadFile(std::string filename) { std::ifstream fd(filename.c_str()); _size_x = ReadFloat(&fd); _size_y = ReadFloat(&fd); _max_motor_torque = ReadFloat(&fd); _side_damping = ReadFloat(&fd); _linear_damping = ReadFloat(&fd); _density = ReadFloat(&fd); _friction = ReadFloat(&fd); fd.close(); }
/************* * DESCRIPTION: read mapping coordinates of object * INPUT: - * OUTPUT: - *************/ static void ParseMapping(HANDLER_DATA *data) { // read number of mapping coordinates ReadWord(data, (WORD *)&data->mapcount, 1); if (data->mapcount == 0) return; data->mapping = new VECT2D[data->mapcount]; // Allocate memory if (!data->mapping) { data->err = ERR_MEM; return; } ReadFloat(data, (float *)data->mapping, data->mapcount*2); // Read mapping coordinates }
void ReadVector(TiXmlElement *element, Point3 &v) { double x = (double) v.x; double y = (double) v.y; double z = (double) v.z; element->QueryDoubleAttribute( "x", &x ); element->QueryDoubleAttribute( "y", &y ); element->QueryDoubleAttribute( "z", &z ); v.x = (float) x; v.y = (float) y; v.z = (float) z; float f=1; ReadFloat( element, f ); v *= f; }
void ReadColor(TiXmlElement *element, Color &c) { double r = (double) c.r; double g = (double) c.g; double b = (double) c.b; element->QueryDoubleAttribute( "r", &r ); element->QueryDoubleAttribute( "g", &g ); element->QueryDoubleAttribute( "b", &b ); c.r = (float) r; c.g = (float) g; c.b = (float) b; float f=1; ReadFloat( element, f ); c *= f; }
size_t Particle::deserialize(const Buffer& _src, size_t _offset) { _offset = _pm_checkPacketId(_src, _offset); _offset = ReadString16(_src, _offset, _pf_particleName); _offset = ReadFloat(_src, _offset, _pf_x); _offset = ReadFloat(_src, _offset, _pf_y); _offset = ReadFloat(_src, _offset, _pf_z); _offset = ReadFloat(_src, _offset, _pf_offsetX); _offset = ReadFloat(_src, _offset, _pf_offsetY); _offset = ReadFloat(_src, _offset, _pf_offsetZ); _offset = ReadFloat(_src, _offset, _pf_particleSpeed); _offset = ReadInt32(_src, _offset, _pf_numOfParticles); _pf_initialized = true; return _offset; }
void LoadMaterial(TiXmlElement *element) { Material *mtl = NULL; // name const char* name = element->Attribute("name"); printf("Material ["); if ( name ) printf("%s",name); printf("]"); // type const char* type = element->Attribute("type"); if ( type ) { if ( COMPARE(type,"blinn") ) { printf(" - Blinn\n"); MtlBlinn *m = new MtlBlinn(); mtl = m; for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) { Color c(1,1,1); float f=1; if ( COMPARE( child->Value(), "diffuse" ) ) { ReadColor( child, c ); m->SetDiffuse(c); printf(" diffuse %f %f %f\n",c.r,c.g,c.b); } else if ( COMPARE( child->Value(), "specular" ) ) { ReadColor( child, c ); m->SetSpecular(c); printf(" specular %f %f %f\n",c.r,c.g,c.b); } else if ( COMPARE( child->Value(), "glossiness" ) ) { ReadFloat( child, f ); m->SetGlossiness(f); printf(" glossiness %f\n",f); } } } else { printf(" - UNKNOWN\n"); } } if ( mtl ) { mtl->SetName(name); materials.push_back(mtl); } }
/************* * DESCRIPTION: read the points * INPUT: data handler data * cn iff context node * OUTPUT: error string *************/ static char *ReadPoints(HANDLER_DATA *data, struct ContextNode *cn) { int count; // get point count (each point has a size of 12 bytes) count = (cn->cn_Size)/sizeof(VECTOR); // Allocate memory data->pointcount = count; data->points = ALLOCMEM(VECTOR, count); if (!data->points) return errors[ERR_MEM]; // Read points if(!ReadFloat(data->iff, (float*)data->points, count*3)) return errors[ERR_LWOBFILE]; return NULL; }
boost::shared_ptr< Expr > ReadExpr( std::list< std::string > & tokens ) { if( tokens.empty( ) ) { throw SyntaxError( "ReadExpr: unexpected end of token stream" ); } else { if( tokens.front( ) == "function" ) { return ReadFuncDecl( tokens ); /*} else if( tokens.front( ) == "assign" ) { return ReadAssignExpr( tokens );*/ } else if( tokens.front( ) == "if" ) { return ReadIfExpr( tokens ); } else if( tokens.front( ) == "while" ) { return ReadWhileExpr( tokens ); /*} else if( tokens.front( ) == "call" ) { return ReadFuncCall( tokens );*/ } else if( tokens.front( ) == "false" || tokens.front( ) == "true" ) { return ReadBool( tokens ); } else if( tokens.front( )[ 0 ] >= '0' && tokens.front( )[ 0 ] <= '9' || tokens.front( )[ 0 ] == '-' || tokens.front( )[ 0 ] == '+' ) { if( tokens.front( ).find( '.' ) == -1 ) { return ReadInteger( tokens ); } else { return ReadFloat( tokens ); } } else if( tokens.front( )[ 0 ] >= 'A' && tokens.front( )[ 0 ] <= 'Z' || tokens.front( )[ 0 ] >= 'a' && tokens.front( )[ 0 ] <= 'z' || tokens.front( )[ 0 ] == '_' ) { if( tokens.size( ) == 1 ) { throw SyntaxError( "ReadExpr: unexpected end of stream" ); } else { std::list< std::string >::iterator nexttoken = tokens.begin( ); ++nexttoken; if( *nexttoken == "(" ) { return ReadFuncCall( tokens ); } else if( *nexttoken == "=" ) { return ReadAssignExpr( tokens ); } else { return ReadIdent( tokens ); } } } else if( tokens.front( )[ 0 ] == '"' ) { return ReadStringConst( tokens ); } else { throw SyntaxError( "ReadExpr: unexpected token " + tokens.front( ) ); } } }
/************* * DESCRIPTION: read a percent value * INPUT: - * OUTPUT: float (0..1) *************/ static float ParsePercentage(HANDLER_DATA *data) { CHUNK chunk; float percent = 0.f; BeginChunk(data, &chunk); switch (chunk.id) { case ID_PERCENT100: ReadFloat(data, &percent, 1); percent*= 0.01f; break; case ID_PERCENT1: ReadChunkBytes(data, &percent, 1); break; } EndChunk(data, &chunk); return percent; }