NAME

SDL::Tutorial::3DWorld::Actor::TextureCube - Crates, companions and more...

DESCRIPTION

The TextureCube is one of the staples of classic 3D games.

Most famously, it can be used to create the ubiquitous and stereotypical crate model from classic first person shooters like Quake.

Since this is a relatively practical class you might actually realistically use in a 3D world in large numbers we will also attempt to make use of simple straight forward optimisation methods to get the cubes drawing relatively quickly.

For convenience when stacking, the original on a TextureCube is located at the centre of the bottom face of the cube. So given a surface plane at the original, a TextureCube located at the origin will in effect be sitting "on" the plane.

METHODS

new

# Sweet crate, familiar crate, err... flying crate?
my $crate = SDL::Tutorial::3DWorld::Actor::TextureCube->new(
    size     => 2,
    velocity => [ 0.0, 1.0, 0.1 ],
    material => {
        texture  => File::Spec->catfile(
            File::ShareDir::dist_dir('SDL::Tutorial::3DWorld'),
            'crate1.jpg',
        ),
    ),
);

The new constructor creates a new textured cube.

In addition to the usual SDL::Tutorial::3DWorld::Actor parameters, it takes some additional parameters.

The size parameter is the size of the cube in metres. Cubes grow in size upwards from the base in the vertical plane, and outwards from the centre on the horizontal plane.

The texture parameter should be the name of the file containing the texture to be used on all six sides of the cube. Alternatively, you can if you wish pass in your own SDL::Tutorial::3DWorld::Texture object.

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.