Replaced TIndex* types by TVector*i

git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/trunk@462 0420edf4-82e4-42fc-9478-35b55e6d67a3
master
pkeus 2013-10-04 10:21:09 +00:00
parent df18d00a07
commit 07bd482769
16 changed files with 132 additions and 188 deletions

View File

@ -99,14 +99,6 @@ void PrintVector (const TVector3d& v) {
cout << v.x << " " << v.y << " " << v.z << '\n';
}
void PrintIndex3 (const TIndex3& idx) {
cout << idx.i << ' ' << idx.j << ' ' << idx.k << '\n';
}
void PrintIndex4 (const TIndex4& idx) {
cout << idx.i << ' ' << idx.j << ' ' << idx.k << ' ' << idx.l << '\n';
}
template<int x, int y>
void PrintMatrix (const TMatrix<x, y>& mat) {
cout << '\n';

View File

@ -91,9 +91,6 @@ template<int x, int y>
void PrintMatrix (const TMatrix<x, y>& mat);
void PrintQuaternion (const TQuaternion& q);
void PrintIndex3 (const TIndex3& idx);
void PrintIndex4 (const TIndex4& idx);
// --------------------------------------------------------------------
// file utils
// --------------------------------------------------------------------

View File

@ -584,7 +584,7 @@ bool CCourse::LoadObjectTypes () {
ObjTypes[i].use_normal = SPBoolN (line, "usenorm", false);
if (ObjTypes[i].use_normal) {
ObjTypes[i].normal = SPVector3N (line, "norm", TVector3d(0, 1, 0));
ObjTypes[i].normal = SPVector3(line, "norm", TVector3d(0, 1, 0));
ObjTypes[i].normal.Norm();
}
ObjTypes[i].poly = 1;
@ -912,8 +912,8 @@ void CCourse::GetIndicesForPoint(double x, double z, int *x0, int *y0, int *x1,
}
}
void CCourse::FindBarycentricCoords (double x, double z, TIndex2 *idx0,
TIndex2 *idx1, TIndex2 *idx2, double *u, double *v) const {
void CCourse::FindBarycentricCoords(double x, double z, TVector2i *idx0,
TVector2i *idx1, TVector2i *idx2, double *u, double *v) const {
double xidx, yidx;
int x0, x1, y0, y1;
double dx, ex, dz, ez, qx, qz, invdet;
@ -924,32 +924,32 @@ void CCourse::FindBarycentricCoords (double x, double z, TIndex2 *idx0,
if ((x0 + y0) % 2 == 0) {
if (yidx - y0 < xidx - x0) {
*idx0 = TIndex2 (x0, y0);
*idx1 = TIndex2 (x1, y0);
*idx2 = TIndex2 (x1, y1);
*idx0 = TVector2i(x0, y0);
*idx1 = TVector2i(x1, y0);
*idx2 = TVector2i(x1, y1);
} else {
*idx0 = TIndex2 (x1, y1);
*idx1 = TIndex2 (x0, y1);
*idx2 = TIndex2 (x0, y0);
*idx0 = TVector2i(x1, y1);
*idx1 = TVector2i(x0, y1);
*idx2 = TVector2i(x0, y0);
}
} else {
if (yidx - y0 + xidx - x0 < 1) {
*idx0 = TIndex2 (x0, y0);
*idx1 = TIndex2 (x1, y0);
*idx2 = TIndex2 (x0, y1);
*idx0 = TVector2i(x0, y0);
*idx1 = TVector2i(x1, y0);
*idx2 = TVector2i(x0, y1);
} else {
*idx0 = TIndex2 (x1, y1);
*idx1 = TIndex2 (x0, y1);
*idx2 = TIndex2 (x1, y0);
*idx0 = TVector2i(x1, y1);
*idx1 = TVector2i(x0, y1);
*idx2 = TVector2i(x1, y0);
}
}
dx = idx0->i - idx2->i;
dz = idx0->j - idx2->j;
ex = idx1->i - idx2->i;
ez = idx1->j - idx2->j;
qx = xidx - idx2->i;
qz = yidx - idx2->j;
dx = idx0->x - idx2->x;
dz = idx0->y - idx2->y;
ex = idx1->x - idx2->x;
ez = idx1->y - idx2->y;
qx = xidx - idx2->x;
qz = yidx - idx2->y;
invdet = 1 / (dx * ez - dz * ex);
*u = (qx * ez - qz * ex) * invdet;
@ -965,17 +965,17 @@ TVector3d CCourse::FindCourseNormal (double x, double z) const {
int x0, x1, y0, y1;
GetIndicesForPoint (x, z, &x0, &y0, &x1, &y1);
TIndex2 idx0, idx1, idx2;
TVector2i idx0, idx1, idx2;
double u, v;
FindBarycentricCoords (x, z, &idx0, &idx1, &idx2, &u, &v);
const TVector3d& n0 = Course.nmls[ idx0.i + nx * idx0.j ];
const TVector3d& n1 = Course.nmls[ idx1.i + nx * idx1.j ];
const TVector3d& n2 = Course.nmls[ idx2.i + nx * idx2.j ];
const TVector3d& n0 = Course.nmls[ idx0.x + nx * idx0.y ];
const TVector3d& n1 = Course.nmls[ idx1.x + nx * idx1.y ];
const TVector3d& n2 = Course.nmls[ idx2.x + nx * idx2.y ];
TVector3d p0 = COURSE_VERTX (idx0.i, idx0.j);
TVector3d p1 = COURSE_VERTX (idx1.i, idx1.j);
TVector3d p2 = COURSE_VERTX (idx2.i, idx2.j);
TVector3d p0 = COURSE_VERTX (idx0.x, idx0.y);
TVector3d p1 = COURSE_VERTX (idx1.x, idx1.y);
TVector3d p2 = COURSE_VERTX (idx2.x, idx2.y);
TVector3d smooth_nml = u * n0 +
v * n1 +
@ -1000,13 +1000,13 @@ double CCourse::FindYCoord (double x, double z) const {
if (cache_full && last_x == x && last_z == z) return last_y;
double *elevation = Course.elevation;
TIndex2 idx0, idx1, idx2;
TVector2i idx0, idx1, idx2;
double u, v;
FindBarycentricCoords (x, z, &idx0, &idx1, &idx2, &u, &v);
TVector3d p0 = COURSE_VERTX (idx0.i, idx0.j);
TVector3d p1 = COURSE_VERTX (idx1.i, idx1.j);
TVector3d p2 = COURSE_VERTX (idx2.i, idx2.j);
TVector3d p0 = COURSE_VERTX (idx0.x, idx0.y);
TVector3d p1 = COURSE_VERTX (idx1.x, idx1.y);
TVector3d p2 = COURSE_VERTX (idx2.x, idx2.y);
double ycoord = u * p0.y + v * p1.y + (1. - u - v) * p2.y;
@ -1019,30 +1019,30 @@ double CCourse::FindYCoord (double x, double z) const {
}
void CCourse::GetSurfaceType (double x, double z, double weights[]) const {
TIndex2 idx0, idx1, idx2;
TVector2i idx0, idx1, idx2;
double u, v;
FindBarycentricCoords (x, z, &idx0, &idx1, &idx2, &u, &v);
char *terrain = Course.terrain;
for (size_t i=0; i<Course.TerrList.size(); i++) {
weights[i] = 0;
if (terrain [idx0.i + nx*idx0.j ] == i) weights[i] += u;
if (terrain [idx1.i + nx*idx1.j ] == i) weights[i] += v;
if (terrain [idx2.i + nx*idx2.j ] == i) weights[i] += 1.0 - u - v;
if (terrain [idx0.x + nx*idx0.y ] == i) weights[i] += u;
if (terrain [idx1.x + nx*idx1.y ] == i) weights[i] += v;
if (terrain [idx2.x + nx*idx2.y ] == i) weights[i] += 1.0 - u - v;
}
}
int CCourse::GetTerrainIdx (double x, double z, double level) const {
TIndex2 idx0, idx1, idx2;
TVector2i idx0, idx1, idx2;
double u, v;
FindBarycentricCoords (x, z, &idx0, &idx1, &idx2, &u, &v);
char *terrain = Course.terrain;
for (size_t i=0; i<Course.TerrList.size(); i++) {
double wheight = 0.0;
if (terrain [idx0.i + nx*idx0.j] == i) wheight += u;
if (terrain [idx1.i + nx*idx1.j] == i) wheight += v;
if (terrain [idx2.i + nx*idx2.j] == i) wheight += 1.0 - u - v;
if (terrain [idx0.x + nx*idx0.y] == i) wheight += u;
if (terrain [idx1.x + nx*idx1.y] == i) wheight += v;
if (terrain [idx2.x + nx*idx2.y] == i) wheight += 1.0 - u - v;
if (wheight > level) return (int)i;
}
return -1;

View File

@ -169,7 +169,7 @@ public:
void GetIndicesForPoint (double x, double z, int *x0, int *y0, int *x1, int *y1) const;
void FindBarycentricCoords (double x, double z,
TIndex2 *idx0, TIndex2 *idx1, TIndex2 *idx2, double *u, double *v) const;
TVector2i *idx0, TVector2i *idx1, TVector2i *idx2, double *u, double *v) const;
TVector3d FindCourseNormal (double x, double z) const;
double FindYCoord (double x, double z) const;
void GetSurfaceType (double x, double z, double weights[]) const;

View File

@ -25,25 +25,6 @@ enum Orientation {
OR_BOTTOM = 1 // bottom-orientated
};
struct TIndex2 {
int i, j;
TIndex2(int i_ = 0, int j_ = 0)
: i(i_), j(j_)
{}
};
struct TIndex3 : public TIndex2 {
int k;
TIndex3(int i_ = 0, int j_ = 0, int k_ = 0)
: TIndex2(i_, j_), k(k_)
{}
};
struct TIndex4 : public TIndex3 {
int l;
TIndex4(int i_ = 0, int j_ = 0, int k_ = 0, int l_ = 0)
: TIndex3(i_, j_, k_), l(l_)
{}
};
struct TColor3 {
double r, g, b;
TColor3(double r_ = 0, double g_ = 0, double b_ = 0)
@ -139,7 +120,7 @@ struct TGameData {
size_t theme_id;
// requirements
TIndex3 herring_req; // 3 levels of needed herrings
TVector3i herring_req; // 3 levels of needed herrings
TVector3d time_req; // 3 levels of allowed time
// race results (better in player.ctrl ?)

View File

@ -226,9 +226,9 @@ void CEvent::Loop (double timestep) {
int ddd = FT.AutoDistanceN (1);
FT.SetColor (colDBlue);
string info = Trans.Text(11);
info += " " + Int_StrN (ecup->races[curr_race]->herrings.i);
info += " " + Int_StrN (ecup->races[curr_race]->herrings.j);
info += " " + Int_StrN (ecup->races[curr_race]->herrings.k);
info += " " + Int_StrN (ecup->races[curr_race]->herrings.x);
info += " " + Int_StrN (ecup->races[curr_race]->herrings.y);
info += " " + Int_StrN (ecup->races[curr_race]->herrings.z);
FT.DrawString (CENTER, framebottom+15, info);
info = Trans.Text(12);

View File

@ -53,8 +53,8 @@ bool CEvents::LoadEventList () {
RaceList.back().light = Env.GetLightIdx (item);
RaceList.back().snow = SPIntN (line, "snow", 0);
RaceList.back().wind = SPIntN (line, "wind", 0);
RaceList.back().time = SPVector3N (line, "time");
RaceList.back().herrings = SPIndex3N (line, "herring", TIndex3 (0, 0, 0));
RaceList.back().time = SPVector3d(line, "time");
RaceList.back().herrings = SPVector3i(line, "herring");
RaceList.back().music_theme = Music.GetThemeIdx (SPStrN (line, "theme", "normal"));
}
}

View File

@ -38,7 +38,7 @@ struct TRace2 {
size_t light;
int snow;
int wind;
TIndex3 herrings;
TVector3i herrings;
TVector3d time;
size_t music_theme;
};

View File

@ -96,7 +96,7 @@ void GameOverMessage (const CControl *ctrl) {
line = Int_StrN (g_game.herring);
if (g_game.game_type == CUPRACING) {
line += " (";
line += Int_StrN (g_game.herring_req.i);
line += Int_StrN (g_game.herring_req.x);
line += ")";
}
FT.DrawString (leftframe+240, topframe+40, line);

View File

@ -112,7 +112,7 @@ bool CKeyframe::Load (const string& dir, const string& filename) {
for (size_t i=0; i<list.Count(); i++) {
const string& line = list.Line(i);
frames[i].val[0] = SPFloatN (line, "time", 0);
TVector3d posit = SPVector3N (line, "pos");
TVector3d posit = SPVector3d(line, "pos");
frames[i].val[1] = posit.x;
frames[i].val[2] = posit.y;
frames[i].val[3] = posit.z;
@ -121,19 +121,19 @@ bool CKeyframe::Load (const string& dir, const string& filename) {
frames[i].val[6] = SPFloatN (line, "roll", 0);
frames[i].val[7] = SPFloatN (line, "neck", 0);
frames[i].val[8] = SPFloatN (line, "head", 0);
TVector2d pp = SPVector2N (line, "sh");
TVector2d pp = SPVector2d(line, "sh");
frames[i].val[9] = pp.x;
frames[i].val[10] = pp.y;
pp = SPVector2N (line, "arm");
pp = SPVector2d(line, "arm");
frames[i].val[11] = pp.x;
frames[i].val[12] = pp.y;
pp = SPVector2N (line, "hip");
pp = SPVector2d(line, "hip");
frames[i].val[13] = pp.x;
frames[i].val[14] = pp.y;
pp = SPVector2N (line, "knee");
pp = SPVector2d(line, "knee");
frames[i].val[15] = pp.x;
frames[i].val[16] = pp.y;
pp = SPVector2N (line, "ankle");
pp = SPVector2d(line, "ankle");
frames[i].val[17] = pp.x;
frames[i].val[18] = pp.y;
}

View File

@ -143,11 +143,11 @@ bool CScore::LoadHighScore () {
int CScore::CalcRaceResult () {
g_game.race_result = -1;
if (g_game.time <= g_game.time_req.x &&
g_game.herring >= g_game.herring_req.i) g_game.race_result = 0;
g_game.herring >= g_game.herring_req.x) g_game.race_result = 0;
if (g_game.time <= g_game.time_req.y &&
g_game.herring >= g_game.herring_req.j) g_game.race_result = 1;
g_game.herring >= g_game.herring_req.y) g_game.race_result = 1;
if (g_game.time <= g_game.time_req.z &&
g_game.herring >= g_game.herring_req.k) g_game.race_result = 2;
g_game.herring >= g_game.herring_req.z) g_game.race_result = 2;
int herringpt = g_game.herring * 10;
double timept = Course.GetDimensions().y - (g_game.time * 10);

View File

@ -74,12 +74,6 @@ void STrimN (string &s) {
// conversion functions
// --------------------------------------------------------------------
void Int_StrN (string &s, const int val) {
ostringstream os;
os << val;
s = os.str();
}
string Int_StrN (const int val) {
ostringstream os;
os << val;
@ -92,12 +86,6 @@ string Int_StrN (const int val, const streamsize count) {
return os.str();
}
void Float_StrN (string &s, const float val, const streamsize count) {
ostringstream os;
os << setprecision(count) << fixed << val;
s = os.str();
}
string Float_StrN (const float val, const streamsize count) {
ostringstream os;
os << setprecision(count) << fixed << val;
@ -111,6 +99,11 @@ string Vector_StrN (const TVector3d& v, const streamsize count) {
return res;
}
string Bool_StrN(const bool val) {
if (val == true) return "true";
else return "false";
}
int Str_IntN (const string &s, const int def) {
int val;
istringstream is(s);
@ -135,37 +128,39 @@ float Str_FloatN (const string &s, const float def) {
else return val;
}
TVector2d Str_Vector2N (const string &s, const TVector2d &def) {
float x, y;
template<typename T>
TVector2<T> Str_Vector2(const string &s, const TVector2<T> &def) {
T x, y;
istringstream is(s);
is >> x >> y;
if (is.fail()) return def;
else return TVector2d (x, y);
else return TVector2<T>(x, y);
}
template TVector2<double> Str_Vector2(const string &s, const TVector2<double> &def);
template TVector2<int> Str_Vector2(const string &s, const TVector2<int> &def);
TVector3d Str_Vector3N (const string &s, const TVector3d &def) {
float x, y, z;
template<typename T>
TVector3<T> Str_Vector3(const string &s, const TVector3<T> &def) {
T x, y, z;
istringstream is(s);
is >> x >> y >> z;
if (is.fail()) return def;
else return TVector3d (x, y, z);
else return TVector3<T>(x, y, z);
}
template TVector3<double> Str_Vector3(const string &s, const TVector3<double> &def);
template TVector3<int> Str_Vector3(const string &s, const TVector3<int> &def);
TIndex3 Str_Index3N (const string &s, const TIndex3 &def) {
int i, j, k;
istringstream is(s);
is >> i >> j >> k;
if (is.fail()) return def;
else return TIndex3 (i, j, k);
}
TVector4d Str_Vector4N (const string &s, const TVector4d &def) {
float x, y, z, w;
template<typename T>
TVector4<T> Str_Vector4(const string &s, const TVector4<T> &def) {
T x, y, z, w;
istringstream is(s);
is >> x >> y >> z >> w;
if (is.fail()) return def;
else return TVector4d (x, y, z, w);
else return TVector4<T>(x, y, z, w);
}
template TVector4<double> Str_Vector4(const string &s, const TVector4<double> &def);
template TVector4<int> Str_Vector4(const string &s, const TVector4<int> &def);
TColor Str_ColorN (const string &s, const TColor &def) {
float r, g, b, a;
@ -191,11 +186,6 @@ void Str_ArrN (const string &s, float *arr, size_t count, float def) {
for (size_t i=0; i<count; i++) arr[i] = def;
}
string Bool_StrN (const bool val) {
if (val == true) return "true";
else return "false";
}
// --------------------------------------------------------------------
// SP functions for parsing lines
// --------------------------------------------------------------------
@ -236,21 +226,26 @@ float SPFloatN (const string &s, const string &tag, const float def) {
return (Str_FloatN (SPItemN (s, tag), def));
}
TVector2d SPVector2N (const string &s, const string &tag, const TVector2d& def) {
return (Str_Vector2N (SPItemN (s, tag), def));
template<typename T>
TVector2<T> SPVector2 (const string &s, const string &tag, const TVector2<T>& def) {
return (Str_Vector2(SPItemN (s, tag), def));
}
template TVector2<int> SPVector2(const string &s, const string &tag, const TVector2<int>& def);
template TVector2<double> SPVector2(const string &s, const string &tag, const TVector2<double>& def);
TVector3d SPVector3N (const string &s, const string &tag, const TVector3d& def) {
return (Str_Vector3N (SPItemN (s, tag), def));
template<typename T>
TVector3<T> SPVector3(const string &s, const string &tag, const TVector3<T>& def) {
return (Str_Vector3(SPItemN(s, tag), def));
}
template TVector3<int> SPVector3(const string &s, const string &tag, const TVector3<int>& def);
template TVector3<double> SPVector3(const string &s, const string &tag, const TVector3<double>& def);
TIndex3 SPIndex3N (const string &s, const string &tag, const TIndex3& def) {
return (Str_Index3N (SPItemN (s, tag), def));
}
TVector4d SPVector4N (const string &s, const string &tag, const TVector4d& def) {
return (Str_Vector4N (SPItemN (s, tag), def));
template<typename T>
TVector4<T> SPVector4(const string &s, const string &tag, const TVector4<T>& def) {
return (Str_Vector4(SPItemN(s, tag), def));
}
template TVector4<int> SPVector4(const string &s, const string &tag, const TVector4<int>& def);
template TVector4<double> SPVector4(const string &s, const string &tag, const TVector4<double>& def);
TColor SPColorN (const string &s, const string &tag, const TColor& def) {
return (Str_ColorN (SPItemN (s, tag), def));
@ -264,12 +259,6 @@ void SPArrN (const string &s, const string &tag, float *arr, size_t count, float
Str_ArrN (SPItemN (s, tag), arr, count, def);
}
bool SPExistsN (const string &s, const string &tag) {
string tg = '[' + tag + ']';
size_t i = SPosN (s, tg);
return i != string::npos;
}
size_t SPPosN (const string &s, const string &tag) {
string tg = '[' + tag + ']';
return SPosN (s, tg);
@ -320,32 +309,6 @@ void SPAddVec3N (string &s, const string &tag, const TVector3d &val, size_t coun
s += Float_StrN (val.z, count);
}
void SPAddIndx3N (string &s, const string &tag, const TIndex3 &val) {
s += '[';
s += tag;
s += ']';
s += ' ';
s += Int_StrN (val.i);
s += ' ';
s += Int_StrN (val.j);
s += ' ';
s += Int_StrN (val.k);
}
void SPAddIndx4N (string &s, const string &tag, const TIndex4 &val) {
s += '[';
s += tag;
s += ']';
s += ' ';
s += Int_StrN (val.i);
s += ' ';
s += Int_StrN (val.j);
s += ' ';
s += Int_StrN (val.k);
s += ' ';
s += Int_StrN (val.l);
}
void SPAddBoolN (string &s, const string &tag, const bool val) {
s += '[';
s += tag;

View File

@ -37,37 +37,43 @@ void STrimRightN (string &s);
void STrimN (string &s);
// ----- conversion functions -----------------------------------------
void Int_StrN (string &s, const int val);
string Int_StrN (const int val);
string Int_StrN (const int val, const streamsize count);
void Float_StrN (string &s, const float val, const streamsize count);
string Float_StrN (const float val, const streamsize count);
string Bool_StrN (const bool val);
string Vector_StrN (const TVector3d& v, const streamsize count);
int Str_IntN (const string &s, const int def);
bool Str_BoolN (const string &s, const bool def);
float Str_FloatN (const string &s, const float def);
TVector2d Str_Vector2N(const string &s, const TVector2d& def);
TVector3d Str_Vector3N(const string &s, const TVector3d& def);
TVector4d Str_Vector4N(const string &s, const TVector4d& def);
float Str_FloatN(const string &s, const float def);
template<typename T>
TVector2<T> Str_Vector2(const string &s, const TVector2<T>& def);
template<typename T>
TVector3<T> Str_Vector3(const string &s, const TVector3<T>& def);
template<typename T>
TVector4<T> Str_Vector4(const string &s, const TVector4<T>& def);
TColor Str_ColorN (const string &s, const TColor& def);
TColor3 Str_Color3N (const string &s, const TColor3& def);
void Str_ArrN (const string &s, float *arr, size_t count, float def);
string Bool_StrN (const bool val);
TIndex3 Str_Index3N (const string &s, const TIndex3& def);
// ----- SP functions for parsing lines --------------------------------
bool SPExistsN (const string &s, const string &tag);
size_t SPPosN (const string &s, const string &tag);
string SPItemN (const string &s, const string &tag);
string SPStrN (const string &s, const string &tag, const string& def = emptyString);
int SPIntN (const string &s, const string &tag, const int def);
bool SPBoolN (const string &s, const string &tag, const bool def);
float SPFloatN (const string &s, const string &tag, const float def);
TVector2d SPVector2N (const string &s, const string &tag, const TVector2d& def = NullVec2);
TVector3d SPVector3N (const string &s, const string &tag, const TVector3d& def = NullVec3);
TIndex3 SPIndex3N (const string &s, const string &tag, const TIndex3& def);
TVector4d SPVector4N (const string &s, const string &tag, const TVector4d& def);
template<typename T>
TVector2<T> SPVector2(const string &s, const string &tag, const TVector2<T>& def);
static inline TVector2d SPVector2d(const string &s, const string &tag) { return SPVector2(s, tag, NullVec2); }
static inline TVector2i SPVector2i(const string &s, const string &tag) { return SPVector2(s, tag, NullVec2i); }
template<typename T>
TVector3<T> SPVector3(const string &s, const string &tag, const TVector3<T>& def);
static inline TVector3d SPVector3d(const string &s, const string &tag) { return SPVector3(s, tag, NullVec3); }
static inline TVector3i SPVector3i(const string &s, const string &tag) { return SPVector3(s, tag, NullVec3i); }
template<typename T>
TVector4<T> SPVector4(const string &s, const string &tag, const TVector4<T>& def);
static inline TVector4d SPVector4d(const string &s, const string &tag) { return SPVector4(s, tag, NullVec4); }
static inline TVector4i SPVector4i(const string &s, const string &tag) { return SPVector4(s, tag, NullVec4i); }
TColor SPColorN (const string &s, const string &tag, const TColor& def);
TColor3 SPColor3N (const string &s, const string &tag, const TColor3& def);
void SPArrN (const string &s, const string &tag, float *arr, size_t count, float def);
@ -78,9 +84,7 @@ void SPAddFloatN (string &s, const string &tag, const float val, size_t cou
void SPAddStrN (string &s, const string &tag, const string &val);
void SPAddVec2N (string &s, const string &tag, const TVector2d& val, size_t count);
void SPAddVec3N (string &s, const string &tag, const TVector3d& val, size_t count);
void SPAddIndx3N (string &s, const string &tag, const TIndex3& val);
void SPAddIndx4N (string &s, const string &tag, const TIndex4& val);
void SPAddBoolN (string &s, const string &tag, const bool val);
void SPAddBoolN (string &s, const string &tag, const bool val);
// ----- manipulating SP strings --------------------------------------
void SPSetIntN (string &s, const string &tag, const int val);

View File

@ -338,11 +338,10 @@ TCharMaterial* CCharShape::GetMaterial (const string& mat_name) {
}
void CCharShape::CreateMaterial (const string& line) {
TVector3d diff = SPVector3N(line, "diff");
TVector3d spec = SPVector3N(line, "spec");
TVector3d diff = SPVector3d(line, "diff");
TVector3d spec = SPVector3d(line, "spec");
float exp = SPFloatN (line, "exp", 50);
std::string mat = SPItemN (line, "mat");
STrimN(mat);
std::string mat = SPStrN(line, "mat");
Materials.push_back(TCharMaterial());
Materials.back().diffuse.r = diff.x;
@ -447,13 +446,13 @@ bool CCharShape::Load (const string& dir, const string& filename, bool with_acti
bool shadow = SPBoolN (line, "shad", false);
string order = SPStrN (line, "order");
CreateCharNode (parent_name, node_name, name, fullname, order, shadow);
TVector3d rot = SPVector3N (line, "rot");
TVector3d rot = SPVector3d(line, "rot");
MaterialNode (node_name, mat_name);
for (size_t ii = 0; ii < order.size(); ii++) {
int act = order[ii]-48;
switch (act) {
case 0: {
TVector3d trans = SPVector3N(line, "trans");
TVector3d trans = SPVector3d(line, "trans");
TranslateNode (node_name, trans);
break;
}
@ -467,7 +466,7 @@ bool CCharShape::Load (const string& dir, const string& filename, bool with_acti
RotateNode (node_name, 3, rot.z);
break;
case 4: {
TVector3d scale = SPVector3N (line, "scale", TVector3d (1,1,1));
TVector3d scale = SPVector3(line, "scale", TVector3d(1, 1, 1));
ScaleNode (node_name, scale);
break;
}

View File

@ -24,6 +24,10 @@ GNU General Public License for more details.
const TVector2d NullVec2;
const TVector3d NullVec3;
const TVector4d NullVec4;
const TVector2i NullVec2i;
const TVector3i NullVec3i;
const TVector4i NullVec4i;
// Instanciate only functions we actually need

View File

@ -164,6 +164,10 @@ TVector3d CrossProduct(const TVector3d& u, const TVector3d& v);
extern const TVector2d NullVec2;
extern const TVector3d NullVec3;
extern const TVector4d NullVec4;
extern const TVector2i NullVec2i;
extern const TVector3i NullVec3i;
extern const TVector4i NullVec4i;
#endif