Graphics

 View Only
  • 1.  Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-24-2015 13:52
    I have a little challenge for you guys here. I'm still fresh to the XPression software and still do not know all the tips and tricks yet.

    So imagine four 3D rings designed to look like odometer rings with numbers 0-9 on them. I have them side-by-side in the scene and then added 4 text objects. Within Visual Logic, I have it set up where each text object is tied to one of the rings, and depending on what number is input into the text object, the 3D ring will rotate on its x-axis to reflect that number on its surface.

    What I'd like to happen, is that the rings will all start on '0' and the scene director will sit on a pause until the graphic is taken. Then, I'd like it to rotate 2 or 3 times and eventually land on the number that has been inputted into the text objects (they'll be hidden in the scene, by the way). What is the best way to go about setting this up to do this? Through scripts and scene directors/animation controllers? Also, I'd like the tie each ring from theft to right to the ring on its right to behave much like an odometer would when counting up (the right rings will rotate the quickest and influence the rotation of the rings on its left), but I understand that this may be trickier to start off and things would need to be adjusted. Any tips or scripting ideas may help, I know nothing about scripts in XPression.

    XPression v6


  • 2.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-24-2015 14:30
    See, what I think needs to happen is that I'm going to have to have a duplicate set of numbers that will affect their copy's appropriate 3D ring, and then through scripting or visual logic, to animate the ring it'll have to start off with the first set of text objects (which will all be '0') and then transition to the set of numbers with the data input. That's one way I think it can be tackled, I'm just not sure how. I can provide the 3D object and texture I made if anyone wants to play with this.

    #XPression


  • 3.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-24-2015 16:49
    You might find some inspiration from this project:

    Clocks and Charts

    #XPression


  • 4.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-24-2015 18:37

    I would do this through scripting. In the OnOnline for the scene, you could take the number it should land on, use that to get degree of rotation, add 360 for each time you want it to full circle. So for example, assuming it starts at 0, if it is the number 4, that could be a 150 degree rotation, plus 2 spins = 720, which is 870.

    Next thing get the animation controller(SpinTheRings), the first keyframe should already be set to 0, so you now need to set the second one in the script at 60 frames in the AnimController, for example if you want this animation to take 2 seconds, etc.

    Anyway, it might be something like this.



    dim number, ring as xpBaseObject

    dim rotation as double

    Self.GetObjectByName("number",number)

    Self.GetObjectByName("ring",ring)

    rotation = Cdbl(720) + Cdbl(number.Text)

    engine.debugmessage("Here",1)

    dim SpinAnimController as xpAnimController

    Self.GetAnimControllerByName("SpinAnimController",SpinAnimController)

    SpinAnimController.SetKeyFrameRotation(ring,Clng(60),0,0,Cdbl(rotation))



    You probably want to set a curve on the second keyframe so it slows to a halt.

    Mike


    #XPression


  • 5.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-25-2015 20:49
    So Mike was able to get me started on the right track here. Since I knew nothing about scripting or anything in the SDK, you could say I was a bit lost on how to go about doing this. But, with some edits in the "OnOnline" Script event, I was able to get the animation to start from 0 to the desired number. However, I don't want this animation to start right at the beginning, I would like it to start when the director takes the item again. This is my script:

    dim SpinningRings as xpAnimController

    dim Digit, ringObj as xpBaseObject

    dim NumberOfSpins, TotalSpin, ThisRotation as double

    dim KFat as long

    for num as integer = 1 to 4

    ' engine.debugmessage("Loop" + cstr(num),1)

    Self.GetObjectByName("Digit" + Cstr(num),Digit)

    ' Set up a case for each value that is possible number 0-9

    Select Case Cdbl(Digit.Text)

    Case "0"

    ThisRotation = 0

    Case "1"

    ThisRotation = 34

    Case "2"

    ThisRotation = 70

    Case "3"

    ThisRotation = 106

    Case "4"

    ThisRotation = 143

    Case "5"

    ThisRotation = 179

    Case "6"

    ThisRotation = 215

    Case "7"

    ThisRotation = 252

    Case "8"

    ThisRotation = 287

    Case "9"

    ThisRotation = 323

    Case Else

    ' engine.debugmessage("You typed something else",1)

    End Select

    ' engine.debugmessage("Done getting rotation: " + Cstr(ThisRotation),1)

    ' This is defining where to set each keyframe. ring 1 @ 15 frames, ring 2 at 30 frames, etc,

    KFat = num * -1 * 8 + 120

    TotalSpin = (num * 720) + ThisRotation

    Self.GetObjectByName("ringObj" + Cstr(num),ringObj)

    Self.GetAnimControllerByName("SpinningRings",SpinningRings)

    SpinningRings.SetKeyFrameRotation(ringObj,Clng(KFat),Cdbl(TotalSpin),0,0,3,0)

    ' engine.debugmessage("Done ",1)

    next


    How could I go about adding a pause event in this?

    #XPression


  • 6.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-25-2015 21:05
    Hi Phillip,

    Instead of doing this in the OnOnline script, you could try moving this to a script that you put on the Scene Director.

    Place a Pause event at the beginning of the scene director and the script event somewhere after the pause; so when the director resumes the pause it will run the script which modifies the animation controller.

    Make sure the SpinningRings animation controller is after the script event on the scene director; or remove it entirely from the scene director and add SpinningRings.Position=0 and SpinningRings.Play to the end of your script.

    #XPression


  • 7.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-25-2015 21:08
    Actually thinking about it more, maybe you could just leave it OnOnline, and simply add the Pause to the scene director.. (And make sure SpinningRings animcontroller is either after the pause or not on the scene director (and use SpinningRings.Play as I mentioned in my last response)..

    #XPression


  • 8.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-25-2015 21:20
    Oh, I've definitely tried this. Unfortunately, adding a Pause Event in the Scene Director causes the rings to show that number right when the pause is hit, and then once you take the item again, it will then show all zero's and then animate. I've tried what you've suggested, and either those won't work either, or I'm doing it wrong. The state will show paused, but it'll still animate. Where exactly do I need to put those last lines of script?

    #XPression


  • 9.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-25-2015 23:34
    Can you upload the scene for me to experiment with?

    #XPression


  • 10.  RE: Here's a Challenge... (Rotating scripts and Visual Logic)

    Posted 08-26-2015 13:47
    Yes, once our news cast is finished and I try one more method to make sure it's not just me. Brian, what would be fantastic to have in this community would be to have a forum section of useful scripts, demo projects, and maybe some free elements/user submitted templates. Have you guys ever considered that? With me, sites like VideoCopilot and Greyscale Gorilla really helped me hone my skills. I actually went though all of the tutorials on Video Copilot's site at one point just so I can learn the basics and shortcuts. How cool would it be to do one tutorial a month on some frequently asked questions, both basic and advanced? You guys are fantastic with you customer support, this would make you guys even better! Just a suggestion.

    #XPression