Ok, another question for you:
im trying to set the alpha level of a camera frame on aspect2d, but I can’t get it to be transparent. I can get the actual background of the frame to be transparent, but this isnt what I want. I want the entire frame (including the contents of the frame) to start as transparent, and when you click on a card, I want the card to flip, increase scale, and then fade out while the aspect2d frame (and the objects inside it) fades in.
If I use setTransparency(1) like I do below, the background of the frame is transparent, but the object inside it is not. When I use the setAlphaScale interval I can get the entire frame to fade out, but the background is still transparent when I fade it in, which isnt what I want.
Any ideas on how to start the entire frame (plus the contents) as transparent, and then fade in the entire frame (plus contents) with the frame background NOT being transparent?
Here’s the code:
def createViewport(self):
# Create the left offscreen buffer
self.cam2Buffer = base.win.makeTextureBuffer('viewport', 512, 512)
self.cam2Buffer.setClearColor(VBase4(0, 0, 0, 0))
base.makeCamera(self.cam2Buffer)
# Create a card to view the buffer on render2d
self.cam2Card = CardMaker('scene')
self.cam2Card.setFrame(-1, 1, -.75, .75)
self.cam2CardNP = aspect2d.attachNewNode(self.cam2Card.generate())
self.cam2CardNP.setTexture(self.cam2Buffer.getTexture())
# make the frame camera look at the scene
base.camList[1].setPos(50, 0, 0)
base.camList[1].lookAt(50,1,0)
self.cam2CardNP.setTransparency(1)
# end createViewport
def collide(self, w, collisionEntry):
if (w.mouseClicked):
if (w.cardHit):
None
else:
w.cardHit = True
w.objectSelected = self
self.cardSpin = self.model.hprInterval(.5, Vec3(self.model.getH()+180,0,0) )
self.cardToCenter = self.model.posInterval(.75, Vec3(0,20,-.3))
self.cardScaleUp = self.model.scaleInterval(.75, 100)
self.cardFadeOut = LerpFunctionInterval(self.model.setAlphaScale, toData = 0.0, fromData = 1.0, duration = 1.0)
w.viewportFadeIn = LerpFunctionInterval(w.cam2CardNP.setAlphaScale, toData = 1.0, fromData = 0.0, duration = 1.0)
w.viewportFadeOut = LerpFunctionInterval(w.cam2CardNP.setAlphaScale, toData = 0.0, fromData = 1.0, duration = 1.0)
Sequence( self.cardSpin, Parallel(self.cardToCenter, self.cardScaleUp), Wait(.5), Parallel( self.cardFadeOut, w.viewportFadeIn), Func(self.model.detachNode), Wait(2), w.viewportFadeOut, Func(self.resetHit, w) ).start()
# end collide
Thanks in advance,
Adam