void SPSetStrN (string &s, const string &tag, const string &val) { int pos = SPPosN (s, tag); if (pos >= 0) { int ipos = pos + tag.size() + 2; string item = SPItemN (s, tag); if (item.size() > 0) SDeleteN (s, ipos, item.size()); SInsertN (s, ipos, val); } else SPAddStrN (s, tag, val); }
void SPSetFloatN (string &s, const string &tag, const float val, int count) { int pos = SPPosN (s, tag); if (pos >= 0) { int ipos = pos + tag.size() + 2; string item = SPItemN (s, tag); if (item.size() > 0) SDeleteN (s, ipos, item.size()); SInsertN (s, ipos, Float_StrN (val, count)); } else SPAddFloatN (s, tag, val, count); }
void CSPList::MakeIndex (string &index, const string &tag) { index = ""; string item; int idx = 0; for (int i=0; i<fcount; i++) { item = SPItemN (flines[i], tag); STrimN (item); if (item.size() > 0) { index += "["; index += item; index += "]"; index += Int_StrN (idx); idx++; } } }
void CCharShape::CreateMaterial (const string& line) { TVector3 diff = SPVector3N (line, "diff", TVector3 (0,0,0)); TVector3 spec = SPVector3N (line, "spec", TVector3 (0,0,0)); float exp = SPFloatN (line, "exp", 50); std::string mat = SPItemN (line, "mat"); STrimN(mat); Materials.push_back(TCharMaterial()); Materials.back().diffuse.r = diff.x; Materials.back().diffuse.g = diff.y; Materials.back().diffuse.b = diff.z; Materials.back().diffuse.a = 1.0; Materials.back().specular.r = spec.x; Materials.back().specular.g = spec.y; Materials.back().specular.b = spec.z; Materials.back().specular.a = 1.0; Materials.back().exp = exp; if(useActions) Materials.back().matline = line; MaterialIndex[mat] = Materials.size()-1; }
char *SPNewCharN (string &s, const string &tag) { string item = SPItemN (s, tag); if (item.size() < 1) return 0; STrimN (item); return NewStrN (item.c_str()); }
void SPCharN (string &s, const string &tag, char *result) { string item = SPItemN (s, tag); if (item.size() < 1) return; STrimN (item); strcpy (result, item.c_str()); }
void SPArrN (string &s, const string &tag, float *arr, int count, float def) { Str_ArrN (SPItemN (s, tag), arr, count, def); }
TColor3 SPColor3N (string &s, const string &tag, const TColor3 def) { return (Str_Color3N (SPItemN (s, tag), def)); }
int SPIntN (string &s, const string &tag, const int def) { return (Str_IntN (SPItemN (s, tag), def)); }
TTuple4 SPTuple4N (string &s, const string &tag) { return (Str_Tuple4N (SPItemN (s, tag))); }
TVector3 SPVector3N (string &s, const string &tag) { return (Str_Vector3N (SPItemN (s, tag))); }
TIndex3 SPIndex3N (string &s, const string &tag, const TIndex3 def) { return (Str_Index3N (SPItemN (s, tag), def)); }
float SPFloatN (string &s, const string &tag, const float def) { return (Str_FloatN (SPItemN (s, tag), def)); }
bool SPBoolNX (string &s, const string &tag, const bool def) { string item = SPItemN (s, tag); STrimN (item); return Str_BoolNX (item, def); }
bool SPBoolN (string &s, const string &tag, const bool def) { return (Str_BoolN (SPItemN (s, tag), def)); }
int SPEnumN (string &s, const string &tag, int def) { string item = SPItemN (s, tag); STrimN (item); if (item.size() < 1) return def; return SPIntN (EnumStr, item, def);; }
TVector4 SPVector4N (string &s, const string &tag, const TVector4 def) { return (Str_Vector4N (SPItemN (s, tag), def)); }
string SPStrN (string &s, const string &tag, const string def) { string item = SPItemN (s, tag); if (item.size() < 1) return def; STrimN (item); return item; }