本文整理汇总了C++中D3DXVec3Cross函数的典型用法代码示例。如果您正苦于以下问题:C++ D3DXVec3Cross函数的具体用法?C++ D3DXVec3Cross怎么用?C++ D3DXVec3Cross使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D3DXVec3Cross函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: D3DXVec3Normalize
void Camera::lookAt(D3DXVECTOR3& pos, D3DXVECTOR3& target, D3DXVECTOR3& up)
{
D3DXVECTOR3 L = target - pos;
D3DXVec3Normalize(&L, &L);
D3DXVECTOR3 R;
D3DXVec3Cross(&R, &up, &L);
D3DXVec3Normalize(&R, &R);
D3DXVECTOR3 U;
D3DXVec3Cross(&U, &L, &R);
D3DXVec3Normalize(&U, &U);
m_posW = pos;
m_rightW = R;
m_upW = U;
m_lookW = L;
buildView();
buildFrustumPlanes();
m_viewProj = m_view * m_proj;
}
示例2: assert
void Geometry::setMesh(engine::Mesh* mesh)
{
assert( mesh->numVertices == _numVertices );
assert( mesh->numTriangles == _numTriangles );
assert( mesh->numUVs == _numUVSets );
unsigned int i,j;
for( i=0; i<_numVertices; i++ )
{
_vertices[i] = wrap( mesh->vertices[i] );
}
for( i=0; i<_numUVSets; i++ )
{
for( j=0; j<_numVertices; j++ )
{
_uvs[i][j] = wrap( mesh->uvs[i][j] );
}
}
for( i=0; i<_numTriangles; i++ )
{
_triangles[i].set(
mesh->triangles[i].vertexId[0],
mesh->triangles[i].vertexId[1],
mesh->triangles[i].vertexId[2],
mesh->triangles[i].shaderId
);
}
// calculate per-triangle normals
Vector e01, e02, n;
for( i=0; i<_numTriangles; i++ )
{
D3DXVec3Subtract(
&e01,
_vertices + mesh->triangles[i].vertexId[1],
_vertices + mesh->triangles[i].vertexId[0]
);
D3DXVec3Subtract(
&e02,
_vertices + mesh->triangles[i].vertexId[2],
_vertices + mesh->triangles[i].vertexId[0]
);
D3DXVec3Cross( &n, &e02, &e01 );
D3DXVec3Normalize( &n, &n );
_normals[mesh->triangles[i].vertexId[0]] = n;
_normals[mesh->triangles[i].vertexId[1]] = n;
_normals[mesh->triangles[i].vertexId[2]] = n;
}
instance();
}
示例3: D3DXVec3Normalize
void CamerClass::GetViewMatrix(D3DXMATRIX* V)
{
//保持view局部坐标系,各自轴的彼此正交
D3DXVec3Normalize(&_look, &_look);
//look X right
D3DXVec3Cross(&_up, &_look, &_right);
D3DXVec3Normalize(&_up, &_up);
D3DXVec3Cross(&_right, &_up, &_look);
D3DXVec3Normalize(&_right, &_right);
// 生成view矩阵:
float x = -D3DXVec3Dot(&_right, &_pos);
float y = -D3DXVec3Dot(&_up, &_pos);
float z = -D3DXVec3Dot(&_look, &_pos);
(*V)(0,0) = _right.x; (*V)(0, 1) = _up.x; (*V)(0, 2) = _look.x; (*V)(0, 3) = 0.0f;
(*V)(1,0) = _right.y; (*V)(1, 1) = _up.y; (*V)(1, 2) = _look.y; (*V)(1, 3) = 0.0f;
(*V)(2,0) = _right.z; (*V)(2, 1) = _up.z; (*V)(2, 2) = _look.z; (*V)(2, 3) = 0.0f;
(*V)(3,0) = x; (*V)(3, 1) = y; (*V)(3, 2) = z; (*V)(3, 3) = 1.0f;
return;
}
示例4: D3DXVec3Normalize
void Camera::buildView()
{
// Keep camera's axes orthogonal to each other and of unit length.
D3DXVec3Normalize(&mLookW, &mLookW);
D3DXVec3Cross(&mUpW, &mLookW, &mRightW);
D3DXVec3Normalize(&mUpW, &mUpW);
D3DXVec3Cross(&mRightW, &mUpW, &mLookW);
D3DXVec3Normalize(&mRightW, &mRightW);
// Fill in the view matrix entries.
float x = -D3DXVec3Dot(&mPosW, &mRightW);
float y = -D3DXVec3Dot(&mPosW, &mUpW);
float z = -D3DXVec3Dot(&mPosW, &mLookW);
mView(0,0) = mRightW.x;
mView(1,0) = mRightW.y;
mView(2,0) = mRightW.z;
mView(3,0) = x;
mView(0,1) = mUpW.x;
mView(1,1) = mUpW.y;
mView(2,1) = mUpW.z;
mView(3,1) = y;
mView(0,2) = mLookW.x;
mView(1,2) = mLookW.y;
mView(2,2) = mLookW.z;
mView(3,2) = z;
mView(0,3) = 0.0f;
mView(1,3) = 0.0f;
mView(2,3) = 0.0f;
mView(3,3) = 1.0f;
}
示例5: D3DXVec3Cross
bool CPicking::CollisionCheckTriangle(D3DXVECTOR3 &PickPos, RAY &_ray, D3DXVECTOR3 &_v0, D3DXVECTOR3 &_v1, D3DXVECTOR3 &_v2)
{
float t,u,v;
t = u = v = 0.0f;
D3DXVECTOR3 v_edge1 = _v1 - _v0;
D3DXVECTOR3 v_edge2 = _v2 - _v0;
D3DXVECTOR3 tvec, pvec, qvec;
float det, inv_det;
D3DXVec3Cross(&pvec, &_ray.direction, &v_edge2);
det = D3DXVec3Dot(&v_edge1, &pvec);
if(det > -0.0001f && det < 0.0001f) return false;
inv_det = 1.0f / det;
tvec = _ray.origin - _v0;
u = D3DXVec3Dot(&tvec, &pvec) * inv_det;
if(u < 0.0001f || u > 1.0001f) return false;
D3DXVec3Cross(&qvec, &tvec, &v_edge1);
v = D3DXVec3Dot(&_ray.direction, &qvec) * inv_det;
if(v < 0.0001f || (u+v) > 1.0001f ) return false;
_ray.fT = D3DXVec3Dot(&v_edge2, &qvec) * inv_det;
if(_ray.fT <= 0) return false;
PickPos = _v0 + (u * (_v1 - _v0)) + (v * (_v2 - _v0));
return true;
}
示例6: D3DXVec3Normalize
void Camera::BuildViewMatrix()
{
// Keep camera's axes orthogonal to each other and of unit length.
D3DXVec3Normalize(&m_vForward, &m_vForward);
D3DXVec3Cross(&m_vUp, &m_vForward, &m_vRight);
D3DXVec3Normalize(&m_vUp, &m_vUp);
D3DXVec3Cross(&m_vRight, &m_vUp, &m_vForward);
D3DXVec3Normalize(&m_vRight, &m_vRight);
// Fill in the view matrix entries.
float x = -D3DXVec3Dot(&m_vEyePoint, &m_vRight);
float y = -D3DXVec3Dot(&m_vEyePoint, &m_vUp);
float z = -D3DXVec3Dot(&m_vEyePoint, &m_vForward);
m_matView(0,0) = m_vRight.x;
m_matView(1,0) = m_vRight.y;
m_matView(2,0) = m_vRight.z;
m_matView(3,0) = x;
m_matView(0,1) = m_vUp.x;
m_matView(1,1) = m_vUp.y;
m_matView(2,1) = m_vUp.z;
m_matView(3,1) = y;
m_matView(0,2) = m_vForward.x;
m_matView(1,2) = m_vForward.y;
m_matView(2,2) = m_vForward.z;
m_matView(3,2) = z;
m_matView(0,3) = 0.0f;
m_matView(1,3) = 0.0f;
m_matView(2,3) = 0.0f;
m_matView(3,3) = 1.0f;
}
示例7: D3DXVec3Cross
void AVCamera::walk(float units)
{
if( units == 0 ) return;
if(m_type == CAMERA_TYPE_LANDOBJECT)
{
D3DXVECTOR3 dir;
D3DXVec3Cross(&dir, &m_right, &D3DXVECTOR3(0,1,0));
m_pos += D3DXVECTOR3(dir.x, 0.f, dir.z) * units;
}
//type == air
else
m_pos += m_look * units;
}
示例8: D3DXVec3Dot
D3DXQUATERNION ArcBall::QuatFromBallPoints(D3DXVECTOR3& start_point, D3DXVECTOR3& end_point)
{
// Calculate rotate angle
float angle = D3DXVec3Dot(&start_point, &end_point);
// Calculate rotate axis
D3DXVECTOR3 axis;
D3DXVec3Cross(&axis, &start_point, &end_point);
// Build and Normalize the Quaternion
D3DXQUATERNION quat(axis.x, axis.y, axis.z, angle);
D3DXQuaternionNormalize(&quat, &quat);
return quat;
}
示例9: D3DXVec3Normalize
void Camera::lookAt(const D3DXVECTOR3 &eye, const D3DXVECTOR3 &target, const D3DXVECTOR3 &up)
{
m_eye = eye;
m_zAxis = target - eye;
D3DXVec3Normalize(&m_zAxis, &m_zAxis);
m_viewDir = m_zAxis;
D3DXVec3Cross(&m_xAxis, &up, &m_zAxis);
D3DXVec3Normalize(&m_xAxis, &m_xAxis);
D3DXVec3Cross(&m_yAxis, &m_zAxis, &m_xAxis);
D3DXVec3Normalize(&m_yAxis, &m_yAxis);
D3DXVec3Normalize(&m_xAxis, &m_xAxis);
D3DXMatrixIdentity(&m_viewMatrix);
m_viewMatrix(0,0) = m_xAxis.x;
m_viewMatrix(1,0) = m_xAxis.y;
m_viewMatrix(2,0) = m_xAxis.z;
m_viewMatrix(3,0) = -D3DXVec3Dot(&m_xAxis, &eye);
m_viewMatrix(0,1) = m_yAxis.x;
m_viewMatrix(1,1) = m_yAxis.y;
m_viewMatrix(2,1) = m_yAxis.z;
m_viewMatrix(3,1) = -D3DXVec3Dot(&m_yAxis, &eye);
m_viewMatrix(0,2) = m_zAxis.x;
m_viewMatrix(1,2) = m_zAxis.y;
m_viewMatrix(2,2) = m_zAxis.z;
m_viewMatrix(3,2) = -D3DXVec3Dot(&m_zAxis, &eye);
// Extract the pitch angle from the view matrix.
m_accumPitchDegrees = D3DXToDegree(-asinf(m_viewMatrix(1,2)));
}
示例10: D3DXMatrixRotationYawPitchRoll
void Camera::UpdateView()
{
D3DXMatrixRotationYawPitchRoll(&rotationMatrix, yaw, pitch, 0);
D3DXVec3TransformCoord(&view, &v, &rotationMatrix);
D3DXVec3TransformCoord(&up, &u, &rotationMatrix);
D3DXVec3Normalize(&forward, &view);
D3DXVec3Cross(&right, &up, &view);
D3DXVec3Normalize(&right, &right);
view = eye + view;
D3DXMatrixLookAtLH(&viewMatrix, &eye, &view, &up);
}
示例11: D3DXMatrixRotationYawPitchRoll
void Camera::updateView(float dt)
{
//rotation
D3DXMatrixRotationYawPitchRoll(&rotationMatrix, heading, pitch, 0);
D3DXVec3TransformCoord(&view,&dV,&rotationMatrix);
D3DXVec3TransformCoord(&up,&dU,&rotationMatrix);
D3DXVec3Normalize(&forward,&view);
D3DXVec3Cross(&strafeRight,&up,&view);
D3DXVec3Normalize(&strafeRight,&strafeRight);
view = eye + view;
D3DXMatrixLookAtLH(&viewMatrix,&eye,&view,&up);
}
示例12: D3DXVec3Normalize
void CCameraKernel::CalculateViewMatrix(D3DXMATRIX *pMatrix)
{
//规范化三个向量使之成为正交矩阵
//规范化观察向量
D3DXVec3Normalize(&m_vLookVector, &m_vLookVector);
//使上向量与观察向量垂直
D3DXVec3Cross(&m_vUpVector, &m_vLookVector, &m_vRightVector);
//规范化上向量
D3DXVec3Normalize(&m_vUpVector, &m_vUpVector);
//右向量与上向量垂直
D3DXVec3Cross(&m_vRightVector, &m_vUpVector, &m_vLookVector);
//规范化右向量
D3DXVec3Normalize(&m_vRightVector, &m_vRightVector);
//创建取景变换矩阵
pMatrix->_11 = m_vRightVector.x;
pMatrix->_12 = m_vUpVector.x;
pMatrix->_13 = m_vLookVector.x;
pMatrix->_14 = 0.0f;
pMatrix->_21 = m_vRightVector.y;
pMatrix->_22 = m_vUpVector.y;
pMatrix->_23 = m_vLookVector.y;
pMatrix->_24 = 0.0f;
pMatrix->_31 = m_vRightVector.z;
pMatrix->_32 = m_vUpVector.z;
pMatrix->_33 = m_vLookVector.z;
pMatrix->_34 = 0.0f;
pMatrix->_41 = -D3DXVec3Dot(&m_vRightVector, &m_vCameraPosition);
pMatrix->_42 = -D3DXVec3Dot(&m_vUpVector, &m_vCameraPosition);
pMatrix->_43 = -D3DXVec3Dot(&m_vLookVector, &m_vCameraPosition);
pMatrix->_44 = 1.0f;
}
示例13: D3DXVec3Dot
bool U2IntectRayBox3D::Test()
{
float aWdU[3], aAWdU[3], aDdU[3], aADdU[3], aAWxDdU[3], fRhs;
D3DXVECTOR3 diff = m_pRay->m_vOrigin - m_pBox->m_vCenter;
aWdU[0] = D3DXVec3Dot(&m_pRay->m_vDir, &m_pBox->m_avAxis[0]);
aAWdU[0] = U2Math::FAbs(aWdU[0]);
aDdU[0] = D3DXVec3Dot(&diff, &m_pBox->m_avAxis[0]);
aADdU[0] = U2Math::FAbs(aDdU[0]);
if(aADdU[0] > m_pBox->m_afExtent[0] && aDdU[0] * aWdU[0] >= 0.f)
return false;
aWdU[1] = D3DXVec3Dot(&m_pRay->m_vDir, &m_pBox->m_avAxis[1]);
aAWdU[1] = U2Math::FAbs(aWdU[1]);
aDdU[1] = D3DXVec3Dot(&diff, &m_pBox->m_avAxis[1]);
aADdU[1] = U2Math::FAbs(aDdU[1]);
if(aADdU[1] > m_pBox->m_afExtent[1] && aDdU[1] * aWdU[1] >= 0.f)
return false;
aWdU[2] = D3DXVec3Dot(&m_pRay->m_vDir, &m_pBox->m_avAxis[2]);
aAWdU[2] = U2Math::FAbs(aWdU[2]);
aDdU[2] = D3DXVec3Dot(&diff, &m_pBox->m_avAxis[2]);
aADdU[2] = U2Math::FAbs(aDdU[2]);
if(aADdU[2] > m_pBox->m_afExtent[2] && aDdU[2] * aWdU[2] >= 0.f)
return false;
D3DXVECTOR3 WxD;
D3DXVec3Cross(&WxD, &m_pRay->m_vDir, &diff);
aAWxDdU[0] = U2Math::FAbs(D3DXVec3Dot(&WxD, &m_pBox->m_avAxis[0]));
fRhs = m_pBox->m_afExtent[1] *aAWdU[2] + m_pBox->m_afExtent[2]*aAWdU[1];
if(aAWxDdU[0] > fRhs)
return false;
aAWxDdU[1] = U2Math::FAbs(D3DXVec3Dot(&WxD, &m_pBox->m_avAxis[1]));
fRhs = m_pBox->m_afExtent[0] *aAWdU[2] + m_pBox->m_afExtent[2]*aAWdU[0];
if(aAWxDdU[1] > fRhs)
return false;
aAWxDdU[2] = U2Math::FAbs(D3DXVec3Dot(&WxD, &m_pBox->m_avAxis[2]));
fRhs = m_pBox->m_afExtent[0] *aAWdU[1] + m_pBox->m_afExtent[1]*aAWdU[0];
if(aAWxDdU[2] > fRhs)
return false;
return true;
}
示例14: wrap
OcTreeSector* RayIntersection::collideBSPOcTreeSector(OcTreeSector* ocTreeSector)
{
if( ocTreeSector->_triangles.size() )
{
// collide octree sector triangles
Triangle* triangle;
Vector v0v1, v0v2, n;
Vector hitPoint;
for( unsigned int i=0; i<ocTreeSector->_triangles.size(); i++ )
{
triangle = _triangles + ocTreeSector->_triangles[i];
if( ::intersectionRayTriangle(
&_ray,
_vertices + triangle->vertexId[0],
_vertices + triangle->vertexId[1],
_vertices + triangle->vertexId[2],
&hitPoint,
&_collisionTriangle.distance
))
{
_collisionTriangle.vertices[0] = wrap( _vertices[triangle->vertexId[0]] );
_collisionTriangle.vertices[1] = wrap( _vertices[triangle->vertexId[1]] );
_collisionTriangle.vertices[2] = wrap( _vertices[triangle->vertexId[2]] );
v0v1 = _vertices[triangle->vertexId[1]] - _vertices[triangle->vertexId[0]];
v0v2 = _vertices[triangle->vertexId[2]] - _vertices[triangle->vertexId[0]];
D3DXVec3Cross( &n, &v0v1, &v0v2 );
D3DXVec3Normalize( &n, &n );
_collisionTriangle.normal = wrap( n );
_collisionTriangle.collisionPoint = wrap( hitPoint );
_collisionTriangle.shader = _geometry->shader( triangle->shaderId );
_collisionTriangle.triangleId = ocTreeSector->_triangles[i];
if( !_callBack( &_collisionTriangle, _bspSector, NULL, _callBackData ) ) return NULL;
return ocTreeSector;
}
}
}
else if( ocTreeSector->_subtree[0] )
{
for( unsigned int i=0; i<8; i++ )
{
if( intersectionRayAABB( &_ray, &ocTreeSector->_subtree[i]->_boundingBox ) )
{
if( !collideBSPOcTreeSector( ocTreeSector->_subtree[i] ) ) return NULL;
}
}
}
return ocTreeSector;
}
示例15: D3DXVec3Normalize
/// 카메라 행렬을 생성하기위한 기본 벡터값들을 설정한다.
D3DXMATRIXA16* ZCamera::SetView( D3DXVECTOR3* pvEye,D3DXVECTOR3* pvLookat,D3DXVECTOR3* pvUp)
{
m_vEye = *pvEye;
m_vLookat = *pvLookat;
m_vUp = *pvUp;
D3DXVec3Normalize( &m_vView, &( m_vLookat - m_vEye ) );
D3DXVec3Cross( &m_vCross, &m_vUp, &m_vView );
D3DXMatrixLookAtLH( &m_matView, &m_vEye, &m_vLookat, &m_vUp);
D3DXMatrixInverse( &m_matBill, NULL, &m_matView );
m_matBill._41 = 0.0f;
m_matBill._42 = 0.0f;
m_matBill._43 = 0.0f;
return &m_matView;
}