Author Topic: suggestion on API, setTranslation, setMatrix, setOrigin  (Read 407 times)

Offline MichaelJPCT

  • long
  • ***
  • Posts: 136
    • View Profile
suggestion on API, setTranslation, setMatrix, setOrigin
« on: July 06, 2016, 09:23:12 am »
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) ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: suggestion on API, setTranslation, setMatrix, setOrigin
« Reply #1 on: July 06, 2016, 03:24:51 pm »
isn't setTranslation() a better method?

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

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.

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.