24 vector(
const T* &pv){
x = pv[0];
y = pv[1];
z = pv[2];};
27 {
x = pv.
x;
y = pv.
y;
z = pv.
z;
return *
this;};
28 inline void Set(T px, T py, T pz){
x=px;
y=py;
z=pz;};
38 void Normalize(
void){
vector<T> pv((T)(
x*
x),(T)(
y*
y), (T)(
z*
z));T fLength = (T)(1.0f/(
float)(pv.
x + pv.
y + pv.
z));
if (fLength < 1e-08)
return;
x = (T)(pv.
x * fLength);
y = (T)(pv.
y * fLength);
z = (T)(pv.
z * fLength);};
44 template<
typename T,
int size>
49 Array(
const T* pT){memcpy(
data, pT, size *
sizeof(T));};
52 {memcpy(
data, pA.data, size *
sizeof(T));
return *
this;};
60 typedef Array<unsigned short, 3>
Face;
61 typedef Array<float, 3>
Vertex;
62 typedef Array<float, 2>
TCoord;
63 typedef Array<float, 4>
Color4;
64 typedef Array<float, 3>
Color3;
85 void Zero(
void){memset(
data, 0, 16 *
sizeof(T));};
99 T _fastcall
Index(
int pRow,
int pCol)
const{
return data[(pRow<<2) + pCol];};
113 template <
typename T>
121 {
xs = prect.
xs;
ys = prect.
ys;
xe = prect.
xe;
ye = prect.
ye;
return *
this;};
123 {
xs += pV.
x;
ys += pV.
y;
xe += pV.
x;
ye += pV.
y;
return *
this;};
126 trect(
const T pxs,
const T pys,
const T pxe,
const T pye)
127 {
xs = pxs;
ys = pys;
xe = pxe;
ye = pye;};
128 inline void Set(
const T pxs,
const T pys,
const T pxe,
const T pye)
129 {
xs = pxs;
ys = pys;
xe = pxe;
ye = pye;};
130 bool _fastcall
InRect(
const T &px,
const T &py)
131 {
if (px <
xs)
return false;
132 if (px >
xe)
return false;
133 if (py <
ys)
return false;
134 if (py >
ye)
return false;
137 {
if (pv.
x <
xs)
return false;
138 if (pv.
x >
xe)
return false;
139 if (pv.
y <
ys)
return false;
140 if (pv.
y >
ye)
return false;
149 {
if ((prect.
xe <=
xe) &&
156 {
if (prect.
xe <
xs)
return false;
157 if (prect.
xs >
xe)
return false;
158 if (prect.
ye <
ys)
return false;
159 if (prect.
ys >
ye)
return false;
172 template<
typename T,
int size>
175 for (
int i= 0; i< size; i++)
176 data[i] += pA.data[i];
180 template<
typename T,
int size>
184 memcpy(rdata,
data, size *
sizeof(T));
185 for (
int i= 0; i< size; i++)
190 template<
typename T,
int size>
194 for (
int i= 0; i< size; i++)
195 rdata[i]=
data[i] + pA.data[i];
203 for(k = 0; k < 16; k++)
212 for(k = 0; k < 16; k++)
221 for (row = 0; row < 16; row +=4)
222 for (col = 0; col < 4; col ++)
225 Rdata[row + col] = 0;
226 for (k = 0; k < 4; k++, l += 4)
227 Rdata[row + col] +=
data[row + k] * pm.
data[l + col];
236 for (row = 0; row < 16; row +=4)
237 for (col = 0; col < 4; col ++)
240 Rdata[row + col] = 0;
241 for (k = 0; k < 4; k++, l += 4)
242 Rdata[row + col] +=
data[row + k] * pm.
data[l + col];
244 memcpy(
data, Rdata, 16*
sizeof(T));
252 memcpy(Rdata,
data, 16 *
sizeof(T));
253 for(k = 0; k < 16; k++)
261 T vdata[4], pvdata[4];
266 for (col = 0; col < 4; col++)
270 for (row = 0; row < 4; row++, k+=4)
271 vdata[col] +=
data[k + col]*pvdata[row];
279 T vdata[4], pvdata[4];
281 memcpy(pvdata, pV.data, 3*
sizeof(T));
284 for (col = 0; col < 4; col++)
288 for (row = 0; row < 4; row++, k+=4)
289 vdata[col] +=
data[k + col]*pvdata[row];
Using X files without the sources and the makefile How to use you just create a debug directory e the sample3 directory must contain Sample3 Final Sample3 exe Sample3 Final Debug Sample3 Final Gfx OpenGL bmp Sample3 Final Gfx tiny_skin bmp Sample3 Final Gfx tiny_4anim x The source files have the DevCpp project file plus the makefile The demos use standard FreeGlut functions Technical without warranty Neither Paul Coppens nor GameDev net make any or either express or with respect to the their or fitness for a specific purpose neither Paul Coppens nor GameDev net shall have any liability to you or any other person or entity with respect to any or damage caused or alleged to have been caused directly or indirectly by the programs provided by Paul Coppens and GameDev net This but is not limited interruption of loss of data
Definition: Readme.txt:39
Definition: Frm_3DMath.h:79
matrix< T > operator*(T pT)
Definition: Frm_3DMath.h:249
T & operator[](int index)
Definition: Frm_3DMath.h:97
vector< T > GetRow(int index)
Definition: Frm_3DMath.h:102
void Zero(void)
Definition: Frm_3DMath.h:85
matrix< T > operator*(matrix< T > &pm)
Definition: Frm_3DMath.h:218
matrix(const T *pT)
Definition: Frm_3DMath.h:84
void Identity(void)
Definition: Frm_3DMath.h:86
matrix(const matrix< T > &pm)
Definition: Frm_3DMath.h:83
matrix< T > operator-(matrix< T > &pm)
Definition: Frm_3DMath.h:209
matrix< T > & operator*=(matrix< T > &pm)
Definition: Frm_3DMath.h:233
T data[16]
Definition: Frm_3DMath.h:81
matrix< T > & operator=(const matrix< T > &pm)
Definition: Frm_3DMath.h:87
vector< T > GetColumn(int index)
Definition: Frm_3DMath.h:103
matrix< T > operator+(matrix< T > &pm)
Definition: Frm_3DMath.h:200
T operator()(int pRow, int pCol) const
Definition: Frm_3DMath.h:100
T _fastcall Index(int pRow, int pCol) const
Definition: Frm_3DMath.h:99
Array< T, 3 > operator*(const Array< T, 3 > &pV)
Definition: Frm_3DMath.h:277
matrix(void)
Definition: Frm_3DMath.h:82
vector< T > operator*(const vector< T > &pV)
Definition: Frm_3DMath.h:259
T operator[](int index) const
Definition: Frm_3DMath.h:96
T & operator()(int pRow, int pCol)
Definition: Frm_3DMath.h:101
Definition: Frm_3DMath.h:114
bool _fastcall Union(const trect< T > &prect)
Definition: Frm_3DMath.h:161
trect< T > & operator=(const trect< T > &prect)
Definition: Frm_3DMath.h:120
bool _fastcall InRect(const trect< T > &prect)
Definition: Frm_3DMath.h:148
trect(const T pxs, const T pys, const T pxe, const T pye)
Definition: Frm_3DMath.h:126
trect(void)
Definition: Frm_3DMath.h:117
T ys
Definition: Frm_3DMath.h:116
bool _fastcall InRect(const T &px, const T &py)
Definition: Frm_3DMath.h:130
bool _fastcall InRect(const vector< T > &pv)
Definition: Frm_3DMath.h:136
trect< T > & operator+=(const vector< T > &pV)
Definition: Frm_3DMath.h:122
trect(const trect< T > &prect)
Definition: Frm_3DMath.h:118
bool _fastcall Intersect(const trect< T > &prect)
Definition: Frm_3DMath.h:155
T xs
Definition: Frm_3DMath.h:116
T xe
Definition: Frm_3DMath.h:116
T ye
Definition: Frm_3DMath.h:116
void Set(const T pxs, const T pys, const T pxe, const T pye)
Definition: Frm_3DMath.h:128
Definition: Frm_3DMath.h:16
vector< T > & operator=(const vector< T > &pv)
Definition: Frm_3DMath.h:26
T y
Definition: Frm_3DMath.h:18
T & operator[](int index)
Definition: Frm_3DMath.h:32
vector< T > operator*(T pT) const
Definition: Frm_3DMath.h:36
vector< T > Cross(vector< T > pV) const
Definition: Frm_3DMath.h:40
bool operator>(const vector< T > &pv)
Definition: Frm_3DMath.h:29
vector(T px, T py, T pz)
Definition: Frm_3DMath.h:22
void Set(T px, T py, T pz)
Definition: Frm_3DMath.h:28
vector< T > operator+(vector< T > pv) const
Definition: Frm_3DMath.h:34
T x
Definition: Frm_3DMath.h:18
vector(const T *&pv)
Definition: Frm_3DMath.h:24
vector< T > operator-(vector< T > pv) const
Definition: Frm_3DMath.h:35
vector(const vector< T > &pv)
Definition: Frm_3DMath.h:23
vector(void)
Definition: Frm_3DMath.h:21
T operator[](int index) const
Definition: Frm_3DMath.h:31
vector< T > UnitCross(vector< T > pV) const
Definition: Frm_3DMath.h:41
T Dot(vector< T > pV) const
Definition: Frm_3DMath.h:39
void Normalize(void)
Definition: Frm_3DMath.h:38
T z
Definition: Frm_3DMath.h:18
Array< T, 2 > Set2(T pu, T pv)
Definition: Frm_3DMath.h:42
Array< T, 3 > Set3(T px, T py, T pz)
Definition: Frm_3DMath.h:39
Array< float, 3 > Vertex
Definition: Frm_3DMath.h:30
matrix< float > glMatrix
Definition: Frm_3DMath.h:109
Array< float, 4 > Color4
Definition: Frm_3DMath.h:32
Array< T, 4 > Set4(T px, T py, T pz, T pw)
Definition: Frm_3DMath.h:36
Array< float, 2 > TCoord
Definition: Frm_3DMath.h:31
Array< float, 3 > Color3
Definition: Frm_3DMath.h:33
Array< unsigned short, 3 > Face
Definition: Frm_3DMath.h:58
uint16 index
Definition: sample3.cpp:29
Definition: Frm_3DMath.h:15
Array(const T *pT)
Definition: Frm_3DMath.h:49
Array< T, size > operator+(Array< T, size > &pA)
Definition: Frm_3DMath.h:65
Array(void)
Definition: Frm_3DMath.h:47
Array< T, size > & operator=(Array< T, size > pA)
Definition: Frm_3DMath.h:51
Array< T, size > operator*(const T pScalar)
Definition: Frm_3DMath.h:181
T data[size]
Definition: Frm_3DMath.h:16
T & operator[](int index)
Definition: Frm_3DMath.h:57
T operator[](int index) const
Definition: Frm_3DMath.h:56
Array(const Array< T, size > &pA)
Definition: Frm_3DMath.h:48
Array< T, size > & operator+=(Array< T, size > &pA)
Definition: Frm_3DMath.h:47
Array< T, size > & operator+=(Array< T, size > &pA)
Array< T, size > operator+(Array< T, size > &pA)