Georg,

    The NullPointerException is expected because the texture unit state array
of the specified Appearance is null. This version of the setTextureUnitState
is to modify an existing entry of the texture unit state array of
the Appearance. So for the first set, use the array version of
setTextureUnitState.


    /**
     * Sets the texture unit state object at the specified index
     * within the texture unit state array to the specified object.
     * If the specified object is null, the corresponding texture unit
     * is disabled.  The index must be within the range
     * <code>[0,&nbsp;stateArray.length-1]</code>.
     *
     * @param index the array index of the object to be set
     *
     * @param state new texture unit state object
     *
     * @exception CapabilityNotSetException if appropriate capability is
     * not set and this object is part of live or compiled scene graph
     * @exception NullPointerException if the texture unit state array is
     * null.
     * @exception ArrayIndexOutOfBoundsException if <code>index >=
     * stateArray.length</code>.
     *
     * @since Java 3D 1.2
     */
    public void setTextureUnitState(int index, TextureUnitState state) {


-Charmaine


>
> >Subject: [JAVA3D] Problem with TextureUnitState
> >To: [EMAIL PROTECTED]
> >MIME-version: 1.0
> >X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
> >Content-transfer-encoding: 7bit
> >X-Priority: 3
> >X-MSMail-priority: Normal
> >Delivered-to: [EMAIL PROTECTED]
> >
> >Hi group,
> >
> >I'm trying to use TextureUnitState in an Appearance to apply
> >different Textures to different parts of the Geometry contained
> >in only one Shape3D.
> >
> >My code is as follows:
> >
> >    /**
> >     * Returns the Appearance for a house containing 2 Textures,
> >     * one for the 4 walls, the other for the roof.
> >     */
> >    protected Appearance getHouseAppearance() {
> >        if (houseAppearance == null) {
> >            houseAppearance = new Appearance();
> >            TextureUnitState tus = new TextureUnitState();
> >            tus.setTexture(getTexture("facade.gif"));
> >            // the texture IS returned, definitely
> >            houseAppearance.setTextureUnitState(0, tus); // <=====
> >            tus = new TextureUnitState();
> >            tus.setTexture(getTexture("roof.gif"));
> >            houseAppearance.setTextureUnitState(1, tus);
> >        }
> >        return houseAppearance;
> >    }
> >
> >However, at the marked line of code, I get this exception:
> >
> >java.lang.NullPointerException
> > at
>
javax.media.j3d.AppearanceRetained.setTextureUnitState(AppearanceRetained.java:6
> 65)
> > at javax.media.j3d.Appearance.setTextureUnitState(Appearance.java:687)
> > at Zoom.getHouseAppearance(Zoom.java:310)
> > at Zoom.createHouse(Zoom.java:298)
> > at Zoom.createCity(Zoom.java:144)
> > at Zoom.createSceneGraph(Zoom.java:118)
> > at Zoom.init(Zoom.java:435)
> > at com.sun.j3d.utils.applet.JMainFrame.run(JMainFrame.java:180)
> > at java.lang.Thread.run(Thread.java:536)
> >
> >What am I doing wrong?
> >
> >Or might this be a bug in J3D 1.3 beta2?
> >
> >regards
> >
> >Georg
> > ___   ___
> >| + | |__    Georg Rehfeld      Woltmanstr. 12     20097 Hamburg
> >|_|_\ |___   [EMAIL PROTECTED]           +49 (40) 23 53 27 10
> >
> >===========================================================================
> >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