POV-Ray : Newsgroups : povray.animations : Skeletal Animation Saga Continues Server Time
23 Apr 2024 09:07:54 EDT (-0400)
  Skeletal Animation Saga Continues (Message 1 to 8 of 8)  
From: melo
Subject: Skeletal Animation Saga Continues
Date: 15 Feb 2008 01:45:01
Message: <web.47b534b08e58508092254edf0@news.povray.org>
Well, I have been doing some cleaning up the code based on various
recommendations Chris had offered along the way.

Such as capitalizing the var names, getting my animation control joint rotation
arrays working smoothly across frames.

I felt brave enough to switch to moving joint rotation specifications per pose
(i.e Key_Frame) into separate files I can read during animation.

I have not managed to get too far.  I have kept my staged animation logic, let
me include 1st two stages for discussions sake, and describe the error I am
getting from POV-RAY, I have search the Wiki and Support to see if there is a
documented problem, I have not seen any.

My code will be further down.  In the first stage, that is, when clock is
between 0 and 1, I first draw the Humanoid in its pose 0, i.e default pose, in
which all of his joint rotations are zero and s/he is standing erect with arms
down her sides.
Then I read my walk01.pov file that contains the involved joint rotation vectors
as a triplet: Joint_name as a string, joint index as a float, and finally,
rotation  as a vector.  Joint_name string is just for information purposes.
Later, I could do a lookup to figure out the index.  For now, I am hardcoding
the index.

Well, the first time around, I can read the file correctly.  Move_Humanoid macro
builds the object Humanoid, and if any rotation vector in AVAR[1] is set,
rotates the segments associated with that rotation vector.

In the second stage of animation marked with #range(1, 2) statement, I attempt
to reread the walk01.pov file to know which pose to start the animation and
read walk03.pov to know which pose to end the animation.  However, during that
second attempt to reread the walk01.pov file which was read ok the first time,
the program crashes at the second line of the file claiming it could not be
read.



Here is the code
===============

#switch ( clock )

   #range( 0.0, 1.0 )
      //=== Key_Frame1: STRIDE LEFT
      #if ( clock = 0.0 ) // STAND STILL
         #declare Key_Frame = 0;
         #declare Action = 0.0; // Stand still
         #declare Human_Trans =
         transform {
            scale 1.5
            translate <0.0, -1.0, 0.0>
            rotate <0, 0, 0>
            };


         Move_Humanoid( Key_Frame, Action )
         #declare Humanoid_Still = Humanoid;
         object { Humanoid_Still transform Human_Trans }

      #else //=== Key_Frame1: STRIDE LEFT

         #declare Action = 1.11; // "Stride.LeftKey_Frame1
         #declare IBP = clock;   // In Between Position counter
         #declare Key_Frame = 1;

         // declare all AVARs associated with left stride
         #debug "In Key Frame 1 else about to read walk01 for the 1st time.\n"
         #fopen posFile "Walk01.pov" read
         #while (defined( PosFile ))
            #read (PosFile, Joint_Name, AVar_Ndx, Rot_Vector )
            #declare AVAR[1][AVar_Ndx] = Rot_Vector * IBP;
         #end



         #declare L_Step_Size = 1.5*Calculate_Step_Size( "L" );
         #declare Human_Trans_1_1_01 =
         transform {
            scale 1.5
            translate L_Step_Size*clock*z -1.0*y
            //rotate <20*IBP, 0, 0>
            };


         Move_Humanoid( Key_Frame, Action )
         #declare Humanoid_1_1_01 = Humanoid;
         object{ Humanoid_1_1_01 transform Human_Trans_1_1_01 }

         // Here I observe another problem, even though now a number of
         // rotation vectors are set in AVAR[1], Move_Humanoid should have
         // rotated some of the joints, the only thing I see happening is the
         // transformation getting applied to my Humanoid in his defualt pose??
      #end
   #break

   #range( 1.0, 2.0 )
      //== Key_Frame 3  page 113
      #declare Key_Frame = 3;
      #declare Action = 1.13; // "Stride.Left.Key_Frame3
      #declare IBP = clock - 1;  // In-Between Position counter

      // load previous pose into AVAR[0]
      #debug "In key_Frame 3. About to open walk01 to load previous pose\n"
      #fopen Pos2File "Walk01.pov" read
      #while (defined(Pos2File) )
         #read (Pos2File, Joint_Name, AVar_Ndx, Rot_Vector )
         #declare AVAR[0][AVar_Ndx] = Rot_Vector;
      #end

      // load current target pose into AVAR[1] elements
      #debug "In KeyFrame 3. About to open walk03 to load current pose\n"
      #fopen Pos3File "walk03.pov" read
      #while (defined(Pos3File) )
         #read (Pos3File, Joint_Name, AVar_Ndx, Rot_Vector )
         #declare AVAR[1][AVar_Ndx] = Rot_Vector;
      #end

      // now interpolate from prev pose AVAR[0] to current pose AVAR[1]
      #declare JointNdx = 0;
      #while ( JointNdx < 22 )
        #declare AVAR[1][JointNdx]=IRV(AVAR[1][JointNdx],AVAR[0][JointNdx],IBP);
        #declare JointNdx = JointNdx + 1;
      #end

      #declare L_Step_Size = 1.5*Calculate_Step_Size( "L" );
      #declare Human_Trans_1_1_03 =
      transform {
         scale 1.5
         translate L_Step_Size*clock*z -1.0*y //<0.0, 1.0, 0.0 >
         };
      Move_Humanoid( Key_Frame, Action )
      #declare Humanoid_1_1_03 = Humanoid;
      object{ Humanoid_1_1_03 transform Human_Trans_1_1_03 }
   #break

//=== Here is walk01.pov file
"L_Hip_Ind",3,<-40,0,0>
"L_Knee_Ind",4,<0,0,0>
"L_Ankle_Ind",5,<50,0,0>
"R_Hip_Ind",13,<45, 0, 0>
"R_Knee_Ind",14,<5, 0, 0>
"L_Elbow_Ind",10,<2, 0, 0>
"R_Acromioclav_Ind",18,<0, 10, 0>
"L_Acromioclav_Ind",8,<0, -10, 0>
"R_Acromioclav_Ind",18,<-40, 0, 20>
"R_Elbow_Ind",20,<-90, 0, 0>
"R_Ball_Ind",17,<-60, 0, 0>
"Lower_Back_Ind",2,<-0,0,0>
"HumanoidRoot_Ind",0,<20, 0, 0>


Post a reply to this message

From: Chris B
Subject: Re: Skeletal Animation Saga Continues
Date: 15 Feb 2008 16:07:50
Message: <47b5ff26@news.povray.org>
"melo" <mel### [at] coxnet> wrote in message 
news:web.47b534b08e58508092254edf0@news.povray.org...
> ...
> In the second stage of animation marked with #range(1, 2) statement, I 
> attempt
> to reread the walk01.pov file to know which pose to start the animation 
> and
> read walk03.pov to know which pose to end the animation.  However, during 
> that
> second attempt to reread the walk01.pov file which was read ok the first 
> time,
> the program crashes at the second line of the file claiming it could not 
> be
> read.
>

I suspect you just need to close each file once you've finished reading it 
for each frame (See fclose).

Regards,
Chris B.


Post a reply to this message

From: gregjohn
Subject: Re: Skeletal Animation Saga Continues
Date: 15 Feb 2008 16:45:00
Message: <web.47b606a6a986a95840d56c170@news.povray.org>
"melo" <mel### [at] coxnet> wrote:
>
> I felt brave enough to switch to moving joint rotation specifications per pose
> (i.e Key_Frame) into separate files I can read during animation.
>
> I have not managed to get too far.  I have kept my staged animation logic, let
> me include 1st two stages for discussions sake, and describe the error I am
> getting from POV-RAY, I have search the Wiki and Support to see if there is a
> documented problem, I have not seen any.


Here's how I do it.
1) I have one #included file with all the junk I don't want to look at all the
time: macro definitions, etc.  It also has the definitions of the skeletal
points for the character

2) I have another #included file which is a long series of linear_spline and
cubic_spline definitions.  Thus the right wrist position might be defined as:

#declare rwristspl=  //right wristpt
        spline {
        linear_spline
        //cubic_spline
        0.00, <20,45,0>,
        0.50, <20,70,0>,
        1.00, <20,45,0>
}

#declare rtempwristpt=<0,0,0>+rwristspl(clock);

Some of my other variables are rotations, like for the head.


3) Then I have an #included file which has all the difficult math of turning my
list of rotations and wrist translations into a long list of transforms.  One
transform for every segment of the body, including all the fingers. It is based
on the angles and skeletal points defined previously:

#declare necktrans=transform{rotate neckang translate neckendpt-ribpvt
transform{ribtrans}}

Once you go through this painful exercise, you will hopefully never have to
touch it again.

4) Then I have an #included file which has a list of textures, as needed for the
foot texture and eye texture, etc.

5) Then I have an #included file which defines the body. Each segment of the
body (either a unique povray object or merely a blob component) is transformed
and textured as above. The body is finally defined as an object called "body".

cylinder{headpvt-neckendpt,0,3.4,5  texture{necktext}transform{necktrans} }


6) Now my main povray file may use the object{body} as it wishes.


Post a reply to this message

From: melo
Subject: Re: Skeletal Animation Saga Continues
Date: 15 Feb 2008 18:25:01
Message: <web.47b61ed2a986a95892254edf0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:
> "melo" <mel### [at] coxnet> wrote in message
> news:web.47b534b08e58508092254edf0@news.povray.org...
> > ...
> > In the second stage of animation marked with #range(1, 2) statement, I
> > attempt
> > to reread the walk01.pov file to know which pose to start the animation
> > and
> > read walk03.pov to know which pose to end the animation.  However, during
> > that
> > second attempt to reread the walk01.pov file which was read ok the first
> > time,
> > the program crashes at the second line of the file claiming it could not
> > be
> > read.
> >
>
> I suspect you just need to close each file once you've finished reading it
> for each frame (See fclose).
>
> Regards,
> Chris B.

Thanks Chris,  I had tried that, however, PoV-RAY complained, when I inserted
fclose statemnts. Read says that when you attempt reading past end of file, it
automatically closes it that is how we know to end the while loop that controls
the reads.

Meltem


Post a reply to this message

From: melo
Subject: Re: Skeletal Animation Saga Continues
Date: 15 Feb 2008 21:30:00
Message: <web.47b6498ba986a95892254edf0@news.povray.org>
Well,

Including a .pov  file works.

However, opening a file and reading containing rotation vector for joints
involved in a move I could not get it working.

I could not replicate what I reported yeaterday.  Today's behaviour makes more
sense, I could not read my walk01 file even for the first time, in the while
loop, it reads  the first record, however in the second record it complains.

I could not see anything different between the two records, I even copied the
1st record twice to see if it will read it for the seond time, it had not.

Again, here is my walk01.txt file, I even changed file extention, in case I was
confusing POV-RAY by using .pov extention.

"L_Hip_Ind",3,<-40,0,0>
"L_Knee_Ind",4,<0,0,0>
"L_Ankle_Ind",5,<50,0,0>
"R_Hip_Ind",13,<45, 0, 0>
"R_Knee_Ind",14,<5, 0, 0>
"L_Elbow_Ind",10,<2, 0, 0>
"R_Acromioclav_Ind",18,<0, 10, 0>
"L_Acromioclav_Ind",8,<0, -10, 0>
"R_Acromioclav_Ind",18,<-40, 0, 20>
"R_Elbow_Ind",20,<-90, 0, 0>
"R_Ball_Ind",17,<-60, 0, 0>
"Lower_Back_Ind",2,<-0,0,0>
"HumanoidRoot_Ind",0,<20, 0, 0>

Here is the loop that refuse to read beyond 1st record:

         #fopen PosFile "walk01.txt" read
         #while (defined( PosFile ))
            #read (PosFile, Joint_Name, AVar_Ndx, Rot_Vector )
            #declare AVAR[1][AVar_Ndx] = Rot_Vector * IBP;
            #debug concat( Joint_Name, ",", str(AVar_Ndx, 2, 0), ",",
                           vstr( 3, Rot_Vector, ", ", 3, 0), "\n" )
         #end
         #fclose PosFile


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Skeletal Animation Saga Continues
Date: 15 Feb 2008 21:38:27
Message: <47b64ca3$1@news.povray.org>

> "L_Hip_Ind",3,<-40,0,0>
> "L_Knee_Ind",4,<0,0,0>
> "L_Ankle_Ind",5,<50,0,0>
> "R_Hip_Ind",13,<45, 0, 0>
 >
> [...]
> 
> Here is the loop that refuse to read beyond 1st record:

Does it work if you add a comma at the end of every line?


Post a reply to this message

From: melo
Subject: Re: Skeletal Animation Saga Continues
Date: 15 Feb 2008 22:15:01
Message: <web.47b65493a986a95892254edf0@news.povray.org>
Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:

> > "L_Hip_Ind",3,<-40,0,0>
> > "L_Knee_Ind",4,<0,0,0>
> > "L_Ankle_Ind",5,<50,0,0>
> > "R_Hip_Ind",13,<45, 0, 0>
>  >
> > [...]
> >
> > Here is the loop that refuse to read beyond 1st record:
>
> Does it work if you add a comma at the end of every line?

Well, I'll be darned.  IT WORKED!

My gosh, I would have never thought of that?  What prompted you that the key
could be putting commas at the end of lines?

Thanks Nicolas.  Now I am in the game, I can debug his moves at my hearts
content, until I get the correct pose specifications.


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Skeletal Animation Saga Continues
Date: 16 Feb 2008 07:41:29
Message: <47b6d9f9$1@news.povray.org>

> Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:
>> Does it work if you add a comma at the end of every line?
> 
> Well, I'll be darned.  IT WORKED!
> 
> My gosh, I would have never thought of that?  What prompted you that the key
> could be putting commas at the end of lines?
> 
> Thanks Nicolas.  Now I am in the game, I can debug his moves at my hearts
> content, until I get the correct pose specifications.
> 

Looks like the parser doesn't care if there are newlines. Only commas 
separate items.

"L_Hip_Ind", 3, <-40,0,0>, "L_Knee_Ind", 4, <0,0,0>, "L_Ankle_Ind", 5, 
<50,0,0>, "R_Hip_Ind", 13, <45, 0, 0>

Imagine how the parser would work with *that* if it didn't have commas 
between the vectors and the strings.


Post a reply to this message

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