0

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.

1 Answers1

0

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;
tobi3245
  • 26
  • 2
  • Thanks Tobi for your answer. Actually, I am using material to load the Image. – Puneet Mahali Sep 11 '18 at 07:40
  • Thanks Tobi for your answer.Actually, I am using material to load the Image. var plane = baseNode.CreateComponent(); plane.Model = CoreAssets.Models.Plane; var imageUrl = "here Image url"; var wc = new WebClient() { Encoding = Encoding.UTF8 }; var img = new Image(Context) { Name = "MyTextureImage" }; img.Load(new MemoryBuffer(wc.DownloadData(imageUrl))); plane.SetMaterial(Material.FromImage(img)); Image loading fine with 2D, but moving in a 3D way. So, how can I move the Image in a 2D way also when I zoom the Image it should display in a 3D way like Google Map. – Puneet Mahali Sep 11 '18 at 07:50
  • @PuneetMahali If you want panning effect like Google Maps, you can move your camera on XY plane. For zoom effect, change your camera zoom value. https://developer.xamarin.com/api/property/Urho.Camera.Zoom/ – tobi3245 Sep 12 '18 at 08:23
  • I already tried to change the camera zoom value but still moving in 3D. – Puneet Mahali Sep 12 '18 at 13:45
  • How can I zoom on X,Y axis also I tried Orthographic but it's stops the movement? – Puneet Mahali Sep 12 '18 at 13:47