|
|
|
Return to General Discussion
by donkeykong » Tue Mar 13, 2012 11:29 am
- Code: Select all
from math import pi, sin, cos from pandac.PandaModules import * from direct.showbase.DirectObject import DirectObject from direct.showbase.ShowBase import ShowBase from direct.task import Task from direct.actor.Actor import Actor class MyApp(ShowBase): def __init__(self): ShowBase.__init__(self) self.keyMap = {"mouse1":0 , "mouse3":0 , "left":0 , "right":0 , "up":0 , "down":0} self.accept("escape", sys.exit, [0]) # Load the environment model. self.environ = self.loader.loadModel("models/environment") # Reparent the model to render. self.environ.reparentTo(self.render) # Apply scale and position transforms on the model. self.environ.setScale(0.25, 0.25, 0.25) self.environ.setPos(-8, 42, 0) # Add the spinCameraTask procedure to the task manager. self.taskMgr.add(self.spinCameraTask, "SpinCameraTask") # Load and transform the panda actor. self.pandaActor = Actor("models/panda-model", {"walk": "models/panda-walk4"}) self.pandaActor.setScale(0.005, 0.005, 0.005) self.pandaActor.reparentTo(self.render) # Loop its animation. self.pandaActor.loop("walk") # Define a procedure to move the camera. def spinCameraTask(self, task): angleDegrees = task.time * 6.0 angleRadians = angleDegrees * (pi / 180.0) self.camera.setPos(20 * sin(angleRadians), -20.0 * cos(angleRadians), 3) self.camera.setHpr(angleDegrees, 0, 0) return Task.cont app = MyApp() app.run()[code][/code]
Last edited by donkeykong on Tue Mar 13, 2012 11:33 am, edited 4 times in total.
-
donkeykong
-
- Posts: 10
- Joined: Wed Feb 16, 2011 2:25 pm
by donkeykong » Tue Mar 13, 2012 11:31 am
self.keyMap = {"mouse1":0 , "mouse3":0 , "left":0 , "right":0 , "up":0 , "down":0}
indentation error.
i can't put it.
it just gives me a wrong answer
this is so frustrating.
i forgot this language
-
donkeykong
-
- Posts: 10
- Joined: Wed Feb 16, 2011 2:25 pm
by rdb » Tue Mar 13, 2012 12:26 pm
I advise learning Python before you attempt to use Panda3D. We could explain to you what exactly is wrong, but if you don't take the time to gain experience with Python, you will keep running into issues like these.
-
rdb
-
- Posts: 8547
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
by powerpup118 » Tue Mar 13, 2012 10:31 pm
I agree, it's much better to learn Python first.
Ensure that you never mix spaces(' ') and tabs('\t') inside your program, also make sure the proper indention is used.
Hope this helps,
~powerpup118
-

powerpup118
-
- Posts: 325
- Joined: Sat Apr 17, 2010 11:59 pm
by Yodaman Jer » Wed Mar 28, 2012 11:03 pm
That's the one thing that annoys me the most about Python. To avoid it I just always use the tab key when indenting lines of code. No need to count spaces with the space bar!
-Yodaman Jer
-

Yodaman Jer
-
- Posts: 22
- Joined: Tue Oct 18, 2011 10:34 am
by rdb » Thu Mar 29, 2012 2:17 am
Most editors out there can automatically convert tabs to spaces, or insert the right amount of spaces automatically when you hit the tab key.
-
rdb
-
- Posts: 8547
- Joined: Mon Dec 04, 2006 5:58 am
- Location: Netherlands
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 0 guests
| | |