Intermediate tutorials 1 - Problem with scale

Nosferax

11-08-2009 03:09:00

hey there,

I'm trying to run the intermediate tutorial 1 and i'm having problems with the scale attribute of entities (very basic indeed). The entities don't seem to rescale themselves. At this point when I run the application I have one robot(ninja) and 3 VERY big knots. too big. I ran this tutorial under C++ Ogre and I know something is wrong. Here's my code, but I pretty much copy and pasted it from wiki. Is there something that changed or something that I didn't understand ?

Thanks!

Nox


#!/usr/bin/env python
# This code is Public Domain.
"""Python-Ogre Intermediate Tutorial 01: Animation, Walking Between Points, and Basic Quaternions."""

import ogre.renderer.OGRE as ogre
import SampleFramework as sf

class TutorialFrameListener(sf.FrameListener):
"""A FrameListener class that handles basic user input."""

def __init__(self, win, cam, sc, ent, walk):
# Subclass any Python-Ogre class and you must call its constructor.
sf.FrameListener.__init__(self, win, cam)

self.entity = ent # The entity we are animating
self.node = sc # The SceneNode that the Entity is attached to
self.walklist = walk # The list of points we are walking to

def nextLocation(self):
return True

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

class TutorialApplication(sf.Application):
"""Application class."""

def _createScene(self):
sceneManager = self.sceneManager
# Setup the ambient light.
sceneManager.ambientLight = (1.0, 1.0, 1.0)

# Create the entity
self.entity = sceneManager.createEntity('Ninja', 'ninja.mesh')

# Create the scene node and attach the entity to it
self.node = sceneManager.getRootSceneNode().createChildSceneNode('RobotNode', (0, 0, 25))
self.node.attachObject(self.entity)

# Create the walking list
self.walklist = []
self.walklist.append(ogre.Vector3(550, 0, 50))
self.walklist.append(ogre.Vector3(-100, 0, -200))

# Add some objects so we can see movement
knotEnt = sceneManager.createEntity('Knot1', 'knot.mesh')
knotNode = sceneManager.getRootSceneNode().createChildSceneNode('Knot1Node', (0, -10, 25))
knotNode.attachObject(knotEnt)
knotNode.scale = (0.1, 0.1, 0.1)

knotEnt = sceneManager.createEntity('Knot2', 'knot.mesh')
knotNode = sceneManager.getRootSceneNode().createChildSceneNode('Knot2Node', (550, -10, 50))
knotNode.attachObject(knotEnt)
knotNode.scale = (.1, .1, .1)

knotEnt = sceneManager.createEntity('Knot3', 'knot.mesh')
knotNode = sceneManager.getRootSceneNode().createChildSceneNode('Knot3Node', (-100, -10, -200))
knotNode.attachObject(knotEnt)
knotNode.scale = (.1, .1, .1)

# Set the camera to look at our handiwork
self.camera.position = (90, 280, 535)
self.camera.pitch(ogre.Degree(-30))
self.camera.yaw(ogre.Degree(-15))

def _createCamera(self):
self.camera = self.sceneManager.createCamera('PlayerCam')

def _createFrameListener(self):
self.frameListener = TutorialFrameListener(self.renderWindow,
self.camera,
self.node,
self.entity,
self.walklist
)
self.root.addFrameListener(self.frameListener)
self.frameListener.showDebugOverlay(True)

if __name__ == '__main__':
ta = TutorialApplication()
ta.go()

Nosferax

18-08-2009 16:22:30

Basically it all boils down to this : Is there any reason the following call might not be executed properly ??

knotNode.scale = (0.1, 0.1, 0.1)

Nosferax

19-08-2009 01:20:26

Basically it all boils down to this : Is there any reason the following call might not be executed properly ??

knotNode.scale = (0.1, 0.1, 0.1)


OK, after some more toying around I found out the real call is knotNode.setScale(0.1,0.1,0.1)

I thought it was supposed to work just with .scale ?