3D Importing 3D Models?

Discussion in 'Programming' started by TheJJGamer, Jul 12, 2016.

  1. TheJJGamer

    TheJJGamer Guest

    Heya!
    Sorry for so many posts about 3D stuff. I'm really new to 3D Game Maker, and I can't find any 3D tutorials that work with Game Maker Studio. Anyway, I have my room/walls built and things, but I can't find a way of importing 3D models, (.obj file), into Game Maker: Studio. I've tried many different tutorials and none of them are compatible. If anybody can help me figure out a way of importing a 3D model into my game or maybe link me to a good tutorial I would really appreciate it! Thanks! :)
     
  2. alexde5th

    alexde5th Member

    Joined:
    Jun 26, 2016
    Posts:
    93
    The best that I could say about 3D... use Unity or the Unreal engine. While GM:S has the capability to be 3D, it'd be better to use tools that were more designed for it.
    Also, not sure if you've ran into this already, but GM:S only accepts D3D files...

    At least it does from the last time I've checked.
     
    Ricardo and slojanko like this.
  3. TheJJGamer

    TheJJGamer Guest

    I'm always told that I should use Unity, but I'm not really that interested in it. But yeah, I've been trying d3d, obj, gmmod, ect; but none of them seem to work... Oh well, I'll just keep trying to import objects into GM:S until it works I guess. Thanks anyway. :/
     
  4. Paolo Mazzon

    Paolo Mazzon Guest

    I am no expert in Gamemaker's 3D capabilities, so take my suggestions here with a grain of salt. GM:S only accepts .d3d files, which leaves you two options: Write a script (like a Python script or something) that converts .objs to .d3ds, or write a .obj loader in GML. The former would be faster at runtime, but the latter would be much more convenient. Either way, you can use the Wikipedia page to figure out how a .obj file works then its just a matter of writing a decoder.
     
  5. orange451

    orange451 Member

    Joined:
    Jun 22, 2016
    Posts:
    108
    I tried to talk to Nocturne about getting a 3d forum section here. So we could populate it with up-to-date information on creating 3d applications with Game Maker.

    However, the developers think it's a waste of time :/
    You're not going to find many recent tutorials for 3d on these forums.

    It's really a shame that they feel this way. They could easily make game-maker compete with the big 3d engines. Easily.

    Game Maker is already almost capable of creating any 3d game you can think of. It has modern shader support, and GPU-accelerated graphics. You can do nearly anything that other engines can do, you just have to put in more work.

    In fact, most of the changes I proposed about a year ago to Mike.daily for improving the 3d parts of GameMaker were single-line changes in the code of the engine. Stuff that would improve game maker entirely, not just for 3d. These changes would take literally 20 seconds to implement. But they refuse to work on it. Things like:
    • High precision frame buffers
    • Enable texturefiltering (mipmapping) on externally loaded textures <-- This one is literally changing a "false" to a "true"
    • Different internal buffer formats ( as opposed to the hardcoded GL_RGBA8 )

    So my advise to you, if you truly enjoy using Game Maker, then you're probably someone who likes to write a lot engine-code. If this is the case, and you enjoy 3d programming, then switch to Java using a 3d Engine such as LWJGL. Because sadly, you're not going to get any support from YYG. I've been using Game Maker since 2006; It was my introduction to 3d graphics programming. Like I said earlier, Game Maker is perfectly capable. It is, but there aren't many resources to help you. Something like LWJGL will give you the benefit of using OpenGL which has tons of resources.

    If you just want to make a 3d game and don't want to faff around with engine development, give unity a try.

    Best of luck to you.
     
    Last edited: Jul 12, 2016
    jujubs, Rukola, Katipo007 and 4 others like this.
  6. TheJJGamer

    TheJJGamer Guest

    Ok, so I got the .obj file converted to a .d3d file. The only problem is, it's not loading into GM:S. Idk why it's not working, but it's just not. It's not appearing in the room I put it in.

    CREATE EVENT:
    Model = d3d_model_create();
    d3d_model_load(Model, "bear-obj.d3d");
    if (!Model) {show_message("Could not load model");} else {show_message("Model Loaded");}

    DRAW EVENT:
    draw_set_alpha(1);
    draw_set_color(c_white);
    d3d_model_draw(Model, x, y, 0, -1);
     
  7. Paolo Mazzon

    Paolo Mazzon Guest

    Okay if it's not drawing maybe you didn't convert it properly?
     
  8. TheJJGamer

    TheJJGamer Guest

    I know I converted it properly, but I guess I can try again, or maybe another file. :/
     
  9. Paolo Mazzon

    Paolo Mazzon Guest

    Better question: How did you convert it?
     
  10. TheJJGamer

    TheJJGamer Guest

    I followed this tutorial.
     
  11. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    Use GMModelfix to convert. 99% of the obj out there are half broken. the link is in my tools page
     
  12. TheJJGamer

    TheJJGamer Guest

    OMG I GOT IT WORKING!!

    I used Game Maker Model Creator to import the obj file and I used the 'export as script' option. Now I have a script file with a gazilion lines of code that creates the model and textures it!
     
  13. orange451

    orange451 Member

    Joined:
    Jun 22, 2016
    Posts:
    108
    I'd say it's more close to 99% of OBJ-readers are half broken.

    OBJ is such a loose format. There's no real one correct way to write one anymore.
     
    Roa likes this.
  14. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    Yeah 0 based indexing, 1 based indexing, relative indexing... exporter not following the specs (yes there are/were some). Took me months to make the obj loader dll.

    And let's not talk about modelers that don't respect right handedness of facets
     
    orange451 likes this.
  15. lolslayer

    lolslayer Member

    Joined:
    Jun 23, 2016
    Posts:
    687
    Why are the GM developers being so stubborn though?
     
  16. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    I think they are more comfortable with 2d stuff
     
  17. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,433
    Speaking of zero-indexing, you should change the failure condition in your Create event to <0. Like all other resource IDs, model IDs are zero-indexed. The first model loaded by your game would get an ID of 0 for success, yet your code would brush it off as a flop.

    Using ! to check for failure in non-Boolean return values is an unsafe coding habit that performance whores on the GMC constantly peddle. You should stop drinking their kool-aid.
     
  18. flyingsaucerinvasion

    flyingsaucerinvasion Member

    Joined:
    Jun 20, 2016
    Posts:
    2,112
    I'm really bummed out by this. I was hoping they'd be working on bringing more 3d to Game Maker Studio 2. I can't figure out why they are resistant to it. Firstly, you can already do so many things in 3d using Game Maker. And I've recently seen a lot of posts concerning 3d in the forums, so that proves there is interest. It seems like there is a lot of stuff that can be done to improve the 3d game maker developer experience. If there is no sign that YYG will shift on this issue I'll just have to move on to something else... I can already tell GM is holding me back in some ways. Which sucks, because I've learned so much about Game Maker in the last year that I don't want to leave it behind.
     
  19. lolslayer

    lolslayer Member

    Joined:
    Jun 23, 2016
    Posts:
    687
    It's interesting that Nocturne is silent on topics like these though...
     
  20. icuurd12b42

    icuurd12b42 TMC Founder GMC Elder

    Joined:
    Apr 22, 2016
    Posts:
    1,837
    Why, Nocturne is not into the whole 3d thing
     
  21. lolslayer

    lolslayer Member

    Joined:
    Jun 23, 2016
    Posts:
    687
    He's our main source of contact with the yoyogames staff
     
  22. zircher

    zircher Member

    Joined:
    Jun 21, 2016
    Posts:
    379
    Instead of using script exports, I just add the d3d files to the Included Files section so that GM:S can see/load them. I placed the texture files for the models in the Backgrounds or Sprites section.

    The create event for the tank object goes something like this.

    Code:
    /// init unit
    {
      owner = 1;
      moveMax = 12;
      moveLeft = irandom(12);
      health = 100;
      name = 'GravTank';
      type = 30;  // grav tanks all move the same for now
      HX = getHX(x,y);  HY = getHY(x,y);
      
      w = 16;
      l = 16;
      h = .3;
      z = 0;
    
      vPosition = vecCreate(x, y, z);
    
      hullFacing = irandom(5) * 60;  // 0 to 300 degree
      turretFacing = hullFacing + (irandom(4)-2 * 60);  // offset +/- 120 degrees
     
      modelHull = d3d_model_create();
      modelTurret = d3d_model_create();
      modelDisk = d3d_model_create();
      tex01 = 0;
      tex02 = 0;
    
      d3d_model_load(modelDisk, "disk.d3d");
     
      switch irandom(4)
      {
        case 0: tex01 = background_get_texture(back_Camo);     break;
        case 1: tex01 = background_get_texture(back_DarkCamo); break;
        case 2: tex01 = background_get_texture(back_DarkHull); break;
        case 3: tex01 = background_get_texture(back_Mecha1);   break;
        case 4: tex01 = background_get_texture(back_Mecha2);   break;
      }
    
      switch irandom(5)
      {
        case 0: tex02 = sprite_get_texture(spr_unit_blue,0);    owner=1; break;
        case 1: tex02 = sprite_get_texture(spr_unit_green,0);   owner=1; break;
        case 2: tex02 = sprite_get_texture(spr_unit_red,0);     owner=1; break;
        case 3: tex02 = sprite_get_texture(spr_unit_white,0);   owner=1; break;
        case 4: tex02 = sprite_get_texture(spr_unit_yellow,0);  owner=1; break;
        case 5: tex02 = sprite_get_texture(spr_unit_magenta,0); owner=2; break;
      }
      
      switch irandom(8)
      {
         case 0:
           d3d_model_load(modelHull, "grav_tank_01_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_01_turret.d3d");
           break;
         case 1:
           d3d_model_load(modelHull, "grav_tank_02_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_02_turret.d3d");
           break;
         case 2:
           d3d_model_load(modelHull, "grav_tank_03_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_03_turret.d3d");
           break;
         case 3:
           d3d_model_load(modelHull, "grav_tank_05_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_05_turret.d3d");
           break;
         case 4:
           d3d_model_load(modelHull, "grav_tank_06_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_06_turret.d3d");
           break;
         case 5:
           d3d_model_load(modelHull, "grav_tank_07_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_07_turret.d3d");
           break;
         case 6:
           d3d_model_load(modelHull, "grav_tank_09_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_09_turret.d3d");
           break;
         case 7:
           d3d_model_load(modelHull, "grav_tank_10_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_10_turret.d3d");
           break;
         case 8:
           d3d_model_load(modelHull, "grav_tank_11_hull.d3d");
           d3d_model_load(modelTurret, "grav_tank_11_turret.d3d");
           break;
      }
    }
    
    /////////////////////////////////////////////////////////
    // In the draw event of the tank object I have
    
    if room == room_main
    {
      d3d_start();
      d3d_set_perspective(true);
      d3d_set_hidden(true);
      d3d_set_culling(true);
    
      draw_set_color(c_white);
      d3d_set_lighting(true);
      d3d_light_enable(0,true);
    
      d3d_transform_set_identity();
      d3d_transform_set_rotation_z(hullFacing);
      d3d_transform_add_translation(x,y,z);
      if( modelHull >= 0 ) d3d_model_draw(modelHull,0,0,0, tex01);
      d3d_transform_set_identity();
    
      d3d_transform_set_identity();
      d3d_transform_set_rotation_z(hullFacing + turretFacing);
      d3d_transform_add_translation(x,y,z);
      if(modelTurret >= 0 ) d3d_model_draw(modelTurret,0,0,0, tex01);
      d3d_transform_set_identity();
    
      d3d_transform_set_identity();
      d3d_transform_add_translation(x,y,z);
      if(modelDisk >= 0 ) d3d_model_draw(modelDisk,0,0,0, tex02);
      d3d_transform_set_identity();
    }
    
    
    
    [​IMG]

    I hope that helps. :)
    --
    TAZ

    [edit for typos]
     
    Lonewolff likes this.
  23. misterprickly

    misterprickly Member

    Joined:
    Jan 19, 2017
    Posts:
    2
    I've been feeling THIS pain you years!
    Got a whole lot of low poly .MAX files that I've been converting into .OBJs; only to find that the converters either don't work OR don't work well.

    At one point I was like "I'll just make the whole thing out of CUBES!" 'cause that's the only thing I could get to work... Primitives.

    My point is... Don't give up BUT don't be afraid to make compromises.
     
  24. Misty

    Misty Member

    Joined:
    Jun 22, 2016
    Posts:
    1,024
    Thing is, can I import a multitextured obj. Gm seems limited that there is no program that imports a obj and saves it as multiple models for each texture. This is a basic feature in gaming technology since 1995 that GM seems to not have.
     
  25. TheJJGamer

    TheJJGamer Guest

    I'm not too sure I understand your question. You mean you want to use multiple textures to texture a model? Like using a sprite sheet like this:
    [​IMG]
    I apologize as I don't believe I understand your question. :/
     
  26. Misty

    Misty Member

    Joined:
    Jun 22, 2016
    Posts:
    1,024
    Thats for little meshes and objects. Multitexture is needed for maps, like u have repeated grass then wall.
     
  27. I can't get Model Creator to work. The application throws the error "Failed to load game data. File seems corrupted."
     
  28. Tonydaderp

    Tonydaderp Member

    Joined:
    Sep 7, 2016
    Posts:
    120
    would pre-rendering the models work? Y'know, like donkey kong country. This way, you still maintain the easy 2d coding for gm, but get the nice looks of 3d stuff.
     
  29. Kentae

    Kentae Member

    Joined:
    Sep 24, 2016
    Posts:
    105
    Seems like this is an old thread but since it came up on top just now I guess someone is trying to restart it or get info from some of the previous participants.
    Either way I read thruogh most of it and find a lot of what is said here quite interesting.
    Also I saw someone wanting multitexture capabilities for maps and if anyones still interested, I can actually help there.
    I recently made a shader that does just that.. And I even wrote a tutorial on how to use it https://forum.yoyogames.com/index.php?threads/multi-texture-shader-for-use-in-3d.32076/

    Again, I know this is an old thread but I must say I agree with all the people who wants 3D to be a thing in game maker again.
    I am currently attempting to create my own sort of 3D game engine in game maker studio 1.4 and I am kind of amazed by what GMS is actually capable of if you but some work into it.
    Anyway, if anyone's interested, the engine I'm creating currently have:
    Terrain creation using a heightmap.
    Terrain normal calculation to make lighting (and other effects) work properly with it.
    The multitexture shader I posted above. (I have since the tutorial was posted added my specular effect to the multitexture so that you can have shiny surfaces if you want)
    3D collisions. Using a DLL I found on the old forums. Can't remember who made it though and there is no name anywhere in the codes. (It's not P3DC though)
    I'm currently working on making easy implementation of both 1st- and 3rd-person cameras.

    Things I would like to add:
    3D pathfinding.
    Some sort of 3D animation system. (not sure wich one yet, I have found a few)
    And I'm planning on creating a seprate world editor to go with the engine.

    And I hope I'll actually be able to finnish all this.
    And also I kind of feel like I've been writing too much here now but it was great to get some of these thoughts out :)
     
    Joe Ellis and zircher like this.
  30. Bunelee

    Bunelee Member

    Joined:
    Oct 30, 2018
    Posts:
    21
    Try GMMC. (Gamemaker model creator)
     
  31. dannyjenn

    dannyjenn Member

    Joined:
    Jul 29, 2017
    Posts:
    568
    I'll just point out, this thread is really old. GMS2 didn't even exist when this thread was made, and 3D has undergone major changes between GMS1.4 and GMS2.

    But here are a couple video tutorials I came across, which might be helpful to GMS2 users who are trying to import *.obj files:


    Looks like a fairly straightforward process, but I personally haven't tried them out. (I haven't gotten into much 3D yet.) Seems a little tedious but it probably makes for a good learning exercise. (No idea if there are any extensions out there that can save you the trouble...)
     
    Last edited: Mar 31, 2019
    EvanSki and zircher like this.
  32. Misty

    Misty Member

    Joined:
    Jun 22, 2016
    Posts:
    1,024
    Yeah the video doesn't show how to do shadows... which is the main thing I was interested in in the video.
     
  33. Ricardo

    Ricardo Member

    Joined:
    Jun 20, 2016
    Posts:
    170
    YoYo Games, as a company, already has enough problems keeping things working as they are currently. I can totally see why they don't put more time - and money - on 3D. Even if they start today investing heavily in 3D features, a year of hard work will pass and yet GMS2 probably won't reach 30% of Unity's 3D features and ease of use on 3D. YoYo has to focus on stay competitive - and economically viable - in their own niche, the niche they already built and have experience with. It'll be a great risk to them to put dev time (money) on a area in which other dev tools are already solidly established.
    If you want competitive 3D, be smart and use the right tool for it. Don't try to bend the wrong tool beyond its possibilities.
     
  34. zircher

    zircher Member

    Joined:
    Jun 21, 2016
    Posts:
    379
    Making 3D on GMS is still viable for some tasks. Perhaps as a platformer or arcade shooter where you want to be different and things like realistic shadows is not a requirement. Is it optimal or productive? Not even close, but it can still be fun to play with in a limited capacity without having to learn a whole new system. Call it 'just for fun' coding.

    [Edit for a whole lot of typos. Wow, I must have been tired.]
     
    Last edited: Aug 17, 2019

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice