void XmlUniformiser::skipComment() { while ( isValidIndex() && !startsWith( "-->" ) ) skipNext(); if ( isValidIndex() ) skipNext( 3 ); }
void XmlUniformiser::skipProcessed() { while ( isValidIndex() && !startsWith( "?>" ) ) skipNext(); if ( isValidIndex() ) skipNext( 2 ); }
void CFileReader::skipString(const char *_delim) { _toNextToken(); u32 t_delimsize = strlen(_delim); if (strncmp(m_pos, _delim, t_delimsize) == 0) { m_pos += t_delimsize; while (*m_pos) { if (strncmp(m_pos, _delim, t_delimsize) == 0) { m_pos += t_delimsize; break; } ++m_pos; } } else { skipNext(1); } }
void CFileReader::skipNext(u32 _count) { _toNextToken(); if (_count) { while (*m_pos && !xisspace(*m_pos)) { ++m_pos; } skipNext(_count - 1); } }
void CFileReader::skipString(char _delim) { _toNextToken(); if (*m_pos == _delim) { m_pos++; while (*m_pos) { if (*m_pos == _delim) { ++m_pos; break; } ++m_pos; } } else { skipNext(1); } }
int proc_vec( int argc, char *argv[], byte first_param ) { float Angles[MAX_VECTOR_SIZE]; float Speeds[MAX_VECTOR_SIZE]; byte Instances[MAX_VECTOR_SIZE]; // GET SPECIFIC INSTANCE NUMBER (255 for all): if (argc < (first_param+1)) { printf( "No vector command.\n"); return 0; } // GET OPERATION TO BE DONE ON INSTANCE: if (strcmp(argv[first_param+1], "clearall") == 0) { // Erase .ini file FILE* f = fopen(VectorFileName,"w"); fprintf(f, " "); fclose(f); printf("Motor Vectors Erased!...\n"); } if (strcmp(argv[first_param+1], "define") == 0) { // Create a Vector (mapping of board instances with indexes) printf("Create Motor Vector...\n"); if (argc < (first_param+3)) { printf( "No vector command.\n"); return 0; } // CONSTRUCT vector: byte size = atoi(argv[first_param+3]); if (size > 50) { printf("Current Max vector size = 50\n"); return 0; } //struct stVector* vector = NewVector( argv[first_param+2], size ); // AssignBoards ( vector, instances ); FILE* f = fopen(VectorFileName,"a+"); fprintf(f, "%s %d ", argv[first_param+2], size); byte instances[50]; for (int i=0; i<size; i++) { if ((i+3) > argc) { printf("Not enough instances!"); return 0; } else { instances[i] = atoi(argv[first_param+4+i]); fprintf( f, "%d ", instances[i] ); } } fprintf( f, "\n"); fclose(f); } if (strcmp(argv[first_param+1], "showall") == 0) { FILE* f = fopen(VectorFileName,"r"); // PRINT .ini file char c = fgetc(f); while (!feof(f)) { printf("%c", c); c = fgetc(f); } fclose(f); } else if (strcmp(argv[first_param+1], "set") == 0) { // GET VECTOR FROM INI File: char* vect_text = readvec( argv[first_param+2] ); if (vect_text == NULL) return 0; //printf("%s\n", vect_text); // Create a Vector (mapping of board instances with indexes) // PARSE SIZE: char* sLine = skipNext( vect_text ); // skip Name byte vsize = atoi( getWord(sLine) ); char* rLine = skipNext( sLine ); // skip size // PARSE INSTANCES: byte size = getIntArray( rLine, Instances ); // The send actually does the AddToSendList() calls for each element if (argc < (vsize*2 + first_param+2)) { printf ("Not enough vectors!"); return 0; } //int argi = 0; // EXTRACT ALL ANGLES & SPEEDS: int i; for (i=0; i<vsize; i++) { Angles[i] = atof(argv[first_param+4+i]); //printf("%9.3f, ", Angles[i]); } //printf("\nSpeeds="); byte s = first_param+4+i; for (i=0; i<vsize; i++) { Speeds[i] = atof(argv[s+i]); //printf("%9.3f ", Speeds[i]); } //printf("\n"); send_angle_vector( vsize, Instances, Angles, Speeds ); } }
void DlgAutoDJ::skipNextButton(bool) { // Activate regardless of button being checked skipNext(1.0); }
//return face count MCInline void processMtlLine(BAMtlLibrary* lib, const char* linebuff) { //debug_log("processMtlLine:%s\n", linebuff); //MCToken token; MCToken token; char word[256] = {0}; const char* remain = linebuff; while (!isNewLine(remain) && *remain != NUL) { token = tokenize(nextWord(&remain, word)); switch (token.type) { case MCTokenIdentifier: if (MCStringEqualN(word, "newmtl", 6)) { token = tokenize(nextWord(&remain, word)); if (token.type == MCTokenIdentifier || token.type == MCTokenFilename) { if (!BAFindMaterial(lib, token.value.Word)) { BAAddMaterial(lib, token.value.Word); } continue; } } //texture else if (MCStringEqualN(word, "map_Ka", 6)) { return;//next line } else if (MCStringEqualN(word, "map_Kd", 6)) { char name[256] = {0}; BAMaterial* material = lib->materialsList; if (material && MCString_filenameFromPath(remain, &name)) { MCStringFill(material->diffuseMapName, name); lib->diffuse_map_count++; } else { error_log("BAMtlParser - can not get filename form path: %s\n", remain); } return;//next line } else if (MCStringEqualN(word, "map_Ks", 6)) { char name[256] = {0}; BAMaterial* material = lib->materialsList; if (material && MCString_filenameFromPath(remain, &name)) { MCStringFill(material->specularMapName, name); } else { error_log("BAMtlParser - can not get filename form path: %s\n", remain); } return;//next line } else if (MCStringEqualN(word, "map_Ns", 6)) { char name[256] = {0}; BAMaterial* material = lib->materialsList; if (material && MCString_filenameFromPath(remain, &name)) { MCStringFill(material->normalMapName, name); lib->normal_map_count++; } else { error_log("BAMtlParser - can not get filename form path: %s\n", remain); } return;//next line } else if (MCStringEqualN(word, "map_Ke", 6)) { return;//next line } //LSLightColor else if (MCStringEqualN(word, "illum", 5)) { token = tokenize(nextWord(&remain, word)); BAMaterial* material = lib->materialsList; if (material) { if (token.type == MCTokenIdentifier) { if (MCStringEqualN(token.value.Word, "illum_", 6)) { char* num = &token.value.Word[6]; int n = atoi(num); if (n >= 0 && n <= 10) { material->illumModelNum = n; } } } else if (token.type == MCTokenInteger) { int n = (int)token.value.Integer; if (n >= 0 && n <= 10) { material->illumModelNum = n; } } } } //Ka|Kd|Ks|Tf [xyz|spectral] rx gy bz | [file.rfl factor] else if (MCStringEqualN(word, "K", 1) || MCStringEqualN(word, "Tf", 2)) { BALightColor* light = null; if (MCStringEqualN(word, "Tf", 2)) { light = &(lib->materialsList->lightColors[TFilter]); } else if (MCStringEqualN(word, "Ka", 2)) { light = &(lib->materialsList->lightColors[Ambient]); } else if (MCStringEqualN(word, "Kd", 2)) { light = &(lib->materialsList->lightColors[Diffuse]); } else if (MCStringEqualN(word, "Ks", 2)) { light = &(lib->materialsList->lightColors[Specular]); } else if (MCStringEqualN(word, "Ke", 2)) { light = &(lib->materialsList->lightColors[Emissive]); } if (!light) { error_log("BAMtlParser - [%s] not light Ka/Kd/Ks\n", word); return; } light->Ctype = RGB; //option next token = tokenize(peekNext(&remain, word)); if (token.type == MCTokenIdentifier) { if (MCStringEqualN(token.value.Word, "xyz", 3)) { light->Ctype = XYZ; } else if (MCStringEqualN(token.value.Word, "spectral", 8)) { light->Ctype = SpectralFile; //filename next skipNext(&remain);//skip token = tokenize(nextWord(&remain, word)); if (token.type == MCTokenIdentifier) { MCStringFill(light->data.spectral, token.value.Word); //factor next token = tokenize(nextWord(&remain, word)); if (token.type == MCTokenFloat) { light->factor = token.value.Double; } } //end line return; } } //float value next else if (token.type == MCTokenFloat || token.type == MCTokenInteger) { if (light->Ctype != SpectralFile) { double buff[3] = {0}; size_t n = nextNumbersAsFloat(&remain, buff); if (n >= 3) { light->data.rgbxyz[0] = buff[0]; light->data.rgbxyz[1] = buff[1]; light->data.rgbxyz[2] = buff[2]; } else { error_log("MC3DMtlParser [%s] value count less than 3\n", linebuff); } } } } //LSScalar else if (MCStringEqualN(word, "Ns", 2)) { token = tokenize(nextWord(&remain, word)); if (token.type == MCTokenInteger) { lib->materialsList->specularExponent = (double)token.value.Integer; } if (token.type == MCTokenFloat) { lib->materialsList->specularExponent = (double)token.value.Double; } continue; } else if (MCStringEqualN(word, "decal", 5)) { //state = LSScalar; } else if (MCStringEqualN(word, "disp", 4)) { //state = LSScalar; } else if (MCStringEqualN(word, "bump", 4)) { //state = LSScalar; } else if (MCStringEqualN(word, "d", 1)) { token = tokenize(nextWord(&remain, word)); if (lib->materialsList) { if (token.type == MCTokenFloat) { lib->materialsList->dissolveFactor = (double)token.value.Double; } if (token.type == MCTokenInteger) { lib->materialsList->dissolveFactor = (double)token.value.Integer; } } continue; } //BohdiEngine extensions else if (MCStringEqualN(word, "ext_hidden", 10)) { token = tokenize(nextWord(&remain, word)); if (lib->materialsList) { if (token.type == MCTokenIdentifier && MCStringEqualN(token.value.Word, "off", 3)) { lib->materialsList->hidden = 0; }else{ lib->materialsList->hidden = 1; } } } else if (MCStringEqualN(word, "ext_tex_file", 12)) { token = tokenize(nextWord(&remain, word)); if(!BAFindTextureByFilename(lib, token.value.Word)) { BAAddTexture(lib, token.value.Word, null, null); } } else if (MCStringEqualN(word, "ext_tex_group", 13)) { token = tokenize(nextWord(&remain, word)); BATexture* tex = lib->texturesList; MCStringFill(tex->attachedGroup, token.value.Word); } else if (MCStringEqualN(word, "ext_tex_object", 14)) { token = tokenize(nextWord(&remain, word)); BATexture* tex = lib->texturesList; MCStringFill(tex->attachedObject, token.value.Word); } else { } break; case MCTokenComment: case MCTokenUnknown: default: nextWord(&remain, word); continue; } } return; }
void XmlUniformiser::skipSpaces() { while ( isSpace() ) skipNext(); }