Moving an Object3D to another smoothly.

Started by dl.zerocool, May 26, 2010, 07:55:02 PM

Previous topic - Next topic

dl.zerocool

Hello.

I would like to know if someone know how to move an Object3D to another smoothly,
without using too much resources ?

Thank you in advance.

EgonOlsen


dl.zerocool

No no just a simple translation algorithm :P

EgonOlsen

I don't get it...what is a translation if not a morph in this case. Any examples?

dl.zerocool

hmm... I didn't explain myself very well certainly. (sorry)

I want to move and object X to another object Y  position, but smoothly, and I want to use calculation time as low  as possible

The best would be to be able to render à simple vector between both objects and make the object X follow this vector.

So if needed I can apply some math to this vector to make it less straight to the other object.

I don't know if I explained myself pretty well.
I already have a way to do it. But it's not very clean, and use too much calculation.

at moment I've a function "move" proprietary to each of my objects and make them move not in a straight line to a direction.

But I've to store few last pos value to be able to decide the next point to move to.

I don't want my object to move   like this ->    ___/\/\/\/  etc... I want something more smoth like a sinus or a cos ;)

EgonOlsen

To keep it simple and fast, i would use some kind of linear interpolation. But i guess, you are already doing something like that. What's wrong with it? Too slow?

dl.zerocool

No atm I'm using something like this
" if (getTransformedCenter().x < obj.getTransformedCenter().x)
    translate(speed, 0f, 0f);
etc."


Just wanted to know if there was something better.

I don't know pretty much 3D math, I know basic vectors equations etc...
find an opposite point of a plan, distance between a point and a line or a plan, projection of a point to a plan, apply matrice to transforme an object (rotate,
scale, translate)  etc..
So very basic IMO.

^^ I try to do a function to lookAt another object but I think I didn't understand it correctly XD
   public void lookAt(Object3D obj){
   lookVector.set(getXAxis().x-obj.getXAxis().x,
      getYAxis().y-obj.getYAxis().y,
      getZAxis().z-obj.getZAxis().z);
   
   setOrientation(lookVector.normalize(), obj.getYAxis().normalize());
    }

EgonOlsen

Those vectors have to be perpendicular and in your example, they are not (except by accident).
You might try to set the objects rotation matrix to delta.getRotationMatrix()...it will suffer from the usual lookAt drawbacks, but might be sufficient.

dl.zerocool

Thank you !
:)
"those vectors have to be perpendicular solved my problem"
I didn't tough they had to be perpendicular.

I was seeing dir as   vector director from A to B
and up like the vector OY of B

Thank you ;)

dl.zerocool

Another question, is it possible to know world camera position ?

EgonOlsen


dl.zerocool

^^Sorry I forgot to inherit Camera
That's why I wasn't seeing the method.

dl.zerocool

#12
I've another problem, I'm using camera.getDirection()

But even if I move the camera with camera.rotateCameraX/Y/Z
getDirection still continue to give me the direction of the backbuffer and not the actual poiting camera direction.

Is there a way to solve this ?

I shot projectiles from the camera position and direction that's why I need this.

[edit] I'm using rotateCamera  not rotate.

EgonOlsen

#13
Which backbuffer? The Camera in AE isn't buffered like in desktop jPCT, so you should be getting the current direction... ???

dl.zerocool

No sadly I'm not,

There's rotateCameraY(Rotates the camera around the y-axis.)  and rotateY wich(Rotates the backbuffer matrix around the y-axis.)

I'm using rotateCameraY

and when I do a getDirection I get the direction that the camera what initially pointing, not the current direction.