Hi David,

    You will get DanglingReferenceException if

    public SimpleRotate(TransformGroup tg)

tg is not clone together with this Behavior Node
in part of a cloneTree() process.


          BG
        /    \
     /        \
SimpleRotate  TG


So if you use cloneTree at BG, this should work.
If you use cloneTree at SimpleRotate only, the above
exception is expected.

If you would like to explicitly clone tg only,
use tg.cloneNode().

BTW,

 TransformGroup newTransformGroup = (TransformGroup)
                    referenceTable.getNewObjectReference(tg);

should be

   tg  = (TransformGroup)
               referenceTable.getNewObjectReference(tg);

in  your attach file.

For an example, please refer to page 115, Example User Behavior Node
of the Java 3D API Specification,  Second Edition.

Thanks.

- Kelvin

---------------
Java 3D Team
Sun Microsystems Inc.

>MIME-Version: 1.0
>X-Priority: 3 (Normal)
>X-MSMail-Priority: Normal
>Importance: Normal
>X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
>Date: Wed, 18 Oct 2000 14:47:49 +1000
>From: David Grace <[EMAIL PROTECTED]>
>Subject: Re: [JAVA3D] Using CloneNode on Behavior
>To: [EMAIL PROTECTED]
>
>Thank you for your response.
>
>I still have a problem. I get a DanglingReferenceException when I put
>updateNodeReferences() in my behavior.
>
>Would it be possible to refer me to an example of cloning a Behavior, or
>show me what the cloneNode and updateNodeReferences functions should look
>like for this simple example.
>
>-----Original Message-----
>From: Kelvin Chung [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, October 18, 2000 9:39 AM
>To: [EMAIL PROTECTED]
>Cc: [EMAIL PROTECTED]
>Subject: Re: [JAVA3D] Using CloneNode on Behavior
>
>
>Hi Dave,
>
>  You should use the following callback to retrieve the cloned copy of
>TransformGroup which Behavior refer to:
>
>
> public void updateNodeReferences(NodeReferenceTable referenceTable) {
>         super.updateNodeReferences(referenceTable);
>
>         newTransformGroup = (TransformGroup)
>                    referenceTable.getNewObjectReference(oldTransformGroup);
>         ....
>
>  }
>
>- Kelvin
>
>---------------
>Java 3D Team
>Sun Microsystems Inc.
>
>>I have a Behavior similar to a RotationInterpolator which given a
>>TransformGroup changes the transform. I want to clone a BranchGroup which
>>contains the Behavior and the TransformGroup.
>>
>>        BranchGroup
>>                |
>>                /\
>>             /  \
>>    Behavior   TransformGroup
>>
>>The documentation says you must include in your class:
>>
>>     public Node cloneNode(boolean forceDuplicate) {
>>         UserSubClass usc = new UserSubClass();
>>         usc.duplicateNode(this, forceDuplicate);
>>         return usc;
>>     }
>>
>>
>>If my initial constructor was :
>>SimpleRotateBehavior b = new SimpleRotationBehavior(TransformGroup tg);
>>
>>I assume you replace UserSubClass with SimpleRotateBehavior but how do you
>>get the cloned TransformGroup to give to the cloned Behavior.
>>
>>I think I might be missing something fundamental here, so any help or any
>>starting point would be greatly appreciated.
>>
>>Thanks in advance,
>>
>>Dave.
>>
>>===========================================================================
>>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