Anim8or Community

General Category => Ongoing Anim8or Development => Topic started by: Steve on December 24, 2020, 10:44:27 am

Title: Animated Parameteric Plug-in Scripts
Post by: Steve on December 24, 2020, 10:44:27 am
I have a prelimimary version of Anim8or Build 1394+ (http://www.anim8or.com/download/preview/files/animcl1394+.zip) that supports animated parameteric plug-in meshes. You can reference the frame and time variables to animate them. Here's how it works:

1. Add the new directive #animated after the #plugin("obect", ...) directive.
2. The value of the built in variable "time" will be the scene's time in seconds, and the variable "frame" will be set to the frame number.

There are still a few loose ends in this build, such as the meshes don't revert to frame 0 in the Object editor. I hope to have an oficial buld out soon.

ianross I've modified one of your wave scripts to animate the waves. I added the statement:

$time = $time + time*10.0;

and here's what it looks like in a scene:

Title: Re: Animated Parameteric Plug-in Scripts
Post by: NickE on December 25, 2020, 02:09:38 pm
Wow, Steve!
That is a great Christmas present! I have been asking for this for years!
Thank you, thank you, thank you!

NickE
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on December 29, 2020, 05:49:39 am
That looks great Steve! I shall have to have a play with it.

John
Title: Re: Animated Parameteric Plug-in Scripts
Post by: ianross on December 29, 2020, 05:57:35 am
Hi Steve, I did not have the pleasure of creating the new wave script, all credit goes to my good friend Hindsight. So a big thank you to Hindsight, he is new to anim8or and this is a remarkable achievement for a newbie.
Also thank you Steve for the help to make the wave script animated.
Wishing all anim8ors a Happy and Safe New year.
Title: Re: Animated Parameteric Plug-in Scripts
Post by: Steve on December 29, 2020, 11:53:12 am
Grest script, 2020 Hindsight. I still have a couple of issues to work out but I should have a more solid build out soon.
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on December 29, 2020, 07:01:14 pm
This is my first try of Anim8or's animated parametric plug-in meshes. It is cribbed off Steve’s demo files. But I have moved the wave source closer, rotated the wave direction 180 degrees, and added a decaying wave origin at the centre of the grid (offset from grid by 0.49 to reduce the splash height. But this resulted in a truncated splash. Is it possible to subdivide faces on an animated parametric plug-in mesh? ):

Thanks for all your work Steve!
Title: Re: Animated Parameteric Plug-in Scripts
Post by: Steve on December 30, 2020, 04:54:01 am
Ahhh, yes, subdivided parameteric meshes! You read my mnd. I alrady have that about 3/4 finished :)
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on December 30, 2020, 05:10:38 am
:)
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on December 30, 2020, 07:34:40 am
Hi Steve – you may want to shout “That’s forboden!” at me, but …

The parameter editor only allows 10 parameters, which was a bit limiting on the waves script. Originally I had separate scaling factors for X, Y, and Z. And as an experiment I just added back the “Z scale” (as an eleventh parameter). From the .an8 file I can configure the wave scrip with all 11 parameters (proved by animating big and small waves).

Should it be safe to add extra script accessible only parameters?

If I select the wave object, and bring up the “Parametric Plug-in Editor” then hit “OK”, I get the error “Bad value:  Z scale”. And if I hit “Cancel” I get “Anim8or has stopped working”.

If I just load the .an8 script that sets all 11 parameters, I can produce animations without a problem.
Title: Re: Animated Parameteric Plug-in Scripts
Post by: Steve on December 30, 2020, 11:19:29 am
Heh heh! You're hacking the Anim8or file format (https://www.anim8or.com/em/johnar/ThumbsUpW1.gif)

The 10 parameter limit is artificial, I know. I thought it would be sufficient and it was a simpler dialog. I'll see what I can do.

As for adding the parameter to the .an8 file, at least it somewhat works (https://www.anim8or.com/em/johnar/biggrinnW.gif)
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 05, 2021, 07:21:29 pm
I’ve had a bit of a play with the animated waves, and tried to give the impression of interaction between an object and water.

I added a function to the script to make a boat hull shaped splash. I felt that otherwise it looks artificial - I probably should do another animation without calling the addBoat() function, and compare them:
/* Function: $addBoat( float $x, float $y, float $direction, float $length, float $width )
 *
 * x,y - Center of boat
 * direction - direction boat is pointing
 * length - length of the boat
 * width - width of the boat
 */

If you set the width to the same value as the length, then your boat is a coracle, or Rover from The Prisoner, as I have animated! (Well a sphere is a lot easier to model than a boat!)

Having the ball bobbing around a bit would help with the realism.

The function adds a number of decaying wave sources around the periphery of the boat:
$DecayingWaveOrigins.push( ($x + $len_x * $dy - $len_y * $dx,
                            $y + $len_x * $dx + $len_y * $dy,
                            1, 12) ); // amplitude, wave length


The last two parameters set the wave height and the wave length.

Anyway here is the result:
[/youtube]

I notice that the video on YouTube isn’t as sharp as the video I uploaded. I have been using the “Intel IYUV codec” for video compression. Is there a better choice for uploading to YouTube?

Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 05, 2021, 07:45:14 pm
The addBoat() function can make boat shaped splashes too (well ellipses anyway).

Here is an animation I made testing this functionality – you see the splashes but I haven’t added a boat.

I think I used a length of 20, a width of 5, and an angle of PI/6 radians (which is 30 degrees).
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 06, 2021, 06:09:20 pm
Waves around ball but with no call of addBoat()
(For comparison with "Waves around a ball animation, with decaying waves around the ball.")

[/youtube]
The second video is the video I posted before of "Waves around a ball animation, with decaying waves around the ball."

As I mentioned in the earlier post: It is a shame that the YouTube video quality is so fuzzy – the video I uploaded was nice and crisp. I have been using the “Intel IYUV codec” for video compression. Is there a better choice for uploading to YouTube?
Title: Re: Animated Parameteric Plug-in Scripts
Post by: johnar on January 07, 2021, 01:53:20 am
 Just wanted to say how sweet that animated water looks.
At first it looked, to me, like the ground grid was underneath  and scene mode had been flooded.
 Really cool stuff. (https://i.postimg.cc/6QhpTB37/Smile-Blnkwhite.gif)


 
Title: Re: Animated Parameteric Plug-in Scripts
Post by: Steve on January 07, 2021, 06:24:22 am
johnae the ground grid is underneath the water. The water has an index of refraction of 1.3 which redirects the rays as you look trough the surface.
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 07, 2021, 07:01:26 am
Thanks Johnar!
Title: Re: Animated Parameteric Plug-in Scripts
Post by: AlecJames on January 07, 2021, 08:24:26 am
I agree that water effect is really good :)
Title: Re: Animated Parameteric Plug-in Scripts
Post by: ianross on January 07, 2021, 08:57:09 am
Hi 2020 Hindsight this is really amazing, thank you. I enclose a zipped file of my toy yacht with water plane that incudes a reflective attribute water surface (rendered with the art ray tracer) , also there is a back drop cloud scene.
2020 Hindsight you are very welcome to animate this uploaded file with your new surrounding wave script.
Also thank you Steve.
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 07, 2021, 12:19:53 pm
Hi Ian,
There be monsters!


OK. Some scale and centring issues here!
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 07, 2021, 06:28:02 pm
How about this version Ian?

The water is wider than it is deep 192x128 to fill horizon, with small waves so the reflections don't go off the cloud .jpg backdrop. It would have been better if the wave origin wasn’t so far left or at least if it was further back from the grid.


Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 08, 2021, 08:58:31 am
I think this looks better. I increased the height of the waves:

I tweaked the settings from the last video to:
    parameter { "X Tiles" int 192 }
    parameter { "Y Tiles" int 128 }
    parameter { "Scale" float 0.50000 "scale" "scale_x" }
    parameter { "Seed" int 3454 }
    parameter { "Wave origin count" int 23 }
    parameter { "Max wave height" float 0.33000 }
    parameter { "Mean wavelength" float 7 }
    parameter { "Min wave distance" float 120 }
    parameter { "Wave direction" float -65 }
    parameter { "Time" float 92 }


and

$DecayingWaveOrigins.push( ($x + $len_x * $dy - $len_y * $dx,
                            $y + $len_x * $dx + $len_y * $dy,
                            0.15, 4) ); // amplitude, wave length
Title: Re: Animated Parameteric Plug-in Scripts
Post by: ianross on January 08, 2021, 09:34:51 am
Thank you 2020 Hindsight, fantastic work!!!!!! well done.
Title: Re: Animated Parameteric Plug-in Scripts
Post by: johnar on January 09, 2021, 03:36:42 am
johnae the ground grid is underneath the water. The water has an index of refraction of 1.3 which redirects the rays as you look trough the surface.

Wicked!! (https://i.postimg.cc/5tHMW1zd/SSG03W.gif) (https://i.postimg.cc/mr96SrMD/Thumbs-Up-W1.gif)
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 09, 2021, 09:11:51 am
I would like to make floating objects bob with the waves. But I think I must be being thick as I cannot follow what is written under the heading “Controller Expression Script” in https://www.anim8or.com/scripts/spec/index.html (https://www.anim8or.com/scripts/spec/index.html)

I have tried adding the following to the “Animated toy yacht on sea - 192x128zoom.an8” file I’ve been using, but I just get the error report “Error in reading file” in a pop-up window named “just so you’d know”:
  point3 $bluePos;
  $bluePos = GetAttributePoint3("toy yacht", "position");
  $position = $bluePos + (0, 50, 0);


I have also tried simply declaring an int variable at any point I think it may be acceptable within the .an8 file. But I always get the “Error in reading file” error report.

Can someone point me to a .an8 script that demonstrates how to use the GetAttribute* functions?

Should the above code be inside the scene { "scene01" …} section, or after the closing ‘}’? Or somewhere else?

Thanks,
John
Title: Re: Animated Parameteric Plug-in Scripts
Post by: Steve on January 10, 2021, 08:20:29 am
2020 Hindsight - Did you try adding this to a controller script, or to a parameteric mesh script? The GetAttributeXXX() functions are only supported in controller scripts in a scene.
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 10, 2021, 09:55:16 am
I believe I added it to the “controller script” but I’m not confident in the terminology – I could be confused about the names of things.

I added it to the file with the “.an8” file extension not the “.a8s” file extension. The file attached to the post above that starts “How about this version Ian?” called “Animated toy yacht on sea - 192x128zoom.an8”
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 10, 2021, 10:18:38 am
For example I’ve tried:

scene { "scene01"
  frames { 600 }
  groundgrid { 0 }
  shadowbias { 0.00100 }
  background { 187 227 235 }
  image {
    "C:\\___ 0 ANIM8OR MANUAL\\waves\\water typpes\\sky-1286888_960_720.jpg" }
  panorama { (-90 90 -30 30) }
  objectelement { "BOAT" "toy yacht"
    loc { (-246.74 -128.82 -535.56) }
    orientation { (-0.11446 -0.01427 0.04222 0.99243) }
    scale { 10.591 }
  }
  point3 $bluePos;
  $bluePos = GetAttributePoint3("toy yacht", "position");

Title: Re: Animated Parameteric Plug-in Scripts
Post by: Steve on January 10, 2021, 12:24:24 pm
OK, you make a Controller Script by opening an element's dialog in the scene editor, then click on the "..." next to the Location, Orientation, Visibility, etc. entry. This brings up a Key editor dialog. In the Expression area click on the "on" radio button, then on the "Edit" button. This is where you enter the Controller Script.

I've attaced an example with some controllers. You can also access the scripts text by double clicking on the name of the controller in the track window if it already exists.

Be sure to look at scene02 which has an example of a red flashing light.
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 12, 2021, 07:52:40 am
Thanks Steve. Things make more sense now!
Title: Re: Animated Parameteric Plug-in Scripts
Post by: 2020 Hindsight on January 12, 2021, 08:48:14 am
Some notes for people wanting to use animated water, and waves around objects.

Using the files “IansBoatWaves.a8s”, and “Animated toy yacht on sea - 192x128zoom.an8” which I attached to the “How about this version Ian?” post above. (These 2 files work, but the sea and sky will be black unless you copy the “sky-1286888_960_720.jpg” file from the zip file IanRoss posted.) Place these files in the Anim8orScripts directory.

1) You need a recent version of Anim8or. At least Version 1.01.1394+ dated 22/12/2020.

2) Open "Animated toy yacht on sea - 192x128zoom.an8" You should get a pop-up DOS window titled "Anim8or Debug Output"

3) Switch to Scene mode

4) Press '1' on the numeric keypad to look through the camera

5) Render movie

This animation makes use of the addBoat() function in “IansBoatWaves.a8s” to create the waves around the boat.

The boat hull has to be added to the wave script. It would be much nicer if this could be controlled from the .AN8 script. But I don't know of a way to do that.
I would recommend that for each animation you copy and re-name the original wave script, and reflect the new file name in both the "#plugin("object", "mesh", "IansBoatWaves");" in the .a8s file, and the "plugin { "IansBoatWaves" }" line in the .AN8 file, otherwise the code is likely to call the old script rather than the modified one.

The new script will add a second wave icon which is less than ideal, so it is best to store your modified scripts in a different directory, and only copy them to the "Anim8orScripts" directory when you are making the animation. And after the animation remove the modified version.

As the addBoat() function adds decaying waves, the first waves are quite large, so it may look better to pass a smaller length and width to addBoat() than the real boat, and use the boat hull to hide the most violent waves.



“Animated toy yacht on sea - 192x128zoom.an8” sets the number of frames that get animated  with the "frames{600} " line.

The wave parameters used in the animation are set up in the .AN8 script with:
  parameteric {
    name { "IansBoatWaves01" }
    plugin { "IansBoatWaves" }
    base {
      origin { (-48 -15 -5.5) }
      orientation { (0 0 0 0) }
    }
    material { "material02" }
    parameter { "X Tiles" int 192 }
    parameter { "Y Tiles" int 128 }
    parameter { "Scale" float 0.50000 "scale" "scale_x" }
    parameter { "Seed" int 3454 }
    parameter { "Wave origin count" int 23 }
    parameter { "Max wave height" float 0.33000 }
    parameter { "Mean wavelength" float 7 }
    parameter { "Min wave distance" float 120 }
    parameter { "Wave direction" float -65 }
    parameter { "Time" float 92 }
  }


Note the "plugin { "IansBoatWaves" }" where  "IansBoatWaves" is the name given in the "#plugin("object", "mesh", "IansBoatWaves");" line of IansBoatWaves.a8s.
This differentiates this wave object from the original unmodified waves script.

The object name passed to “    name { "IansBoatWaves01" }” is generated form the plugin name, so adjust that too.

If the wave script didn't have the "#animated" line in it then it would just be calculated the once like the other un-animated objects in the scene.

The speed of the waves is controlled by the multiplier you put in the “IansBoatWaves.a8s” line:
$time = $time + time*6.0;

Title: Re: Animated Parameteric Plug-in Scripts
Post by: jbskaggs on January 12, 2021, 02:06:29 pm
Wow!