08.11.2012 Views

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This might look a bit complicated. We look from the camera position (x,y), 10 above the<br />

ground. To determine a point in the correct direction we need to do a little arithmetic. This<br />

point is indicated by the next three parameters. Finally we use the up vector as above.<br />

One important remark! When <strong>Game</strong> <strong>Maker</strong> starts drawing a room it will set the view point<br />

back to the default position. So the first thing you must do when drawing the scene is set is to<br />

the projection you want. This must be done in a drawing event!<br />

There is also an extended version of the function above:<br />

d3d_set_projection_ext(xfrom,yfrom,zfrom,xto,yto,zto,xup,yu<br />

p,zup,angle,aspect,znear,zfar) An extended version of this function in<br />

which you also specify the angle defining the field of view, the aspect ratio<br />

between horizontal and vertical size of the view, and the near and far clipping<br />

planes.<br />

The additional parameters work as follows. If you specified the camera position, point to look<br />

at, and up vector, you can still change how wide the lens of the camera is. This is called the<br />

field of view. A reasonable value is 45 degrees and this is what is default taken. But you can<br />

change this if you like. Next you can specify the aspect ratio between the horizontal and<br />

vertical projection. Normally you want to use the same as the aspect ration of the room or<br />

view, e.g. 640/480. Finally you can indicate the clipping planes. Objects that are closer than<br />

znear to the camera are not drawn. Similar for objects further than zfar. It can be important<br />

to set these parameters to reasonable values because they also influence the precision of the<br />

z-comparisons. If you make the range too large the precision gets worse. Default we use 1<br />

and 32000. znear must be larger than 0!<br />

Sometimes you temporarily need a normal orthographic projection as is used when there is no<br />

3D. Or you want to return to the default perspective projection. For this you can use the<br />

following functions:<br />

d3d_set_projection_ortho(x,y,w,h,angle) Sets a normal<br />

orthographic projection of the indicated area in the room, rotated over the<br />

indicated angle.<br />

d3d_set_projection_perspective(x,y,w,h,angle) Sets a normal<br />

perspective projection of the indicated area in the room, rotated over the<br />

indicated angle.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!