How to create scripts with Nova
We will see in this chapter, with different and simple examples, how the script engine allows to interact within a
NOVA scene.
First steps with the script editor - basis of Visual Basic programming
When you click on the
New button of the script editor, a window invites us to enter the name of the script that we want to create. An empty script appears in the editor:
 A script when being created |
Here is the minimum combination so that a script can be run properly: :
- A class (between "Class Script" and "End Class")
- A method New
- A method Finalize
If we run a script (via the
Run button),
NOVA localizes the method New of the script and executes the instructions situated in the content of this method. In the method New, we will do all the actions of initialization needed to run our script.
When we get out of the scene, when clicking on the
Stop button or if we click a second time on the
Run button,
NOVA executes the instructions situated in the content of the method Finalize (). The method Finalize () allows us to "clean up" all that has been created in our script.
Commented example n° 1: Changing the material of an object
The aim of this script is to change rapidly and dynamically the material of an object. For this example and the 5 next ones, we will need a scene exported form 3ds Max available
here.
This scene contains:
- A box (Box01) which has no material associated.
- 3 icons containing a material for each of them:
- YellowIconObject and his material Material Yellow
- GreenIconObject and his material MaterialGreen
- BlueIconObject and his material MaterialBlue
- 3 invisible plans (the option Renderable has been unchecked in the objects properties within 3ds Max carrying the materials that will be used later on:
- InvisiblePlane01 associated to the material Material Yellow For Box
- InvisiblePlane02 associated to the material Material Green For Box
- InvisiblePlane03 associated to the material Material Blue For Box
These plans are not rendered on the screen, they just allow us to export the materials created in 3ds Max that are not affected to any object. In fact, the
NOVA Exporter runs a series of optimizations when processing the export, one of them consisting in not exporting the materials which are not affected to objects in order to avoid heavy resources associated to the scene.
- 1 light to enlighten our scene.
- 1 camera to visualize the scene.
If we open the mxb format scene in
NOVA, we have access to all this information when opening the
Entities Browser window and the
Properties window:
 The scene we will use for the scripts examples |
In the scripts, we have access to all the information (and even more!) in the
Entities Browser and in the
Properties, which means that we will be able to modify dynamically the content of these windows during the scene run.
 Entities Browser |
It is very easy to change from the
Entities Browser to the scripts: a Scene becomes a
NovaScene, a camera becomes a
NovaCamera, a group becomes a
NovaGroup, etc. We can see in the
Entities Browser that all the elements of the scene are hierarchically situated under Scene. If we had access to this scene, we could have access to all its content !
When looking at the title of the New function, we can see that it has an argument: ByVal scene As NovaScene.
 The New method has an argument: scene |
We can consider that the element named scene (of the
NovaScene type ) is at the higher lever of our hierarchy in the
Entities Browser. Thanks to this element, we have access to all the elements of the actual scene.
Class Script
Public Sub New(ByVal scene As NovaScene)
scene.GetObject("Box01")
End Sub
Sub Finalize()
End Sub
End Class
To get back the
Material Blue For Box in a script:
Class Script
Public Sub New(ByVal scene As NovaScene)
scene.GetMaterial("Material Blue For Box")
End Sub
Sub Finalize()
End Sub
End Class
To get back the
Omni02 in a script:
Class Script
Public Sub New(ByVal scene As NovaScene)
scene.GetLight("Omni02")
End Sub
Sub Finalize()
End Sub
End Class
As we can see, it is very easy to have access to the elements of the scene via their names (their properties
Name) and to the methods needed. When opening the
Script Helper and by selecting
NovaScene, we have access to all "Get" methods allowing to get back the elements of the actual scene:
 The Get methods of the NovaScene class |
We will need in our script of "Box01". Box01 is a in the
Entities Browser, then a NovaObject in the scripts. We need to have access to our object Box01 and we will not type again scene.GetObject ( "Box01") every time. We then declare a private variable named box of the
NovaObject type on top of the New method:
Class Script
Private box As NovaObject
Public Sub New(ByVal scene As NovaScene)
box = scene.GetObject("Box01")
End Sub
Sub Finalize()
End Sub
End Class
From then on, to type box or to type scene.GetObject("Box01") is exactly the same. But, the fact to use the variable box gives us a big advantage: The IntelliScript appears just after having typed a point after box:
 The IntelliScript appears when we type a point after "box" |
Compare the content of the IntelliScript of the previous screen with the Properties window: all the properties are there (and we have even access to other parameters!).
 We can have access to all the "Properties" in the scripts! |
We will affect the Green Material For Box to the Box01, we get back this by the same way we got back the Box01:
Class Script
Private box As NovaObject
Private greenMaterial As NovaMaterial
Public Sub New(ByVal scene As NovaScene)
box = scene.GetObject("Box01")
greenMaterial = scene.GetMaterial("Material Green For Box")
End Sub
Sub Finalize()
End Sub
End Class
We want to modify the property Material of the box object then :
Class Script
Private box As NovaObject
Private greenMaterial As NovaMaterial
Public Sub New(ByVal scene As NovaScene)
box = scene.GetObject("Box01")
greenMaterial = scene.GetMaterial("Material Green For Box")
box.Material = greenMaterial
End Sub
Sub Finalize()
End Sub
End Class
Click on
Run, the function New is called, Box01 now has the material Green Material For Box.
Commented example n°2: Change the material of the box when clicking on an icon
We will now improve our script so that when the user clicks on icons in the right down side of the screen, the material of the color corresponding to that of the icon is affected to the box situated in the center of the scene ("Box01").
We have seen in the previous example that we can have access to all the elements of a scene (materials, objects, lights, cameras) in the scripts and then modify dynamically all the properties of these elements.
We now introduce the idea of event. When we click on a pickable object,
NOVA launches an event (
Interaction) to which we can register and specify the actions to do when the event is launched. We can identify the events in the
Script Helper,
IntelliScript or in the documentation of the NOVA SDK thanks to the

icon.
 Events visualized from the documentation of the NOVA SDK |
To register to an event means to specify a method to call when an event is launched. When using Visual Basic, this is done with the keyword
AddHandler to specify the event to which we would like to register and
AddressOf to specify the method to call when the event is launched.
The signature of the method must correspond to what the event is waiting for. To know the signature it is waiting for, use the
Script Helper.
If we want to register a method to the Collision event of a NovaObject, the method must have a signature of the following type:
Public Sub MethodName(ByVal source As NovaObject)
End Sub
Example: we want that the method
IconeGreen_Interaction be called when the user clicks on IconeGreen. We know that when a pickable object is clicked, an
Interaction event is launched.
Caution: When registering to an event, we must think about un-registering to the Finalize () method thanks to the keyword RemoveHandler :
Class Script
Private greenIcon As NovaObject
Public Sub New(ByVal scene As NovaScene)
greenIcon = scene.GetObject("GreenIconObject")
AddHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
End Sub
Public Sub GreenIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
End Sub
Protected Overrides Sub Finalize()
RemoveHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
End Sub
End Class
If we haven't done the RemoveHandler, the method GreenIcon_Interaction will still be called even if we stop the script or if we re-launch it, which can bring problems. We then need to always keep in mind to associate a RemoveHandler in the Finalize when we do a AddHandler in the New. These are the only lines that we need to specify in the Finalize () method.
We will then check that the GreenIcon_Interaction method is called when we click on the green icon, displaying a dialog box.
To display a dialog box in Visual Basic.NET: MessageBox.Show()
Class Script
Private greenIcon As NovaObject
Public Sub New(ByVal scene As NovaScene)
greenIcon = scene.GetObject("GreenIconObject")
AddHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
End Sub
Public Sub GreenIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
MessageBox.Show("Ok...")
End Sub
Protected Overrides Sub Finalize()
RemoveHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
End Sub
End Class
Click on
Run, and then click on the green icon. The dialog box appears. Our method is properly called when we click on the icon.
We now do the same operation for the 3 icons :
Class Script
Private yellowIcon As NovaObject
Private greenIcon As NovaObject
Private blueIcon As NovaObject
Public Sub New(ByVal scene As NovaScene)
yellowIcon = scene.GetObject("YellowIconObject")
greenIcon = scene.GetObject("GreenIconObject")
blueIcon = scene.GetObject("BlueIconObject")
AddHandler yellowIcon.Interaction, AddressOf YellowIcon_Interaction
AddHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
AddHandler blueIcon.Interaction, AddressOf BlueIcon_Interaction
End Sub
Public Sub YellowIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
End Sub
Public Sub GreenIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
End Sub
Public Sub BlueIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
End Sub
Protected Overrides Sub Finalize()
RemoveHandler yellowIcon.Interaction, AddressOf YellowIcon_Interaction
RemoveHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
RemoveHandler blueIcon.Interaction, AddressOf BlueIcon_Interaction
End Sub
End Class
And we fill-in the content of our methods by affecting the requested material to Box01 :
Class Script
Private yellowIcon As NovaObject
Private greenIcon As NovaObject
Private blueIcon As NovaObject
Private yellowMaterialForBox As NovaMaterial
Private greenMaterialForBox As NovaMaterial
Private blueMaterialForBox As NovaMaterial
Private box As NovaObject
Public Sub New(ByVal scene As NovaScene)
yellowIcon = scene.GetObject("YellowIconObject")
greenIcon = scene.GetObject("GreenIconObject")
blueIcon = scene.GetObject("BlueIconObject")
yellowMaterialForBox = scene.GetMaterial("Material Yellow For Box")
greenMaterialForBox = scene.GetMaterial("Material Green For Box")
blueMaterialForBox = scene.GetMaterial("Material Blue For Box")
box = scene.GetObject("Box01")
AddHandler yellowIcon.Interaction, AddressOf YellowIcon_Interaction
AddHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
AddHandler blueIcon.Interaction, AddressOf BlueIcon_Interaction
End Sub
Public Sub YellowIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
box.Material = yellowMaterialForBox
End Sub
Public Sub GreenIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
box.Material = greenMaterialForBox
End Sub
Public Sub BlueIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
box.Material = blueMaterialForBox
End Sub
Protected Overrides Sub Finalize()
RemoveHandler yellowIcon.Interaction, AddressOf YellowIcon_Interaction
RemoveHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
RemoveHandler blueIcon.Interaction, AddressOf BlueIcon_Interaction
End Sub
End Class
Click on
Run. When we click on one of the icons, the corresponding material is affected to our box !
Commented example n°3: Visualize the selected icon
In our scene, select one of the icon objects in the
Entities Browser, then in the
Properties window, specify a new value for the
Visibility property (0.5 for example ) of one of the icons, YellowIconObject for example.
We want that only the selected icon has its
Visibility property to 1. The others icons will have a
Visibility of 0.5. We just have to fill in the example n°2 with the following lines:
Class Script
Private yellowIcon As NovaObject
Private greenIcon As NovaObject
Private blueIcon As NovaObject
Private yellowMaterialForBox As NovaMaterial
Private greenMaterialForBox As NovaMaterial
Private blueMaterialForBox As NovaMaterial
Private box As NovaObject
Public Sub New(ByVal scene As NovaScene)
yellowIcon = scene.GetObject("YellowIconObject")
greenIcon = scene.GetObject("GreenIconObject")
blueIcon = scene.GetObject("BlueIconObject")
yellowMaterialForBox = scene.GetMaterial("Material Yellow For Box")
greenMaterialForBox = scene.GetMaterial("Material Green For Box")
blueMaterialForBox = scene.GetMaterial("Material Blue For Box")
box = scene.GetObject("Box01")
AddHandler yellowIcon.Interaction, AddressOf YellowIcon_Interaction
AddHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
AddHandler blueIcon.Interaction, AddressOf BlueIcon_Interaction
End Sub
Public Sub YellowIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
box.Material = yellowMaterialForBox
greenIcon.Visibility = 0.5
blueIcon.Visibility = 0.5
yellowIcon.Visibility = 1.0
End Sub
Public Sub GreenIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
box.Material = greenMaterialForBox
greenIcon.Visibility = 1.0
blueIcon.Visibility = 0.5
yellowIcon.Visibility = 0.5
End Sub
Public Sub BlueIcon_Interaction(ByVal source As NovaObject)
' This method will be called when user click on the green icon
box.Material = blueMaterialForBox
greenIcon.Visibility = 0.5
blueIcon.Visibility = 1.0
yellowIcon.Visibility = 0.5
End Sub
Protected Overrides Sub Finalize()
RemoveHandler yellowIcon.Interaction, AddressOf YellowIcon_Interaction
RemoveHandler greenIcon.Interaction, AddressOf GreenIcon_Interaction
RemoveHandler blueIcon.Interaction, AddressOf BlueIcon_Interaction
End Sub
End Class
Click on Run to visualize the result :
Commented example n°4: display of a text on the screen
We will see how to display the information as text on the screen during the rendering of a scene. The Render() method of the current scene is automatically called by
NOVA, but we still can register to events of the NovaScene to interact with the rendering. In this example, we will register to the AfterRender() event to specify the text to display during the next rendering of the scene.
We register to the
AfterRender event of the actual scene:
Class Script
Private novaScene As NovaScene
Public Sub New(scene As NovaScene)
novaScene = scene
AddHandler novaScene.AfterRender, AddressOf Scene_AfterRender
End Sub
Private Sub Scene_AfterRender()
End Sub
Protected Overrides Sub Finalize()
RemoveHandler novaScene.AfterRender, AddressOf Scene_AfterRender
End Sub
End Class
We have seen in the previous events that we can have access and that we can parameter dynamically, through the scripts, the
Properties of the elements that can be displayed in the
Entities Browser. But there is still an entity above all this, an entity which manages the display of the scene, the options and offers new possibilities: the
NovaEngine. We can, thanks to this object, have access to the public properties of the NOVA 3D engine. The display of the scenes is directly linked to the properties specified by the NovaEngine.
Class Script
Private novaScene As NovaScene
Public Sub New(scene As NovaScene)
novaScene = scene
AddHandler novaScene.AfterRender, AddressOf Scene_AfterRender
End Sub
Private Sub Scene_AfterRender()
Dim topX As Single = Vertice.Nova.NovaEngine.Viewport.X
Dim topY As Single = Vertice.Nova.NovaEngine.Viewport.Y
Dim bottomX As Single = Vertice.Nova.NovaEngine.Viewport.Width
Dim bottomY As Single = Vertice.Nova.NovaEngine.Viewport.Height
Dim rect As New System.Drawing.Rectangle(topX, topY, bottomX, bottomY)
Vertice.Nova.NovaEngine.DrawText("Hello World", rect, NovaDrawTextFormats.Left, Color.White)
End Sub
Protected Overrides Sub Finalize()
RemoveHandler novaScene.AfterRender, AddressOf Scene_AfterRender
End Sub
End Class
The
Viewport property of the NovaEnginerepresents the rendering zone on the screen:
- Vertice.Nova.NovaEngine.Viewport.X is the X coordinate of the point in the upper left corner of the rendering.
- Vertice.Nova.NovaEngine.Viewport.Y is the Y coordinate of the point in the upper left corner of the rendering.
- Vertice.Nova.NovaEngine.Viewport.Height is the height of the rendering zone.
- Vertice.Nova.NovaEngine.Viewport.Width is the width of the rendering zone.
If we run this script, we can see that "Hello World" is displayed in the upper left corner of the screen. The DrawText method look like the following :

- text is the text to display
- rect is a rectangle specifying the positions and the size of the text box
- format specifies the alignment of the text in rect
- color specifies the color of the text
We can also modify the important properties for the display of the text thanks to the NovaEngine : the size (20 in the example) and the font ("System" in the example).
Private Sub Scene_AfterRender()
Dim topX As Single = Vertice.Nova.NovaEngine.Viewport.X
Dim topY As Single = Vertice.Nova.NovaEngine.Viewport.Y
Dim bottomX As Single = Vertice.Nova.NovaEngine.Viewport.Width
Dim bottomY As Single = Vertice.Nova.NovaEngine.Viewport.Height
Dim rect As New System.Drawing.Rectangle(topX, topY, bottomX, bottomY)
Vertice.Nova.NovaEngine.FontName = "System"
Vertice.Nova.NovaEngine.FontSize = 20
Vertice.Nova.NovaEngine.DrawText("Hello World", rect, NovaDrawTextFormats.Left, Color.White)
End Sub
Commented example n°5: use of the timer
We will see in this example how to change automatically the material of Box01 in a regular way (every second for example) by using the
Timers.
The timer is an object of the framework .NET 2.0, very easy to use if the notion of event is understood. When the Timer is set up, it creates an event for every "tick". By registering to this event, we can then specify what we want to do each time there is a tick in the Timer.
The Timer won't be in the Nova documentation as it is an element of the framework .NET 2.0. You can find the documentation for it here :
http://msdn2.microsoft.com/en-us/library/h1c2h276(VS.80).aspxWe are now used to the events in the scripts. One plug directly on the Tick of a Timer declared in our script:
Class Script
Private novaScene As NovaScene
Private timer As Timer
Public Sub New(scene As NovaScene)
novaScene = scene
timer = New Timer()
timer.Interval = 500
AddHandler timer.Tick, AddressOf Timer_TickEventHandler
End Sub
Private Sub Timer_TickEventHandler(ByVal source As Object, ByVal e As EventArgs)
End Sub
Protected Overrides Sub Finalize()
RemoveHandler timer.Tick, AddressOf Timer_TickEventHandler
End Sub
End Class
The
Timer_TickEventHandler method at every Tick of the Timer. We want to modify the material of the object Box01 at each Tick of the Timer. We run the necessary initializations: we get the object Box01 and the materials that we are going to affect to this object:
Class Script
Private novaScene As NovaScene
Private timer As Timer
Private box As NovaObject
Private greenMaterial As NovaMaterial
Private blueMaterial As NovaMaterial
Private yellowMaterial As NovaMaterial
Public Sub New(scene As NovaScene)
novaScene = scene
timer = New Timer()
timer.Interval = 500
AddHandler timer.Tick, AddressOf Timer_TickEventHandler
box = novaScene.GetObject("Box01")
greenMaterial = novaScene.GetMaterial("Material Green For Box")
blueMaterial = novaScene.GetMaterial("Material Blue For Box")
yellowMaterial = novaScene.GetMaterial("Material Yellow For Box")
box.Material = yellowMaterial
timer.Start()
End Sub
Private Sub Timer_TickEventHandler(ByVal source As Object, ByVal e As EventArgs)
End Sub
Protected Overrides Sub Finalize()
RemoveHandler timer.Tick, AddressOf Timer_TickEventHandler
End Sub
End Class
We just have to fill in our
Timer_TickEventHandler method by applying the following rule : if the material of Box01 is yellowMaterial, we affect to Box01 the greenMaterial. Overwise : if the material of Box01 is greenMaterial, we affect to Box01 the blueMaterial, overwise the material of Box01 is blueMaterial and in this case, we affect yellowMaterial to Box01.
This kind of rule is easily programmable with the scripts :
Private Sub Timer_TickEventHandler(ByVal source As Object, ByVal e As EventArgs)
If box.Material.Name = yellowMaterial.Name Then
box.Material = greenMaterial
Else
If box.Material.Name = greenMaterial.Name Then
box.Material = blueMaterial
Else
box.Material = yellowMaterial
End If
End If
End Sub
Commented example n°6: conditioned programming
In the Video Games, we regularly have actions of the following type: "get an object before being able to open the door", "launch a mechanism to have access to this level". With the scripts, it is easy to do it. We will se in this simple example how to deny the access to the icons used to change the material till the user has clicked on Box01.
To start, we can see that Box01 is not
pickable. We are not going to launch 3ds Max to specify the Pickable property, and then export again. We will do it thanks to the script. We register to the
Interaction events of the icons and of Box01.
Class Script
Private novaScene As NovaScene
Private box As NovaObject
Private greenIcon As NovaObject
Private blueIcon As NovaObject
Private yellowIcon As NovaObject
Public Sub New(scene As NovaScene)
novaScene = scene
box = novaScene.GetObject("Box01")
box.Pickable = True
AddHandler box.Interaction, AddressOf Box_InteractionEventHandler
greenIcon = novaScene.GetObject("GreenIconObject")
blueIcon = novaScene.GetObject("BlueIconObject")
yellowIcon = novaScene.GetObject("YellowIconObject")
AddHandler greenIcon.Interaction, AddressOf GreenIcon_InteractionEventHandler
AddHandler blueIcon.Interaction, AddressOf BlueIcon_InteractionEventHandler
AddHandler yellowIcon.Interaction, AddressOf YellowIcon_InteractionEventHandler
End Sub
Private Sub Box_InteractionEventHandler(ByVal source As NovaObject)
' The user picked the box, set it to non-pickable
box.Pickable = False
End Sub
Private Sub YellowIcon_InteractionEventHandler(ByVal source As NovaObject)
End Sub
Private Sub GreenIcon_InteractionEventHandler(ByVal source As NovaObject)
End Sub
Private Sub BlueIcon_InteractionEventHandler(ByVal source As NovaObject)
End Sub
Protected Overrides Sub Finalize()
RemoveHandler box.Interaction, AddressOf Box_InteractionEventHandler
RemoveHandler greenIcon.Interaction, AddressOf GreenIcon_InteractionEventHandler
RemoveHandler blueIcon.Interaction, AddressOf BlueIcon_InteractionEventHandler
RemoveHandler yellowIcon.Interaction, AddressOf YellowIcon_InteractionEventHandler
End Sub
End Class
When running the script, we can see that if we put the mouse cursor on
Box01, the object is now "Pickable".
Till the box has not been clicked, we display a dialog box informing the user that he needs to click on the box before using the icons. As soon as the user has clicked on the box, the material can be changed:
Class Script
Private novaScene As NovaScene
Private box As NovaObject
Private greenIcon As NovaObject
Private blueIcon As NovaObject
Private yellowIcon As NovaObject
Public Sub New(scene As NovaScene)
novaScene = scene
box = novaScene.GetObject("Box01")
box.Pickable = True
AddHandler box.Interaction, AddressOf Box_InteractionEventHandler
greenIcon = novaScene.GetObject("GreenIconObject")
blueIcon = novaScene.GetObject("BlueIconObject")
yellowIcon = novaScene.GetObject("YellowIconObject")
AddHandler greenIcon.Interaction, AddressOf GreenIcon_InteractionEventHandler
AddHandler blueIcon.Interaction, AddressOf BlueIcon_InteractionEventHandler
AddHandler yellowIcon.Interaction, AddressOf YellowIcon_InteractionEventHandler
End Sub
Private Sub Box_InteractionEventHandler(ByVal source As NovaObject)
' The user picked the box, set it to non-pickable
box.Pickable = False
End Sub
Private Sub YellowIcon_InteractionEventHandler(ByVal source As NovaObject)
If box.Pickable Then
'The box is pickable, so it has not be clicked
MessageBox.Show("You must click on the box before using these icons")
Else
box.Material = novaScene.GetMaterial("Material Yellow For Box")
End If
End Sub
Private Sub GreenIcon_InteractionEventHandler(ByVal source As NovaObject)
If box.Pickable Then
'The box is pickable, so it has not be clicked
MessageBox.Show("You must click on the box before using these icons")
Else
box.Material = novaScene.GetMaterial("Material Green For Box")
End If
End Sub
Private Sub BlueIcon_InteractionEventHandler(ByVal source As NovaObject)
If box.Pickable Then
'The box is pickable, so it has not be clicked
MessageBox.Show("You must click on the box before using these icons")
Else
box.Material = novaScene.GetMaterial("Material Blue For Box")
End If
End Sub
Protected Overrides Sub Finalize()
RemoveHandler box.Interaction, AddressOf Box_InteractionEventHandler
RemoveHandler greenIcon.Interaction, AddressOf GreenIcon_InteractionEventHandler
RemoveHandler blueIcon.Interaction, AddressOf BlueIcon_InteractionEventHandler
RemoveHandler yellowIcon.Interaction, AddressOf YellowIcon_InteractionEventHandler
End Sub
End Class
Commented example n°7: Interact with Nova Studio
In the Nova's Script you can get all .Net Framework Components. It means that you can put all controls of .Net Framework directly into NOVA Studio.
We will see a sample which expose a textbox directly on high left of the NOVA rendered zone.
Class Script
Private textArea As System.Windows.Forms.TextBox
Public Sub New(scene As NovaScene)
textArea = New System.Windows.Forms.TextBox()
' textArea will be multiline
textArea.Multiline = True
' textArea will be in top left
textArea.Location = New System.Drawing.Point(0, 0)
' make textArea Visible
textArea.Visible = True
' textArea size specification
textArea.Size = New System.Drawing.Size(180, 200)
' add textArea to Nova Studio
MainForm.ExplorerMainTabControl.Controls.Add(textArea)
textArea.Text = "textArea is Ready..."
End Sub
Protected Overrides Sub Finalize()
End Sub
End Class
Now we have to put one line to add a text line on the control :
Private Sub AddLine(ByVal text As String)
' Microsoft.VisualBasic.Constants.vbcrlf = new line in visual basic .NET
textArea.Text = textArea.Text + Microsoft.VisualBasic.Constants.vbcrlf + text
End Sub
Commented example n°8: The events of Nova Studio
Until now, we have gone through the events related to the direct interactions with the 3D scene. We will now talk about the events started by NOVA Studio itself. If we open the
Script Helper, we note that the Nova objects are gathered in 2 spaces bearing the names:
Vertice.Nova and
Vertice.NovaStudio. We also have the namespace MathServices, which contains some mathematics tools.
The events presented in the previous sections belongs to the namespace
Vertice.Nova. Now, let's examine
Vertice.NovaStudio.
Detail of the mouse events :
- NovaMouseDown: Launched when one of the mouse button is pressed
- NovaMouseEnterObject: Launched when the cursor of the mouse gets over a Nova pickable object
- NovaMouseLeaveObject: Launched when the cursor of the mouse gets out a Nova pickable object
- NovaMouseMove: Launched when the cursor of the mouse is moving in NOVA Studio
- NovaMouseUp : Launched when the mouse button is released
- NovaMouseOverObject : Launched when mouse is hover an object
We can now complete the previous example :
Class Script
Private textArea As System.Windows.Forms.TextBox
Public Sub New(scene As NovaScene)
textArea = New System.Windows.Forms.TextBox()
' textArea will be multiline
textArea.Multiline = True
' textArea will be in top left
textArea.Location = New System.Drawing.Point(0, 0)
' make textArea Visible
textArea.Visible = True
' textArea size specification
textArea.Size = New System.Drawing.Size(180, 200)
' add textArea to Nova Studio
MainForm.ExplorerMainTabControl.Controls.Add(textArea)
textArea.Text = "textArea is Ready..."
' New Nova events exemples
AddHandler MainForm.NovaMouseEnterObject, AddressOf NovaMouseEnterObjectEvent
AddHandler MainForm.NovaMouseLeaveObject, AddressOf NovaMouseLeaveObjectEvent
End Sub
Private Sub NovaMouseEnterObjectEvent(ByVal obj As NovaObject)
AddLine("- NovaMouseEnterObject Event : obj.Name = " + obj.Name)
End Sub
Private Sub NovaMouseLeaveObjectEvent(ByVal obj As NovaObject)
AddLine("- NovaMouseLeaveObject Event : obj.Name = " + obj.Name)
End Sub
Private Sub AddLine(ByVal text As String)
' Microsoft.VisualBasic.Constants.vbcrlf = new line in visual basic .NET
textArea.Text = textArea.Text + Microsoft.VisualBasic.Constants.vbcrlf + text
End Sub
Protected Overrides Sub Finalize()
MainForm.ExplorerMainTabControl.Controls.Remove(textArea)
RemoveHandler MainForm.NovaMouseEnterObject, AddressOf NovaMouseEnterObjectEvent
RemoveHandler MainForm.NovaMouseLeaveObject, AddressOf NovaMouseLeaveObjectEvent
End Sub
End Class