Merrick82
Member
Hi Community, hoping you can help me figure this out: I've been importing some models I made and textured in Model Creator (a simple Chest for example). Everything was working fine for a while and suddenly all D3D models stopped working one day.
In the textures I checked to see if I accidentally unchecked Use For 3D. Still checked.
So I stripped down the game to its bare bones, just a Camera Object, the Chest Object and a Floor Object is left.... and still the chest model is not getting drawn. Here is all the code remaining:
The Camera Object
The Chest Object
The Floor Object (stretchable)
So there it is... just three objects. And again, this was working fine, but obviously there's something I'm having a brain fog about now, so I'm hoping the community can help me clear it.
In the textures I checked to see if I accidentally unchecked Use For 3D. Still checked.
So I stripped down the game to its bare bones, just a Camera Object, the Chest Object and a Floor Object is left.... and still the chest model is not getting drawn. Here is all the code remaining:
The Camera Object
///CREATE EVENT
depth = 10000; //camera object is initially set to depth -10000 in object editor
d3d_start();
d3d_set_culling(false);
draw_set_alpha_test_ref_value(20);
draw_set_alpha_test(true);
d3d_set_hidden(0);
display_reset(0,true);
draw_set_colour(c_white);
//Set Mouse to Centre
display_mouse_set(display_get_width()/2,display_get_height()/2);
//Camera Mouse-Look Variables
pitch = 0;
direction = 0;
height = 16;
xto = x+10;
yto = y;
zto = height;
depth = 10000; //camera object is initially set to depth -10000 in object editor
d3d_start();
d3d_set_culling(false);
draw_set_alpha_test_ref_value(20);
draw_set_alpha_test(true);
d3d_set_hidden(0);
display_reset(0,true);
draw_set_colour(c_white);
//Set Mouse to Centre
display_mouse_set(display_get_width()/2,display_get_height()/2);
//Camera Mouse-Look Variables
pitch = 0;
direction = 0;
height = 16;
xto = x+10;
yto = y;
zto = height;
///STEP EVENT
//Mouse-Look Direction Controls
var lock = !keyboard_check(vk_alt);
if (lock)
{
//Calculate Direction
direction -= (display_mouse_get_x()-display_get_width()/2)/10;
pitch -= (display_mouse_get_y()-display_get_height()/2)/10;
pitch = clamp(pitch,-80,80);
//Reset Mouse Position to Center of Screen
var center_x = display_get_width()/2;
var center_y = display_get_height()/2;
display_mouse_set(center_x,center_y);
}
//Calculate Camera Turning
var d = degtorad(direction);
var zd = degtorad(pitch);
xto = x+cos(d) * abs(sin(zd)+sign(-pitch));
yto = y-sin(d) * abs(sin(zd)+sign(-pitch));
zto = height + sin(zd);
//Mouse-Look Direction Controls
var lock = !keyboard_check(vk_alt);
if (lock)
{
//Calculate Direction
direction -= (display_mouse_get_x()-display_get_width()/2)/10;
pitch -= (display_mouse_get_y()-display_get_height()/2)/10;
pitch = clamp(pitch,-80,80);
//Reset Mouse Position to Center of Screen
var center_x = display_get_width()/2;
var center_y = display_get_height()/2;
display_mouse_set(center_x,center_y);
}
//Calculate Camera Turning
var d = degtorad(direction);
var zd = degtorad(pitch);
xto = x+cos(d) * abs(sin(zd)+sign(-pitch));
yto = y-sin(d) * abs(sin(zd)+sign(-pitch));
zto = height + sin(zd);
The Chest Object
///CREATE EVENT
closed_model = d3d_model_create();
open_model = d3d_model_create();
d3d_model_load(closed_model, "chest_1_closed.gmmod");
d3d_model_load(open_model, "chest_1_open.gmmod");
current_model = closed_model;
z = 0;
height = 10;
x_size = sprite_get_width(mask_index)*image_xscale; // for collisions, but i stripped that out too.
y_size = sprite_get_height(mask_index)*image_yscale; //....
///DRAW EVENT
d3d_model_draw(current_model,x,y,0,background_get_texture(tex_chest_1));
closed_model = d3d_model_create();
open_model = d3d_model_create();
d3d_model_load(closed_model, "chest_1_closed.gmmod");
d3d_model_load(open_model, "chest_1_open.gmmod");
current_model = closed_model;
z = 0;
height = 10;
x_size = sprite_get_width(mask_index)*image_xscale; // for collisions, but i stripped that out too.
y_size = sprite_get_height(mask_index)*image_yscale; //....
///DRAW EVENT
d3d_model_draw(current_model,x,y,0,background_get_texture(tex_chest_1));
The Floor Object (stretchable)
///CREATE EVENT
tex_img = background_get_texture(tex_cave_floor_1);
z = -5; //negative to give it thickness within code only
height = 5;
x_size = sprite_get_width(mask_index)*image_xscale; // for collisions, but i stripped that out too.
y_size = sprite_get_height(mask_index)*image_yscale; //....
///DRAW EVENT
var w = image_xscale*16;
var h = image_yscale*16;
d3d_draw_floor(x, y+h, z+height, x+w,y ,z+height, tex_img ,w/16, h/16);
tex_img = background_get_texture(tex_cave_floor_1);
z = -5; //negative to give it thickness within code only
height = 5;
x_size = sprite_get_width(mask_index)*image_xscale; // for collisions, but i stripped that out too.
y_size = sprite_get_height(mask_index)*image_yscale; //....
///DRAW EVENT
var w = image_xscale*16;
var h = image_yscale*16;
d3d_draw_floor(x, y+h, z+height, x+w,y ,z+height, tex_img ,w/16, h/16);
So there it is... just three objects. And again, this was working fine, but obviously there's something I'm having a brain fog about now, so I'm hoping the community can help me clear it.
Last edited: