Page 1 of 4

Rocket-Ticket Questionthread (... haha)

Posted: Mon Apr 26, 2010 2:21 pm
by tyderion
didn't know how to name the thread because right now I have one specific problem after which the other questions might disappear.


Right now the Rocket (named SimpleRocket) is in the folder: modules\weapons\projectiles\
the RocketController "sits" in: \orxonox\controllers
while the weapon mode is in: \modules\weapons\weaponmodes\

In the RocketController-file I cannot include "weapons/projectiles/SimpleRocket.cc" but I need to do this because I make a new pointer to my rocket (similar to the DroneController) to control it.

In the case of the droneController this works, because the drone is in: /orxonox/worldentities

How can I include this file? is it not possible?

I hope you get what i mean ... for me it's quite confusing ...

Re: Rocket-Ticket Questionthread (... haha)

Posted: Mon Apr 26, 2010 7:03 pm
by x3n
do you need RocketController in src/orxonox or is it only needed in modules/weapons? because if the controller is only used by the weapon, i suggest to move the controller to modules/weapons.

however if you have to access the controller from within src/orxonox, we probably need an interface (i can't tell you right now how this interface would look like, because i don't know the actual problem, but interfaces are a common way to solve dependency problems).

Re: Rocket-Ticket Questionthread (... haha)

Posted: Tue Apr 27, 2010 5:36 am
by tyderion
ah. I think i only need it in modules/weapons ... I'll try that and put the controller there too. I'll post again after testing.
thanks for the suggestions :)

Re: Rocket-Ticket Questionthread (... haha)

Posted: Thu Apr 29, 2010 12:16 pm
by tyderion
ok ... now I was able to include all needed files but when compiling (after adjusting all includes and adding a function) there were ... strange errors.

Code: Select all

18>..\..\..\..\src\modules\weapons\RocketController.cc(58) : warning C4273: 'orxonox::RocketController::tick' : inconsistent dll linkage
18>        m:\orxonox\orxonox_vs\trunk\src\modules\weapons\RocketController.h(53) : see previous definition of 'tick'
it tells me I redefined tick as well as the initializerfunction. Once in the headerfile and once in the source file. This is wrong.
Somewhere something went wrong (inconsistent dll linkage) but I don't know what.
Thanks for helping :)

Re: Rocket-Ticket Questionthread (... haha)

Posted: Thu Apr 29, 2010 10:47 pm
by x3n
i'm not 100% sure, but i guess you have to change this:

Code: Select all

RocketController.h:32
-#include "OrxonoxPrereqs.h"
+#include "weapons/WeaponsPrereqs.h"

Code: Select all

RocketController.h:46
-    class _OrxonoxExport RocketController : public Controller, public Tickable
+    class _WeaponsExport RocketController : public Controller, public Tickable

Re: Rocket-Ticket Questionthread (... haha)

Posted: Fri Apr 30, 2010 12:40 pm
by tyderion
oh thanks now it compiles :)
okay now i struggle again with the problem that I'm not able to "spawn" a model of a rocket.
i get the following error:
Unhandled exception at 0x5ae8a4b4 (libweapons.dll) in orxonox.exe: 0xC0000005: Access violation reading location 0x00000000.

which originates in my RocketControllers call to one of the control-functions of the (I reckon not really existing) rocket.
I uploaded the newest files into the rocket branch.
What I'm trying to do right now is get a model of the rocket to spawn in "empty space" when trying to shoot a "SimpleRocket" (same button as rocket, T)

Re: Rocket-Ticket Questionthread (... haha)

Posted: Fri Apr 30, 2010 4:03 pm
by x3n
do you tell the RocketController which ControllableEntity it has to controll?

you probably have to call this->getController()->setControllableEntity(this); in SimpleRocket.cc after you created a controller.

Code: Select all

61	        RocketController* myRController = new RocketController(this);
62	        this->setController(myRController);
+ 	        this->getController()->setControllableEntity(this);
or
+ 	        myRController->setControllableEntity(this);

Re: Rocket-Ticket Questionthread (... haha)

Posted: Fri Apr 30, 2010 10:41 pm
by tyderion
this tells me no access

Code: Select all

+            this->getController()->setControllableEntity(this);
leads to

Code: Select all

1>SimpleRocket.cc
1>..\..\..\..\src\modules\weapons\projectiles\SimpleRocket.cc(65) : error C2248: 'orxonox::Controller::setControllableEntity' : cannot access protected member declared in class 'orxonox::Controller'
1>        M:\Orxonox\orxonox_VS\trunk\src\orxonox\controllers/Controller.h(63) : see declaration of 'orxonox::Controller::setControllableEntity'
1>        M:\Orxonox\orxonox_VS\trunk\src\orxonox\controllers/Controller.h(37) : see declaration of 'orxonox::Controller'

and this

Code: Select all

myRController->setControllableEntity(this);
leads to this

Code: Select all

1>SimpleRocket.cc
1>..\..\..\..\src\modules\weapons\projectiles\SimpleRocket.cc(66) : error C2065: 'myController' : undeclared identifier
1>..\..\..\..\src\modules\weapons\projectiles\SimpleRocket.cc(66) : error C2227: left of '->setControllableEntity' must point to class/struct/union/generic type
... i could add Simplerocket as a friendclass to the Controller ... but somehow that seems extremely ... "hack-ish" as well as unnecessary

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sat May 01, 2010 12:22 am
by x3n
ah yeah you're right. i'm a little unsure how this was intended to be handled (even though it was coded by me, but quite some time ago).

one option is, instead of creating a new SimpleRocket (and then create a controller within the constructor of SimpleRocket), create a new RocketController and then create a rocket in it's constructor. that way "setControllableEntity" would be called in the context of the controller and thus works with the "protected" keyword.

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sat May 01, 2010 10:39 am
by tyderion
ah yes doing it in this file resolves the access problems.
It now compiles without errors, but when invoking the "Rocketfire" (which creates a new rocketcontroller) nothing happens ingame.

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sat May 01, 2010 11:01 am
by greenman
i'm not sure, but i think the way you programmed it, rocketfire should create a new rocket and the rocket itself should create it's own controller, or am i wrong?

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sat May 01, 2010 12:57 pm
by tyderion
no i changed that. the rocket does nothing but initialize some default values.
the rocketfire should create a controller and the controller should create the rocket...

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sat May 01, 2010 1:06 pm
by greenman
then i would rather create rocket and controller both in rocketfire and tell them about the other.
like that you can easily select different controllers depending on the firemode or whatever and they don't need to create the rocket themself

edit: seems like that's not possible at the moment ^^

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sat May 01, 2010 1:08 pm
by x3n
tyderion wrote:ah yes doing it in this file resolves the access problems.
It now compiles without errors, but when invoking the "Rocketfire" (which creates a new rocketcontroller) nothing happens ingame.
i guess it spawns, but you don't see it, because it spawns in the middle of the level. you have to set position and orientation according to your weapon.

you already have this code in SimpleRocketFire.cc:

Code: Select all

68	        rocket->setOrientation(this->getMuzzleOrientation());
69	        rocket->setPosition(this->getMuzzlePosition());
now instead of rocket, use con->getControllableEntity() and it should work

Re: Rocket-Ticket Questionthread (... haha)

Posted: Sat May 01, 2010 4:17 pm
by tyderion
i changed that but still no rocked is visible.
I just tried to go back to the main menu for the first time after trying the "rocket" and orxonox crashes while trying to destroy the RocketController.
I attached a screenshot of the commandline output.