Hi all,
I should get the render data to process it, so I’m trying to render to a texture buffer.
I followed the example on the manual I couldn’t make it work. When the step function is called it returns an empty object.
Any suggestion?
Thanks.
class ChronoPandaInterface(ShowBase):
ChBodyList = []
ModelList = []
def __init__(self):
# Initialize the ShowBase class from which we inherit, which will
# create a window and set up everything we need for rendering into it.
ShowBase.__init__(self)
mybuffer = base.win.makeTextureBuffer("Buffer", 512, 512)
mytexture = mybuffer.getTexture()
mybuffer.setSort(-100)
mycamera = base.makeCamera(mybuffer)
myscene = NodePath("My Scene")
mycamera.reparentTo(myscene)
self.texture = mybuffer.getTexture()
self.accept('escape', sys.exit) # Escape quits
self.disableMouse() # Disble mouse camera control
self.setupLights() # Setup default lighting
def setupLights(self): # This function sets up some default lighting
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor((.8, .8, .8, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(LVector3(0, 45, -45))
directionalLight.setColor((0.2, 0.2, 0.2, 1))
render.setLight(render.attachNewNode(directionalLight))
render.setLight(render.attachNewNode(ambientLight))
"""Function called at each step to update rendered bodies positions
according to the position af their respective modelled bodies"""
def Update_Pos(self):
for model, body in zip(self.ModelList, self.ChBodyList) :
new_pos = body.GetPos()
model.setPos(new_pos.x, new_pos.y, new_pos.z)
new_ori = body.GetRot()
q = Quat(new_ori.e0, new_ori.e1, new_ori.e2, new_ori.e3)
model.setQuat(q)
"""Function used to update the visualization
It shouldn't be called at each simulation step"""
def Advance(self):
self.Update_Pos()
self.taskMgr.step()
return self.texture