Pythonizing remaining tutorials

alextreme

24-05-2008 16:44:55

Hi all!

After figuring out how to compile python-ogre, I happily started following the tutorials on the wiki. From Intermediate tutorial 2 onwards however they weren't yet updated for python-ogre (they were the same C++ tutorials as on the main ogre wiki).

Over the last few days I've been slowly working on python-versions of the C++ code (which I added to the remaining intermediate tutorials) and I rewrote (to start off with) Intermediate tutorial 2 for Python.

I would appreciate it if someone with more (python-)Ogre experience would take a look to see if I haven't made any large errors. If someone who (like me) is new to Ogre would give it a try and note any problems found, that too would be appreciated.

Thanks!

Alex

dedesite

25-05-2008 11:56:29

I think I could do that, I use Ogre since a couple of years now and even if I started in python, I think I can help ;).

First, is your code working? If it's the case, it's a good starting point :D.
Just post your code here and I'll test it.

Greetings,
Andreas

alextreme

25-05-2008 16:26:12

Great, TIA!

See the python-ogre wiki for the code.

I added a python-version of the code to intermediate tutorials 2, 3, 5 and 6 (4 was already converted), and rewrote intermediate tutorial 2. You can simply copy the final version of each tutorial's code and give it a try.

Zyzle

25-05-2008 17:57:15

Hey, great work on the tutorials.

While I'm quite busy with my own python-ogre project at the moment(although you might not think it if you've looked at the code) I'd be willing to help too. I've already converted a few of the tutorials from the main ogre wiki into python so I'll upload them as soon as I get the chance.

alextreme

25-05-2008 18:47:59

Thanks! I think python-ogre could really benefit from some effort on the tutorial-front, which is why I dived in. Looking forward to your tutorials as well.

As a side note, I added a Minimal Application code snippet to the wiki (with buffered events, OIS/CEGUI support and without the use of ExampleFrameListener/SampleFramework). The main ogre wiki has a number of these snippets and I hit a number of snags when setting up a base project, so it might be helpful for others starting out.

Zyzle

26-05-2008 03:14:30

Had a look over the intermediate tutorial 2 (sorry for the slow progress i have a lot on) and came up with a small problem. Namely that there are times while moving arround in the map that the camera will infact move below the terrain, I havent fully looked into the reason for this, but here is some code that'll fix it.

Change the frameStarted method to the following:


def frameStarted(self, evt):
if not sf.FrameListener.frameStarted(self, evt):
return False

camPos = self.camera.getPosition()

updateRay = ogre.Ray()
updateRay.setOrigin(camPos + ogre.Vector3(0,10,0))
updateRay.setDirection(ogre.Vector3.NEGATIVE_UNIT_Y)
self.raySceneQuery.Ray = updateRay

for queryResult in self.raySceneQuery.execute():
if queryResult.worldFragment is not None:
self.camera.setPosition(camPos.x, camPos.y - queryResult.distance + 40, camPos.z)
break
return True


This code is a little more verbose than it needs to be (you can set the origin and direction of the ray from the constructor) but since its a tutorial probably best to leave it as is.


The camera movement in the app also seems a little odd to me, I'll see what I can do about it later. Hope this was helpful :D

alextreme

29-05-2008 12:43:50

Hey Zyzle,

Thanks for working through the tutorial, I've updated it where you indicated. I have made some minor changes as I don't want to deviate too much from the C++ version. I do indeed remember some issues with the camera height and movement, but as I recall the C++ one wasn't perfect either ;)

In the future, feel free to update it directly on the wiki. I'll now work on updating the other tutorials.

cheers,

Alex

Zyzle

29-05-2008 23:00:48

To be honest I never actually looked at the C++ version of the tutorial heh :D

I think its better to have the tutorials as good as possible rather than completely mirroring he C++ one.

I also don't generally like editing other peoples wiki entries (I realise thats the whole point of a wiki, but still :oops: ).

alextreme

31-05-2008 14:26:38

Intermediate tutorial 3 is ready for scrutiny: http://wiki.python-ogre.org/index.php/I ... Tutorial_3

I agree with having the tutorials as good as possible, just as long as they complete the same task in Ogre.

And really, edit my pages as much as you want. If I wanted to write something in stone, I wouldn't put it on a wiki ;)

Zyzle

26-06-2008 10:19:02

I realise this is an old topic now but I thought I'd mention that I've recently ported over the 3rd Person camera tutorial from the C++ to here

http://wiki.python-ogre.org/index.php/3rd_Person_Camera_System_Tutorial

I haven't been going through the C++ tutorials in any particular order, just porting over the ones I need myself or find interesting.

If anyone has any requests for C++ tutorials you'd like to see on the python-ogre wiki send me a message and I'll do my best (my days are very empty atm :( ).