Reputation: 21
I realize a simple model of 2 colors (black horn with a yellow support) with Blender 3.0.0 which I export in * .0bj. When I open it with the 3D viewer I can see the colors appear. But, when I call it in Python (I use Pycharm 2021.3 and the 3D engine Panda3d 1.10.10) the model appears white. Moreover, it is no longer vertical but horizontal. See attached images.
from panda3d.core import loadPrcFile, AmbientLight
loadPrcFile("config/conf.prc")
from direct.showbase.ShowBase import ShowBase
class MyGame(ShowBase):
def __init__(self):
super().__init__()
pion = self.loader.loadModel("Models/Pion2.obj")
pion.setPos(0, 15, -1.5)
pion.reparentTo(self.render)
game = MyGame()
game.run()
Can you tell me how to get my 2 colors on my model with Panda3d ?
Upvotes: 2
Views: 531
Reputation: 538
I have had a similar experience with .obj
files in Panda3D that had been exported from Blender. However, I found that exporting in the .dae
format from Blender the texture is more likely to be preserved.
Upvotes: 0
Reputation: 11
I dont know about obj files. But if you are using gltf or glb files then you can get the texture by doing this
1.pip install panda3d-gltf 2.pip install panda3d-simplepbr
then in the main.py or whatever
import simplepbr
inside your game class
def __init__(self):
super().__init__()
simplepbr.init()
pion = self.loader.loadModel("Models/Pion2.glb") # or use gltf
pion.setPos(0, 15, -1.5)
pion.reparentTo(self.render)
after doing these you could see the texture in the model
Upvotes: 1