3D Drawing

This section details all the functions available for drawing primitives and shapes in 3D.

The problem with drawing in the traditional (2D) way is that a sprite or polygon always lies in the xy-plane, that is, all corners have the same depth. For true 3D you want to be able to have vertices at different depths, and this depth is called the z-axis. So from this moment on we will talk about z-coordinate rather than depth, and we will specify coordinates as (x,y,z) tuples. It should also be noted that unless the colour or alpha is set by the function itself, you can use draw_set_colour and draw_set_alpha to set the drawing colour and alpha of the object being drawn.

For drawing basic primitives in 3D mode with these x,y,z coordinates we have the following functions:

  1. d3d_primitive_begin
  2. d3d_vertex
  3. d3d_vertex_colour
  4. d3d_primitive_end

For drawing textured primitives in 3D mode with these x,y,z coordinates we have the following functions (to end drawing use the d3d_primitive_end() function above):

  1. d3d_primitive_begin_texture
  2. d3d_vertex_texture
  3. d3d_vertex_texture_colour

You are not limited to just drawing your own shapes made from primitives either , as GameMaker: Studio has a set of functions that allow you to draw pre-defined shapes at any point in the 3D environment, with (or without) a texture mapping too (note that these functions can also be used with backface culling switched on):

  1. d3d_draw_block
  2. d3d_draw_cylinder
  3. d3d_draw_cone
  4. d3d_draw_ellipsoid
  5. d3d_draw_wall
  6. d3d_draw_floor


Back: Working With 3D
Next: 3D Projections
© Copyright YoYo Games Ltd. 2018 All Rights Reserved