当前位置: 首页>>代码示例>>C++>>正文


C++ LTMatrix类代码示例

本文整理汇总了C++中LTMatrix的典型用法代码示例。如果您正苦于以下问题:C++ LTMatrix类的具体用法?C++ LTMatrix怎么用?C++ LTMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LTMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: gr_GetEulerVectors

void gr_GetEulerVectors(
	const LTVector vAngles,
	LTVector &vRight,
	LTVector &vUp,
	LTVector &vForward)
{
	LTMatrix mTemp;

	gr_SetupMatrixEuler(vAngles, mTemp.m);
	mTemp.GetBasisVectors(&vRight, &vUp, &vForward);
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:11,代码来源:geomroutines.cpp

示例2: GetOrientationSpace

bool CTrackedNodeMgr::GetOrientationSpace( HTRACKEDNODE ID,	LTVector& vRight, 
											LTVector& vUp, 
											LTVector& vForward)
{
	if(!CheckValidity(ID))
		return false;

	//read in the vectors
	LTMatrix mTargetTransform = ID->m_mInvTargetTransform;
	mTargetTransform.Transpose();

	mTargetTransform.GetBasisVectors(&vRight, &vUp, &vForward);
	return true;
}
开发者ID:emoose,项目名称:lithtech,代码行数:14,代码来源:TrackedNodeMgr.cpp

示例3: gr_IntersectPlanes

LTBOOL gr_IntersectPlanes(
	LTPlane &plane0,
	LTPlane &plane1,
	LTPlane &plane2,
	LTVector &vOut)
{
	LTMatrix mPlanes;

	/*
		Math behind this:

		Plane equation is Ax + By + Cz - D = 0
		Standard matrix equation Ax = b.

		So stick the plane equations into the A matrix:

		A B C -D	(from plane 0)
		A B C -D	(from plane 1)
		A B C -D	(from plane 2)
		0 0 0  1

		then the b vector is:
		[0 0 0 1]

		and we're solving for the x vector so:
		~AAx = ~Ab
		x = ~Ab
	*/

	mPlanes.Init(
		plane0.m_Normal[0], plane0.m_Normal[1], plane0.m_Normal[2], -plane0.m_Dist,
		plane1.m_Normal[0], plane1.m_Normal[1], plane1.m_Normal[2], -plane1.m_Dist,
		plane2.m_Normal[0], plane2.m_Normal[1], plane2.m_Normal[2], -plane2.m_Dist,
		0.0f, 0.0f, 0.0f, 1.0f);

	// If we can't invert the matrix, then two or more planes are equal.
	if(!mPlanes.Inverse())
		return LTFALSE;

	// Since our b vector is all zeros, we don't need to do a full matrix multiply.
	// vOut = mPlaneNormal * vPlaneDist;
	vOut.Init(
		mPlanes.m[0][3],
		mPlanes.m[1][3],
		mPlanes.m[2][3]);

	vOut *= (1.0f / mPlanes.m[3][3]);
	return LTTRUE;
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:49,代码来源:geomroutines.cpp

示例4: d3d_InitFrustum

bool d3d_InitFrustum(ViewParams *pParams, 
	float xFov, float yFov, float nearZ, float farZ, 
	float screenMinX, float screenMinY, float screenMaxX, float screenMaxY,
	const LTVector *pPos, const LTRotation *pRotation, ViewParams::ERenderMode eMode)
{
	LTMatrix mat;

	quat_ConvertToMatrix((float*)pRotation, mat.m);
	mat.SetTranslation(*pPos);

	ViewBoxDef viewBox;
	d3d_InitViewBox(&viewBox, nearZ, farZ, xFov, yFov);

	// Setup initial states and stuff.
	return d3d_InitFrustum2(pParams, &viewBox, 
		screenMinX, screenMinY, screenMaxX, screenMaxY, &mat, LTVector(1.0f, 1.0f, 1.0f), eMode);
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:17,代码来源:common_draw.cpp

示例5: d3d_SetEnvMapTransform

//Given a stage to install it on, it will grab the global world envmap transform
//and apply it into the texture transform on that stage
void d3d_SetEnvMapTransform(RTexture* pEnvMap, uint32 nStage)
{
	//determine how many times the texture will be tiling.

	float fScale = g_CV_EnvScale;

	//now see if it is okay to divide by it, since that will provide proper scaling
	if(fabs(fScale) > 0.001f)
		fScale = -0.5f / fScale;

	//now apply our custom scale
	LTMatrix mScale;

	if(pEnvMap->IsCubeMap())
	{
		PD3DDEVICE->SetTextureStageState(nStage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3);
		mScale = g_ViewParams.m_mWorldEnvMap;
	}
	else
	{
		PD3DDEVICE->SetTextureStageState(nStage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
		mScale.Init(fScale,	0.0f,	0.0f, 0.5f,
					0.0f,   fScale, 0.0f, 0.5f,
					0.0f,	0.0f,   1.0f, 0.0f,
					0.0f,   0.0f,   0.0f, 1.0f);

		//now multiply the two together to get our result
		mScale = mScale * g_ViewParams.m_mWorldEnvMap;
	}

	LTMatrix& m = mScale;

	//now setup the D3D version of our matrix
	D3DMATRIX mat;
	mat._11 = m.m[0][0]; mat._12 = m.m[1][0]; mat._13 = m.m[2][0]; mat._14 = m.m[3][0];
	mat._21 = m.m[0][1]; mat._22 = m.m[1][1]; mat._23 = m.m[2][1]; mat._24 = m.m[3][1];
	mat._31 = m.m[0][2]; mat._32 = m.m[1][2]; mat._33 = m.m[2][2]; mat._34 = m.m[3][2];
	mat._41 = m.m[0][3]; mat._42 = m.m[1][3]; mat._43 = m.m[2][3]; mat._44 = m.m[3][3];

	//and install the transform
	PD3DDEVICE->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0 + nStage), &mat);
	PD3DDEVICE->SetTextureStageState(nStage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR | nStage);

}
开发者ID:Joincheng,项目名称:lithtech,代码行数:46,代码来源:3d_ops.cpp

示例6: GeneratePolyGridFresnelAlphaAndCamera

static void GeneratePolyGridFresnelAlphaAndCamera(const LTVector& vViewPos, CPolyGridBumpVertex* pVerts, LTPolyGrid* pGrid, uint32 nNumVerts)
{
	//we need to transform the camera position into our view space
	LTMatrix mInvWorldTrans;

	mInvWorldTrans.Identity();
	mInvWorldTrans.SetTranslation(-pGrid->GetPos());

	LTMatrix mOrientation;
	pGrid->m_Rotation.ConvertToMatrix(mOrientation);

	mInvWorldTrans = mOrientation * mInvWorldTrans;

	LTVector vCameraPos = mInvWorldTrans * vViewPos;

	//now generate the internals of the polygrid
	CPolyGridBumpVertex* pCurrVert	= pVerts;
	CPolyGridBumpVertex* pEnd		= pCurrVert + nNumVerts;

	//determine the fresnel table that we are going to be using
	const CFresnelTable* pTable = g_FresnelCache.GetTable(LTMAX(1.0003f, pGrid->m_fFresnelVolumeIOR), pGrid->m_fBaseReflection);

	//use a vector from the camera to the center of the grid to base our approximations off of. The further
	//we get to the edges the more likely this error will be, but it is better than another sqrt per vert
	LTVector vToPGPt;

	while(pCurrVert < pEnd)
	{
		//the correct but slow way, so only do it every once in a while
		//if((pCurrVert - g_TriVertList) % 4 == 0)
		{
			vToPGPt = vCameraPos - pCurrVert->m_Vec;
			vToPGPt.Normalize();
		}

		pCurrVert->m_fEyeX = vToPGPt.x;
		pCurrVert->m_fEyeY = vToPGPt.y;
		pCurrVert->m_fEyeZ = vToPGPt.z;

		pCurrVert->m_nColor |= pTable->GetValue(vToPGPt.Dot(pCurrVert->m_vBasisUp));
		++pCurrVert;
	}
}
开发者ID:emoose,项目名称:lithtech,代码行数:43,代码来源:drawpolygrid.cpp

示例7: Draw

// ------------------------------------------------------------------------
// Draw
// use gl to draw the model
// ------------------------------------------------------------------------
void CRenderWnd::Draw()
{
	static LTMatrix IdMat;
	IdMat.Identity();

	DrawStruct *pStruct;

	pStruct = &m_DrawStruct;

	// Setup with 2 lights.
	pStruct->m_ViewerPos = m_Camera.m_Position;
	pStruct->m_LookAt = m_Camera.m_LookAt;
	pStruct->m_LightPositions[0] = m_LightLocators[0].m_Location;
	pStruct->m_LightPositions[1] = m_LightLocators[1].m_Location;
	pStruct->m_LightColors[0].Init(255.0f, 255.0f, 255.0f);
	pStruct->m_LightColors[1].Init(128.0f, 128.0f, 128.0f);
	pStruct->m_nLights = 2;

	SetupViewingParameters((GLMContext*)m_hContext, pStruct );

 	DrawWorldCoordSys();
	
	// if the model exists 
	if (GetModel()  )
	{
		pStruct->m_SelectedPieces = m_SelectedPieces.GetArray();
		pStruct->m_SelectedNodes = m_SelectedNodes.GetArray();

		pStruct->m_bCalcRadius = m_bCalcRadius;
		pStruct->m_fModelRadius = 0.0f;
		pStruct->m_bCalcAndDraw = m_bCalcAndDraw;

		DrawModel (m_hContext, pStruct);

		m_fCurRadius = pStruct->m_fModelRadius;
	}
		
	SwapBuffers( (( GLMContext*)m_hContext)->m_hDC);

}
开发者ID:Joincheng,项目名称:lithtech,代码行数:44,代码来源:RenderWnd.cpp

示例8: CalcDims

void CLoadedPrefab::CalcDims()
{
	LTVector vMin, vMax;
	vMin.Init(FLT_MAX, FLT_MAX, FLT_MAX);
	vMax.Init(FLT_MIN, FLT_MIN, FLT_MIN);

	LTMatrix mIdent;
	mIdent.Identity();
	RecurseAndGrowDims(m_cRegion.GetRootNode(), vMin, vMax, mIdent);

	// If one of the members didn't get modified, none of them did...
	if (vMin.x == FLT_MAX)
	{
		ASSERT(vMin.y == FLT_MAX && vMin.z == FLT_MAX && 
			vMax.x == FLT_MIN && vMax.y == FLT_MIN && vMax.y == FLT_MIN);
		// Treat it as an empty set (Which it probably is...  All null nodes or something..)
		vMin.Init();
		vMax.Init();
	}

	m_vMin = vMin;
	m_vMax = vMax;
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:23,代码来源:PrefabMgr.cpp

示例9: SAVE_HOBJECT

void CTransitionAggregate::Save( ILTMessage_Write *pMsg, uint32 dwSaveFlags )
{
	if( !pMsg ) return;

	SAVE_HOBJECT( m_hObject );

	// The rest is dependent on the save type...
	
	if( dwSaveFlags != LOAD_TRANSITION ) return;

	HOBJECT hTransArea = g_pTransMgr->GetTransitionArea();
	if( !hTransArea ) return;

	TransitionArea *pTransArea = (TransitionArea*)g_pLTServer->HandleToObject( hTransArea );
	if( !pTransArea ) return;

	LTransform tfLocal;
	LTransform tfObjectWorld;
	LTransform const& tfTransAreaWorld = pTransArea->GetWorldTransform( );
	LTMatrix mInverseRot;
	tfTransAreaWorld.m_Rot.ConvertToMatrix( mInverseRot );
	mInverseRot.Inverse( );

	g_pLTServer->GetObjectPos( m_hObject, &tfObjectWorld.m_Pos );
	g_pLTServer->GetObjectRotation( m_hObject, &tfObjectWorld.m_Rot );
	LTVector vVel;
	g_pPhysicsLT->GetVelocity( m_hObject, &vVel );

	tfLocal.m_Pos = mInverseRot * ( tfObjectWorld.m_Pos - tfTransAreaWorld.m_Pos );
	tfLocal.m_Rot = tfObjectWorld.m_Rot * ~tfTransAreaWorld.m_Rot;
	LTVector vRelVel = mInverseRot * vVel;

	SAVE_VECTOR( tfLocal.m_Pos );
	SAVE_ROTATION( tfLocal.m_Rot );
	SAVE_VECTOR( vRelVel );
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:36,代码来源:TransitionAggregate.cpp

示例10: Eul_ToMatrix

/* Construct matrix from Euler angles (in radians). */
void Eul_ToMatrix(EulerAngles ea, LTMatrix &M)
{
    float ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
    int i,j,k,h,n,s,f;
    EulGetOrd((int)ea.w,i,j,k,h,n,s,f);
    if (f==EulFrmR) {
        float t = ea.x;
        ea.x = ea.z;
        ea.z = t;
    }
    if (n==EulParOdd) {
        ea.x = -ea.x;
        ea.y = -ea.y;
        ea.z = -ea.z;
    }
    ti = ea.x;
    tj = ea.y;
    th = ea.z;
    ci = (float)cos(ti);
    cj = (float)cos(tj);
    ch = (float)cos(th);
    si = (float)sin(ti);
    sj = (float)sin(tj);
    sh = (float)sin(th);
    cc = ci*ch;
    cs = ci*sh;
    sc = si*ch;
    ss = si*sh;
    if (s==EulRepYes) {
        M.El(i,i) = cj;
        M.El(i,j) =  sj*si;
        M.El(i,k) =  sj*ci;
        M.El(j,i) = sj*sh;
        M.El(j,j) = -cj*ss+cc;
        M.El(j,k) = -cj*cs-sc;
        M.El(k,i) = -sj*ch;
        M.El(k,j) =  cj*sc+cs;
        M.El(k,k) =  cj*cc-ss;
    } else {
        M.El(i,i) = cj*ch;
        M.El(i,j) = sj*sc-cs;
        M.El(i,k) = sj*cc+ss;
        M.El(j,i) = cj*sh;
        M.El(j,j) = sj*ss+cc;
        M.El(j,k) = sj*cs-sc;
        M.El(k,i) = -sj;
        M.El(k,j) = cj*si;
        M.El(k,k) = cj*ci;
    }
    M.El(EulW,EulX)=M.El(EulW,EulY)=M.El(EulW,EulZ)=M.El(EulX,EulW)=M.El(EulY,EulW)=M.El(EulZ,EulW)=0.0;
    M.El(EulW,EulW)=1.0;
}
开发者ID:xfw5,项目名称:Fear-SDK-1.08,代码行数:53,代码来源:LTEulerAngles.cpp

示例11: Eul_FromQuat

/* Convert quaternion to Euler angles (in radians). */
EulerAngles Eul_FromQuat(LTRotation const& q, int order)
{
    LTMatrix M;
    float Nq = q[0]*q[0]+q[1]*q[1]+q[2]*q[2]+q[3]*q[3];
    float s = (Nq > 0.0f) ? (2.0f / Nq) : 0.0f;
    float xs = q[0]*s,	  ys = q[1]*s,	 zs = q[2]*s;
    float wx = q[3]*xs,	  wy = q[3]*ys,	 wz = q[3]*zs;
    float xx = q[0]*xs,	  xy = q[0]*ys,	 xz = q[0]*zs;
    float yy = q[1]*ys,	  yz = q[1]*zs,	 zz = q[2]*zs;
    M.El(EulX,EulX) = 1.0f - (yy + zz);
    M.El(EulX,EulY) = xy - wz;
    M.El(EulX,EulZ) = xz + wy;
    M.El(EulY,EulX) = xy + wz;
    M.El(EulY,EulY) = 1.0f - (xx + zz);
    M.El(EulY,EulZ) = yz - wx;
    M.El(EulZ,EulX) = xz - wy;
    M.El(EulZ,EulY) = yz + wx;
    M.El(EulZ,EulZ) = 1.0f - (xx + yy);
    M.El(EulW,EulX)=M.El(EulW,EulY)=M.El(EulW,EulZ)=M.El(EulX,EulW)=M.El(EulY,EulW)=M.El(EulZ,EulW)=0.0;
    M.El(EulW,EulW)=1.0f;
    return (Eul_FromMatrix(M, order));
}
开发者ID:xfw5,项目名称:Fear-SDK-1.08,代码行数:23,代码来源:LTEulerAngles.cpp

示例12: Eul_FromMatrix

/* Convert matrix to Euler angles (in radians). */
EulerAngles Eul_FromMatrix(LTMatrix& M, int order)
{
    EulerAngles ea;
    int i,j,k,h,n,s,f;
    EulGetOrd(order,i,j,k,h,n,s,f);
    if (s==EulRepYes) {
        float sy = (float)sqrt(M.El(i,j)*M.El(i,j) + M.El(i,k)*M.El(i,k));
        if (sy > 16*FLT_EPSILON) {
            ea.x = (float)atan2(M.El(i,j), M.El(i,k));
            ea.y = (float)atan2(sy, M.El(i,i));
            ea.z = (float)atan2(M.El(j,i), -M.El(k,i));
        } else {
            ea.x = (float)atan2(-M.El(j,k), M.El(j,j));
            ea.y = (float)atan2(sy, M.El(i,i));
            ea.z = 0;
        }
    } else {
        float cy = (float)sqrt(M.El(i,i)*M.El(i,i) + M.El(j,i)*M.El(j,i));
        if (cy > 16*FLT_EPSILON) {
            ea.x = (float)atan2(M.El(k,j), M.El(k,k));
            ea.y = (float)atan2(-M.El(k,i), cy);
            ea.z = (float)atan2(M.El(j,i), M.El(i,i));
        } else {
            ea.x = (float)atan2(-M.El(j,k), M.El(j,j));
            ea.y = (float)atan2(-M.El(k,i), cy);
            ea.z = 0;
        }
    }
    if (n==EulParOdd) {
        ea.x = -ea.x;
        ea.y = - ea.y;
        ea.z = -ea.z;
    }
    if (f==EulFrmR) {
        float t = ea.x;
        ea.x = ea.z;
        ea.z = t;
    }
    ea.w = (float)order;
    return (ea);
}
开发者ID:xfw5,项目名称:Fear-SDK-1.08,代码行数:42,代码来源:LTEulerAngles.cpp

示例13: d3d_DrawRotatableSprite

static void d3d_DrawRotatableSprite(const ViewParams& Params, SpriteInstance *pInstance, SharedTexture *pShared)
{
	
	if(!d3d_SetTexture(pShared, 0, eFS_SpriteTexMemory))
		return;

	float fWidth = (float)((RTexture*)pShared->m_pRenderData)->GetBaseWidth();
	float fHeight = (float)((RTexture*)pShared->m_pRenderData)->GetBaseHeight();

	//cache the object position
	LTVector vPos = pInstance->GetPos();
	
	LTMatrix mRotation;
	d3d_SetupTransformation(&vPos, (float*)&pInstance->m_Rotation, &pInstance->m_Scale, &mRotation);

	//get our basis vectors
	LTVector vRight, vUp, vForward;
	mRotation.GetBasisVectors(&vRight, &vUp, &vForward);

	//scale the vectors to be the appropriate size
	vRight  *= fWidth;
	vUp		*= fHeight;

	// Setup the points.
	RGBColor Color;
	d3d_GetSpriteColor(pInstance, &Color);
	uint32 nColor = Color.color;

	CSpriteVertex SpriteVerts[4];
	SpriteVerts[0].SetupVert(vPos + vUp - vRight, nColor, 0.0f, 0.0f);
	SpriteVerts[1].SetupVert(vPos + vUp + vRight, nColor, 1.0f, 0.0f);
	SpriteVerts[2].SetupVert(vPos + vRight - vUp, nColor, 1.0f, 1.0f);
	SpriteVerts[3].SetupVert(vPos - vRight - vUp, nColor, 0.0f, 1.0f);


	//figure out our final vertices to use
	CSpriteVertex	*pPoints;
	uint32			nPoints;
	CSpriteVertex	ClippedSpriteVerts[40 + 5];

	if(pInstance->m_ClipperPoly != INVALID_HPOLY)
	{
		if(!d3d_ClipSprite(pInstance, pInstance->m_ClipperPoly, &pPoints, &nPoints, ClippedSpriteVerts))
		{
			return;
		}
	}
	else
	{
		pPoints = SpriteVerts;
		nPoints = 4;
	}

	if((pInstance->m_Flags & FLAG_SPRITEBIAS) && !(pInstance->m_Flags & FLAG_REALLYCLOSE))
	{
		//adjust the points
		for(uint32 nCurrPt = 0; nCurrPt < nPoints; nCurrPt++)
		{
			//get the sprite vertex that we are modifying
			LTVector& vPt = SpriteVerts[nCurrPt].m_Vec;

			//find a point relative to the viewer position
			LTVector vPtRelCamera = vPt - Params.m_Pos;

			//determine the distance from the camera
			float fZ = vPtRelCamera.Dot(Params.m_Forward);

			if(fZ <= NEARZ)
				continue;

			//find the bias, up to, but not including the near plane
			float fBiasDist = SPRITE_POSITION_ZBIAS;
			if((fZ + fBiasDist) < NEARZ)
				fBiasDist = NEARZ - fZ;
			
			//now adjust our vectors accordingly so that we can move it forward
			//but have it be the same size
			float fScale = 1 + fBiasDist / fZ;

			vPt = Params.m_Right * vPtRelCamera.Dot(Params.m_Right) * fScale +
				  Params.m_Up * vPtRelCamera.Dot(Params.m_Up) * fScale +
				  (fZ + fBiasDist) * Params.m_Forward + Params.m_Pos;
		}
	}
	
	LTEffectImpl* pEffect = (LTEffectImpl*)LTEffectShaderMgr::GetSingleton().GetEffectShader(pInstance->m_nEffectShaderID);
	if(pEffect)
	{
		pEffect->UploadVertexDeclaration();

		ID3DXEffect* pD3DEffect = pEffect->GetEffect();
		if(pD3DEffect)
		{
			RTexture* pTexture = (RTexture*)pShared->m_pRenderData;
			pD3DEffect->SetTexture("texture0", pTexture->m_pD3DTexture);

			i_client_shell->OnEffectShaderSetParams(pEffect, NULL, NULL, LTShaderDeviceStateImp::GetSingleton());

			UINT nPasses = 0;
			pD3DEffect->Begin(&nPasses, 0);
//.........这里部分代码省略.........
开发者ID:emoose,项目名称:lithtech,代码行数:101,代码来源:drawsprite.cpp

示例14: GetProps


//.........这里部分代码省略.........
		{
			LTVector vPrev = m_collPathPts.GetTail()->m_Data.m_vPos;
			float fUPrev = m_collPathPts.GetTail()->m_Data.m_uVal;
			
			float fWidth = (float)m_dwWidth;
			float fScalar = fWidth / GetProps()->m_fTrailWidth;

			ts.m_uVal = fUPrev + ((((vNew - vPrev).Mag()) / fWidth) * fScalar);

		}
		else
		{
			ts.m_uVal = 0.0f;
		}

		m_collPathPts.AddTail(ts);
		
		m_tmElapsedEmission = 0.0f;
	}

	// Render the tube....

	if (m_collPathPts.GetSize() < 2) return true;

	CLinkListNode<PT_TRAIL_SECTION> *pNode = m_collPathPts.GetHead();

	// Fudge the last point to be the current one...

	if( !IsShuttingDown() )
		m_collPathPts.GetTail()->m_Data.m_vPos = m_vPos;

	// Transform the path

	LTMatrix mCam;
	if( m_bReallyClose || (GetProps()->m_eAllignment != ePTA_Camera))
	{
		mCam.Identity();
	}
	else
	{
		mCam = GetCamTransform(m_pLTClient, m_hCamera);
	}
	 
	while (pNode)
	{
		MatVMul(&pNode->m_Data.m_vTran, &mCam, &pNode->m_Data.m_vPos);
		pNode = pNode->m_pNext;
	}

	// Do some precalculations

	pNode = m_collPathPts.GetHead();

	float fCurU = 0.0f;

	while (pNode)
	{
		pNode->m_Data.m_tmElapsed += tmFrameTime;

		if( GetProps()->m_eAllignment == ePTA_Camera )
		{
			LTVector vBisector;
			vBisector.z = 0.0f;

			// Compute the midpoint vectors
开发者ID:rickyharis39,项目名称:nolf2,代码行数:66,代码来源:polytubefx.cpp

示例15: RecurseAndGrowDims

static void RecurseAndGrowDims(CWorldNode *pNode, LTVector &vMin, LTVector &vMax, LTMatrix& mTransMat)
{
	//sanity check
	if(pNode == NULL)
	{
		return;
	}

	// Grow the dims for this node
	switch (pNode->GetType())
	{
		case Node_Object :
		{
			CBaseEditObj *pObject = pNode->AsObject();
			LTVector vCenter;
			mTransMat.Apply(pObject->GetPos(), vCenter);

			//always include at least the object center
			VEC_MIN(vMin, vMin, vCenter);
			VEC_MAX(vMax, vMax, vCenter);

#ifdef DIRECTEDITOR_BUILD			
			
			//see if there are other dims we need
			for (uint32 nCurDim = pObject->GetNumDims(); nCurDim > 0; --nCurDim)
			{
				LTVector vDims = *pObject->GetDim(nCurDim - 1);
				LTVector vObjMin = vCenter - vDims;
				LTVector vObjMax = vCenter + vDims;
				VEC_MIN(vMin, vMin, vObjMin);
				VEC_MAX(vMax, vMax, vObjMax);
			}
#endif
		}
		break;
		case Node_Brush:
		{
			CEditBrush *pBrush = pNode->AsBrush();
			
			CBoundingBox BBox = pBrush->CalcBoundingBox();

			//transform the bounding box
			LTVector vBoxMin, vBoxMax;
			mTransMat.Apply(BBox.m_Min, vBoxMin);
			mTransMat.Apply(BBox.m_Max, vBoxMax);

			VEC_MIN(vMin, vMin, vBoxMin);
			VEC_MAX(vMax, vMax, vBoxMax);
		}
		break;
		case Node_PrefabRef:
		{
			//create the new transformation matrix
			LTMatrix mRot;
			::gr_SetupMatrixEuler(pNode->GetOr(), mRot.m);

			LTMatrix mTranslate;
			mTranslate.Identity();
			mTranslate.SetTranslation(pNode->GetPos());

			LTMatrix mNewTransMat = mTransMat * mTranslate * mRot;
			RecurseAndGrowDims((CWorldNode*)((CPrefabRef*)pNode)->GetPrefabTree(), vMin, vMax, mNewTransMat);
		}
		break;
	}

	// Go through the children
	GPOS iFinger = pNode->m_Children.GetHeadPosition();
	while (iFinger)
	{
		CWorldNode *pChild = pNode->m_Children.GetNext(iFinger);
		RecurseAndGrowDims(pChild, vMin, vMax, mTransMat);
	}
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:74,代码来源:PrefabMgr.cpp


注:本文中的LTMatrix类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。