本文整理汇总了C++中Matrix3::SetColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3::SetColumn方法的具体用法?C++ Matrix3::SetColumn怎么用?C++ Matrix3::SetColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3
的用法示例。
在下文中一共展示了Matrix3::SetColumn方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillLinearMaxTransformationController
bool AnimationImporter::fillLinearMaxTransformationController( Control* maxController,
size_t keyCount,
const InputArrayType& inputValues,
const OutputArrayType& outputValues,
ConversionFunctorType inputConversionFunctor,
ConversionFunctor* outputConversionFunctors[])
{
SuspendAnimate();
AnimateOn();
for ( size_t i = 0; i < keyCount; ++i)
{
TimeValue keyTime;
if ( inputConversionFunctor )
{
keyTime = (TimeValue)((*inputConversionFunctor)((float)(inputValues[i])));
}
else
{
keyTime = (TimeValue)(inputValues[i]);
}
Matrix3 matrixValue;
size_t firstMatrixElement = 16*i;
Point4 column;
column[ 0 ] = convert(outputConversionFunctors[0], (float)outputValues[firstMatrixElement + 0]);
column[ 1 ] = convert(outputConversionFunctors[1], (float)outputValues[firstMatrixElement + 1]);
column[ 2 ] = convert(outputConversionFunctors[2], (float)outputValues[firstMatrixElement + 2]);
column[ 3 ] = convert(outputConversionFunctors[3], (float)outputValues[firstMatrixElement + 3]);
matrixValue.SetColumn(0, column);
column[ 0 ] = convert(outputConversionFunctors[4], (float)outputValues[firstMatrixElement + 4]);
column[ 1 ] = convert(outputConversionFunctors[5], (float)outputValues[firstMatrixElement + 5]);
column[ 2 ] = convert(outputConversionFunctors[6], (float)outputValues[firstMatrixElement + 6]);
column[ 3 ] = convert(outputConversionFunctors[7], (float)outputValues[firstMatrixElement + 7]);
matrixValue.SetColumn(1, column);
column[ 0 ] = convert(outputConversionFunctors[8], (float)outputValues[firstMatrixElement + 8]);
column[ 1 ] = convert(outputConversionFunctors[9], (float)outputValues[firstMatrixElement + 9]);
column[ 2 ] = convert(outputConversionFunctors[10], (float)outputValues[firstMatrixElement + 10]);
column[ 3 ] = convert(outputConversionFunctors[11], (float)outputValues[firstMatrixElement + 11]);
matrixValue.SetColumn(2, column);
SetXFormPacket matrixValuePacket(matrixValue);
maxController->SetValue( keyTime, &matrixValuePacket, 1, CTRL_ABSOLUTE);
}
ResumeAnimate();
return true;
}
示例2: convertSpaceUnit
//---------------------------------------------------------------
void ImporterBase::Matrix4ToMaxMatrix3 ( Matrix3 & copy, const COLLADABU::Math::Matrix4& original )
{
Point4 column;
column[ 0 ] = (float)original.getElement(0,0);
column[ 1 ] = (float)original.getElement(0,1);
column[ 2 ] = (float)original.getElement(0,2);
column[ 3 ] = convertSpaceUnit((float)original.getElement(0,3));
copy.SetColumn(0, column);
column[ 0 ] = (float)original.getElement(1,0);
column[ 1 ] = (float)original.getElement(1,1);
column[ 2 ] = (float)original.getElement(1,2);
column[ 3 ] = convertSpaceUnit((float)original.getElement(1,3));
copy.SetColumn(1, column);
column[ 0 ] = (float)original.getElement(2,0);
column[ 1 ] = (float)original.getElement(2,1);
column[ 2 ] = (float)original.getElement(2,2);
column[ 3 ] = convertSpaceUnit((float)original.getElement(2,3));
copy.SetColumn(2, column);
}
示例3:
void Road2::textureFit(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, int texfit, Vector2* texc, Vector3 pos, Vector3 lastpos, float width)
{
int i;
if (texfit == TEXFIT_BRICKWALL || texfit == TEXFIT_CONCRETEWALL || texfit == TEXFIT_CONCRETEWALLI)
{
Vector3 ps[4];
ps[0] = p1;
ps[1] = p2;
ps[2] = p3;
ps[3] = p4;
Vector3 pref1 = pos;
Vector3 pref2 = lastpos;
//make matrix
Vector3 bx = pref2 - pref1;
bx.normalise();
Vector3 by = Vector3::UNIT_Y;
Vector3 bz = bx.crossProduct(by);
//coordinates change matrix
Matrix3 reverse;
reverse.SetColumn(0, bx);
reverse.SetColumn(1, by);
reverse.SetColumn(2, bz);
Matrix3 forward;
forward = reverse.Inverse();
//transpose
for (i = 0; i < 4; i++)
{
Vector3 trv = forward * (ps[i] - pref1);
if (texfit == TEXFIT_BRICKWALL)
{
float ty = 0.746 - trv.y * 0.25 / 4.5;
// fix overlapping
if (ty > 1)
ty = 1;
texc[i] = Vector2(trv.x / 10.0, ty);
}
if (texfit == TEXFIT_CONCRETEWALL)
{
// fix overlapping
float ty = 0.496 - (trv.y - 0.7) * 0.25 / 4.5;
if (ty > 1)
ty = 1;
texc[i] = Vector2(trv.x / 10.0, ty);
}
if (texfit == TEXFIT_CONCRETEWALLI)
{
float ty = 0.496 + trv.y * 0.25 / 4.5;
// fix overlapping
if (ty > 1)
ty = 1;
texc[i] = Vector2(trv.x / 10.0, ty);
}
}
return;
}
if (texfit == TEXFIT_ROAD || texfit == TEXFIT_ROADS1 || texfit == TEXFIT_ROADS2 || texfit == TEXFIT_ROADS3 || texfit == TEXFIT_ROADS4 || texfit == TEXFIT_CONCRETETOP || texfit == TEXFIT_CONCRETEUNDER)
{
Vector3 ps[4];
ps[0] = p1;
ps[1] = p2;
ps[2] = p3;
ps[3] = p4;
Vector3 pref1 = pos;
Vector3 pref2 = lastpos;
//project
for (i = 0; i < 4; i++)
ps[i].y = 0;
pref1.y = 0;
pref2.y = 0;
//make matrix
Vector3 bx = pref2 - pref1;
bx.normalise();
Vector3 by = Vector3::UNIT_Y;
Vector3 bz = bx.crossProduct(by);
//coordinates change matrix
Matrix3 reverse;
reverse.SetColumn(0, bx);
reverse.SetColumn(1, by);
reverse.SetColumn(2, bz);
Matrix3 forward;
forward = reverse.Inverse();
//transpose
float trvrefz = 0.0;
for (i = 0; i < 4; i++)
{
Vector3 trv = forward * (ps[i] - pref1);
if (texfit == TEXFIT_CONCRETETOP)
{
if (i == 0)
trvrefz = trv.z;
texc[i] = Vector2(trv.x / 10.0, 0.621 + (trv.z - trvrefz) * 0.25 / 4.5);
}
else
{
float v1 = 0.072;
float v2 = 0.423;
if (texfit == TEXFIT_ROADS1)
{
v1 = 0.001;
//.........这里部分代码省略.........
示例4: flexit
Vector3 FlexBody::flexit()
{
if(faulty) return Vector3::ZERO;
if(!enabled) return Vector3::ZERO;
if (haveblend) updateBlend();
//compute the local center
Vector3 normal;
Vector3 center;
if(cref >= 0)
{
normal=(nodes[cy].smoothpos-nodes[cref].smoothpos).crossProduct(nodes[cx].smoothpos-nodes[cref].smoothpos);
normal.normalise();
center=nodes[cref].smoothpos+coffset.x*(nodes[cx].smoothpos-nodes[cref].smoothpos)+coffset.y*(nodes[cy].smoothpos-nodes[cref].smoothpos);
center=(center+normal*coffset.z);
} else
{
normal = Vector3::UNIT_Y;
center = nodes[0].smoothpos;
}
//okay
for (int i=0; i<(int)vertex_count; i++)
{
Locator_t *loc=&locs[i];
Matrix3 mat;
mat.SetColumn(0, nodes[loc->nx].smoothpos-nodes[loc->ref].smoothpos);
mat.SetColumn(1, nodes[loc->ny].smoothpos-nodes[loc->ref].smoothpos);
// mat.SetColumn(2, nodes[loc->nz].smoothpos-nodes[loc->ref].smoothpos);
Vector3 vz=(nodes[loc->nx].smoothpos-nodes[loc->ref].smoothpos).crossProduct(nodes[loc->ny].smoothpos-nodes[loc->ref].smoothpos);
vz.normalise();
mat.SetColumn(2, vz);
dstpos[i]=mat*loc->coords+nodes[loc->ref].smoothpos-center;
dstnormals[i]=mat*srcnormals[i];
dstnormals[i].normalise(); //painfull but necessary!
}
Vector3 *ppt=dstpos;
Vector3 *npt=dstnormals;
if (hasshared)
{
sharedpbuf->writeData(0, sharedcount*sizeof(Vector3), ppt, true);
ppt+=sharedcount;
sharednbuf->writeData(0, sharedcount*sizeof(Vector3), npt, true);
npt+=sharedcount;
}
for (int i=0; i<numsubmeshbuf; i++)
{
subpbufs[i]->writeData(0, subnodecounts[i]*sizeof(Vector3), ppt, true);
ppt+=subnodecounts[i];
subnbufs[i]->writeData(0, subnodecounts[i]*sizeof(Vector3), npt, true);
npt+=subnodecounts[i];
}
if (haveshadows)
{
EdgeData * ed=msh->getEdgeList();
//ed->updateFaceNormals(0, pbuf); //wtf?
}
snode->setPosition(center);
return center;
}
示例5: addinterval
//.........这里部分代码省略.........
Vector3 vy=nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos;
vy.normalise();
for (int k=0; k<numnodes; k++)
{
if (nodes[k].iswheel) continue;
if (k==locs[i].ref) continue;
if (k==locs[i].nx) continue;
if (k==locs[i].ny) continue;
Vector3 vt=nodes[k].smoothpos-nodes[locs[i].ref].smoothpos;
vt.normalise();
float cost=vx.dotProduct(vt);
if (cost>0.707 || cost<-0.707) continue; //rejection, fails the orthogonality criterion (+-45 degree)
cost=vy.dotProduct(vt);
if (cost>0.707 || cost<-0.707) continue; //rejection, fails the orthogonality criterion (+-45 degree)
float dist=(vertices[i]-nodes[k].smoothpos).length();
if (dist<mindist) {mindist=dist;minnode=k;};
}
if (minnode==-1) LOG("FLEXBODY ERROR on mesh "+String(meshname)+": VZ node not found");
locs[i].nz=minnode;
//rright, check orientation
Vector3 xyn=vx.crossProduct(vy);
if (xyn.dotProduct(nodes[locs[i].nz].smoothpos-nodes[locs[i].ref].smoothpos)<0)
{
//the base is messed up
int t=locs[i].nz;
locs[i].nz=locs[i].ny;
locs[i].ny=t;
}
*/
Vector3 vz=(nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos).crossProduct(nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos);
vz.normalise();
Matrix3 mat;
mat.SetColumn(0, nodes[locs[i].nx].smoothpos-nodes[locs[i].ref].smoothpos);
mat.SetColumn(1, nodes[locs[i].ny].smoothpos-nodes[locs[i].ref].smoothpos);
// mat.SetColumn(2, nodes[locs[i].nz].smoothpos-nodes[locs[i].ref].smoothpos);
mat.SetColumn(2, vz);
mat=mat.Inverse();
//compute coordinates in the newly formed euclidian basis
locs[i].coords=mat*(vertices[i]-nodes[locs[i].ref].smoothpos);
//thats it!
}
//shadow
if (haveshadows)
{
LOG("FLEXBODY preparing for shadow volume");
msh->prepareForShadowVolume(); //we do this always so we have only one datastructure format to manage
msh->buildEdgeList();
}
//adjusting bounds
AxisAlignedBox aab=msh->getBounds();
Vector3 v=aab.getMinimum();
float mi=v.x;
if (v.y<mi) mi=v.y;
if (v.z<mi) mi=v.z;
mi=fabs(mi);
v=aab.getMaximum();
float ma=v.x;
if (ma<v.y) ma=v.y;
if (ma<v.z) ma=v.z;
ma=fabs(ma);
if (mi>ma) ma=mi;