Re: Question for Diego Park and oc you
memcpy(iktransf,keyframes+animations[animation].index,numbones*sizeof(spatial_t<real>));
More info:
spatial_t<real> iktransf[MAX_BONES];
////////////////////////////////
template <class real>
class spatial_t
{
public:
spatial_t();
vector3_t<real> operator*(const vector3_t<real>& vec) const;
matrix3_t<real> rotation;
vector3_t<real> position;
};
Animation is spatial_t<real>, but its member "index" is an "int".
numbones is an int as well. How can a class be added to an integer and
then memcpy'ed to a spatial<real>
Any thoughts?
Jack, the information you provided doesn't make sense. What is
`keyframes'? According to the declaration of `spatial_t' template there is
no `index' member, too. Also, `matrix3_t' and `vector3_t' types are
undefined, so it's impossible to tell definitely what's going on there.
////////////////////////////////////////////////////
More and more info:
--------------------------------------------------
sequence_t<real> animations[MAX_SEQUENCES];
spatial_t<real> keyframes[MAX_KEYFRAMES];
int animation;
template <class real>
class sequence_t
{
public:
sequence_t();
real fps;
int index;
int numframes;
};
// vector3_t
------------------------------------------------
template <class real>
class vector3_t
{
public:
vector3_t();
vector3_t(const real vec[3]);
vector3_t(real rx,real ry,real rz);
vector3_t(const vector3_t& vec);
vector3_t abs() const;
real dot(const vector3_t& vec) const;
vector3_t cross(const vector3_t& vec) const;
real length() const;
real normalize();
real sqlength() const;
vector3_t operator+(const vector3_t& vec) const;
vector3_t operator-(const vector3_t& vec) const;
vector3_t operator*(real scalar) const;
vector3_t operator/(real scalar) const;
vector3_t operator-() const;
vector3_t& operator+=(const vector3_t& vec);
vector3_t& operator-=(const vector3_t& vec);
vector3_t& operator*=(real scalar);
vector3_t& operator/=(real scalar);
bool operator==(const vector3_t& vec) const;
bool operator!=(const vector3_t& vec) const;
bool operator<(const vector3_t& vec) const;
real operator[](int i) const;
real& operator[](int i);
operator const real*() const;
operator real*();
real x;
real y;
real z;
static const vector3_t ZERO;
static const vector3_t UNIT_X;
static const vector3_t UNIT_Y;
static const vector3_t UNIT_Z;
static const vector3_t MAX_REAL;
};
// matrix3_t
------------------------------------------------
template <class real>
class matrix3_t
{
public:
matrix3_t();
matrix3_t(const real mat[3][3]);
matrix3_t(const matrix3_t& mat);
matrix3_t( real mat00,real mat01,real mat02,
real mat10,real mat11,real mat12,
real mat20,real mat21,real mat22);
real determinant() const;
matrix3_t inverse() const;
matrix3_t transpose() const;
void from_zyx(real z,real y,real x);
matrix3_t operator+(const matrix3_t& mat) const;
matrix3_t operator-(const matrix3_t& mat) const;
matrix3_t operator*(const matrix3_t& mat) const;
matrix3_t operator*(real scalar) const;
matrix3_t operator/(real scalar) const;
matrix3_t& operator+=(const matrix3_t& mat);
matrix3_t& operator-=(const matrix3_t& mat);
matrix3_t& operator*=(real scalar);
matrix3_t& operator/=(real scalar);
vector3_t<real> operator*(const vector3_t<real>& vec) const;
bool operator==(const matrix3_t& mat) const;
const real* operator[](int i) const;
real* operator[](int i);
operator const real*() const;
operator real*();
static const matrix3_t ZERO;
static const matrix3_t IDENTITY;
static const matrix3_t MAX_REAL;
protected:
real matrix[3][3];
};
It seems that one or more instances of `spatial_t' are copied to an array
with `memcpy' call. Usually copying objects with `memcpy' is wrong because
`memcpy' just copies memory bits and completely ignores class' copy
semantics. Only POD (plain old data) structures can be copied with defined
result.
The data to be obtained is quite "raw"... It is called the SMD format
You can find the info here
http://developer.valvesoftware.com/wiki/SMD_file_format
Unless `matrix3_t' and `vector3_t' classes (and other members of
`spatial_t' template) are specifically designed to be copied with `memcpy'
such copy will break them. Why don't you just assign it:
:) ha ha, because it is not my source code, I downloaded it from here (by
Diego Park)
http://diegopark.googlepages.com/computerGraphics.pdf
spatial_t<real>* src =
keyframes + animations[animation].index;
for(size_t i = 0; i < numbones && i < MAX_BONES; ++i)
{
iktransf[i] = src[i];
}
Seems to be the SMD thing that makes Diego make this decision.
Thanks
Jack