|Yo Frankie! | Crystal Space Tutorials|
Using Crystal Space + CEL + B2CS + Blenderby Dariusz Dawidowski
This tutorial shows solution how to make something practical using Apricot pipeline but doesn't teach details. Also note that tools are under heavy developing and some names or techniques can be outdated when you reading this. Always please refer Crystal Space , CEL , Blender2crystal and Blender manuals.
Step 1 - Crystal Space settings
So... that lazybones (you know - your artists) already made a character ! It's rigged and animated. But I bet they didn't read your guide :) so make sure that character has proper direction: face to you in the Front view, origin of the object is placed on floor - between character's legs, all necessary animations are added to NLA, all the names are clean and both object and armature are added to one group, no werid parenting (only standard armature->object), also position, rotation and scale are cleared/applied. You can create Blender material but don't apply any textures (will be created automatically). But most important is to load and map textures into UV editor using one UV channel. Aha, let's make a floor, just add simple plane with size, say 20x20 and some light. Now we can start.
> Use the file in SVN: pro/tutorials/scripting_character_01.blend
Enable Blender2Crystal: Scripts->Export->CrystalSpace, in the 3d viewport View->Space Handler Scripts->Event: blender2crystal.py, make sure that Script Links are enabled: Buttons window: Scripts: Scriptlinks: Enable Script Links.
Character is already properly detected as Crystal Space animesh, and armature as Crystal Space skeleton:
To validate properly animated character for Crystal Space let's check a couple of things. It's a good habit to have root bone for a character (1). With this you can easily change direction of the character and correct other problems. Also use for this bone at least one key (2) but also not too much (one is perfect). No key can cause sometimes problems when you rotationg it in other animation, then switching back. Too big amout of keys can make possible correcting hard. Also be careful with very closely overlapping keys, sometimes there are two keys but looks like one and character "blinks" for a moment.
Because Blender materials are not compatibile with Crystal Space - first custom thing what we need to do is material setup. In the B2CS UI choose first icon in row and bottom vertical. Default Cg shader lighting_default is good enough so we don't need to change it. Diffuse texture is necessary, you can additionally add specular and normalmap textures by pushing 'add', typing name 'tex specular' or 'tex normal' and picking choosen texture.
You can preview how it looks rended by Crystal Space. Choose last green icon in row and press CTRL+V, scene will be exported and showed after a couple of seconds. This is Crystal Space embended inside Blender window.
Step 2 - Crystal Entity Layer settings
After basic visual setup now we can put life into our character. CEL tab is under second icon in row.
> Use the file in SVN: pro/tutorials/scripting_character_02.blend
Activate this object as entity and also as player. Entity means this object 'lives' executing some logic.
Go to second vertical tab, here we can add property classes which are components to build an entity. So we have components for walking, cameras, navigating, physics, sounds, neural networks, even for cars and hovers. CEL has already a lot of pre-defined Property Classes like that, but you can make also your custom one in C++ or Python. By default B2CS creates DefaultCamera for a player, but delete it (click red 'x'). To make basic character we need 5 standard CEL Property Classes. you can add them by clicking 'add pc' and choosing proper one from menu.
To see all the property classes please refer CEL API documentation - search all methods with name celPc*.
Property Classes have Properties and Actions which are in tabs below Property Class name. Properties contains some values, for example AnalogMotion's 'movespeed' which says how fact character can move. For a moment lets leave default values for everything. Actions doing something, for example AnalogMotion's 'SetAxis' activates movement in given axis.
So Property Classes are 'building blocks' of our character - now we need way to control character's logic during game. It's called Quest and you can find it in second horizontal tab and fourth vertical. CEL also contains set of standard pre-defined Quests, so choose 'add quest -> AnalogMotionControl.xml' it's Quest to standard control character using keyboard arrows, and it's good enough for a beginning. One more hidden property class will be added by B2CS called 'Quest' which contains quest name and settings.
Step 3 - Run
Open Scripts window with Crystal Space. Optionally if Crystal Space is not loaded into memory - you can do it initially (but probably should be at this step already because 3d View overlay making this too):
After compilation by default Virtual Clock is disabled (game is paused), so enable it to play game. Now we can play Crystal Space game inside Blender window. Make sure that mouse cursor is inside this window to get proper input (all standard Blender input will be disabled and redirected to Crystal Space).
Step 4 - Animation settings
Probably you noticed that animation is more or less random. It's because you need to make map of animations, name, set priorities and states also optional speed.
> Use the file in SVN: pro/tutorials/scripting_character_03.blend
Now we can create animation graph for our character.
Keys: C - create new node, D - Delete node, LMB - select/create connection, MMB - move node/view, RMB - clean connection
Open 3d window, select Armature and assign it to your new animation graph in the b2cs overlay:
Done. You have first simple animation. Now add also 'walk' as excersise so we have two basic animations already.
Step 5 - Quest system
Now we can take a closer look on standard quest AnalogMotionControl.xml.
Quest is decision system, it's kind of 'router' - can take some input and decide what reaction give as output. Every Entity in CEL can send and receive message and this is most useful feature for a quest.
How it works ?