Author Topic: translation back to start point.  (Read 4550 times)

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
translation back to start point.
« 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.
click here->Fireside 7 Games<-

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: translation back to start point.
« Reply #1 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.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: translation back to start point.
« Reply #2 on: August 08, 2008, 09:26:59 pm »
The Matrix constructor doesn't take an argument. 
click here->Fireside 7 Games<-

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: translation back to start point.
« Reply #3 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.
click here->Fireside 7 Games<-

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: translation back to start point.
« Reply #4 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.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: translation back to start point.
« Reply #5 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.
click here->Fireside 7 Games<-

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: translation back to start point.
« Reply #6 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.

Offline fireside

  • double
  • *****
  • Posts: 607
    • View Profile
Re: translation back to start point.
« Reply #7 on: August 09, 2008, 03:21:14 pm »
I think that would be a good idea, also.  It just seems like it belongs there.
click here->Fireside 7 Games<-