|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I have an animation of a ball rolling on an arbitrary surface. I'm using the
normal force on the ball to induce an acceleration and create movement.
That works great, the problem come when I try and make the ball "roll"
realistically. The problem is that the axis that the ball needs to rotate
around is constantly changing.
In effect I have a new rotation step added every frame around an arbitrary
axis. Does anyone have an idea of how to store an rotational "state" for my
ball that I can call during the next frame and add to?
Any help would be great.
-Phil
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On Mon, 17 Mar 2003 20:14:13 EST, Phil Brewer wrote:
> I have an animation of a ball rolling on an arbitrary surface. I'm using the
> normal force on the ball to induce an acceleration and create movement.
> That works great, the problem come when I try and make the ball "roll"
> realistically. The problem is that the axis that the ball needs to rotate
> around is constantly changing.
>
> In effect I have a new rotation step added every frame around an arbitrary
> axis. Does anyone have an idea of how to store an rotational "state" for my
> ball that I can call during the next frame and add to?
>
> Any help would be great.
>
> -Phil
Keep track of how far the ball has moved and apply the rotation before the
translation. This should work provided the ball doesn't bounce or do any
kind of naughty mechanics.
--
light_source#macro G(E)sphere{z+E*y*5e-3.04rotate-z*E*6pigment{rgbt#end{
20*y-10#local n=162;1}#while(n)#local n=n-.3;G(n)x}}G(-n).7}}#end//GregE
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Phil Brewer <kod### [at] mindspringcom> wrote:
> Does anyone have an idea of how to store an rotational "state" for my
> ball that I can call during the next frame and add to?
Write the necessary values to a file (see the documentation about
#fopen and #write) and read them in the next frame (#read).
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Write the necessary values to a file (see the documentation about
>#fopen and #write) and read them in the next frame (#read).
>
I am currently writing my translation values to an external file. The
problem is finding the necessary rotational values to write.
To give more info:
At every frame in the scene, the ball's calculation, velocity, and position
are calculated. Based on these values, I can determine the direction the
ball is moving, and what vector the ball needs rotated about to be rolling.
This rotate_about vector changes every frame to a new value.
The way I see it, I can either save a new rotate statement for every frame
including all previous frames (I think parse times would get excessive
towards the end), or break my arbitrary axis rotation into something that
could be stored as a simple sequence of rotations. This sequence would be
modified every frame, but would never escalate in size like my other
"option". Any ideas on how to do this? Perhaps matrix rotation?
I have had luck with rotating vectors as if they were the ball, because you
can store just the new vector, you don't have to store all of the rotations
that got you the new vector.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Phil Brewer wrote:
> The way I see it, I can either save a new rotate statement for every
> frame including all previous frames (I think parse times would get
> excessive towards the end), or break my arbitrary axis rotation into
> something that could be stored as a simple sequence of rotations.
Any sequence of rotations can be stored as a single matrix
transformation, and any matrix transformation made of only rotations can
be stored as a single rotation statement. So the accumulated rotations
can be stored as a single rotation vector.
Untested code below.
// I assume you have:
// CurRotate and CurTranslate
// - the rotation and translation from the previous frames.
// ThisRotate and ThisTranslate
// - the rotation and translation to be done in the current frame.
// And then you get NewRotate and NewTranslate
// - the rotation and translation from the previous frames
// plus the current frame.
// Given 2 vectors, a vector for the X direction
// (similar to the 1st - 3rd number in a matrix),
// and one for the Y direction (similar to the
// 4th - 6th number in a matrix), Vectors2Rotate will
// return a rotation vector which will transform an
// object in the same way as a matrix using the
// vectors would do. VectorX and VectorY must be
// perpendicular to each other.
#macro Vectors2Rotate (VectorX,VectorY) // by Rune S. Johansen
#local RotZ = VRotationD(x,<VectorX.x,VectorX.y,0>,z);
#local RotY = VRotationD(x,vrotate(VectorX,-RotZ*z),y);
#local RotX = VRotationD(vrotate(y,<0,RotY,RotZ>),VectorY,VectorX);
<RotX,RotY,RotZ>
#end
// Get the current local x, y and z axis
CurX = vrotate(x,CurRotate);
CurY = vrotate(y,CurRotate);
// Get new rotation from old using using
// the rotation for the current frame...
// (You can also use vaxis_rotate to get
// NewX,Y,Z from OldX,Y,Z if that is
// more natural to your algorithm.)
NewX = vrotate(CurX,ThisRotate);
NewY = vrotate(CurY,ThisRotate);
NewRotate = Vectors2Rotate(NewX,NewY);
NewTranslate = CurTranslate + ThisTranslate;
object {Ball rotate NewRotate translate NewTranslate}
Hope that helps...
Rune
--
3D images and anims, include files, tutorials and more:
rune|vision: http://runevision.com (updated Oct 19)
POV-Ray Ring: http://webring.povray.co.uk
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
That worked spectacular. It'll take me forever to figure out how it works,
but the movement is perfect. Thanks a lot Rune!
>
>Hope that helps...
>
>Rune
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|