-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModel.cpp
650 lines (542 loc) · 17.2 KB
/
Model.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
/*
Model.cpp
Abstract base class for a model. The specific extended class will render the given model.
Author: Brett Porter
Email: brettporter@yahoo.com
Website: http://www.geocities.com/brettporter/
Copyright (C)2000, Brett Porter. All Rights Reserved.
This file may be used only as long as this copyright notice remains intact.
*/
#include "stdafx.h"
#include "Model.h"
#include <glm/gtc/matrix_transform.hpp>
#include <omp.h>
Model::Model()
{
m_usNumMeshes = 0;
m_pMeshes = NULL;
m_numMaterials = 0;
m_pMaterials = NULL;
m_usNumTriangles = 0;
m_pTriangles = NULL;
m_usNumVerts = 0;
m_pVertices = NULL;
m_load = false;
bFirstTime = true;
m_bPlay = true;
#if ENABLE_DRAW
m_bDrawBones = false;
m_bDrawMesh = true;
#else
m_bDrawBones = true;
m_bDrawMesh = false;
#endif
m_pIndexArray = NULL;
maxMeshVertexNumber = 0;
m_pJointsMatrix = NULL;
}
Model::~Model()
{
int i;
for ( i = 0; i < m_usNumMeshes; i++ )
delete[] m_pMeshes[i].m_uspIndices;
for ( i = 0; i < m_numMaterials; i++ )
delete[] m_pMaterials[i].m_pTextureFilename;
m_usNumMeshes = 0;
if ( m_pMeshes != NULL )
{
delete[] m_pMeshes;
m_pMeshes = NULL;
}
m_numMaterials = 0;
if ( m_pMaterials != NULL )
{
delete[] m_pMaterials;
m_pMaterials = NULL;
}
m_usNumTriangles = 0;
if ( m_pTriangles != NULL )
{
delete[] m_pTriangles;
m_pTriangles = NULL;
}
m_usNumVerts = 0;
if ( m_pVertices != NULL )
{
delete[] m_pVertices;
m_pVertices = NULL;
}
if (m_pIndexArray)
{
delete[] m_pIndexArray;
m_pIndexArray = NULL;
}
if (m_pJointsMatrix)
{
delete[] m_pJointsMatrix;
m_pJointsMatrix = NULL;
}
}
void Model::draw()
{
#if RENDERMODE_MOVING
getPlayTime( 1, 0, m_fTotalTime , true);
// float rotation[3] = { 90,90,90 };
//
// for (int i = 0; i < m_usNumJoints; i++)
// {
// }
updateJoints(fTime);
modifyVertexByJoint();
#endif
glColor3f(1, 1, 1);
updateJoints();
modifyVertexByJointInit();
GLboolean texEnabled = glIsEnabled( GL_TEXTURE_2D );
// texEnabled = false;
if(m_bDrawMesh)
{
// Draw by group
for ( int i = 0; i < m_usNumMeshes; i++ )
{
#if ENABLE_CROSSARRAY
glInterleavedArrays(GL_T2F_N3F_V3F, 0, m_meshVertexData.m_pMesh[i].pVertexArrayDynamic);
#else
glVertexPointer(3, GL_FLOAT, 12, m_meshVertexData.m_pMesh[i].pVertexArrayDynamic);
glEnableClientState( GL_VERTEX_ARRAY );
#endif
#if RENDERMODE_POINT
glDrawArrays(GL_POINTS, 0, m_pMeshes[i].m_usNumTris * 3 );
#else
glDrawElements(GL_TRIANGLES, m_meshVertexData.m_pMesh[i].numOfVertex,
GL_UNSIGNED_INT , m_pIndexArray);
#endif
#if !ENABLE_CROSSARRAY
glDisableClientState( GL_VERTEX_ARRAY );
#endif
}
}
if ( texEnabled )
glEnable( GL_TEXTURE_2D );
else
glDisable( GL_TEXTURE_2D );
}
void Model::updateJoints(void)
{
//std::cout << "Current Time: " << fTime << std::endl;
// update matrix
for (int i = 0; i < 1; i++)
{
// update matrix
for (int x = 0; x < m_usNumJoints; x++)
{
//Transformation matrix
vgMs3d::CMatrix4X4 matTmp;
//Current joint
MS3DJoint * pJoint = &m_pJoints[x];
//Calculate the rotation
//If its at the extremes
float rotation[3] = { glm::radians(ModelRotation[x][0]) ,glm::radians(ModelRotation[x][1]) , glm::radians(ModelRotation[x][2]) };
matTmp.SetRotation(rotation);
//Calculate the joints final transformation
vgMs3d::CMatrix4X4 matFinal = pJoint->m_matLocal * matTmp;
//if there is no parent, just use the matrix you just made
if (pJoint->m_sParent == -1)
pJoint->m_matFinal = matFinal;
//otherwise the final matrix is the parents final matrix * the new matrix
else
pJoint->m_matFinal = m_pJoints[pJoint->m_sParent].m_matFinal * matFinal;
}//x
for (int i = 0; i < m_usNumJoints; i++)
{
memcpy(m_pJointsMatrix + 16 * i, &(m_pJoints[i].m_matFinal), sizeof(float) * 16);
}
}//i
}
// void Model::updateJoints(float fTime)
// {
//
//
// //std::cout << "Current Time: " << fTime << std::endl;
// // update matrix
// for(int i = 0; i < 1; i++)
// {
// // update matrix
// for (int x = 0; x < m_usNumJoints; x++)
// {
// //Transformation matrix
// glm::mat4 matTmp;
// //Current joint
// MS3DJoint * pJoint = &m_pJoints[x];
// //Current frame]
// unsigned int uiFrame = 0;
//
// //if there are no keyframes, don't do any transformations
// if (pJoint->m_usNumRotFrames == 0 && pJoint->m_TransKeyFrames == 0)
// {
// pJoint->m_matFinal = pJoint->m_matAbs;
// continue;
// }
// //Calculate the current frame
// //Translation
// while (uiFrame < pJoint->m_usNumTransFrames && pJoint->m_TransKeyFrames[uiFrame].m_fTime < fTime)
// uiFrame++;
//
// glm::vec3 fTranslation;
// float fDeltaT = 1;
// float fInterp = 0;
//
// //If its at the extremes
// if (uiFrame == 0)
// memcpy(fTranslation, pJoint->m_TransKeyFrames[0].m_fParam, sizeof(float[3]));
// else if (uiFrame == pJoint->m_usNumTransFrames)
// memcpy(fTranslation, pJoint->m_TransKeyFrames[uiFrame - 1].m_fParam, sizeof(float[3]));
// //If its in the middle of two frames
// else
// {
// MS3DKeyframe * pkCur = &pJoint->m_TransKeyFrames[uiFrame];
// MS3DKeyframe * pkPrev = &pJoint->m_TransKeyFrames[uiFrame - 1];
//
// fDeltaT = pkCur->m_fTime - pkPrev->m_fTime;
// fInterp = (fTime - pkPrev->m_fTime) / fDeltaT;
//
// //Interpolate between the translations
// fTranslation[0] = pkPrev->m_fParam[0] + (pkCur->m_fParam[0] - pkPrev->m_fParam[0]) * fInterp;
// fTranslation[1] = pkPrev->m_fParam[1] + (pkCur->m_fParam[1] - pkPrev->m_fParam[1]) * fInterp;
// fTranslation[2] = pkPrev->m_fParam[2] + (pkCur->m_fParam[2] - pkPrev->m_fParam[2]) * fInterp;
// }
// //Calculate the current rotation
// uiFrame = 0;
// while (uiFrame < pJoint->m_usNumRotFrames && pJoint->m_RotKeyFrames[uiFrame].m_fTime < fTime)
// uiFrame++;
//
// matTmp = glm::rotate(matTmp, pJoint->m_RotKeyFrames[0].m_fParam);
// //If its at the extremes
// if (uiFrame == 0)
// matTmp.SetRotation(pJoint->m_RotKeyFrames[0].m_fParam);
// else if (uiFrame == pJoint->m_usNumTransFrames)
// matTmp.SetRotation(pJoint->m_RotKeyFrames[uiFrame - 1].m_fParam);
// //If its in the middle of two frames, use a quaternion SLERP operation to calculate a new position
// else
// {
// MS3DKeyframe * pkCur = &pJoint->m_RotKeyFrames[uiFrame];
// MS3DKeyframe * pkPrev = &pJoint->m_RotKeyFrames[uiFrame - 1];
//
// fDeltaT = pkCur->m_fTime - pkPrev->m_fTime;
// fInterp = (fTime - pkPrev->m_fTime) / fDeltaT;
//
// //Create a rotation quaternion for each frame
// glm::quat qCur;
// glm::quat qPrev;
// qCur.FromEulers(pkCur->m_fParam);
// qPrev.FromEulers(pkPrev->m_fParam);
// //SLERP between the two frames
// glm::quat qFinal = SLERP(qPrev, qCur, fInterp);
//
// //Convert the quaternion to a rota tion matrix
// matTmp = qFinal.ToMatrix4();
// }
//
// //Set the translation part of the matrix
//
// matTmp=glm::translate(matTmp,fTranslation);
// //Calculate the joints final transformation
// glm::mat4 matFinal = pJoint->m_matLocal * matTmp;
// g
// //if there is no parent, just use the matrix you just made
// if (pJoint->m_sParent == -1)
// pJoint->m_matFinal = matFinal;
// //otherwise the final matrix is the parents final matrix * the new matrix
// else
// pJoint->m_matFinal = m_pJoints[pJoint->m_sParent].m_matFinal * matFinal;
// }//x
//
// for (int i = 0; i < m_usNumJoints; i++)
// {
// memcpy(m_pJointsMatrix + 16 * i, &m_pJoints[i].m_matFinal, sizeof(float) * 16);
// }
// }//i
//
// }
void Model::Syc()
{
ModelRotation[1]=glm::vec3(1, 0, 0);
}
void Model::getPlayTime(float fSpeed, float fStartTime, float fEndTime, bool bLoop)
{
if (m_load==FALSE)
{
// Setup();
m_load=TRUE;
bFirstTime = true;
}
//First time animate has been called
if(bFirstTime)
{//修改的部分
fLastTime= fStartTime;
m_Timer.Init();
m_Timer.GetSeconds();
bFirstTime = false;
}
if (m_bPlay)
{
fTime = m_Timer.GetSeconds() * fSpeed;//帧时间
fTime += fLastTime;
fLastTime = fTime;
}
if(fTime > fEndTime)
{
if(bLoop)
{
float dt = fEndTime - fStartTime;
while (fTime > dt)
{
fTime -= dt;
}
fTime += fStartTime;
}
else
fTime = fEndTime;
}
}
void Model::modifyVertexByJointInit()
{
// 遍历每个Mesh,根据Joint更新每个Vertex的坐标
for(int x = 0; x < m_usNumMeshes; x++)
{
float* pVertexArrayStatic = m_meshVertexData.m_pMesh[x].pVertexArrayStatic;
float* pVertexArrayDynamic = m_meshVertexData.m_pMesh[x].pVertexArrayDynamic;
float* pVertexArrayRaw = m_meshVertexData.m_pMesh[x].pVertexArrayRaw;
int* pIndexJoint = m_meshVertexData.m_pMesh[x].pIndexJoint;
Mesh* pMesh = m_pMeshes+x;
modifyVertexByJointInitKernel( pVertexArrayRaw, pVertexArrayStatic, pIndexJoint, pMesh ); // 更新pVertexArrayStatic
#if !RENDERMODE_MOVING
#if ENABLE_CROSSARRAY
memcpy( pVertexArrayDynamic, pVertexArrayStatic, (2+3+3) * m_pMeshes[x].m_usNumTris * 3 * sizeof(float) );
#else
memcpy( pVertexArrayDynamic, pVertexArrayStatic, 3 * m_pMeshes[x].m_usNumTris * 3 * sizeof(float) );
#endif
#endif
}
}
void Model::modifyVertexByJoint()
{
// 遍历每个Mesh,根据Joint更新每个Vertex的坐标
//int x = 2;
for(int x = 0; x < m_usNumMeshes; x++)
{
float* pVertexArrayRaw = m_meshVertexData.m_pMesh[x].pVertexArrayRaw;
float* pVertexArrayDynamic = m_meshVertexData.m_pMesh[x].pVertexArrayDynamic;
int* pIndexJoint = m_meshVertexData.m_pMesh[x].pIndexJoint;
Mesh* pMesh = m_pMeshes+x;
#if ENABLE_OPTIMIZE
modifyVertexByJointKernelOpti( pVertexArrayRaw, pVertexArrayDynamic, pIndexJoint, pMesh );
#else
modifyVertexByJointKernel( pVertexArrayDynamic, pIndexJoint, pMesh );
#endif
}
}
void Model::setupVertexArray( )
{
// 根据Mesh数生成m_usNumMeshes个VertexArray.
// 在m_meshVertexData的析构函数中释放.
m_meshVertexData.m_pMesh = new Ms3dVertexArrayMesh[m_usNumMeshes];
m_meshVertexData.m_numberOfMesh = m_usNumMeshes;
for (int x = 0; x < m_usNumMeshes; x++)
{
// 在m_pMesh的析构函数中释放. 如需要增加法线则使用
int* pIndexJoint = new int[m_pMeshes[x].m_usNumTris * 3];
#if ENABLE_CROSSARRAY
int nVertexSize = (2 + 3 + 3) * m_pMeshes[x].m_usNumTris * 3;
#else
int nVertexSize = 3 * m_pMeshes[x].m_usNumTris * 3;
#endif
float* pVertexArrayStatic = (float*)_aligned_malloc(nVertexSize * sizeof(float), 16);//new float[];
float* pVertexArrayDynamic = (float*)_aligned_malloc(nVertexSize * sizeof(float), 16);//new float[];
float* pVertexArrayRaw = (float*)_aligned_malloc(nVertexSize * sizeof(float), 16);//new float[];
m_meshVertexData.m_pMesh[x].numOfVertex = m_pMeshes[x].m_usNumTris * 3;
m_meshVertexData.m_pMesh[x].pVertexArrayStatic = pVertexArrayStatic;
m_meshVertexData.m_pMesh[x].pVertexArrayDynamic = pVertexArrayDynamic;
m_meshVertexData.m_pMesh[x].pIndexJoint = pIndexJoint;
m_meshVertexData.m_pMesh[x].pVertexArrayRaw = pVertexArrayRaw;
m_meshVertexData.m_pMesh[x].materialID = m_pMeshes[x].m_materialIndex;
if (m_meshVertexData.m_pMesh[x].numOfVertex > (int)maxMeshVertexNumber)
{
maxMeshVertexNumber = m_meshVertexData.m_pMesh[x].numOfVertex;
}
}
glm::vec3 vecNormal;
glm::vec3 vecVertex;
for (int x = 0; x < m_usNumMeshes; x++)
{
int vertexCnt = 0;
float* pVertexArrayStatic = m_meshVertexData.m_pMesh[x].pVertexArrayStatic;
int* pIndexJoint = m_meshVertexData.m_pMesh[x].pIndexJoint;
for (int y = 0; y < m_pMeshes[x].m_usNumTris; y++)
{
//Set triangle pointer to triangle #1
Triangle * pTri = &m_pTriangles[m_pMeshes[x].m_uspIndices[y]];
//Loop through each vertex
for (int z = 0; z < 3; z++)
{
//Get the vertex
Vertex * pVert = &m_pVertices[pTri->m_usVertIndices[z]];
pIndexJoint[3 * y + z] = pVert->m_cBone;
pVertexArrayStatic[vertexCnt++] = pTri->m_s[z];
pVertexArrayStatic[vertexCnt++] = 1.0f - pTri->m_t[z];
// 不初始化法线
pVertexArrayStatic[vertexCnt++] = pTri->m_vNormals[z].Get()[0];
pVertexArrayStatic[vertexCnt++] = pTri->m_vNormals[z].Get()[1];
pVertexArrayStatic[vertexCnt++] = pTri->m_vNormals[z].Get()[2];
pVertexArrayStatic[vertexCnt++] = pVert->m_vVert.Get()[0];
pVertexArrayStatic[vertexCnt++] = pVert->m_vVert.Get()[1];
pVertexArrayStatic[vertexCnt++] = pVert->m_vVert.Get()[2];
}
}
}
m_pIndexArray = new unsigned int[maxMeshVertexNumber];
for (unsigned int i = 0; i < maxMeshVertexNumber; i++)
{
m_pIndexArray[i] = i;
}
}
void Model::modifyVertexByJointKernel( float* pVertexArrayDynamic , int* pIndexJoint, Mesh* pMesh)
{
vgMs3d::CVector3 vecNormal;
vgMs3d::CVector3 vecVertex;
int vertexCnt = 0;
//遍历Mesh的每个三角面
for(int y = 0; y < pMesh->m_usNumTris; y++)
{
//Set triangle pointer to triangle #1
Triangle * pTri = &m_pTriangles[pMesh->m_uspIndices[y]];
// 遍历三角面的三个顶点
for(int z = 0; z < 3; z++)
{
//Get the vertex
Vertex * pVert = &m_pVertices[pTri->m_usVertIndices[z]];
pIndexJoint[3 * y + z] = pVert->m_cBone;
//If it has no bone, render as is
if(pVert->m_cBone == -1)
{
//Send all 3 components without modification
vecNormal = pTri->m_vNormals[z];
vecVertex = pVert->m_vVert;
}
//Otherwise, transform the vertices and normals before displaying them
else
{
MS3DJoint * pJoint = &m_pJoints[pVert->m_cBone];
// Transform the normals
// vecNormal = pTri->m_vNormals[z];
// Only rotate it, no translation
// 当前版本不计算法线
// vecNormal.Transform3(pJoint->m_matFinal);
// Transform the vertex
vecVertex = pVert->m_vVert;
// translate as well as rotate
vecVertex.Transform4(pJoint->m_matFinal);
}
#if ENABLE_CROSSARRAY
vertexCnt += 2;
// 法线没有被计算和拷贝
pVertexArrayDynamic[vertexCnt++] = vecNormal[0];
pVertexArrayDynamic[vertexCnt++] = vecNormal[1];
pVertexArrayDynamic[vertexCnt++] = vecNormal[2];
#endif
pVertexArrayDynamic[vertexCnt++] = vecVertex[0];
pVertexArrayDynamic[vertexCnt++] = vecVertex[1];
pVertexArrayDynamic[vertexCnt++] = vecVertex[2];
}//for z
}//for y
}
void Model::modifyVertexByJointInitKernel( float* pVertexArrayStatic , float* pVertexArrayDynamic , int* pIndexJoint, Mesh* pMesh)
{
vgMs3d::CVector3 vecNormal;
vgMs3d::CVector3 vecVertex;
int vertexCnt = 0;
//遍历Mesh的每个三角面
for(int y = 0; y < pMesh->m_usNumTris; y++)
{
//Set triangle pointer to triangle #1
Triangle * pTri = &m_pTriangles[pMesh->m_uspIndices[y]];
// 遍历三角面的三个顶点
for(int z = 0; z < 3; z++)
{
//Get the vertex
Vertex * pVert = &m_pVertices[pTri->m_usVertIndices[z]];
pIndexJoint[3*y+z] = pVert->m_cBone;
//If it has no bone, render as is
if(pVert->m_cBone == -1)
{
//Send all 3 components without modification
vecNormal = pTri->m_vNormals[z];
vecVertex = pVert->m_vVert;
}
//Otherwise, transform the vertices and normals before displaying them
else
{
MS3DJoint * pJoint = &m_pJoints[pVert->m_cBone];
vecVertex = pVert->m_vVert;
// translate as well as rotate
vecVertex.Transform4(pJoint->m_matFinal);
}
#if ENABLE_CROSSARRAY
vertexCnt += 2;
// 法线没有被计算和拷贝
pVertexArrayDynamic[vertexCnt++] = vecNormal[0];
pVertexArrayDynamic[vertexCnt++] = vecNormal[1];
pVertexArrayDynamic[vertexCnt++] = vecNormal[2];
#endif
pVertexArrayDynamic[vertexCnt++] = vecVertex[0];
pVertexArrayDynamic[vertexCnt++] = vecVertex[1];
pVertexArrayDynamic[vertexCnt++] = vecVertex[2];
#if ENABLE_CROSSARRAY
if(pVertexArrayStatic)
{
pVertexArrayStatic[ 8*(3*y+z) +5 ] = pVert->m_vVert[0];
pVertexArrayStatic[ 8*(3*y+z) +6 ] = pVert->m_vVert[1];
pVertexArrayStatic[ 8*(3*y+z) +7 ] = pVert->m_vVert[2];
}
#else
if(pVertexArrayStatic)
{
pVertexArrayStatic[ 3*(3*y+z) ] = pVert->m_vVert[0];
pVertexArrayStatic[ 3*(3*y+z)+1 ] = pVert->m_vVert[1];
pVertexArrayStatic[ 3*(3*y+z)+2 ] = pVert->m_vVert[2];
}
#endif
}//for z
}//for y
}
void Model::modifyVertexByJointKernelOpti( float* pVertexArrayRaw , float* pVertexArrayDynamic , int* pIndexJoint, Mesh* pMesh)
{
float *pSrcPos = pVertexArrayRaw +STRIDE_POINT;
float *pDestPos = pVertexArrayDynamic + STRIDE_POINT;
//遍历每个顶点
#if ENABLE_OPENMP
#pragma omp parallel for
#endif
for(int y = 0; y < pMesh->m_usNumTris*3; y++)
{
float* pIn = pSrcPos+ELEMENT_COUNT_POINT*y;
float* pOut = pDestPos+ELEMENT_COUNT_POINT*y;
float* pMat = m_pJointsMatrix+ELEMENT_COUNT_MATIRX*pIndexJoint[y];
//kernelElement( pSrcPosOne, pDestPosOne, pMatOne );
pOut[0] =
(pMat[0*4+0] * pIn[0] +
pMat[1*4+0] * pIn[1] +
pMat[2*4+0] * pIn[2] +
pMat[3*4+0]) ;
pOut[1] =
(pMat[0*4+1] * pIn[0] +
pMat[1*4+1] * pIn[1] +
pMat[2*4+1] * pIn[2] +
pMat[3*4+1]) ;
pOut[2] =
(pMat[0*4+2] * pIn[0] +
pMat[1*4+2] * pIn[1] +
pMat[2*4+2] * pIn[2] +
pMat[3*4+2]) ;
}//for y
}