how to import an object in urhosharp

jddjdd USMember ✭✭✭
edited January 11 in Xamarin.Forms

Hello,
I made made progress in my planetarium project: I know how to add urhosharp in my xamarin.forms project and how to show lines and write text. But I need to receive a boost.

The purpose is to make a planetarium. The user sees stars and can click on a star to select it and get informations.
I made a 3D scene with blender and python scripting with white filled circles around a sphere (500 stars are at the good position, facing the center). The light and the camera are in the center of the scene (see picture). I can render it.

Next, I need to import the objects in my xamarin.forms project.

These are few questions. If an Urhosharp expert could give me few indications, it could be great.

  1. I need to use Assetimport to convert my scene. Can I convert a full node with all the circles in it. Is there any step by step documentation ?
  2. what will I get? a xml file? 500 xml files? a mdl file?
  3. where should I copy these files to import them in my project?
  4. how can I import them in my code, what is the path?
  5. how can I import in my project a blender made material?
    I made python scripting in blender to draw the sky.
  6. would it be a better (faster or easier) solution to draw the sky in C# in the app?
  7. would it be a better (faster or easier) solution to draw the sky in urho editor with angelscript?

Thank you for your help and your advices

Best Answer

  • jddjdd US ✭✭✭
    Accepted Answer

    There is not many activity about urhosharp on Xamarin forums.
    To find help we need to go to the urho3d forum:
    https://discourse.urho3d.io/
    But keep in mind not talking about xamarin and urhosharp but only about urho3d as people in that forum don't like very much C# wrappers.

    I need to use Assetimport to convert my scene. Can I convert a full node with all the circles in it. Is there any step by step documentation ?
    what will I get? a xml file? 500 xml files? a mdl file?

    I did use a up-to-date add-on:
    reattiva’s exporter: https://github.com/reattiva/Urho3D-Blender/tree/2_80
    I got a .mdl file

    where should I copy these files to import them in my project?
    how can I import them in my code, what is the path?

    for UWP, I added the model in the data\models folder and changed the Build Action to Content (see picture)

    When I call the urhosharp app, I tell the assets folder like that:

               await urhoSurface.Show<SkyUrho>(new Urho.ApplicationOptions(assetsFolder: "Data"));
    

    Then I get the model like that:

    using Urho;
    using Urho.Shapes;
    using Urho.Actions;
    using Urho.Gui;
    using Urho.Forms;
    
    namespace AlmicantaratXF.ViewModels
    {
        public class SkyUrho : Urho.Application
        {
            public SkyUrho() : base(new ApplicationOptions(assetsFolder: "Data") { Height = 1024, Width = 576, Orientation = ApplicationOptions.OrientationType.Portrait }) { }
    
            public SkyUrho(Urho.ApplicationOptions options) : base(options) { }
    
            static SkyUrho() { }
            protected override void Start()
            {
                base.Start();
                CreatText();
                CreateSkyMap();
            }
            private void CreateSkyMap()
            {
                Scene scene = new Scene();
                scene.CreateComponent<Octree>();
                Node node = scene.CreateChild();
                node.Position = new Vector3(0, 0, 3);
                node.SetScale(0.2f);
    
                Node nodeCenterSphere = scene.CreateChild();
                nodeCenterSphere.Position = new Vector3(0, 0, 0);
                var modelCelstialSphere = nodeCenterSphere.CreateComponent<StaticModel>();
                modelCelstialSphere.Model = ResourceCache.GetModel("Models/circle302.mdl");
                nodeCenterSphere.RunActions(new RepeatForever(new RotateBy(2f, 0, 0, 20f)));
    

    For Android, I don't know yet.

    how can I import in my project a blender made material?

    for the moment, the only solution is to use blender 2.7
    https://discourse.urho3d.io/t/solved-how-to-import-from-blender/5822

    would it be a better (faster or easier) solution to draw the sky in C# in the app?
    would it be a better (faster or easier) solution to draw the sky in urho editor with angelscript?

    I did well with blender but may be I will need to use urho editor to add materials to my model...

Answers

  • jddjdd USMember ✭✭✭
    Accepted Answer

    There is not many activity about urhosharp on Xamarin forums.
    To find help we need to go to the urho3d forum:
    https://discourse.urho3d.io/
    But keep in mind not talking about xamarin and urhosharp but only about urho3d as people in that forum don't like very much C# wrappers.

    I need to use Assetimport to convert my scene. Can I convert a full node with all the circles in it. Is there any step by step documentation ?
    what will I get? a xml file? 500 xml files? a mdl file?

    I did use a up-to-date add-on:
    reattiva’s exporter: https://github.com/reattiva/Urho3D-Blender/tree/2_80
    I got a .mdl file

    where should I copy these files to import them in my project?
    how can I import them in my code, what is the path?

    for UWP, I added the model in the data\models folder and changed the Build Action to Content (see picture)

    When I call the urhosharp app, I tell the assets folder like that:

               await urhoSurface.Show<SkyUrho>(new Urho.ApplicationOptions(assetsFolder: "Data"));
    

    Then I get the model like that:

    using Urho;
    using Urho.Shapes;
    using Urho.Actions;
    using Urho.Gui;
    using Urho.Forms;
    
    namespace AlmicantaratXF.ViewModels
    {
        public class SkyUrho : Urho.Application
        {
            public SkyUrho() : base(new ApplicationOptions(assetsFolder: "Data") { Height = 1024, Width = 576, Orientation = ApplicationOptions.OrientationType.Portrait }) { }
    
            public SkyUrho(Urho.ApplicationOptions options) : base(options) { }
    
            static SkyUrho() { }
            protected override void Start()
            {
                base.Start();
                CreatText();
                CreateSkyMap();
            }
            private void CreateSkyMap()
            {
                Scene scene = new Scene();
                scene.CreateComponent<Octree>();
                Node node = scene.CreateChild();
                node.Position = new Vector3(0, 0, 3);
                node.SetScale(0.2f);
    
                Node nodeCenterSphere = scene.CreateChild();
                nodeCenterSphere.Position = new Vector3(0, 0, 0);
                var modelCelstialSphere = nodeCenterSphere.CreateComponent<StaticModel>();
                modelCelstialSphere.Model = ResourceCache.GetModel("Models/circle302.mdl");
                nodeCenterSphere.RunActions(new RepeatForever(new RotateBy(2f, 0, 0, 20f)));
    

    For Android, I don't know yet.

    how can I import in my project a blender made material?

    for the moment, the only solution is to use blender 2.7
    https://discourse.urho3d.io/t/solved-how-to-import-from-blender/5822

    would it be a better (faster or easier) solution to draw the sky in C# in the app?
    would it be a better (faster or easier) solution to draw the sky in urho editor with angelscript?

    I did well with blender but may be I will need to use urho editor to add materials to my model...

Sign In or Register to comment.