int CIFStockNotein::ReadData(QSettings& set) { set.beginGroup("NOTEIN"); m_Notein.SetFaceNum(set.value("face_num").toInt()); m_Notein.SetAllNum( set.value("all_num").toInt()); m_Notein.SetAllSum(set.value("all_sum").toInt()); set.endGroup(); for (int i=0;i<m_Notein.GetFaceNum();i++) { ReadFace(set, i); } return 1; }
void CLoadASE::GetData(t3DModel *pModel, t3DObject *pObject, char *strDesiredData, int desiredObject) { char strWord[255] = {0}; static int faceNum=0; MoveToObject(desiredObject); while(!feof(m_FilePointer)) { fscanf(m_FilePointer, "%s", &strWord); if(!strcmp(strWord, OBJECT)) { return; } else if(!strcmp(strWord, VERTEX)) { if(!strcmp(strDesiredData, VERTEX)) { ReadVertex(pObject); } } else if(!strcmp(strWord, TVERTEX)) { if(!strcmp(strDesiredData, TVERTEX)) { ReadTextureVertex(pObject, pModel->pMaterials[pObject->materialID]); } } else if(!strcmp(strWord, FACE)) { if(!strcmp(strDesiredData, FACE)) { ReadFace(pObject); } } else if(!strcmp(strWord, TFACE)) { if(!strcmp(strDesiredData, TFACE)) { ReadTextureFace(pObject); } } else if(!strcmp(strWord, SHADEMODEL)) { if(!strcmp(strDesiredData, SHADEMODEL)) { pObject->shadeModel = (int)ReadFloat(); return; } } else if(!strcmp(strWord, MATERIAL_ID)) { if(!strcmp(strDesiredData, MATERIAL_ID)) { pObject->materialID = (int)ReadFloat(); return; } } else { fgets(strWord, 100, m_FilePointer); } } }
// parse object data-file ----------------------------------------------------- // int AodInput::ParseObjectData() { int faceprop_itemsread = 0; int facenorm_itemsread = 0; InfoMessage( "Processing input data file (format='AOD V1.1') ..." ); // parse sections and read data ------------------------------- m_section = _nil; while ( m_input.ReadLine( line, TEXTLINE_MAX ) != NULL ) { if ( ( m_parser_lineno++ & PARSER_DOT_SIZE ) == 0 ) printf( "." ), fflush( stdout ); if ( ( m_scanptr = strtok( line, "/, \t\n\r" ) ) == NULL ) continue; else if ( *m_scanptr == ';' ) continue; else if ( strnicmp( m_scanptr, "<end", 4 ) == 0 ) break; else if ( *m_scanptr == '#' ) { if ( strncmp( m_scanptr, _aodsig_str, strlen( _aodsig_str ) ) == 0 ) { m_section = _comment; } else if ( ( m_section = GetSectionId( m_scanptr ) ) == _nil ) { { StrScratch error; sprintf( error, "%s[Undefined section-name]: %s (line %d)", parser_err_str, m_scanptr, m_parser_lineno ); ErrorMessage( error ); } HandleCriticalError(); } } else { switch ( m_section ) { // list of vertices ------------------------------------ case _vertices : ReadVertex(); break; // vertexnums of faces --------------------------------- case _faces : ReadFace( TRUE ); break; // normals for face's planes --------------------------- case _facenormals : //NOTE: // face normals are currently ignored in the aod // file, since they are too inaccurate for later // BSP compilation purposes. if no normals are read // in, they will be calculated later on anyway. //ReadFaceNormal( facenorm_itemsread ); break; // properties of faces --------------------------------- case _faceproperties : ReadFaceProperties( faceprop_itemsread ); break; // texture->face correspondences ---------------------- case _correspondences : ReadCorrespondences(); break; // texturing data ----------------------------------- case _textures : ReadTextures(); break; // location of the object --------------------------- case _worldlocation : ReadWorldLocation(); break; // location of camera ------------------------------- case _camera : ReadCameraLocation(); break; // filename of palette file ------------------------- case _palette : ReadPaletteFilename(); break; // scalefactors for object -------------------------- case _scalefactors : ReadScaleFactors(); break; // exchange command for axes ------------------------ case _xchange : ReadXChangeCommand(); break; // set new object origin ---------------------------- case _setorigin : ReadOrigin(); break; } } } // do post processing after parsing ApplyOriginTranslation(); FilterAxesDirSwitch(); FilterScaleFactors(); FilterAxesExchange(); EnforceMaximumExtents(); m_baseobject->CheckParsedData(); InfoMessage( "\nObject data ok.\n" ); // do colorindex to rgb conversion ConvertColIndxs(); return ( m_inputok = TRUE ); }
// parse object data-file ----------------------------------------------------- // int BspInput::ParseObjectData() { int facedef_itemsread = 0; int faceprop_itemsread = 0; int facenorm_itemsread = 0; int mappdef_itemsread = 0; InfoMessage( "Processing input data file (format='BSP V1.1') ..." ); // parse sections and read data ------------------------------- m_section = _nil; while ( m_input.ReadLine( line, TEXTLINE_MAX ) != NULL ) { if ( ( m_parser_lineno++ & PARSER_DOT_SIZE ) == 0 ) printf( "." ), fflush( stdout ); if ( ( m_scanptr = strtok( line, "/, \t\n\r" ) ) == NULL ) continue; else if ( *m_scanptr == ';' ) continue; else if ( strnicmp( m_scanptr, "<end", 4 ) == 0 ) break; else if ( *m_scanptr == '#' ) { if ( strncmp( m_scanptr, _bspsig_str, strlen( _bspsig_str ) ) == 0 ) { m_section = _comment; } else if ( ( m_section = GetSectionId( m_scanptr ) ) == _nil ) { { StrScratch error; sprintf( error, "%s[Undefined section-name]: %s (line %d)", parser_err_str, m_scanptr, m_parser_lineno ); ErrorMessage( error ); } HandleCriticalError(); } } else { switch ( m_section ) { // list of vertices ------------------------------------ case _vertices : ReadVertex(); break; // vertexnums of polygons ------------------------------ case _polygons : ReadFace( FALSE ); break; // definition of faces (consisting of polygons) -------- case _faces : ReadPolyIndxs( facedef_itemsread ); break; // bsptree --------------------------------------------- case _bsptree : ReadBspTree(); break; // normals for face's planes --------------------------- case _facenormals : ReadFaceNormal( facenorm_itemsread ); break; // properties of faces --------------------------------- case _faceproperties : ReadFaceProperties( faceprop_itemsread ); break; // texture->face correspondences ---------------------- case _correspondences : ReadDirectCorrespondences( mappdef_itemsread ); break; // texturing data ----------------------------------- case _textures : ReadTextures(); break; // location of the object --------------------------- case _worldlocation : ReadWorldLocation(); break; // location of camera ------------------------------- case _camera : ReadCameraLocation(); break; // filename of palette file ------------------------- case _palette : ReadPaletteFilename(); break; // scalefactors for object -------------------------- case _scalefactors : ReadScaleFactors(); break; // exchange command for axes ------------------------ case _xchange : ReadXChangeCommand(); break; // set new object origin ---------------------------- case _setorigin : ReadOrigin(); break; } } } // do post processing after parse CorrectMappingCoordinates(); ApplyOriginTranslation(); FilterAxesDirSwitch(); FilterScaleFactors(); FilterAxesExchange(); EnforceMaximumExtents(); m_baseobject->CheckParsedData(); InfoMessage( "\nObject data ok.\n" ); // do colorindex to rgb conversion ConvertColIndxs(); return ( m_inputok = TRUE ); }