[java]

Spatial rocket;

ParticleEmitter smoketrail;

smoketrail.setInWorldSpace(false);

Node pivot = new Node(“pivot”);

rootNode.attachChild(pivot);

pivot.attachChild(rocket);

pivot.attachChild(smoketrail);

pivot.setLocalTranslation(start);

pivot.lookAt(target,Vector3f.UNIT_Y);

[/java]

I would like to let the rocket fly in the curve below(p0=start, p1, p2=target as known coordinates):

How can I let the rocket rotate like the green tangent?

I have tried to calculate all the middle points, and then with

[java]pivot.lookAt(interpolatePath(), Vector3f.UNIT_Y);[/java]

But it doesn’t work.

Can someone help me please? It would be best with an example in detail.

To interpolate between P1 and P2 you can use FastMath.interpolate(), this way your lookAt() method might still work, but you have to account for the “up” vector of the rotation to get correct results. For information and examples on rotation, check this document.

@kaelthas added support for bezier curves yesterday, maybe that can help see the spline, curve and FastMath classes

normen said:

For information and examples on rotation, check this document.

you suggested me to read the document.

i have done that. but i am really a newbie with jme, so i dont understand it completely.

here is my question:

which case fits my problem? three angles or three axes?

i have tried with three angels.

//rotate 1 radian on the x, 3 on the y and 0 on z

float[] angles = {1, 3, 0};

i did it like this(previousmeans the previous point on the bezier curve, next means the next point):

angles[0] = next.getX() – previous.getX();

angles[1] = next.getY() – previous.getY();

angles[2] = next.getZ() – previous.getZ();

but it seems wrong, and the rocket flies like drunk.

can you help me more please? thx

This should look from above like your animation (pseudo-code):

[java]

time = time + tpf;

Vector3f locationA = FastMath.interpolate(P0, P1, time);

Vector3f locationB = FastMath.interpolate(P1, P2, time);

Vector3f locationBetween = FastMath.interpolate(locationA, locationB, time);

spatial.setLocalTranslation(locationBetween);

spatial.lookAt(locationB);

[/java]

ah, i see.

thx a lot.