3 Replies
Latest reply on May 20, 2020 12:29 PM by parker9
Level 1 (0 points)

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 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

• ###### Re: how do I determine which side is up?
Level 4 (605 points)

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".)

• ###### Re: how do I determine which side is up?
Level 1 (0 points)

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

• ###### Re: how do I determine which side is up?
Level 1 (0 points)