I need a semi-transparent 3D sphere around another sphere. How do I do that?
Regarding the lighting issue, look at the two images One is unlit another is lit by a point light.
What is causing the issue? How do I correct it?
Here is the code I have written for it.
from panda3d.core import loadPrcFile
loadPrcFile("config/conf.prc")
from direct.showbase.ShowBase import ShowBase
# from panda3d.core import NodePath
from panda3d.core import PointLight, AmbientLight
from math import sin, cos
class MyGame(ShowBase):
def __init__(self):
super().__init__()
self.cam.setPos(0, -500, 0)
self.setBackgroundColor(0,0,0)
self.chara = self.loader.loadModel("planet_models/Earth")
self.chara.setScale(0.2)
self.chara.setPos(0, 0, -2.5)
self.chara.reparentTo(self.render)
self.charaNode = self.chara.node()
self.sphere_light = self.loader.loadModel("models/misc/sphere")
self.sphere_light.setScale(0.2)
self.sphere_light.setColor(1, 1, 1, 1)
self.sphere_light.setPos(0, -600, 0)
self.sphere_light.reparentTo(self.render)
plight = PointLight("plight")
plight.setColor((1, 1, 1, 1))
self.plnp = self.sphere_light.attachNewNode(plight)
# self.plightNodePath.setPos(2, 0, 0)
plight.setAttenuation((1, 0, 0))
self.chara.setLight(self.plnp)
alight = AmbientLight("alight")
alight.setColor((0.04, 0.04, 0.04, 1))
alnp = self.render.attachNewNode(alight)
self.chara.setLight(alnp)
self.taskMgr.add(self.move_light, "move-light")
def move_light(self, task):
ft = globalClock.getFrameTime()
self.sphere_light.setPos(cos(ft)*400, sin(ft)*400, 0)
return task.cont
game = MyGame()
game.run()
with the prc file being
win-size 1280 720
window-title First Trial
show-frame-rate-meter true
show-scene-graph-analyzer-meter true