Get world position of untransformed object.

Started by ErDetEnAnd?, December 10, 2008, 11:28:34 AM

Previous topic - Next topic

ErDetEnAnd?

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?

EgonOlsen

I don't get your question!? If the object hasn't been transformed, it has no coordinates in world space... ???

ErDetEnAnd?

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.

EgonOlsen

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?

fireside

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<-

paulscode

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.