A shadow puppet control instruction spectrum self-growth programming method
By generating a set of component world transformation functions and a dynamic bounding box hierarchical forest, spatial conflicts in shadow puppetry are automatically detected and optimized, solving the problem of unexpected collisions in action sequences in existing technologies, and realizing automated and reliable generation of shadow puppet manipulation instruction spectra.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XINYANG ART VOCATIONAL COLLEGE
- Filing Date
- 2026-02-12
- Publication Date
- 2026-06-02
AI Technical Summary
In the digital choreography of shadow puppetry, existing technologies cannot automatically and accurately eliminate spatial conflicts in the sequence of movements while satisfying the complex artistic intentions. This leads to unexpected interweaving and collisions, affecting the physical rationality and visual realism of the performance.
By generating a set of component world transformation functions, a dynamic bounding box hierarchical forest is constructed, continuous collision detection is performed, a priority queue of conflict events is generated, a trajectory mathematical optimization problem is defined, and a new local trajectory function is obtained by solving the optimization problem. After fusion, the shadow puppet manipulation command spectrum is updated.
It achieves fully automated generation from high-level action intentions to conflict-free, executable instruction spectra, improving creative efficiency and the reliability of generated actions, ensuring spatial rationality and adherence to artistic intentions, and reducing reliance on human experience.
Smart Images

Figure CN122133326A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digitization of intangible cultural heritage, specifically to a method for self-growing and arranging shadow puppet manipulation instruction spectra. Background Technology
[0002] As a traditional performing art, shadow puppetry's digitization and automated choreography represent a crucial technological path for the creative transformation and innovative development of outstanding traditional Chinese culture. This invention aims to provide innovative technical solutions for the digital preservation and interpretation of cultural heritage by integrating the essence of traditional art with modern digital technology through the modern protection and inheritance of intangible cultural heritage represented by shadow puppetry.
[0003] In the specific process of digital choreography, automatically generating the character's control instruction spectrum (i.e., the sequence of timing instructions driving each joint actuator) based on the script or high-level action semantics is a crucial step. However, automatically generated action sequences often lead to unexpected interweaving and collisions between the limbs and props of different characters in three-dimensional motion space, undermining the physical plausibility and visual realism of the performance. Existing technologies typically employ two methods to address this spatial conflict problem. One approach involves introducing collision detection algorithms during the choreography stage to perform post-production checks on the generated actions. If a conflict is detected, manual adjustment of parameters or keyframes is required for correction, resulting in low automation and limited efficiency. The other approach embeds a physics engine or simple distance constraints during instruction generation. While this can prevent some penetration, it is difficult to accurately and automatically eliminate collisions while satisfying complex artistic intentions (such as specific postures or movement trajectories), and it may excessively restrict the range of motion, affecting artistic expression. In addition, while some solutions can detect conflicts, they lack a closed-loop, automatic optimization mechanism to directly feed back conflict information to the trajectory generation layer and make adjustments with minimal intervention, while ensuring that the adjusted motion still meets the original kinematic constraints and artistic requirements.
[0004] Therefore, there is an urgent need for a spatial conflict self-suppression method that can be deeply integrated into the automatic orchestration process. This method needs to be able to predict potential collisions in the action sequence in real time and accurately, and automatically transform conflict resolution into a trajectory optimization problem constrained by both artistic intent and physical laws. Through calculation, a new trajectory with minimal modification to the original action can be obtained, which can ensure smooth motion and physical feasibility. Ultimately, the instruction spectrum can achieve self-correction and spatial rationality guarantee during the "self-growth" process. Summary of the Invention
[0005] Based on the shortcomings of the prior art described above, the purpose of this invention is to provide a self-growing and arranging method for shadow puppet manipulation instruction spectrum to solve the above-mentioned technical problems.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a method for self-growing and arranging shadow puppet manipulation command spectra, comprising: S1: Based on the geometric model of the shadow puppet parts, the binding relationship between the parts and the driving joints, and the preset trajectory functions of the joints, generate a set of part world transformation functions in the world coordinate system for all parts; S2: Construct a dynamic bounding box hierarchical forest based on the component world transformation function set; S3: Within a preset time window, continuous collision detection is performed using a dynamic bounding box hierarchical forest to generate a priority queue of conflict events. S4: Based on the first conflict event in the priority queue of conflict events, construct the definition of the trajectory mathematical optimization problem for eliminating spatial conflicts; S5: By solving the definition of the trajectory mathematical optimization problem, we obtain the new local trajectory function of the driving joint corresponding to the conflict; S6: The new local trajectory function is fused with the original global trajectory. After the collision re-detection verification is passed, the shadow puppet manipulation command spectrum is updated with the fused trajectory.
[0007] The present invention is further configured such that S1 includes: Acquire triangular mesh data of shadow puppet components, rigid binding relationship data between components and drive joints, parameterized joint preset trajectory functions, and joint topology data; Based on joint topology data and parameterized joint preset trajectory functions, the global transformation matrix function of each joint in the world coordinate system is obtained through forward kinematics calculation. For each component, based on the rigid binding relationship data, the joint global transformation matrix function of its driving joint is combined with the corresponding static binding transformation matrix to generate the component world transformation function that changes continuously with time in the world coordinate system. The component world transformation function set is composed of the component world transformation functions of all components.
[0008] The present invention is further configured such that the static binding transformation matrix represents the fixed pose transformation relationship from the local coordinate system of the driving joint to the local geometric coordinate system of the bound component.
[0009] The present invention is further configured such that S2 includes: For each component, based on the triangular mesh data of that component, principal component analysis is used to calculate and generate the component orientation bounding box located in the local coordinate system of that component. The component orientation bounding box is defined by the center coordinates, axial vector and half-length parameter. At any given moment, based on the pose transformation matrix of the component in the world coordinate system provided by the component world transformation function set, the center coordinates and axial vectors of the component orientation bounding box are spatially transformed to obtain the world orientation bounding box of the component at the current moment. Based on the joint hierarchy topology within a character, the world bounding boxes of all parts belonging to the same character are recursively merged from bottom to top. The world bounding box of each parent node is generated by aggregating the vertex set of the world bounding boxes of all its child nodes and recalculating, thereby constructing a complete bounding box hierarchy for each character. A dynamic bounding box hierarchy forest is generated based on the bounding box hierarchy of all roles.
[0010] The present invention is further configured such that S3 includes: Within a preset time window, a discrete time point sequence is generated based on a preset discrete sampling time interval; For each time point in the discrete time point sequence, perform traversal and bounding box intersection tests on the dynamic bounding box hierarchical forest to obtain all component pairs where bounding boxes intersect at that time point; Merge the bounding box intersection test results from all time points and perform deduplication to form a set of potential collision component pairs; For each pair of components in the set of potential collision components, perform continuous collision detection calculations based on the component world transformation functions corresponding to both components. The continuous collision detection algorithm iteratively advances the detection time and calculates the separation distance between the two components at each time point to determine the collision time when the component pair first penetrates within a preset time window. When the separation distance is less than or equal to the preset contact tolerance, penetration is determined and that moment is identified as the collision time. At the collision time, the spatial coordinates of the contact point between the penetrating component pair and the penetration vector are calculated, the penetration vector being used to characterize the penetration direction and penetration depth; All penetration events are sorted according to their collision time, generating a priority queue of conflict events arranged in ascending order of time.
[0011] The present invention is further configured such that S4 includes: Extract the first conflict event from the conflict event priority queue, and obtain the original global trajectory parameters and joint kinematic constraints of the driving joint corresponding to the first component in the component pair of the conflict event. The trajectory of the joint within the optimization time window, which is defined by the collision time, is parameterized using a set of control points, and the adjustment amount of the control points is defined as the decision variable of the optimization problem. Based on the spatial coordinates of the contact point and the penetration vector, an anti-penetration constraint is constructed. This anti-penetration constraint requires that the displacement of the contact point in the opposite direction of penetration at the time of collision be greater than or equal to the penetration depth. Based on joint kinematic constraints, position and velocity constraints of the joint are constructed within the optimization time window. Construct an objective function with the goal of minimizing the norm of the decision variables and minimizing the second derivative of the trajectory. Based on decision variables, anti-penetration geometric constraints, position and velocity constraints, and objective function, a mathematical optimization problem for trajectory is defined.
[0012] The present invention is further configured such that the optimized time window extends symmetrically to both sides of the collision time for a preset duration.
[0013] The present invention is further configured such that S5 includes: A numerical optimization solver is used to iteratively solve the trajectory mathematical optimization problem to obtain the optimal decision variables that satisfy all constraints and minimize the objective function. The control points in the original global trajectory parameters are adjusted using the optimal decision variables to obtain the adjusted set of control points; Based on the adjusted set of control points and trajectory parameterization method, a new local trajectory function of the driving joint within the optimization time window is reconstructed.
[0014] The present invention is further configured such that S6 includes: The new local trajectory function is smoothly fused with the original global trajectory at the boundary of the optimization time window to generate the fused trajectory; The kinematic state of the driving joint and related components is updated based on the fused trajectory, and the component pairs involved in the first collision event in the collision event priority queue are re-detected for continuous collision. If the retest confirms that the separation distance between the components is always greater than the preset safety threshold within the verification time interval, then the trajectory data of the corresponding joint in the shadow puppet manipulation command spectrum is updated with the fused trajectory. If the re-detection fails, the original global trajectory is retained, and the conflict event is marked as needing to be reprocessed.
[0015] The present invention is further configured such that the conflict event priority queue is implemented using a minimum priority queue data structure.
[0016] This invention provides a self-growing and arrangement method for shadow puppet manipulation command spectra. The method comprises: S1: Generating a set of world transformation functions for all parts in the world coordinate system based on the geometric model of shadow puppet components, the binding relationship between components and driving joints, and preset trajectory functions of the joints; S2: Constructing a dynamic bounding box hierarchical forest based on the set of component world transformation functions; S3: Performing continuous collision detection using the dynamic bounding box hierarchical forest within a preset time window to generate a priority queue of conflict events; S4: Constructing a trajectory mathematical optimization problem definition for eliminating spatial conflicts based on the first conflict event in the priority queue; S5: Obtaining a new local trajectory function for the driving joint corresponding to the conflict by solving the trajectory mathematical optimization problem definition; S6: Merging the new local trajectory function with the original global trajectory, and updating the shadow puppet manipulation command spectra with the merged trajectory after successful conflict re-detection verification. The beneficial effects include: 1. By systematically integrating geometric modeling, spatial conflict detection, automated trajectory optimization, and closed-loop verification, the method achieves fully automated generation and iterative optimization from high-level action intentions to conflict-free, executable instruction spectra. This method reduces the reliance on human experience in traditional shadow puppet digital choreography, endows the choreography process with self-growth capabilities, and enables it to automatically discover and resolve spatial conflicts in action sequences while strictly adhering to physical constraints and artistic intentions, thereby substantially improving creative efficiency and the reliability of generated actions. 2. By pre-compiling local orientation bounding boxes for each component and transforming them to the world coordinate system in real time during runtime, and then recursively aggregating them according to the role topology to form a hierarchical bounding box forest, an efficient spatial index structure is constructed. This structure can quickly eliminate a large number of obviously disjoint component pairs in the wide phase stage of collision detection, and concentrate computing resources on potential collision areas, thereby reducing the time complexity of the detection algorithm from the quadratic level of the number of components to the near-linear level, providing key performance guarantees for real-time or near-real-time collision detection. 3. By smoothly integrating the local optimized trajectory with the global trajectory and performing re-detection and verification on the original conflict area, a "generation-verification" closed-loop quality control mechanism was constructed. This mechanism ensures that the solution will only be adopted when it has been verified and the conflict has been completely eliminated while a safety gap is retained. This effectively avoids the secondary interference problem that may be caused by local optimization and ensures the deterministic reliability of the final output shadow puppet manipulation command spectrum in the spatial dimension, thereby realizing the controllability and robustness of the self-growth process.
[0017] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings: Figure 1 The flowchart illustrates a self-growing arrangement method for shadow puppet manipulation command spectrum, which is an exemplary embodiment of the present invention. Detailed Implementation
[0019] The embodiments of the present invention will be described below with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention and not for limiting the scope of protection of the present invention.
[0020] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0021] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.
[0022] A method for self-growing and arranging shadow puppet manipulation command spectra, such as Figure 1 As shown, it includes: S1: Based on the geometric model of the shadow puppet parts, the binding relationship between the parts and the driving joints, and the preset trajectory functions of the joints, generate a set of part world transformation functions in the world coordinate system for all parts; S2: Construct a dynamic bounding box hierarchical forest based on the component world transformation function set; S3: Within a preset time window, continuous collision detection is performed using a dynamic bounding box hierarchical forest to generate a priority queue of conflict events. S4: Based on the first conflict event in the priority queue of conflict events, construct the definition of the trajectory mathematical optimization problem for eliminating spatial conflicts; S5: By solving the definition of the trajectory mathematical optimization problem, we obtain the new local trajectory function of the driving joint corresponding to the conflict; S6: The new local trajectory function is fused with the original global trajectory. After the collision re-detection verification is passed, the shadow puppet manipulation command spectrum is updated with the fused trajectory.
[0023] The present invention is further configured such that S1 includes: Acquire triangular mesh data of shadow puppet components, rigid binding relationship data between components and drive joints, parameterized joint preset trajectory functions, and joint topology data; Based on joint topology data and parameterized joint preset trajectory functions, the global transformation matrix function of each joint in the world coordinate system is obtained through forward kinematics calculation. For each component, based on the rigid binding relationship data, the joint global transformation matrix function of its driving joint is combined with the corresponding static binding transformation matrix to generate the component world transformation function that changes continuously over time in the world coordinate system; the present invention is further configured such that the static binding transformation matrix represents the fixed pose transformation relationship from the local coordinate system of the driving joint to the local geometric coordinate system of the bound component. The component world transformation function set is composed of the component world transformation functions of all components; specifically, geometric and kinematic state calculations are performed based on the complete digital definition of the shadow puppet character. This digital definition includes four parts of data: the triangular mesh data of the shadow puppet components, where the geometry of each independently movable component is described by a triangular mesh, which includes a vertex coordinate list and a triangular facet index list. Each element of the vertex coordinate list is a three-dimensional coordinate, defining the spatial position of the component in its local geometric coordinate system. Each element of the triangular facet index list consists of three vertex indices, defining how these vertices are connected to form the triangular mesh on the component's surface; and the rigid binding relationship between the component and the driving joint. The data is a mapping table that records the unique drive joint identifier of each triangular mesh component and defines a static binding transformation matrix for each binding relationship. This matrix is a 4x4 homogeneous transformation matrix that describes the fixed pose relationship between the component's local geometric coordinate system and its drive joint's local coordinate system. The parameterized joint preset trajectory function is a continuous mathematical function with time as the independent variable, generated by the upstream motion choreography process according to high-level semantic instructions. This set of parameterized joint preset trajectory functions defines the motion law of each drive joint within a specified choreography time window: for rotary joints, the function output is the rotation angle about its preset motion axis; for translational joints, the function output is the motion along its preset motion axis. The linear displacement; this set of functions constitutes the reference motion input for subsequent kinematic calculations and spatial conflict detection; the joint topology data defines the hierarchical relationship of the character skeleton in a tree structure, recording the parent joint reference of each joint and its local coordinate transformation matrix relative to the parent joint in the initial pose; based on the joint topology data and the parameterized joint preset trajectory function, the continuous pose of each joint in the world coordinate system is calculated through forward kinematics; the calculation process recursively traverses the joint tree starting from the root joint of the skeleton. For any non-root joint, its world coordinate system pose is determined by the world transformation matrix of the parent joint at the same moment, the initial static local transformation matrix of the joint relative to the parent joint, and the motion determined by the trajectory function of the joint itself at the current moment. The transformation matrix combination is determined as follows: First, the world transformation matrix of the parent joint at the current moment is obtained, multiplied by the initial static local transformation matrix of the joint, and then superimposed with the motion transformation matrix calculated from the joint motion parameters at the current moment, thus obtaining the world transformation matrix of the joint at the current moment; this process is applied to all time points, that is, for each joint, a joint global transformation matrix function is derived with time as input and a four-by-four homogeneous transformation matrix as output. This joint global transformation matrix function characterizes the change of the joint's position and orientation in world space over time; for each shadow puppet component, its corresponding driving joint is found based on the rigid binding relationship data between the component and the driving joint, and the joint global transformation matrix function of the driving joint is obtained;The world coordinate system transformation of a component is achieved through two consecutive coordinate transformations: First, a static binding transformation matrix is applied to transform the component from its local geometric coordinate system to the local coordinate system of the driving joint. Then, at any given moment, the global transformation matrix function of the driving joint at that moment is applied to transform the component from the joint's local coordinate system to the world coordinate system. The result of the consecutive multiplication of the two transformation matrices is the component's world transformation function. This function takes time as its independent variable and a four-by-four homogeneous transformation matrix as its output value. This component world transformation function determines the trajectory of each vertex of the component in the world coordinate system. Finally, the component world transformation functions of all components are summarized to form a set of component world transformation functions.
[0024] The present invention is further configured such that S2 includes: For each component, based on the triangular mesh data of that component, principal component analysis is used to calculate and generate the component orientation bounding box located in the local coordinate system of that component. The component orientation bounding box is defined by the center coordinates, axial vector and half-length parameter. At any given moment, based on the pose transformation matrix of the component in the world coordinate system provided by the component world transformation function set, the center coordinates and axial vectors of the component orientation bounding box are spatially transformed to obtain the world orientation bounding box of the component at the current moment. Based on the joint hierarchy topology within a character, the world bounding boxes of all parts belonging to the same character are recursively merged from bottom to top. The world bounding box of each parent node is generated by aggregating the vertex set of the world bounding boxes of all its child nodes and recalculating, thereby constructing a complete bounding box hierarchy for each character. Based on the bounding box hierarchy of all characters, a dynamic bounding box hierarchy forest is generated. Specifically, for the triangular mesh data of each shadow puppet component, its vertex coordinate list is processed. By calculating the covariance matrix of the vertex coordinates and performing eigenvalue decomposition, three eigenvectors are obtained. These three eigenvectors are defined as the three mutually orthogonal axis vectors of the bounding box. The axis vectors represent the main distribution direction of the component's geometry in space and serve as the local coordinate system axes of the bounding box. Subsequently, all vertex coordinates are projected onto the coordinate directions defined by these three axis vectors, and the maximum and minimum coordinate values on each axis are determined. Based on these extreme values, the center point coordinates of the bounding box and the coordinates from the center point to each vertex are calculated. The distance of the axial limit surface, i.e., the half-length parameter, yields an axis-aligned cube description that tightly encloses all vertices of the component. This is the component's orientation bounding box in its own local coordinate system. This bounding box is fully defined by its center coordinates, three axial vectors, and three half-length parameters, and is stored as the component's static geometric properties. At any given moment, the homogeneous transformation matrix representing the component's rotation and translation from the local coordinate system to the world coordinate system is obtained according to the component's world transformation function at that moment. This matrix is used to transform the center coordinates of the component's orientation bounding box, and its center coordinates in the world coordinate system are obtained through matrix multiplication. Simultaneously, the rotation submatrix in this matrix is extracted to rotate the three local axial vectors of the bounding box. The transformation yields a new axial vector in the world coordinate system, ensuring the correct orientation of the bounding box in space. The three half-length parameters of the bounding box are treated as scalars during this coordinate transformation, maintaining their original dimensions. Through the above transformation of the center coordinates and axial vectors, the world orientation bounding box of the component at that moment is obtained. This world orientation bounding box is defined by the transformed center coordinates, the new axial vector, and the original half-length parameters. Based on the parent-child hierarchy defined by the joint topology data, a bottom-up recursive strategy is used to construct a bounding box hierarchy for each component. The world orientation bounding box of each component in the world coordinate system is initialized as a leaf node in this hierarchy. Starting from the bottom-most leaf node, the bounding box hierarchy is constructed... All child nodes belonging to the same parent joint are merged. These child nodes include leaf nodes representing the part geometry and intermediate nodes that have already been merged. During the merging operation, all eight corner vertices of the world orientation bounding boxes of all child nodes to be merged are collected to form an aggregated vertex set. The same principal component analysis method as the part orientation bounding box is applied to this aggregated vertex set to calculate new axial vectors and determine the extreme values of the coordinates on each axis, thereby generating a new bounding box that can tightly enclose all child bounding boxes. This new bounding box serves as the world orientation bounding box of the parent node. This recursive merging process continues until the root joint node of the character is reached, ultimately forming a complete bounding box hierarchy that represents the overall character and the spatial extent of its parts.Finally, the bounding box hierarchy of all roles is integrated to form a dynamic bounding box hierarchy forest. This dynamic bounding box hierarchy forest can be dynamically updated. When the world pose of a part is updated over time, the world orientation bounding box is recalculated starting from the affected leaf node, and the bounding boxes of its ancestor nodes are recursively updated from bottom to top, realizing incremental updates and providing spatial indexes for subsequent wide-phase collision detection.
[0025] The present invention is further configured such that S3 includes: Within a preset time window, a discrete time point sequence is generated based on a preset discrete sampling time interval; For each time point in the discrete time point sequence, perform traversal and bounding box intersection tests on the dynamic bounding box hierarchical forest to obtain all component pairs where bounding boxes intersect at that time point; Merge the bounding box intersection test results from all time points and perform deduplication to form a set of potential collision component pairs; For each pair of components in the set of potential collision components, perform continuous collision detection calculations based on the component world transformation functions corresponding to both components. The continuous collision detection algorithm iteratively advances the detection time and calculates the separation distance between the two components at each time point to determine the collision time when the component pair first penetrates within a preset time window. When the separation distance is less than or equal to the preset contact tolerance, penetration is determined and that moment is identified as the collision time. At the collision time, the spatial coordinates of the contact point between the penetrating component pair and the penetration vector are calculated, the penetration vector being used to characterize the penetration direction and penetration depth; All penetration events are sorted according to their collision time, generating a priority queue of conflict events arranged in ascending order of time. Specifically, within a preset time window, a discrete time point sequence is generated based on a preset discrete sampling time interval. For each time point in this discrete time point sequence, traversal and intersection tests are performed on the dynamic bounding box hierarchy forest. The traversal process uses a recursive strategy to visit each bounding box hierarchy in the forest. For any two different bounding box hierarchies, the intersection relationship of their world-direction bounding boxes is tested starting from their root node. If the world-direction bounding boxes of the root node do not intersect, it is determined that the two corresponding roles have no component-level collision at that moment, and the subsequent detection of the bounding box hierarchy is terminated. If the root node... If the world-direction bounding boxes intersect, the recursive testing of the world-direction bounding boxes of their child nodes continues until leaf nodes are reached. All component pairs whose bounding boxes intersect at the leaf node level are recorded as potential collision pairs at that moment. After traversing all time points, the component pairs recorded at each time point are aggregated and deduplicated, forming a set of potential collision component pairs that may collide within a preset time window. For each component pair in the potential collision component pair set, continuous collision detection is performed. This detection is based on the continuous motion described by the component world transformation functions corresponding to both components. The detection process starts from the beginning of the preset time window and iteratively advances the detection time to search for the exact time point of the first geometric penetration. In each iteration... At the current detection moment, the minimum distance between the triangular mesh surfaces of the two components at that moment is calculated using the Gilbert-Johnson-Creer algorithm and taken as the separation distance. If this separation distance is greater than a preset contact tolerance, a conservative time step is estimated based on the motion state between the two components at that moment to advance the detection. The specific estimation method is as follows: the instantaneous relative linear velocity of the closest point pair on the two components at the current position is calculated based on the component world transformation function. By comparing the relative linear velocities of all point pairs, a maximum relative linear velocity is determined. Then, this maximum relative linear velocity is used as the upper bound of the velocity. The current geometric separation distance is divided by this upper bound of the velocity to obtain the time required for the two components to move from the current distance to contact under this velocity upper bound assumption. A conservative time step estimate is used as the advance step size for this iteration, and the detection time is then advanced by this step size. If the separation distance is less than or equal to the preset contact tolerance, it is determined that the two components have made contact or penetrated at this moment, and this moment is recorded as the collision time of the component for the first penetration. After determining the collision time, the extended polyhedron algorithm is further used to iteratively expand the final simplex structure output by the Gilbert-Johnson-Creer algorithm when determining penetration. This expansion process gradually extends the geometry of the simplex outward until it closely fits the contour surface of the two components that interfere at the moment of collision, thereby calculating the spatial coordinates of the contact point, the penetration depth, and the penetration direction.The penetration direction is defined as the direction from the contact point of the first component to the interior of the second component. Finally, the information of each detected penetrating component pair, including its component pair identifier, collision time, contact point coordinates, and penetration vector, is encapsulated into a collision event. These events are then inserted into a min-heap priority queue in ascending order of their collision times, thus generating a priority queue of collision events arranged in ascending time.
[0026] The present invention is further configured such that S4 includes: Extract the first conflict event from the conflict event priority queue, and obtain the original global trajectory parameters and joint kinematic constraints of the driving joint corresponding to the first component in the component pair of the conflict event. The trajectory of the joint within an optimization time window determined by the collision time is parameterized using a set of control points, and the adjustment amount of the control points is defined as the decision variable of the optimization problem; the present invention is further configured such that the optimization time window extends symmetrically to the front and back sides of the collision time as a time interval of a preset duration. Based on the spatial coordinates of the contact point and the penetration vector, an anti-penetration constraint is constructed. This anti-penetration constraint requires that the displacement of the contact point in the opposite direction of penetration at the time of collision be greater than or equal to the penetration depth. Based on joint kinematic constraints, position and velocity constraints of the joint are constructed within the optimization time window. Construct an objective function with the goal of minimizing the norm of the decision variables and minimizing the second derivative of the trajectory. Based on decision variables, anti-penetration geometric constraints, position and velocity constraints, and the objective function, a trajectory mathematical optimization problem is defined. Specifically, the first conflict event in the priority queue is extracted, identifying the component pair with the earliest collision time. Based on the binding relationship between the component pair identifier and the driving joint recorded in this conflict event, the driving joint corresponding to the first component that caused the penetration is determined. The predefined trajectory parameterized representation of this joint in the original choreography is obtained. This representation mathematically and parametrically defines the joint's motion path over time, typically expressed as a set of control points and node vectors required to define the curve, or a set of polynomial coefficients. Simultaneously, the mechanical properties or safe operation parameters of the joint are also obtained. The predefined physical kinematic constraints include position constraints (minimum and maximum angle or displacement limits corresponding to the joint's range of motion) and velocity constraints (maximum angular or linear velocity limits corresponding to the joint's maximum speed). A continuous time interval is formed by extending symmetrically forward and backward from the collision time point as a preset duration, serving as an optimization time window. The motion trajectory of the driven joint within the optimization time window is re-parameterized using a parameterized mathematical expression of the same type as the original global trajectory. This parameterized mathematical expression uses B-spline curve control points uniformly or non-uniformly distributed along the time axis to define the trajectory shape. This parameterization method ensures the continuity and differentiability of the trajectory in the time dimension and adjusts a finite number of control points. Control points modify the shape of the entire trajectory. The number and time distribution of control points are pre-set based on the length of the optimization time window and the required flexibility of trajectory adjustment. The adjustment amount of each control point relative to its spatial coordinates or joint angle value in the original global trajectory is defined as the decision variable of the optimization problem. For translational joints in three-dimensional space, the adjustment amount is a three-dimensional displacement vector; for rotational joints, the adjustment amount is an angle change. The adjustment amounts of all control points are arranged in sequence to form a decision variable vector. Based on the three-dimensional spatial coordinates of the contact point in the world coordinate system and the direction and depth of the penetration vector provided by the collision event, an anti-penetration geometric constraint is constructed. This constraint requires that after the above trajectory adjustment, at the moment of collision, the contact point moves in the opposite direction of penetration. The resulting displacement must be greater than or equal to the penetration depth. This constraint is mathematically expressed as an inequality about the decision variable vector. Based on the obtained joint kinematic constraints, a series of discrete time sampling points are selected at preset time intervals within the optimization time window. At each sampling point, two independent inequality constraints are constructed: the first constraint requires that the position value of the parameterized new trajectory at that moment be between the minimum and maximum allowable position values of the joint; the second constraint requires that the absolute value of the first derivative of the new trajectory at that moment, i.e., the instantaneous velocity value, is less than or equal to the allowable velocity limit of the joint. These constraints constructed at discrete time points together ensure that the optimized new trajectory satisfies the physical range of motion and velocity limit of the joint throughout the entire time window.The objective function for the optimization problem is constructed, consisting of a weighted sum of two parts. The first part is a trajectory adjustment penalty term, achieved by minimizing the Euclidean norm of the decision variable vector. Its purpose is to penalize the total adjustment magnitude of the control points relative to their original positions, driving the optimized trajectory to closely approximate the original artistic choreography. The second part is a motion smoothing penalty term, achieved by minimizing the norm of the second-order difference vector calculated from the trajectory control point sequence. This term serves as a smoothing regularization term, used to suppress changes in trajectory acceleration, thus promoting smooth and natural motion. The trajectory adjustment penalty term and the motion smoothing penalty term are balanced and integrated using preset weighting coefficients. Finally, the objective function, composed of the decision variable vector, anti-penetration geometric constraints, position and velocity constraints sampled at discrete time points, and the aforementioned weighted sum, is integrated to form the definition of the trajectory mathematical optimization problem.
[0027] The present invention is further configured such that S5 includes: A numerical optimization solver is used to iteratively solve the trajectory mathematical optimization problem to obtain the optimal decision variables that satisfy all constraints and minimize the objective function. The control points in the original global trajectory parameters are adjusted using the optimal decision variables to obtain the adjusted set of control points; Based on the adjusted control point set and trajectory parameterization method, a new local trajectory function of the driving joint within the optimization time window is reconstructed. Specifically, the problem type is determined based on the mathematical form of the objective function and constraints in the definition of trajectory mathematical optimization problems. When the objective function is a quadratic function of the decision variables and all constraints are linear functions of the decision variables, the problem is classified as a quadratic programming problem, and a numerical optimization solver suitable for quadratic programming is selected. When the objective function or any constraint is a nonlinear function of the decision variables, the problem is classified as a nonlinear programming problem, and a numerical optimization solver suitable for nonlinear programming is selected. The solver can employ the interior-point method or a sequential quadratic programming algorithm. The process involves inputting the complete mathematical definition of the trajectory optimization problem into a selected numerical optimization solver to initiate an iterative solution process. The problem definition includes a vector of decision variables, a weighted objective function consisting of a trajectory adjustment penalty term and a motion smoothing penalty term, anti-penetration geometric constraints, and position and velocity constraints sampled at discrete time points. The solver begins iterative computation with an initial guess solution, set as a vector with all elements equal to zero, corresponding to an initial state where all control points are not adjusted. In each iteration, the solver evaluates the specific value of the objective function and the degree to which all constraints are satisfied based on the current values of the decision variables, and calculates the gradient vector of the objective function with respect to the decision variables and the gradient vector of each constraint with respect to the constraints. The Jacobian matrix of the decision variables is obtained; subsequently, based on the aforementioned gradient vector and Jacobian matrix, the solver constructs a locally approximate quadratic programming subproblem and solves it, thereby determining a search direction and computational step size that decreases the objective function value and simultaneously moves the solution into the feasible region, thus completing the update of the decision variable vector; this iterative computation process continues until a preset convergence termination condition is met, the convergence condition including that the improvement of the objective function value in two consecutive iterations is less than a preset function convergence threshold, and the maximum value of the violation of all constraints is less than a preset constraint convergence tolerance; when the convergence condition is met, the solver outputs the final optimal decision variable vector; if the number of iterations reaches a preset maximum... If the upper limit of the number of iterations still does not meet the convergence condition, or if the solver determines that the original optimization problem is infeasible based on the first-order and second-order information of the problem during the calculation process, a status signal of solution failure will be output. After obtaining the optimal decision variable vector that has successfully converged, the control point set update operation is performed. This operation is defined as adding the optimal decision variable vector to the original control point set corresponding to the optimization time window in the original global trajectory element by element to obtain a new set of adjusted control point coordinates, i.e., the adjusted control point set. Subsequently, according to the trajectory parameterization mathematical expression adopted in step S4, the new local trajectory function of the driving joint within the optimization time window is reconstructed using the adjusted control point set.The specific reconstruction logic varies depending on the parametric mathematical expression: If the original global trajectory is represented by a B-spline curve, then new control point coordinates are used, combined with the original node vectors and basis function orders of the B-spline curve, to calculate the motion parameter values of the joint at any time within the optimization time window using the standard evaluation formula for B-spline curves; if the original global trajectory uses other parametric representations, then based on its corresponding mathematical definition and a new parameter set composed of a new set of control points, a complete trajectory function expression is reconstructed; the new local trajectory function generated through the above process, defined within the optimization time window, satisfies all anti-penetration geometric constraints and joint kinematic constraints, and makes the objective function reach the minimum value obtained by the numerical optimization solver.
[0028] The present invention is further configured such that S6 includes: The new local trajectory function is smoothly fused with the original global trajectory at the boundary of the optimization time window to generate the fused trajectory; The kinematic state of the driving joint and related components is updated based on the fused trajectory, and the component pairs involved in the first collision event in the collision event priority queue are re-detected for continuous collision. If the retest confirms that the separation distance between the components is always greater than the preset safety threshold within the verification time interval, then the trajectory data of the corresponding joint in the shadow puppet manipulation command spectrum is updated with the fused trajectory. If the re-detection fails, the original global trajectory is retained, and the conflict event is marked as requiring reprocessing. Specifically, to ensure the continuity of the motion trajectory in the time dimension, the new local trajectory function defined within the optimization time window and the original global trajectory defined on the complete orchestration time axis need to be smoothly merged at the window boundary. The specific process is as follows: a preset transition time interval is defined before the start time and after the end time of the optimization time window. Within this transition interval, a mixing function that continuously changes from zero to one and whose first and second derivatives are both continuous is introduced to perform weighted fusion of the new local trajectory function and the original global trajectory. At the initial boundary of the transition interval, the weight of the mixing function is set to 1, that is, the original trajectory is completely adopted. The initial global trajectory is generated; as time progresses into the optimization time window, the weight smoothly decreases to 0, thus fully transitioning to the new local trajectory function; at the end boundary of the optimization time window, the reverse weight transition process is performed, i.e., the weight smoothly increases from 0 to 1 to connect back to the original global trajectory; by constructing a hybrid function with continuous first and second derivatives, such as a fifth-order polynomial function, it can be ensured that the final fused trajectory remains continuous in the three kinematic dimensions of position, velocity, and acceleration, thereby effectively eliminating possible step jumps or abrupt changes at the trajectory splicing points; after generating the fused trajectory, the kinematic state of the driving joints and related components needs to be updated based on the trajectory for conflict resolution verification, the specific process being: based on the fused trajectory... The motion parameters of the driving joint and all its downstream sub-joints in the entire kinematic chain are recalculated within the affected time interval, i.e., the complete forward kinematic chain calculation starting from that joint is re-executed. The affected time interval consists of three parts: an optimization time window for directly applying the new motion trajectory function, a pre-trajectory transition time interval before the start time of the window, and a post-trajectory transition time interval after the end time. Subsequently, based on the updated joint motion state and combined with the predefined rigid binding relationship between the component and the joint, the continuous poses of the two components involved in the first conflict event in the world coordinate system are recalculated, thereby accurately obtaining the updated component world transformation of these two components within the verification time interval. The function; the verification time interval is a time range set to ensure the sufficiency of verification, usually equal to or slightly larger than the affected time interval; then, a re-collision detection is performed to verify whether the conflict has been resolved. The verification time interval is defined as a continuous period covering the optimization time window and the transition time intervals before and after it, to ensure coverage of the entire period affected by the trajectory adjustment; within this verification time interval, the same continuous collision detection algorithm as in step S3 is re-executed for the component pair recorded for the first conflict event; this algorithm will calculate the separation distance between the two components at any time within this verification time interval; the standard for passing the verification is that all calculated separation distance values are greater than a preset safety threshold throughout the entire verification time interval;The safety threshold is used to ensure, at the geometric level, that not only is penetration interference eliminated between components, but also a small safety gap is maintained, thereby enhancing the reliability and stability of the solution in actual physical execution. If re-detection confirms that the separation distance between the aforementioned components at all times within the verification time interval is greater than the preset safety threshold, then the optimization is considered successful and the original conflict has been eliminated. At this time, the trajectory data of the corresponding drive joint in the shadow puppet manipulation command spectrum within the affected time interval is replaced with the fused trajectory to complete the atomic update of the command spectrum, and the information that the conflict was successfully resolved is recorded in the system log. If re-detection finds that the separation distance is less than or equal to the preset safety threshold at any time, then the local optimization is considered to have failed to effectively eliminate penetration or maintain a safety gap. At this time, the optimization result is abandoned, the original global trajectory data is retained unchanged, the conflict event in the conflict event priority queue is marked as needing to be reprocessed, and the specific reason for failure is recorded so that subsequent processes can try to adjust the optimization parameters or adopt other solutions.
[0029] The present invention is further configured such that the conflict event priority queue is implemented using a minimum priority queue data structure; specifically, the conflict event priority queue is implemented using a minimum priority queue data structure, specifically constructed based on a min-heap, with each conflict event stored as an element in the queue, and its collision time used as the comparison key; when performing an insertion operation, the newly generated conflict event is inserted into the heap according to its collision time, and the heap order property is maintained through a floating operation, that is, ensuring that the collision time of any node in the heap is less than or equal to the collision time of its child nodes, so that the top element of the heap always remains the conflict event with the earliest collision time; when the next conflict needs to be processed, a pop operation is performed, the top element of the heap is retrieved and removed, and then the heap structure is readjusted through a sink operation to maintain its heap order property.
[0030] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for self-growing and arranging a shadow puppet manipulation command spectrum, characterized in that, include: S1: Based on the geometric model of the shadow puppet parts, the binding relationship between the parts and the driving joints, and the preset trajectory functions of the joints, generate a set of part world transformation functions in the world coordinate system for all parts; S2: Construct a dynamic bounding box hierarchical forest based on the component world transformation function set; S3: Within a preset time window, continuous collision detection is performed using a dynamic bounding box hierarchical forest to generate a priority queue of conflict events. S4: Based on the first conflict event in the priority queue of conflict events, construct the definition of the trajectory mathematical optimization problem for eliminating spatial conflicts; S5: By solving the definition of the trajectory mathematical optimization problem, we obtain the new local trajectory function of the driving joint corresponding to the conflict; S6: The new local trajectory function is fused with the original global trajectory. After the collision re-detection verification is passed, the shadow puppet manipulation command spectrum is updated with the fused trajectory.
2. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 1, characterized in that, S1 includes: Acquire triangular mesh data of shadow puppet components, rigid binding relationship data between components and drive joints, parameterized joint preset trajectory functions, and joint topology data; Based on joint topology data and parameterized joint preset trajectory functions, the global transformation matrix function of each joint in the world coordinate system is obtained through forward kinematics calculation. For each component, based on the rigid binding relationship data, the joint global transformation matrix function of its driving joint is combined with the corresponding static binding transformation matrix to generate the component world transformation function that changes continuously with time in the world coordinate system. The component world transformation function set is composed of the component world transformation functions of all components.
3. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 2, characterized in that, The static binding transformation matrix represents the fixed pose transformation relationship from the local coordinate system of the driving joint to the local geometric coordinate system of the bound component.
4. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 1, characterized in that, S2 includes: For each component, based on the triangular mesh data of that component, principal component analysis is used to calculate and generate the component orientation bounding box located in the local coordinate system of that component. The component orientation bounding box is defined by the center coordinates, axial vector and half-length parameter. At any given moment, based on the pose transformation matrix of the component in the world coordinate system provided by the component world transformation function set, the center coordinates and axial vectors of the component orientation bounding box are spatially transformed to obtain the world orientation bounding box of the component at the current moment. Based on the joint hierarchy topology within a character, the world bounding boxes of all parts belonging to the same character are recursively merged from bottom to top. The world bounding box of each parent node is generated by aggregating the vertex set of the world bounding boxes of all its child nodes and recalculating, thereby constructing a complete bounding box hierarchy for each character. A dynamic bounding box hierarchy forest is generated based on the bounding box hierarchy of all roles.
5. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 1, characterized in that, S3 includes: Within a preset time window, a discrete time point sequence is generated based on a preset discrete sampling time interval; For each time point in the discrete time point sequence, perform traversal and bounding box intersection tests on the dynamic bounding box hierarchical forest to obtain all component pairs where bounding boxes intersect at that time point; Merge the bounding box intersection test results from all time points and perform deduplication to form a set of potential collision component pairs; For each pair of components in the set of potential collision components, perform continuous collision detection calculations based on the component world transformation functions corresponding to both components. The continuous collision detection algorithm iteratively advances the detection time and calculates the separation distance between the two components at each time point to determine the collision time when the component pair first penetrates within a preset time window. When the separation distance is less than or equal to the preset contact tolerance, penetration is determined and that moment is identified as the collision time. At the collision time, the spatial coordinates of the contact point between the penetrating component pair and the penetration vector are calculated, the penetration vector being used to characterize the penetration direction and penetration depth; All penetration events are sorted according to their collision time, generating a priority queue of conflict events arranged in ascending order of time.
6. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 1, characterized in that, S4 includes: Extract the first conflict event from the conflict event priority queue, and obtain the original global trajectory parameters and joint kinematic constraints of the driving joint corresponding to the first component in the component pair of the conflict event. The trajectory of the joint within the optimization time window, which is defined by the collision time, is parameterized using a set of control points, and the adjustment amount of the control points is defined as the decision variable of the optimization problem. Based on the spatial coordinates of the contact point and the penetration vector, an anti-penetration constraint is constructed. This anti-penetration constraint requires that the displacement of the contact point in the opposite direction of penetration at the time of collision be greater than or equal to the penetration depth. Based on joint kinematic constraints, position and velocity constraints of the joint are constructed within the optimization time window. Construct an objective function with the goal of minimizing the norm of the decision variables and minimizing the second derivative of the trajectory. Based on decision variables, anti-penetration geometric constraints, position and velocity constraints, and objective function, a mathematical optimization problem for trajectory is defined.
7. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 6, characterized in that, The optimized time window is a time interval with a preset duration, centered on the collision time and symmetrically extended to both sides before and after it.
8. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 1, characterized in that, S5 includes: A numerical optimization solver is used to iteratively solve the trajectory mathematical optimization problem to obtain the optimal decision variables that satisfy all constraints and minimize the objective function. The control points in the original global trajectory parameters are adjusted using the optimal decision variables to obtain the adjusted set of control points; Based on the adjusted set of control points and trajectory parameterization method, a new local trajectory function of the driving joint within the optimization time window is reconstructed.
9. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 1, characterized in that, S6 includes: The new local trajectory function is smoothly fused with the original global trajectory at the boundary of the optimization time window to generate the fused trajectory; The kinematic state of the driving joint and related components is updated based on the fused trajectory, and the component pairs involved in the first collision event in the collision event priority queue are re-detected for continuous collision. If the retest confirms that the separation distance between the components is always greater than the preset safety threshold within the verification time interval, then the trajectory data of the corresponding joint in the shadow puppet manipulation command spectrum is updated with the fused trajectory. If the re-detection fails, the original global trajectory is retained, and the conflict event is marked as needing to be reprocessed.
10. The method for self-growing and arranging shadow puppet manipulation command spectra according to claim 1, characterized in that, The conflict event priority queue is implemented using a minimum priority queue data structure.