Perdon por no incluir el texto en ingles...
V�ctor como has deducido los valores de los quaterniones ? Al azar ?
Yo sigo el siguiente sistema y funciona bien :
Un quaternion se define por 4 valores (x, y, z, w) .
Para definir una rotacion sobre un vector unitario u, por ejemplo el (0, 1, 0), y un
angulo w de 60�, las
formulas son:
x = u(x) * sin(w / 2) = 0
y = u(y) * sin(w / 2) = 0.5
z = u(z) * sin(w / 2) = 0
w = cos(w / 2) = 0.8660...
Bien ahora si miro los valores que has puesto en el primer y segundo quaternion no me
dicen nada.
Es decir, no definen ningun giro, por eso no ves ninguna interpolaci�n.
Si quieres definir un giro sobre el eje Y de 60� los valores son los de antes. Si
quieres sobre el eje X,
entoncex u = (1, 0, 0) ; etc...
Suerte...
Daniel del R�o.
V�ctor wrote:
> Hello,
> I've been messing around with the example "RotPosPathApp" from the
> "Getting Started" tutorial. I'm trying to do some rotations and
> translations. I'm using the follwing quats values:
>
> quats[0] = new Quat4f(0.0f, 0.0f, 0.0f, 0.0f);
> quats[1] = new Quat4f(0.0f, 0.5f, 0.0f, 0.0f);
> quats[2] = new Quat4f(0.0f, 0.0f, 0.5f, 0.0f);
>
> My problem is that I get no interpolation between the quat values 0
> and 1, and I don't know why. If I put another value different from 0 in
> the first quat value then the cube starts already rotated in the
> animation. What I want is to move the object a little bit to the front,
> and then rotate it. I think in the documentation is not really clearly
> explained how these values work. Attached is the source.
>
> Greetings...
>
> ------------------------------------------------------------------------
> /*
> * @(#)RotPosPathApp.java 1.0 99/07/01 11:42:40
> *
> * Copyright (c) 1996-1999 Sun Microsystems, Inc. All Rights Reserved.
> *
> * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
> * modify and redistribute this software in source and binary code form,
> * provided that i) this copyright notice and license appear on all copies of
> * the software; and ii) Licensee does not utilize the software in a manner
> * which is disparaging to Sun.
> *
> * This software is provided "AS IS," without a warranty of any kind. ALL
> * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
> * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
> * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
> * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
> * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
> * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
> * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
> * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
> * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
> * POSSIBILITY OF SUCH DAMAGES.
> *
> * This software is not designed or intended for use in on-line control of
> * aircraft, air traffic, aircraft navigation or aircraft communications; or in
> * the design, construction, operation or maintenance of any nuclear
> * facility. Licensee represents and warrants that it will not use or
> * redistribute the Software for such purposes.
> */
>
> import java.applet.Applet;
> import java.awt.BorderLayout;
> import java.awt.Frame;
> import com.sun.j3d.utils.applet.MainFrame;
> import com.sun.j3d.utils.universe.*;
> import com.sun.j3d.utils.geometry.ColorCube;
> import javax.media.j3d.*;
> import javax.vecmath.*;
>
> public class RotPosPathApp extends Applet {
>
> public BranchGroup createSceneGraph() {
> // Create the root of the branch graph
> BranchGroup objRoot = new BranchGroup();
>
> Alpha alpha = new Alpha(-1, 7000);
> TransformGroup target = new TransformGroup();
> Transform3D axisOfRotPos = new Transform3D();
> float[] knots = {0.0f, 0.2f/*0.1f, 0.2f, 0.3f, 0.4f, 0.6f, 0.8f, 0.9f*/,
>1.0f};
> Quat4f[] quats = new Quat4f[3];
> Point3f[] positions = new Point3f[3];
>
> target.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
>
> AxisAngle4f axis = new AxisAngle4f(1.0f,0.0f,0.0f,0.0f);
> axisOfRotPos.set(axis);
>
> quats[0] = new Quat4f(0.0f, 0.0f, 0.0f, 0.0f);
> quats[1] = new Quat4f(0.0f, 0.5f, 0.0f, 0.0f);
> quats[2] = new Quat4f(0.0f, 0.0f, 0.5f, 0.0f);
> /* quats[3] = new Quat4f(0.0f, 1.0f, 1.0f, 0.0f);
> quats[4] = new Quat4f(0.0f, 0.0f, 1.0f, 0.0f);
> quats[5] = new Quat4f(0.0f, 1.0f, 1.0f, 0.0f);
> quats[6] = new Quat4f(1.0f, 1.0f, 0.0f, 0.0f);
> quats[7] = new Quat4f(1.0f, 0.0f, 0.0f, 0.0f);
> quats[1] = new Quat4f(1.0f, 1.0f, 1.0f, 1.0f);*/
>
> positions[0]= new Point3f( -0.5f, 0.0f, -1.0f);
> /* positions[1]= new Point3f( 1.0f, -1.0f, -2.0f);
> positions[2]= new Point3f( -1.0f, 1.0f, -3.0f);
> positions[3]= new Point3f( 2.0f, 0.0f, -4.0f);
> positions[4]= new Point3f( -2.0f, -1.0f, -5.0f);
> positions[5]= new Point3f( 3.0f, 1.0f, -6.0f);
> positions[6]= new Point3f( -3.0f, 0.0f, -7.0f);
> positions[7]= new Point3f( 2.0f, -1.0f, -4.0f);*/
> positions[2]= new Point3f( -0.5f, 0.0f, -0.5f);
> positions[1]= positions[0];
>
> RotPosPathInterpolator rotPosPath = new RotPosPathInterpolator(
> alpha, target, axisOfRotPos, knots, quats, positions);
> rotPosPath.setSchedulingBounds(new BoundingSphere());
>
> objRoot.addChild(target);
> objRoot.addChild(rotPosPath);
> target.addChild(new ColorCube(0.4));
>
> Background background = new Background();
> background.setColor(1.0f, 1.0f, 1.0f);
> background.setApplicationBounds(new BoundingSphere());
> objRoot.addChild(background);
>
> PointArray point_geom = new PointArray(9, GeometryArray.COORDINATES);
> point_geom.setCoordinates(0, positions);
> Appearance points_appear = new Appearance();
> ColoringAttributes points_coloring = new ColoringAttributes();
> points_coloring.setColor(1.0f, 0.0f, 0.0f);
> points_appear.setColoringAttributes(points_coloring);
> PointAttributes points_points = new PointAttributes(4.0f, true);
> points_appear.setPointAttributes(points_points);
> Shape3D points = new Shape3D(point_geom, points_appear);
> objRoot.addChild(points);
>
> objRoot.compile();
>
> return objRoot;
> } // end of CreateSceneGraph method of RotPosPathApp
>
> // Create a simple scene and attach it to the virtual universe
>
> public RotPosPathApp() {
> setLayout(new BorderLayout());
> Canvas3D canvas3D = new Canvas3D(null);
> add("Center", canvas3D);
>
> BranchGroup scene = createSceneGraph();
>
> // SimpleUniverse is a Convenience Utility class
> SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
>
> // This will move the ViewPlatform back a bit so the
> // objects in the scene can be viewed.
> simpleU.getViewingPlatform().setNominalViewingTransform();
>
> simpleU.addBranchGraph(scene);
> } // end of RotPosPathApp (constructor)
>
> // The following allows this to be run as an application
> // as well as an applet
>
> public static void main(String[] args) {
> System.out.print("RotPosPathApp.java \n- a demonstration of using the
>RotPosPathInterpolator ");
> System.out.println("and Alpha classes to provide animation in a Java 3D
>scene.");
> System.out.println("The RotPosPathInterpolator changes the target
>TransformGroup");
> System.out.println("to change the POSition and ROTation along a PATH. The
>positions");
> System.out.println("are marked by the red dots in the scene.");
> System.out.println("This is a simple example progam from The Java 3D API
>Tutorial.");
> System.out.println("The Java 3D Tutorial is available on the web at:");
> System.out.println("http://java.sun.com/products/java-media/3D/collateral");
> Frame frame = new MainFrame(new RotPosPathApp(), 256, 256);
> } // end of main (method of RotPosPathApp)
>
> } // end of class RotPosPathApp
===========================================================================
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".