本文整理汇总了C++中LTMatrix::SetBasisVectors方法的典型用法代码示例。如果您正苦于以下问题:C++ LTMatrix::SetBasisVectors方法的具体用法?C++ LTMatrix::SetBasisVectors怎么用?C++ LTMatrix::SetBasisVectors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LTMatrix
的用法示例。
在下文中一共展示了LTMatrix::SetBasisVectors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: i_OrientedBoundingBoxTest
// returns true if intersection happened, plus fills hit dist param with
// the parametric position of the intersection on the ray dir.
// the obb must be within ray-origin + ray-dir. So ray-dir isn't normalized.
// source : Real-time rendering moller&haines
inline bool i_OrientedBoundingBoxTest(const ModelOBB &mobb,
const LTransform &tf,
const LTVector &origin,
const LTVector &dir,
float &t)
{
float tmin = -999999999999.0f;
float tmax = 999999999999.0f;
LTVector vObbPos = mobb.m_Pos;
// Setup our OBB's translated position
LTMatrix obb_mat;
obb_mat.Identity();
obb_mat.SetBasisVectors( &tf.m_Rot.Right(), &tf.m_Rot.Up(), &tf.m_Rot.Forward() );
obb_mat.SetTranslation( tf.m_Pos );
obb_mat.Apply(vObbPos);
LTVector p = vObbPos - origin;
float e ;
float f;
float hi;
float t1,t2;
// Setup OBB rotation tranforms
LTMatrix mObbMat;
mObbMat.SetBasisVectors(&mobb.m_Basis[0], &mobb.m_Basis[1], &mobb.m_Basis[2]);
// Get matrix of our Node's rotation
LTMatrix mTrMat;
tf.m_Rot.ConvertToMatrix(mTrMat);
// Apply our node rotation to our obb rotation
mTrMat.Apply(mObbMat);
// Get our translated basis vectors
LTVector axis[3];
mObbMat.GetBasisVectors(&axis[0], &axis[1], &axis[2]);
LTVector vSize = mobb.m_Size * 0.5f ; // we want the 1/2 size of the box.
for( int i = 0 ; i < 3 ; i++ )
{
e = axis[i].Dot(p);
f = axis[i].Dot(dir);
hi= vSize[i] ; //
if( fabs(f) > 0.00015 )
{
t1 = ( e + hi ) / f ;
t2 = ( e - hi ) / f ;
if( t1 > t2 ) {float v = t2 ; t2 = t1 ; t1 = v ; }
if(t1 > tmin ) {tmin = t1 ;}
if(t2 < tmax ) {tmax = t2 ;}
if(tmin > tmax ) {
return false ; }
if(tmax < 0 ) {
return false ; }
}
else if( ((-e - hi) > 0 ) || ( (-e + hi) < 0 )) { t = 0 ; return false ; }
}
if( tmin > 0 ) { t = tmin ; return true ; }
else { t = tmax ; return true ;}
}
示例2: WrapTexture
// Wrap the textures, starting at a poly index
void CRVTrackerTextureWrap::WrapTexture(CTWPolyInfo *pPoly, const CVector &vWrapDir, CTextExtents &cExtents) const
{
// Mark this poly as wrapped
pPoly->m_bTouched = TRUE;
CTexturedPlane& Texture = pPoly->m_pPoly->GetTexture(GetCurrTexture());
// Get the texture space
LTVector vWrapO = Texture.GetO();
LTVector vWrapP = Texture.GetP();
LTVector vWrapQ = Texture.GetQ();
// Get the texture offset projections
float fWrapOdotP = vWrapO.Dot(vWrapP);
float fWrapOdotQ = vWrapO.Dot(vWrapQ);
// Update the texturing extents
for (uint32 nExtentLoop = 0; nExtentLoop < pPoly->m_aEdges.GetSize(); ++nExtentLoop)
{
LTVector vEdgePt = pPoly->m_aEdges[nExtentLoop]->m_aPt[0];
float fCurU = vWrapP.Dot(vEdgePt) - fWrapOdotP;
float fCurV = vWrapQ.Dot(vEdgePt) - fWrapOdotQ;
cExtents.m_fMinU = LTMIN(fCurU, cExtents.m_fMinU);
cExtents.m_fMaxU = LTMAX(fCurU, cExtents.m_fMaxU);
cExtents.m_fMinV = LTMIN(fCurV, cExtents.m_fMinV);
cExtents.m_fMaxV = LTMAX(fCurV, cExtents.m_fMaxV);
}
CMoArray<uint32> aNeighbors;
CMoArray<float> aDots;
// Insert the neighbors into a list in dot-product order
for (uint32 nNeighborLoop = 0; nNeighborLoop < pPoly->m_aNeighbors.GetSize(); ++nNeighborLoop)
{
CTWPolyInfo *pNeighbor = pPoly->m_aNeighbors[nNeighborLoop];
// Skip edges that don't have a neighbor
if (!pNeighbor)
continue;
// Skip neighbors that are already wrapped
if (pNeighbor->m_bTouched)
continue;
// Get our dot product
float fCurDot = vWrapDir.Dot(pPoly->m_aEdges[nNeighborLoop]->m_Plane.m_Normal);
if ((m_bRestrictWalkDir) && (fCurDot < 0.707f))
continue;
// Mark this neighbor as touched (to avoid later polygons pushing it onto the stack)
pNeighbor->m_bTouched = TRUE;
// Insert it into the list
for (uint32 nInsertLoop = 0; nInsertLoop < aNeighbors.GetSize(); ++nInsertLoop)
{
if (fCurDot > aDots[nInsertLoop])
break;
}
aDots.Insert(nInsertLoop, fCurDot);
aNeighbors.Insert(nInsertLoop, nNeighborLoop);
}
// Recurse through its neighbors
for (uint32 nWrapLoop = 0; nWrapLoop < aNeighbors.GetSize(); ++nWrapLoop)
{
CTWPolyInfo *pNeighbor = pPoly->m_aNeighbors[aNeighbors[nWrapLoop]];
CTWEdgeInfo *pEdge = pPoly->m_aEdges[aNeighbors[nWrapLoop]];
//////////////////////////////////////////////////////////////////////////////
// Wrap this neighbor
// Create a matrix representing the basis of the polygon in relation to this edge
LTMatrix mPolyBasis;
mPolyBasis.SetTranslation(0.0f, 0.0f, 0.0f);
mPolyBasis.SetBasisVectors(&pEdge->m_vDir, &pPoly->m_pPoly->m_Plane.m_Normal, &pEdge->m_Plane.m_Normal);
// Create a new basis for the neighbor polygon
LTMatrix mNeighborBasis;
LTVector vNeighborForward;
vNeighborForward = pNeighbor->m_pPoly->m_Plane.m_Normal.Cross(pEdge->m_vDir);
// Just to be sure..
vNeighborForward.Norm();
mNeighborBasis.SetTranslation(0.0f, 0.0f, 0.0f);
mNeighborBasis.SetBasisVectors(&pEdge->m_vDir, &pNeighbor->m_pPoly->m_Plane.m_Normal, &vNeighborForward);
// Create a rotation matrix from here to there
LTMatrix mRotation;
mRotation = mNeighborBasis * ~mPolyBasis;
// Rotate the various vectors
LTVector vNewP;
LTVector vNewQ;
LTVector vNewDir;
mRotation.Apply3x3(vWrapP, vNewP);
mRotation.Apply3x3(vWrapQ, vNewQ);
//.........这里部分代码省略.........