Thank you for the information. I got everything working.
For others interested in an example, I modified the walktut app to control the motion of the character + camera mode thought the Subscribe action.
There were three changes that I had to make to the example:
The key change was to add the following code to the end of the CreatePlayer function. It basically adds a wire that pipes actions from pcinput.standard to pcmove.actor.standard.
csRef<iPcWire> wire=scfQueryInterface<iPcWire>(pl->CreatePropertyClass(player_entity,"pclogic.wire"));
wire->AddInput("cel.input.forward");
wire->AddInput("cel.input.backward");
wire->AddInput("cel.input.rotateleft");
wire->AddInput("cel.input.rotateright");
wire->AddInput("cel.input.cammode");
wire->AddOutput(pl->FetchStringID("cel.move.actor.action.Subscribe"),0);
I had to include propclass/wire.h to use the iPcWire interface. However I also had to move the physicallayer/propclas.h include to the top. With it after the wire.h include, I got a compile error:[/li]
C++ ./out/linux/optimize/apps/tutorial/walktut/app.o
In file included from /home/kkrizka/Sources/cel-svn/apps/tutorial/walktut/app.cpp:10:0:
./include/propclass/wire.h:54:48: error: ‘iMessageChannel’ has not been declared
In file included from /home/kkrizka/Sources/cel-svn/apps/tutorial/walktut/app.cpp:10:0:
./include/propclass/wire.h:67:47: error: ‘iMessageChannel’ has not been declared
./include/propclass/wire.h:68:7: error: ‘iCelParameterBlock’ has not been declared
I'm guessing the error is from a missing include inside wire.h that will be fixed sometimes later?
Remove action handling from BehaviourPlayer. The behaviour layer is still needed for the inventory stuff, as the ShowInventory() is a custom function.
Is there any interest in me writing an update to the manual, so this information could become more readily available to new users of CEL like me?
The full patch is as follows (SVN revision 4903):
Index: apps/tutorial/walktut/behave.h
===================================================================
--- apps/tutorial/walktut/behave.h (revision 4903)
+++ apps/tutorial/walktut/behave.h (working copy)
@@ -115,15 +115,6 @@
class BehaviourPlayer : public BehaviourCommon
{
private:
- csStringID id_pccommandinput_forward1;
- csStringID id_pccommandinput_forward0;
- csStringID id_pccommandinput_backward1;
- csStringID id_pccommandinput_backward0;
- csStringID id_pccommandinput_rotateleft1;
- csStringID id_pccommandinput_rotateleft0;
- csStringID id_pccommandinput_rotateright1;
- csStringID id_pccommandinput_rotateright0;
- csStringID id_pccommandinput_cammode1;
csStringID id_pccommandinput_drop1;
csStringID id_pcinventory_addchild;
Index: apps/tutorial/walktut/app.cpp
===================================================================
--- apps/tutorial/walktut/app.cpp (revision 4903)
+++ apps/tutorial/walktut/app.cpp (working copy)
@@ -1,13 +1,14 @@
#include <crystalspace.h>
#include <celtool/initapp.h>
+#include <physicallayer/propclas.h>
#include <propclass/zone.h>
#include <propclass/camera.h>
#include <propclass/mesh.h>
#include <propclass/linmove.h>
#include <propclass/actormove.h>
#include <propclass/input.h>
-#include <physicallayer/propclas.h>
+#include <propclass/wire.h>
#include "app.h"
#include "behave.h"
@@ -101,6 +102,15 @@
pcinput->Bind ("m", "cammode");
pcinput->Bind ("d", "drop");
+ // Setup the inputs using wires
+ csRef<iPcWire> wire=scfQueryInterface<iPcWire>(pl->CreatePropertyClass(player_entity,"pclogic.wire"));
+ wire->AddInput("cel.input.forward");
+ wire->AddInput("cel.input.backward");
+ wire->AddInput("cel.input.rotateleft");
+ wire->AddInput("cel.input.rotateright");
+ wire->AddInput("cel.input.cammode");
+ wire->AddOutput(pl->FetchStringID("cel.move.actor.action.Subscribe"),0);
+
return true;
}
Index: apps/tutorial/walktut/behave.cpp
===================================================================
--- apps/tutorial/walktut/behave.cpp (revision 4903)
+++ apps/tutorial/walktut/behave.cpp (working copy)
@@ -93,15 +93,6 @@
BehaviourPlayer::BehaviourPlayer (iCelEntity* entity, BehaviourLayer* bl, iCelPlLayer* pl)
: BehaviourCommon (entity, bl, pl)
{
- id_pccommandinput_forward1 = pl->FetchStringID ("pccommandinput_forward1");
- id_pccommandinput_forward0 = pl->FetchStringID ("pccommandinput_forward0");
- id_pccommandinput_backward1 = pl->FetchStringID ("pccommandinput_backward1");
- id_pccommandinput_backward0 = pl->FetchStringID ("pccommandinput_backward0");
- id_pccommandinput_rotateleft1 = pl->FetchStringID ("pccommandinput_rotateleft1");
- id_pccommandinput_rotateleft0 = pl->FetchStringID ("pccommandinput_rotateleft0");
- id_pccommandinput_rotateright1 = pl->FetchStringID ("pccommandinput_rotateright1");
- id_pccommandinput_rotateright0 = pl->FetchStringID ("pccommandinput_rotateright0");
- id_pccommandinput_cammode1 = pl->FetchStringID ("pccommandinput_cammode1");
id_pccommandinput_drop1 = pl->FetchStringID ("pccommandinput_drop1");
id_pcinventory_addchild = pl->FetchStringID ("pcinventory_addchild");
@@ -177,25 +168,7 @@
{
GetActorMove ();
- if (msg_id == id_pccommandinput_forward1)
- pcactormove->Forward (true);
- else if (msg_id == id_pccommandinput_forward0)
- pcactormove->Forward (false);
- else if (msg_id == id_pccommandinput_backward1)
- pcactormove->Backward (true);
- else if (msg_id == id_pccommandinput_backward0)
- pcactormove->Backward (false);
- else if (msg_id == id_pccommandinput_rotateleft1)
- pcactormove->RotateLeft (true);
- else if (msg_id == id_pccommandinput_rotateleft0)
- pcactormove->RotateLeft (false);
- else if (msg_id == id_pccommandinput_rotateright1)
- pcactormove->RotateRight (true);
- else if (msg_id == id_pccommandinput_rotateright0)
- pcactormove->RotateRight (false);
- else if (msg_id == id_pccommandinput_cammode1)
- pcactormove->ToggleCameraMode ();
- else if (msg_id == id_pccommandinput_drop1)
+ if (msg_id == id_pccommandinput_drop1)
Drop ();
else if (msg_id == id_pcinventory_addchild)
{