Here are two files , one is java3d file and other one is a vrml file which
do same job.
It may be useful to you to understand RotPosPathInterpolator
----------------java3d file---------
//Rot.java
import com.sun.j3d.utils.geometry.ColorCube;
import java.applet.Applet;
import java.awt.BorderLayout;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public class Rot extends Applet {
float knot[] = {0.0f,0.25f,0.5f,0.75f,1.0f};
Point3f pos[] = {
new Point3f(-.8f,-.6f,0.0f),
new Point3f(-.8f,.6f, 0.0f),
new Point3f(.8f, .6f, 0.0f),
new Point3f(.8f, -.6f,0.0f),
new Point3f(-.8f,-.6f,0.0f), };
Quat4f quat[ ] = {
new Quat4f( 0.0f ,1.0f ,0.0f ,0.0f),
new Quat4f(0.0f ,1.0f ,0.0f ,0.78f ),
new Quat4f(0.0f ,1.0f, 0.0f , 1.57f ),
new Quat4f(0.0f, 1.0f ,0.0f, 0.78f ),
new Quat4f( 0.0f ,1.0f, 0.0f, 0.0f ) };
private BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
TransformGroup objTran=new TransformGroup();
objTran.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Transform3D t3d=new Transform3D();
t3d.setScale(.3);
objTran.setTransform(t3d);
objRoot.addChild(objTran);
BoundingSphere bound=new BoundingSphere(
new Point3d(0.0,0.0,0.0),50.);
Transform3D tr=new Transform3D();
TransformGroup translation=new TransformGroup(tr);
translation.addChild(new ColorCube(.2));
objTran.addChild(translation);
translation.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Alpha xtranAlpha = new Alpha(-1,
Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE,
0, 0,10000, 0, 2000, 10000, 0, 2000);
RotPosPathInterpolator tran =
new RotPosPathInterpolator(xtranAlpha, translation, tr,
knot,quat , pos);
tran.setSchedulingBounds(bound);
translation.addChild(tran);
return objRoot;
}
public Rot() {
setLayout(new BorderLayout());
Canvas3D c = new Canvas3D(null);
add("Center", c);
BranchGroup scene = createSceneGraph();
SimpleUniverse u = new SimpleUniverse(c);
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(scene);
}
public static void main(String[] args) {
new MainFrame(new Rot(), 640,480);
}
}
//end of Rot.java
----------------vrml file ----------
#VRML V2.0 utf8
DEF T Transform{
children Shape{
appearance Appearance{
material Material{diffuseColor 1 0 0}}
geometry Box{size .5 .5 .5}}
}
DEF TS TimeSensor{
loop TRUE
cycleInterval 10}
DEF PI PositionInterpolator{
key[0 .125 .25 .375 .5 .625 .75 .875 1]
keyValue[-.8 -.6 0 , -.8 .6 0,
.8 .6 0, .8 -.6 0, -.8 -.6 0
.8 -.6 0, .8 .6 0, -.8 .6 0
-.8 -.6 0]}
DEF OI OrientationInterpolator{
key[0 .125 .25 .375 .5 .625 .75 .875 1]
keyValue[0 1 0 0,0 1 0 .78,0 1 0 1.57, 0 1 0 0.78,
0 1 0 0, 0 1 0 0.78, 0 1 0 1.57, 0 1 0 0.78
0 1 0 0]}
ROUTE TS.fraction TO PI.fraction
ROUTE PI.value TO T.translation
ROUTE TS.fraction TO OI.fraction
ROUTE OI.value TO T.rotation
Background{skyColor 1 1 1}
Viewpoint{
position 0 2 8
orientation 1 0 0 -.3}
# end of Rot.wrl
----------------end of files--------
Chris Wewerka wrote:
> Hi,
>
> is anyone able to give me information how to use the
> RotPosPathInterpolator?
> I also need a description what the quat values at each knot exactly
> mean.
>
> My purpose:
> I want to rotate and translate an object in such a way that it slowly
> rotates and moves the part, which was clicked, towards the viewer.
> I'm trying to realize this using the RotPosPathInterpolator, but because
> of the documentation, which explains this in a pretty short form, I do
> not really know what the quaternion values are for at each knot.
>
> Thanks,
>
> Chris Wewerka
>
> =====================================================================
> To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> Java 3D Home Page: http://java.sun.com/products/java-media/3D/
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/