++ed by:
GARU

1 PAUSE user
1 non-PAUSE user.

Adam Kennedy

NAME

SDL::Tutorial::3DWorld::Actor - A moving object within the game world

SYNOPSIS

  # 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,
      );
  }

DESCRIPTION

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.

METHODS

new

  my $teapot = SDL::Tutorial::3DWorld::Actor->new;

The new constructor is used to create a new actor within the 3D World.

In the demonstration implementation, the default actor consists of a teapot.

X

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.

Y

The Y accessor is location of the actor 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.

position

The position accessor provides the location of the camera as a 3 element array reference of the structure [ X, Y, Z ].

box

The box method returns the bounding box for the object if it has one, relative to the position of the object.

bounding

The bounding method returns the bounding box for the object if it has one, relative to the world origin.

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.

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.