Hi,
I’m making a planet, and I would like anything above a certain height to be a stony texture instead of a grassy texture.
This is more difficult with a sphere than with a plane, so I thought for a while, and eventually came up with the idea to project a texture from the centre of the planet.
rockProjector = render.attachNewNode(LensNode('rockProj'))
rockLens = PerspectiveLens()
#Ground level is about 2000
rockLens.setNearFar(2100, 3000)
#To cover half the planet, I will make another one for the other half
rockLens.setFov(180)
#rockProjector.node().showFrustum()
rockProjector.node().setLens(rockLens)
rockProjector.reparentTo(render)
rockProjector.setHpr(0, 0, 0)
rockTexture = loader.loadTexture('models/blue_cracks.jpg')
ts = TextureStage('rockTs')
ts.setMode(TextureStage.MDecal)
self.planetBR.projectTexture(ts, rockTexture, rockProjector)
To make the mountains only mountainous above a certain height, I added the setNearFar, though this does nothing. Even if I set the NearFar to 30000, 40000 (much greater than the radius of my planet), it still makes the planet rocky everywhere.
So my question is: Does setNearFar work with projectTexture()?
Also, in the panda API it says
setFar
void Lens::set_far(float far_distance);
Description: Defines the position of the far plane (or cylinder, sphere, whatever). Points farther from the lens than this may not be rendered.
How do I set the far plane to be a sphere. I think this would be better for limiting the view onto a spherical shape?
Thanks,
H4rtland