# This is just the version number and the documentation
package Games::3D;
# (C) by Tels
use strict;
use 5.8.1;
use vars qw/$VERSION/;
$VERSION = '0.10';
1;
__END__
=pod
=head1 NAME
Games::3D - a package containing an object system for (not only) 3D games
=head1 SYNOPSIS
use Games::3D::World;
my $world = Games::3D::World->new();
$world->save_to_file( $filename );
my $loaded = Games::3D::world->load_from_file( $filename );
my $thing1 = $world->add ( Games::3D::Thingy->new( ... ) );
my $thing2 = $world->add ( Games::3D::Thingy->new( ... ) );
$world->link($thing1, $thing2);
=head1 EXPORTS
Exports nothing.
=head1 INTRODUCTION
This package is just the basis documentation for all the classes contained
under Games::3D. It does not need to be used, unless you want to require a
specific version of this package.
=head1 DESCRIPTION
=head2 Overview
L provides you with a container class that will contain
every object in your game object system. This are primarily objects that
have states, change these states and need to announce the states to other
objects.
The L container also enables you to save and restore
snapshots of your objects system.
Basic things that you object system contains are derived from a class called
L. These can represent physical objects (buttons, levers,
doors, lights etc) as well as virtual objects (trigger, sensors, links,
markers, sound sources etc).
You can link Cs together, either directly or via L.
The links have some more features than direct linking, which are explained
below.
This package also provides you with L, a class for objects
that I state changes and act upon them. Or not, depending on the
sensor. Sensors are primarily used to watch for certain conditions and
then act when they are met. Examples are the death of an object, values
that go below a certain threshold etc.
State changes are transported in the object system with B.
A detailed explanation of all these basic building blocks follows below.
=head2 World and Things
The L is just a container to hold all the things. One
advantage of having a global container is that you can get a snapshot of
the world and save it to a file, and later restore it.
There are also certan performance advantages, for instance, if you want an
event to trigger if one object from a certain class of objects dies, you
can just ask the container to notify you. This is better than
linking every object of that class to each sensor to watch for this
particular state change.
The world contains Cs, Cs and C.
=head2 Templates
Templates are blueprints for objects. Each template describes a class of
objects, their valid settings as well as default values for these settings.
Cs belong to a class, and Templates descirbe these classes.
The template list is hirarchival, meaning templates for subclasses inherit
all settings from their parent class. Here is an example for a template list:
Virtual {
base = 'Games::3D::Thingy'
visible = off
}
Virtual::Link {
base = 'Games::3D::Link'
}
Virtual::Sensor {
base = 'Games::3D::Sensor'
}
Physical {
model = "default.md2"
visible = 1
}
Physical::Light {
r = FRACT=0
g = FRACT=0
b = FRACT=0
a = FRACT=0
state_0 = [ 75, a, 0 ]
state_1 = [ 250, a, 1 ]
}
The first three templates describe virtual (invisible) objects with different
base classes. The last two are physical (visible) objects (their base class
is automatically C).
Note that C inherits the C setting from
C!
There are a few settings that are common to all templates and don't need to
be defined - everything else can be defined at will, to describe complex game
environments. Here is an overview with their names and default values:
=over 2
=item visible = BOOL=off
Flag to tell whether the object is visible (needs rendering) or not.
=item active = BOOL=on
Flag to tell whether the object is active (receiving/relaying signals) or not.
=item base = STR="Games::3D::Thingy"
The underlying base object class.
=item id = INT=
The unqiue ID of the object. Will be automatically set. Read-only.
=item name = STR=
The name of the object. A 'Physical::Light' with ID=2 will have a default
name of 'Light #2'. The name is usefull for refering objects by name, instead
by the (possible changing) ID.
=item info = STR=
Short info text, that will be displayed in-game if someone looks at the
object.
=back
Since the Template defines an object with default settings, it is possible
to construct new objects in-game just by giving the template name.
=head2 Thingys
Each C has the ability to link itself to another object. If the
C receives a signal, it will pass it along to all other objects
that it is linked to (except for a few signals that the C will
act upon, but not pass along. See below).
From now on Cs will be simple called C