0

正在使用 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);
4

2 回答 2

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);
    }
}
于 2016-08-04T12:07:07.450 回答
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);
};
于 2018-06-02T15:35:29.373 回答