Jump to content


Photo

d3d_model_load_ext - 3d Models Importing Script


  • Please log in to reply
84 replies to this topic

#1 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 393 posts
  • Version:GM8

Posted 02 October 2006 - 10:28 PM

d3d_model_load_ext() is a script for importing models in the following file formats

  • WaveFront .obj
  • Anim8or .vtx
  • C source files .c (as exported by LithUnwrap)
  • DirectX files .x (only in ascii/non compressed)
  • 3D Studio ASCII files .asc
  • GameMaker .mod (as loaded and saved by the builtin GM3D model loading/saving routines)

to Game Maker d3d.

d3d_model_load_ext() reads all vertex, texture and normals data (if available in the file).

It has parameters to make it easier to use the model in GM, you can:

  • flip the normals
  • mirror the texture coordinates
  • set a scale (because d3d_transform_add_scaling(xy,ys,zs) distorts the normals)

(this only works for non .mod models)

Download

Download the script and demo project, .gmk


Usage
Loading a model works the same way as with d3d_load_model(), with three additional parameters:

model=d3d_model_create();
d3d_model_load_ext(model, fname, flipnormals, fliptexcoords, scale);
(TODO: Make parameters optional)

The model can then be used in the Draw Event:
d3d_model_draw(model,x,y,z,texture);

Additioal Information and Licensing
d3d_model_load_ext() is a freeware script and you may well redistribute the package as it is.

Some parts of it took me hours to develop/figure out/research.
If you use it in your projects, please give credit to me like:
"Uses d3d_model_load_ext() by Paul "Master Xilo" Frischknecht"

Created for model formats as exported by LithUnwrap 1.3, but should work for files created by any exporter.
If it doesn't, try reconverting your model using the above program.

Remember that loading Game Maker's .mod 3d model format is always the fastest. Convert other formats only once and save them as .mod if possible. If you want to load .mod files even faster, check out d3d_model_load_fast.

I hope you'll find this script useful.
- Paul

Edited by Master Xilo, 02 April 2014 - 09:02 PM.

  • 5

#2 Skarik

Skarik

    GMC member

  • GMC Member
  • 1068 posts

Posted 02 October 2006 - 10:32 PM

O_O SHINY.....

Edit:

HOLY SH*T! DOES THIS LOAD FASTER THAN MOSAIC LIGHT???????!?!?!?! OR IS IT MY PC?!?!?!

Edited by Skarik, 02 October 2006 - 10:35 PM.

  • 0

#3 INl

INl

    GMC Member

  • New Member
  • 102 posts

Posted 03 October 2006 - 02:50 AM

I haven't found any problems with it... besides what I assume to be the program's limitations (in a rather detailed file... more simplistic models work perfectly).

Nice job :)
  • 0

#4 wildweststballa

wildweststballa

    GMC Member

  • New Member
  • 272 posts

Posted 03 October 2006 - 03:01 AM

This is Very good and looks Very promising. I believe it allows for more detailed models to run at a higher fps, I believe. Anyway, I have to disagree with you on one part and that is not wanting to use marzinip anymore. How do we protect are models from people stealing them cry* I still like this program, I could see myself using this for terrain. Does it supports animations?
  • 0

#5 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 393 posts
  • Version:GM8

Posted 03 October 2006 - 12:22 PM

I'll upload a demo of the future feautres soon.

EDIT: view first post

Edited by Master Xilo, 03 October 2006 - 01:34 PM.

  • 0

#6 Proffessor_gad

Proffessor_gad

    GMC Member

  • New Member
  • 757 posts

Posted 03 October 2006 - 04:25 PM

This looks quite promising. I hope you continue making things like this :) .

P.S. Game maker 6.0, needs a good 3d collissions example. So if you have some free time :lol: ......
  • 0

#7 Voxel

Voxel

    8-bit pixel

  • New Member
  • 61 posts

Posted 08 October 2006 - 04:48 AM

can you show the example of the full one?
thanks :ph34r:

Edited by Voxel, 09 October 2006 - 02:15 AM.

  • 0

#8 Darksoul

Darksoul

    3D Dude

  • New Member
  • 124 posts

Posted 10 October 2006 - 03:23 PM

this is REALLY cool it needs more attention
  • 0

#9 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 393 posts
  • Version:GM8

Posted 11 October 2006 - 07:30 AM

OK, finally I release the whole script.

See first post.
  • 0

#10 coolsmile

coolsmile

    Programmer

  • New Member
  • 1346 posts

Posted 11 October 2006 - 11:53 PM

AWESOME JOB, this is a beautiful :GM5:
  • 0

#11 abacus

abacus

    GMC Member

  • New Member
  • 1330 posts

Posted 14 October 2006 - 12:26 AM

sickism
  • 0

#12 coolsmile

coolsmile

    Programmer

  • New Member
  • 1346 posts

Posted 15 October 2006 - 03:58 PM

This topic deserves more attention :D
  • 0

#13 alzable

alzable

    GMC Member

  • New Member
  • 188 posts

Posted 16 October 2006 - 07:11 AM

WOW ... this means I can finally load my 1610 vertex model! This is one of the fastest model loaders ive seen! THis certainly does deserve more attention! =D

Well done!!!

alzable
  • 0

#14 Obiki_San

Obiki_San

    GMC Member

  • New Member
  • 136 posts

Posted 16 October 2006 - 10:48 AM

Pretty Cool *smiles*

I've tested the model that came with the demo. Why is it that the .mod file is so much bigger but loads the fastest? Ah well.

Good Work.
  • 0

#15 Burntrubber9

Burntrubber9

    GMC Member

  • New Member
  • 101 posts

Posted 16 October 2006 - 11:47 PM

The reason the .mod file loads fastest is because it is the GM default. It does not require you to read any strings, pull out the data,and write it to a model. It is just written directly to a model from the data in the file.
  • 0

#16 aparoid_x

aparoid_x

    Nintendork

  • New Member
  • 228 posts

Posted 17 October 2006 - 12:04 AM

I can't get it to load my .vtx file. How can I import one, changing the code in the creation event of your example?
  • 0

#17 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 393 posts
  • Version:GM8

Posted 17 October 2006 - 03:41 PM

Controls:
Space: load a model
L: light on/off

more: see help
  • 0

#18 zyvolution

zyvolution

    GMC Member

  • New Member
  • 255 posts

Posted 26 October 2006 - 01:24 PM

I would really like to try this one but the link is dead can you please re-upload it?
  • 0

#19 Klite-GameMaker

Klite-GameMaker

    GMC Member

  • New Member
  • 7 posts

Posted 27 October 2006 - 05:01 PM

AWESOME :D But the link is down :GM5:
  • 0

#20 cambesa

cambesa

    GMC Member

  • GMC Member
  • 868 posts
  • Version:Unknown

Posted 27 October 2006 - 06:44 PM

i thought it only can import or load .d3d files...
you can make them with marzipan but.....
i dont like it that you need to make the texture again with gamemaker because gm cant load textured models...

i hope gm will make better 3d in the next version but i dont think so.
maybe a litle bit more but not so much thet it can load all models textured...
  • 0

#21 zyvolution

zyvolution

    GMC Member

  • New Member
  • 255 posts

Posted 27 October 2006 - 06:56 PM

I converted my obj file with marzipan and i added it to gml and i added the texture in gm and it just uses it correctly.
  • 0

#22 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 393 posts
  • Version:GM8

Posted 27 October 2006 - 09:46 PM

AWESOME :D But the link is down :GM5:

<{POST_SNAPBACK}>

I fixed the link.

Edited by Master Xilo, 27 October 2006 - 09:46 PM.

  • 0

#23 BenRK

BenRK

    Now in high-definition!

  • GMC Member
  • 756 posts
  • Version:GM:Studio

Posted 28 October 2006 - 07:03 AM

Wow! This is perfect! It ran an obj file on my computer at (lit)50fps and (not lit)~60fps on my comp with over 8500 vertexes loaded! And seeing as my comp is crap, THAT'S GREAT! I'll be using this in the future.
  • 0

#24 Voxel

Voxel

    8-bit pixel

  • New Member
  • 61 posts

Posted 29 October 2006 - 05:01 PM

wow this is so cool!
  • 0

#25 Double A

Double A

    GMC Member

  • New Member
  • 97 posts

Posted 31 October 2006 - 04:41 PM

...

This is a godsend. I love you. ^_^
  • 0

#26 Master Xilo

Master Xilo

    GMC Member

  • GMC Member
  • 393 posts
  • Version:GM8

Posted 31 January 2007 - 05:29 PM

no problem Double A
  • 0

#27 kawearo

kawearo

    GMC Member

  • New Member
  • 12 posts

Posted 17 February 2007 - 06:48 PM

how do i get an avatar??[SIZE=14]???
  • 0

#28 Gumgo

Gumgo

    The Gecko

  • New Member
  • 310 posts

Posted 23 February 2007 - 04:20 AM

Hmm... For some reason, it rotates my .X models 90 degrees and also seems to "center" the objects even if I want their origin somewhere else (maybe that's just the .X format though. I KNOW the rotation isn't though) and also throws an error (error in real() function or something) when loading .OBJ files (all exported from 3ds max). I took a look at the files and they both looked fairly normal, aside from the fact that for some reason 3ds max doesn't seem to export normals and texture coords in OBJ format (no idea why, but it's starting to really bug me). Anyway, and idea about the .X thing?

Edit: Figured out the weird origin thing, turns out it is because DirectX Meshes have a seperate section for transformation. There's just a little extra code you have to add. Anyways, if you want me to PM it to you, Master Xilo, I'd be happy to.

Edit2: Oh, and the thing about rotations I figured out as well. I believe that either 3DS Max or the exporter I'm using uses the Y axis as "up and down" whereas Game Maker (with the most commonly used projection) uses the Z axis. Anyways, just thought I'd mention these for anyone else who might have trouble.

And a third thing about .X files: In your script, Master Xilo, you had a spot where the script searched for "Mesh {" (with one space). My exporter actually outputs "Mesh . {" with two spaces (but not the dot, just did that so the second space'd show up), so that section was never found. I recommend changing it to something like if (string_replace_all(" ","",row) == "Mesh{") so that it will work in more cases.

Great script though!

Edited by Gumgo, 23 February 2007 - 11:46 PM.

  • 0

#29 guzu_ligo

guzu_ligo

    GMC Member

  • New Member
  • 109 posts

Posted 30 April 2007 - 11:59 PM

I made an object in Cinema 4D and export it to .x and also .obj and they didn't seem to work. I get an error message about not being able to read real (Not real) or something. If you are still working on this, I'll provide you with the files to check. The thing I noticed that the file format is a bit different than yours. There is the use of // for comments and there is something like (Mesh CINEMA_4DMESH {..... ).

Keep up the good work.
  • 0

#30 the_doominator

the_doominator

    Eight Star

  • New Member
  • 925 posts

Posted 10 May 2007 - 09:41 PM

this is easily better than mosaic light.... - :D
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users