Importing custom 3D models

Hi everyone. I'm getting started with Urho Forms in Xamarin Shared app. There is one important question arised: how can i use custom 3D model into my project? With built-in models (such as box, plane, sphere, etc.) everyhing works fine. But when I'm trying to use any model of .mdl format, I'm getting no result, they're not displayed. I'm not sure, where does model have to be placed in my project. I have 3 project solutions: Shared, Android, IOS, and I'm putting model named "MyCustomModel" into Shared solution, in folder named "MyModels", and then trying to access it through code in following way:

        var baseNode = plotNode.CreateChild().CreateChild();
        var object = baseNode.CreateComponent<StaticModel>();
        object.Model = ResourceCache.GetModel("MyModels/MyCustomModel.mdl");

If i'll change

        object.Model = ResourceCache.GetModel("MyModels/MyCustomModel.mdl");

to

        object.Model = ResourceCache.GetModel("Models/Box.mdl");

everything works fine, box displayed. But any custom model don't. I've searched for answer over the forum and documentation, but found no any related materials. Thanks for any replies.

Answers

  • EgorBoEgorBo BYXamarin Team ✭✭✭

    GreenQ, Unfortunately at this moment you can't store assets in a SharedProjects - on each platform they should have different Build Action (or you can use this technique).
    Add them on each platform project via link to a folder "MyAssets" (e.g. AndroidProject/MyAssets/MyModels/MyCustomModel.mdl)
    Android: AndroidAsset
    iOS: BundleResource

    and make sure you create an app instance via these options:
    var app = new MyUrhoApp(new ApplicationOptions("MyAssets"));

  • thyagarajanSAthyagarajanSA USMember

    Hi EgorBo
    I am getting started with Urho. I have the same problem, I followed your advice.
    I am getting a unhandled exception error. Can you please help

    thanks
    rajan

  • alessandrosuppiejalessandrosuppiej ITMember ✭✭

    @EgorBo said:
    GreenQ, Unfortunately at this moment you can't store assets in a SharedProjects - on each platform they should have different Build Action (or you can use this technique).
    Add them on each platform project via link to a folder "MyAssets" (e.g. AndroidProject/MyAssets/MyModels/MyCustomModel.mdl)
    Android: AndroidAsset
    iOS: BundleResource

    and make sure you create an app instance via these options:
    var app = new MyUrhoApp(new ApplicationOptions("MyAssets"));

    Same problem here.
    nothing showed even if i followed your tip.

    What am i doing wronG?

  • EgorBoEgorBo BYXamarin Team ✭✭✭

    Can you provide a repro project please?

Sign In or Register to comment.