Graphics

 View Only
  • 1.  Request help on scripting to reset SceneDirector and play from the begining

    Posted 03-20-2018 10:45
    Hi,

    I'm about to write a script inside the scene that look like this.

    if object 1 is visible, then reset a sceneDirector and play from the begining.

    Please advise.


  • 2.  RE: Request help on scripting to reset SceneDirector and play from the begining

    Posted 03-20-2018 14:51
    Assuming your object is named "Object_1" and the scene directory is named "SceneDirector1",
    here is a sample code :

    Dim myObj as xpBaseObject
    Dim objSceneDir as xpSceneDirector

    if Scene.GetObjectByName("Object_1", myObj) = True Then

    ' check if object is visible
    if myObj.Visible = True Then

    ' Get scene director by his name
    if Scene.GetSceneDirectorByName("SceneDirector1", objSceneDir) = True then

    ' Stop, reset position and play again
    objSceneDir.Stop()
    objSceneDir.position = 0
    objSceneDir.Play()

    ' maybe you will need to put back visibility to False to avoid reset again at next render
    myObj.Visible = False
    end if

    end if
    End if



    if you want to be notified only when the visibility has changed to "visible" , you can add a Event Marker object in your scene, and put the following script in the OnShow() event :
    Dim objSceneDir as xpSceneDirector

    ' Get scene director by his name
    if Scene.GetSceneDirectorByName("SceneDirector1", objSceneDir) = True then

    ' Stop, reset position and play again
    objSceneDir.Stop()
    objSceneDir.position = 0
    objSceneDir.Play()
    End if


    If you have only one scene director in your scene you can use the default one (no need to search by name anymore) :

    Scene.SceneDirector.Stop()
    Scene.SceneDirector.position = 0
    Scene.SceneDirector.Play()


    Hope it helps,
    Antoine
    #XPression


  • 3.  RE: Request help on scripting to reset SceneDirector and play from the begining

    Posted 03-21-2018 15:32
    You could also use the command scenedirector.playrange(0, scenedirector.duration)which will always play from the beginning until the end of the scene director.
    #XPression


  • 4.  RE: Request help on scripting to reset SceneDirector and play from the begining

    Posted 03-21-2018 15:52
    I usually recommend doing this before playing the scene director from a script:
    objSceneDir.autostop=true
    This makes sure when it gets to the end; it will stop updating the positions of objects to be wherever the last frame of the scene director has them.
    If you don't do this and you then try playing a different scene director that controls the same object, you can end up with the two scene directors fighting over where the object should be positioned.
    #XPression


  • 5.  RE: Request help on scripting to reset SceneDirector and play from the begining

    Posted 03-22-2018 17:48
    Thank you guys. Those infos are very useful. It helps a lot, much appreciated.
    #XPression