NAME

SDL::Tutorial::3DWorld::Camera - A movable viewpoint in the game world

SYNOPSIS

# Start the camera 1.5 metres above the ground, 10 metres back from
# the world origin, looking north and slightly downwards.
my $camera = SDL::Tutorial::3DWorld::Camera->new(
    X         => 0,
    Y         => 1.5,
    Z         => 10,
    angle     => 0,
    elevation => -5,
};

DESCRIPTION

The SDL::Tutorial::3DWorld::Camera represents the viewpoint that the user controls to move through the 3D world.

In this initial skeleton code, the camera is fixed and cannot be moved.

METHODS

new

# Start the camera at the origin, facing north and looking at the horizon
my $camera = SDL::Tutorial::3DWorld::Camera->new(
    X         => 0,
    Y         => 0,
    Z         => 0,
    angle     => 0,
    elevation => 0,
};

The new constructor creates a camera that serves as the primary abstraction for the viewpoint as it moves through the world.

X

The X accessor provides the location of the camera in metres on the east to west dimension within the 3D world. The positive direction is east.

Y

The Y accessor is location of the camera in metres on the vertical dimension within the 3D world. The positive direction is up.

Z

The Z accessor provides the location of the camera in metres on the north to south dimension within the 3D world. The positive direction is north.

angle

The angle accessor provides the direction the camera is facing on the horizontal plane within the 3D world. Positive indicates clockwise degrees from north. Thus 0 is north, 90 is east, 180 is south and 270 is west.

The angle is more correctly known as the "azimuth" but we prefer the simpler common term for a gaming API. For more details see http://en.wikipedia.org/wiki/Azimuth.

elevation

The elevation accessor provides the direction the camera is facing on the vertical plane. Positive indicates degrees above the horizon. Thus 0 is looking at the horizon, 90 is facing straight up, and -90 is facing straight down.

The elevation is more correctly known as the "altitude" but we prefer the simpler common term for a gaming API. For more details see see http://en.wikipedia.org/w/index.php?title=Altitude_(astronomy).

direction

The direction accessor provides a unitised geometric vector for where the camera is currently pointing. This vector does not have a rotational component so for any math requiring rotation you will need to naively assume that the camera rotational orientation is zero (i.e. when looking at the horizon camera up is geometric up along the positive Y axis)

SUPPORT

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SDL-Tutorial-3DWorld

AUTHOR

Adam Kennedy <adamk@cpan.org>

SEE ALSO

SDL, OpenGL

COPYRIGHT

Copyright 2010 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.