Open oganm opened 5 years ago
"Translation" here is synonym to "Position" (by the way I can't understand why)
Ah it seems like they merged the function to change the position and set the position into a single function since the widgets initiate at the origin. Thanks!
Yes its addTranslation() The new API kinda works like the OpenGL stack, so the methods are also named like that.
Also think of it as moving instead of setting a position as if you do another addTranslation they will add up, so calling widget.addTranslation(0, 2, 0)
twice will move the widget 4 blocks up, if you dont want to save multiple translations on the render stack you can change the values of a existing modifier, the following example will move the widget to y2 first and then set it to y4
modifierIndex = widget.addTranslation(0, 2, 0)
widget.updateModifier(modifierIndex, 0, 4, 0)
Are the modifiers ordered in the same way they are shown in the wiki? Might be nice to have named constants for them
no, they are executed and get their index in the order you add them to a widget, so you have to store their index if you want to modify them later.
-- this example would draw the widget 2 blocks above and then rotate it
modifier1 = widget.addTranslation(0, 2, 0)
modifier2 = widget.addRotation(45, 0, 1, 0)
-- this example would rotate by 45° and move in that angle 2 blocks away to draw the widget
modifier1 = widget.addRotation(45, 0, 1, 0)
modifier2 = widget.addTranslation(0, 2, 0)
so changing in which order you add the modifiers can significantly change the render result.
old openglasses1 behavior can be easy wrapped with a small lua lib which uses fixed modifiers like you mentioned before, and just updates them when necessary.
btw. all add Modifier methods return their index. so if you just want to keep track of one for later usage you dont have to count them, just store it somewhere
-- add green color
myColorModifier = widget.addColor(0, 1, 0, 0)
-- some code [...]
-- change the green to red color
widget.updateModifier(myColorModifier, 1, 0, 0, 0)
I am going through the wiki but I was unable to find functions to set positions of 3D objects like cube3D. Is there a way to do this or is it a work in progress? It seems like OCG1 had functions to set positions but those don't seem to exist anymore