Author Topic: Model getting rotated while translating  (Read 1559 times)

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Model getting rotated while translating
« on: October 04, 2010, 08:35:02 am »
Hi,

        My models are getting rotated when i am trying to translate it.

I am attaching my file......Plz help it out.

[attachment deleted by admin]

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Re: Model getting rotated while translating
« Reply #1 on: October 06, 2010, 09:48:04 am »
hi.........anyone plz help it out.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Model getting rotated while translating
« Reply #2 on: October 06, 2010, 11:01:54 am »
I don't see how this is supposed to happen and i can't run this code ATM. But, apart from that, what you shouldn't do is to do a translate in the onKeyDown, because it runs in another thread than the rendering. You'll get all kinds of funny side effects when doing so. Increasing the x/y-positions is fine, but move the actual translation into the moveCharacter method. Maybe this will already fix your problem!?

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Re: Model getting rotated while translating
« Reply #3 on: October 06, 2010, 12:03:59 pm »
Hi,

       Thanx for the reply.

      I don't know how the translate method is functioning but as per my new code the translate method is adding the coordinate value(x,y,z) to the last position of the model/object.

     Its working fine now but i supposed it to perform the translate by positioning the model to the supplied coordinate value.

I don't know if its because of onKeyDown as translated the model directly in the draw method.

But its a great pleasure to use jPCT for my project.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11775
    • View Profile
    • http://www.jpct.net
Re: Model getting rotated while translating
« Reply #4 on: October 06, 2010, 12:30:52 pm »
[quote author=JKumar link=topic=1723.msg12820#msg12820 date=1286359439
     Its working fine now but i supposed it to perform the translate by positioning the model to the supplied coordinate value.
[/quote]If you want to do absolute translations, just do:

Code: [Select]
obj.clearTranslation();
obj.translate(<your position>);

However, i don't understand how this is related to rotations...is your problem now fixed or not? I couldn't derive this from your answer...!?

Offline JKumar

  • byte
  • *
  • Posts: 33
    • View Profile
Re: Model getting rotated while translating
« Reply #5 on: October 06, 2010, 02:22:59 pm »
Hi,

   The problem is fixed now.

Thanks