Reputation: 11
I have a issue with UrhoSharp. I want to load a Indoor Map image with 2D texture. I create a scene with Octree(Urho Class)with Box Shape and it's comes in a 3d view. So, how can I achieve the same in 2D view any suggestion or demo will be so helpful.
Thanks in advance.
Upvotes: 0
Views: 184
Reputation: 26
You can use staticsprite2d to load your 2d texture and view from orthographic camera. Refer https://developer.xamarin.com/api/type/Urho.Urho2D.StaticSprite2D/
//Create sprite image
var floorNode = _scene.CreateChild();
floorNode.Position = new Vector3(0, 0, 0.0f);
StaticSprite2D staticSprite = floorNode.CreateComponent<StaticSprite2D>();
staticSprite.Color = Color.White;
staticSprite.BlendMode = BlendMode.Alpha;
var sprite = ResourceCache.GetSprite2D("floorplan_image.jpg");
staticSprite.Sprite = sprite;
//Create a camera
Node cameraNode = _scene.CreateChild("camera");
var camera = cameraNode.CreateComponent<Camera>();
camera.Orthographic = true;
cameraNode.Position = (new Vector3(0.0f, 0.0f, -10.0f));
camera.OrthoSize = (float)Graphics.Height * PixelSize;
Upvotes: 0