Scripting tip: handle user events triggered from Action Builder

by Frédéric Colin 7. July 2010 23:58

Sometimes, it may be useful to trigger user events from the Action Builder in order to process them in Nova Script while continuing current execution tree.

That's why I've just published on the Vertice wiki a little tip on this subject.

Enjoy!

Change scene quality on the fly - Part II

by Frédéric Colin 24. June 2010 23:26

A corollary question to my last post was also whether it was possible to automate something about this. Namely, something that would automate the quality adjustment based on the machine behind the scene.

You have to know that Nova Engine already does a part of that kind of things when used rendering options are not available on the graphics card. But the question was more about an artificial intelligence that will adapt rendering quality. In fact, in such a way, Nova does not yet include an artificial intelligence.

So, I was thinking without such a tool how today I will implement easily and in a short time this requirement if I had to develop it. Once more, simple heuristics can always help us on these complex issues. The best heuristics I was thinking about, would be to simply use the current scene FPS to determine if the scene quality may be increased or decreased. Then, after a predetermined (ie: after each x frames rendering), the system could check if the overall quality should be increased or decreased. And this can easily be done using Nova Scripting and Action builder. This complete the proof!

However, if we wanted to go further in that kind of solution, we will have to study the current scene to determine which will be the best quality options and channels to enable to disable and in which order. Moreover, we will have also to study what will be the quality scale to hold.

In my previous sample, I have arbitrarily decided that the level would include three stages of quality, but why not more? It is still a topic that should be studied further.

Finally and in order to set this little heuristic, we should provide the scene designer a way to decline (or not) in quality such and such options. It is understandable that with the addition of such features a small artificial intelligence engine would be perfect.

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)

New scripting tip on Vertice wiki

by Frédéric Colin 21. June 2010 17:06

I've just published a new tip on Vertice wiki. It will allow you change the active novaCamera on the fly using a joystick.

Do you know also you can publish on our wiki? So don't hesitate to contact me if you need further informations and if you think it's too difficult, you should know that everyone has talent, it's my leitmotiv! 

If you are a little bit afraid about publishing, I will help you on your first article by an author-reader cycle, so join us in the Vertice community!

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 

Web Plugin tip: Change FOV on the fly in javascript with Nova Web Plugin

by Frédéric Colin 16. June 2010 23:58

I've just wrote a new entry on the wiki. Indeed, Nova Web Pluging is a powerful tool with a complete object model to manipulate the scene in javascript.

To illustrate this fact, I developed a little javascript function to change the camera FOV on the fly.

Enjoy!

 

Vertice Channel on Youtube

by Frédéric Colin 16. June 2010 14:47

I've just created a channel on YouTube to gather on a single web page all the videos already available on the 2010 range.

Tags:

Webcast

Sending a sms through Nova Scripting

by Frédéric Colin 6. June 2010 21:46

Many of you asked me to provide Nova script and assemblies used for my virtual intrusion detector demonstration that sent a sms. So here's the script:

Below, you will find:

  1. 64 bits GSMCOM assemblies
  2. the script as a nsr Nova file.
  3. The C# project to send the sms (I encapsulated the well known GSMCOM assembly)

Sms.rar (52.58 kb)

Enjoy!

 

Unlucky?

by Frédéric Colin 6. June 2010 19:13

First of all, thank you very much to all attendees that followed the session we animated Mitch and myself at the BDC in Aix en Provence (France). Behind the scenes of a session are sometimes surprising. So here is a little anecdote.

One of my demonstration was to illustrate an funny plugin into Nova Studio 2010. Here it is the architecture of my demonstration:

The main objective was to use 3 motorized IP webcam inside a WPF Application and a Nova Studio Plugin. I used Windows Communication Foundation announcement service to detect IP cameras. Then, each client application was notified from the arrival of cameras on the network through WCF announcement.

But 30 minuts before the session during my last demonstration checks, 2 of 3 IP cameras have decided to no longer work (processor off), a network cable has blown and the network card of my laptop acting as a server has also decided to stop working. I rebuild my demo with only 1 IP camera and with clients and services on my laptop. At the point where I was, I was waiting for a meteorite!

Finally the demonstration worked well with the material that I had. The day was very interesting but rough.

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!

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