Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / July 2005

Tip: Looking for answers? Try searching our database.

How to color backside of panel?

Thread view: 
aaronhirshberg@yahoo.com - 04 Jul 2005 23:38 GMT
I have a four sided object that is 2d, but can be rotated and
translated, etc., using java 3d.  I specified the color, but it only
does the front side.  When the normal points in the same direction as
viewer is looking, it is black.  How do I specify the color for the
back side?

BTW, where is the FAQ?

Aaron Hirshberg
aaronhirshberg@yahoo.com
Paul Drallos - 09 Jul 2005 17:06 GMT
> I have a four sided object that is 2d, but can be rotated and
> translated, etc., using java 3d.  I specified the color, but it only
[quoted text clipped - 6 lines]
> Aaron Hirshberg
> aaronhirshberg@yahoo.com

I'm not sure if I understand your question correctly, and I'm only a beginner with Java 3D.  I'm assuming that your four sided 2D object is something like a four-sided plane like you would get by calling QuadArray.

Something like this:

     QuadArray plane = new QuadArray(4, GeometryArray.COORDINATES
                                     | GeometryArray.COLOR_3);

   //set coordinates  
     Point3f p = new Point3f(-1.0f,  1.0f,  0.0f);
     plane.setCoordinate(0, p);
     p.set(-1.0f, -1.0f,  0.0f);
     plane.setCoordinate(1, p);
     p.set(1.0f, -1.0f,  0.0f);
     plane.setCoordinate(2, p);
     p.set(1.0f,  1.0f,  0.0f);
     plane.setCoordinate(3, p);

   //set color
     Color3f red = new Color3f(1.0f,0.0f,0.0f);
     plane.setColor(0,red);
     plane.setColor(1,red);
     plane.setColor(2,red);
     plane.setColor(3,red);

Then, when you create the Appearance() object, set CULL_NONE in the PolygonAttributes like this:

     Appearance appear = new Appearance();
     PolygonAttributes polyAttrib = new PolygonAttributes();
     polyAttrib.setCullFace(PolygonAttributes.CULL_NONE);
     appear.setPolygonAttributes(polyAttrib);

     Shape3D planeObj  = new Shape3D(plane, appear);

When I ran this (in a rotating TransformGroup)I get a red square on both sides.  But if I set CULL_BACK or CULL_FRONT instead of CULL_NONE, I get a red square on one side, black on the other.  I hope this helps.
aaronhirshberg@yahoo.com - 10 Jul 2005 05:01 GMT
> > I have a four sided object that is 2d, but can be rotated and
> > translated, etc., using java 3d.  I specified the color, but it only
[quoted text clipped - 41 lines]
>
> When I ran this (in a rotating TransformGroup)I get a red square on both sides.  But if I set CULL_BACK or CULL_FRONT instead of CULL_NONE, I get a red square on one side, black on the other.  I hope this helps.

What I did was create a second panel in the same place with reversed
vertices so the normal points the other way
and made the two polygons different colors.  It worked.  Culling is
important in a situation like what I have
created as culling out the nonvisible panels saves rendering time.  As
soon as I figure that out I will do that, too.

Aaron
Paul Drallos - 10 Jul 2005 12:28 GMT
> What I did was create a second panel in the same place with reversed
> vertices so the normal points the other way
> and made the two polygons different colors.  It worked.  Culling is
> important in a situation like what I have
> created as culling out the nonvisible panels saves rendering time.  As
> soon as I figure that out I will do that, too.

I'm confused again.  As soon as you figure 'what' out?
aaronhirshberg@yahoo.com - 11 Jul 2005 00:59 GMT
> > What I did was create a second panel in the same place with reversed
> > vertices so the normal points the other way
[quoted text clipped - 4 lines]
>
> I'm confused again.  As soon as you figure 'what' out?

I am so busy fiddling with Java 3D using my existing knowledge that I
haven't had time  to read the various on-line instructions more
extensively.  That is what I mean.

Aaron Hirshberg


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.