POV-Ray : Newsgroups : povray.general : Please Help with coding problem! (long post) Server Time
4 Nov 2024 23:14:47 EST (-0500)
  Please Help with coding problem! (long post) (Message 1 to 7 of 7)  
From: Josh English
Subject: Please Help with coding problem! (long post)
Date: 7 Jan 1999 22:43:53
Message: <36957FC4.7175D4B9@spiritone.com>
I am working on an animation of a chess game, and one of the Knights is
causing trouble. I want the Knights jump to be rather comical, so it
gets shorter and fatter, then thins out as it springs up, breaking into
three component parts, flies through the air and lands again a few
squares away.

I had a good jump and made a Quicktime movie out of it which can be seen
at http://www.spiritone.com/~english/sproing.mov. The bad jump is at
http://www.spiritone.com/badsproing.mov. When I started to alter the
shape it moved the piece during the first part of the jump.

here is the code:

#declare JumpPoint = a place on the board;
#declare Target = a nother place n the board
#declare midPoint = a point on the board directly between target and
jumpPoint
#declare roation = rotation value along y axis to align Knight with new
square

/// Use 0 to 1 for clock

#declare anim_clock = clock;

#declare Trans_1 = 0.25; // stop looking and jump
#declare Trans_2 = 0.50; // bounce up
#declare Trans_3 = 0.75; // bounce down

#switch (anim_clock)
#range (0,Trans_1) // normalize to target
   //   rotates the knight to face the direction of the jump
#break

#range(Trans_1,Trans_2) // decelerate up
  // sets to be in normalized range
  #declare temp_clock = (anim_clock - Trans_1) / (Trans_2 - Trans_1);
  #declare bounce_time = 3/7;     // transition between prep and jump

// There are two segments, preparing to jump, and jumping up to the apex
of
// the movement
#switch(temp_clock)
  #range(0,bounce_time)
   // create a new normalized clock variable
    #declare really_temp_clock = temp_clock / bounce_time;

    #declare squish_value = sin(really_temp_clock * pi * 1.5)/5;

    #declare newWidth = 1 + squish_value; // get fatter then thinner
    #declare newHeight =1 - squish_value; // get shorter then taller

    object { base
             pigment { rgb 1 }
             scale <newWidth,newHeight,newWidth>
             rotate rotation
             translate JumpPoint }

    object { body
             pigment { rgb 1 }
             scale <newWidth,newHeight,newWidth>
             rotate rotation
             translate JumpPoint }

    object { knight_head
             pigment { rgb 1 }
             translate (1.2 - squish_value)*y
             rotate rotation
             translate JumpPoint }

  #break

#range (bounce_time,1.001)   ////   ***************** The problem is
here somewhere
   // create a new normalized clock variable
    #declare really_temp_clock = (temp_clock - bounce_time) / (1 -
bounce_time);

    #declare temp_pos = <0,0,-1>;   // begins to setup the position
    #declare jump_clock = pow (really_temp_clock,1/2);
    #declare temp_rot = 90 * x * jump_clock;

    #declare temp_pos = vrotate(really_temp_clock,temp_rot); // move
along jump path
    #declare temp_pos = vrotate(really_temp_clock,rotation);  // rotate
into position
    #declare temp_pos = temp_pos + midPoint; // final placement of parts


    object { base
             pigment { rgb 1 }
             rotate really_temp_clock *15*x
             rotate rotation
             translate temp_pos }

    object { body
             pigment { rgb 1 }
             rotate really_temp_clock *8*x
             rotate rotation
             translate temp_pos * <1,1.25,1> }

    object { knight_head
             pigment { rgb 1 }
             rotate really_temp_clock *-15*x // Nose goes up during
upward movement
             translate 1.2*y
             rotate rotation
             translate temp_pos * <1,1.75,1> }
    #break
  #end
#break

#range(Trans_2,Trans_3) // accerlarate down

  #declare temp_clock = (anim_clock - Trans_2) / (Trans_3 - Trans_2);

  #render concat ("Temp Clock is ",str(temp_clock,3,3))
  #declare temp_pos = <0,0,-1>;
  #declare temp_clock = pow (temp_clock,2);
  #declare temp_rot = ((90*temp_clock)+90)*x;

  #declare temp_pos = vrotate(temp_pos,temp_rot);
  #declare temp_pos = vrotate(temp_pos,rotation);
  #declare temp_pos = temp_pos + midPoint;

  object { base pigment { rgb 1 }
           rotate (15-(temp_clock*15))*x
           rotate rotation
           translate temp_pos }

  object { body pigment { rgb 1 }
           rotate (8-(temp_clock*8))*x
           rotate rotation
           translate temp_pos * <1,1.25,1> }

  object { knight_head
           pigment { rgb 1 }
           rotate (-15+(temp_clock*15))*x
           translate 1.2*y
           rotate rotation
           translate temp_pos * <1,1.75,1> }

#break

#range (Trans_3,1.01) // normalize to target

 // rotate back

#break
#end
-----------------------------------------------------------------------------------------------------------

Now, during the second part of the second segment, is where the problem
lies. It starts the jumpat the midpoint and behaves as if it's rotating
around the target position, then during the third segment, it appears
above the midpoint and rotates around the midpoint down to the target.
The code is exactly the same except that I add 90 degrees to the
rotation. This code also did not change from the successful version
except in the following ways: since I broke the second segment up  with
a second #switch statement, I created the really_temp_clock variable and
used that instead of temp_clock in the first part of that bit of code.
This is the confusing part, and I'm asking if anyone can see the
mistake, since I can't.

Thanks for any aide.

Josh English
eng### [at] spiritonecom
http://www.spiritone.com/~english


Post a reply to this message

From: Josh English
Subject: Re: Please Help with coding problem! (long post)
Date: 7 Jan 1999 22:52:05
Message: <369581B6.5F66B67B@spiritone.com>
Josh English wrote:

> I am working on an animation of a chess game, and one of the Knights is
> causing trouble. I want the Knights jump to be rather comical, so it
> gets shorter and fatter, then thins out as it springs up, breaking into
> three component parts, flies through the air and lands again a few
> squares away.
>
> I had a good jump and made a Quicktime movie out of it which can be seen
> at http://www.spiritone.com/~english/sproing.mov. The bad jump is at
> http://www.spiritone.com/badsproing.mov. When I started to alter the
> shape it moved the piece during the first part of the jump.
>

<SNIP>

Of course, that second movie it at http://www.spiritone.com/~english/badsproing.mov

I knew I should have doubled checked that

Josh English
eng### [at] spiritonecom
www.spiritone.com/~english


Post a reply to this message

From: Bob Hughes
Subject: Re: Please Help with coding problem! (long post)
Date: 8 Jan 1999 01:36:10
Message: <3695A75D.F82C613C@aol.com>
Change this:
    #declare temp_rot = 90 * x * jump_clock;

to this:
    #declare temp_rot = 90 * jump_clock * x;

Maybe that will fix, not easy to understand someone elses code but from
my experience an axis being manipulated must go last.

Josh English wrote:
> 
> I am working on an animation of a chess game, and one of the Knights is
> causing trouble. I want the Knights jump to be rather comical, so it
> gets shorter and fatter, then thins out as it springs up, breaking into
> three component parts, flies through the air and lands again a few
> squares away.
> 
> I had a good jump and made a Quicktime movie out of it which can be seen
> at http://www.spiritone.com/~english/sproing.mov. The bad jump is at
> http://www.spiritone.com/badsproing.mov. When I started to alter the
> shape it moved the piece during the first part of the jump.
> 
> here is the code:
> 
> #declare JumpPoint = a place on the board;
> #declare Target = a nother place n the board
> #declare midPoint = a point on the board directly between target and
> jumpPoint
> #declare roation = rotation value along y axis to align Knight with new
> square
> 
> /// Use 0 to 1 for clock
> 
> #declare anim_clock = clock;
> 
> #declare Trans_1 = 0.25; // stop looking and jump
> #declare Trans_2 = 0.50; // bounce up
> #declare Trans_3 = 0.75; // bounce down
> 
> #switch (anim_clock)
> #range (0,Trans_1) // normalize to target
>    //   rotates the knight to face the direction of the jump
> #break
> 
> #range(Trans_1,Trans_2) // decelerate up
>   // sets to be in normalized range
>   #declare temp_clock = (anim_clock - Trans_1) / (Trans_2 - Trans_1);
>   #declare bounce_time = 3/7;     // transition between prep and jump
> 
> // There are two segments, preparing to jump, and jumping up to the apex
> of
> // the movement
> #switch(temp_clock)
>   #range(0,bounce_time)
>    // create a new normalized clock variable
>     #declare really_temp_clock = temp_clock / bounce_time;
> 
>     #declare squish_value = sin(really_temp_clock * pi * 1.5)/5;
> 
>     #declare newWidth = 1 + squish_value; // get fatter then thinner
>     #declare newHeight =1 - squish_value; // get shorter then taller
> 
>     object { base
>              pigment { rgb 1 }
>              scale <newWidth,newHeight,newWidth>
>              rotate rotation
>              translate JumpPoint }
> 
>     object { body
>              pigment { rgb 1 }
>              scale <newWidth,newHeight,newWidth>
>              rotate rotation
>              translate JumpPoint }
> 
>     object { knight_head
>              pigment { rgb 1 }
>              translate (1.2 - squish_value)*y
>              rotate rotation
>              translate JumpPoint }
> 
>   #break
> 
> #range (bounce_time,1.001)   ////   ***************** The problem is
> here somewhere
>    // create a new normalized clock variable
>     #declare really_temp_clock = (temp_clock - bounce_time) / (1 -
> bounce_time);
> 
>     #declare temp_pos = <0,0,-1>;   // begins to setup the position
>     #declare jump_clock = pow (really_temp_clock,1/2);
>     #declare temp_rot = 90 * x * jump_clock;
> 
>     #declare temp_pos = vrotate(really_temp_clock,temp_rot); // move
> along jump path
>     #declare temp_pos = vrotate(really_temp_clock,rotation);  // rotate
> into position
>     #declare temp_pos = temp_pos + midPoint; // final placement of parts
> 
>     object { base
>              pigment { rgb 1 }
>              rotate really_temp_clock *15*x
>              rotate rotation
>              translate temp_pos }
> 
>     object { body
>              pigment { rgb 1 }
>              rotate really_temp_clock *8*x
>              rotate rotation
>              translate temp_pos * <1,1.25,1> }
> 
>     object { knight_head
>              pigment { rgb 1 }
>              rotate really_temp_clock *-15*x // Nose goes up during
> upward movement
>              translate 1.2*y
>              rotate rotation
>              translate temp_pos * <1,1.75,1> }
>     #break
>   #end
> #break
> 
> #range(Trans_2,Trans_3) // accerlarate down
> 
>   #declare temp_clock = (anim_clock - Trans_2) / (Trans_3 - Trans_2);
> 
>   #render concat ("Temp Clock is ",str(temp_clock,3,3))
>   #declare temp_pos = <0,0,-1>;
>   #declare temp_clock = pow (temp_clock,2);
>   #declare temp_rot = ((90*temp_clock)+90)*x;
> 
>   #declare temp_pos = vrotate(temp_pos,temp_rot);
>   #declare temp_pos = vrotate(temp_pos,rotation);
>   #declare temp_pos = temp_pos + midPoint;
> 
>   object { base pigment { rgb 1 }
>            rotate (15-(temp_clock*15))*x
>            rotate rotation
>            translate temp_pos }
> 
>   object { body pigment { rgb 1 }
>            rotate (8-(temp_clock*8))*x
>            rotate rotation
>            translate temp_pos * <1,1.25,1> }
> 
>   object { knight_head
>            pigment { rgb 1 }
>            rotate (-15+(temp_clock*15))*x
>            translate 1.2*y
>            rotate rotation
>            translate temp_pos * <1,1.75,1> }
> 
> #break
> 
> #range (Trans_3,1.01) // normalize to target
> 
>  // rotate back
> 
> #break
> #end
>
-----------------------------------------------------------------------------------------------------------
> 
> Now, during the second part of the second segment, is where the problem
> lies. It starts the jumpat the midpoint and behaves as if it's rotating
> around the target position, then during the third segment, it appears
> above the midpoint and rotates around the midpoint down to the target.
> The code is exactly the same except that I add 90 degrees to the
> rotation. This code also did not change from the successful version
> except in the following ways: since I broke the second segment up  with
> a second #switch statement, I created the really_temp_clock variable and
> used that instead of temp_clock in the first part of that bit of code.
> This is the confusing part, and I'm asking if anyone can see the
> mistake, since I can't.
> 
> Thanks for any aide.
> 
> Josh English
> eng### [at] spiritonecom
> http://www.spiritone.com/~english

-- 
 omniVERSE: beyond the universe
  http://members.aol.com/inversez/POVring.htm
=Bob


Post a reply to this message


Attachments:
Download 'us-ascii' (1 KB)

From: Bob Hughes
Subject: Re: Please Help with coding problem! (long post)
Date: 8 Jan 1999 01:43:17
Message: <3695A90C.E331BE1F@aol.com>
Yep, I see a difference but not easy to see that 90 degrees x rotation.
I guess because it is only actually a partial amount of the whole?
Thought you were going to stretch the knight from what I understood, but
guess you meant break it apart and put back together instead. Think
you'd get a great look if you managed a scale y shrinkage before the
piece moves (like crouching before a jump) then increase scale y as it
moves up slightly and again a lessened scale y at the end. Then back to
normal.
Just a suggestion.

Josh English wrote:
> 
> Josh English wrote:
> 
> > I am working on an animation of a chess game, and one of the Knights is
> > causing trouble. I want the Knights jump to be rather comical, so it
> > gets shorter and fatter, then thins out as it springs up, breaking into
> > three component parts, flies through the air and lands again a few
> > squares away.
> >
> > I had a good jump and made a Quicktime movie out of it which can be seen
> > at http://www.spiritone.com/~english/sproing.mov. The bad jump is at
> > http://www.spiritone.com/badsproing.mov. When I started to alter the
> > shape it moved the piece during the first part of the jump.
> >
> 
> <SNIP>
> 
> Of course, that second movie it at http://www.spiritone.com/~english/badsproing.mov
> 
> I knew I should have doubled checked that
> 
> Josh English
> eng### [at] spiritonecom
> www.spiritone.com/~english

-- 
 omniVERSE: beyond the universe
  http://members.aol.com/inversez/POVring.htm
=Bob


Post a reply to this message


Attachments:
Download 'us-ascii' (1 KB)

From: Josh English
Subject: Re: Please Help with coding problem! (long post)
Date: 8 Jan 1999 10:37:03
Message: <369626FD.157452AE@spiritone.com>
Actually, it is going to crouch down before the jump... that's the part I was
beginning
to code when it "broke".

Thanks for the suggestion, tho, I'll try that.

Josh English
eng### [at] spiritonecom

Bob Hughes wrote:

> Yep, I see a difference but not easy to see that 90 degrees x rotation.
> I guess because it is only actually a partial amount of the whole?
> Thought you were going to stretch the knight from what I understood, but
> guess you meant break it apart and put back together instead. Think
> you'd get a great look if you managed a scale y shrinkage before the
> piece moves (like crouching before a jump) then increase scale y as it
> moves up slightly and again a lessened scale y at the end. Then back to
> normal.
> Just a suggestion.
>
> Josh English wrote:
> >
> > Josh English wrote:
> >
> > > I am working on an animation of a chess game, and one of the Knights is
> > > causing trouble. I want the Knights jump to be rather comical, so it
> > > gets shorter and fatter, then thins out as it springs up, breaking into
> > > three component parts, flies through the air and lands again a few
> > > squares away.
> > >
> > > I had a good jump and made a Quicktime movie out of it which can be seen
> > > at http://www.spiritone.com/~english/sproing.mov. The bad jump is at
> > > http://www.spiritone.com/badsproing.mov. When I started to alter the
> > > shape it moved the piece during the first part of the jump.
> > >
> >
> > <SNIP>
> >
> > Of course, that second movie it at
http://www.spiritone.com/~english/badsproing.mov
> >
> > I knew I should have doubled checked that
> >
> > Josh English
> > eng### [at] spiritonecom
> > www.spiritone.com/~english
>
> --
>  omniVERSE: beyond the universe
>   http://members.aol.com/inversez/POVring.htm
> =Bob


Post a reply to this message

From: Josh English
Subject: Re: Please Help with coding problem! (long post)
Date: 8 Jan 1999 11:36:32
Message: <369634EC.D2E92DB7@spiritone.com>
I found it! While changing the temp_clock to really_temp_clock, I used a series of cut
and
paste commands, and mistook a couple of temp_pos for temp_clock... Thanks Bob, your
suggestion didn't work, but it allowed me to see the code differently, and I began to
wonder why I was changing the postion based on the clock and not changing the
position...
silly me.

Thanks again

Josh

Josh English wrote:

> Actually, it is going to crouch down before the jump... that's the part I was
beginning
> to code when it "broke".
>
> Thanks for the suggestion, tho, I'll try that.
>
> Josh English
> eng### [at] spiritonecom
>
> Bob Hughes wrote:
>
> > Yep, I see a difference but not easy to see that 90 degrees x rotation.
> > I guess because it is only actually a partial amount of the whole?
> > Thought you were going to stretch the knight from what I understood, but
> > guess you meant break it apart and put back together instead. Think
> > you'd get a great look if you managed a scale y shrinkage before the
> > piece moves (like crouching before a jump) then increase scale y as it
> > moves up slightly and again a lessened scale y at the end. Then back to
> > normal.
> > Just a suggestion.
> >
> > Josh English wrote:
> > >
> > > Josh English wrote:
> > >
> > > > I am working on an animation of a chess game, and one of the Knights is
> > > > causing trouble. I want the Knights jump to be rather comical, so it
> > > > gets shorter and fatter, then thins out as it springs up, breaking into
> > > > three component parts, flies through the air and lands again a few
> > > > squares away.
> > > >
> > > > I had a good jump and made a Quicktime movie out of it which can be seen
> > > > at http://www.spiritone.com/~english/sproing.mov. The bad jump is at
> > > > http://www.spiritone.com/badsproing.mov. When I started to alter the
> > > > shape it moved the piece during the first part of the jump.
> > > >
> > >
> > > <SNIP>
> > >
> > > Of course, that second movie it at
http://www.spiritone.com/~english/badsproing.mov
> > >
> > > I knew I should have doubled checked that
> > >
> > > Josh English
> > > eng### [at] spiritonecom
> > > www.spiritone.com/~english
> >
> > --
> >  omniVERSE: beyond the universe
> >   http://members.aol.com/inversez/POVring.htm
> > =Bob


Post a reply to this message

From: Bob Hughes
Subject: Re: Please Help with coding problem! (long post)
Date: 9 Jan 1999 07:55:28
Message: <369751C4.8D8B1BB3@aol.com>
As long as it works in the end, that's of prime importance. I only
rarely actually manage any real help anyway.

Josh English wrote:
> 
> I found it! While changing the temp_clock to really_temp_clock, I used a series of
cut and
> paste commands, and mistook a couple of temp_pos for temp_clock... Thanks Bob, your
> suggestion didn't work, but it allowed me to see the code differently, and I began
to
> wonder why I was changing the postion based on the clock and not changing the
position...
> silly me.
> 
> Thanks again
> 
> Josh
> 
> Josh English wrote:
> 
> > Actually, it is going to crouch down before the jump... that's the part I was
beginning
> > to code when it "broke".
> >
> > Thanks for the suggestion, tho, I'll try that.
> >
> > Josh English
> > eng### [at] spiritonecom
> >
> > Bob Hughes wrote:
> >
> > > Yep, I see a difference but not easy to see that 90 degrees x rotation.
> > > I guess because it is only actually a partial amount of the whole?
> > > Thought you were going to stretch the knight from what I understood, but
> > > guess you meant break it apart and put back together instead. Think
> > > you'd get a great look if you managed a scale y shrinkage before the
> > > piece moves (like crouching before a jump) then increase scale y as it
> > > moves up slightly and again a lessened scale y at the end. Then back to
> > > normal.
> > > Just a suggestion.
> > >
> > > Josh English wrote:
> > > >
> > > > Josh English wrote:
> > > >
> > > > > I am working on an animation of a chess game, and one of the Knights is
> > > > > causing trouble. I want the Knights jump to be rather comical, so it
> > > > > gets shorter and fatter, then thins out as it springs up, breaking into
> > > > > three component parts, flies through the air and lands again a few
> > > > > squares away.
> > > > >
> > > > > I had a good jump and made a Quicktime movie out of it which can be seen
> > > > > at http://www.spiritone.com/~english/sproing.mov. The bad jump is at
> > > > > http://www.spiritone.com/badsproing.mov. When I started to alter the
> > > > > shape it moved the piece during the first part of the jump.
> > > > >
> > > >
> > > > <SNIP>
> > > >
> > > > Of course, that second movie it at
http://www.spiritone.com/~english/badsproing.mov
> > > >
> > > > I knew I should have doubled checked that
> > > >
> > > > Josh English
> > > > eng### [at] spiritonecom
> > > > www.spiritone.com/~english
> > >
> > > --
> > >  omniVERSE: beyond the universe
> > >   http://members.aol.com/inversez/POVring.htm
> > > =Bob

-- 
 omniVERSE: beyond the universe
  http://members.aol.com/inversez/POVring.htm
=Bob


Post a reply to this message

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