SDK Tip: create a perpendicular plane to the camera

by Frédéric Colin 30. August 2010 06:28

Sometimes, it may be useful to create a kind of panel perpendicular to the active camera. That's why, I've added a new page to demonstrate it on our wiki

Enjoy!

Nova Script Editor

by Frédéric Colin 20. July 2010 18:08

Do you know that some Visual Studio Shortcuts are available in the Nova Script Editor. Here is a partial list:

  • ctrl-S => save the script
  • ctrl-K + ctrl-C => comment all selected line
  • ctrl-K + ctrl-U => un-comment all selected line
  • ctrl-space => launch intellisense list
  • ctrl-M + ctrl-O => collapse all code to definitions
  • ...

Change scene quality on the fly

by Frédéric Colin 24. June 2010 22:45

A very good question I was asked recently about the possibility of change on the fly graphics quality of a scene. It's indeed possible in different ways:

  • Using Nova Studio: just go to the "Developer" menu and click on Engine Options:

This options will display the following panel that will allow you to enable or disable any Nova quality options and channels and therefore the speed of rendering.

  • Using Nova scripting, Nova plugin model or Nova SDK. Indeed all Nova quality options and channels are available through Nova Object Model. In the following script, I first create a slider that will change on the fly Nova Engine option according 3 values ranges:
    • From 0.0 to 1.0 excluded: main quality options are disabled.
    • From 1.0 to 2.0 excluded: some quality options are enabled.
    • Else: all quality options are enabled.
Class Script

    Private slider As NovaSlider
    Private currentScene As NovaScene 
    
    Public Sub New(scene As NovaScene)
        currentScene = scene
        slider = Scene.CreateSlider()

        slider.Top = 10
        slider.Left = 10

        slider.Min = 0.0
        slider.Max = 3.0
        slider.Value = slider.Max
        slider.Width = 300
        slider.ID = "SliderQualitySensor"
        slider.Text = "Quality Sensor"
        slider.RelativeWidth = False
        slider.Visible = True
        
        AddHandler slider.ValueChanged, AddressOf manageValueChanged
    End Sub

    Private Sub manageValueChanged(ByVal o As Object, e As EventArgs)
        If  slider.Value >= 0.0 AndAlso slider.Value < 1.0 Then
            changeToLowQuality()                
        ElseIf  slider.Value >= 1.0 AndAlso slider.Value < 2.0 Then
            changeToMediumQuality()
        Else
            changeToHighQuality()
        End If
    End Sub
    
    Private Sub changeToLowQuality()
        currentScene.Engine.QualityLevel = 0
        NovaEngine.Shadows = False
                
        NovaEngine.BumpChannel = False
        NovaEngine.SpecularChannel = False
        NovaEngine.ReflectionChannel = False
        NovaEngine.RefractionChannel = False
        Novaengine.EmissiveChannel = False
        Novaengine.AmbientChannel = False 
        NovaEngine.ParticleSystems = False
        NovaEngine.MirrorMatrixActivated = False
    End Sub
    
    Private Sub changeToMediumQuality()
        currentScene.Engine.QualityLevel = 1
        NovaEngine.Shadows = False
                
        NovaEngine.BumpChannel = True
        NovaEngine.SpecularChannel = True
        NovaEngine.ReflectionChannel = True
        NovaEngine.RefractionChannel = False
        Novaengine.EmissiveChannel = False
        Novaengine.AmbientChannel = False 
        NovaEngine.ParticleSystems = True
        NovaEngine.MirrorMatrixActivated = False
    End Sub
    
    Private Sub changeToHighQuality()
        currentScene.Engine.QualityLevel = 3
        NovaEngine.Shadows = True

        NovaEngine.BumpChannel = True
        NovaEngine.SpecularChannel = True
        NovaEngine.ReflectionChannel = True
        NovaEngine.RefractionChannel = True
        Novaengine.EmissiveChannel = True
        Novaengine.AmbientChannel = True 
        NovaEngine.ParticleSystems = True
        NovaEngine.MirrorMatrixActivated = True
    End Sub
    
    Protected Overrides Sub Finalize()
        RemoveHandler slider.ValueChanged, AddressOf manageValueChanged
        currentScene.Widgets.Clear()
    End Sub
End Class

SliderManager.nsr (2.83 kb)

Detect camera Moves in Nova script

by Frédéric Colin 19. June 2010 22:23
Just a small tip to detect camera moves on a scene with Nova script. We may think that PropertyChanged event on NovaCamera can do it, but not...
Indeed for rendering performance reasons, it's not possible to track every properties changes on NovaCamera (see wiki). So here it is a little script to track camera moves on a Nova scene.
The tip is quite simple: at the scene creation, we store initial coordinates and on every rendering we check current coordinates with the previous one (since we work on floating real, we calculate the daifference according an epsilon). After the calcultation, if there is a difference, the camera moved. Since this check is done on every rendering (ie: 30 fps), the result of differential remains true during this time. We can work on the epsilon value to reduce somewhat the sensitivity, but to reduce it further, it should be considered a lapse of time during which the audit should not take place (using a stopwath as an example).
Here is the code Code:
  Private myScene As NovaScene
    Private epsilon As Single = 0.0001
    Private cameraLastGlobalPosition As Vector3
    Private cameraLastRotationPosition As Vector3
    Private camera As NovaCamera
    
    Public Sub New(ByVal scene As NovaScene)
        myScene = scene
        
        camera = myScene.GetCamera("MainCamera")
        StoreCameraPostion()

        AddHandler myScene.AfterRender, AddressOf manageAfterRender
    End Sub

    Private Sub manageAfterRender
        If Math.Abs(CType((camera.GlobalPosition - cameraLastGlobalPosition).Length, Single)) 
> epsilon OrElse Math.Abs(CType((camera.Rotation - cameraLastRotationPosition).Length, Single)) 
> epsilon Then    
            StoreCameraPostion()
            
            PluginHelper.LogInfo("it moves!")
        End If
    End Sub

    Public Sub StoreCameraPostion()
        cameraLastGlobalPosition = camera.GlobalPosition
        cameraLastRotationPosition = camera.Rotation 
    End Sub

    Protected Overrides Sub Finalize()
        RemoveHandler myScene.AfterRender, AddressOf ManageAfterRender
    End Sub
End Class 

Extend Nova Studio scripting with your own object model: the webcast

by Frédéric Colin 25. May 2010 00:16

Since a little Webcast is certainly more efficient than words, I decided to illustrate my previous post with a video. You will be able to see how I included sms sending message on intersection detection in a Nova scene. A kind of virtual alarm in fact!

[youtube:PJdMOprbFR4&hl]  

Enjoy!

Nova Explorer Tip

by Frédéric Colin 26. October 2009 21:17

I'm not sure this tip is well documented in Nova Explorer! Do you know that if you put a jpeg file called NovaScreenShot.jpg side by side to your mxb file, it will be used as a splash screen when you will open your scene.

Enjoy this tip!

Tags:

Fun | Nova Explorer | PLE | Tips

Disclaimer
The opinions expressed herein are the author own personal opinions and do not represent their employers' view in anyway..

© Copyright 2010 Nova by Vertice Team