How to get Object3D's Position when loaded from .3ds

Started by dubbox, January 01, 2015, 05:53:19 PM

Previous topic - Next topic

dubbox

I am confused all the get Methods which return a SimpleVector for the Object3D are not the ones i am looking for nearly all are 0,0,0,0

I just want to get the Position or Translation (the getTranslation Method does not work for me its 0,0,0,0) of an Object created in Blender and saved as .3ds file

In Blender for example a created cube is at 4,5,1 so how can i get this position after loading it into jpct-ae?

The getName() Method works nicely so i just want to get the Name and the position so i get something like :
"Cube001 at (4,5,1)"

Irony

Because you have not translated the cube in you program yet. It is still at it's initial position. That it's not in the physical center of your exported 3ds file does not really matter for JPCT...
Question: What do you want to achieve exactly? Why not just set the cube at the center and translate it in the engine?
edit: Take a look at getCenter()/ getTransformedCenter. If you only have one object in the scene, it might achieve what you want.

dubbox

The thing is i have build an building in blender and want to implement listeners to open doors when you are near to them so i have to Check for the position of the door

i can read the position in blender and set the camera to it then i am really at the position like i am in blender but i cannot access this position by calling any method in jpct it would be nicer to read it in jpct

Irony

If you export the doors as seperate files, getCenter should work.

dubbox

Its all in one file bute in that file are multiple objects so when i use the loader class i get an Object3d array of the size 36 so i have to seperate each object to an extra file?

EgonOlsen

The different positions in a nutshell:


  • getTranslation() -  That's the translation that has been applied to the object in world space. If it hasn't been translated, this will be (0,0,0).
  • getOrigin() - The origin if set. The origin is a kind of pre-translation that doesn't change over time, i.e. the normal translations add up with the origin. If none has been set, this will be (0,0,0)
  • getCenter() - The center of the object in object space. This will be calculated when calling build(). Otherwise, it will be (0,0,0).
  • getRotationPivot() - The rotation pivot of the object in object space, i.e. the point around which the object will be rotated. After calling build() and when not using http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Config.html#useRotationPivotFrom3DS, this will be equal to getCenter().
  • getTransformedCenter() -  The point in world space to which the object's object space center will be transformed given it's current translations and rotations.

EgonOlsen

#6
Quote from: dubbox on January 01, 2015, 07:57:51 PM
Its all in one file bute in that file are multiple objects so when i use the loader class i get an Object3d array of the size 36 so i have to seperate each object to an extra file?
No, you don't. If their position is fine after loading them (i.e. their translation has been baked into their object space coordinates by Blender), then just call build() on them and use getCenter().

dubbox

Thank you very much now it works just fine :))

Do you know if empties do work with jpct? Empties are just objects without meshes just a position

EgonOlsen

No, these won't be loaded. But you can assign some mesh to it, load it but only use it's position instead.

dubbox

Thats a nice workaround so i just dont add thrse objects to the world object and they wont be rendered but i can use their positions :)