Let's start Panda3D

Tweet


Panda3D is a software library for Python (and C++). This 3DCG library can be used for game programming.

The following command installs Panda3D. Please refer to other websites if you don't know pip.

pip install panda3d

Create python file shown below. If successed, the version is shown. Note that the file name should not be panda3d.

import panda3d
print(panda3d.__version__)

The programming environment must open windows. So, you cannot use Google Colab. It is not recommended to use Jupyter Notebook.

Let's make a program that views 3D object file. Prepare your 3D object file.

(This is just an example: Open http://mizu-cha.sakura.ne.jp/ Click [ふちゃきち] and click[ふちゃきち3Dモデルver1.03]. Unzip the downloaded file. Copy [Hutyakiti_hatON_animeVer.fbx] and [tex] included in [ふちゃきち3Dモデルver1.03] to working directory. )

Run the following python code. Change the input file name adequately.

from direct.showbase.ShowBase import ShowBase

class cgprogram(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        self.exitFunc=self.exit

        object=self.loader.loadModel('Hutyakiti_hatON_animeVer.fbx',noCache=True)
        object.reparentTo(self.render)

    def exit(self):
        self.taskMgr.remove(self.taskMgr.getAllTasks())
        self.destroy()

app=cgprogram()
app.run()

Panda3D cannot read a certain kind of 3D object files. Even if Panda3D can read the file, some files are not correctly read. Also, sometimes, you need to adequately modify the source code in order to adequately show the 3D object.


Back