Thank you, Vladimir. What I nice idea!..
I think I understand it, but I must admit that I
couldn't adjust it to my situation. With all my
rotations at stuff the background was either appearing
in the wrong location or not at all.
Do you think it is possible to write a generic
GradientBackground class so that instead of
bg = new Background(new Color3f(...));
(which works for me well in all situations)
one could write
bg = new GradientPaint();
(and have it work without any more effort)?
I tried to accomplish this by taking your code and
changing it as attached, but like I said, it doesn't
really work! Could you suggest how to adjust it to
make it work?
Many thanks in advance!
Dola
--- Vladimir Vernikovski <[EMAIL PROTECTED]>
wrote:
> May be this...
> I hope this code good if not need precise
> gradient...
>
> Vladimir A. Vernikovski
> Programmer
> -------------------------------------------
> JPROOF Technologies Ltd.
> ----- Original Message -----
> From: "Dola Woolfe" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, June 14, 2003 11:06 AM
> Subject: [JAVA3D] Gradient Paint in Background
>
>
> > Hi,
> >
> > I apologize if this is an FAQ.
> >
> > Is there an easy way to have a gradient paint in
> the
> > background, without going through the trouble of
> > creating an image every time a background is
> needed?
> >
> > Thanks.
> >
> > Dola
> >
> > __________________________________
> > Do you Yahoo!?
> > The New Yahoo! Search - Faster. Easier. Bingo.
> > http://search.yahoo.com
> >
> >
>
===========================================================================
> > 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".
>
> ATTACHMENT part 2 application/octet-stream
name=HelloUniverse.java
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.compackage smccube;
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 GradientBackground extends Background {
private Color3f white = new Color3f(1.0f,1.0f,1.0f);
private 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 GradientBackground() {
BranchGroup branch = new BranchGroup();
Shape3D rectangle = new Shape3D();
QuadArray aQuadArray = new
QuadArray(4,QuadArray.COORDINATES|QuadArray.NORMALS|QuadArray.COLOR_3);
aQuadArray.setCoordinates(0,vertices);
aQuadArray.setColor(0, white);
aQuadArray.setColor(1, blue);
aQuadArray.setColor(2, blue);
aQuadArray.setColor(3, white);
rectangle.addGeometry(aQuadArray);
branch.addChild(rectangle);
this.setApplicationBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),
Double.POSITIVE_INFINITY));
this.setGeometry(branch);
}
}