trackgen: add per axis matrix scale and rotation
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8891 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 38efe17dae012e2f37d9eefb1cfb219815b39a8d Former-commit-id: 573d261795d394771356e63c27309ded5ca6309a
This commit is contained in:
parent
4251707d60
commit
44aa9dfbf3
4 changed files with 101 additions and 15 deletions
|
@ -481,6 +481,75 @@ void Ac3d::Matrix::setRotation(const std::array<double, 9> &rotation)
|
||||||
(*this)[2][0] = rotation[6]; (*this)[2][1] = rotation[7]; (*this)[2][2] = rotation[8];
|
(*this)[2][0] = rotation[6]; (*this)[2][1] = rotation[7]; (*this)[2][2] = rotation[8];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const double PI = 3.14159265358979323846;
|
||||||
|
|
||||||
|
void Ac3d::Matrix::setRotation(double x, double y, double z)
|
||||||
|
{
|
||||||
|
double cx, sx, cy, sy, cz, sz, szsy, czsy, szcy;
|
||||||
|
|
||||||
|
if (x == 0)
|
||||||
|
{
|
||||||
|
cx = 1;
|
||||||
|
sx = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const double ax = x * PI / 180.0;
|
||||||
|
sx = sin(ax);
|
||||||
|
cx = cos(ax);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y == 0)
|
||||||
|
{
|
||||||
|
cy = 1;
|
||||||
|
sy = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const double ay = y * PI / 180.0;
|
||||||
|
sy = sin(ay);
|
||||||
|
cy = cos(ay);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (z == 0)
|
||||||
|
{
|
||||||
|
cz = 1;
|
||||||
|
sz = 0;
|
||||||
|
szsy = 0;
|
||||||
|
szcy = 0;
|
||||||
|
czsy = sy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const double az = z * PI / 180.0;
|
||||||
|
sz = sin(az);
|
||||||
|
cz = cos(az);
|
||||||
|
szsy = sz * sy;
|
||||||
|
czsy = cz * sy;
|
||||||
|
szcy = sz * cy;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*this)[0][0] = cx * cz - sx * szsy;
|
||||||
|
(*this)[1][0] = -sx * cy;
|
||||||
|
(*this)[2][0] = sz * cx + sx * czsy;
|
||||||
|
(*this)[3][0] = 0;
|
||||||
|
|
||||||
|
(*this)[0][1] = cz * sx + szsy * cx;
|
||||||
|
(*this)[1][1] = cx * cy;
|
||||||
|
(*this)[2][1] = sz * sx - czsy * cx;
|
||||||
|
(*this)[3][1] = 0;
|
||||||
|
|
||||||
|
(*this)[0][2] = -szcy;
|
||||||
|
(*this)[1][2] = sy;
|
||||||
|
(*this)[2][2] = cz * cy;
|
||||||
|
(*this)[3][2] = 0;
|
||||||
|
|
||||||
|
(*this)[0][3] = 0;
|
||||||
|
(*this)[1][3] = 0;
|
||||||
|
(*this)[2][3] = 0;
|
||||||
|
(*this)[3][3] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void Ac3d::Matrix::setScale(double scale)
|
void Ac3d::Matrix::setScale(double scale)
|
||||||
{
|
{
|
||||||
(*this)[0][0] = scale;
|
(*this)[0][0] = scale;
|
||||||
|
@ -489,6 +558,14 @@ void Ac3d::Matrix::setScale(double scale)
|
||||||
(*this)[3][2] = 1;
|
(*this)[3][2] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ac3d::Matrix::setScale(double x, double y, double z)
|
||||||
|
{
|
||||||
|
(*this)[0][0] = x;
|
||||||
|
(*this)[1][1] = y;
|
||||||
|
(*this)[2][2] = z;
|
||||||
|
(*this)[3][2] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void Ac3d::Matrix::makeIdentity()
|
void Ac3d::Matrix::makeIdentity()
|
||||||
{
|
{
|
||||||
(*this)[0][0] = 1; (*this)[0][1] = 0; (*this)[0][2] = 0; (*this)[0][3] = 0;
|
(*this)[0][0] = 1; (*this)[0][1] = 0; (*this)[0][2] = 0; (*this)[0][3] = 0;
|
||||||
|
@ -525,6 +602,12 @@ void Ac3d::Matrix::makeRotation(const std::array<double, 9> &rotation)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ac3d::Matrix::makeRotation(double x, double y, double z)
|
||||||
|
{
|
||||||
|
makeIdentity();
|
||||||
|
setRotation(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
void Ac3d::Matrix::makeScale(double scale)
|
void Ac3d::Matrix::makeScale(double scale)
|
||||||
{
|
{
|
||||||
(*this)[0][0] = scale; (*this)[0][1] = 0; (*this)[0][2] = 0; (*this)[0][3] = 0;
|
(*this)[0][0] = scale; (*this)[0][1] = 0; (*this)[0][2] = 0; (*this)[0][3] = 0;
|
||||||
|
@ -533,6 +616,14 @@ void Ac3d::Matrix::makeScale(double scale)
|
||||||
(*this)[3][0] = 0; (*this)[3][1] = 0; (*this)[3][2] = 0; (*this)[3][3] = 1;
|
(*this)[3][0] = 0; (*this)[3][1] = 0; (*this)[3][2] = 0; (*this)[3][3] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ac3d::Matrix::makeScale(double x, double y, double z)
|
||||||
|
{
|
||||||
|
(*this)[0][0] = x; (*this)[0][1] = 0; (*this)[0][2] = 0; (*this)[0][3] = 0;
|
||||||
|
(*this)[1][0] = 0; (*this)[1][1] = y; (*this)[1][2] = 0; (*this)[1][3] = 0;
|
||||||
|
(*this)[2][0] = 0; (*this)[2][1] = 0; (*this)[2][2] = z; (*this)[2][3] = 0;
|
||||||
|
(*this)[3][0] = 0; (*this)[3][1] = 0; (*this)[3][2] = 0; (*this)[3][3] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void Ac3d::Matrix::transformPoint(v3d &point) const
|
void Ac3d::Matrix::transformPoint(v3d &point) const
|
||||||
{
|
{
|
||||||
v3d dst;
|
v3d dst;
|
||||||
|
|
|
@ -155,12 +155,16 @@ struct Ac3d
|
||||||
void setLocation(const v3 &location);
|
void setLocation(const v3 &location);
|
||||||
void setLocation(double x, double y, double z);
|
void setLocation(double x, double y, double z);
|
||||||
void setRotation(const std::array<double, 9> &rotation);
|
void setRotation(const std::array<double, 9> &rotation);
|
||||||
|
void setRotation(double x, double y, double z);
|
||||||
void setScale(double scale);
|
void setScale(double scale);
|
||||||
|
void setScale(double x, double y, double z);
|
||||||
void makeIdentity();
|
void makeIdentity();
|
||||||
void makeLocation(const v3 &location);
|
void makeLocation(const v3 &location);
|
||||||
void makeLocation(double x, double y, double z);
|
void makeLocation(double x, double y, double z);
|
||||||
void makeRotation(const std::array<double, 9> &rotation);
|
void makeRotation(const std::array<double, 9> &rotation);
|
||||||
|
void makeRotation(double x, double y, double z);
|
||||||
void makeScale(double scale);
|
void makeScale(double scale);
|
||||||
|
void makeScale(double x, double y, double z);
|
||||||
void transformPoint(v3d &point) const;
|
void transformPoint(v3d &point) const;
|
||||||
void transformNormal(v3d &normal) const;
|
void transformNormal(v3d &normal) const;
|
||||||
Matrix multiply(const Matrix &matrix);
|
Matrix multiply(const Matrix &matrix);
|
||||||
|
|
|
@ -70,15 +70,7 @@ struct objdef
|
||||||
std::string fileName;
|
std::string fileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<objdef> objects;
|
static std::vector<objdef> objects;
|
||||||
|
|
||||||
int
|
|
||||||
GetObjectsNb(void *TrackHandle)
|
|
||||||
{
|
|
||||||
static const char *section = TRK_SECT_TERRAIN "/" TRK_SECT_OBJMAP;
|
|
||||||
|
|
||||||
return GfParmGetEltNb(TrackHandle, section);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ApplyTransform(sgMat4 m, ssgBase *node)
|
ApplyTransform(sgMat4 m, ssgBase *node)
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#define _OBJECTS_H_
|
#define _OBJECTS_H_
|
||||||
|
|
||||||
extern void GenerateObjects(tTrack *track, void *TrackHandle, void *CfgHandle, Ac3d &allAc3d, bool all, const std::string &meshFile, const std::string &outputFile);
|
extern void GenerateObjects(tTrack *track, void *TrackHandle, void *CfgHandle, Ac3d &allAc3d, bool all, const std::string &meshFile, const std::string &outputFile);
|
||||||
extern int GetObjectsNb(void *TrackHandle);
|
|
||||||
|
|
||||||
#endif /* _OBJECTS_H_ */
|
#endif /* _OBJECTS_H_ */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue