When drawing up sprites within a 2d xy world sprites work great but when you are entering not 3d programming and using sprites as menu and control items they sit along the 0 point of he z axis. Yes you can draw these items as a mesh and always rotate and align with the camera view but I would be nice if the xy coords were separated from the 3d plain and rendering area of the software. Thus meaning an xy coord for sprite always draws its coord in reference to the xy position of the screen regardless of camera movement

In the draw(), yoou just have to

1/ draw your 3d.

2/ `resetMatrix()`

.

3/ Draw your 2d.

This will do exactly what you need

Not quite. resetMatrix() only resets your model transforms, not you camera and perspective. I’ll look in my code tonight, but it’s some combination of the following commands from memory:

```
resetMatrix()
projectionMatrix(matrix())
viewMatrix(matrix())
ortho()
```

Text on screen needs

ortho

projectionMatrix

but I don’t know about drawing 2D…

Oh yes, i forgot about the camera that needs to be reset too.

@spacemonkey if you do manage to figure this out, can you please explain what these commands actually mean? What do they actually do?

I don’t have my iPad with me today, I’ll write up something tonight on it.

So in summary…

to move to a 3D view you do:

```
camera(camerax, cameray, cameraz, lookatx, lookaty, lookatz)
perspective()
```

to revert to 2D view

```
viewMatrix(matrix())
ortho()
```

The 3 matrixes in general achieve steps in the pipeline:

Meshes are expressed in object space, multiplying by the modelMatrix converts these into world space.

World space is multiplied by the viewMatrix which converts the coordinates into eye space.

Eye space is multiplied by the projectionMatrix which sorts out visual perspective and places the 3d objects onto a 2d screen.

The main one we play with is the modelMatrix for moving our meshes around the world, and using resetMatrix() after transforms or the stack with pushMatrix() and popMatrix(). Generally the view and projection are set once. However, by reverting to 2D or some other camera we can mix the content of a screen into different camera and perspectives.

The following will show you the commands and the debug window may give a little insight (paste into a draw function:

```
output.clear()
print("model matrix initial")
print(modelMatrix())
translate(5,40,10)
print("model matrix affected by translate, rotate and scale")
print(modelMatrix())
--reset the model matrix
resetMatrix()
print("model matrix reset to initial state")
print(modelMatrix())
print("view matrix initial")
print(viewMatrix())
camera(10,2,0,0,0,0)
print("view matrix changed by positioning the camera")
print(viewMatrix())
--reset the view matrix (there isn't a special function for this so we just set it to the identity matrix)
viewMatrix(matrix())
print("projection matrix initial state")
print(projectionMatrix())
perspective(50)
print("projection matrix adjusted to field of view")
print(projectionMatrix())
--reset the projectionMatrix
ortho()
print("projection matrix reset to initial state")
print(projectionMatrix())
```