Thread: "Lerping" / Basic linear interpolation of vertex coordinates between animation frames

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 "Lerping" / Basic linear interpolation of vertex coordinates between animation frames 
    Registered Member Makaveli V2's Avatar
    Join Date
    Feb 2014
    Posts
    140
    Thanks given
    18
    Thanks received
    101
    Rep Power
    9
    Note: Instead of adding some gay anti-leech to prevent over usage of this I am minimizing the amount of code I am providing.
    This is actually linear interpolation of positions instead of interpolating transformation values. If you want to do the latter then it involves finding the appropriate transformation of this skin and type in the next frame, subtracting the parameters and then progressing them as necessary. This has also been called tweening.
    Open Model.java
    Create copies of method470, method471, method472. Name them "applyTransformFuture", "mixTransformFuture" and "transformStepFuture".
    Create copies of anIntArray1627, anIntArray1628, anIntArray1629. Name them "vertexXFuture", "vertexYFuture", "vertexZFuture".
    Go into transformStepFuture and replace all occurrences of the original arrays with the new ones. Go into applyTransformFuture & mixTransformFuture and replace all usages of the original methods with the new ones.
    Find all times the original arrays are redefined or written to, and mimic (copy) the information to the new arrays.
    Find all usages of method470 and method471, and add a call below it to applyTransformFuture and mixTransformFuture but for the next frame in the sequence.
    Define this method in Model:
    Code:
        public void interpolate(double progression) {
        	for (int v = 0; v < vertexXFuture.length; v++) {
        		double diffX = vertexXFuture[v] - anIntArray1627[v];
        		double diffY = vertexYFuture[v] - anIntArray1628[v];
        		double diffZ = vertexZFuture[v] - anIntArray1629[v];
        		anIntArray1627[v] += (int) (diffX * progression);
        		anIntArray1628[v] += (int) (diffY * progression);
        		anIntArray1629[v] += (int) (diffZ * progression);
        	}
        }
    After applyTransformFuture and mixTransformFuture usage, call interpolate. The parameter should be a value between 0d and 1d. This can be calculated by (([the current amount of render frames this animation frame has been shown for] * 1d) / [animation frame length]
    If you're too lazy to copy all of the actions, make a method in Model which reconstructs vertex[X/Y/Z]Future to be the same size as the other arrays and then copy all the values. Then you call this before the FIRST animation frame (method470/method471) is applied.
    Reply With Quote  
     


  2. #2  
    Google it ffs

    Reich's Avatar
    Join Date
    Mar 2011
    Age
    30
    Posts
    825
    Thanks given
    120
    Thanks received
    174
    Rep Power
    105
    Nasty release thanks a ton!
    Programmers are machines that convert caffeine into code
    Reply With Quote  
     

  3. #3  
    Endeavor

    Mikey`'s Avatar
    Join Date
    Dec 2007
    Posts
    4,434
    Thanks given
    715
    Thanks received
    1,435
    Rep Power
    1202
    Care to explain how to know which frames mesh with which frame..

    For instance

    Code:
    Class36 class36 = Class36.method531(Animation.anims[anim2].anIntArray353[animationFramePosition]);
    Class36 class36next = Class36.method531(Animation.anims[anim2].anIntArray353[animationFramePosition + 1]);
    
    for(int j = 0; j < class36next.anInt638; j++) {
    	for(int j2 = 0; j2 < class36.anInt638; j2++) {
    							
    	int a = class36next.anIntArray639[j];
    	int a2 = class36.anIntArray639[j2];
    							
    							
    		if (a == a2) {
    			//these frames will be tweened
                            break;
    		}
    	}
    }
    EDIT:

    My problem is complex animations will not mesh correctly, but simple animations like walking will mesh correctly.
    Reply With Quote  
     

  4. #4  
    Registered Member Makaveli V2's Avatar
    Join Date
    Feb 2014
    Posts
    140
    Thanks given
    18
    Thanks received
    101
    Rep Power
    9
    Quote Originally Posted by Mikey` View Post
    Care to explain how to know which frames mesh with which frame..

    For instance

    Code:
    Class36 class36 = Class36.method531(Animation.anims[anim2].anIntArray353[animationFramePosition]);
    Class36 class36next = Class36.method531(Animation.anims[anim2].anIntArray353[animationFramePosition + 1]);
    
    for(int j = 0; j < class36next.anInt638; j++) {
    	for(int j2 = 0; j2 < class36.anInt638; j2++) {
    							
    	int a = class36next.anIntArray639[j];
    	int a2 = class36.anIntArray639[j2];
    							
    							
    		if (a == a2) {
    			//these frames will be tweened
                            break;
    		}
    	}
    }
    EDIT:

    My problem is complex animations will not mesh correctly, but simple animations like walking will mesh correctly.
    I don't quite understand what you mean?
    Reply With Quote  
     

  5. #5  
    Endeavor

    Mikey`'s Avatar
    Join Date
    Dec 2007
    Posts
    4,434
    Thanks given
    715
    Thanks received
    1,435
    Rep Power
    1202
    Quote Originally Posted by Patrick Star View Post
    I don't quite understand what you mean?
    Say one specific index of the animation moves the players arm (we'll call this a). No when you are generating the tweened animation, how would you know which index (of the next animation frame) you need to mesh/tween with a.
    Reply With Quote  
     

  6. #6  
    Google it ffs

    Reich's Avatar
    Join Date
    Mar 2011
    Age
    30
    Posts
    825
    Thanks given
    120
    Thanks received
    174
    Rep Power
    105
    Quote Originally Posted by Mikey` View Post
    Say one specific index of the animation moves the players arm (we'll call this a). No when you are generating the tweened animation, how would you know which index (of the next animation frame) you need to mesh/tween with a.
    The previous one?
    Programmers are machines that convert caffeine into code
    Reply With Quote  
     

  7. #7  
    Endeavor

    Mikey`'s Avatar
    Join Date
    Dec 2007
    Posts
    4,434
    Thanks given
    715
    Thanks received
    1,435
    Rep Power
    1202
    Quote Originally Posted by Reich View Post
    The previous one?
    I don't think you understand, this is the animation being applied to the model

    Code:
    for(int k = 0; k < class36.anInt638; k++)
    {
    	int l = class36.anIntArray639[k];
    	method472(class18.anIntArray342[l], class18.anIntArrayArray343[l], class36.anIntArray640[k], class36.anIntArray641[k], class36.anIntArray642[k]);
    }
    Now see how k = the index of the animation frame being applied to the model, now the question is how do you find the index in the next animation frame that you would be meshed with the current animation frame. As in..

    Code:
    for(int j = 0; j < class36next.anInt638; j++)
    {
    	for(int j2 = 0; j2 < class36.anInt638; j2++)
    	{
    		
    		if (this next frame should be tweened with the frame at index j, this is the part i need) { 
    			model_2.method472(
    					class18.anIntArray342[a2], 
    					class18.anIntArrayArray343[a2], 
    					blah);
    			
    			break;
    		}
    		
    	}
    }
    Reply With Quote  
     

  8. #8  
    Google it ffs

    Reich's Avatar
    Join Date
    Mar 2011
    Age
    30
    Posts
    825
    Thanks given
    120
    Thanks received
    174
    Rep Power
    105
    Quote Originally Posted by Mikey` View Post
    I don't think you understand, this is the animation being applied to the model

    Code:
    for(int k = 0; k < class36.anInt638; k++)
    {
    	int l = class36.anIntArray639[k];
    	method472(class18.anIntArray342[l], class18.anIntArrayArray343[l], class36.anIntArray640[k], class36.anIntArray641[k], class36.anIntArray642[k]);
    }
    Now see how k = the index of the animation frame being applied to the model, now the question is how do you find the index in the next animation frame that you would be meshed with the current animation frame. As in..

    Code:
    for(int j = 0; j < class36next.anInt638; j++)
    {
    	for(int j2 = 0; j2 < class36.anInt638; j2++)
    	{
    		
    		if (this next frame should be tweened with the frame at index j, this is the part i need) { 
    			model_2.method472(
    					class18.anIntArray342[a2], 
    					class18.anIntArrayArray343[a2], 
    					((class36.anIntArray640[j2] + class36next.anIntArray640[j]) / 2), 
    					((class36.anIntArray641[j2] + class36next.anIntArray641[j]) / 2), 
    					((class36.anIntArray642[j2] + class36next.anIntArray642[j])) / 2);
    			
    			break;
    		}
    		
    	}
    }
    This can be calculated by (([the current amount of render frames this animation frame has been shown for] * 1d) / [animation frame length]
    Would that be it?
    Programmers are machines that convert caffeine into code
    Reply With Quote  
     

  9. #9  
    Registered Member Makaveli V2's Avatar
    Join Date
    Feb 2014
    Posts
    140
    Thanks given
    18
    Thanks received
    101
    Rep Power
    9
    Animation frames are standalone, not progressive. Look at the class which loads seq.dat. This is the class which you can get the next frame from.
    Reply With Quote  
     

  10. Thankful user:


  11. #10  
    Left to be damned

    Join Date
    Jul 2012
    Posts
    90
    Thanks given
    13
    Thanks received
    6
    Rep Power
    24
    The only thing that I am unsure about is: the current amount of render frames this animation frame has been shown for
    Never heard of it
    Death's nod to the rescue!
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 1
    Last Post: 07-09-2014, 02:28 PM
  2. Replies: 22
    Last Post: 11-30-2012, 06:06 AM
  3. Replies: 2
    Last Post: 10-30-2011, 06:04 PM
  4. Proof of a cache between 377-400s (381)
    By TheElveAge in forum RS2 Server
    Replies: 9
    Last Post: 04-15-2010, 07:38 AM
  5. Replies: 14
    Last Post: 02-28-2010, 04:42 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •