本文整理汇总了C#中IVehicle.ToMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# IVehicle.ToMatrix方法的具体用法?C# IVehicle.ToMatrix怎么用?C# IVehicle.ToMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVehicle
的用法示例。
在下文中一共展示了IVehicle.ToMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBasic2dCircularVehicle
// a simple 2d vehicle on the XZ plane
public static void DrawBasic2dCircularVehicle(IVehicle vehicle, Color color)
{
// "aspect ratio" of body (as seen from above)
const float X = 0.5f;
float y = (float)Math.Sqrt(1 - (X * X));
// radius and position of vehicle
float r = vehicle.Radius;
Vector3 p = vehicle.Position;
// shape of triangular body
Vector3 u = new Vector3(0, 1, 0) * r * 0.05f; // slightly up
Vector3 f = Vector3.UnitZ * r;
Vector3 s = Vector3.UnitX * X * r;
Vector3 b = Vector3.UnitZ * -y * r;
var matrix = vehicle.ToMatrix();
// draw double-sided triangle (that is: no (back) face culling)
BeginDoubleSidedDrawing();
iDrawTriangle(Vector3.Transform(f + u, matrix),
Vector3.Transform(b - s + u, matrix),
Vector3.Transform(b + s + u, matrix),
color);
EndDoubleSidedDrawing();
// draw the circular collision boundary
DrawXZCircle(r, p + u, Color.White, 20);
}