Easiest part of all!

The camera is nothing but what you see on the screen.

You can move FWD & REV

You can turn LEFT & RIGHT

You can pitch UP & DOWN

All you have to do is to specify Angle# (0 to 360 Degree - Real Value) or Distance# (Real Value +Ve for FWD or -Ve for REV)

The following commands are self explanatory.

Move Camera Distance#

Turn Camera Left Angle#

Turn Camera Right Angle#

Pitch Camera Up Angle#

Pitch Camera Down Angle#

But what if you have to shift camera up & down vertically?

Well what we can do is find out current position of camera (X#,Y#,Z# co-ordinates) and RePosition camera with Y# co-ordinate with its value increased or decreased by the amount we need.

camera position x()

camera position y()

camera position z()

gives current co-ordinates in real value. We can store them in variables, lets suppose x#,y#,z#

Then use y# = y# + 10

And finally reposition using

Position Camera x#,y#,z#

You can use these commands as you wish to implement your logic.

How to keep camera always above the ground (matrix)?

Very important part because we want to walk, not float! What we have to do is to get x# & z# co-ordinates of camera. We won't bother with getting y# as it may be or may not be under the ground or at too much height above ground.

What we want to find is the ground level height (height of the tile your camera is standing on) at co-ordinates x# & z#. For that, we will use

get ground height (MatrixID,X# co-ordinates,Z# co-ordinates)

and store it in variable y#, and then reposition the camera.

The exact commands will be

x# = camera position x()

z# = camera position z()

y# = get ground height(1,x#,z#)

position camera x#,y#,z#

An Example

LoadMatrix("Proj1",1)

sync on

do

if upkey() = 1 then move camera 8

if downkey() = 1 then move camera -8

if rightkey() = 1 then turn camera right 4

if leftkey() = 1 then turn camera left 4

x# = camera position x()

z# = camera position z()

y# = get ground height(1,x#,z#)

position camera x#,y#,z#

sync

loop

## Friday, April 6, 2007

Subscribe to:
Post Comments (Atom)

## No comments:

Post a Comment