Another way of doing it is to reinit the matrix to ID, but having previously stored the translation information int a vector. Then you can apply rotation and scale, and afterthat reset the translation component with your vector. That what's done in the OrbitBehavior class
Alessandro Borges wrote:
hi, I am sorry if I miss the point, but I use the following transform3d multiplication to get the compound tranformation:cpTransform = translate * refptInv * scale * rotation * refPT where * refptInv is the inverse translation of refPT; * refPT is the tuple3f coordinates of center of rotation - take it as a translation transform; * translate, scale, rotation are the transformations to be applied on the object. Alessandro --- Jean-Robert D'Amore <[EMAIL PROTECTED]> escreveu: > Try by inverting the matrix multiplication.Let say you've got the matric M for the scene, and T for the transform. If you do M=M*T then the transform will be in local coordinatyes. If you do M=T*M then you have the transform in global coordinates... JR Ben Logan wrote:Could someone take a quick look at the followingclass. The problem isthat when a rotation is performed and then atranslation the translationtakes place on the local coordinates. i.e it movesthe shape in thedirection of the rotation. I want the shape to bemoved in the samedirection whatever the rotation. Any help would bemuch appreciated.Thanks Ben public class MyPickTranslateBehavior extendsPickTranslateBehavior {protected WakeupCondition m_WakeupCondition =null;private int x = 0; private int y = 0; private int x_last = 0; private int y_last = 0; private double y_angle = 0.0; private double x_factor = 0.02; int changeX; int changeY; private Transform3D modelTrans = null; private Transform3D transformY = null; private PickResult pickResult = null; private Node pickNode = null; private TransformGroup transformGroup = null; Canvas3D canvas; BranchGroup objRoot; Java3DFrame frame; float step = 0.005f; // was 0.01 public MyPickTranslateBehavior(Java3DFrame f,BranchGroup objRoot,Canvas3D canvas, BoundingSpherebounds) {super(objRoot, canvas, bounds); this.frame = f; this.setBounds(bounds); this.canvas = canvas; this.objRoot = objRoot; transformGroup = new TransformGroup(); modelTrans = new Transform3D(); transformY = new Transform3D();transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);//create the wakeupCriterion for the behavior WakeupCriterion criterionArray[] = newWakeupCriterion[2];criterionArray[0] = newWakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);criterionArray[1] = newWakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);//save the WakeupCriterion for the behavior m_WakeupCondition = newWakeupOr(criterionArray);} public void initialize() { // initialize wakeupOn(m_WakeupCondition); //Apply theinitial WakeupCriterion} public void processStimulus(Enumeration criteria){ // processStimuluswhile (criteria.hasMoreElements()) { WakeupCriterion wakeUp = (WakeupCriterion)criteria.nextElement();if (wakeUp instanceof WakeupOnAWTEvent) { AWTEvent[] evt = ( (WakeupOnAWTEvent)wakeUp).getAWTEvent();try { processAWTEvent(evt); } catch (Exception e) { } } } //Assign the next WakeupCondition, so we arenotified againwakeupOn(m_WakeupCondition); } private void processAWTEvent(AWTEvent[] events) { for (int n = 0; n < events.length; n++) { if (events[n] instanceof MouseEvent) { MouseEvent eventPress = (MouseEvent)events[n];if (eventPress.getModifiers() ==MouseEvent.BUTTON1_MASK) {//System.out.println("LEFT MOUSE PRESSED_ DOING ROTATION");if (eventPress.getID() ==MouseEvent.MOUSE_PRESSED) {pickCanvas.setShapeLocation(eventPress);pickResult = pickCanvas.pickClosest(); if (pickResult != null) { pickNode = pickResult.getObject(); transformGroup = (TransformGroup) pickResult.getNode(PickResult. TRANSFORM_GROUP); //System.out.println("DELETE MODE? "+frame.deleteMode()); if (frame.deleteMode() == true) { //So delete that shapetry { //no capability to detact thebranchgrouptransformGroup.removeAllChildren(); // Not yet working} catch (Exception ex) { System.out.println("DELETEEXCEPTION : " +ex.toString()); } } else { // Setup rotation of thatshapetransformGroup.getTransform(modelTrans);x = x_last = eventPress.getX(); } } } if (eventPress.getID() ==MouseEvent.MOUSE_DRAGGED) {// Rotating the object around the Yaxis onlyx = eventPress.getX(); y_angle = (x - x_last) * x_factor; transformY.rotY(y_angle); modelTrans.mul(modelTrans, transformY);transformGroup.setTransform(modelTrans);x_last = x; } } if (eventPress.getModifiers() ==MouseEvent.BUTTON3_MASK) {//System.out.println("RIGHT MOUSE PRESSED_ DOINGTRANSLATION");=== message truncated === Yahoo! Mail - 6MB, anti-spam e antivírus gratuito. Crie sua conta agora: http://mail.yahoo.com.br =========================================================================== 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".
--
D'Amore Jean-Robert
IT Systems
Bell Geospace Ltd.
Unit 5A, Crombie Lodge
Aberdeen A.S.T.P
Balgownie Drive
Aberdeen AB228GU
Tel: +44(0)1224227703
Email: [EMAIL PROTECTED]
D'Amore Jean-Robert
IT Systems
Bell Geospace Ltd.
Unit 5A, Crombie Lodge
Aberdeen A.S.T.P
Balgownie Drive
Aberdeen AB228GU
Tel: +44(0)1224227703
Email: [EMAIL PROTECTED]
=========================================================================== 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".