Hello
Good day to you.
I follow youtube to load a model but fail.
May I have your help to check my code?
Thank you.
from direct.showbase.ShowBase import ShowBase
import sys,os
from panda3d.core import Filename
mydir = Filename.fromOsSpecific(mydir).getFullpath()
class game(ShowBase):
def _init_(self):
super()._init_()
#I try to call full path, or short path, or /model/box。 None of them can success.
box = self.loader.loadModel(mydir + "/box")
box.setPos(0, 10, 0)
box.reparentTo(self.render)
my=game()
my.run()
Greetings, and welcome to the forum! I hope that you find your time here to be positive!
As to your question, the main problem that I see is that where you have “_init_”, you have only one underscore (i.e. “_”) on either side of “init”–there should be two.
That is, you have this:
def _init_(self):
super()._init_()
Instead of this:
def __init__(self):
super().__init__()
As a result, that function isn’t being automatically called as an initialisation function, and the code within–including the loading of the model–isn’t being run, I daresay.
1 Like
Hello Thaumaturge
That’s the reason.
Thank you very much for helping.
Thank you.
Best Regards.
Scott Gao
1 Like