panda3d中文问题

来源:互联网 发布:清华ubuntu源 编辑:程序博客网 时间:2024/04/30 18:49

1. 在$PANDA3D_HOME/etc/Config.prc最后添加

 

text-encoding utf8
text-default-font /c/Windows/Fonts/simsun.ttc

 

2. 在每个.py文件头加:#encoding=utf-8

 

3. .py文件必须是utf-8格式的

 

例子:

#encoding=utf-8
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.gui.DirectGui import *
from pandac.PandaModules import *
from direct.gui.OnscreenText import OnscreenText

class World(DirectObject):
  def __init__(self):
    text = TextNode('node name')
    text.setText('中国')
    textNodePath = aspect2d.attachNewNode(text)
    textNodePath.setScale(0.07)

w = World()

run()