本文整理汇总了C++中Matrix4::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::GetPosition方法的具体用法?C++ Matrix4::GetPosition怎么用?C++ Matrix4::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::GetPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DropDownBox
//////////////////////////////////////////////////////////////////////////
// Position the body precisely
//////////////////////////////////////////////////////////////////////////
void DropDownBox(NewtonBody *body)
{
float matrix[16];
NewtonBodyGetMatrix(body, matrix);
Matrix4 m = Matrix4(matrix);
Vector3 pos = m.GetPosition();
pos.y += 1.0f;
m.SetPosition(pos);
Vector3 p = pos;
p.y -= 20;
// cast collision shape within +20 -20 y range
NewtonWorld *world = NewtonBodyGetWorld(body);
NewtonCollision *collision = NewtonBodyGetCollision(body);
float param;
NewtonWorldConvexCastReturnInfo info[16];
m.FlattenToArray(matrix);
NewtonWorldConvexCast(world, matrix, &p[0], collision, ¶m, body, DropDownConvexCastCallback, info, 16, 0);
m = Matrix4(matrix);
pos = m.GetPosition();
m.SetPosition(pos + Vector3(0, (p.y - pos.y) * param, 0) );
m.FlattenToArray(matrix);
NewtonBodySetMatrix(body, matrix);
}
示例2: TransformCallback
void CPhysics::TransformCallback(const NewtonBody* body, const float* matrix, int threadIndex)
{
CObject3D *object = (CObject3D*)NewtonBodyGetUserData(body);
float m[16];
NewtonBodyGetMatrix(body, m);
Matrix4 M = Matrix4(m);
Vector3 destination = M.GetPosition();
Vector3 velocity = (destination - object->GetWorldPosition()) * object->physicsDelay;
object->velocity = velocity;
Vector3 pos = object->position;
object->SetMatrix( Matrix4(m) );
object->SetPosition(pos);
// setting entire matrix each physics frame might cause desync with the renderer,
// that might run more often, resulting in drawing the object in the same location
// twice in a row
// Instead each physics frame we set the object's velocity so that it reaches
// the desginated position in 1/10th of a second
}