我正在使用xamarim的urhosharp游戏引擎来开发一个跨平台的游戏....这是非常好的选择并与WPF兼容,但我不知道如何绘制形状,我浏览了指南和文档而没有找到一种方法可能画圆圈,圆角形状,环形或任何人都知道或可以帮助我的几何类型。我将非常感激。
提前致谢
我尝试了这段代码,但屏幕上没有出现任何圆圈:
DebugRenderer debug = new DebugRenderer();
debug.AddCircle(new Vector3(50,50,0),new Vector3(100,25,0),50,Color.Magenta,2 ,true );
for (int i = 0; i < 512; ++i)
{
var start = new Vector3(i, 0, 0);
var end = new Vector3(i, 100, 0);
debug.AddLine(start, end, Color.White, false);
debug.AddCircle(start, end, 50f, Color.Red, i, false);
}
scene.AddComponent(debug);
答案 0 :(得分:2)
只是要注意DebugRenderRender用于调试目的。如果你想使DebugRenderer工作,你需要订阅PostRenderUpdate,如下所示:
Engine.SubscribeToPostRenderUpdate(args => YourMethodHandler);
通常您会在设置中执行此操作。然后YourMethodHandler就像:
protected void YourMethodHandler()
{
// this requires that you have already added a DebugRenderer
// component in your scene object
var debugRenderer = scene.GetComponent<DebugRenderer>();
if (debugRenderer != null)
{
// do your drawing code here
// to draw a rectangle for example:
var upperBound = new Vector3(-4.0f, 2.0f, 0.0f);
var lowerBound = new Vector3(4.0f, -2.0f, 0.0f);
debugRenderer.AddBoundingBox(
new BoundingBox(upperBound, lowerBound),
Color.White,
false);
}
}
答案 1 :(得分:0)
更确切地说,它只有在这样实现时才有效:
var dr = app.Scene.GetOrCreateComponent<DebugRenderer>();
app.Engine.PostRenderUpdate += (arg4) => {
app.Renderer.DrawDebugGeometry(false);
};
app.Renderer.BeginViewRender += (arg5) => {
dr.AddBoundingBox(new BoundingBox(-1000, 1000), Color.Blue);
dr.LineAntiAlias = true;
dr.AddTriangle(new Vector3(2,0,0), new Vector3(2,1,0), new Vector3(2,0,1), Color.Magenta, false);
dr.AddCircle(new Vector3(2,0,0), new Vector3(1,1,1), 5.0f, Color.Red);
};