Single color->U mean setting a color to the background and then adding the
background node to objRoot.Yes ,I tried that and it works .
Also,about the geometry I have tried changing the coordinates of the
QuadArray.
Note: vertices array was changed to->
private final float[] vertices =
{ 0.5f,0.0f,0.0f, 0.0f, 0.5f,0.0f, -0.5f, 0.0f,0.0f,
0.0f,-0.5f,0.0f};
It still does not work .
Can u suggest something,please.
P.S:I got another reply about creating an image having color gradient,with
Buffered Image.I have used that and it was a succesful process but there are
some speed issues due to which I cannot use this method.
----- Original Message -----
From: "Kevin Glass" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 12, 2003 5:43 PM
Subject: Re: [JAVA3D] Creating a Background with a color gradient
> Have you tried it with a single color? Does that work?
>
> I was under the impression that the background geometry needed to fit in a
> 1 unit cube centered around (0,0,0). Unless I read it wrong, your
> background is outside of this cube (it being a 2 unit cube).
>
> Kev
>
> > Hi All,
> > I am trying to create a background with a color gradient.
> > I am working with HelloUniverse example for this.
> > I am trying to use Background geometry.
> > The problem is that when I give the branchgroup , to which the geometry
> > is added as an argument to setGeometry method of Background class ,I
> > cannot see the effect. The code is :
> > import java.applet.Applet;
> > import java.awt.BorderLayout;
> > import java.awt.event.*;
> > import java.awt.Color;
> > import java.awt.GraphicsConfiguration;
> > import com.sun.j3d.utils.applet.MainFrame;
> > import com.sun.j3d.utils.geometry.ColorCube;
> > import com.sun.j3d.utils.universe.*;
> > import javax.media.j3d.*;
> > import javax.vecmath.*;
> > import com.sun.j3d.utils.geometry.Sphere;
> >
> > public class HelloUniverse extends Applet {
> >
> > private SimpleUniverse u = null;
> > Color3f white = new Color3f(1.0f,1.0f,1.0f);
> > Color3f blue = new Color3f(0.0f,0.0f,1.0f);
> >
> > private final float[] vertices { 1.0f,-1.0f,1.0f,
> > 1.0f, 1.0f,1.0f,
> > -1.0f, 1.0f,1.0f,
> > -1.0f,-1.0f,1.0f};
> >
> >
> > public BranchGroup createSceneGraph() {
> >
> > BranchGroup objRoot = new BranchGroup();
> >
> > TransformGroup objTrans = new TransformGroup();
> > objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
> > objRoot.addChild(objTrans);
> >
> > // Create a simple Shape3D node; add it to the scene graph.
> > objTrans.addChild(new ColorCube(0.4));
> >
> > Transform3D yAxis = new Transform3D();
> > Alpha rotationAlpha = new Alpha(-1, 4000);
> >
> > RotationInterpolator rotator new
> > RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float)
> > Math.PI*2.0f);
> > BoundingSphere bounds new BoundingSphere(new Point3d(0.0,0.0,0.0),
> > 100.0); rotator.setSchedulingBounds(bounds);
> > objRoot.addChild(rotator);
> >
> >
> > BranchGroup branch = new BranchGroup();
> > branch.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
> > branch.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
> > branch.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
> >
> >
> > Shape3D rectangle = new Shape3D();
> > rectangle.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
> > rectangle.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
> > rectangle.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
> > rectangle.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
> > rectangle.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE);
> > rectangle.setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_READ);
> > rectangle.setCapability(Shape3D.ALLOW_LOCAL_TO_VWORLD_READ);
> >
> > QuadArray aQuadArray = new
> > QuadArray(4,QuadArray.COORDINATES|QuadArray.NORMALS|QuadArray.COLOR_3);
> > aQuadArray.setCapability(QuadArray.ALLOW_COLOR_READ);
> > aQuadArray.setCapability(QuadArray.ALLOW_COLOR_WRITE);
> > aQuadArray.setCapability(QuadArray.ALLOW_COORDINATE_WRITE);
> > aQuadArray.setCapability(QuadArray.ALLOW_COORDINATE_READ);
> >
> >
> > aQuadArray.setCoordinates(0,vertices);
> >
> >
> > Vector3f vector=new Vector3f( 0.0f,0.7f,0.7f);
> > for( int i = 0; i < 4; i++ )
> > {aQuadArray.setNormal( i,vector);}
> >
> >
> > aQuadArray.setColor(0,white);
> > aQuadArray.setColor(1,white);
> > aQuadArray.setColor(2,blue);
> > aQuadArray.setColor(3,blue);
> >
> >
> > rectangle.addGeometry(aQuadArray);
> > branch.addChild(rectangle);
> > Background background = new Background();
> > background.setApplicationBounds(bounds);
> > background.setCapability(Background.ALLOW_GEOMETRY_READ);
> > background.setCapability(Background.ALLOW_GEOMETRY_WRITE);
> > background.setGeometry(branch);
> >
> > objRoot.addChild(background);
> >
> > objRoot.compile();
> > return objRoot;
> >
> > }
> >
> > public HelloUniverse() {
> >
> > }
> >
> > public void init() {
> >
> > setLayout(new BorderLayout());
> > GraphicsConfiguration config =
> > SimpleUniverse.getPreferredConfiguration();
> >
> > Canvas3D c = new Canvas3D(config);
> > add("Center", c);
> >
> > // Create a simple scene and attach it to the virtual universe
> > BranchGroup scene = createSceneGraph();
> > u = new SimpleUniverse(c);
> >
> > u.getViewingPlatform().setNominalViewingTransform();
> >
> > u.addBranchGraph(scene);
> > }
> >
> > public void destroy() {
> >
> > u.removeAllLocales();
> >
> > }
> >
> > public static void main(String[] args) {
> > new MainFrame(new HelloUniverse(), 256, 256);
> > }
> >
> >
> > }
>
>
===========================================================================
> 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".