[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Written by Jorrit Tyberghein, (jorrit.tyberghein@uz.kuleuven.ac.be).
A 2D Sprite is basically a polygon that always faces the camera. There are some special effects that you can do with this but it is really very simple otherwise.
The following SCF class names are used (for CS_LOAD_PLUGIN()
):
Objects in this plugin implement the following SCF interfaces (get with
SCF_QUERY_INTERFACE()
):
Use the SCF interface `iSprite2DFactoryState' to access settings for a 2D sprite factory. The definition of this interface can be found in `CS/include/imesh/sprite2d.h' and that is also the include file you need to include in your applications to use this plugin. Using this interface you can access the material, blending mode (mixmode), and lighting settings.
<lighting>yes/no</lighting>
<material>materialname</material>
<mixmode><mode /></mixmode>
<uvanimation name=uvanimationname><frame ...> ...
<frame><duration><vertices ...> ...
<frame name="framename"> <duration>milliseconds</duration> <v u="" v="" /> ... u,v coo list </frame> |
`iSprite2DState' is the SCF interface that you can use to set/get settings for a 2D sprite object. The definition of this interface can be found in `CS/include/imesh/sprite2d.h' and that is also the include file you need to include in your applications to use this plugin. Using this interface you can access the material, blending mode (mixmode), lighting settings, and also the vertices of the 2D polygon controlled by this plugin.
<factory>factoryname</factory>
<mixmode><mode /></mixmode>
<material>materialname</material>
<lighting>yes/no</lighting>
vertices <v x="" y="" /> ...
<uv u="" v="" />
<color red="" green="" blue="" />
<animate> ...
<animate name="animationname"> <timing>milliseconds</timing> <loop>yes/no</loop> </animate> |
This is how our world file looks:
<world> <textures> <texture name="blow"> <file>blow.png</file> </texture> </textures> <materials> <material name="explosion"> <texture>blow</texture> </material> </materials> <meshobj name="Explosion"> <plugin>crystalspace.mesh.loader.factory.sprite.2d</plugin> <params> <material>explosion</material> <uvanimation name="boom"> <frame name="first"> <duration>100</duration> <v u="0" v="0" /> <v u="0.5" v="0" /> <v u="0.5" v="0.5" /> <v u="0" v="0.5" /> </frame> <frame name="second"> <duration>100</duration> <v u="0.5" v="0" /> <v u="1" v="0" /> <v u="1" v="0.5" /> <v u="0.5" v="0.5" /> </frame> <frame name="third"> <duration>100</duration> <v u="0" v="0.5" /> <v u="0.5" v="0.5" /> <v u="0.5" v="1" /> <v u="0" v="1" /> </frame> <frame name="fourth"> <duration>100</duration> <v u="0.5" v="0.5" /> <v u="1" v="0.5" /> <v u="1" v="1" /> <v u="0.5" v="1" /> </frame> </uvanimation> </params> </meshobj> <sector name="space"> <!-- define all the stuff in space ... and now one of the enemies right after we met him --> <meshobj name="Kaboom"> <plugin>crystalspace.mesh.loader.sprite.2d</plugin> <params> <v x="-1" y="1" /> <v x="1" y="1" /> <v x="1" y="-1" /> <v x="-1" y="-1" /> <uv u="0" v="0" /> <uv u="1" v="0" /> <uv u="1" v="1" /> <uv u="0" v="1" /> <color red="1" green="1" blue="1" /> <color red="1" green="1" blue="1" /> <color red="1" green="1" blue="1" /> <color red="1" green="1" blue="1" /> <lighting>no</lighting> <!-- show the animation, use the timings attached to the frames, loop --> <animate name="boom"> <timing>0</timing> <loop>yes</loop> </animate> </params> <move> <v x="0" y="0" z="0"> </move> </meshobj> </sector> </world> |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |