0
這是我第一次使用urhosharp,我有一些問題。我嘗試了一些示例示例,但我的應用崩潰了。Xamarin Forms - Urho - 創建場景網頁
我安裝了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 = Renderer; //renderer.SetViewport(0,new Viewport(Context,scene,camera,null));