SDL::Tutorial::3DWorld::Actor - A moving object within the game world
# Create a vertical stack of teapots my @stack = (); foreach my $height ( 1 .. 10 ) { push @stack, SDL::Tutorial::3DWorld::Actor->new( X => 0, Y => $height * 0.30, # Each teapot is 30cm high Z => 0, ); }
Within the game, the term "Actor" is used to describe anything that has a shape and moves around the world based on it's own set of rules.
In practice, an actor could be anything from a bullet or a grenade flying through the air, to a fully articulated roaring dragon with flaming breath and it's own artificial intelligence.
To the game engine, all of these "actors" are basically the same. They are merely things that need to describe where they are and what they look like each time the engine wants to render a frame.
In this demonstration, the default actor is a 30cm x 30cm teapot. We are using a teapot because it is the "official" test mesh object for OpenGL and is built directly into the library itself via the glutCreateTeapot function.
glutCreateTeapot
my $teapot = SDL::Tutorial::3DWorld::Actor->new;
The new constructor is used to create a new actor within the 3D World.
new
In the demonstration implementation, the default actor consists of a teapot.
The X accessor provides the location of the actor in metres on the east to west dimension within the 3D world. The positive direction is east.
X
The Y accessor is location of the actor in metres on the vertical dimension within the 3D world. The positive direction is up.
Y
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.
Z
The position accessor provides the location of the camera as a 3 element array reference of the structure [ X, Y, Z ].
position
[ X, Y, Z ]
The box method returns the bounding box for the object if it has one, relative to the position of the object.
box
The bounding method returns the bounding box for the object if it has one, relative to the world origin.
bounding
The default implementation of the bounding method will take the actors position-relative bounding box and combine it with the relative position of the actor to get the world-relative box.
Bugs should be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SDL-Tutorial-3DWorld
Adam Kennedy <adamk@cpan.org>
SDL, OpenGL
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.
To install SDL::Tutorial::3DWorld, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL::Tutorial::3DWorld
CPAN shell
perl -MCPAN -e shell install SDL::Tutorial::3DWorld
For more information on module installation, please visit the detailed CPAN module installation guide.