Beginner Tutorials?

squeakypants

29-03-2007 20:44:38

Correct me if I'm wrong, but Python-Ogre is based on pyogre?

It seems like everything is done similar, but a lot of things are slightly changed (for example, instead of using ".position =" you use ".setPosition()". The beginner tutorials for pyogre were really good at teaching Ogre in the python environment, whereas just looking at python-ogre's demos tells me how to use Ogre in python, but I'm a noob and I don't know how to use Ogre in the first place :P

My point is, how would someone who doesn't know Ogre learn python-ogre?

andy

30-03-2007 02:33:54

No, Python-Ogre is not based upon PyOgre, they end up looking very simular because they wrap the same library however they are implemented very differently..

Having said that Python-Ogre does build on the great work done by the original PyOgre team in using the PyOgre demos etc as the basis for the Python-Ogre ones etc etc

We are in a transistion stage so the tutorials etc on the Wiki are broken -- however once we get version 1.0 out the door it's on the top of the list to update the tutorials and make life easier for new users...

Cheers
Andy

Game_Ender

30-03-2007 03:40:49

Why don't the setter's work Andy? I have always wondered that its quite an inconsistency in the API.

andy

30-03-2007 04:33:22

Which setters do you mean -- in fact so long as they don't overlap with C++ function names all the available getters and setter are exposed.

For example any (and all) of the following are valid..
camera.setPosition(1,2,2)
camera.setPostion(Vector3(1,2,2))
camera.position=1,2,2
camera.position=[1,2,2]
camera.position=(1,2,2)
camera.position=Vector3(1,2,2)

Cheers
Andy

squeakypants

31-03-2007 05:03:04

Which setters do you mean -- in fact so long as they don't overlap with C++ function names all the available getters and setter are exposed.

For example any (and all) of the following are valid..
camera.setPosition(1,2,2)
camera.setPostion(Vector3(1,2,2))
camera.position=1,2,2
camera.position=[1,2,2]
[b]camera.position=(1,2,2)[/b]
camera.position=Vector3(1,2,2)

Cheers
Andy


Well I've tried the bolded and it doesn't work. Only setPosition worked for me.

Also I'm on the 4th tutorial now and I only need to change a bit. ResourceManager = ResourceGroupManager. Also, loading the Terrain sceneManager was completely different.

andy

31-03-2007 07:52:59

Well I've tried the bolded and it doesn't work. Only setPosition worked for me.
Ah, that would be because the functionality was added post the 0.9 release :oops:

I'm trying to get out a 1.0 RC1 over the next couple of days that will include the setter enhancements plus all outstanding (known) issues resolved, and is built against the release version fo Ogre 1.4.

If you do happen to fix the tutorials could you update the wiki as you go ??

Cheers
Andy

squeakypants

31-03-2007 21:53:05

Should I copy the pages to a Python-Ogre namespace? Also, how do I make an account for the wiki? Registering is disabled.

Also, I'm having trouble with tutorial 4. I can't get inputDevice working.

One more thing: How do I begin working without the SampleFramework? Should I just use demo_blank as a base?

andy

01-04-2007 01:35:05

I'd suggest you spend your time learning the sample framework and work with the CameraTracking, Lighting, Smoke, Skyxxx demos as starting points...

Basically the tutorials are simply too out of date to be useful and the sample framework is reasonably clean and simple -- also by using the samepl framework you can focus on the 'Ogre' functionality and not worry about 'implementation'..

Having said that demo_basic and demo_spinner aren't bad places to start either :)

Cheers
Andy

squeakypants

01-04-2007 02:19:14

Okay, I'll check them out.

Any idea on the inputDevice? How do you set it up with the FrameListener? I can't find any demos that use it.

andy

01-04-2007 03:28:44

Demo_CameraTracking uses the FrameListener and callbacks
def _createFrameListener(self):
self.frameListener = CameraTrackListener(self.renderWindow, self.camera, self.animationState)
self.root.addFrameListener(self.frameListener)

class CameraTrackListener(sf.FrameListener):
def __init__(self, renderWindow, camera, animationState):
sf.FrameListener.__init__(self, renderWindow, camera)
self.animationState = animationState

OIS replaces InputDevice for input handling -- see Sky_Dome and Sky_Box for examples on handing additional input

squeakypants

01-04-2007 05:17:13

Sorry to keep asking. I've gotten the esc key working, but I can't get the mouse button working now!

class TutorialFrameListener(SampleFramework.FrameListener):
def __init__(self, renderWindow, camera, sceneManager):
SampleFramework.FrameListener.__init__(self, renderWindow, camera)
self.mouseDown = False
self.toggle = 0
self.camNode = camera.parentSceneNode.parentSceneNode
self.sceneManager = sceneManager
self.rotate = 0.13
self.move = 250

def frameStarted(self, frameEvent):
self.Keyboard.capture()
self.Mouse.capture()
return not self.Keyboard.isKeyDown(OIS.KC_ESCAPE)

currMouse = self.Mouse.getMouseButton(0)
if currMouse and not self.mouseDown:
light = self.sceneManager.getLight("Light1")
light.visible = not light.visible
self.mouseDown = currMouse


Any idea why it won't turn the light off?

andy

01-04-2007 07:03:52

When in doubt refer to sf_OIS.py...

def _isToggleMouseDown(self, Button, toggleTime = 1.0):
ms = self.Mouse.getMouseState()
if ms.buttonDown( Button ) and self.timeUntilNextToggle <=0:
self.timeUntilNextToggle = toggleTime
return True
return False


You have to do a getMouseState() ...

Now in your code it's never getting to the getMouseButton call anyway as you are returning in the line above.... I suspect you really want your return line after checking the mouse button

Cheers
Andy

squeakypants

01-04-2007 17:49:45

I'm guessing this is because I'm using 0.9, I can't find sf_OIS.py. Also, with this code:
def frameStarted(self, frameEvent):
self.Keyboard.capture()
self.Mouse.capture()
ms = self.Mouse.getMouseState()
if ms.buttonDown(0) and not self.mouseDown:
light = self.sceneManager.getLight("Light1")
light.visible = not light.visible
return True
self.mouseDown = ms.buttonDown(0)

return not self.Keyboard.isKeyDown(OIS.KC_ESCAPE)

I get this error:
"...\basic_4.py", line 51, in frameStarted
if ms.buttonDown(0) and not self.mouseDown:
Boost.Python.ArgumentError: Python argument types in
MouseState.buttonDown(MouseState, int)
did not match C++ signature:
buttonDown(struct OIS::MouseState {lvalue}, enum OIS::MouseButtonID button)


EDIT: I figured it out. Here is my final code:
ms = self.Mouse.getMouseState()
if ms.buttonDown(OIS.MB_Left) and not self.mouseDown:
light = self.sceneManager.getLight("Light1")
light.visible = not light.visible
self.mouseDown = ms.buttonDown(OIS.MB_Left)


I might do a complete rehaul of the Python-Ogre tutorials. I'll wait until RC1 though.