Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 99731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:26:37+00:00 2026-05-11T00:26:37+00:00

I’m a complete n00b in j3d (but an expert in Java). Just starting out,

  • 0

I’m a complete n00b in j3d (but an expert in Java). Just starting out, I’m running into a problem playing with transparency. I’ve got a simple example which draws a rotating planar quad (disappears when showing the back face because I haven’t disabled backface culling).

With the Color3b and COLOR_3 lines uncommented (and the corresponding Color4b and COLOR_4 lines commented), I see the rotating quad, colored red.

However, when I comment the color-3 lines and uncomment the color-4 lines, I see a BLACK square (against the white background), even though the alpha value is set to 255 (fully opaque).

What am I doing wrong? Google doesn’t help, and even the Java3D forum over at java.forums.net is less than helpful. StackOverflow, save me! You can copy and past the below program, run it and see what happens.

Here are my specs:

Java 6 on OSX 10.5.5 J3D 1.5.2 JOGL 1.1.1

Thanks,

–Rob

Here’s the code:

import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.universe.SimpleUniverse; import java.applet.Applet; import java.awt.*; import javax.media.j3d.*; import javax.vecmath.*;  public class Hello extends Applet {  public Hello() throws Exception  {   setLayout(new BorderLayout());   GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();   Canvas3D canvas3D = new Canvas3D(config);    add('Center', canvas3D);    BranchGroup scene = createSceneGraph();   scene.compile();    SimpleUniverse univ = new SimpleUniverse(canvas3D);    univ.getViewingPlatform().setNominalViewingTransform();    univ.addBranchGraph(scene);  }   public BranchGroup createSceneGraph() throws Exception  {   BranchGroup root = new BranchGroup();    // A white background.    Background bgd = new Background(1.0f, 1.0f, 1.0f);   root.addChild(bgd);    // This will spin the quad around    TransformGroup spin = new TransformGroup();   spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);   root.addChild(spin);    // define the quad:    Point3d p1 = new Point3d(-0.5, -0.5, 0);   Point3d p2 = new Point3d(0.5, -0.5, 0);   Point3d p3 = new Point3d(0.5, 0.5, 0);   Point3d p4 = new Point3d(-0.5, 0.5, 0);    // colors    Color4b c = new Color4b((byte)255, (byte)0, (byte)0, (byte)255);   //Color3b c = new Color3b((byte)255, (byte)0, (byte)0);    QuadArray quads = new QuadArray(4,     GeometryArray.COORDINATES | GeometryArray.COLOR_4);     // GeometryArray.COORDINATES | GeometryArray.COLOR_3);    quads.setCoordinate(0, p1);   quads.setCoordinate(1, p2);   quads.setCoordinate(2, p3);   quads.setCoordinate(3, p4);   quads.setColor(0, c);   quads.setColor(1, c);   quads.setColor(2, c);   quads.setColor(3, c);    // Not sure if I need this. Doesn't seem to make a difference.    Appearance appearance = new Appearance();   TransparencyAttributes trans = new TransparencyAttributes();   trans.setTransparencyMode(TransparencyAttributes.BLENDED);   appearance.setTransparencyAttributes(trans);    // Create the shape...    Shape3D shape = new Shape3D();   shape.setGeometry(quads);   shape.setAppearance(appearance);    spin.addChild(shape);    Alpha rotationAlpha = new Alpha(-1, 4000);   RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, spin);   BoundingSphere bounds = new BoundingSphere();   rotator.setSchedulingBounds(bounds);   spin.addChild(rotator);    return root;  }   public static void main(String[] args) throws Exception  {   Frame frame = new MainFrame(new Hello(), 256, 256);  } }  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:26:38+00:00Added an answer on May 11, 2026 at 12:26 am

    Replacing Color4b with Color4f, worked for me. Replace corresponding lines in your code with the lines below,

    Color color = new Color(255, 0, 0, 50);  Color4f c = new Color4f(color); QuadArray quads = new QuadArray(4,             GeometryArray.COORDINATES | GeometryArray.COLOR_4); 

    I used AWT Color, found it easier to pass in all ColorNx() constructors, i.e. Color3b(), Color4b(), and Color4f() etc. You may use float arguments directly, if that feels natural to you. The actual fix is the use of Color4f, not the AWT thingy. Even using AWT Color didn’t solve the issue with Color4b. Just go with Color4f, I don’t see any problem.

    My platform: Java Version ‘1.6.0_10’, Java 3D 1.5.2, Core2 Duo, OpenSUSE 11.0, Intel G33 Graphics.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 85k
  • Answers 85k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer the markup <div id="fixed">fixed content</div> <div id="fluid">fluid content</div> the css… May 11, 2026 at 5:07 pm
  • Editorial Team
    Editorial Team added an answer There is an ugly hack that gets Extension methods working… May 11, 2026 at 5:07 pm
  • Editorial Team
    Editorial Team added an answer The way you'd expect: if (theObject instanceof int[]) { //… May 11, 2026 at 5:07 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.