本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Model.GetVerticesAndIndices方法的典型用法代码示例。如果您正苦于以下问题:C# Model.GetVerticesAndIndices方法的具体用法?C# Model.GetVerticesAndIndices怎么用?C# Model.GetVerticesAndIndices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.Model
的用法示例。
在下文中一共展示了Model.GetVerticesAndIndices方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BoxModelPhysics
/// <summary>
/// Create box model physics.
/// </summary>
/// <param name="game">The game.</param>
/// <param name="model">The visual model.</param>
/// <param name="position">The position of the box entity.</param>
/// <param name="mass">The physics mass.</param>
public BoxModelPhysics(XiGame game, Model model, Vector3 position, float mass)
{
this.game = game;
Vector3[] vertices;
int[] indices;
model.GetVerticesAndIndices(out vertices, out indices);
BoundingBox boundingBox = BoundingBox.CreateFromPoints(vertices);
body = new BEPUphysics.Entities.Box(
position,
Math.Max(Math.Abs(boundingBox.Max.X), Math.Abs(boundingBox.Min.X)) * 2,
Math.Max(Math.Abs(boundingBox.Max.Y), Math.Abs(boundingBox.Min.Y)) * 2,
Math.Max(Math.Abs(boundingBox.Max.Z), Math.Abs(boundingBox.Min.Z)) * 2,
mass);
/*
this alternative method does not work and I don't know why -
Box box = new Box(
(boundingBox.Max + boundingBox.Min) * 0.5f,
boundingBox.Max.X - boundingBox.Min.X,
boundingBox.Max.Y - boundingBox.Min.Y,
boundingBox.Max.Z - boundingBox.Min.Z,
Mass);
body = new CompoundBody();
body.addBody(box);
*/
}
示例2: StaticMeshModelPhysics
/// <summary>
/// Create sphere model physics.
/// </summary>
/// <param name="game">The game.</param>
/// <param name="model">The visual model.</param>
/// <param name="position">The position of the static mesh entity.</param>
/// <param name="mass">The physics mass.</param>
public StaticMeshModelPhysics(XiGame game, Model model, Vector3 position, float mass)
{
this.game = game;
StaticTriangleGroup.StaticTriangleGroupVertex[] vertices;
int[] indices;
model.GetVerticesAndIndices(out vertices, out indices);
TriangleMesh triangleMesh = new TriangleMesh(vertices, indices);
staticTriangleGroup = new StaticTriangleGroup(triangleMesh);
}
示例3: SphereModelPhysics
/// <summary>
/// Create sphere model physics.
/// </summary>
/// <param name="game">The game.</param>
/// <param name="model">The visual model.</param>
/// <param name="position">The position of the sphere entity.</param>
/// <param name="mass">The physics mass.</param>
public SphereModelPhysics(XiGame game, Model model, Vector3 position, float mass)
{
this.game = game;
Vector3[] vertices;
int[] indices;
model.GetVerticesAndIndices(out vertices, out indices);
BoundingSphere boundingSphere = BoundingSphere.CreateFromPoints(vertices);
body = new Sphere(position, boundingSphere.Radius, mass);
}
示例4: CapsuleModelPhysics
/// <summary>
/// Create capsule model physics.
/// </summary>
/// <param name="game">The game.</param>
/// <param name="model">The visual model.</param>
/// <param name="position">The position of the sphere entity.</param>
/// <param name="mass">The physics mass.</param>
public CapsuleModelPhysics(XiGame game, Model model, Vector3 position, float mass)
{
this.game = game;
Vector3[] vertices;
int[] indices;
model.GetVerticesAndIndices(out vertices, out indices);
BoundingSphere boundingSphere = BoundingSphere.CreateFromPoints(vertices);
body = new Capsule(position, boundingSphere.Radius, boundingSphere.Radius * 0.5f, mass);
game.SceneSpace.Add(body);
}