GML - Loading 3D models
From Global Programming Syntax
Note that Gamemaker 5 and below do not support 3D modeling. So now if you have Gamemaker 6 or 7 then you will need a 3D model. Unfortunately with gamemaker 7, it only accepts 2 filetypes. They are d3d and obj. But hasn't got full support for the obj model type.
Example Code
This code will focus on the d3d type. You can pm admin on the forum for this site to convert any 3D model which is in the site. Keep in mind that converting a single model takes over half an hour. Then place the below code to load the model. First put this GML into the create event.
{
z=0;
model = d3d_model_create();
d3d_model_load(model,"modelname.d3d");
texture = background_get_texture(backgroundtexturename);
}
Now put the following GML into the draw event.
d3d_transform_set_identity();
d3d_transform_add_scaling(scalex,scaley,scalez); // Add the scale factor in the
//scalex,scaley,scalez. So 0.5 his half the size and 2 is twice the size.
d3d_model_draw(model,x+0,y+0,z+0,texture);
d3d_transform_set_identity();
Now don't forget to include all models and external files in the 'Global Game Settings' which is listed at the bottom of the left hand bar. So after you open the 'Global Game Settings' window, select the 'include' tab at the top. Then click the add button and locate the external file which is being used in the game.
