本文整理汇总了C++中D3DXVec3Length函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXVec3Length函数的具体用法?C++ D3DXVec3Length怎么用?C++ D3DXVec3Length使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D3DXVec3Length函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: D3DXVec3Length
//****************************************************************
// attack
void Finger::attack( const D3DXVECTOR3& pos )
{
float thre = 2.0f;
D3DXVECTOR3 v = pos - coarse_->get_current_center();
float l = D3DXVec3Length( &v );
if( waiting_ && 1.0f < l ) {
D3DXVec3Normalize( &v, &v );
v *= -0.5f;
D3DXVECTOR3 t = pos + v;
coarse_->kill_inertia();
coarse_->teleport( t - coarse_->get_current_center() );
} else {
px::tetrahedralmesh_type::points_type& points = mesh_->get_points();
size_t n = points.size();
for( size_t i = 0 ; i < n ; i++ ) {
if( 0.2f < points[i].source_position.y ) {
D3DXVECTOR3 d = pos - points[i].new_position;
if( thre < D3DXVec3Length( &d ) ) {
d /= thre;
D3DXVec3Normalize( &d, &d );
d *= thre;
}
points[i].forces += d * 50.0f;
}
}
}
coarse_->set_positive( true );
waiting_ = false;
}
示例2: while
//================================================================================
//! メソッド名 C3D_MAP::draw
//
// 機能 描画(見えない物は、描画しない)(ソートしない)(Zテクスチャシェーダ使用)
// 引数 inZTexSha Zテクスチャシェーダ
// inViewPoint カメラ視点
// 更新 2008/12/14 <新規>
//================================================================================
void
C3D_MAP::draw(CZTEX_SHA* inZTexSha, VEC3* inViewPoint)
{
vector<C3D_OBJECT*>* c3dObjvec; //!< vectorポインター
vector<C3D_OBJECT*>::iterator p; //!< 作業用イテレータ
// 検査しながら描画するため、とりだして描画
// 背景描画
c3dObjvec = backG.getObjects();
p = c3dObjvec->begin();
while(p != c3dObjvec->end())
{
// オブジェクトのメッセージをチェックして、描画判定
if( D3DXVec3Length(&(*inViewPoint - (*p)->getLoc())) < fDistance)
{
(*p)->draw(inZTexSha);
}
p++;
}
// 通常描画
c3dObjvec = viewG.getObjects();
p = c3dObjvec->begin();
while(p != c3dObjvec->end())
{
// オブジェクトのメッセージをチェックして、描画判定
if( D3DXVec3Length(&(*inViewPoint - (*p)->getLoc())) < fDistance)
{
(*p)->draw(inZTexSha);
}
p++;
}
}
示例3: CheckDuplicatePortal
BOOL CheckDuplicatePortal ( PORTAL* CheckPortal, int* index )
{
// this is used to check the current portal with the portal already
// sharing the same leaves in tree, it is only accepted if the portal is
// larger than the one that is ready occupying this place in the master
// portal array.
long CheckPortalLeaf1 = CheckPortal->LeafOwnerArray [ 0 ];
long CheckPortalLeaf2 = CheckPortal->LeafOwnerArray [ 1 ];
long PALeaf1 = 0;
long PALeaf2 = 0;
// loop through the portals
for ( long i = 0; i < NumberOfPortals; i++ )
{
PALeaf1 = PortalArray [ i ]->LeafOwnerArray [ 0 ];
PALeaf2 = PortalArray [ i ]->LeafOwnerArray [ 1 ];
if (
( CheckPortalLeaf1 == PALeaf1 && CheckPortalLeaf2 == PALeaf2 )
||
( CheckPortalLeaf1 == PALeaf2 && CheckPortalLeaf2 == PALeaf1 )
)
{
D3DXVECTOR3 Max1,
Min1,
Max2,
Min2;
GetPortalBounds ( CheckPortal, &Min1, &Max1 );
GetPortalBounds ( PortalArray [ i ], &Min2, &Max2 );
// measure the length of the vectors to see which is bigger
float NewSize = D3DXVec3Length ( &( Max1 - Min1 ) );
float OldSize = D3DXVec3Length ( &( Max2 - Min2 ) );
if ( fabs ( NewSize ) > fabs ( OldSize ) )
{
PORTAL* temp = PortalArray [ i ];
DeletePortal ( temp );
temp = NULL;
*index = i;
return FALSE;
}
else
{
// this portal is already in the array
return TRUE;
}
}
}
*index = NumberOfPortals;
// this portal was not found in the array
return FALSE;
}
示例4: D3DXVec3Dot
float CRouter::GetDistance(const D3DXVECTOR3 *vPosA, const D3DXVECTOR3 *vPosB)
{
D3DXVECTOR3 vDif = *vPosB - *vPosA;
D3DXVECTOR3 vPos = *vPosA;
float fDot = D3DXVec3Dot(&vDif, &vPos);
float fCos = fDot/(D3DXVec3Length(&vDif)*D3DXVec3Length(&vPos));
return D3DXVec3Length(&vPos)*(sqrt(1 - fCos*fCos));
}
示例5: ReflectCollision
void CLine::DetectCollision() {
if (!m_pMap) return;
/// Model 2: Turn back if throughed.
/// Cons: Some will break through edges.
m_bTurned = m_pMap->GetArea(MT_WALL, m_mapIndex)->
ReflectCollision(m_vPos, m_vDir, m_bTurned);
if (m_pEcho.empty()) {
m_pEcho.push_back(CPoint(m_vPos, m_pMap->GetRenderEffect(m_vPos)));
} else {
if (m_bQuiet) {
D3DXVECTOR3 *pre = &m_pEcho.back().GetPos();
D3DXVECTOR3 lerp = m_vPos - *pre;
FLOAT step = 1.f / D3DXVec3Length(&lerp);
for (FLOAT s(0); s < 1.f; s += step) {
D3DXVec3Lerp(&lerp, pre, &m_vPos, s);
m_pEcho.push_back(CPoint(lerp, m_pMap->GetRenderEffect(lerp)));
}
} else {
D3DXVECTOR3 *pre = &m_pEcho.front().GetPos();
D3DXVECTOR3 lerp = m_vPos - *pre;
FLOAT step = 1.f / D3DXVec3Length(&lerp);
for (FLOAT s(0); s < 1.f; s += step) {
D3DXVec3Lerp(&lerp, pre, &m_vPos, s);
m_pEcho.push_front(CPoint(lerp, m_pMap->GetRenderEffect(lerp)));
}
}
}
/// Model 1: Roll back to previous if throughed.
/// Cons: Some will stay still on egdes and flash.
//if (map->GetArea(MT_WALL, index)->ReflectCollision(m_vPos, m_vDir)) {
// if (m_bQuiet) m_pEcho.push_back(m_vPos);
// else m_pEcho.push_front(m_vPos);
//} else {
// if (m_bQuiet) {
// m_pEcho.pop_back();
// if (!m_pEcho.empty()) m_vPos = m_pEcho.back();
// } else {
// m_pEcho.pop_front();
// if (!m_pEcho.empty()) m_vPos = m_pEcho.front();
// }
//}
/// Model 0: Judging from intersection point.
/// Cons: Only tested in early version, unstable.
//if (map->GetArea(MT_WALL, index)->Validate(m_vPos)) return;
//for (EdgesCIt it(map->GetArea(MT_WALL, index)->edges.begin());
// it != map->GetArea(MT_WALL, index)->edges.end(); ++it) {
// if (it->Intersected(m_vPre, m_vPos)) {
// if (it->AimingInside(m_vDir)) return;
// FLOAT dis(fabsf(it->GetDistance(m_vPos)));
// //m_vPre = m_vPos;
// m_vPos += it->normal*dis*(it->inside?2.f:-2.f);
// m_vDir = it->GetReflectDirection(m_vDir);
// return;
// }
//}
}
示例6: SetIsAccelerating
void Character::UpdateItSelf( float dTime )
{
// 가속
if ( IsAccelerating() )
{
if ( timeGetTime() - GetAccelerationStartTime() > ACCELERATION_TIME )
{
// 가속 끝났다
SetIsAccelerating( false );
SetAcceleration( ZERO_VECTOR3 );
}
}
if ( !m_CharacterClass->IsAlive() )
{
//printf_s( "player %d is dead \n", m_CharacterId );
return;
}
m_Matrix = GetTransform()->MatrixTransform();
if ( IsSpinning() )
{
AddSpinTime( dTime );
// 회전축을 기준으로 물체를 회전시킵니다.
D3DXMATRIXA16 spinTransform;
D3DXVECTOR3 tmpSpinAxis = GetSpinAxis();
float tmpSpinAngle = GetSpinAngularVelocity();
D3DXMatrixRotationAxis( &spinTransform, &tmpSpinAxis, tmpSpinAngle * GetSpinTime() );
// D3DXMatrixMultiply( &m_Matrix, &m_Matrix, &spinTransform );
D3DXMatrixMultiply( &m_Matrix, &spinTransform, &m_Matrix );
}
D3DXVECTOR3 tmpVec3 = GetTransform()->GetPosition();
D3DXVECTOR3 tmpVel = GetVelocity();
Physics::CalcCurrentPosition( &tmpVec3, &tmpVel, GetAcceleration(), dTime, GetSpeedConstant() );
// 최대 이동거리 제한
float currentDistanceFromOrigin = D3DXVec3Length( &tmpVec3 );
if ( currentDistanceFromOrigin > MAX_DISTANCE_FROM_ORIGIN )
m_CharacterClass->SetOxygen( 0.0f );
// 최대 속도 제한
float currentSpeed = D3DXVec3Length( &tmpVel );
if ( currentSpeed > MAX_PLAYER_SPEED )
{
D3DXVec3Normalize( &tmpVel, &tmpVel );
tmpVel *= MAX_PLAYER_SPEED;
}
GetTransform()->SetPosition( tmpVec3 );
SetVelocity( tmpVel );
// 산소량 감소등의 작업 처리
GetClassComponent()->Update( dTime );
}
示例7: D3DXVECTOR3
void StaticCamera::SetFromSunlight(D3DXVECTOR3* position, D3DXVECTOR3* direction, D3DXVECTOR4 Power, float Width, float Height, float Depth)
{
D3DXVECTOR3 d3dLookAt = D3DXVECTOR3(Width, Height, Depth) * 0.5f;//(*position + *Direction * m_fFarPlane);
D3DXVECTOR3 eye = *position / D3DXVec3Length(position);
eye *= D3DXVec3Length(&d3dLookAt) * 1.1f;
eye += d3dLookAt;
CBaseCamera::SetViewParams(&eye, &d3dLookAt);
mLightColor = Power;
*position = eye;
d3dLookAt = d3dLookAt - eye;
d3dLookAt /= D3DXVec3Length(&d3dLookAt);
*direction = d3dLookAt;
D3DXVECTOR3 cornersWorld[] = {
D3DXVECTOR3(0,0,0),
D3DXVECTOR3(Width, 0, 0),
D3DXVECTOR3(Width, Height, 0),
D3DXVECTOR3(Width, Height, Depth),
D3DXVECTOR3(0, Height, 0),
D3DXVECTOR3(0, Height, Depth),
D3DXVECTOR3(0,0,Depth),
D3DXVECTOR3(Width, 0, Depth)
};
D3DXVECTOR3 lightSpaceBoxMin = D3DXVECTOR3(FLT_MAX,FLT_MAX,FLT_MAX);
D3DXVECTOR3 lightSpaceBoxMax = D3DXVECTOR3(FLT_MIN, FLT_MIN, FLT_MIN);
for (int i = 0; i < 8; ++i)
{
D3DXVec3TransformCoord(&cornersWorld[i], &cornersWorld[i], GetViewMatrix());
lightSpaceBoxMin.x = lightSpaceBoxMin.x < cornersWorld[i].x ? lightSpaceBoxMin.x : cornersWorld[i].x;
lightSpaceBoxMin.y = lightSpaceBoxMin.y < cornersWorld[i].y ? lightSpaceBoxMin.y : cornersWorld[i].y;
lightSpaceBoxMin.z = lightSpaceBoxMin.z < cornersWorld[i].z ? lightSpaceBoxMin.z : cornersWorld[i].z;
lightSpaceBoxMax.x = lightSpaceBoxMax.x > cornersWorld[i].x ? lightSpaceBoxMax.x : cornersWorld[i].x;
lightSpaceBoxMax.y = lightSpaceBoxMax.y > cornersWorld[i].y ? lightSpaceBoxMax.y : cornersWorld[i].y;
lightSpaceBoxMax.z = lightSpaceBoxMax.z > cornersWorld[i].z ? lightSpaceBoxMax.z : cornersWorld[i].z;
};
SetOrthoParams(lightSpaceBoxMax.x - lightSpaceBoxMin.x, lightSpaceBoxMax.y - lightSpaceBoxMin.y, lightSpaceBoxMin.z, lightSpaceBoxMax.z);
//set constant buffer
D3DXMATRIX identityMatrix;
D3DXMatrixIdentity(&identityMatrix);
cameraCBuffer->Data.World = identityMatrix;
cameraCBuffer->Data.refractiveIndexETA = 1.0f;
cameraCBuffer->Data.View = *GetViewMatrix();
cameraCBuffer->Data.WorldViewProjection = identityMatrix * cameraCBuffer->Data.View * (*GetProjMatrix());
//float test = D3DXMatrixDeterminant(GetProjMatrix());
//test = D3DXMatrixDeterminant(GetViewMatrix());
//test = test +1;
}
示例8: DXVector
//first attempt at an implementation - use 'force' as an impulse, and change velocities instantaneously
void CRigidBody::OnCollision(const PAVECTOR* pLocation, const PAVECTOR* pForce)
{
D3DXVECTOR3 dxLocation = DXVector(*pLocation);
D3DXVECTOR3 dxForce = DXVector(*pForce);
m_velocity += dxForce / m_mass;
// find the vector from the origin to the point through which the force is exerted
D3DXVECTOR3 radius;
// first find some multiplier A for which radius = location + A * force
float A;
float forceMagnitude = D3DXVec3Length(&dxForce);
A = - D3DXVec3Dot(&dxLocation, &dxForce) / (forceMagnitude * forceMagnitude);
radius = dxLocation + A * dxForce;
if (D3DXVec3Length(&radius) < 0.001)
{
//the force is effectively acting directly through the COM, and is therefore purely translational
return;
}
// now consider two sections of the mass, divided by the force. One is attmpting to turn one way, the other section attempts to turn the other way.
// the plane separating the two sections is described by two vectors. One is the force, the other is perpendicular to the force and the radius.
D3DXVECTOR3 rotationAxis;
D3DXVec3Cross(&rotationAxis, &radius, &dxForce);
// section one: the smaller section
/*
D3DXVECTOR3 sec1COM;
float sec1Size = m_hitbox.GetSplitSection(&sec1COM, &force, &rotationAxis);
if (sec1Size < 0.0001)
{
// the force is right on the edge of the object, and is purely rotational
*/
D3DXQUATERNION change;
D3DXQuaternionRotationAxis(&change, &rotationAxis, D3DXVec3Length(&rotationAxis));
m_angularVelocity += change / (m_mass * GetMomentOfInertia(&PAVector(rotationAxis)));
return;
/*
}
{
// a combination of translation and rotation
D3DXVECTOR3 sec1Radius;
}
*/
}
示例9: min
bool Tank::checknResolveBulletCollision(Bullet* other, D3DXVECTOR3& location)
{
vector<State*> *bullets = other->GetBullets();
vector<int> *collisions = new vector<int>();
bool hascollision = false;
for (unsigned int i = 0; i < bullets->size(); i++)
{
State *otherState = (*bullets)[i];
D3DXVECTOR3 plane = *otherState->GetPosition()-*m_tankState->GetPosition();
D3DXVECTOR3 plane2 = *otherState->GetPosition()-(*m_tankState->GetPosition() + *m_tankState->GetForward()*0.75f);
float distance = min(D3DXVec3Length(&plane),D3DXVec3Length(&plane2));
if (distance < 1)
{
collisions->push_back(i);
D3DXVECTOR3 thisvel,othervel,thisafter,otherafter, thisperp, otherperp;
D3DXVec3Normalize(&plane,&plane);
thisvel = m_tankState->GetPosVel();
othervel = otherState->GetPosVel();
thisvel = thisvel.x * *m_tankState->GetRight() + thisvel.y * *m_tankState->GetUp() + thisvel.z * *m_tankState->GetForward();
othervel = othervel.x * *otherState->GetRight() + othervel.y * *otherState->GetUp() + othervel.z * *otherState->GetForward();
thisperp = plane * D3DXVec3Dot(&plane,&thisvel);
//thispar = thisvel - thisperp;
otherperp = plane * D3DXVec3Dot(&plane,&othervel);
//otherpar = othervel - otherperp;
//result = (thisperp-otherperp) * 0.5f;
thisafter = thisvel + D3DXVec3Dot(&(othervel+thisvel),&plane) * plane;
//otherafter = othervel + D3DXVec3Dot(&(thisvel-othervel),&plane) * plane;
thisafter.y = 0;
thisafter = thisafter * 0.1f;
m_tankState->SetPosVel(thisafter);
otherState->SetPosVel(D3DXVECTOR3(0,0,0));
location = *otherState->GetPosition();
hascollision = true;
}
}
other->removeBullets(collisions);
return hascollision;
}
示例10: Vector3f
//compute the vertex normals
void Terrain::ComputeNormals()const{
for (int i = 0; i < gridWidth; i++){
for (int j = 0; j < gridDepth; j++){
Vector3f v1,v2,v3,v4,v12,v23,v34,v41,v;
v1 = v2 = v3 = v4 = v12 = v23 = v34 = v41 = v = Vector3f(0.0f,0.0f,0.0f);
//grab 2 vectors for this
if (j != gridWidth - 1){
v1 = Vector3f(vertices[i*gridDepth+j+1].pos-vertices[i*gridDepth+j].pos);
}
if (i != gridWidth - 1){
v2 = Vector3f(vertices[(i+1)*gridDepth+j].pos-vertices[i*gridDepth+j].pos);
}
if (j > 0){
v3 = Vector3f(vertices[i*gridDepth+j-1].pos-vertices[i*gridDepth+j].pos);
}
if (i > 0){
v4 = Vector3f(vertices[(i-1)*gridDepth+j].pos-vertices[i*gridDepth+j].pos);
}
D3DXVec3Cross(&v12,&v1,&v2);
D3DXVec3Normalize(&v12,&v12);
D3DXVec3Cross(&v23,&v2,&v3);
D3DXVec3Normalize(&v23,&v23);
D3DXVec3Cross(&v34,&v3,&v4);
D3DXVec3Normalize(&v34,&v34);
D3DXVec3Cross(&v41,&v4,&v1);
D3DXVec3Normalize(&v41,&v41);
if (D3DXVec3Length(&v12) > 0.0f)
v = v + v12;
if (D3DXVec3Length(&v23) > 0.0f)
v = v + v23;
if (D3DXVec3Length(&v34) > 0.0f)
v = v + v34;
if (D3DXVec3Length(&v41) > 0.0f)
v = v + v41;
D3DXVec3Normalize(&v,&v);
vertices[i*gridDepth+j].normal = v;
}
}
}
示例11: D3DXVECTOR3
//**関数***************************************************************************
// 概要 : 拡大込み2D矩形と円判定
//*********************************************************************************
bool CCalc::IntersectBoxAndCircleScale(CHitRect rect , D3DMATRIX matRect , CHitCircle circle , D3DMATRIX matCircle)
{
D3DXVECTOR3 ScaleA = D3DXVECTOR3(0,0,0) , ScaleB = D3DXVECTOR3(0,0,0);
ScaleA.x = D3DXVec3Length(& D3DXVECTOR3(matRect._11 , matRect._12 , matRect._13));
ScaleA.y = D3DXVec3Length(& D3DXVECTOR3(matRect._21 , matRect._22 , matRect._23));
ScaleB.x = D3DXVec3Length(& D3DXVECTOR3(matCircle._11 , matCircle._12 , matCircle._13));
rect.m_fWidth *= ScaleA.x;
rect.m_fHeight *= ScaleA.y;
circle.m_fRadius *= ScaleB.x;
rect.m_fWidth += circle.m_fRadius * 2;
rect.m_fHeight += circle.m_fRadius * 2;
// 左上に位置合わせ
switch(rect.m_nPointType)
{
case eHitRect::CENTER:
rect.m_Point.x -= rect.m_fWidth / 2.0f;
rect.m_Point.y -= rect.m_fHeight / 2.0f;
break;
case eHitRect::UP_LEFT_2D:
break;
case eHitRect::DOWN_CENTER:
rect.m_Point.x -= rect.m_fWidth / 2.0f;
rect.m_Point.y -= rect.m_fHeight;
break;
case eHitRect::DOWN_RIGHT_2D:
rect.m_Point.x -= rect.m_fWidth;
rect.m_Point.y -= rect.m_fHeight;
break;
default:
// エラー
return false;
break;
}
// 判定
if(rect.m_Point.x < circle.m_Point.x && rect.m_Point.x + rect.m_fWidth > circle.m_Point.x &&
rect.m_Point.y < circle.m_Point.y && rect.m_Point.y + rect.m_fHeight > circle.m_Point.y)
return true;
else
return false;
}
示例12: D3DXVec3Normalize
D3DXVECTOR3 HitJudgments::CircleLineCollideCompensation(
const D3DXVECTOR3 _center,
const float _rad,
const D3DXVECTOR3 _Spos,
const D3DXVECTOR3 _Epos
)
{
// スタート座標とエンド座標のベクトル
D3DXVECTOR3 StartEndVec = _Epos - _Spos ;
// ベクトルを正規化
D3DXVECTOR3 Dir ;
D3DXVec3Normalize( &Dir, &StartEndVec ) ;
// スタート座標と球の座標のベクトル
D3DXVECTOR3 StartCenterVec = _Spos - _center ;
float t = 0.0f ;
D3DXVECTOR3 p = D3DXVECTOR3( 0,0,0 ) ;
// 最近接点を取る
D3DXVECTOR3 LineNear = ClosestPtPointSegment( _center, _Spos, _Epos ) ;
D3DXVECTOR3 CompDir = _center - LineNear ;
CompDir.y = 0.0f ;
D3DXVec3Normalize( &CompDir, &CompDir ) ;
float b = D3DXVec3Dot( &StartCenterVec, &Dir ) ;
float c = D3DXVec3Dot( &StartCenterVec, &StartCenterVec ) - _rad * _rad;
float Length = D3DXVec3Length( &StartEndVec ) ;
if( c > 0.0f && b > 0.0f ) return _center ;
float Discr = b * b - c ;
if( Discr < 0.0f ) return _center ;
t = -b - sqrt( Discr ) ;
if( t < 0.0f ) t = 0.0f ;
p = _Spos + t * Dir ;
float length = D3DXVec3Length( &StartEndVec ) ;
if( t >= 0.0f && t <= Length )
{
return LineNear + ( CompDir * _rad ) ;
}
return _center ;
}
示例13: D3DXVec3Subtract
void BSP::addAlphaGeometry(Atomic* atomic, unsigned int subsetId)
{
// calculate sorting key
_objectPos = atomic->getBoundingSphere()->center;
D3DXVec3Subtract( &_distanceV, &_objectPos, &Camera::eyePos );
_distance = 0.005f * D3DXVec3Length( &_distanceV );
// retrieve sector
BSPSector* firstSector = NULL;
if( atomic->_sectors.size() )
{
firstSector = reinterpret_cast<BSPSector*>( *atomic->_sectors.begin() );
}
// choose alpha pool
if( _distance <= 255 )
{
_sortedAlpha.add( &AlphaGeometry(
_nearest,
unsigned char( _distance ),
atomic->frame(),
atomic->geometry(),
firstSector,
atomic->getBoneMatrices(),
subsetId
) );
}
示例14: edge
void WaypointManager::addEdge(int id1, int id2)
{
EdgePtr edge(new Edge());
edge->destination = id2;
edge->distance = D3DXVec3Length(&(waypoints[id1]->_position - waypoints[id2]->_position));
waypoints[id1]->neighbors.insert(edge);
}
示例15: D3DXVECTOR3
void CBoxMesh::SetSize()
{
D3DXVECTOR3 vPos = D3DXVECTOR3(10.f, 0.f, 10.f);
//D3DXVECTOR3 vMax;
//D3DXVECTOR3 vMin;
//
//memset(&vMax, 0, sizeof(D3DXVECTOR3));
//memset(&vMin, 0, sizeof(D3DXVECTOR3));
float fRadius = -1.f;
if(m_pMesh )
{
BYTE* ppVB = NULL;
m_pMesh->LockVertexBuffer( 0, (VOID**) &ppVB);
if(FAILED(D3DXComputeBoundingBox((D3DXVECTOR3*)ppVB, m_pMesh->GetNumVertices(),
m_pMesh->GetNumBytesPerVertex(), &m_Size.vMin, &m_Size.vMax)))
{
m_fRadius = fRadius;
return;
}
D3DXVECTOR3 vLen = m_Size.vMax - m_Size.vMin;
fRadius = D3DXVec3Length(&vLen);
fRadius *= 0.5f;
}
m_fRadius = fRadius;
}