Spam1985
Member
Game Maker Studio 1.4:
Hi folks. I made my first 3D model using Maarten Baert's Model Creator (thanks to NickKall for bringing that amazing program to my attention!)
It's a gun. It's created with a d3d_model_primitive_begin script.
Managed to get it into the game and follow the camera as the player looks around, but I am having some issues:
1) It clips through everything else in the game world.
2) It perfectly rotates with the camera horizontally, but when looking up or down, the rotation is off and becomes more extreme the higher/lower you look.
3) Should such primitives be created at the start of the game? Do they need to be created and destroyed as and when to save memory?
Thanks for reading and any help is much appreciated!
///Player's Draw Event
///Relevant Step Event code
Hi folks. I made my first 3D model using Maarten Baert's Model Creator (thanks to NickKall for bringing that amazing program to my attention!)
It's a gun. It's created with a d3d_model_primitive_begin script.
Managed to get it into the game and follow the camera as the player looks around, but I am having some issues:
1) It clips through everything else in the game world.
2) It perfectly rotates with the camera horizontally, but when looking up or down, the rotation is off and becomes more extreme the higher/lower you look.
3) Should such primitives be created at the start of the game? Do they need to be created and destroyed as and when to save memory?
Thanks for reading and any help is much appreciated!
///Player's Draw Event
GML:
//camera
d3d_set_projection_ext(x, y, z + eyeLevel, xto, yto, zto, 0, 0 , 1, fov, aspectRatio, 1, 1500);
//draw gun
d3d_transform_set_identity();
d3d_transform_add_rotation_x(-zDir); //rotates the gun vertically (not working properly!)
d3d_transform_add_rotation_y(0);
d3d_transform_add_rotation_z(direction + 90); //rotates gun horizontally (works!)
d3d_transform_add_translation(x,y,z);
d3d_model_draw(global.gun,-15,5,25,background_get_texture(tex));
d3d_transform_set_identity();
GML:
zDir -= (display_mouse_get_y() - display_get_height()/2) / 10;
//clamp zDir
zDir = clamp(zDir, -80, 80);
//set xto, yto, zto...
var d = degtorad(direction);
var zd = degtorad(zDir);
xto = x + cos(d) * abs(sin(zd) + sign(-zDir));
yto = y - sin(d) * abs(sin(zd) + sign(-zDir));
Last edited: