obj.lookAt ()

Started by Melssj5, June 21, 2006, 07:55:47 AM

Previous topic - Next topic

Melssj5

Is there anyway to implement this method into the Object3D, it may be usefull, I need to make an object3D to look at (0, 0, 1), but I dont know its actual direction, of course I cant get the zAxis and calc a angle and the rotate it, but it will be kind of messy. If anyone have another idea, please post it. I have no another object to align with!
Nada por ahora

EgonOlsen

Subtract the object's center in world space from the (0,0,1) vector to get the vector pointing from the object to (0,0,1). Use SimpleVector.getRotationMatrix() on this vector and feed the resulting matrix back into the object as its new rotation matrix.

Melssj5

:cry:  :cry:

??? what? I am afraid I am a fool about this kind of things. I better look for another way to do it.
Nada por ahora

EgonOlsen

SimpleVector la=new SimpleVector(0,0,1);
la=la.calcSub(obj.getTransformedCenter());
obj.setRotationMatrix(la.getRotationMatrix());

mogli

i have a similar problem.

i need an object that look at a point in the world.
but my problem is that this object needs to orientated at the camera direction.
this
SimpleVector la=world.getObjectByName("xx.3ds").getCenter();
la=la.calcSub(camera.getPosition());
obj.setRotationMatrix(la.getRotationMatrix());

points to the right in the world but it doesn't notice that camera has turned... :(

hope you could understand what i mean and help me...

EgonOlsen

Quote from: "mogli"hope you could understand what i mean and help me...
No, i don't really understand. You want the object to "look" at a point in world space but you want it to look into the camera's direction as well ?

Melssj5

Well, I guess that he needs that the object is aligned with the camera (direction only) and looking at the point on the world at the same time.
Nada por ahora

mogli

ok, i solved it. i set the pointing object as origin for the cam in the other world and rotate with the cam in mainworld.