Tina,

Structure it like:

tranTG - (for locating the object in the world)
  |
  scaleTG - (for adjusting it's size)
     |
    Shape3D - (the object itself)

ie:
  // set up your scaling and translating
  Shape3D s3d = // create the shape
  scaleTG.addChild(s3d);
  tranTG.addChild(scaleTG);

- John Wright
Starfire Research

Tina Manoharan Valappil wrote:
>
>         Hello Lee & John ,
>
>         Actually what I did first was translate, scale, inverse translate
>         on the same Transform3D, but now u have told me that I should
>         have 3 seperate ones. But I am not sure why we have to do like
>         that please do tell me.
>
>         But still it doesnt work !!
>
>         This is my scenegraph:
>         --------------------------------------------------------------
>
>         <SimpleUniverse> - <VPTrans/Avatar start point (0.0, 0.5, 3.0)>
>                |
>             <worldBG>
>                |
>             <worldTG> this is the world start point (0.0, 0.0, 0.0)
>                |
>             <pickBG>
>                |
>             <objBG> detachable, under which I have my loaded VRML obj
>                |
>             <objTG> inserted 1 unit in front of the Avatar
>                |
>               <BG> Bg from loading e.g. scene.getSceneGroup()
>                |
>          <VRML loaded obj>
>
>         This is how I inserted the object 1 unit in front of the user:
>         -----------------------------------------------------------
>
>                 Transform3D vpTransTransform = new Transform3D();
>                 vpTrans.getTransform(vpTransTransform);
>
>                 Point3d finalPoint = new Point3d();
>                 vpTransTransform.transform(new Point3d(0,0,-1), finalPoint);
>                                                 // 1 unit(mt) in front of user
>                 Vector3d finalVector = new Vector3d();
>                 finalVector.set(finalPoint);
>
>                 Transform3D objFinalTrans = new Transform3D();
>                 objFinalTrans.setTranslation(finalVector);
>
>                 objTG.setTransform(objFinalTrans);
>
>         Then when the user inputs scale value say (2.0, 3.0, 1.0)
>         I am applying the scale like this:
>         ----------------------------------------------------------
>
>           // original transform
>           Transform3D originalTrans = new Transform3D();
>           objTG.getTransform(originalTrans);
>
>           // first translate the object to the origin (0,0,0)
>           Vector3d translateVec = new Vector3d(0.0, 0.0, 0.0);
>           Transform3D translateTrans = new Transform3D();
>           translateTrans.setTranslation(translateVec);
>
>           // then scale the object
>           Vector3d scaleVec = new Vector3d(xScale, yScale, zScale);
>           Transform3D scaleTrans = new Transform3D();
>           scaleTrans.setScale(scaleVec);
>
>           // then translate back to the original point
>           Vector3d translateVec2 = new Vector3d();
>           originalTrans.get(translateVec2);
>           Transform3D translateTrans2 = new Transform3D();
>           translateTrans2.setTranslation(translateVec2);
>
>           // final transform = [original]*[translate]*[scale]*[translate2]
>           Transform3D finalTrans = new Transform3D();
>           finalTrans.mul(originalTrans);
>           finalTrans.mul(translateTrans);
>           finalTrans.mul(scaleTrans);
>           finalTrans.mul(translateTrans2);
>
>           objTG.setTransform(finalTrans);
>
>         But there is something funny when I increase the size say
>         change the scale from (0.1,0.1,0.1) to say (0.8,0.8,0.8) then
>         the object becomes smaller and also moves somewhere else !!
>
>         Thanks for your 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