Alpha intervals


I was wondering if anyone knew how to adjust a model’s (or a texture’s) transparency in an interval. I’m trying to use a render2d frame and a big graphic on the screen at the same time, but I want the graphic to fade out and the frame to fade in using alpha values. Not sure how to do this.

Thanks in advance,


alphaInterval = LerpFunctionInterval(myNodePath.setAlphaScale, toData = 0.0, fromData = 1.0, duration = 1.2)

to fade back in, switch toData = 1.0 and fromData = 0.0 You can set the duration time to whatever you want

thanks a bunch =)

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 ='viewport', 512, 512) 
        self.cam2Buffer.setClearColor(VBase4(0, 0, 0, 0)) 

        # 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()) 

        # make the frame camera look at the scene
        base.camList[1].setPos(50, 0, 0) 

    # end createViewport

    def collide(self, w, collisionEntry):
        if (w.mouseClicked):
            if (w.cardHit):
                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,


Make two cards. Parent the second card is to the first card. The parent card has the frame and the child card has the texture buffer. You can fade in/out the child card without changing the alpha of parent card. When the parent card is transparent, the child should be also. I am little confused about the objects/contents you are talking about. Unless they are parented to the child card, you would have to set their alpha in parallel.

nevermind I got it, thanks =)

the command i was looking for was