Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Texture Shape3D - "Alpha Transparency "not working  (Read 1264 times)
0 Members and 1 Guest are viewing this topic.
Offline Ben_3D

Junior Newbie





« Posted 2006-05-03 23:18:11 »

Hi All,
  I'm quiet new to java3D...but I've been trying my best to learn some of the main things.  One thing I can't seem to get to work, not matter what I seem to change is the Alpha value...I've loaded a texture and applied it to a shape, but wnat to set it to 20% transparent...or partially transparent so I can see through it.

I've set the shape3d appearance to use a transparencyAttribute, but I'm not sure if it has to be done in a specific order, or if something else in the code has to be set up...do I have to force the texture to be a texture2d?...any ideas or snippets or anything to fix this would be great.

I've put my main code below that does the shape texture and alpha values together before adding them to the child list.

Thanks,

Ben



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
        //Load and set texture if the object is textured
       Appearance app = null;
      {
         System.out.println("tex filename: " + m_fullTexPathName);
         
         app = new Appearance();
         
         TextureLoader loader = new TextureLoader(m_fullTexPathName, null);
         //TextureLoader loader = new TextureLoader(m_fullTexPathName,Texture.RGBA, null);

         Texture texture = loader.getTexture();
         app.setTexture(texture);

         TextureAttributes texatt = new TextureAttributes();
         texatt.setTextureMode(TextureAttributes.REPLACE);
         app.setTextureAttributes(texatt);
      }
       
       
        TransparencyAttributes ta;
        ta = new TransparencyAttributes();
      ta.setTransparencyMode(TransparencyAttributes.BLENDED);
      ta.setTransparency(0.15f);
        app.setTransparencyAttributes(ta);
       
       
        Shape3D shape = new Shape3D(m_triangleArray, app);
       
     
       
        m_tg.addChild(shape);
      m_tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Offline Breakfast

Senior Member




for great justice!


« Reply #1 - Posted 2006-05-04 00:29:21 »

Far too long since I've used this a lot to make a detailed call and I'm too lazy to start up one of my applications that is lying around but looking at your code I'm wondering if it could it be something to do with using TextureAttributes.REPLACE ? Perhaps you want to Combine with the underlying appearance rather than replacing it altogether with the texture?
Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2006-05-04 00:41:47 »

Yes I think you need to set the right mode.  I vaugely remember running into this myself.  I *think* it might be "modulate"

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ben_3D

Junior Newbie





« Reply #3 - Posted 2006-05-04 01:05:04 »

Fantastic!

Well I modified the code to get the appearance, also tried setting replace....but setting it to MODULATE got it to work in the end Smiley

Modulate was what I was missing...sure I tried it before...but I tried so many different things, guess I might have missed this one...well great stuff...finally works...spent hours reading about on the net about it...but just couldn't get it to work....just made up now..

Thanks everyone...just brilliant.

Ben


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
        Shape3D shape = new Shape3D(m_triangleArray, app);
       
        Appearance shapeApp = shape.getAppearance();
       
        TransparencyAttributes ta;
        ta = new TransparencyAttributes();
      ta.setTransparencyMode(TransparencyAttributes.BLENDED);
      ta.setTransparency(0.50f);
      shapeApp.setTransparencyAttributes(ta);
     
      TextureLoader loader = new TextureLoader(m_fullTexPathName, null);
      Texture texture = loader.getTexture();
      shapeApp.setTexture(texture);

      TextureAttributes texatt = new TextureAttributes();
      texatt.setTextureMode(TextureAttributes.MODULATE);
      shapeApp.setTextureAttributes(texatt);




Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (18 views)
2014-07-24 01:59:36

Riven (17 views)
2014-07-23 21:16:32

Riven (14 views)
2014-07-23 21:07:15

Riven (17 views)
2014-07-23 20:56:16

ctomni231 (45 views)
2014-07-18 06:55:21

Zero Volt (40 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (36 views)
2014-07-16 23:30:00

Cero (51 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!