这是我第一次使用 urhosharp,我遇到了一些问题。我尝试遵循一些示例示例,但我的应用程序崩溃了。
我安装了 nuget 包 UrhoSharp.Forms
我只想用相机在中间创建一个可以旋转 360 度的场景。
这是我的页面:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Urho;
using Urho.Forms;
using Urho.Resources;
using Urho.Gui;
using Xamarin.Forms;
namespace testApp.Pages.Urho
{
public partial class urhoPage : ContentPage
{
Scene scene;
Camera camera;
protected Node CameraNode { get; set; }
public urhoPage()
{
InitializeComponent();
scene = new Scene();
scene.CreateComponent<Octree>();
scene.CreateComponent<DebugRenderer>();
var planeNode = scene.CreateChild("Plane");
planeNode.Scale = new Vector3(100, 1, 100);
var planeObject = planeNode.CreateComponent<StaticModel>();
// Create a Zone component for ambient lighting & fog control
var zoneNode = scene.CreateChild("Zone");
var zone = zoneNode.CreateComponent<Zone>();
// Set same volume as the Octree, set a close bluish fog and some ambient light
zone.SetBoundingBox(new BoundingBox(-1000.0f, 1000.0f));
zone.AmbientColor = new Urho.Color(0.15f, 0.15f, 0.15f);
zone.FogColor = new Urho.Color(0.5f, 0.5f, 0.7f);
zone.FogStart = 100;
zone.FogEnd = 300;
// Create the camera. Limit far clip distance to match the fog
CameraNode = scene.CreateChild("Camera");
camera = CameraNode.CreateComponent<Camera>();
camera.FarClip = 300;
// Set an initial position for the camera scene node above the plane
CameraNode.Position = new Vector3(0.0f, 5.0f, 0.0f);
// var renderer = Renderer;
//renderer.SetViewport(0, new Viewport(Context, scene, camera, null));
}
}
}
当我遇到错误时,我不得不删除这 2 行。未设置渲染器和上下文。我是从不使用页面的功能样本中得到的
// var 渲染器 = 渲染器;//renderer.SetViewport(0, new Viewport(Context, scene, camera, null));