Frederic Barachant wrote:
you should replace this line:
Texture tex2 = new TextureLoader("swbSmall.gif", "RGB", new Container()).getTexture();
by
Texture tex2 = new TextureLoader("swbSmall.gif", null);
that's assigning a TextureLoader to a Texture - won't work.  Did you mean something else?
Creating a new container for nothing is not a good idea, anyway.
Texture loader should create the right buffer type (that should be RGBA if you want transparency
That "A" was the trick!  thanks, it works fine now :)

chris

to be taken in account) based on the file type.


At 27/01/2003 13:28:00, you wrote:
  
Also,

I am using j2sdk1.4.1-b21
and Java3d 1.3

chris

chris Thorne wrote:

    
Hi,
I am trying to apply one texture with transparency over another.  The
base texture does not
show through where the top texture has transparency.  Here is the simple
test code fragment I am using to
test it.  Anyone spot the problem?


thanks,

chris
...
       // Create appearance object for textured tristrip
       Appearance app = new Appearance();

        Texture tex = new TextureLoader("world.gif", "RGB", new
Container()).getTexture();
       TextureAttributes texAttr = new TextureAttributes();
       texAttr.setTextureMode(TextureAttributes.MODULATE);

       // Create second texture unit
       Texture tex2 = new TextureLoader("swbSmall.gif", "RGB", new
Container()).getTexture();
       TextureAttributes texAttr2 = new TextureAttributes();
       texAttr2.setTextureMode(TextureAttributes.DECAL);

       TextureUnitState tus1= new TextureUnitState(tex, texAttr, null);
       TextureUnitState tus2= new TextureUnitState(tex2, texAttr2, null);

       TextureUnitState[] textureUnits = new TextureUnitState[2];
       textureUnits[0] = tus1;
       textureUnits[1] = tus2;

       app.setTextureUnitState(textureUnits);

       BranchGroup objRoot = new BranchGroup();

       TransformGroup sceneNavTg = new TransformGroup();

       // create the geometry
       int vertexCounts[] = {4};
       int texCoordSetMap[] = {0,1};

       IndexedTriangleStripArray tri = new IndexedTriangleStripArray(4,
               GeometryArray.COORDINATES |
GeometryArray.TEXTURE_COORDINATE_2, 2, texCoordSetMap, 4, vertexCounts);
       float txtr0[] = {0f,1f, 0f,0f, 1f,1f, 1f,0f};
       float txtr1[] = {0f,0.5f, 0f,0f, 0.5f,0.5f, 0.5f,0f};
       double coords0[] = {0,0,0, 0,0,1, 1,0,0, 1,0,1};
       int indices[]  ={0, 1, 2, 3};
       int indices2[] ={0, 1, 2, 3};
       tri.setTextureCoordinateIndices(0,0, indices);
       tri.setTextureCoordinateIndices(1,0, indices2);
       tri.setCoordinateIndices(0, indices);
       tri.setTextureCoordinates(0, 0, txtr1);
       tri.setTextureCoordinates(1, 0, txtr0);

       tri.setCoordinates(0, coords0);

       Shape3D shape = new Shape3D(tri,app);
       sceneNavTg.addChild(shape);
       objRoot.addChild(sceneNavTg);

...

===========================================================================

To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff JAVA3D-INTEREST".  For general help, send
email to
[EMAIL PROTECTED] and include in the body of the message "help".

      
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

    

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

  

Reply via email to