Jump to content


Photo

Another .mod question


  • Please log in to reply
4 replies to this topic

#1 faissialoo

faissialoo

    I get high on orange

  • GMC Member
  • 1239 posts
  • Version:GM8.1

Posted 15 April 2012 - 08:43 AM

I am using the 4x4 driver engine and am trying to change the terrain, however, everytime I change it the game crashes. I know why but do not know how to fix. It is because the .mod I am trying to load has a different file structure to the one that existed before?

look at the header:
original:
128.0000
 128.0000
 128.0000
 128.0000
 796.8750 1162.1094 1207.7637 1213.4704 1214.1838 1214.2730 1214.2841 1214.2855 1214.2856 1213.2440 1211.0305 1207.6287 1206.1619 1204.9368 1204.7837 1204.7645 1204.7621 1204.7619 1194.3452 1172.2099 1138.1930 1112.0658 1096.2998 1092.2458 1090.6975 1090.5039 1090.4797 1090.4766 1090.4763 1090.4763 1090.4763 1090.4763 1090.4763 1090.4763 1090.4763 1090.4763 1090.4763 1100.8930 1124.0699 1160.3004 1187.7459 1202.6347 1204.4960 1204.7285 1204.7577 1204.7613 1204.7617 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1204.7619 1193.3036 1168.9545 1131.5360 1103.9421 1089.0344 1087.1710 1086.9381 1086.9089 1086.9053 1087.9464 1089.1183 1090.3065 1090.4551 1090.4736 1090.4760 1090.4762 1092.5595 1105.3200 1130.8733 1165.3175 1190.4563 1202.9736 1204.5384 1204.7339 1205.8000 1206.9750 1208.1635 1208.3120 1208
mine:
100
52316
0 4.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000

does anybody know a good .obj converter that won't do this?

Edited by faissialoo, 15 April 2012 - 08:44 AM.

  • 0

#2 Tepi

Tepi

    GMC Member

  • Global Moderators
  • 4238 posts
  • Version:GM:Studio

Posted 19 April 2012 - 09:27 PM

The model file that GM uses has no extension. Its structure is described in detail here.

Which brings me to the question; where are the "mod" files from (where have they been generated), and how are they read in code.
  • 0

#3 faissialoo

faissialoo

    I get high on orange

  • GMC Member
  • 1239 posts
  • Version:GM8.1

Posted 20 April 2012 - 03:22 PM

A app program called GM alter ego generated the second one and the first one was found in the 4x4 driver engine (just search it up in 3d editable examples section) this is the script the engine is using to read the file
//opens selected terrain file and creates it in the same way as if 

//using heightmap builder.

//if (variable_global_exists(global.grid)) ds_grid_destroy(global.grid);

var fileid, fname;

if (argument0="")

fname = get_open_filename("GM Models (*.MOD)|*.MOD","");

else

fname = argument0;



fileid = file_text_open_read(fname);

///----------next few lines just sets values usualy set by the heightmap seize

width = file_text_read_real(fileid);

file_text_readln(fileid);

height = file_text_read_real(fileid);

file_text_readln(fileid);



global.parts = file_text_read_real(fileid);

file_text_readln(fileid);

global.size = file_text_read_real(fileid);

file_text_readln(fileid);

///----------

global.grid = ds_grid_create(width,height);



for (yy=0; yy<height; yy+=1;)

{

    for (xx=0; xx<width; xx+=1)

    {

        val=file_text_read_real(fileid);

        ds_grid_set(global.grid,xx,yy,val);

    }

file_text_readln(fileid);

}

file_text_close(fileid);


  • 0

#4 Tepi

Tepi

    GMC Member

  • Global Moderators
  • 4238 posts
  • Version:GM:Studio

Posted 22 April 2012 - 07:53 PM

There's your problem.

The file is totally different (it's not GM's format at all). It's a file specifically designed for this engine.

Now in order to make it work, you'd need to:
  • have such terrain that its vertices are confined to a grid on the x-y-plane, and
  • make a script to read the model file and rearrange the data in, or
  • find a script that generates such file (not provided?), or
  • regenerate the terrain using the "terrain builder" mentioned in the comments.
The file structure seems to be:
[width]
[height]
[value of global.parts]
[value of global.size]
[vertex height at (0,0)] [vertex height at (1,0)] [vertex height at (2,0)] ...
[vertex height at (0,1)] [vertex height at (1,1)] [vertex height at (2,1)] ...
⋮
while your model file is as described as Sinaz's post I linked. Now to write a script to rearrange the data, you can loop through the GM model data and create a grid where each z value will be stored, after which the values are called and written in the order specified.
  • 0

#5 faissialoo

faissialoo

    I get high on orange

  • GMC Member
  • 1239 posts
  • Version:GM8.1

Posted 23 April 2012 - 03:04 PM

I have no Idea how to make a script for this as I know near nothing about loops. I just find this complex, I get the idea of how to make this. I think making it manually would be easier for me.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users