ios - Place SCNNode Intersecting Detection -
ios - Place SCNNode Intersecting Detection -
is possible find out if 1 scnnode touching another?
i want randomly place nodes in plane without of them intersecting.
let's have box.
scnnode *box = [scnnode node]; box.geometry = [scnbox boxwithwidth:1 height:1 length:1 chamferradius:0]; let's create plane position boxes in well.
cgrect plane = cgrectmake(0,0,3,3); now let's place 3 random boxes in 3x3 square.
for (int = 0; < 3; i++) { int randomx = arc4random() % 3; int randomz = arc4random() % 3; scnnode *node = [box copy]; node.position = scnvector3make(randomx, 1, randomz); [self.rootnode addchild:node]; } as stands now, boxes share same coordinates, , result undesirable. thinking of putting contents of loop in do-while loop.
for (int = 0; < 3; i++) { bool isintersecting; { isintersecting = no; //above placement of node. (scnnode *child in self.rootnode.childnodes) if ([self testintersectingbetween:(scnnode*)a :(scnnode*)b]) isintersecting = yes; }while(isintersecting) } how test intersection between 2 nodes?
ios objective-c scenekit
Comments
Post a Comment