A kind of layering barrier-avoiding method that is used for transaction
Technical field
The present invention relates to the virtual reality field, particularly a kind of layering barrier-avoiding method that is used for transaction.
Background technology
Along with the continuous development of virtual reality technology and computer graphics techniques with popularize, the simulation of virtual individual and virtual community is widely used in safe preview, video display stunt, animation generates and numerous areas such as virtual world structure, is becoming the extremely theme paid close attention to of researchers in recent years.
In the various aspects of virtual individual and virtual community modeling effort, the barrier realization that keeps away of transaction is a key factor that guarantees the analog result authenticity.Wherein, transaction is meant the dummy object that can move in simulated environment, comprises virtual individual and movable environment object.For realize between transaction and transaction and static environment object between collision avoid, and stop to penetrate, people have proposed a large amount of barrier-avoiding methods in conjunction with various analogy models.Yet in simulation, because the realization that keeps away barrier relates to all many-sides such as the control of the selection in the formulation of the extraction of environmental information and utilization, behaviour decision making and enforcement, path and planning, concrete motion and realization and analog result is visual, and researchers have been proposed acid test.Wherein the challenge of most critical is: how to stop penetration phenomenon and farthest reduce owing to the space constraint and the distortion that keep away in the transaction Behavior modeling that the barrier demand brings.
Class barrier-avoiding method commonly used is to use repulsion to realize the barrier of keeping away of transaction in the prior art.These class methods at first are being provided with certain repulsion producing method between transaction and the transaction and between transaction and the static entities; Then, in the process of transaction motion, its various repulsion that are subjected to are stacked up by certain mode obtains making a concerted effort of a repulsion; At last, the power of other type that is subjected to transaction of making a concerted effort of repulsion is changed together the position of transaction by the Newtonian mechanics formula.At list of references 1: in " C.W.Reynolds; SteeringBehaviors For Autonomous Characters (for autonomous individual guiding behavior); in:ConferenceProceedings of the 1999 Ganme Developers Conference; 1999, pp.763-782. " this barrier-avoiding method has been done detailed introduction.This method can generate smooth movement locus, but is difficult to avoid between the transaction, penetrates generation between transaction and the static entities, and is especially many at transaction, under the bigger situation of velocity ratio.
Another kind of barrier-avoiding method commonly used of the prior art is to set the barrier of keeping away that carries out transaction by division by force and exclusivity to environment.In these class methods, environment can be divided into the grid (based on positive square or regular hexagon) that occupies the consistent size in space with transaction equably usually, and each grid is endowed different conditions according to the attribute of environment, as walking and can not walking; Stipulate that simultaneously each grid can only be occupied by a transaction simultaneously.Transaction carries out choosing of grid according to certain rule in the process of motion, thereby obtains the renewal of position.At list of references 2: in " N.Ketchell; A.Holt; k.Kinsella; ATechnical Summary of The AEAEGRESS Code (technology about AEA EGRESS code is summed up); in:AEA Technology Safety andRisk Management, 2002 " this class barrier-avoiding method has been done detailed introduction.This barrier-avoiding method can guarantee that no penetration phenomenon takes place between transaction and transaction and transaction and the static entities, but, too much restriction the behavior of transaction, cause transaction can only as chess piece the chessboard by lattice walking, damaged the authenticity of simulation behavior greatly.These methods only lay particular emphasis on some and keep away satisfying of barrier simulation demand, as require smooth trajectory or transaction not to have fully to penetrate etc., comprehensively do not keep away barrier simulation solution and provide, therefore can't satisfy demand higher in the real world applications.
Summary of the invention
The objective of the invention is to overcome existing barrier-avoiding method authenticity in virtual process low, defectives such as penetration phenomenon take place easily, thereby a kind of layering barrier-avoiding method is provided.
To achieve these goals, the invention provides a kind of layering barrier-avoiding method that is used for transaction, may further comprise the steps:
Step 1), transaction is carried out static state keep away barrier operation, keep away in the barrier process in static state, when transaction enters a certain static-obstacle thing reach, select the route that is used for avoiding described static-obstacle thing in the alternative environment route around the described static-obstacle thing;
Step 2), transaction is carried out the dynamic obstacle avoidance operation, in the dynamic obstacle avoidance process, calculate the possibility of conflicting of described transaction and other barriers in each update cycle, to being about to the transaction of occurrence positions conflict, change the movement velocity or the direction of motion of described transaction, no longer conflict with the barrier occurrence positions until described transaction; Wherein,
Described dynamic obstacle avoidance operation comprises:
Step 21), with the surrounding space of described transaction by the angular divisions direction, with one of them direction as target direction;
Step 22), with described target direction as working direction, movement velocity according to described transaction, whether prediction has other barriers to conflict with described movement entity occurrence positions, if there is not the position conflict, described transaction keeps original route to move on, if the location conflict is carried out next step;
Step 23), according to distance and relative velocity between described transaction and the barrier that described occurrence positions conflicts, reduce the pace of described transaction on direction of motion;
Step 24), judge that whether pace after described transaction reduces is less than a threshold speed, if be not less than, then described transaction keeps original route to move on according to the pace after reducing, if less than, then search the not possible direction of occurrence positions conflict on the direction of other outside target direction, if there is the possible direction of a plurality of not occurrence positions conflicts, then select and the most approaching direction of target direction, if find the not possible direction of occurrence positions conflict, carry out next step, if do not find, promptly all directions all can the occurrence positions conflict, and then described transaction holding position is motionless;
Step 25), according to the speed of new direction that is found and the described transaction of current time, calculate the position of described transaction in the next update cycle.
In the technique scheme, after described transaction being finished described static state and being kept away barrier and dynamic obstacle avoidance and operate, also to carry out collision detection and corrective operations.
In the technique scheme, described alternative environment route is meant the route segment set of delimiting in advance that is used to avoid this static-obstacle thing around each static-obstacle thing in virtual environment.
In the technique scheme, in described step 1), in described static-obstacle thing alternative environment route on every side, select when being used for avoiding the route of described static-obstacle thing, from described alternative environment route, select the immediate minimal path of target travel direction with described transaction.
Described collision detection and corrective operations comprise:
In each update cycle, whether detect the current location of described transaction conflicts with other barrier occurrence positions, if clash, then according to priority criteria, for described transaction and barrier are provided with priority, and utilize the conflict antidote that the position of described transaction or described other barriers is adjusted.
Described priority criteria comprises:
If described transaction conflicts with the static-obstacle occurrence positions, then the priority of described static-obstacle is higher than the priority of described transaction;
The conflict of two transaction occurrence positions, if the current location of a transaction is last one original position constantly the time, then the priority of this transaction is higher than the priority of another transaction; If the position of two transactions was not the position in a last moment, then person's priority is higher forwardly for original position.
Described conflict antidote or according to the transaction that clashes and described other barriers at last one constantly original position, or according to the line direction of the transaction that clashes and described other barriers, or according to certain random direction, draw back the distance between described transaction and described other barriers, until both no longer till the occurrence positions conflict.
Described conflict antidote is according to transaction that clashes and the original position of described other barriers in a last moment, draw back between the two apart from the time, its specific implementation step comprises:
Step a), connect transaction with straight line and upgrade the position P2 that the back penetrates and upgrade preceding position P1, can get P2 is PP to the vector of P1;
The accuracy requirement that step b), foundation are corrected is set a maximum actual figure N, and the value of described N is more than or equal to 1:
Step c), actual figure n of setting, the value of this actual figure of initialization is 0;
Step d), in implementation, transaction and object are on every side done collision detection, if not conflict, then the conflict correcting process of this transaction finishes, if conflict is arranged, and the priority of described transaction is not higher than the other side's priority, then with correcting position P
3=P
1+ 1/ (N-n) * P
21The position of substitution P
2, if the priority of described transaction is higher than the other side's priority, the position of then correcting the other side;
Step e), the value of actual figure n is added 1, and whether the value of judging current actual figure n is less than maximum actual figure N, if less than, then re-execute step d), take turns correcting process otherwise finish this.
Step f),, the transaction that penetrates repeats above step, till not having the position conflict to being arranged.
The invention has the advantages that:
1, the layering barrier-avoiding method that is used for transaction of the present invention only carries out aligning to the object that is subjected to displacement, and has therefore avoided stationary object owing to correcting the motion distortion that brings.
2, because each object does not have the penetration phenomenon generation at initial position, therefore method of the present invention has guaranteed to penetrate the feasibility of avoiding fully, can generate rationally and do not have penetrate generation keep away the barrier analog result, improved the verisimilitude of virtual individual motion simulation and virtual community simulation.
3, layering of the present invention keeps away the barrier method and has good versatility, can be used for various types of virtual individual and virtual communities simulations based on individuality.
Description of drawings
Fig. 1 is the process flow diagram that is used for the layering barrier-avoiding method of transaction of the present invention.
Embodiment
Below in conjunction with the drawings and specific embodiments the present invention is described in further detail:
The same with real world, in virtual world, when a transaction in when motion, may run into various barriers, whether move according to barrier can be divided into static-obstacle thing and dynamic barrier.For transaction, it is simple relatively to avoid the static-obstacle thing, and dynamic barrier all may change along with the variation of time owing to position, movement velocity etc., and therefore, it is then more difficult to avoid dynamic barrier.Based on to the evading and there are different characteristics evading of dynamic barrier of static-obstacle thing, the present invention proposes a kind of layering barrier-avoiding method, this method is carried out different processing to the static-obstacle thing that transaction ran into dynamic barrier.
Fig. 1 is the process flow diagram of the inventive method, and in this process flow diagram, frame of broken lines is represented corresponding action, and solid box is represented the action execution resulting result in back.Below in conjunction with this process flow diagram method of the present invention is done detailed description.
In a virtual environment, a transaction is arranged, be assumed to a visual human, when he on the way walks, a plurality of different types of barriers are arranged on the road, suppose roadblock set when the static-obstacle thing that is comprised has dustbin, the road maintenance in street lamp, roadside etc., suppose that the dynamic barrier that is comprised has pedestrian, bicycle etc.
When this motion of virtual human, at first carry out static state and keep away barrier.Said herein static state is kept away barrier and just is meant and avoids the static-obstacle thing.Suppose the people in motion process, during the reach of being barricaded when entering road maintenance, in alternative environment route, select the route that can be used for avoiding this roadblock.Wherein, described alternative environment route is meant the route segment set of delimiting in advance that is used to avoid this static-obstacle around each static-obstacle thing in virtual environment, and these route segment can be specified by manual interaction, also can generate automatically according to information.The reach of static-obstacle thing can calculate by the coverage size to the static-obstacle thing of artificial appointment, also can be generated by Automatic Program after the given threshold value.
Be easy to expect that may have more than one circuit selectable in alternative environment route, the selection principle of route is so: from the route segment set, select the immediate minimal path of target travel direction with transaction.
Keep away the barrier process by above-mentioned static state, the visual human has obtained the reference route that can avoid the static-obstacle thing, this route provides the direction and goal of a walking for the visual human, but and do not require that the visual human is fully according to this route walking, in follow-up dynamic obstacle avoidance process, may adjust visual human's track route, direction of travel, with the dynamic barrier of avoiding to occur at any time.
After the visual human finishes static state and keeps away barrier, also need to finish the dynamic obstacle avoidance operation.Dynamic obstacle avoidance is meant the dynamic barrier of avoiding in the motion process being run into.Because uncertainty and the unpredictability of dynamic barrier in virtual environment, therefore, in the dynamic obstacle avoidance process, the visual human need be in the route traveling process each carry out the position collision detection constantly, determine moving line, gait of march of visual human etc. according to the result of position collision detection.
Being implemented as follows of dynamic obstacle avoidance: the space around the visual human is divided into 6 directions, be respectively forward direction, back to, left front, left back, right front, right back, the angle between two adjacent directions is 60 degree, forward direction is visual human's a target travel direction.Whether the visual human predicts having barrier to conflict with own occurrence positions in one or several update cycle about the forward direction, if there is conflict, then reduce people's movement velocity, make that the visual human after the reduction movement velocity can not clash with barrier according to distance between people and barrier and relative velocity.If but the movement velocity after reducing is less than a preassigned threshold value, 0.1m/s for example, then begin on other 5 directions to seek the most approaching and do not have occurrence positions to conflict the direction of possibility as direction of motion with target direction, if all occurrence positions conflicts on all directions, then the visual human keeps original position motionless.In forecasting process, because current position and the speed of visual human all is known, therefore, be easy to calculate after next or several update cycles the position of oneself, and dynamic barrier possible position when the time comes, be whether measurable visual human can conflict with the dynamic barrier occurrence positions by the position of comparing both.
In the above-mentioned dynamic obstacle avoidance process, if will change direction of motion, can pay the utmost attention to left front and the right front to, be left back then and the right back to, be the back at last to.
In the present invention, the length of update cycle can determine that according to the effect of simulation, the factors such as efficient of computing such as being 0.33 second~1 second, generally getting the update cycle is 0.1 second by the user in the simulation process.
Keep away barrier and dynamic obstacle avoidance operation by above-mentioned static state, can realize substantially that visual human's keeping away in virtual environment hinders realization.
In another embodiment, multilayer barrier-avoiding method of the present invention also will carry out collision detection and corrective operations after finishing static state and keeping away barrier and dynamic obstacle avoidance and operate.The purpose of collision detection and corrective operations is in order to prevent the generation of penetration phenomenon.In collision detection and corrective operations, at first in each update cycle, after the calculating of visual human's shift position finishes, detect and whether can conflict with other barrier occurrence positions, if location conflict, then to the visual human who the clashes rectification that conflicts with barrier, till not having the position conflict to take place.
In above-mentioned collision detection and correcting process, during the conflict of detection position, can adopt the method for keeping away the barrier bounding box to detect.Occurrence positions conflicts between people and other barriers when detecting, and those skilled in the art will readily appreciate that, when the people that clashes or thing are adjusted, relates to which position is adjusted.In order to address this problem, the present invention proposes the corresponding priority level criterion, the people who clashes according to this criterion adjustment or the position of thing, wherein, people or thing that people that priority is low or thing are high than priority are preferentially adjusted.The particular content of priority criteria comprises: 1, transaction is as conflicting with the static-obstacle occurrence positions, and static-obstacle priority is higher than transaction; 2, two transactions such as occurrence positions conflict, if the current location of a certain entity is last one original position constantly, then this entity priority is higher than another transaction; 3, as both sides' current location all non-last a position constantly, original position person's priority height forwardly then.
In the conflict correcting process, the transaction that clashes progressively can be drawn back between the two distance according to original position, until both no longer till the occurrence positions conflict.In conjunction with formula above-mentioned conflict correcting process is specifically described: at first connect transaction with straight line and upgrade the position P2 that the back penetrates and upgrade preceding position P1, can get P2 is PP to the vector of P1; According to the accuracy requirement of correcting, set a maximum actual figure N then, N is more than or equal to 1; Follow the actual actual figure n=0 of initialization; At last when carrying out each time, to this entity and around it transaction carry out collision detection, if do not have conflict, this entity conflict is corrected and is finished; If there being conflict to take place, and priority is not higher than the other side's entity, then with correcting position P
3=P
1+ 1/ (N-n) * P
21The position of substitution P
2,, then the other side's entity is done same adjustment, up to the P of all transactions if priority is higher than the other side's entity
2The position does not all have till the conflict of position.As long as the initial position when guaranteeing the simulation beginning is no penetration site, this algorithm just necessarily can be corrected transaction and be no penetrativity.The computation complexity of this algorithm be O (N * C * M * r), wherein C is the individual maximum individual number that can have in the scope that searches, N is maximum actual figure, M is altogether number of individuals in the simulation, r is for need whole round-robin number of times.In the worst case, r=M-1.
In the present embodiment, the method that conflict is corrected is progressively drawn back the transaction that clashes according to original position, till no longer clashing, but in other embodiment, also two transactions that clash directly can be spaced out along the direction of both lines, perhaps space out, until between two transactions, no longer clash according to certain random direction.In addition, also can add, delete or revise for the priority criteria of being mentioned in the present embodiment, as determining the priority of transaction according to the identity of transaction, described priority criteria is as long as can adjust collision position according to criterion between the transaction that guarantees to clash.
It should be noted last that above embodiment is only unrestricted in order to technical scheme of the present invention to be described.Although the present invention is had been described in detail with reference to embodiment, those of ordinary skill in the art is to be understood that, technical scheme of the present invention is made amendment or is equal to replacement, do not break away from the spirit and scope of technical solution of the present invention, it all should be encompassed in the middle of the claim scope of the present invention.