Scripting tip: change UV Address mode on the fly

by Frédéric Colin 15. December 2010 16:41

Sometimes, it may userful to change on the fly UV address Mode to clamp textures. But when there are too many textures, it's time consumming. So, I've just added a little script on the wiki to demonstrate it.

Enjoy!

Use Excel in Nova scripting

by Frédéric Colin 26. October 2010 10:15

Some of you asked me if it was possible to use Excel in Nova scripting. Yes it is with the following prerequisite: Excel must be installed on the computer! Then, here a small piece of code:

   ' Bypass for this error: old format or invalid type library excel 2007

  System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US")

  Dim excelApp As Object
  Dim wb As Object
  Dim ws As Object

  ' Create Excel application

  excelApp = CreateObject("Excel.Application")
  
  If Not excelApp Is Nothing Then
   ' Excel file openning

   wb = excelApp.WorkBooks.Open(filePath,, False)

   If Not wb Is Nothing Then
    ws = wb.Worksheets(excelWorksheetName)
   
    If Not ws Is Nothing Then
     ws.Range(cellCoord).Value2 = valueToStore
     
     wb.Save()
    End If
    
    wb.Close()
   End If
   
   ' Free COM Object from memory

   System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp)
  End If 

Since we use COM Interop, it's very important to explicitly release COM Object with Marshal.ReleaseComObject method's call.

I've tested this code with Excel 2007. Enjoy!

How to store a state in a Nova scene

by Frédéric Colin 1. September 2010 09:03

There are many possibilities to store user data inside a Nova Scene. That's why I've just added a new sample on Nova Wiki.

If you are interested, just have a look here.

Scripting tip: change Nova Standard Material textures on the fly

by Frédéric Colin 27. July 2010 17:51

I continue my series of publication on Nova scripting by demonstrating the ability to load your materials' textures on the fly from external files.

That happens here.

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
  • ...

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 
Disclaimer
The opinions expressed herein are the author own personal opinions and do not represent their employers' view in anyway..

© Copyright 2012 Nova by Vertice Team