You're not loading the variable 'texture' up with the texture you loaded in
from TextureLoader.

Replace this line:
        Texture2D texture = new Texture2D(Texture.BASE_LEVEL,
Texture.RGBA,image.getWidth(), image.getHeight());

with this one:
        Texture texture = loader.getTexture();


----- Original Message -----
From: Adrian Meekings <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 06, 2001 11:31 PM
Subject: [JAVA3D] Texture problem for newbe


> Hi folks.
>
> The following code will not place a texture (that I can see anyway onto an
object)
>
> Appearance appearance = (Appearance)shape3D.getAppearance();
> TextureLoader loader = new TextureLoader(directoryString,applet);
file://applet is the applet used for this program
>
> ImageComponent2D image = loader.getImage();
>
>       if(image == null) {
>             System.out.println("load failed for texture:
"+directoryString);
>        // never gets into here ... good
>       }
>
>
>       file://Texture texture = appearance.getTexture();  // try this out
gives null therefore there is no texture object yet
>       Texture2D texture = new Texture2D(Texture.BASE_LEVEL,
Texture.RGBA,image.getWidth(), image.getHeight());
>       texture.setBoundaryModeS(Texture.WRAP);  file://THIS IS THE DEFAULT
ANYWAY
>       texture.setBoundaryModeT(Texture.WRAP);  file://THIS IS THE DEFAULT
ANYWAY
>
>       texture.setImage(0, image);
>       appearance.setTexture(texture);
>       appearance.setTextureAttributes(new TextureAttributes());  // do I
have to do this?? it doesnt seem to make a difference
> //      shape3D.setAppearance(appearance); file://does not have to be done
>
> This code works fine on the individual shape3D objects of a Box object (I
use a Box object for the walls of a room).
> But wont work on any imported objects. (ie the tables and chairs)
>
> Is there anything else I have to set within the shape3D inorder to allow
me to render this texture?
>
> I can change the material properties of the shape3D easily enough (there
is already a material object present in the appearance object)
>
>
>
> Thanks for getting this far down the page
> Cheers
> Adrian
>
>
===========================================================================
> 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