im new to panda and learning from tutorial, though my python does not work, when i run the program it stays grey, no code is misstyped, though some things arent the color of the code on tutorial, im using panda3d v1.7.0 what python should i use???
you should be running the python that comes with panda. Are you sure that you have everything correct? Maybe you didnt instance the app if you made it a class. What is the code that you have?
I assume you are a windows user. Panda3d comes with python and should be located in C:\Panda3D-1.7. I suggest adding it to your system path to make accessing python much simpler.
The default panda window should be gray, however I do not understand the rest of your question.
If this is your first time coding then I suggest spending some time learning python first before you attempt to tackle panda.
Ahh so it is your first time with python.
I suggest following this tutorial over the next several days to help you learn how to use python: greenteapress.com/thinkpytho … index.html
If it is in your system path (I don’t remember if it is by default for windows, I code in linux), you should be able to just type python in the command prompt. Otherwise python.exe will be in c:\panda3d
You can write your code in any text editor, or use an editor that is tailored to writing Python.
You should really learn at least the basics of Python first before attempting something like Panda3D otherwise you will find it extremely difficult.
There are a number of converters, one of the most popular one is called Chicken for the free modeling program Blender. However blender does take some time to learn as well.
I suggest spending the time getting comfortable with python first, then learning some basics of panda, then tackle modeling.
If you are interested in some more real time help, and willing to be polite , you can get some more real time help in our chatroom.
ok i use blender so no prob, but ive tried diff editors mentiond and they all have a prob when i add spin camera, plz check code.
from math import pi, sin, cos
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# 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")
# 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), -10.0 * cos(angleRadians), 3)
self.camera.setHpr(angleDegrees, 0, 0)
return Task.cont
app = MyApp()
app.run()
Python uses whitespace (tabs, enters, etc) to help manage the code. This is what it should look like.
from math import pi, sin, cos
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# 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")
# 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), -10.0 * cos(angleRadians), 3)
self.camera.setHpr(angleDegrees, 0, 0)
return Task.cont
app = MyApp()
app.run()
See how it lines up? Make sure that your editor is set to use four spaces for tabs, not three.