I'm working on some tools for Blender->BeamNG and cant seem to get the rotation Matrix to resolve properly in BeamNG. I'm working on a python script that will take the X,Y,Z radian rotation values, convert them to the rotationMatrix in the order of ZXY. There seems to be an extra layer of data processing that Beam is doing on top of the rotationMatrix results. I've noticed in the BeamNG UI, you can input any rotation values in the boxes, but they resolve to a range of +-90 for X, and +-180 for Y and Z. When I enter 260 into the Z, it takes the value, but converts it to -100. Does anyone have any insight into this? --- Post updated --- I've created a custom panel in Blender to help me troubleshoot the conversion. I'm leveraging the Matrix functions from the mathutils python library within Blender to convert from Euler to Rotation Matrix. When I reduce 3x3 array to a linear rotationMatrix, BeamNG will read in the results, but they get interpreted improperly. --- Post updated --- I've created a custom panel in Blender to help me troubleshoot the conversion. I'm leveraging the Matrix functions from the mathutils python library within Blender to convert from Euler to Rotation Matrix. When I reduce 3x3 array to a linear rotationMatrix, BeamNG will read in the results, but they get interpreted improperly. --- Post updated --- Do i need to convert the Euler -> Quaternion before I do my conversion to RotationMatrix? --- Post updated --- I've updated my panel with the euler>quaternion>rotationMatrix. Testing this now:
How did you solve it? Please update your post or add a new reply detailing your solution, so that other people with the same problem as you can see it.
For a quick and easy method I used ChatGTP and it worked flawlessly. I had a dozen or so prefab files that I simply wanted to modify each one so a few objects inside were all rotated 90º I could have just remade every prefab, but I really just wanted to do a quick "find and replace in files" to just batch them out since they all had the same rotation. In the WorldEditor I loaded a prefab and rotated one object how I wanted then copied the rotation from the Inspector window. Then plugged that into GTP. I put the new matrix it gave me into the prefab files and all of the objects were rotated exactly how I wanted. Just keep an eye out on the X,Y,Z order - regardless of which order you type, it usually tells you the order for the results, but they can easily be different then your original order. So If you have an object in the BeamNG WorldEditor (or blender) you can simply right click > copy the rotation numbers from the Inspector window: eg. {"copiedFieldType":"EulerRotation","copiedValue":"-0.00482931221 -0.00158329576 0.121708125"} then in ChatGTP: Code: convert the given Euler angles "-0.00482931221 -0.00158329576 0.121708125" into a rotation matrix gave me this output: Code: ... ... Therefore, the rotation matrix is approximately: R ≈ | 0.999994577 -0.003251269 -0.000014892 | | 0.003251268 0.999992327 -0.00390505 | | 0.000025236 0.003905048 0.999992042 | --OR-- Code: convert the given Radian angles "12,42,120" into a rotation matrix Code: ... ... R = | 0.5000 -0.8660 0.0000 | | 0.8660 0.5000 0.0000 | | 0.0000 0.0000 1.0000 | All of this can be done in reverse and you can be a LITTLE bit sloppy when typing your prompt, the first time I tried I just pasted the whole {"copiedFieldType":"EulerRotation".... line into the prompt and it still gave me the right answer. If you get a result and it doesnt show the finished results sometimes you need to simply prompt "display the final matrix" and it will show the exampled I have above.