Transparency - How does it work?!

Started by nerdinand, July 04, 2014, 10:58:14 AM

Previous topic - Next topic

nerdinand

Hello

I'm using JPCT-AE for something serious. ;)
It is a medical application where a user can select a pain point on a 3D model of the body. Right now I implemented this pain point using a Sphere primitive without texture and set the additional color to color it. Now I'd like to make it pulsate by making it more and less transparent over time. How would I implement this? I know there is a setTransparency() method, but this only accepts integers (IMO the JavaDoc could be improved here to explain some more what range of values it accepts and what they mean). When I set the transparency to -1, the object is fully opaque and setting it to 1 seems to make it fully transparent. How can I vary the transparency in order to achieve the desired effect?

Thanks for this easy to use lib and your help!

EgonOlsen

I agree that the documentation isn't sufficient here. I actually thought that it mentions the formula, but obviously it doesn't. But you find it here: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Config.html#glTransparencyOffset. The calculated value ranges from [0..1].
The reason that the method doesn't take these values directly but uses the formula to calculate them based on some integer is historical. jPCT for desktop was a software renderer only in the beginning that handled (and still does...) transparency in a different way. Using ints was perfectly valid for this. With additional hardware support, this changed but i wanted them to behave similar, so i invented this formula. jPCT-AE is based on the desktop version and should be as compatible as possible, so it inherits this behaviour too.

nerdinand

I see, so the way to go here is to modify Config.glTransparencyMul then? Could I for example modify it through a sine wave with each frame rendered?

EgonOlsen

No, that's not how it's meant to be used. I suggest to set the offset to 0 and the mul to maybe 0.0039. Then use values between 0 and 255 for setTransparency(<int>) to go from fully transparent to fully opaque.

nerdinand

Ah I see. Thanks. Although, I already Implemented it the other way now, and it works. But maybe I'll refactor it at some point.