本文整理汇总了C#中RigidBody.GetWorldMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# RigidBody.GetWorldMatrix方法的具体用法?C# RigidBody.GetWorldMatrix怎么用?C# RigidBody.GetWorldMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RigidBody
的用法示例。
在下文中一共展示了RigidBody.GetWorldMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBody
/// <summary>
/// Draw wireframe/solid of any of the RigidBody.Shape primitives, except
/// TerrainShape... for now.
/// </summary>
/// <param name="body">body to draw</param>
/// <param name="color">Color to bias wireframe/solid towards</param>
/// <param name="drawSolid">True: draw solid, False: draw wireframe</param>
/// <param name="enableLightning">enable the default lightning</param>
public void DrawBody(RigidBody body, Color color, bool drawSolid, bool enableLightning)
{
GeometricPrimitive primitive = null;
Matrix scaleMatrix;
#region decide scale and shape
Shape shape = body.Shape;
if (shape is BoxShape)
{
primitive = Primitives.Box;
scaleMatrix = Matrix.CreateScale(Conversion.ToXNAVector((shape as BoxShape).Size));
}
else if (shape is SphereShape)
{
primitive = Primitives.Sphere;
scaleMatrix = Matrix.CreateScale((shape as SphereShape).Radius);
}
else if (shape is CylinderShape)
{
primitive = Primitives.Cylinder;
CylinderShape cs = shape as CylinderShape;
scaleMatrix = Matrix.CreateScale(cs.Radius, cs.Height, cs.Radius);
}
else if (shape is CapsuleShape)
{
CapsuleShape cs = shape as CapsuleShape;
primitive = CapsulePrimitive.GetCapsulePrimitive(
BasicEffect.GraphicsDevice, cs.Radius * 2, cs.Length, 6);
scaleMatrix = Matrix.Identity;
}
else if (shape is ConeShape)
{
primitive = Primitives.Cone;
ConeShape cs = shape as ConeShape;
scaleMatrix = Matrix.CreateScale(cs.Radius, cs.Height, cs.Radius);
}
else
{
throw new ArgumentException("Unable to draw given body (is it a TerrainShape?");
}
#endregion
BasicEffect.World = scaleMatrix * body.GetWorldMatrix();
BasicEffect.DiffuseColor = color.ToVector3();
BasicEffect.LightingEnabled = enableLightning;
if (drawSolid)
{
primitive.DrawSolid(BasicEffect);
}
else
{
primitive.DrawWireFrame(BasicEffect);
}
}
示例2: DrawModel
public void DrawModel(Model model, RigidBody body, Matrix scale)
{
engine.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
//effect.DiffuseColor = color.ToVector3();
setupLightning(effect);
effect.World = mesh.ParentBone.Transform*scale*body.GetWorldMatrix();
effect.View = engine.Camera.View;
effect.Projection = engine.Camera.Projection;
}
mesh.Draw();
}
}