I have a little problem here, in that I think I am missing something on pivoting
on a arbitrary point
to rotate about some point

translate point to origin
rotate
translate point back

snippet of code from MouseRotate that should work

x_angle = dy * y_factor;
                    y_angle = dx * x_factor;
                    
                    transformX.rotX(x_angle);
                    transformY.rotY(y_angle);
                    
                    transformGroup.getTransform(currXform);
                    
                    //Vector3d translation = new Vector3d();
                    //Matrix3f rotation = new Matrix3f();
                    Matrix4d mat = new Matrix4d();
                    
                    // Remember old matrix
                        currXform.setTranslation(new Vector3d(0,0,0));
                
                    currXform.get(mat);
                    
                    // Translate to origin
                    //currXform.setTranslation(new Vector3d(0.0,0.0,0.0));
                        Vector3d negate = new Vector3d(mPivotPoint);
                        negate.negate();
                        currXform.setTranslation(negate);
                        //that should set the translation of the point down to
the origin
                        
                    if (invert) {
                        currXform.mul(currXform, transformX);
                        currXform.mul(currXform, transformY);
                    } else {
                        currXform.mul(transformX, currXform);
                        currXform.mul(transformY, currXform);
                    }
                    
                    // Set old translation back
                    Vector3d translation = new 
                      Vector3d(mat.m03, mat.m13, mat.m23);
                  
                           //currXform.setTranslation(translation);
                   currXform.setTranslation(mPivotPoint);
                   //and we now set the translation back
                        
                        
                    // Update xform
                    transformGroup.setTransform(currXform);


Shouldn't this work?
what I am testing on is a simple cube from the hellouniverse example
adding a PivotBehavior to the transform group right above the cube
so, the cube is at 0,0,0
the pivot point is at 0,.5,0

yet, when run, the cube then just translates up to 0,.5,0 and rotates there

what am I missing?
Thanks
Scott



Scott Decker
Research Scientist
Pacific Northwest National Labs
[EMAIL PROTECTED]

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to