Summary of the invention
For weak point present in the problems referred to above, the invention provides a kind of digital figure for shadow-play based on Xml
The non-linear joining method of animation script file and device, be applied to numeral figure for shadow-play animation script file
End processing sequences in, by later stage of animation script file is revised, splicing synthesis, ultimately form
Complete animation script file, then with numeral shadow puppet performance platform for rely on, show more stable, more flow
Smooth digital figure for shadow-play animation.
For achieving the above object, the present invention provides the non-of a kind of digital figure for shadow-play animation script file based on Xml
Linear mosaic method, comprises the following steps:
S10, collection Xml data, to determine effective number of frames;
S20, according to fixed number of frames Xml data are carried out location resolve;
S30, according to required temporal aspect Xml script file carried out the key frame weight before non-linear splicing
Row processes;
The method positioning splicing point that S40, utilization splice point based on reverse keyframe sequence quickly position, institute
State method that splice point based on reverse keyframe sequence quickly positions for according to keyframe sequence time of origin
The opposite sequence method that carries out positioning splicing point;
S50, utilization key frame calculating formula of similarity judge whether splice point mates;
S60, threshold epsilon is set, to determine whether this splice point is optimal splice point;
S70, from the angle of Xml document tree, Xml file is carried out splicing.
The non-linear joining method of above-mentioned based on Xml digital figure for shadow-play animation script file, wherein, in step
In rapid S10, comprise the following steps:
Xml data are resolved, obtains x coordinate and the y-coordinate of a data in Xml file;
Gather all elements in the swf file loaded, and be stored in an array;
Each element in traversal array, it is judged that whether the touch point described in current data is a certain
In element MovieClip, return in current data first touch point frame number to element MovieClip.
The non-linear joining method of above-mentioned based on Xml digital figure for shadow-play animation script file, wherein, in step
In rapid S20, the number of frames obtained in S10 is positioned, to obtain its Xml being currently located
Data, resolve all information in Xml data.
The non-linear joining method of above-mentioned based on Xml digital figure for shadow-play animation script file, wherein, described
In step S30, comprise 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 functional relationship presented according to above-mentioned difference, to the key frame in data every in Xml script file
The most again assignment.
The non-linear joining method of above-mentioned based on Xml digital figure for shadow-play animation script file, wherein, in step
In rapid S40, for the scene of keyframe sequence intersection splicing, each frame of cross section is carried out between frame
Matching primitives, comprise the following steps:
Obtain length len1 of keyframe sequence A and length len2 of keyframe sequence B;
In keyframe sequence A, from its end, key frame position len1 moves to starting keyframe position 1,
Each position k is circulated successively;
In keyframe sequence B, calculate the 1+i key frame and the kth key frame in keyframe sequence A
Similarity Sim, wherein, if there is similarity to meet threshold epsilon, then terminate circulation, otherwise until circulation knot
Bundle.
The non-linear joining method of above-mentioned based on Xml digital figure for shadow-play animation script file, wherein,
In step S50, utilize two points in Euclidean space range formula calculate similarity:
Wherein, x (x1, x2…xn), y (y1, y2…yn) it is two points of n-dimensional space,
(x y) is the Euclidean distance of all x and all y to dist;
Wherein, as n=2, Euclidean distance is exactly the distance of two points in plane, when with euclidean
When distance represents similarity, use below equation to change, determine similarity sim between x and y (x, y),
When determining that distance is more hour, it is determined that similarity is the biggest,
(x y) is the Euclidean distance between x and y to d;
Following formula is utilized to calculate the similarity Sim (G of key frame Gi Yu Gji, Gj):
Wherein, D (Gi, Gj) it is the Euclidean distance of key frame Gi Yu Gj.
The non-linear joining method of above-mentioned based on Xml digital figure for shadow-play animation script file, wherein,
In step S60, according to calculating formula of similarity to draw threshold epsilon, if touch point track can in scene
Splicing situation with acceptance is relevant to coordinate points Pixel Information, sets acceptable maximum pixel and enters as 2
Row calculates derives, then utilize following formula to draw the value of threshold epsilon:
The non-linear joining method of above-mentioned based on Xml digital figure for shadow-play animation script file, wherein, in step
In rapid S70, the tree of Xml document is changed operation, comprises the following steps:
Remove all right brotgher of node at the Xml document splice point being inserted into;
Extract all right brotgher of node at the Xml document splice point of pre-inserted, and according to corresponding sequential
Property reset key frame, two Xml documents are merged into an Xml document.
The present invention also provides for the non-linear splicing apparatus of a kind of digital figure for shadow-play animation script file based on Xml,
Including:
Xml data acquisition module, is used for gathering Xml data, to determine effective number of frames;
Xml data locking parsing module, for positioning Xml data according to fixed number of frames
Resolve;
Key frame resets processing module, for Xml script file being carried out non-thread according to required temporal aspect
Property splicing before key frame rearrangement process;
Splice point locating module, for the side using splice point based on reverse keyframe sequence quickly to position
Legal position splice point;
Splice point discrimination module, is used for using key frame calculating formula of similarity to judge whether splice point mates;
Threshold value setting module, for being set threshold epsilon, to determine whether this splice point is optimal spelling
Contact;
Splicing module, for carrying out splicing from the angle of Xml document tree to Xml file.
Compared with prior art, the invention have the advantages that
The present invention effectively achieves the non-linear splicing of numeral figure for shadow-play animation script file, the algorithm related to
Improve the operation efficiency of Data Matching, the Xml script file that can apply to be generated by recording technology
Cartoon making processed with the later stage, makes for traditional animation and provides new thinking;
The present invention is applied in the end processing sequences of numeral figure for shadow-play animation script file, by dynamic
Draw the later stage amendment of script file, splicing synthesis, ultimately form complete animation script file, then with number
Word shadow puppet performance platform, for relying on, shows more stable, more smooth digital figure for shadow-play animation.
Detailed description of the invention
As shown in Figure 1 to Figure 3, the present invention provides the non-of a kind of digital figure for shadow-play animation script file based on Xml
Linear mosaic method, comprises the following steps:
S10, collection Xml data, to determine effective number of frames.
Concrete, comprise the following steps:
Xml data are resolved, obtains x coordinate and the y-coordinate of a data in Xml file;
Gather all elements in the swf file loaded, and be stored in an array;
Each element in traversal array, it is judged that whether the touch point described in current data is a certain
In element MovieClip, return in current data first touch point frame number to element MovieClip.
S20, according to fixed number of frames Xml data are carried out location resolve.
Concrete, in step S20, on numeral shadow puppet performance platform, to the generation of figure for shadow-play animation be by
According to flash acquiescence broadcasting speed per second 24 frames record, when playback script file, carry out key frame
Matching operation, Xml data at the current frame number place obtained, location.
The description of key frame matching operation: according to reading frame number record [playRecord-1] and present frame sequence
Number playRecord-1 carries out judging, if the same, touching according to multi-touch event information, KeyEvent information
Send out event corresponding and change the position of figure for shadow-play model and the specially good effect code that execution is corresponding.And by current frame sequence
Number add one, continue executing with aforesaid operations.
Flash has the resolver of an Xml, it is possible to use Xml interface to obtain external data, at Xml
In document tree, it is possible to use firstChild, lastChild, nextSibling, previousSibling,
ChildNodes reads the child node in Xml object, is shown by the node content of taking-up.
S30, according to required temporal aspect Xml script file carried out the key frame weight before non-linear splicing
Row processes.
Concrete, the rearrangement of sequencing contro stage key frame refer to according to user needed for temporal aspect to Xml
Script file carries out the key frame before non-linear splicing and processes, and the key frame of this process processes can be distinguished
Each Xml script file is carried out.Numeral figure for shadow-play interaction platform is when recording figure for shadow-play animation, due to Xml
Data record is data message during generation action, so anthropic factor causes the key of Article 1 data
Frame, therefore can be according to the rearrangement that key frame carries out needed for user certain temporal aspect not from the beginning of 1.
Specific algorithm describes: obtain the temporal aspect value of user's input, calculates former key frame and current temporal aspect
The difference of value, depends on the key frame in data every in Xml script file according to its functional relationship presented
Secondary assignment again.Wherein functional relationship is unitary linear function relation: Y=X+A, A represent temporal aspect
Value.
The method positioning splicing point that S40, utilization splice point based on reverse keyframe sequence quickly position.
Wherein, it is generally divided into two kinds of connecting methods according to the time of origin relation of the keyframe sequence that need to splice:
One is that keyframe sequence excessively splices, and inserts new key frame and generate arteriopathy between two sections of frame sequences
The frame sequence of matter;Another kind is keyframe sequence intersection splicing, and two sections of frame sequences head and the tail intersect, to intersection
Each frame of part carries out the matching primitives between frame, carries out the quick location of splice point.
Concrete, for the scene of keyframe sequence intersection splicing, each frame of cross section is carried out frame
Between matching primitives, comprise the following steps:
Obtain length len1 of keyframe sequence A and length len2 of keyframe sequence B;
In keyframe sequence A, from its end, key frame position len1 moves to starting keyframe position 1,
Each position k is circulated successively;
In keyframe sequence B, calculate the 1+i key frame and the kth key frame in keyframe sequence A
Similarity Sim, wherein, if there is similarity to meet threshold epsilon, then terminate circulation, otherwise until circulation
Terminate.
S50, utilization key frame calculating formula of similarity judge whether splice point mates.
Key frame information includes two kinds, and one is touch point coordinate information, a kind of be institute's touch-control element sit
Mark information, due to this platform to during the recording of figure for shadow-play animation by event-driven, believe for touch point coordinate
Breath carries out recording, therefore to improve the degree of accuracy of splice point Adaptive matching, tackles touch point coordinate
Information carries out the calculating of key frame similarity, to determine splice point key frame.
Concrete, in step s 50, utilize the range formula of two points in Euclidean space to calculate similar
Degree, it is assumed that x, y are two points of n-dimensional space, and the Euclidean distance between them is:
As n=2, Euclidean distance is exactly the distance of two points in plane, when using Euclidean distance table
When showing similarity, below equation is used to change.Wherein, distance is the least, and similarity is the biggest,
Therefore for key frame Gi with Gj similarity (distance difference) Sim (Gi, Gj) computing formula it is:
S60, threshold epsilon is set, to determine whether this splice point is optimal splice point.
Concrete, according to calculating formula of similarity to draw threshold epsilon, the scene described in the present invention is touched
Control locus of points acceptable splicing situation is relevant to coordinate points Pixel Information, sets acceptable maximum
Pixel is 2 to carry out calculating and derive, then utilize following formula to draw the value of threshold epsilon:
S70, from the angle of Xml document tree, Xml file is carried out splicing.
Concrete, in step S70, the tree of Xml document is changed operation, comprises the following steps:
Remove all right brotgher of node at the Xml document splice point being inserted into;
Extract all right brotgher of node at the Xml document splice point of pre-inserted, and according to corresponding sequential
Property reset key frame, two Xml documents are merged into an Xml document.
As shown in Figure 4, the present invention also provides for the non-of a kind of digital figure for shadow-play animation script file based on Xml
Linear mosaic device, it is characterised in that including:
Xml data acquisition module 1, is used for gathering Xml data, to determine effective number of frames.
Concrete, comprise the following steps:
Xml data are resolved, obtains x coordinate and the y-coordinate of a data in Xml file;
Gather all elements in the swf file loaded, and be stored in an array, in traversal array
Each element, it is judged that the touch point described in current data whether in a certain element MovieClip,
Return in current data first touch point frame number to element MovieClip.
Xml data locking parsing module 2, for carrying out Xml data according to fixed number of frames
Location resolves.
Wherein, on numeral shadow puppet performance platform, the generation to figure for shadow-play animation is broadcasting according to flash acquiescence
Put what speed 24 frames per second were recorded, when playback script file, carry out the matching operation of key frame, location
One Xml data at the current frame number place obtained.
The description of key frame matching operation: according to reading frame number record [playRecord-1] and present frame sequence
Number playRecord-1 carries out judging, if the same, touching according to multi-touch event information, KeyEvent information
Send out event corresponding and change the position of figure for shadow-play model and the specially good effect code that execution is corresponding.And by current frame sequence
Number add one, continue executing with aforesaid operations.
Flash has the resolver of an Xml, it is possible to use Xml interface to obtain external data, at Xml
In document tree, it is possible to use firstChild, lastChild, nextSibling, previousSibling,
ChildNodes reads the child node in Xml object, is shown by the node content of taking-up.
Key frame resets processing module 3, for carrying out non-according to required temporal aspect to Xml script file
Key frame rearrangement before linear mosaic processes.
Wherein, the temporal aspect needed for the rearrangement of sequencing contro stage key frame refers to according to user is to Xml
Script file carries out the key frame before non-linear splicing and processes, and the key frame of this process processes can be distinguished
Each Xml script file is carried out.Numeral figure for shadow-play interaction platform is when recording figure for shadow-play animation, due to Xml
Data record is data message during generation action, so anthropic factor causes the key of Article 1 data
Frame, therefore can be according to the rearrangement that key frame carries out needed for user certain temporal aspect not from the beginning of 1.
Specific algorithm describes: obtain the temporal aspect value of user's input, calculates former key frame and current temporal aspect
The difference of value, depends on the key frame in data every in Xml script file according to its functional relationship presented
Secondary assignment again.Wherein functional relationship is unitary linear function relation: Y=X+A, A represent temporal aspect
Value.
Splice point locating module 4, for the side using splice point based on reverse keyframe sequence quickly to position
Legal position splice point.
Wherein, it is generally divided into two kinds of connecting methods according to the time of origin relation of the keyframe sequence that need to splice:
One is that keyframe sequence excessively splices, and inserts new key frame and generate arteriopathy between two sections of frame sequences
The frame sequence of matter;Another kind is keyframe sequence intersection splicing, and two sections of frame sequences head and the tail intersect, to intersection
Each frame of part carries out the matching primitives between frame, carries out the quick location of splice point.
Concrete, for the scene of keyframe sequence intersection splicing, each frame of cross section is carried out frame
Between matching primitives, comprise the following steps:
Obtain length len1 of keyframe sequence A and length len2 of keyframe sequence B;
In keyframe sequence A, from its end, key frame position len1 moves to starting keyframe position 1,
Each position k is circulated successively;
In keyframe sequence B, calculate the 1+i key frame and the kth key frame in keyframe sequence A
Similarity Sim, wherein, if there is similarity to meet threshold epsilon, then terminate circulation, otherwise until circulation
Terminate.
Splice point discrimination module 5, whether splice point is to be used for using key frame calculating formula of similarity to judge
Join.
Wherein, utilize two points in Euclidean space range formula calculate similarity:
As n=2, Euclidean distance is exactly the distance of two points in plane, when using Euclidean distance table
When showing similarity, below equation is used to change.Wherein, distance is the least, and similarity is the biggest,
Therefore for key frame Gi with Gj similarity (distance difference) Sim (Gi, Gj) computing formula it is:
Threshold value setting module 6, for being set threshold epsilon, to determine whether this splice point is optimal spelling
Contact.
Wherein, according to calculating formula of similarity to draw threshold epsilon, touch-control in the scene described in the present invention
Locus of points acceptable splicing situation is relevant to coordinate points Pixel Information, sets acceptable maximum picture
Element is 2 to carry out calculating and derive, then utilize following formula to draw the value of threshold epsilon:
Splicing module 7, for carrying out splicing from the angle of Xml document tree to Xml file.
Wherein, the tree of Xml document is changed operation, comprises the following steps:
Remove all right brotgher of node at the Xml document splice point being inserted into;
Extract all right brotgher of node at the Xml document splice point of pre-inserted, and according to corresponding sequential
Property reset key frame, two Xml documents are merged into an Xml document.
Only as described above, only presently preferred embodiments of the present invention, be such as familiar with the special of this skill
Industry personage.After understanding the technological means of the present invention, natural energy is according to actual needs, in the present invention
Teaching under changed.The most all equal changes made according to scope of the present invention patent and modification,
Once should still remain within the scope of the patent.