suggestion on API, setTranslation, setMatrix, setOrigin

Started by MichaelJPCT, July 06, 2016, 09:23:12 AM

Previous topic - Next topic

MichaelJPCT

when i want to position an Object3D, if the object has children, i can't use setOrigin(), i must set the translation.
but there is no setTranslation(), there is translate() which requires relative position.
but most of the time i don't directly know how much should i move the object, instead i know the current position of the object. so i call clearTranslation() then translate(), or set the Matrix of the object. in case i just need to position an object at a certain position, i don't need a Matrix, isn't setTranslation() a better method?
and if Object3D has a setMatrix method like this, setMatrix(float[] matrixFloatArray), that can be convenient too.

and some APIs require a SimpleVector as argument, such as setOrigin(SimpleVector vec), why not a method like setOrigin(float x,float y,float z) ?

EgonOlsen

Quote from: MichaelJPCT on July 06, 2016, 09:23:12 AM
isn't setTranslation() a better method?

Yes, maybe. I'll consider adding it. For now, you could simply extends Object3D and add it yourself.

Quote from: MichaelJPCT on July 06, 2016, 09:23:12 AM
setMatrix(float[] matrixFloatArray), that can be convenient too.

That will cause more confusion than it would help IMHO. You can use the setDump(float[])-method in Matrix instead. If you really think that you need it, just extends Object3D as mentioned above.

Quote from: MichaelJPCT on July 06, 2016, 09:23:12 AM
and some APIs require a SimpleVector as argument, such as setOrigin(SimpleVector vec), why not a method like setOrigin(float x,float y,float z) ?
I actually prefer the SimpleVector and provide discrete float setters only in methods that are either very very old or where I thought that it might be useful, especially on Android. setOrigin() is something that should be called once per object, so I saw no need to give it a discrete float variant in addition.