SDL::Tutorial::3DWorld::Actor::TextureCube - Crates, companions and more...
The TextureCube is one of the staples of classic 3D games.
TextureCube
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.
# 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.
new
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.
size
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.
texture
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.