POV-Ray : Newsgroups : povray.animations : Help with SDL for Bouncing Ball : Re: Help with SDL for Bouncing Ball Server Time
2 May 2024 04:09:25 EDT (-0400)
  Re: Help with SDL for Bouncing Ball  
From: dick balaska
Date: 28 Dec 2016 01:57:45
Message: <58636269$1@news.povray.org>
Am 2016-12-27 17:32, also sprach Bald Eagle:

> I was wondering if anyone had any practical and concrete advice on how to handle
> the various parts of the animation, and how to organize the code in a sensible
> manner.

A plug for my "movie": http://www.buckosoft.com/tteoac/

I use basic physics for my sphere's motion.  Each sphere has a position 
and a vector. The vector is updated based on gravity and added to the 
position.  Then the position is tested for bouncing and the vector 
modified. (I sort of squish my volcano (cone) before it erupts. ;) )
To squish spheres, I would add a squishFactor = 0; and squishMax = r/2;
   if (sphere.y - r < 0) squishAccelerate = 0.5;
Then iterate,
   squishAccelerate gets added to squishFactor,
   squishAccelerate gets updated, while squishing decrement towards 0
   sphere gets drawn as r - squishFactor.

Hmm, I may have to see what squishing looks like on my spew. :)
My bouncing code is here http://tinyurl.com/jcg8g4s [1]
but it won't help you because it's Java. Once I started testing 1500 
spheres bouncing off of each other I was looking at 24 hour parse times 
in povray, so I moved that off to Java which spits out povray source 
like this. http://tinyurl.com/zk9d9t5 [2]

I break down every move so that at it's fundamental, every move runs 
from 0.0-1.0, so normal sphere (0.0) would be squishFactor = 0 and 
squished (1.0) would be squishFactor = r/2;

But you can't run squishFactor linearly from 0.0-1.0, that looks too 
robotic.  I apply an acceleration curve like Curve0 on this page.
http://www.buckosoft.com/~dick/pov/curves/
So while my timer runs 0.0-1.0, squishFactor is massaged by that quarter 
cosine.

This is all probably way more complicated than you want, ;)
but that's how I do it.

-- 
dik

[1] alias for 
http://git.buckosoft.com/gitweb/pov.cgi?p=TteoacService.git;a=blob;f=src/main/java/com/buckosoft/povspew/tteoac/Volcano/VolcanoRunner.java;h=3ec758b0504ad201ecbd847dc695dfe30927fc7e;hb=HEAD

[2] alias for 
http://www.buckosoft.com/tteoac/tteoac/service?scene=tteo|fps=23.976|type=Volcano|frame=1900


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.