本文整理汇总了C++中Matrix4::SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4::SetPosition方法的具体用法?C++ Matrix4::SetPosition怎么用?C++ Matrix4::SetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4
的用法示例。
在下文中一共展示了Matrix4::SetPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Draw
void Riding::Draw(Renderer & renderer)
{
Vector3 p = renderer.GetBonePosition(modelName, 35);
Matrix4 wandMatrix;
wandMatrix.SetPosition(p + Vector3(0,-1,0)).SetScale(0.01f,0.01f,0.01f);
renderer.Draw3DModel("wand", wandMatrix);
}
示例3: CreateBox
NewtonBody* CPhysics::CreateBox(NewtonWorld *world, CObject3D *object, float x, float y, float z, float mass, Vector3 offset)
{
Matrix4 offsetMat;
offsetMat.SetPosition(offset);
float m[16];
offsetMat.FlattenToArray(m);
NewtonCollision *collision = NewtonCreateBox(world, x, y, z, 0, m);
return CreateRigidBody(world, object, collision, mass);
}
示例4: Simulate
void StarSystemSimulation::Simulate(Entity *simulationParent, float deltaT)
{
base::Simulate(simulationParent, deltaT);
CheckNull(simulationParent);
ObejctState *simulationState = simulationParent->GetSimulationState();
CheckNull(simulationState);
Matrix4 translateToPosition;
translateToPosition.SetIdentityMatrix();
translateToPosition.SetPosition(GGame->GetCamera()->GetPosition());
simulationState->_frame = translateToPosition;
}
示例5: BuildVertexData
void ParticlePool::BuildVertexData()
{
Matrix4 transform = matViewInv;
Matrix3 localRot = transform.GetRotationMatrix();
// 计算顶点法线信息
Vector3f normal = localRot * Vector3f(0.0f, 0.0f, 1.0f);
// 每帧构造新的顶点缓冲,用于渲染
std::vector<Particle>::iterator iter = m_Particles.begin();
for (unsigned int i=0; i<m_ActiveParticleCount; i++, iter++)
{
// 更新顶点颜色
float new_color[16];
for (int j=0; j<4; j++)
memcpy(&(new_color[j*4]), iter->m_Color.GetArray(), sizeof(float) * 4);
m_VertexBuffer->ModifyVertexData(VFormat_Color, 16 * i/*iter->m_VertexOffset*/, sizeof(float) * 16, new_color);
Vector3f points[4] = { Vector3f(-0.5f, 0.5f, 0.0f),
Vector3f(0.5f, 0.5f, 0.0f),
Vector3f(-0.5f, -0.5f, 0.0f),
Vector3f(0.5f, -0.5f, 0.0f) };
float new_pos[12];
float new_normal[12];
// 生成billboard顶点的方向
transform.SetPosition(iter->m_Position);
Matrix3 rotMat = Matrix3::BuildRollRotationMatrix(iter->spin);
for (int j=0; j<4; j++)
{
// 根据缩放等属性计算顶点位置信息
Vector3f point = rotMat * (points[j] * iter->scale);
//point.z = iter->m_ZOffset;
point.x *= iter->m_ScreenScaleX;
point.y *= iter->m_ScreenScaleY;
point = transform * point;
//point += iter->m_Position;
memcpy(&new_pos[j*3], point.GetArray(), sizeof(float) * 3);
memcpy(&new_normal[j*3], normal.GetArray(), sizeof(float) * 3);
}
m_VertexBuffer->ModifyVertexData(VFormat_Position, 12 * i/*iter->m_VertexOffset*/, sizeof(float) * 12, new_pos);
m_VertexBuffer->ModifyVertexData(VFormat_Normal, 12 * i, sizeof(float) * 12, new_normal);
float uv[] = { 0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f };
m_VertexBuffer->ModifyVertexData(VFormat_Texcoord0, 8 * i, sizeof(float) * 8, uv);
}
// 更新索引缓冲数据,处理有效粒子数目变化的情况
m_IndexBuffer->SetIndexSize(m_ActiveParticleCount * 2);
iter = m_Particles.begin();
for (unsigned int i=0; i<m_ActiveParticleCount; i++, iter++)
{
//unsigned int offset = iter->m_IndexOffset;
unsigned int index[6] = { i * 4, 2 + i * 4, 1 + i * 4,
2 + i * 4, 3 + i * 4, 1 + i * 4 };
m_IndexBuffer->ModifyIndexData(6 * i, sizeof(unsigned int) * 6, index);
}
}
示例6: Draw
void StageManager::Draw(Renderer & renderer)
{
if (name == "None")return;
Matrix4 matrix;
renderer.Draw3DModel("stage", matrix.SetPosition(position).SetRotateY(180));
}