## G3D Utility

**PLEASE NOTE: these functions are available for GameMaker Studio 2 only!**

If you are not familiar with cameras (introduced in **GameMaker Studio 2**) and matrices you may find useful **Giavapps 3D** utility functions listed on this page.

## G3D Projection

**Giavapps 3D** provides the following functions for drawing projections. In order to use projections you must toggle **Enable Viewports** (in the **Room Editor** or through code with the function **view_enabled**) and make them visible.

**g3d_projection_set_perspective(ViewIndex, FieldOfView, FromX, FromY, FromZ, ToX, ToY, ToZ, UpX, UpY, UpZ)** This function sets a perspective projection for the specified view.

**ViewIndex:** Index of the view (number from** 0-7**).

**FieldOfView:** The angle of the field of view.

**FromX: **The x coordinate of the position to look from.

**FromY:** The y coordinate of the position to look from.

**FromZ:** The z coordinate of the position to look from.

**ToX:** The x coordinate of the position to look to.

**ToY:** The y coordinate of the position to look to.

**ToZ:** The z coordinate of the position to look to.

**UpX:** The x coordinate of the “up” vector.

**UpY:** The y coordinate of the “up” vector.

**UpZ:** The z coordinate of the “up” vector.

**g3d_projection_set_orthographic(ViewIndex, FromX, FromY)** This function sets an orthographic projection for the specified view.

**ViewIndex:** Index of the view (number from** 0-7**).

**FromX: **The x coordinate of the position to look from.

**FromY:** The y coordinate of the position to look from.

## G3D Transformations

**g3d_transform_set(X, Y, Z, RotationX, RotationY, RotationZ, ScaleX, ScaleY, ScaleZ)** This function sets a perspective projection for the specified view.

**X:** The x component of the transform vector.

**Y: **The y component of the transform vector.

**Z: **The z component of the transform vector.

**RotationX:** The x component of the transform vector.

**RotationY:** The y component of the transform vector.

**RotationZ: **The z component of the transform vector.

**ScaleX:** The x scale amount.

**ScaleY:** The y scale amount.

**ScaleZ: **The z scale amount.

**g3d_transform_set_identity()** This will set the origin of the 3D world to location **0,0,0** (which is the center of the world). This means that you can define an object at this point and then perform transforms on it to change its angle, scale, or position without worrying about the actual room coordinates. It is important to end transformation afterwards, using the same command.

## Code Examples

#### Setting a Perspective Projection

#### Setting Transformations

g3d_object_draw_self();//draws the G3D Object previously assigned to the instance

g3d_transform_set_identity();//reset transformations