Skip to main content

How to get alpha factor working with Sprite3D?

3 replies [Last post]
vprise
Offline
Joined: 2003-11-07
Points: 0

Hi, this is a cross post from the SE forum since its been a while and no one responded there. Hopefully someone here has some idea.

content from this URL pasted bellow for convenience.
http://developer.sonyericsson.com/message.jspa?messageID=104279#104279

I have several Sprite3D m3g objects in a scene that look reasonably good the alpha channel from the Image2D objects are rendered correctly (I manipulated the image bytes to contain either full or partial transparency in the alpha channel).
Their appearance is set as following:

CompositingMode cm = new CompositingMode();
cm.setBlending(CompositingMode.ALPHA);
cm.setAlphaWriteEnable(true);
cm.setDepthTestEnable(true);
m_appearance.setCompositingMode(cm);

However when I try to fade them out using the API's such as AnimationTrack.ALPHA or by directly invoking setAlphaFactor(0.5f) I get no result. I can manipulate the Image2D bytes in runtime but that would be expensive in terms of CPU and I would rather have the animation track working my code for creating the sprite and the animation track looks somewhat like this (notice I reuse the same appearance for all sprite instances although I tried to create new instances for each one too):

sprite = new Sprite3D(true, image, m_appearance);
KeyframeSequence keyAlphaSequence = new KeyframeSequence(frames, 1, KeyframeSequence.LINEAR);
keyAlphaSequence.setDuration(duration));

for(int iter = 0 ; iter < frames ; iter++) {
keyAlphaSequence.setKeyframe(iter, iter * delta, ALPHA_POSITION[iter]);
}
AnimationTrack track = new AnimationTrack(keyAlphaSequence, AnimationTrack.ALPHA);
sprite.addAnimationTrack(track);
track.setController(m_animation);

This code just doesn't produce the desired effect and I'm completely at a loss, I tried multiple internet searches that resulted in links like this:(removed since URL seems to cause a problem with the forum, it works in SE's site linked above)

That seem to indicate that I am on the right track, but I still can't figure this out.

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
terrencebarr
Offline
Joined: 2004-03-04
Points: 0

Hi,

Sorry for the slow reply. I am not a 3D expert myself so I can't answer this. I have contacted some Sun engineers here who might be able to help. I'll let you know what I find out.

Thanks,

-- Terrence

vprise
Offline
Joined: 2003-11-07
Points: 0

Thanks Terrence, sorry I didn't get a chance to update in the forum but I finally got a reply in the SE forum linked above.
Seems the problem was that I was looking at the m3g 1.1 JavaDocs but the device is m3g 1.0. In 1.0 Sprites just don't support Alpha transparency, I got the Alpha to work on the WTK but only in version 2.5 where M3G 1.1 is supported.

Anyway, I will probably need to move to Mesh's when I get the time to do that work ;-)
Sprite3D's in both SE and Nokia are just too flaky.

Terrence Barr - Evangelist, Java Mobile & Embedded

OK, thanks for the update! Glad you were able to figure it out.

-- Terrence

meappdev-interest@mobileandembedded.org wrote:
> Thanks Terrence, sorry I didn't get a chance to update in the forum but I finally got a reply in the SE forum linked above.
> Seems the problem was that I was looking at the m3g 1.1 JavaDocs but the device is m3g 1.0. In 1.0 Sprites just don't support Alpha transparency, I got the Alpha to work on the WTK but only in version 2.5 where M3G 1.1 is supported.
>
> Anyway, I will probably need to move to Mesh's when I get the time to do that work ;-)
> Sprite3D's in both SE and Nokia are just too flaky.
> [Message sent by forum member 'vprise' (vprise)]
>
> http://forums.java.net/jive/thread.jspa?messageID=221780
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@meapplicationdevelopers.dev.java.net
> For additional commands, e-mail: interest-help@meapplicationdevelopers.dev.java.net
>
>

[terrence.barr.vcf]
---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@meapplicationdevelopers.dev.java.net
For additional commands, e-mail: interest-help@meapplicationdevelopers.dev.java.net