|
Post by Andrea Monacchi on May 11, 2011 18:01:48 GMT -5
Hi everyone, Was someone of you able to complete successfully the point 8 of lab 4 using ODE for the physical management?
Bye
|
|
|
Post by David Sorrentino on May 12, 2011 11:42:49 GMT -5
Ok, solved. Now it works! David & Andrea
|
|
emiliano
New Member
Get rich or die trading.
Posts: 21
|
Post by emiliano on May 14, 2011 10:31:10 GMT -5
Hi folks I'm stuck in implementing the space open and closing event Can you gimme a little help? I've tried inserting all the code of set_door in the constructor, but it doesn't work (basically the boolean always remains false i think).. I tried to build this little method but is not working... Attachments:
|
|
|
Post by Samuele Rilli on May 16, 2011 3:43:29 GMT -5
hi emiliano, I've seen and tried to fix you program; i'll try to explain. If i'm not wrong, in order to assign funcions that handle events, the accept call should be done this way: base.accept(<event>, <hander_fun>, <param_list>) the <param_list> is an optional array that allows to specifies the input of the function (if it has): <param_list>: [param_1, param_2... param_n] So, according to your "set_door" funcion, your accept should be: base.accept("space", self.set_door, [door]) Also i've set the "boolean_open" in "set_door" as a class variable (using "self"), otherwise it could not store its value once you go outside the method. See the attachment (beware: i've changed the path when loading the factoryfloor.egg model to make it work on my subdirectories) Hope this help. Good luck! Attachments:
|
|
|
Post by Hannes Vilhjalmsson on May 16, 2011 3:44:23 GMT -5
Hi Emiliano,
There are several things you need to fix:
1. Create the two instances of LerpPosInterval in the constructor of the factory and store them as member variables. Otherwise they will only exist inside your "set_door" function and won't move once you leave that function.
2. In line 24, now you don't need to pass the "door" since you can create the LerpPosIntervals in the constructor itself.
3. Also make "boolean_open" a member variable of factory and initialize it in the constructor. If you take a look at your line 75, it makes little sense to intitialise the variable there and then immediately ask whether it's false, since you just made it false.
4. After you check whether "boolean_open" is false or true, just call the start method of the intervals directly, there is no need to change the handling of the "space" message. The idea is that the "set_door" function will always do the right thing when you press space bar, based on the state of the "boolean_open" variable, which you have to remember to change.
Hope that helps. I have the feeling that you are not making use of class member variables in Python. See if you find some documentation about assigning values to member variables and using them across different member functions.
Cheers,
- hannes högni
|
|
|
Post by Hannes Vilhjalmsson on May 16, 2011 4:04:44 GMT -5
...looks like Samuele and I were replying at the same time ;-)
|
|
emiliano
New Member
Get rich or die trading.
Posts: 21
|
Post by emiliano on May 16, 2011 7:36:10 GMT -5
I changed what you asked me but still doesn't work! I even used the print methods to be sure where the instruction flow goes... Attachments:
|
|