Platforms to show: All Mac Windows Linux Cross-Platform

/Mac64bit/SceneKit/Change Backgroundcolor by Click
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Mac64bit/SceneKit/Change Backgroundcolor by Click
This example is the version from Wed, 24th Mar 2020.
Project "Change Backgroundcolor by Click.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 Function MouseDown(x as Integer, y as Integer, Modifiers as Integer) As Boolean //Saves the coordinates of the click Dim p As New CGPointMBS(x, y) // Checks if there are objects at this point and list them in an array Dim results() As SCNHitTestResultMBS = myview.hitTest(p) If results <> Nil And results.Ubound >= 0 Then // hit something //Get first item from the array Dim result As SCNHitTestResultMBS = results(0) //Get the background color of the clicked node background = result.node.Geometry.firstMaterial.diffuse.contents //Set the background color MyView.backgroundColor = Background End If End EventHandler
EventHandler Sub Open() // Initialization of the working environment MyView = Me.View MyScene = New SCNSceneMBS MyView.scene = MyScene //Set Backgroundcolor, Default light and allows camera control MyView.backgroundColor = NSColorMBS.blackColor MyView.autoenablesDefaultLighting = True Myview.allowsCameraControl = True // Initialize right sphere in yellow Dim sphere1Geometry As New SCNSphereMBS(1) Dim sphere1 As New SCNNodeMBS(sphere1Geometry) sphere1.Position = New SCNVector3MBS(2, 0, 0) sphere1Geometry.firstMaterial.diffuse.contents = NSColorMBS.yellowColor // Initialize left sphere in blue Dim sphere2Geometry As New SCNSphereMBS(1) Dim sphere2 As New SCNNodeMBS(sphere2Geometry) sphere2.Position = New SCNVector3MBS(-2, 0, 0) sphere2Geometry.firstMaterial.diffuse.contents = NSColorMBS.blueColor //Add both sphere to the scene MyScene.rootNode.addChildNode(sphere1) MyScene.rootNode.addChildNode(sphere2) End EventHandler
End Control
Property Background As NSColorMBS
Property MyScene As SCNSceneMBS
Property MyView As SCNViewMBS
Property count As Integer = 0
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

Feedback, Comments & Corrections

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

The biggest plugin in space...




Links
MBS Xojo tutorial videos