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


C++ D3DXVec3Dot函数代码示例

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


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

示例1: acos

void Tank::orientTurret(float deltaX,float deltaY, float time)
{
	float anglelimit = acos(D3DXVec3Dot(&D3DXVECTOR3(0,1,0), m_tankState->GetUp()));

	yaw += deltaX*0.01f;
	if ((deltaY < 0 && pitch > -0.60 + anglelimit) || (deltaY > 0 && pitch <0.60 + anglelimit))
		pitch += deltaY*0.005f;
}
开发者ID:francislavoie,项目名称:COMP3501-Fall2013,代码行数:8,代码来源:Tank.cpp

示例2: orthogonalizeAndNormalizeTangent

		void orthogonalizeAndNormalizeTangent(const D3DXVECTOR3 &tangent, const D3DXVECTOR3& normal, D3DXVECTOR3& tangentOut){
			float d = D3DXVec3Dot(&normal, &tangent);
			
			D3DXVECTOR3 newTangent = tangent - d * normal;
			D3DXVec3Normalize(&newTangent, &newTangent);
			tangentOut = newTangent;
			
		}
开发者ID:Manaluusua,项目名称:Dx11Sandbox,代码行数:8,代码来源:MathUtil.cpp

示例3: 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));
}
开发者ID:flair2005,项目名称:vr-bike,代码行数:8,代码来源:Router.cpp

示例4: D3DXVec3Dot

D3DXQUATERNION Sun::QuatFromBallPoints(const D3DXVECTOR3 &vFrom, const D3DXVECTOR3 &vTo)
{
	D3DXVECTOR3 vPart;
	float fDot = D3DXVec3Dot(&vFrom, &vTo);
	D3DXVec3Cross(&vPart, &vFrom, &vTo);

	return D3DXQUATERNION(vPart.x, vPart.y, vPart.z, fDot);
}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:8,代码来源:Sun.cpp

示例5: MoveBack

// Move camera backwards
void Camera::MoveBack(GameTime& gameTime)
{
	D3DXVECTOR3 forward;
	
	forward = mDirection - (D3DXVec3Dot(&mDirection, &mWorldUp) * mWorldUp);
	D3DXVec3Normalize(&forward, &forward);
	mPosition -= forward * C_MOVE_SPEED * (float)gameTime.GetTimeSinceLastTick().Seconds;
}
开发者ID:KimRestad,项目名称:3D-II-Lab2,代码行数:9,代码来源:Camera.cpp

示例6: D3DXVec3Dot

void BoundingBox::getAxisProjection(D3DXVECTOR3 axis, BoundingBox* box, float& min, float& max)
{
	float val;

	min = D3DXVec3Dot(&axis, &(box->getVertex(0)));
	max = D3DXVec3Dot(&axis, &(box->getVertex(0)));

	for (int i=0; i<8; i++)
	{
		D3DXVECTOR3 as = box->getVertex(i);
		val = D3DXVec3Dot(&axis, &(box->getVertex(i)));
		if (val < min)
			min = val;
		if (val > max)
			max = val;
	}
}
开发者ID:s0n4m,项目名称:ISM,代码行数:17,代码来源:BoundingBox.cpp

示例7: D3DXVec3Dot

D3DXQUATERNION ArcBall::QuatFromBallPoints(const D3DXVECTOR3 &vFrom, const D3DXVECTOR3 &vTo)
{
	D3DXVECTOR3 vPart;
	float fDot = D3DXVec3Dot( &vFrom, &vTo );	// rotation angle
	D3DXVec3Cross( &vPart, &vFrom, &vTo );		// rotation axis

	return D3DXQUATERNION( vPart.x, vPart.y, vPart.z, fDot );
}
开发者ID:Clearlove1992,项目名称:GraphicsDemos,代码行数:8,代码来源:ArcBall.cpp

示例8: calcSphereTriangleDistance

static inline void calcSphereTriangleDistance(
    Sphere* sphere,
    Vector* normal,
    Vector* v0, Vector* v1, Vector* v2,
    Vector* collPoint,
    float* distance 
)
{
    // project sphere center onto plane of triangle.
    Vector* center = &sphere->center;
    Vector  projPoint;
    float   dist2plane = D3DXVec3Dot( v0, normal ) - D3DXVec3Dot( center, normal );
    D3DXVec3Scale( &projPoint, normal, dist2plane );
    D3DXVec3Add( &projPoint, &projPoint, center );

    // does the projected point lie within the collision triangle?
    Vector* vertices[3];
    vertices[0] = v0, vertices[1] = v1, vertices[2] = v2;
    if( isPointWithinTriangle( &projPoint, vertices, normal ) )
    {
        *distance = fabs( dist2plane );
        *collPoint = projPoint;
        return;
    }
    // projected point lies outside the triangle, so find the nearest
    // point on the triangle boundary...
    else
    {
        float currdist;
        Vector closestPoint, temp;
    
        findNearestPointOnLine( &closestPoint, &projPoint, v0, v1 );
        D3DXVec3Subtract( &temp, center, &closestPoint );
        *distance = D3DXVec3Length(&temp), *collPoint = closestPoint;

        findNearestPointOnLine( &closestPoint, &projPoint, v1, v2 );
        D3DXVec3Subtract(&temp, center, &closestPoint);
        currdist = D3DXVec3Length(&temp);
        if( *distance > currdist ) *distance = currdist, *collPoint = closestPoint;

        findNearestPointOnLine( &closestPoint, &projPoint, v0, v2 );
        D3DXVec3Subtract(&temp, center, &closestPoint);
        currdist = D3DXVec3Length(&temp);
        if( *distance > currdist ) *distance = currdist, *collPoint = closestPoint;
    }
}
开发者ID:cheinkn,项目名称:basextreme,代码行数:46,代码来源:collision.cpp

示例9: D3DXVec3Normalize

//**関数***************************************************************************
//	概要	:	反射計算
//*********************************************************************************
void CCalc::Bound3D(CBoundData* boundA , CBoundData* boundB)
{
	D3DXVECTOR3 VelA , VelB;

	D3DXVECTOR3 VecAtoB;					// オブジェクトの方向
	D3DXVECTOR3 VecBtoA;					// オブジェクトの方向

	D3DXVECTOR3 vecBuf;
	float		fBuf;						// 計算用バッファ

	VelA = boundA->m_Velocity;
	VelB = boundB->m_Velocity;
	float fWaA = boundA->m_fMass;
	float fWaB = boundB->m_fMass;
	float fBou = boundA->m_fBounds;

	// オブジェクトの衝突方向を計算
	VecAtoB = boundB->m_Pos - boundA->m_Pos;	// AからBへのベクトル
	D3DXVec3Normalize(&VecAtoB , &VecAtoB);
	VecBtoA = boundA->m_Pos - boundB->m_Pos;	// BからAへのベクトル
	D3DXVec3Normalize(&VecBtoA , &VecBtoA);

	// Aの速度ベクトルを分解
	fBuf = D3DXVec3Dot(&VelA , &VecAtoB);
	VecAtoB = VecAtoB * fBuf;					// 分解したベクトルを保存
	VelA -= VecAtoB;							// 継続して持つベクトルを逃がす
	
	// Bの速度ベクトル
	fBuf = D3DXVec3Dot(&VelB , &VecBtoA);
	VecBtoA = VecBtoA * fBuf;
	VelB -= VecBtoA;

	// ベクトル計算	
	boundA->m_Velocity = ((fWaA - fBou * fWaB) * VecAtoB + ((1 + fBou) * fWaB * VecBtoA)) / (fWaA + fWaB);
	boundB->m_Velocity = ((fWaB - fBou * fWaA) * VecBtoA + ((1 + fBou) * fWaA * VecAtoB)) / (fWaB + fWaA);
	boundA->m_Velocity += VelA;
	boundB->m_Velocity += VelB;

	// 衝突回避位置に移動
	D3DXVECTOR3 vec = boundB->m_Pos - boundA->m_Pos;
	D3DXVec3Normalize(&vec , &vec);
	boundB->m_Pos.x = boundA->m_Pos.x + vec.x * (boundA->m_fRadius + boundB->m_fRadius + 0.5f);
	boundB->m_Pos.y = boundA->m_Pos.y + vec.y * (boundA->m_fRadius + boundB->m_fRadius + 0.5f);
	boundB->m_Pos.z = boundA->m_Pos.z + vec.z * (boundA->m_fRadius + boundB->m_fRadius + 0.5f);
}
开发者ID:FujiokaNaoto,项目名称:DirectX_Base,代码行数:48,代码来源:Calc.cpp

示例10: intersect_plane

bool intersect_plane ( const D3DXVECTOR3& start, const D3DXVECTOR3& dir,  const D3DXVECTOR3& pt, D3DXVECTOR3& ret )
{
	const D3DXVECTOR3& n = cache.normal;
	float denom = D3DXVec3Dot ( &n,&dir );

	if ( denom <= -EPSILON || denom >= EPSILON )
	{
		float numer = D3DXVec3Dot ( &n,&( pt - start ) );
		float u = numer / denom;

		if ( u > 0 && u <= 1.0f )
		{
			ret = start + dir * u;
			return true;
		}
	}
	return false;
}
开发者ID:Fliper12,项目名称:darkbasicpro,代码行数:18,代码来源:Collision.cpp

示例11: Reflect

D3DXVECTOR3	Reflect(const D3DXVECTOR3* pN,	const D3DXVECTOR3* pD)
{
	D3DXVECTOR3	n	= *pN;
	D3DXVECTOR3	d	= *pD;
	D3DXVec3Normalize( &n, &n );
	float fDot	= D3DXVec3Dot( &n, &(-d) );
	
	return	2*fDot*n + d;
}
开发者ID:serialkk,项目名称:sexyspike3,代码行数:9,代码来源:DEFAULT_INLINE.cpp

示例12: D3DXVec3Normalize

void Camera::UpdateViewMatrix()
{
	D3DXVec3Normalize(&m_look, &m_look);
	D3DXVec3Cross(&m_up, &m_look, &m_right);
	D3DXVec3Normalize(&m_up, &m_up);
	D3DXVec3Cross(&m_right, &m_up, &m_look);
	D3DXVec3Normalize(&m_right, &m_right);

	float x = -D3DXVec3Dot(&m_right, &m_position);
	float y = -D3DXVec3Dot(&m_up, &m_position);
	float z = -D3DXVec3Dot(&m_look, &m_position);

	m_matView = D3DXMATRIX(
		m_right.x, m_up.x, m_look.x, 0.0f,
		m_right.y, m_up.y, m_look.y, 0.0f,
		m_right.z, m_up.z, m_look.z, 0.0f,
		x,         y,      z,        1.0f);
}
开发者ID:tcye,项目名称:DXEngine,代码行数:18,代码来源:Camera.cpp

示例13: D3DXVec3Dot

//////////////////////////////////////////////////////////////////////////
//	setDirection
//	(desc) return rotation matrix to match shadow object's normal to input direction
//	+ helper function
//////////////////////////////////////////////////////////////////////////
rmatrix ZShadow::setDirection( rvector& dir_ )
{
	rmatrix xRotMat;
	rmatrix yRotMat;

	rvector xVector = dir_;
	xVector.y = 0;
	float xtheta = D3DXVec3Dot( &mNormal, &xVector );

	rvector yVector = dir_;
	yVector.x = 0;
	float yTheta = D3DXVec3Dot( &mNormal, &yVector );

	D3DXMatrixRotationX( &xRotMat, xtheta );
	D3DXMatrixRotationY( &yRotMat, yTheta );

	return xRotMat*yRotMat;
}
开发者ID:Kallontz,项目名称:gunz-the-tps-mmorpg,代码行数:23,代码来源:ZShadow.cpp

示例14: mPosition

Camera::Camera(D3DXVECTOR3 position, D3DXVECTOR3 direction, D3DXVECTOR3 worldUp, const Frustum& viewFrustum)
	: mPosition(position), mDirection(direction), mWorldUp(worldUp), mZoom(-200.0f)
{
	mPosition = mPosition - (D3DXVec3Dot(&mPosition, &mWorldUp) * mWorldUp);
	mDestination = mPosition;

	D3DXVec3Normalize(&mDirection, &mDirection);
	CreateProjectionMatrix(viewFrustum);
}
开发者ID:rarosu,项目名称:BTH-Gomoku,代码行数:9,代码来源:Camera.cpp

示例15: RayToTriangle

// funkcja z TFQE
// kod do backface cullingu zakomentowany, lepiej daæ to jako osonn¹ funkcjê
// zwraca ujemn¹ wartoœæ jeœli przecina promieñ od ty³u
bool RayToTriangle(const VEC3& _ray_pos, const VEC3& _ray_dir, const VEC3& _v1, const VEC3& _v2, const VEC3& _v3, float& _dist)
{
	////// Nowy, piêkny algorytm :)
	// Znaleziony w Google Code Search:
	// http://www.google.com/codesearch?hl=en&q=+RayTriangleIntersect+show:M63-4o6bYUI:fUr9QIwtaKY:Dw059DARM5E&sa=N&cd=1&ct=rc&cs_p=http://www.angstrom-distribution.org/unstable/sources/ode-snapshot-20060210.tar.bz2&cs_f=ode-snapshot-20060210/ode/src/collision_trimesh_trimesh.cpp#first
	// Dopisa³em do niego Backface Culling, dzia³a bez problemu :D

	VEC3 tvec, pvec, qvec;

	// find vectors for two edges sharing vert0
	VEC3 edge1 = _v2 - _v1;
	VEC3 edge2 = _v3 - _v1;

	// begin calculating determinant - also used to calculate U parameter
	D3DXVec3Cross(&pvec, &_ray_dir, &edge2);

	// if determinant is near zero, ray lies in plane of triangle
	float det = D3DXVec3Dot(&edge1, &pvec);
	//if (BackfaceCulling && det < 0.0f)
	//	return false;
	if (FLOAT_ALMOST_ZERO(det))
		return false;
	float inv_det = 1.0f / det;

	// calculate distance from vert0 to ray origin
	tvec = _ray_pos - _v1;

	// calculate U parameter and test bounds
	float u = D3DXVec3Dot(&tvec, &pvec) * inv_det;
	if (u < 0.0f || u > 1.0f)
		return false;

	// prepare to test V parameter
	D3DXVec3Cross(&qvec, &tvec, &edge1);

	// calculate V parameter and test bounds
	float v = D3DXVec3Dot(&_ray_dir, &qvec) * inv_det;
	if (v < 0.0f || u + v > 1.0f)
		return false;

	// calculate t, ray intersects triangle
	_dist = D3DXVec3Dot(&edge2, &qvec) * inv_det;
	return true;
}
开发者ID:edeksumo,项目名称:carpg,代码行数:47,代码来源:Base.cpp


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