www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: fireside on August 08, 2008, 05:54:15 pm

Title: translation back to start point.
Post by: fireside on August 08, 2008, 05:54:15 pm
I'm trying to get a start point and when the mouse falls off a platform, he goes back to it, but I'm having some problems.

first I made a matrix called "start' and after the mouse was in the world used
start.setTo(mouse.getTranslationMatrix());

When the mouse is in the jump function I check y position and if it's over 20 I do:
mouse.setTranslationMatrix(start);
This works one time, but the next time he misses a platform it doesn't work anymore.
Title: Re: translation back to start point.
Post by: EgonOlsen on August 08, 2008, 06:18:20 pm
Maybe that's because getXXXMatrix() returns a reference, not a new matrix and you  modify your start matrix implicitly that way? Try something like start=new Matrix(getTranslationMatrix()); and setTranslationMatrix(new Matrix(start)); and see if that helps.
Title: Re: translation back to start point.
Post by: fireside on August 08, 2008, 09:26:59 pm
The Matrix constructor doesn't take an argument. 
Title: Re: translation back to start point.
Post by: fireside on August 08, 2008, 10:21:15 pm
This seems to work but I haven't tried it out for getting different positions.  I can get the mouse back to the origin by:
mouse.setTranslationMatrix(new Matrix());

and then give it it's original translation.
mouse.translate(-100, -20, -200);

Since I can get translation of a 3d object from the origin, I should be able to record last position and move it back that way.
Title: Re: translation back to start point.
Post by: EgonOlsen on August 08, 2008, 10:56:45 pm
The Matrix constructor doesn't take an argument. 
Opps, my bad. I've mixed this with SimpleVector. But you can use cloneMatrix() instead.
Title: Re: translation back to start point.
Post by: fireside on August 08, 2008, 11:45:22 pm
I had tried cloneMatrix and still was having trouble but it's probably something dumb I'm doing.  Anyway, I can get it to work with this other way.
Title: Re: translation back to start point.
Post by: EgonOlsen on August 09, 2008, 10:49:23 am
Ok, fine. I'll add that Matrix-constructor anyway to avoid further confusion (of myself) in the future.
Title: Re: translation back to start point.
Post by: fireside on August 09, 2008, 03:21:14 pm
I think that would be a good idea, also.  It just seems like it belongs there.