Manual

control3d

Enable/disable 3D mode
Enter or leave 3D mode. If you want to go 3D, perform this action.

Set projection
Set the 3D projection. The camera will look from (xfrom,yfrom,zfrom) to (xto,yto,zto).

Edit projection
Modify the projection given above by changing the up vector to (xup,yup,zup) with a view angle of Angle degrees and an aspect ratio of Aspect and a maximum viewing distance of zfar.

Enter perspective projection
Create a perspective projection on the region (x,y) to (x+Width,y+Height) rotated by Angle degrees.

Enter orthographic projection
Create an orthographic projection on the region (x,y) to (x+Width,y+Height) rotated by Angle degrees.
Use this action together with to draw overlays.

Enable/disable culling
Turn backface culling on or off (off by default). When it is turned on, only one side of a polygon is drawn, dramatically increasing the performance. As a result shapes and models are only visible on the outside and walls and floors are only visible from one side.

Enable/disable hiding
Turn the depth buffer on or off (on by default). When it is turned off, every new shape is drawn in front of the former no matter the actual distance from the camera.
It is recommended to turn off the depth buffer when drawing on an orthographic projection.

Set fog
Turn fog on or off. When it is turned on, everything drawn up to a distance of Start is not affected, everything drawn beyond End will be completely filled with Color and everything drawn in between Start and End is partly coloured.

Enable/disable lighting
Turn lighting on or off. When it is turn on, lighting will be applied to everything you draw according to the specified lights.

Enable/disable light
Turn light Index on or off. A light can be specified as point source or directional source with the actions below.

Set point light
Set light Index as a point light at position (x,y,z) with the light reaching up to a distance of Range. The light's color is determined by .

Set directional light
Set light Index as an ambient light in the direction of (dx,dy, dz).
Use the direction (0,0,-1) for lighting from above. The light's color is determined by .

Transformations

Translate over X/Y/Z
Move the current origin by Amount along the x, y or z axis. Use to move along all the axes at once.

Rotate over X/Y/Z
Rotate around the origin by Amount degrees along the x, y or z axis.
For example: use followed by to draw a shape rotated around its centre at the right position.

Add translation
Move the current origin to (x,y,z).

Scale
Change the scaling of coordinates.

Reset transformation
Reset all transformations.

draw3d

By default shapes are just filled with the drawing color as determined by . You can use any of , or to draw shapes with a texture.

Draw wall
Draw a wall from (x1,y1,z1) to (x2,y2,z2).

Draw floor
Draw a floor from (x1,y1,z1) to (x2,y2,z2).

Draw block
Draw a block from (x1,y1,z1) to (x2,y2,z2).

Draw ellipsoid
Draw an ellipsoid - a stretched sphere - from (x1,y1,z1) to (x2,y2,z2).

Draw cone
Draw a vertical cone from (x1,y1,z1) to (x2,y2,z2).

Draw cylinder
Draw a vertical cylinder from (x1,y1,z1) to (x2,y2,z2).

Options

Set texture from sprite
Set the image of a sprite as the texture from now on.

Set texture from background
Set a background as the texture from now on.

Set texture
Set the texture manually.
For example: set the texture of a surface with surface_get_texture.

Set precision
Set the drawing precision (24 by default) of rounded shapes, such as spheres and circles.

Set closed
Turn closed drawing on or off (on by default). When it is turned on, cylinders and cones are drawn with a top and bottom, otherwise this is left open.

Models

With this extension you can also use 3D models. Models can be loaded with after creating them.
You can also build a model yourself by drawing basic shapes within a block surrounded by .
Note: transformations are currently not applied within a modelling block (e.g. you cannot put a rotated shape inside a model), but this may change later on!

Create model
Create a model named Name. This name is stored globally, so you can use it anywhere.

Check model
Check if model Name exists and perform the next action if so.

Draw model
Draw model Name at (x,y,z).

Destroy model
Delete model Name.

Load model
Load a 3D model from a file into Name. By default Game Maker models (.mod, .gmmod) and Wavefront models (.obj) are supported.

Save model
Save model Name to a file.

Start model
Start drawing inside model Name. All basic shapes are put inside the model from here on.

End model
End drawing inside the model.

Functions

If needed, you can also perform the actions above and manipulate models with GML.
For example: drag3drop_model_get can be used to get the model index of a named model and pass it to another extension.

drag3drop_model_create(str)
Create a model named str. If the model already exists, it will be cleared.

drag3drop_model_exists(str)
Check whether the model named str exists.

drag3drop_model_destroy(str)
Destroy the model named str. Returns whether successful.

drag3drop_model_load(str, fname)
Load a 3D model from the file fname into str. By default Game Maker models (.mod, .gmmod) and Wavefront-models (.obj) are supported.

drag3drop_model_save(str, fname)
Save model str to the file fname.

drag3drop_model_get(str)
Get the index of the model named str.

drag3drop_model_bind(str, ind)
Bind model ind to the name str.

drag3drop_model_unbind(str)
Remove the binding of the model named str. Unlike drag3drop_model_destroy this function only removes the mapped name, so be sure to remove the model yourself.


Often you would like to get the coordinates of a point in the world as projected on the screen. The functions listed below aid you in doing so. To initialise the transformations, use drag3drop_set_projection_ext, which is also called when setting the projection with and .

drag3drop_set_projection_ext(xfrom, yfrom, zfrom, xto, yto, zto, xup, yup, zup, angle, aspect, znear, zfar)
Update the internal projection variables and set the projection. The arguments are the same as d3d_set_projection_ext.

drag3drop_point_get_distance(x, y, z)
Returns the depth of a point along the camera's centre of view.

drag3drop_point_get_visible(x, y, z)
Returns whether a point is visible, i.e. between znear and zfar.

drag3drop_point_get_x(x, y, z)
Get the x coordinate of a point as projected on the screen.

drag3drop_point_get_y(x, y, z)
Get the y coordinate of a point as projected on the screen.