Author Topic: Get world position of untransformed object.  (Read 2240 times)

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Get world position of untransformed object.
« on: December 10, 2008, 11:28:34 am »
Hi.

I've imported an object3d an need to translate it to world origo, but how to I get the objects world position when it hasn't been transformed?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Get world position of untransformed object.
« Reply #1 on: December 10, 2008, 12:46:56 pm »
I don't get your question!? If the object hasn't been transformed, it has no coordinates in world space... ???

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Re: Get world position of untransformed object.
« Reply #2 on: December 10, 2008, 03:56:30 pm »
It must be a lack of understanding.

Isn't a loaded 3ds model placed in the world according to its vertice values, or at world origom or? If the model (an edge to be simple) has a vertex with value 100,100,100 and another at 20,20,20, I would at first think that I could get the object's center in worldspace somehow. Which is 60,60,60.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Get world position of untransformed object.
« Reply #3 on: December 10, 2008, 04:00:25 pm »
60,60,60 is object space, not world space. If you load that object and simply add it to the world without any tranformation, world space = object space for this object. The loader doesn't define an origin or something. You can call build() on the object and do a getCenter() on it afterwards. Maybe that is the value you want?

Offline fireside

  • double
  • *****
  • Posts: 605
    • View Profile
Re: Get world position of untransformed object.
« Reply #4 on: December 10, 2008, 08:17:23 pm »
I think I had a problem similar to this.  I made a small program where I could place objects by moving them around with the keyboard and then had it print out the location when I had it in the place I wanted it to be in comparison to the level.   Then I just translated the object to that position after it was added to the world.  I tried getting relative positions from my modeling program but it didn't seem to work out, although it seems like it would be possible.
click here->Fireside 7 Games<-

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Get world position of untransformed object.
« Reply #5 on: December 10, 2008, 11:17:45 pm »
Not sure if this is relevant, as I don't completely understand the question, but I thought I would throw it out there anyway.

If you are having a problem with the fact that jPCT calculates a different center for your object than what you expect it to be, you can use methods setCenter() and setRotationPivot() after calling build() for your object.  Also, the setOrigin() method could be used to define a position in world space to begin translations from.

Usually you kind of have to play around with each model you create before it appears the way you want it to in jPCT (the same is true when transfering something from one modeling program to another, so this is certainly not unique to jPCT).  A model's scale, rotations, and center are very often not exactly the same as you want them to be, since these things are, after all, relative in nature.