Python panda3d和Geomipterain-在地形上加载纹理
我目前正在尝试从heightmap png文件创建Geomipterain,然后对其应用纹理,以下是我的代码:Python panda3d和Geomipterain-在地形上加载纹理,python,panda3d,Python,Panda3d,我目前正在尝试从heightmap png文件创建Geomipterain,然后对其应用纹理,以下是我的代码: from direct.showbase.ShowBase import ShowBase from panda3d.core import GeoMipTerrain, Texture class MyApp(ShowBase): def __init__(self): ShowBase.__init__(self) # Set up th
from direct.showbase.ShowBase import ShowBase
from panda3d.core import GeoMipTerrain, Texture
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# Set up the GeoMipTerrain
terrain = GeoMipTerrain("myDynamicTerrain")
terrain.setHeightfield("heightmap.png")
terrainTexture = self.loader.loadTexture("grass.png")
terrainTexture.setWrapU(Texture.WM_repeat)
terrainTexture.setWrapV(Texture.WM_repeat)
# Set terrain properties
terrain.setBlockSize(128)
terrain.setNear(20)
terrain.setFar(100)
terrain.setFocalPoint(self.camera)
# Store the root NodePath for convenience
root = terrain.getRoot()
root.reparentTo(self.render)
root.setSz(100)
# Generate it.
terrain.setColorMap(terrainTexture)
terrain.generate()
app = MyApp()
app.run()
一切正常,但我看不到地形上的纹理,只有纯白的颜色。
我可以将setColorMap行更改为:
terrain.setColorMap("grass.png")
它会工作得很好,但是,纹理非常模糊,没有正确调整大小。我希望能够操纵地形上的纹理,因此如果有人能帮助我找出纹理未渲染的原因,则首选第一种方法
谢谢 好吧,我终于明白了,纹理设置在地形上的效果不同:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import GeoMipTerrain, Texture, TextureStage
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# Set up the GeoMipTerrain
terrain = GeoMipTerrain("myDynamicTerrain")
terrain.setHeightfield("heightmap.png")
terrainTexture = self.loader.loadTexture("grass.png")
# Set terrain properties
terrain.setBlockSize(32)
terrain.setNear(20)
terrain.setFar(100)
terrain.setFocalPoint(self.camera)
# Store the root NodePath for convenience
root = terrain.getRoot()
root.setTexture(TextureStage.getDefault(), terrainTexture)
root.setTexScale(TextureStage.getDefault(), 100)
root.reparentTo(self.render)
root.setSz(1000)
# Generate it.
terrain.generate()
app = MyApp()
app.run()
此外,我建议将来在社区更为活跃的情况下寻找答案