Putting it all together, a walkthrough script. UPDATED

Forums: Putting it all together, a walkthrough script. UPDATED
Forum for OctaneRender Lua scripting examples, discussion and support.

Re: Putting it all together, a walkthrough script

Postby stratified » Thu Feb 13, 2014 12:58 am

stratified Thu Feb 13, 2014 12:58 am
MB wrote:
stratified wrote:I don't know exactly what you mean by orbiting up and down. There's no limitation in Octane. I think (just guessing here) that at some point in the animation the camera direction and the camera up vector are parallel. We take a cross product of those to get the cam's right vector. If the vectors are parallel, the right vector is 0. In this case you would slightly perturb the up vector. If this is what's happening we can help you with that.



I had a complaint that if you set orbit down to 90deg, the animation would reverse direction if you started out looking up. In octane standalone you can only look straight up, or straight down, and everything in between, but you cant rotate 360 degress over the top of the model. I think this is very good behaviour btw.

However if you set up the orbit in the script so that it attempts to go beyond straight up or straight down, it hicups, then reverses direction, its not a big deal, the user need not tell it to orbit as far, and it won't happen. I'm guessing thats the way you have chosen to handle it. Give it a try and let me know what you think.

I haven't implemented yet, but i'm assuming barrel rolls can be done by rotating the up direction of the camera thru 360 or more degrees.

best


Hi Mark,

You can implement it if you want. You just need to handle this special case. If you look up or down in your scene in the Standalone via the camera presets, you'll notice that the up vector changes. It's not a choice, there's no way to handle this case without changing the up vector. I think it is useful to render orbit animations that go over the poles.

Barrel rolls rotate the up vector while moving the position over the camera direction.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Putting it all together, a walkthrough script

Postby MB » Sun Feb 16, 2014 6:42 pm

MB Sun Feb 16, 2014 6:42 pm
Thomas,

I hope you had a good weekend.

The script is coming along well and it can now combine multiple camera moves, and also perform some simple easing as you discussed in an earlier post. However I am trying to implement 'orbiting over the poles' without sucess.

Here is the new code i have for vertical orbiting inside the number of frames loop. Further down i set an animator on P_UP, feeding it all the vecCurrentCameraUp values.

Code: Select all
           -- Rotate the viewing direction around the camera's right vector to orbit up or down

      vecCurrentCameraRight = octane.vec.cross(octane.vec.normalized(vecCurrentViewDirection), vecCurrentCameraUp)

      if octane.vec.length(vecCurrentCameraRight) > 0 then

         vecCurrentViewDirection = octane.vec.rotate(vecCurrentViewDirection, vecCurrentCameraRight , angVerticalOrbitIncrement)

      else

         vecCurrentCameraUp = {0,0,-1}
         vecCurrentCameraRight = octane.vec.cross(octane.vec.normalized(vecCurrentViewDirection), vecCurrentCameraUp)
         vecCurrentViewDirection = octane.vec.rotate(vecCurrentViewDirection, vecCurrentCameraRight , angVerticalOrbitIncrement)


      end
      
      print(" vecCurrentViewDirection2",vecCurrentViewDirection[1],vecCurrentViewDirection[2],vecCurrentViewDirection[3])

   end



I test if the current cameras right vector goes to zero, and then change the camera up to be negative z if it is.
a camera up of z = -1 seems to work playing around outside the script, but not in the script.

Do you have any ideas as to what I'm doing wrong,

Best

Mark
Windows 7 Enterprise, 2x Intel Xeon X5650 2.66 GHz, 24GB Ram, GTX 590, Quadro 5000, Quadro K4200
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 118
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: Putting it all together, a walkthrough script

Postby stratified » Sun Feb 16, 2014 7:23 pm

stratified Sun Feb 16, 2014 7:23 pm
MB wrote:Thomas,

I hope you had a good weekend.

The script is coming along well and it can now combine multiple camera moves, and also perform some simple easing as you discussed in an earlier post. However I am trying to implement 'orbiting over the poles' without sucess.

Here is the new code i have for vertical orbiting inside the number of frames loop. Further down i set an animator on P_UP, feeding it all the vecCurrentCameraUp values.

Code: Select all
           -- Rotate the viewing direction around the camera's right vector to orbit up or down

      vecCurrentCameraRight = octane.vec.cross(octane.vec.normalized(vecCurrentViewDirection), vecCurrentCameraUp)

      if octane.vec.length(vecCurrentCameraRight) > 0 then

         vecCurrentViewDirection = octane.vec.rotate(vecCurrentViewDirection, vecCurrentCameraRight , angVerticalOrbitIncrement)

      else

         vecCurrentCameraUp = {0,0,-1}
         vecCurrentCameraRight = octane.vec.cross(octane.vec.normalized(vecCurrentViewDirection), vecCurrentCameraUp)
         vecCurrentViewDirection = octane.vec.rotate(vecCurrentViewDirection, vecCurrentCameraRight , angVerticalOrbitIncrement)


      end
      
      print(" vecCurrentViewDirection2",vecCurrentViewDirection[1],vecCurrentViewDirection[2],vecCurrentViewDirection[3])

   end



I test if the current cameras right vector goes to zero, and then change the camera up to be negative z if it is.
a camera up of z = -1 seems to work playing around outside the script, but not in the script.

Do you have any ideas as to what I'm doing wrong,

Best

Mark


Hi Mark,

Not sure what goes wrong. What exactly goes wrong in the animation, does it show a black frame?

Could you attach the script so I can reproduce the issue?

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Putting it all together, a walkthrough script

Postby MB » Sun Feb 16, 2014 9:01 pm

MB Sun Feb 16, 2014 9:01 pm
Thomas,

Here is the buggy script.

Search on "Start Broken" it itentifies three areas in the code that could be culprits. It is probabaly the first one, the way it is written now, it flips the model when you look straight down on it. I have not checked look straight up at it.

many thanks

Mark
Attachments
Octane Render Walkthrough orbit updown bug.zip
(16.99 KiB) Downloaded 107 times
Windows 7 Enterprise, 2x Intel Xeon X5650 2.66 GHz, 24GB Ram, GTX 590, Quadro 5000, Quadro K4200
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 118
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: Putting it all together, a walkthrough script

Postby stratified » Mon Feb 17, 2014 8:23 pm

stratified Mon Feb 17, 2014 8:23 pm
Hi MB,

Not sure what's going wrong but can you backtrack your changes? All I see is the frames going black but I don't really understand why.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Putting it all together, a walkthrough script

Postby MB » Mon Feb 17, 2014 8:55 pm

MB Mon Feb 17, 2014 8:55 pm
Thomas

I can easily back this changes out,
However I don't see the screen go black, I see the model flip in I believe the z axis once the right vector becomes less than zero.
Normally if the screen goes black it is because the camera position is beyond the target. This may have happened on what ever you tested the script against.

Best

Mark

P.s I like the look of your noise script, ans was wondering if it would be possible to write a script that wouldm automatically scattered say a blade of grass on anything made of say perlin noise texture.
Windows 7 Enterprise, 2x Intel Xeon X5650 2.66 GHz, 24GB Ram, GTX 590, Quadro 5000, Quadro K4200
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 118
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: Putting it all together, a walkthrough script

Postby stratified » Mon Feb 17, 2014 9:24 pm

stratified Mon Feb 17, 2014 9:24 pm
Hey Mark,

My bad, the daylight animation was during the night. I think you should load the hour that is set in the daylight node. Otherwise users might get confused.

I don't see the model flip. The only thing I do is setting "Orbit Up/Down" to 90 degrees. Do you have any other settings enabled?

Yes, you can scatter vegetation based on perlin noise in a lua script. My code has a lua perlin noise implementation (perlin.lua).

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Putting it all together, a walkthrough script

Postby MB » Mon Feb 17, 2014 11:06 pm

MB Mon Feb 17, 2014 11:06 pm
Thomas,

Here are my settings, and a video of what i see.
I'm wondering if it could be a rounding difference between your code and the script. I am trying to test if the view direction vector and the camera up vector are parallel. If you could write a test for that that worked inside an if statement i might be fine.

i believe there would be two valid tests, if the cross product of the camera up vector and the view direction = zero, or if the two vectors equalled on another.

Using print statements and examining numbers, they never actually equal each other, so the test is never passed, and the code never flips the camera direction, but the model flips as shown in the video never-the-less.

Point taken about daylight settings.


best

Mark
Attachments

[ Play Quicktime file ] OrbitUpDownBug.mp4 [ 1.16 MiB | Viewed 2194 times ]

orbit updown bug settings.png
Windows 7 Enterprise, 2x Intel Xeon X5650 2.66 GHz, 24GB Ram, GTX 590, Quadro 5000, Quadro K4200
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 118
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: Putting it all together, a walkthrough script

Postby stratified » Tue Feb 18, 2014 4:18 am

stratified Tue Feb 18, 2014 4:18 am
Hi Mark,

Now I understand what the issue is. Altough I don't think that your code actually flips the up vector, still it was a bit crude of me :oops:

I don't know what the exact behavior is you want when you go over the poles. IMHO it's the most natural if you gradually rotate the up vector along. That means that when you cross the pole, the scene is upside down. Like in this video:

[youtube]http://www.youtube.com/watch?v=eqY8auMUk98&feature=youtu.be[/youtube]

All you would need to do is modify your code to this:

Code: Select all
    if blnOrbiting == true then

           -- Calculate the horizontal angle of rotation for this frame relative to the original view direction
      local angHorizontalOrbitIncrement = math.rad( (ease(V)) * CamHorizontalRotAmount)

           -- Calculate the vertical angle of rotation for this frame
      local angVerticalOrbitIncrement = math.rad( (ease(V)) * numCamOrbitUpDownAmount )


           -- Rotate the viewing direction around the camera's up vector to orbit left or right
      vecCurrentViewDirection = octane.vec.rotate(vecInitialViewDirection, vecInitialCameraUp, angHorizontalOrbitIncrement)
      print(" vecCurrentViewDirection1",vecCurrentViewDirection[1],vecCurrentViewDirection[2],vecCurrentViewDirection[3])

      vecCurrentCameraRight   = octane.vec.cross(octane.vec.normalized(vecCurrentViewDirection), vecInitialCameraUp)
        -- Rotate the viewing direction around the camera's right vector to orbit up or down
        vecCurrentViewDirection = octane.vec.rotate(vecCurrentViewDirection, vecCurrentCameraRight , angVerticalOrbitIncrement)
        -- modify the camera up vector
        vecCurrentCameraUp = octane.vec.cross(octane.vec.normalized(vecCurrentCameraRight), vecCurrentViewDirection)

      print(" vecCurrentViewDirection2",vecCurrentViewDirection[1],vecCurrentViewDirection[2],vecCurrentViewDirection[3])

   end


BTW: you should configure your editor to convert tabs to 4 spaces. The indentation is all screwed up.

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Putting it all together, a walkthrough script

Postby MB » Tue Feb 18, 2014 5:46 pm

MB Tue Feb 18, 2014 5:46 pm
Many Thanks Thomas,

That did the trick, definately more elegant than my approach with the added benefit that it worked!
I'm pretty close to done with this script now. Will post it shortly.

Best

Mark
Windows 7 Enterprise, 2x Intel Xeon X5650 2.66 GHz, 24GB Ram, GTX 590, Quadro 5000, Quadro K4200
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 118
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.
PreviousNext

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Sat Aug 24, 2019 10:09 pm [ UTC ]