mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2025-01-27 17:58:42 +00:00
116 lines
3.6 KiB
C++
116 lines
3.6 KiB
C++
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
|
// Copyright (C) 2010 Winch Gate Property Limited
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#ifndef NL_MATRIX_3X4_H
|
|
#define NL_MATRIX_3X4_H
|
|
|
|
#include "nel/misc/types_nl.h"
|
|
|
|
|
|
namespace NL3D
|
|
{
|
|
|
|
|
|
// ***************************************************************************
|
|
// ***************************************************************************
|
|
// STD Matrix
|
|
// ***************************************************************************
|
|
// ***************************************************************************
|
|
|
|
|
|
// ***************************************************************************
|
|
/**
|
|
* For fast vector/point multiplication. Special usage for Skinning.
|
|
* \author Lionel Berenguier
|
|
* \author Nevrax France
|
|
* \date 2002
|
|
*/
|
|
class CMatrix3x4
|
|
{
|
|
public:
|
|
// Order them in memory line first, for faster memory access.
|
|
float a11, a12, a13, a14;
|
|
float a21, a22, a23, a24;
|
|
float a31, a32, a33, a34;
|
|
|
|
// Copy from a matrix.
|
|
void set(const CMatrix &mat)
|
|
{
|
|
const float *m =mat.get();
|
|
a11= m[0]; a12= m[4]; a13= m[8] ; a14= m[12];
|
|
a21= m[1]; a22= m[5]; a23= m[9] ; a24= m[13];
|
|
a31= m[2]; a32= m[6]; a33= m[10]; a34= m[14];
|
|
}
|
|
|
|
|
|
// mulSetvector. NB: in should be different as v!! (else don't work).
|
|
void mulSetVector(const CVector &in, CVector &out)
|
|
{
|
|
out.x= (a11*in.x + a12*in.y + a13*in.z);
|
|
out.y= (a21*in.x + a22*in.y + a23*in.z);
|
|
out.z= (a31*in.x + a32*in.y + a33*in.z);
|
|
}
|
|
// mulSetpoint. NB: in should be different as v!! (else don't work).
|
|
void mulSetPoint(const CVector &in, CVector &out)
|
|
{
|
|
out.x= (a11*in.x + a12*in.y + a13*in.z + a14);
|
|
out.y= (a21*in.x + a22*in.y + a23*in.z + a24);
|
|
out.z= (a31*in.x + a32*in.y + a33*in.z + a34);
|
|
}
|
|
|
|
|
|
// mulSetvector. NB: in should be different as v!! (else don't work).
|
|
void mulSetVector(const CVector &in, float scale, CVector &out)
|
|
{
|
|
out.x= (a11*in.x + a12*in.y + a13*in.z) * scale;
|
|
out.y= (a21*in.x + a22*in.y + a23*in.z) * scale;
|
|
out.z= (a31*in.x + a32*in.y + a33*in.z) * scale;
|
|
}
|
|
// mulSetpoint. NB: in should be different as v!! (else don't work).
|
|
void mulSetPoint(const CVector &in, float scale, CVector &out)
|
|
{
|
|
out.x= (a11*in.x + a12*in.y + a13*in.z + a14) * scale;
|
|
out.y= (a21*in.x + a22*in.y + a23*in.z + a24) * scale;
|
|
out.z= (a31*in.x + a32*in.y + a33*in.z + a34) * scale;
|
|
}
|
|
|
|
|
|
// mulAddvector. NB: in should be different as v!! (else don't work).
|
|
void mulAddVector(const CVector &in, float scale, CVector &out)
|
|
{
|
|
out.x+= (a11*in.x + a12*in.y + a13*in.z) * scale;
|
|
out.y+= (a21*in.x + a22*in.y + a23*in.z) * scale;
|
|
out.z+= (a31*in.x + a32*in.y + a33*in.z) * scale;
|
|
}
|
|
// mulAddpoint. NB: in should be different as v!! (else don't work).
|
|
void mulAddPoint(const CVector &in, float scale, CVector &out)
|
|
{
|
|
out.x+= (a11*in.x + a12*in.y + a13*in.z + a14) * scale;
|
|
out.y+= (a21*in.x + a22*in.y + a23*in.z + a24) * scale;
|
|
out.z+= (a31*in.x + a32*in.y + a33*in.z + a34) * scale;
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
} // NL3D
|
|
|
|
|
|
#endif // NL_MATRIX_3X4_H
|
|
|
|
/* End of matrix_3x4.h */
|