本文整理汇总了C++中Matrix3::VectorTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3::VectorTransform方法的具体用法?C++ Matrix3::VectorTransform怎么用?C++ Matrix3::VectorTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix3
的用法示例。
在下文中一共展示了Matrix3::VectorTransform方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IConformCheck
BOOL plDistributor::IConformCheck(Matrix3& l2w, int iRepNode, plMeshCacheTab& cache, int& iCache) const
{
Matrix3 OTM = IOTM(iRepNode);
Mesh* mesh = cache[iRepNode].fMesh;
Point3 dir = l2w.VectorTransform(Point3(0.f, 0.f, 1.f));
dir = FNormalize(dir);
const float kOneOverSqrt2 = 0.707107f;
Point3 scalePt(kOneOverSqrt2, kOneOverSqrt2, 0.f);
scalePt = l2w.VectorTransform(scalePt);
float maxScaledDist = fMaxConform * scalePt.Length();
Box3 bnd = mesh->getBoundingBox() * OTM;
bnd = Box3(Point3(bnd.Min().x, bnd.Min().y, -bnd.Max().z), bnd.Max());
bnd = bnd * l2w;
Tab<int32_t> faces;
IFindFaceSet(bnd, faces);
int i;
for( i = 0; i < mesh->getNumVerts(); i++ )
{
Point3 pt = mesh->getVert(i) * OTM;
pt.z = 0;
pt = pt * l2w;
Point3 projPt;
if( !IProjectVertex(pt, dir, maxScaledDist, faces, projPt) )
return false;
}
return true;
}
示例2: IConformAll
BOOL plDistributor::IConformAll(Matrix3& l2w, int iRepNode, plMeshCacheTab& cache, int& iCache) const
{
Matrix3 OTM = IOTM(iRepNode);
Mesh* mesh = cache[iRepNode].fMesh;
Point3 dir = l2w.VectorTransform(Point3(0.f, 0.f, 1.f));
dir = FNormalize(dir);
const float kOneOverSqrt2 = 0.707107f;
Point3 scalePt(kOneOverSqrt2, kOneOverSqrt2, 0.f);
scalePt = l2w.VectorTransform(scalePt);
float maxScaledDist = fMaxConform * scalePt.Length();
Box3 bnd = mesh->getBoundingBox() * OTM;
bnd = Box3(Point3(bnd.Min().x, bnd.Min().y, -bnd.Max().z), bnd.Max());
bnd = bnd * l2w;
Tab<int32_t> faces;
IFindFaceSet(bnd, faces);
// l2w, iRepNode, cache, &iCache, maxScaledDist, dir
iCache = cache.Count();
cache.SetCount(iCache + 1);
cache[iCache] = cache[iRepNode];
cache[iCache].fMesh = new Mesh(*mesh);
mesh = cache[iCache].fMesh;
Matrix3 v2w = OTM * l2w;
Matrix3 w2v = Inverse(v2w);
BOOL retVal = true;
int i;
for( i = 0; i < mesh->getNumVerts(); i++ )
{
Point3 pt = mesh->getVert(i) * OTM;
pt.z = 0;
pt = pt * l2w;
Point3 projPt;
if( !IProjectVertex(pt, dir, maxScaledDist, faces, projPt) )
{
retVal = false;
break;
}
Point3 del = w2v.VectorTransform(projPt - pt);
mesh->getVert(i) += del;
}
if( !retVal )
{
// delete cache[iCache].fMesh;
delete mesh;
cache.SetCount(iCache);
iCache = iRepNode;
}
return retVal;
}
示例3: ConvertPathToFrenets
// Luna task 748T
void ConvertPathToFrenets (Spline3D *pSpline, Matrix3 & relativeTransform, Tab<Matrix3> & tFrenets,
int numSegs, bool align, float rotateAroundZ) {
// Given a path, a sequence of points in 3-space, create transforms
// for putting a cross-section around each of those points, loft-style.
// bezShape is provided by user, tFrenets contains output, numSegs is one less than the number of transforms requested.
// Strategy: The Z-axis is mapped along the path, and the X and Y axes
// are chosen in a well-defined manner to get an orthonormal basis.
int i;
if (numSegs < 1) return;
tFrenets.SetCount (numSegs+1);
int numIntervals = pSpline->Closed() ? numSegs+1 : numSegs;
float denominator = float(numIntervals);
Point3 xDir, yDir, zDir, location, tangent, axis;
float position, sine, cosine, theta;
Matrix3 rotation;
// Find initial x,y directions:
location = relativeTransform * pSpline->InterpCurve3D (0.0f);
tangent = relativeTransform.VectorTransform (pSpline->TangentCurve3D (0.0f));
Point3 lastTangent = tangent;
Matrix3 inverseBasisOfSpline(1);
if (align) {
theBasisFinder.BasisFromZDir (tangent, xDir, yDir);
if (rotateAroundZ) {
Matrix3 rotator(1);
rotator.SetRotate (AngAxis (tangent, rotateAroundZ));
xDir = xDir * rotator;
yDir = yDir * rotator;
}
Matrix3 basisOfSpline(1);
basisOfSpline.SetRow (0, xDir);
basisOfSpline.SetRow (1, yDir);
basisOfSpline.SetRow (2, tangent);
basisOfSpline.SetTrans (location);
inverseBasisOfSpline = Inverse (basisOfSpline);
lastTangent = Point3(0,0,1);
} else {
inverseBasisOfSpline.SetRow (3, -location);
}
// Make relative transform take the spline from its own object space to our object space,
// and from there into the space defined by its origin and initial direction:
relativeTransform = relativeTransform * inverseBasisOfSpline;
// (Note left-to-right evaluation order: Given matrices A,B, point x, x(AB) = (xA)B
// The first transform is necessarily the identity:
tFrenets[0].IdentityMatrix ();
// Set up xDir, yDir, zDir to match our first-point basis:
xDir = Point3 (1,0,0);
yDir = Point3 (0,1,0);
zDir = Point3 (0,0,1);
for (i=1; i<=numIntervals; i++) {
position = float(i) / denominator;
location = relativeTransform * pSpline->InterpCurve3D (position);
tangent = relativeTransform.VectorTransform (pSpline->TangentCurve3D (position));
// This is the procedure we follow at each step in the path: find the
// orthonormal basis with the right orientation, then compose with
// the translation putting the origin at the path-point.
// As we proceed along the path, we apply minimal rotations to
// our original basis to keep the Z-axis tangent to the curve.
// The X and Y axes follow in a natural manner.
// xDir, yDir, zDir still have their values from last time...
// Create a rotation matrix which maps the last tangent onto the current tangent:
axis = lastTangent ^ tangent; // gives axis, scaled by sine of angle.
sine = FLength(axis); // positive - keeps angle value in (0,PI) range.
cosine = DotProd (lastTangent, tangent); // Gives cosine of angle.
theta = atan2f (sine, cosine);
rotation.SetRotate (AngAxis (Normalize(axis), theta));
xDir = Normalize (rotation * xDir);
yDir = Normalize (rotation * yDir);
zDir = Normalize (rotation * zDir);
lastTangent = tangent;
if (i<=numSegs) {
tFrenets[i].IdentityMatrix ();
tFrenets[i].SetRow (0, xDir);
tFrenets[i].SetRow (1, yDir);
tFrenets[i].SetRow (2, zDir);
tFrenets[i].SetTrans (location);
}
}
/* following code not needed for now - treating all splines as open.
if (!pSpline->Closed ()) return;
// If we have a closed loop, our procedure may result in X,Y vectors
// that are twisted severely between the first and last point.
// Here we correct for that by pre-transforming each frenet transform
//.........这里部分代码省略.........
示例4: loadPoses
//.........这里部分代码省略.........
FxOgreMaxExporterLog( "Exporting Morph target: %s with %d vertices.\n", posename.c_str(), numMorphVertices);
FxOgreMaxExporterLog( "Mesh has %d vertices.\n", numVertices);
FxOgreMaxExporterLog( "%d total vertices.\n", vertices.size());
assert(offset+numVertices <= vertices.size());
// create a new pose
pose p;
p.poseTarget = m_target;
p.index = targetIndex;
p.blendShapeIndex = i;
p.name = posename;
p.pMChannel = pMorphChannel;
size_t numPoints = pMorphChannel->mPoints.size();
std::vector<Point3> vmPoints;
vmPoints.reserve(numPoints);
for( size_t k = 0; k < numPoints; ++k )
{
vmPoints.push_back(pMorphChannel->mPoints[k]);
}
Box3 morphBoundingBox;
// calculate vertex offsets
for (int k=0; k<numVertices; k++)
{
vertexOffset vo;
assert ((offset+k)<vertices.size());
vertex v = vertices[offset+k];
assert(v.index < numMorphVertices);
assert(v.index < origMesh.getNumVerts());
Point3 meshVert = origMesh.getVert(v.index);
Point3 morphVert = vmPoints[v.index];
Point3 diff = morphVert - meshVert;
// Transform our morph vertex movements by whatever
// scaling/rotation is being done by IGame..
Point3 ogreSpacediff = DiffTM.VectorTransform(diff);
// Add this point to the bounding box
morphBoundingBox += morphVert;
vo.x = ogreSpacediff.x * params.lum;
vo.y = ogreSpacediff.y * params.lum;
vo.z = ogreSpacediff.z * params.lum;
vo.index = offset+k;
if (fabs(vo.x) < PRECISION)
vo.x = 0;
if (fabs(vo.y) < PRECISION)
vo.y = 0;
if (fabs(vo.z) < PRECISION)
vo.z = 0;
if ((vo.x!=0) || (vo.y!=0) || (vo.z!=0))
p.offsets.push_back(vo);
}
// add pose to pose list
if (p.offsets.size() > 0)
{
pg.poses.push_back(p);
}
if (params.bsBB)
{
// update bounding boxes of loaded submeshes
for (int j=0; j<params.loadedSubmeshes.size(); j++)
{
Point3 min = morphBoundingBox.Min() * params.lum;
Point3 max = morphBoundingBox.Max() * params.lum;
// Update coordinate system here.
Point3 newMin, newMax;
newMin.x = min.x;
newMin.y = min.z;
newMin.z = min.y;
Box3 newBox(newMin, newMax);
if (params.exportWorldCoords)
newBox = newBox * m_pGameNode->GetWorldTM(GetCOREInterface()->GetTime()).ExtractMatrix3();
params.loadedSubmeshes[j]->m_boundingBox += newBox;
}
}
}
}
}
}
// Re-enable skin modifiers.
for( int i = 0; i < disabledSkinModifiers.size(); ++i )
{
disabledSkinModifiers[i]->EnableMod();
}
// According to David Lanier, this should be deleted, but I get crashes when exporting blendShapes
// without shared geometry when I use the object for the second time. Perhaps it
// can only be used/deleted once. Even without shared geometry, I'll get a strange crash
// a few seconds after successful export with this here.
// if (DeleteObjectWhenDone)
// origMeshTriObj->DeleteMe();
}
return true;
}
示例5: ProcessMesh
//.........这里部分代码省略.........
res = mesh.RemoveIllegalFaces();
if (res)
{
Spam( "Degenerate indices were fixed." );
}
ExpNode* pExpNode = GetExportedNode( node );
if (!pExpNode)
{
return;
}
int numPri = mesh.getNumFaces();
int numVert = mesh.numVerts;
// initialize helper array for building vertices' 0-circles
VertexPtrArray vertexEntry;
vertexEntry.resize( numVert );
memset( &vertexEntry[0], 0, sizeof( ExpVertex* )*numVert );
Spam( "Original mesh has %d vertices and %d faces.", numVert, numPri );
bool bHasVoidFaces = false;
// loop on mesh faces
for (int i = 0; i < numPri; i++)
{
Face& face = mesh.faces[i];
// calculate face normal
const Point3& v0 = mesh.verts[face.v[vx[0]]];
const Point3& v1 = mesh.verts[face.v[vx[1]]];
const Point3& v2 = mesh.verts[face.v[vx[2]]];
Point3 normal = -Normalize( (v1 - v0)^(v2 - v1) );
normal = mOffs.VectorTransform( normal );
normal = c_FlipTM.VectorTransform( normal );
// loop on face vertices
ExpVertex* pFaceVertex[3];
for (int j = 0; j < 3; j++)
{
ExpVertex v;
v.mtlID = pExpNode->GetMaterialIdx( face.getMatID() );
v.nodeID = pExpNode->m_Index;
if (v.mtlID < 0)
{
bHasVoidFaces = true;
}
// extract vertex position and apply world-space modifier to it
int vIdx = face.v[vx[j]];
Point3 pt = mesh.verts[vIdx];
pt = mOffs.PointTransform( pt );
pt = c_FlipTM.PointTransform( pt );
v.index = vIdx;
v.pos = Vec3( pt.x, pt.y, pt.z );
//v.pos *= m_WorldScale;
// extract skinning info
if (bHasSkin)
{
GetSkinInfo( v );
}
// assign normal