本文整理汇总了C++中Matrix::CreateRotationMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::CreateRotationMatrix方法的具体用法?C++ Matrix::CreateRotationMatrix怎么用?C++ Matrix::CreateRotationMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::CreateRotationMatrix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCollision
bool CollisionVolume::testCollision(const VC3 &objectPosition, const VC3 &angles, CollisionData &collisionData, float epsilon)
{
QUAT rotation = getRotation(angles);
//rotation.MakeFromAngles(0, -yRotation, 0);
Matrix tm;
tm.CreateRotationMatrix(rotation);
// Everything's relative etc
VC3 rayOrigin = tm.GetTransformedVector(collisionData.rayOrigin - objectPosition) + objectPosition;
VC3 rayDirection = tm.GetWithoutTranslation().GetTransformedVector(collisionData.rayDirection);
if(!data->possibleCollision(objectPosition, collisionData))
return false;
if(!data->accurateCollision(objectPosition, collisionData, rayOrigin, rayDirection))
return false;
float collisionDistance = objectPosition.GetRangeTo(collisionData.rayOrigin);
VC3 pos = tm.GetInverse().GetTransformedVector(collisionData.collisionPosition - objectPosition) + objectPosition;
if(collisionData.hasCollision)
if(collisionDistance > pos.GetRangeTo(collisionData.rayOrigin))
return false;
collisionData.rayLength = collisionDistance;
collisionData.hasCollision = true;
collisionData.collisionPosition = objectPosition;
collisionData.objectData = data->data;
return true;
}
示例2: init
void PointArrayParticleSystem::init(IStorm3D* s3d, IStorm3D_Scene* scene)
{
defaultInit(s3d, scene, *m_eds);
std::string fileName = m_eds->modelFile;
if(fileName.empty())
return;
Matrix sm;
Matrix rm;
QUAT q;
q.MakeFromAngles(m_eds->rotation.x, m_eds->rotation.y, m_eds->rotation.z);
rm.CreateRotationMatrix(q);
sm.CreateScaleMatrix(m_eds->scale);
sm.Multiply(rm);
IStorm3D_Model* model = s3d->CreateNewModel();
assert(model != NULL);
if(model->LoadS3D(fileName.c_str()))
{
Iterator<IStorm3D_Model_Object*>* obj = model->ITObject->Begin();
assert(obj != NULL);
boost::shared_ptr<PointArray> pm(new PointArray());
for(; !obj->IsEnd(); obj->Next())
{
IStorm3D_Mesh* mesh = obj->GetCurrent()->GetMesh();
VC3 opos = obj->GetCurrent()->GetPosition();
if(mesh)
{
int base = pm->verts.size();
pm->verts.resize(base + mesh->GetVertexCount());
pm->normals.resize(base + mesh->GetVertexCount());
Storm3D_Vertex *v = mesh->GetVertexBuffer();
for(int i = 0; i < mesh->GetVertexCount(); i++)
{
Vector pos = v[i].position + opos;
Vector nor = v[i].normal;
sm.TransformVector(pos);
rm.RotateVector(nor);
pm->verts[base + i] = pos;
pm->normals[base + i] = nor;
}
}
}
m_parray.swap(pm);
if(m_eds->firstVertex < 0)
m_eds->firstVertex = 0;
if(m_eds->lastVertex >= (int)m_parray->verts.size())
m_eds->lastVertex = m_parray->verts.size()-1;
delete obj;
}
delete model;
}
示例3:
/*!
\param position bone position
\param rotation bone rotation
\param model_position parent model position
\param model_rotation parent model rotation
*/
void Storm3D_Bone::SetOriginalProperties(const Vector &position, const Rotation &rotation, const Vector &model_position, const Rotation &model_rotation)
{
this->position = position;
this->rotation = rotation;
// We need original orientations inverse to create vertex tm
Matrix r;
r.CreateRotationMatrix(model_rotation);
Matrix t;
t.CreateTranslationMatrix(model_position);
original_inverse_tm = r * t;
original_inverse_tm.Inverse();
}