Hi Karl,
I am not quite sure what the reason for your error is, but there is an
example program in ...\demo\java3d\AWT_Interaction\AWTInteraction.java ( in the
Java directory). It rotates a cube in response to clicking a button.
An easier way (so I think) is just to implement an ActionListener:
public class programname implements ActionListener {
public BranchGroup scene;
....
public void actionPerformed( ActionEvent e ) {
if ( e.getSource()==Button_newCube ) {
//create BranchGroup for the new objekt
BranchGroup new_BranchGroup = new BranchGroup();
//create TransformGroup for the new object
TransformGroup new_objTrans = new TransformGroup();
Box myCube = new Box();
//connect everything and add to the scene
new_BranchGroup.addChild( new_objTrans );
new_objTrans.setTransform( transTemp );
new_objTrans.addChild( myCube );
scene.addChild( new_BranchGroup );
}
}
}
I hope this helps. If you need more information you can also check out
chapter 4 of the J3D tutorial.
Katja
> Hi again,
> Non stop questions from the one they call KP!
>
> Anyway, I want to be able to let the user decide how
> many objects are to be placed in the scene, I want the
> user to be able to place an object by clicking a
> button..They can click as many times as they like and
> a new object will be placed in the scene, I'm not too
> worried where the object is placed as the user can
> move each object to where they would like it to be.
>
> At the moment I have my objects, I have my button, but
> I can't get them to work together. I'm using
> behaviors, but I not sure I should be?
> I can compile my code but I get the following error
> when I click my addObject button:
>
> Exception occurred during Behavior execution:
> java.lang.NullPointerException at
> AWTInteractionBehavior.processStimulus(AWTInteractionBehavior.java:37)
> at
> javax.media.j3d.BehaviorScheduler.doWork(BehaviorScheduler.java:174)
> at javax.media.j3d.J3dThread.run(J3dThread.java:256)
>
> I think it's got something to do with what my behavior
> is attached to, as if i was rotating a cube I would
> attach to the cube, but as I want to add to the scene,
> i need to attach to the whole scene, but it doesn't
> like that, I don't think?
> Any ideas/code/help??
>
> Cheers
> KP
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> >from News and Sport to Email and Music Charts
> http://uk.my.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".
>
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
===========================================================================
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".