how do I determine which side is up?

how do I determine which side is up? (Scenekit, Swift)


I make a cube (Dice) that spins around how do I determine which side are facing up


var Materials : [SCNMaterial] = [SCNMaterial(),SCNMaterial(),SCNMaterial(),SCNMaterial(),SCNMaterial(),SCNMaterial()]; // Dice

...

Materials[0].diffuse.contents = UIImage(named: "Dice5.png");

Materials[1].diffuse.contents = UIImage(named: "Dice2.png");

Materials[2].diffuse.contents = UIImage(named: "Dice3.png");

Materials[3].diffuse.contents = UIImage(named: "Dice4.png");

Materials[4].diffuse.contents = UIImage(named: "Dice1.png");

Materials[5].diffuse.contents = UIImage(named: "Dice6.png");

...

BoxNode.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.Dynamic, shape: nil)

BoxNode.physicsBody?.mass = 5

BoxNode.name = "Delete"

BoxNode.physicsBody!.applyForce(SCNVector3Make(0, 0, 14), impulse: true)

...

let Wait = SCNAction.waitForDuration(2)

let FadeOut = SCNAction.fadeOutWithDuration(1)

let Sequence = SCNAction.sequence([Move, Wait, FadeOut])

BoxNode.runAction(Sequence,completionHandler:

{

// Here I would like to determine which side that are facing up (1,2,3,4,5 or 6) - how do I do that


})

BoxNode.geometry!.materials = Materials; // set the Dice

Replies

You would probably have to calculate it from your choice of the rotation, eulerAngles, or orientation properties of the SCNNode.



FYI, there is a SceneKit section:

https://forums.developer.apple.com/community/graphics-and-games/scenekit


You can move this thread to that section by going to the "Actions" buton/menu near the top of this page on the right side, and choosing "Move". (Go to the bottom of the dialog which comes up, and choose spaces, then find "Graphics and Games" and click on where it says X subspaces, and then choose "SceneKit".)

Are there someone who has an example of how to calculate which side facing up