Hi j3D Community,
I have a problem .Pl do help me...
I have a scene graph on which I have all the three mouse behaviours are added which enables the user to translate all the objects together.What I wanted is when the user clicks on a button the Mouse translate behavior gets disabled and enable the Pick behavior feature..which enables the user to translate the individual shapes on the sceneGraph. Both these functionalities seem to work fine. Over the Mouse Translate Behavior I have added a BG which I remove and add by toggling the button on the applet. However when the user translates the whole object and then clicks on the click button (which removes the BG node over the mouseTranslate Behavior) all the objects return back to the original position.How do I aviod it..I tried the following way.
I enabled Callback and trapped the Transform3D object of the mouse Translate behavior(Thnx to this mailing list).When the user clicks on the button I introduced the trapped Transform3D object in the scene Graph..! That doesnt seem to work.I dont understand why??...Hope you understand my problem..My SceneGraph looks something like this.
I add and remove the BG between Main and mouse translate behavior.
BG (Main model BranchGroup)
/ | \
/ | \
/ | \
BG | \
/ | \
/ | \
mouse Behavior---TG Lights node
translate |
|
|
|
---------------------
| | |
pick pick pick (with individual TGs)
| | |
| | |
S1 S2 S3 (Shape3D)
My chunk of code for adding mouse Translate is
mouseTranslateBG = new BranchGroup();
mouseTranslateBG.setCapability(BranchGroup.ALLOW_DETACH);
mouseTranslateBG.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
mouseTranslateBG.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
mouseTranslateBG.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
MouseTranslate myMouseTranslate = new MouseTranslate();
myMouseTranslate.setTransformGroup(objTransform);
myMouseTranslate.setSchedulingBounds(bounds);
callback = new Callback();
myMouseTranslate.setupCallback(callback);
mouseTranslateBG.addChild(myMouseTranslate);
rootBranch.addChild(mouseTranslateBG);
chunk of code for action performed of button is
else if(e.getSource() == splitB)
{
int index = rootBranch.numChildren()-1;
if(!checkAdd)
{
checkAdd = true;
Transform3D testTransform = callback.getTransform();
System.out.println("Inside Split Event" + testTransform);
rootBranch.removeChild(index);
appletContext=this.getAppletContext();
//add new transform in the scenegraph after removing mouse translate
viewerThread.setSplitTrue(true, appletContext,testTransform);
objTransform.setTransform(testTransform);
splitB.setText("Integrate");
}
else
{
checkAdd= false;
rootBranch.addChild(mouseTranslateBG);
Transform3D testTransform = new Transform3D();
viewerThread.setSplitTrue(false,appletContext,testTransform);
splitB.setText("Split");
}
This is my chunk of code for adding Pick Behavior
Transform3D blockTranslation = new Transform3D();
TransformGroup blockTranslationGroup;
try
{
Vector3f testvec = new Vector3f();
//get the new translation after mose trnaslate is disabled
transformnew.get(testvec);
blockTranslation.set(testvec);
blockTranslationGroup = new TransformGroup(blockTranslation);
System.out.println("In Object File"+transformnew);
}
Thanx in advance.
(Murali)
