swift - Getting an SCNNode's bounding volume with rotation -


i have simple scene set using xcode level editor.

enter image description here

as can see, 1 of 1x5 rectangular cuboids has been rotated 90º. achieved setting y attribute of euler angles property 90 in node inspector.

enter image description here

but notice bounding box doesn't account cuboids rotation. case when iterate through scnnodes in scene. both cuboids have same bounding volumne

for wall:scnnode in walls.childnodes {     var v1 = scnvector3zero     var v2 = scnvector3zero     wall.getboundingboxmin(&v1, max:&v2)     print(v1, v2) }  // prints // scnvector3(x: -0.5, y: 0.0, z: -2.5) scnvector3(x: 0.5, y: 0.5, z: 2.5) // scnvector3(x: -0.5, y: 0.0, z: -2.5) scnvector3(x: 0.5, y: 0.5, z: 2.5) 

so seems bounding volume calculated using child node's own coordinate system, not node parent's (or scene's) coordinate system. leaves me wondering; how calculate scnnodes bounding volume in scene?

looking through documentation scnnode, seems information there. can read eulerangles gives me correct rotation around y axis. can read transform property.

i thought might able multiply vectors nodes transform matrix, transform matrix (4x4) , bounding box vectors (1x3) don't appear compatible. nor scenekit appear provide methods applying transformation matrix vector. however, i'm not great geometry missing obvious.

a few ideas:

  1. in interface builder, shown on screenshot, there's editing space property can set world (instead of local)

  2. in code, can use temporary node compute bounding box. make sure has 1 child node (the node bounding box want compute), apply transform on child node, , ask parent node bounding box. documentation:

the bounding volume of node containing child nodes minimal volume encloses bounding volumes of node’s children.

  1. get node's bounding box , use utils such -convertposition:tonode: compute bounding box in another's coordinate system

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -