Summary of the invention
For the weak point existing in the problems referred to above, the invention provides a kind of non-linear joining method and device of the digital figure for shadow-play animation script file based on Xml, be applied in the post-processed process of digital figure for shadow-play animation script file, synthesize by the later stage modify to animation script file, splicing, the complete animation script file of final formation, take digital shadow puppet performance platform as support, show more stable, more smooth digital figure for shadow-play animation again.
For achieving the above object, the invention provides a kind of non-linear joining method of the digital figure for shadow-play animation script file based on Xml, comprise the following steps:
S10, collection Xml data, to determine effective number of frames;
S20, according to fixed number of frames, Xml data are positioned to parsing;
S30, key frame Xml script file being carried out before non-linear splicing according to required temporal aspect are reset processing;
S40, the method positioning splicing point that uses the splice point based on reverse keyframe sequence to locate fast;
S50, utilization key frame calculating formula of similarity judge whether splice point mates;
S60, threshold epsilon is set, to determine that whether this splice point is as best splice point;
S70, from the angle of Xml document tree, Xml file is spliced to processing.
The non-linear joining method of the above-mentioned digital figure for shadow-play animation script file based on Xml, wherein, in step S10, comprises the following steps:
Xml data are resolved, obtain x coordinate and the y coordinate of data in Xml file;
Gather all elements in the swf file loading, and be stored in an array;
Traversal each element in array, judges that touch point described in current data is whether in a certain element MovieClip, returns in current data first touch point to the frame number of element MovieClip.
The non-linear joining method of the above-mentioned digital figure for shadow-play animation script file based on Xml, wherein, in step S20, positions the number of frames obtaining in S10, to obtain Xml data at its current place, resolves all information in Xml data.
The non-linear joining method of the above-mentioned digital figure for shadow-play animation script file based on Xml, wherein, in described step S30, comprises the following steps:
Obtain the temporal aspect value of user's input;
Calculate the difference of former key frame and current temporal aspect value;
The funtcional relationship presenting according to above-mentioned difference, to the key frame in every data in Xml script file successively assignment again.
The non-linear joining method of the above-mentioned digital figure for shadow-play animation script file based on Xml, wherein, in step S40, for the scene of keyframe sequence intersection splicing, the coupling that each frame of cross section is carried out between frame is calculated, and comprises the following steps:
Obtain the length l en1 of keyframe sequence A and the length l en2 of keyframe sequence B;
In keyframe sequence A, from its key frame position, end, len1 moves to initial key frame position 1, and each position k is circulated successively;
In keyframe sequence B, calculate the similarity Sim of k key frame in 1+i key frame and keyframe sequence A, wherein, if exist similarity to meet threshold epsilon, stop circulation, otherwise until circulation end.
The non-linear joining method of the above-mentioned digital figure for shadow-play animation script file based on Xml, wherein, in step S50, utilizes the range formula of two points in Euclidean space to calculate similarity:
Wherein, in the time of n=2, Euclidean distance is exactly the distance of two points in plane, in the time representing similarity with Euclidean distance, adopts following formula to change, when determining that distance more hour, determines that similarity is larger,
Utilize following formula to calculate the similarity of key frame Gi and Gj:
The non-linear joining method of the above-mentioned digital figure for shadow-play animation script file based on Xml, wherein, in step S60, according to calculating formula of similarity to draw threshold epsilon, if touch point track acceptable splicing situation is relevant to coordinate points Pixel Information in scene, set acceptable maximum pixel and be 2 and calculate derivation, utilize following formula to draw the value of threshold epsilon:
≈0.261。
The non-linear joining method of the above-mentioned digital figure for shadow-play animation script file based on Xml, wherein, in step S70, to the tree structure change operation of Xml document, comprises the following steps:
Remove all right brotgher of node at the Xml document splice point place being inserted into;
Extract all right brotgher of node at the pre-Xml document splice point place inserting, and reset key frame according to corresponding timing, two Xml documents are merged into an Xml document.
The present invention also provides a kind of non-linear splicing apparatus of the digital figure for shadow-play animation script file based on Xml, comprising:
Xml data acquisition module, for gathering Xml data, to determine effective number of frames;
Xml data location parsing module, for positioning parsing according to fixed number of frames to Xml data;
Key frame is reset processing module, resets processing for key frame Xml script file being carried out before non-linear splicing according to required temporal aspect;
Splice point locating module, for using the splice point method positioning splicing point of location fast based on reverse keyframe sequence;
Splice point discrimination module, for using key frame calculating formula of similarity to judge whether splice point mates;
Threshold module, for threshold epsilon is set, to determine that whether this splice point is as best splice point;
Splicing processing module, splices processing for the angle from Xml document tree to Xml file.
Compared with prior art, the present invention has the following advantages:
The present invention has effectively realized the non-linear splicing of digital figure for shadow-play animation script file, the algorithm relating to improves the operation efficiency of Data Matching, can be applied to cartoon making and the post-processed of the Xml script file generating by recording technology, for traditional cartoon making provides new thinking;
The present invention is applied in the post-processed process of digital figure for shadow-play animation script file, synthesize by the later stage modify to animation script file, splicing, the complete animation script file of final formation, take digital shadow puppet performance platform as support, show more stable, more smooth digital figure for shadow-play animation again.
Embodiment
As shown in Figure 1 to Figure 3, the invention provides a kind of non-linear joining method of the digital figure for shadow-play animation script file based on Xml, comprise the following steps:
S10, collection Xml data, to determine effective number of frames.
Concrete, comprise the following steps:
Xml data are resolved, obtain x coordinate and the y coordinate of data in Xml file;
Gather all elements in the swf file loading, and be stored in an array;
Traversal each element in array, judges that touch point described in current data is whether in a certain element MovieClip, returns in current data first touch point to the frame number of element MovieClip.
S20, according to fixed number of frames, Xml data are positioned to parsing.
Concrete, in step S20, on digital shadow puppet performance platform, to record according to broadcasting speed 24 frames per second of flash acquiescence to the generation of figure for shadow-play animation, in the time of playback script file, carry out the matching operation of key frame, locate Xml data at the current frame number place obtaining.
The description of key frame matching operation: according to reading frame number record[playRecord-1] judge with present frame sequence number playRecord-1 if the same, trigger corresponding event according to multiple point touching event information, KeyEvent information and change the position of figure for shadow-play model and carry out corresponding special efficacy code.And current frame number is added to one, continue to carry out aforesaid operations.
Flash has the resolver of an Xml, so can use Xml interface to obtain external data, in Xml document tree, can use firstChild, lastChild, nextSibling, previousSibling, childNodes reads the child node in Xml object, and the node content of taking-up is shown.
S30, key frame Xml script file being carried out before non-linear splicing according to required temporal aspect are reset processing.
Concrete, the rearrangement of sequential control stage key frame refers to according to the required temporal aspect of user carries out the key frame processing before non-linear splicing to Xml script file, and the key frame processing of this process can be carried out each Xml script file respectively.Numeral figure for shadow-play interaction platform is in the time recording figure for shadow-play animation, due to Xml data recording is the data message while producing action, so human factor causes the key frame of Article 1 data not since 1, therefore can be according to the required rearrangement of key frame being carried out to certain temporal aspect of user.Specific algorithm is described: obtain the temporal aspect value of user input, calculate the difference of former key frame and current temporal aspect value, the funtcional relationship presenting according to it is to the key frame in every data in Xml script file successively assignment again.Wherein funtcional relationship is monobasic linear function relation: Y=X+A, and A represents temporal aspect value.
S40, the method positioning splicing point that uses the splice point based on reverse keyframe sequence to locate fast.
Wherein, be generally divided into two kinds of connecting methods according to the time of origin relation of the keyframe sequence of need splicings: one is that keyframe sequence excessively splices, between two sections of frame sequences, insert new key frame and generate the frame sequence of excessive character; Another kind is the splicing of keyframe sequence intersection, and two sections of frame sequences head and the tail intersect, and the coupling that each frame of cross section is carried out between frame is calculated, and carries out the quick location of splice point.
Concrete, for the scene of keyframe sequence intersection splicing, the coupling that each frame of cross section is carried out between frame is calculated, and comprises the following steps:
Obtain the length l en1 of keyframe sequence A and the length l en2 of keyframe sequence B;
In keyframe sequence A, from its key frame position, end, len1 moves to initial key frame position 1, and each position k is circulated successively;
In keyframe sequence B, calculate the similarity Sim of k key frame in 1+i key frame and keyframe sequence A, wherein, if exist similarity to meet threshold epsilon, stop circulation, otherwise until circulation end.
S50, utilization key frame calculating formula of similarity judge whether splice point mates.
Key frame information comprises two kinds, one is touch point coordinate information, a kind of is the element coordinate information of institute's touch-control, pass through event-driven during to the recording of figure for shadow-play animation due to this platform, record for touch point coordinate information, therefore in order to improve the degree of accuracy of splice point Adaptive matching, reply touch point coordinate information is carried out the calculating of key frame similarity, to determine splice point key frame.
Concrete, in step S50, utilize the range formula of two points in Euclidean space to calculate similarity, suppose x, y is two points of n-dimensional space, the Euclidean distance between them is:
In the time of n=2, Euclidean distance is exactly the distance of two points in plane, in the time representing similarity with Euclidean distance, adopts following formula to change.Wherein, distance is less, and similarity is larger,
Therefore for key frame Gi and Gj similarity (distance difference) Sim(Gi, Gj) computing formula is:
S60, threshold epsilon is set, to determine that whether this splice point is as best splice point.
Concrete, according to calculating formula of similarity to draw threshold epsilon, in the scene of describing in the present invention, touch point track acceptable splicing situation is relevant to coordinate points Pixel Information, and setting acceptable maximum pixel is 2 to calculate derivation, utilizes following formula to draw the value of threshold epsilon:
≈0.261。(4)
S70, from the angle of Xml document tree, Xml file is spliced to processing.
Concrete, in step S70, to the tree structure change operation of Xml document, comprise the following steps:
Remove all right brotgher of node at the Xml document splice point place being inserted into;
Extract all right brotgher of node at the pre-Xml document splice point place inserting, and reset key frame according to corresponding timing, two Xml documents are merged into an Xml document.
As shown in Figure 4, the present invention also provides a kind of non-linear splicing apparatus of the digital figure for shadow-play animation script file based on Xml, it is characterized in that, comprising:
Xml data acquisition module 1, for gathering Xml data, to determine effective number of frames.
Concrete, comprise the following steps:
Xml data are resolved, obtain x coordinate and the y coordinate of data in Xml file;
Gather all elements in the swf file loading, and be stored in an array, traversal each element in array, judges that touch point described in current data is whether in a certain element MovieClip, returns in current data first touch point to the frame number of element MovieClip.
Xml data location parsing module 2, for positioning parsing according to fixed number of frames to Xml data.
Wherein, on digital shadow puppet performance platform, be to record according to broadcasting speed 24 frames per second of flash acquiescence to the generation of figure for shadow-play animation, in the time of playback script file, carry out the matching operation of key frame, locate Xml data at the current frame number place obtaining.
The description of key frame matching operation: according to reading frame number record[playRecord-1] judge with present frame sequence number playRecord-1 if the same, trigger corresponding event according to multiple point touching event information, KeyEvent information and change the position of figure for shadow-play model and carry out corresponding special efficacy code.And current frame number is added to one, continue to carry out aforesaid operations.
Flash has the resolver of an Xml, so can use Xml interface to obtain external data, in Xml document tree, can use firstChild, lastChild, nextSibling, previousSibling, childNodes reads the child node in Xml object, and the node content of taking-up is shown.
Key frame is reset processing module 3, resets processing for key frame Xml script file being carried out before non-linear splicing according to required temporal aspect.
Wherein, the rearrangement of sequential control stage key frame refers to according to the required temporal aspect of user carries out the key frame processing before non-linear splicing to Xml script file, and the key frame processing of this process can be carried out each Xml script file respectively.Numeral figure for shadow-play interaction platform is in the time recording figure for shadow-play animation, due to Xml data recording is the data message while producing action, so human factor causes the key frame of Article 1 data not since 1, therefore can be according to the required rearrangement of key frame being carried out to certain temporal aspect of user.Specific algorithm is described: obtain the temporal aspect value of user input, calculate the difference of former key frame and current temporal aspect value, the funtcional relationship presenting according to it is to the key frame in every data in Xml script file successively assignment again.Wherein funtcional relationship is monobasic linear function relation: Y=X+A, and A represents temporal aspect value.
Splice point locating module 4, for using the splice point method positioning splicing point of location fast based on reverse keyframe sequence.
Wherein, be generally divided into two kinds of connecting methods according to the time of origin relation of the keyframe sequence of need splicings: one is that keyframe sequence excessively splices, between two sections of frame sequences, insert new key frame and generate the frame sequence of excessive character; Another kind is the splicing of keyframe sequence intersection, and two sections of frame sequences head and the tail intersect, and the coupling that each frame of cross section is carried out between frame is calculated, and carries out the quick location of splice point.
Concrete, for the scene of keyframe sequence intersection splicing, the coupling that each frame of cross section is carried out between frame is calculated, and comprises the following steps:
Obtain the length l en1 of keyframe sequence A and the length l en2 of keyframe sequence B;
In keyframe sequence A, from its key frame position, end, len1 moves to initial key frame position 1, and each position k is circulated successively;
In keyframe sequence B, calculate the similarity Sim of k key frame in 1+i key frame and keyframe sequence A, wherein, if exist similarity to meet threshold epsilon, stop circulation, otherwise until circulation end.
Splice point discrimination module 5, for using key frame calculating formula of similarity to judge whether splice point mates.
Wherein, utilize the range formula of two points in Euclidean space to calculate similarity:
In the time of n=2, Euclidean distance is exactly the distance of two points in plane, in the time representing similarity with Euclidean distance, adopts following formula to change.Wherein, distance is less, and similarity is larger,
Therefore for key frame Gi and Gj similarity (distance difference) Sim(Gi, Gj) computing formula is:
Threshold module 6, for threshold epsilon is set, to determine that whether this splice point is as best splice point.
Wherein, according to calculating formula of similarity to draw threshold epsilon, in the scene of describing in the present invention, touch point track acceptable splicing situation is relevant to coordinate points Pixel Information, and setting acceptable maximum pixel is 2 to calculate derivation, utilizes following formula to draw the value of threshold epsilon:
≈0.261。(4)
Splicing processing module 7, splices processing for the angle from Xml document tree to Xml file.
Wherein, to the tree structure change operation of Xml document, comprise the following steps:
Remove all right brotgher of node at the Xml document splice point place being inserted into;
Extract all right brotgher of node at the pre-Xml document splice point place inserting, and reset key frame according to corresponding timing, two Xml documents are merged into an Xml document.
Only as described above, be only preferred embodiment of the present invention, such as professional who are familiar with this art.After understanding technological means of the present invention, natural energy, according to actual needs, is changed under instruction of the present invention.Therefore all equal variation and modifications of doing according to the present patent application the scope of the claims, once should still remain within the scope of the patent.