Reputation: 194
I tried this
xxxx.pivot = SCNMatrix4MakeTranslation(0.5, 0.5, 0.5)
But it does not make it centered. What is the best way of doing that with code?
Upvotes: 0
Views: 280
Reputation: 2415
Center the pivot to the center of the object, and the object to the center of the world, in Blender, Cheeatah 3D, 3D studio Max or any other suitable software and then re-export it with the pivot in the proper position. Changing the pivot in code does not have the same effect and will quite likely lead to other issues once you want to translate, rotate, scale etc. Offsetting the pivot through code is not really meant as a fix for an incorrectly placed pivot which is actually the result of the vertices having the wrong positions. Rather than trying to patch that in code, fix it properly in a 3D modeling package.
Upvotes: 1
Reputation: 148
A little confused about the question. Are you trying to center the couch on the coordinate origin? Why are you using pivot
instead of translation
? The pivot
property moves the local coordinate system origin relative to the object itself (i.e. setting the upper left corner of the couch to be 0,0, instead of the center). Whereas translation
moves the object in the scene but maintains the object's position relative to its own coordinate system. Which are you trying to accomplish?
https://developer.apple.com/documentation/scenekit/scnnode/1408044-pivot
Upvotes: 1