Example: /Mac64bit/SceneKit/Physics

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/Mac64bit/SceneKit/Physics


Required plugins for this example: MBS Mac64bit Plugin, MBS MacBase Plugin, MBS MacCG Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Mac64bit/SceneKit/Physics

This example is the version from Wed, 24th Mar 2020.

Project "Physics.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class mainWindow Inherits Window
Control MyControl Inherits SCNControlMBS
ControlInstance MyControl Inherits SCNControlMBS
EventHandler Sub Open() // Initialization of the working environment MyView = Me.View MyScene = New SCNSceneMBS //Set Backgroundcolor, Default light and allows camera control MyView.scene = MyScene MyView.backgroundColor = NSColorMBS.blackColor MyView.autoenablesDefaultLighting = True Myview.allowsCameraControl = True //Start the timer Timer1.Mode = 1 End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() mass=TextField1.text.Val End EventHandler
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() //Initialize the geometry of the pyramids Dim pyramidGeometry As New SCNPyramidMBS(1, 1, 1) //Set the color of the pyramides pyramidGeometry.firstMaterial.diffuse.contents = NSColorMBS.redColor //Create right Pyramide Dim pyramid1 As New SCNNodeMBS(pyramidGeometry) pyramid1.Position = New SCNVector3MBS(5, 0, 0) //Create left Pyramide Dim pyramid2 As New SCNNodeMBS(pyramidGeometry) pyramid2.Position = New SCNVector3MBS(-5, 0, 0) //Apply physics. The objects that refer to the same node or geometry can influence each other pyramid1.physicsBody = New SCNPhysicsBodyMBS(1, New SCNPhysicsShapeMBS(pyramidGeometry)) pyramid2.physicsBody = New SCNPhysicsBodyMBS(1, New SCNPhysicsShapeMBS(pyramidGeometry)) //Specify the movement of the objects Dim force1 As New SCNVector3MBS(-10, 10, 0) Dim force2 As New SCNVector3MBS(10, 10, 0) pyramid1.physicsBody.applyForce(force1, True) pyramid2.physicsBody.applyForce(force2, True) //Gives the object a mass. //If the mass is less than 1, the object does not move over the physical specification pyramid1.physicsBody.mass = mass //Add them to the Sceen MyScene.rootNode.addChildNode(pyramid1) MyScene.rootNode.addChildNode(pyramid2) //Timer Settings Timer1.Mode = 2 timer1.Period = 600 End EventHandler
End Control
Property MyScene As SCNSceneMBS
Property MyView As SCNViewMBS
Property mass As Integer = 1
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

The items on this page are in the following plugins: MBS Mac64bit Plugin.


💬 Ask a question or report a problem