From: Daniel Selman [[EMAIL PROTECTED]]
Sent: 26 August 1999 11:57
To: 'Discussion list for Java 3D API'
Cc: '[EMAIL PROTECTED]'
Subject: RE: Problems making image background

Hope this helps.

Sincerely,

Daniel Selman

[EMAIL PROTECTED]
http://www.tornadolabs.com

(From my forthcoming book: Java 3D Programming - chapter "Creating Geometry" )

56.1 Background Geometry
Background geometry is assumed to be positioned at infinite distance, that is, no 
perspective calculations need be performed. It is also assumed to have been 
tessellated onto a unit sphere. In addition a background color, image and Bounds 
within which the Background is active can be specified.
Background geometry is rendered after the background image has been drawn.

To set a Background image:
ImageComponent2D image = new TextureLoader( "sky.jpg", this).getScaledImage( 1300,1300 
);
Background back = new Background( image );
back.setApplicationBounds( getBoundingSphere() );

To set Background Geometry:
Background back = new Background();
BranchGroup bgGeometry = new BranchGroup();

Appearance ap = new Appearance();
Texture tex = new TextureLoader( "back.jpg", this).getTexture();
ap.setTexture( tex );

Sphere sphere = new Sphere( 1.0f, Primitive.GENERATE_TEXTURE_COORDS | 
Primitive.GENERATE_NORMALS_INWARD, ap );

bgGeometry.addChild( sphere );
back.setGeometry( bgGeometry );

The examples above both have the effect of setting a background image. However the 
second approach, using a texture-mapped sphere with the image applied has an 
advantage: the texture image is automatically scaled when it is applied to the sphere. 
In the first example the background image must be manually scaled to correspond to the 
size of the rendering window. If the rendering window is resizable the image must be 
re-scaled or it will merely be painted into the top left corner of the rendering 
window.

In the second example note that the Normal vectors generated for the sphere must point 
inwards as the viewer is inside the generated sphere and views the texture applied to 
the inside of the sphere. Alternatively the sphere's PolygonAttributes can be set to 
CULL_NONE to render triangles with Normal vectors pointing away from the viewer.

-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of J A Evans
Sent: 26 August 1999 11:25
To: [EMAIL PROTECTED]
Subject: Re: Problems making image background


I have found it easier to use a boundingLeaf attached to
the viewPlatform for background, as described in chapter 3
of the tutorial. Although I don't know if this is the
cause of your problem.

On Thu, 26 Aug 1999 11:08:38 +0200 Ivaylo Velikov
<[EMAIL PROTECTED]> wrote:
> Hello colleagues,
>
> This message is being resent, because of some "undeliverable" responses,
> caused by incorrect name entered from my side.
> Please, forgive my ignorance.
>
> I want to make an image background in Java3D through the following piece of
> code.
>
> Group scene = new Group( );
>
> ImageComponent2D imageComponent = new ImageComponent2D;
> TextureLoader texLoader = new TextureLoader( "clouds.jpg", this );
> imageComponent = texLoader.getImage();
>
> BoundingSphere worldBounds = new BoundingSphere( new Point3d( 0.0, 0.0, 0.0
>  ), 5000.0 );
>
> Background background = new Background( );
>
> background.setImage( image );
> background.setApplicationBounds( worldBounds );
>
> scene.addChild( background );
>
> The scene then is added to the root.
> The program is compiled without any problems, the scene appears but with no
>  background at all.
> No exceptions occurred. Everything seems to be allright, but it's not.
> Could anybody make some suggestions about the reason of such a problem?
>
> Thanks.
>
> Ivailo Velikov
>
> ===========================================================================
> 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