How to import obj model and how to use color alpha

About Monkey 2 Forums Monkey 2 Programming Help How to import obj model and how to use color alpha

This topic contains 12 replies, has 4 voices, and was last updated by  swipis 1 year, 2 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #13205

    swipis
    Participant

    Hello, I tried to import model (obj file made in blender) I did:

    but I can’t see my model at run time.

    Second question is how to use color alpha?

    And last question can make an empty object and make it parent (in some other game engine can be called Position node, in unity – GameObject)?

     

    Thank you!

    #13206

    Hezkore
    Participant

    For OBJ loading you’ll have to do #Import “<mojo3d-loaders>”
    But I would recommend exporting to GLTF or GLB using Blender, as those are supported by Mojo3D directly.
    Other formats are loaded using “assimp”

    Alpha is just as you wrote it.
    canvas.Color=New Color(1,0,0,0.5) where the last parameter is alpha.
    Though I don’t think Mojo3D supports it?

    Mojo3D entities has “Parents” if that’s what you mean?

    #13208

    swipis
    Participant

    Thank you for answers

    Alpha looks like not working (at least for me, no matter alpha = 0 or =1 result the same).

    I loaded GLTF model but still can’t see in my scene… What can be wrong?

    #13209

    Hezkore
    Participant

    Head over to your Monkey2 folder, then go to ” modules/mojo3d/tests/ ”
    You’ll have a bunch of examples there and some of them load models, so you could just copy that.

    #13210

    swipis
    Participant

    Than you, will look at these examples!

    #13214

    Ethernaut
    Participant

    It’s possible that your model is too small or too big. Try using “ship.Mesh.FitVertices( New Boxf )” to fit everything into a 1x1x1 box, then place your camera accordingly ( moving to “0,2,5” is a good starting point, then “camera.PointAt( ship )” to point at model ).

    #13231

    swipis
    Participant

    OK when I did as you told but still can’t see my model and no errors what so ever… sometimes I getting “Memory access violation” here is code:

    Any ideas what is wrong?

    #13236

    Mark Sibly
    Keymaster

    This is often a sign that your model isn’t loading properly.

    What you can do is put ‘Assert( model )’ after the Model.Load call to verify it did in fact load correctly.

    Can you post the entire sourcec code? It’s generally much easier for us to spot problems if we can see the entire progam.

    #13237

    swipis
    Participant

    Hi Mark, Assert(model) did not output anything, anyway here is all code:

     

     

    #13238

    Mark Sibly
    Keymaster

    It’s missing the #imports at the top! Please post again…

    #13239

    swipis
    Participant

    ohh sorry, here is full code 🙂

    #13240

    Mark Sibly
    Keymaster

    ship.Mesh.FitVertices(New Boxf(1,1),False)

    This looks wrong. New Boxf( 1,1 ) will create a 0 volume box as min and max are both 1. Try New Boxf( -1,1 ) instead.

    #13241

    swipis
    Participant

    OK now my model is on the screen 🙂 thank you!

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.