|
|
I think that you are using the wrong approach for the effect you are
trying to achieve.
What you probably want is a function which gives you the position of
the object as a function of time. We could do this literally with a
function, like this:
#declare ObjectXPosition = function(t) { <a function of t here> };
object { Ball translate <ObjectXPosition(clock*60), 0, 0> }
Now it's only a question of writing the proper implementation for that
"<a function of t here>". If you wrote it like this:
#declare ObjectXPosition = function(t) { 0 };
then you would have a static object at x = 0, which doesn't move. If you
wrote this:
#declare ObjectXPosition = function(t) { t };
then the object would move at a fixed speed, as its x coordinate would be
linear with respect to time. If you wrote this:
#declare ObjectXPosition = function(t) { t*t };
now the speed of the object doubles for each unit of time. In other words,
you get a constant acceleration. You can get a slower acceleration by using
powers smaller than 2, eg:
#declare ObjectXPosition = function(t) { pow(t, 1.5) };
You said that you wanted speed which changes depending on the time.
In other words, if clock*60 <= 3, the speed is linear, but for larger
values it's accelerating. Creating one single function to do this becomes
quite complicated, but you can achieve the same effect by using two
functions for those two cases, and adding them appropriately, like this:
#declare LinearSpeed = function(t) { t };
#declare AcceleratingSpeed = function(t) { pow(t, 1.5) };
#declare num = clock*60;
#declare ObjectX = LinearSpeed(num);
#if(num > 3)
#declare ObjectX = ObjectX + AcceleratingSpeed(num - 3);
#end
(Note that the parameter to the latter function has to be shifted so
that it starts from 0 forwards.)
--
- Warp
Post a reply to this message
|
|