2
« on: September 22, 2006, 09:35:42 pm »
Thank you for the quick response, I will keep the inverse matrix in mind, it seems to be realy important. But sadly I don't get it to work. I think it would be great if it would be possible to set the up-orientation as a second parameter to the lookAt - method like it is possible in direct x, what do you think?
I integrated the code you showed me, and it works for the x axis, but funnily not for the other axes. But ok, that may be just my lack of understanding.
I tried to understand my problem from the root, and a lot of it is just my own stupidity. So instead of rotating the camera I tried a simpler task: rotating an object around another. But even this is something I don't get to work. Please have a look at the following code:
// pointer is a little pyramid that should rotate around an object
SimpleVector p = pointer.getTransformedCenter();
// object is the rotation center
SimpleVector o = object.getTransformedCenter();
// v is the vector from the object to the pointer
SimpleVector v = p.calcSub(o);
// this shows that v.length is not constant!
System.out.println(p+" "+v.length());
// make a copy of v
SimpleVector w = new SimpleVector(v);
// rotate the copy a little bit
w.rotateY(dy);
// set the pointer to the new position = move it the difference
// between old and new position
pointer.translate(v.calcSub(w));
I let this code run every time I move the mouse. The problem is that it is not stable - the pointer rotates around the object, but it is also moving away from it (length of v is increasing). If I comment the rotation line out, than it is stable (ok, it does nothing then). Can this be a number precision error? What would be the best way to do this task? Another question is how to set an object to a new Position. A camera has a position, but an object does not have a setTransformedCenter-Method or something like that, and that is the reason I came to this translation construct.
Thanks for your help for this bloody beginner
Sebastian