www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: dubbox on January 01, 2015, 05:53:19 pm

Title: How to get Object3D's Position when loaded from .3ds
Post by: dubbox on January 01, 2015, 05:53:19 pm
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)"
Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: Irony on January 01, 2015, 07:31:09 pm
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.
Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: dubbox on January 01, 2015, 07:36:06 pm
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
Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: Irony on January 01, 2015, 07:50:10 pm
If you export the doors as seperate files, getCenter should work.
Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: 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?
Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: EgonOlsen on January 01, 2015, 08:03:05 pm
The different positions in a nutshell:

Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: EgonOlsen on January 01, 2015, 08:04:22 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().
Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: dubbox on January 01, 2015, 09:28:37 pm
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
Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: EgonOlsen on January 02, 2015, 12:41:19 am
No, these won't be loaded. But you can assign some mesh to it, load it but only use it's position instead.
Title: Re: How to get Object3D's Position when loaded from .3ds
Post by: dubbox on January 02, 2015, 01:03:13 am
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 :)