Summary of the invention
In order to solve above and other relevant issues, the present invention has used and introduced the method that a plurality of figure layer object carry out coordinate conversion in two-dimensional scene.The present invention can effectively solve problems of the prior art.Coordinate transformation method provided by the present invention comprises following steps:
1. the two-dimentional visual object in two-dimensional scene or the two-dimensional scene gets access to the instruction of carrying out coordinate conversion by computer entry device or other entry terminals or the modes such as message that send by a certain webserver; Relevant apparatus in the two-dimensional scene is the discernible coordinate transformation parameter of two-dimensional scene by the analysis to instruction with this instruction transformation;
2. before the conversion of parameter role object coordinate in of obtaining of instruction analysis, need detect, whether have rationality to judge this coordinate transformation parameter to these coordinate parameters data to scene.
3. according to the coordinate transfer parameters, for two-dimensional scene is created a new figure layer; The coordinate system of new figure layer is identical with the coordinate system in the former scene or mapping relations are arranged, and this figure layer can be used to represent the state of scene;
4. the two-dimentional visual object in two-dimensional scene or this scene is carried out conversion operations, two-dimentional visual object is removed among old figure layer, and calculate corresponding coordinate figure in the figure layer that makes new advances with the coordinate Mapping relation between the scene according to figure layer, this object is added on this coordinate figure position of described figure layer;
5. according to the instruction of coordinate conversion, the focus that the figure layer of newly creating is activated to display device shows view, upgrades the coordinate and the state of all the two-dimentional visual objects in two-dimensional scene, figure layer and two-dimensional scene and the figure layer, and carries out equipment output by demonstration.
Two-dimensional scene in the wherein said step 1 should comprise one or more two-dimentional visual object, and this two dimension visual object is independent of two-dimensional scene or the figure layer exists, and each two-dimentional visual object all comprises an object identity; The instruction of its coordinate conversion can act on two-dimensional scene itself also can the arbitrary two-dimentional visual object of action scope;
In the wherein said step 5, renewal to figure layer and object is finished in the following manner: all signs of carrying out the described two-dimentional visual object of coordinate conversion are listed in the list object to be updated, and described figure layer is unified to refresh to described two-dimensional object according to this list object to be updated.
Corresponding to said method, the present invention also provides a kind of device that is used to implement this coordinate transformation method, and this device comprises:
Instruction fetch unit, be used to obtain the instruction of coordinate conversion, this instruction can be from computer entry device, as the click of mouse, move or the response of keyboard etc., also may come from signal that computer-internal produces or the command signal of coming automatic network to receive;
The instruction analysis judging unit is used to analyze the instruction of being obtained by instruction fetch unit, makes this instruction become the supplemental characteristic of the coordinate conversion that can discern in the two-dimensional scene; Whether simultaneously this supplemental characteristic is judged to check this coordinate transfer parameters whether this scene to be had rationality, be within the coordinate range of two-dimensional scene etc. as scope that two-dimentional visual object moved;
The scene storage unit is used to store relevant contextual data, figure layer data information and two-dimentional visual object data etc.; Comprising contextual data and the figure layer data comprise scene and figure layer coordinate data, scene and figure layer object between the mapping relations data; Two-dimentional visual object data wherein comprise this two-dimensional object in scene or figure layer position coordinate data and the object identity of two-dimensional object;
Management control unit is used for realizing managing and the coordinate blocked operation the two-dimensional scene coordinate system; This unit obtains the coordinate transferring data according to the instruction analysis control module two-dimensional scene, figure layer and two-dimentional visual object is controlled, and carries out the deletion two-dimensional object, adds object and activates operations such as new figure layer;
Display unit is used to show two-dimensional scene, two-dimentional visual object and figure layer object; This unit is exported demonstration with the figure layer data that is in state of activation in the scene storage unit as the focus view, and all the other described figure layer objects and two-dimensional scene can be used as auxiliary view and show output.
According to method and apparatus provided by the invention, create layer by introducing and to carry out the method for coordinate conversion, can carry out various coordinate conversion operations to the two-dimentional visual object in the two-dimensional scene, change the dependence between object and the scene, make two-dimentional visual object between the different conditions of scene, need not just can change freely by loaded down with trivial details process; Adopt method provided by the present invention, simple to operate, reduced dependence to the computer hardware system performance.
Specific embodiments
For making target of the present invention, technical scheme and advantage clearer, the present invention is described in further detail below in conjunction with accompanying drawing.
Fig. 1 has showed the embodiments of the invention synoptic diagram; Among Fig. 1, object 101 is represented two-dimensional scene, and object 102 now needs object 102 is transferred to B place, position according to instruction for being in the two-dimentional visual object of position A in this scene, and wherein position B and position A be not at a horizontal level;
According to method provided by the present invention,, create a new figure layer object 103 at position B place in order to realize the transfer of object 102; Have the coordinate Mapping relation between object 103 and the former object 101, the position that calculates after object 101 shifts by these mapping relations should be the B place, position in the object 103;
Object 102 is removed from object 101, add the B place, position of object 103 to, finish the coordinate handoff procedure of object 102;
Simultaneously, in the embodiment shown in fig. 1, can be defined as the state of scene among this embodiment by object 101 and object 103.Switch the change that to finish scene state by the view between object 101 and the object 103;
Above synoptic diagram is that a kind of method in the coordinate transformation method provided by the invention is implemented synoptic diagram, to the position of the quantity of object, converted coordinate and how to create layer, scheme between layer and the scene be which kind of coordinate Mapping relation etc. is not all done qualification, only need satisfy inventive concept and basic implementation method gets final product.
Fig. 2 is a process flow diagram of the invention process, has described the step that this method is implemented more specifically:
Step 201: by the conversion instruction of input equipment input coordinate, wherein input equipment can also can be network terminal etc. for mouse, keyboard; And the input coordinate conversion instruction can be finished by the modes such as input instruction that network sends by the button or the network terminal to the click of mouse, mouse moving, keyboard;
Step 202: obtain coordinate conversion instruction, obtain the coordinate conversion instruction by the response analysis of seizure that the click described in the step 201 and mouse are moved or keyboard and to the modes such as reception of Network Transmission director data;
Step 203: instruction is analyzed to obtain coordinate transformation parameter to coordinate conversion; Because the instruction that input equipment sends can only directly be discerned by computing machine, but can't allow scene information or visual object discern, therefore need analyze this coordinate conversion instruction, extract coordinate transformation parameter, as: the object identity of the two-dimentional visual object that operate or the location coordinate information that should the two dimension visual object will shift etc.;
Step 204: judge whether coordinate transformation parameter is reasonable; The coordinate transformation parameter of input equipment input might exceed two-dimensional scene or the figure layer of coordinate domain that can comprise, as: the coordinate conversion command request moves to a certain two-dimentional visual object outside the coordinate domain scope of two-dimensional scene; After the performed judgement of this step is finished, carry out different steps respectively, if input parameter rationally then execution in step 205 according to judged result; Otherwise execution in step 206;
Step 205: the coordinate conversion failure, because the irrationality of the coordinate transformation parameter of input equipment input causes this coordinate conversion procedure failure;
Step 206: for two-dimensional scene create new figure layer and set up two-dimensional scene with this figure layer between coordinate Mapping concern, the figure layer of creating is identical with former scene coordinate system or have mapping relations, and this figure layer can also comprise the state that other information are used to represent this two-dimensional scene.By these mapping relations, can calculate object and will be transformed into coordinate position in the described new figure layer;
Step 207: the respective two-dimensional object is transferred to from two-dimensional scene in the new figure layer, is about to object and from described two-dimensional scene, removes, on the pairing coordinate position of new figure layer, add this two dimension visual object;
Step 208: update displayed figure layer object, all signs of carrying out the described two-dimentional visual object of coordinate conversion to be listed in the list object to be updated, described figure layer is unified to refresh to described two-dimensional object according to this list object to be updated; Step 209: finish flow path switch.
Wherein in the step 204, judge whether the input coordinate conversion parameter rationally can define according to the specifying information of two-dimensional scene; Be judged to be irrational condition and can comprise following analogue: the position that the object in the two-dimensional scene will be changed has surpassed the regional extent that two-dimensional scene had, as: a certain two-dimensional scene is of a size of 1200*800, its X-axis coordinate range is 0 to 1200, the Y-axis coordinate range is 0 to 800, but the command request that at a time receives is converted to coordinate points (1300 in this two-dimensional scene with the some two-dimentional visual object in this two-dimensional scene, 900) position, because coordinate points (1300,900) not within the coordinate system range of two-dimensional scene, therefore then this coordinate conversion instruction of decidable is unreasonable instruction; And for example, in the two-dimensional scene and be that location point that object will be changed has comprised other objects such as buildings, barrier etc. and can not place other objects again, therefore can't realize this object is moved to the operation of this position, also can be judged to be this instruction in this case is unreasonable instruction; Remaining situation can define according to user's the demand or the requirement of scene, is not limited within the listed scope.
More specifically, the concrete steps of figure layer creation operation are as shown in Figure 3 in the step 206:
Step 301: determine the needed state of two-dimensional scene and two-dimensional scene;
Step 302: create corresponding figure layer according to the required state of scene;
Step 303: for new figure layer is established coordinate system;
Step 304: between scene and figure layer, establish the coordinate Mapping relation;
Wherein in the step 301, the implication of the needed state representative of two-dimensional scene is meant two-dimensional scene another form of expression according to the instruction appointment, this form of expression is passed through the various parameters of scene, as: the time state of the viewing angle that the observer of two-dimensional scene is in, the size of scene, scene etc. defines.We are by observer's perspective definition two-dimensional scene state among this embodiment: suppose that the initial state of described scene is the height that the residing height of observation of observer has near this scene, and the state of observer to observe to the angle of catotropia 45 degree, we are defined as this state the close shot observation state of scene; The instruction of sending according to output device need promote certain height with the present position of observer now, and viewing angle remains unchanged, and our this state is defined as the distant view observation state of scene; Need add the figure layer of a new distant view observation state by can determine this scene to the analysis of instruction; After establishing the figure layer state information that needs to add, this figure layer information is output as the figure layer creates the supplemental characteristic that equipment institute can receive, this supplemental characteristic will comprise the needed full details of figure layer establishment such as object that contained in the size, pixel value, figure layer of figure layer;
Wherein step 302 will be created layer object of publishing picture according to supplemental characteristic; The concrete parameter information of figure layer is provided by step 301;
Wherein in the step 303, for newly-built figure layer is set up coordinate system; Coordinate system not only is used for determining the position of figure layer, also is used for the coordinate Mapping relation between definite and the two-dimensional scene coordinate system; The foundation of figure layer coordinate system can adopt following mode to carry out: this coordinate system can be consistent with the pixel value of figure layer, and promptly a pixel is represented a unit of coordinate; The Pixel Dimensions of supposing the figure layer is 800*600, and then the coordinate system of figure layer can be a starting point coordinate (0 such as left upper apex from a certain summit then, 0), and the summit, bottom right is end coordinate (800,600), and all the other summits evenly distribute in the figure layer according to the pixel of figure layer;
Wherein in the step 304, set up the coordinate Mapping relation and can adopt following mode to carry out: length and the width value of supposing the coordinate system of scene are L
And W
, new figure layer length and the width range of creating is respectively L
NewlyAnd W
NewlyThen newly-built figure layer coordinate (X
Newly, Y
Newly) with the coordinate (X of former scene graph layer
, Y
) between coordinate Mapping close and to be:
X
Newly=(L
Newly/ L
) * X
Y
Newly=(W
Newly/ W
) * W
By the formula of mapping relations, can calculate former its pairing coordinate figure of position coordinates that is in object in the two-dimensional scene easily at new layer position;
More specifically, in the step 207, two-dimentional visual object is carried out the step of conversion operations and can finish according to process flow diagram as shown in Figure 4:
Step 401: search target two dimension visual object in the scene information according to being identified at of two-dimentional visual object;
Step 402: target two dimension visual object is saved to buffer zone, and reads the coordinate figure of this two dimension visual object in two-dimensional scene;
Step 403: calculate the coordinate figure of target two dimension visual object in new figure layer according to the coordinate Mapping relation of newly-built figure layer and two-dimensional scene;
Step 404: in two-dimensional scene information, delete target two dimension visual object information and this two dimension visual object of interpolation in new figure layer;
Step 405: send message to display module, after display module is received message, will upgrade figure layer and two-dimentional visual object, and will scheme the front view of layer accordingly as display device; Corresponding to the above embodiments, be the method that cooperates coordinate provided by the present invention to shift, the present invention also provides a kind of device of coordinate conversion.
Fig. 5 has showed the installation drawing of the embodiment of the invention:
Instruction fetch unit 501, be used to obtain the instruction of coordinate conversion, this instruction can from computer entry device, as the click of mouse, move, drag or the response of keyboard etc., also may come from signal that computer-internal produces or the command signal that receives by network;
Instruction analysis judging unit 502, be used to analyze the instruction that the unit that obtained by instruction obtains, make it to become the data that can act on the scene coordinate conversion, and these data are judged, checking the reasonable director data whether meet coordinate transform, whether the scope of changing as two-dimensional object exceeds the coordinate range of scene etc.;
Management control unit 503 is used for the scene storage unit is managed, and obtains the coordinate transferring data according to the instruction analysis control module new figure layer and two-dimentional visual object are controlled, and carries out the deletion two-dimensional object, adds operations such as object and the new figure of activation layer;
Scene storage unit 504 is used to store relevant two-dimensional scene data message, figure layer data information and two-dimentional visual object information; In the scene storage unit, can be for each scene information, figure layer data information or unique indications of two-dimentional visual object information distribution, easy-to-look-up;
Display unit 505 is used to show two-dimensional scene and figure layer data, and is responsible for the demonstration that refreshes to the activation of figure layer object and two-dimentional visual object;
Prospect map layer 506 is used to represent two-dimensional scene medium long shot observation state;
Close shot figure layer 507 is used to represent two-dimensional scene two-shot observation state;
In this embodiment device figure, device 506 is respectively applied for expression two-dimensional scene different conditions with device 507, storage is responsible for by scene arrangement 504 in this figure layer unit, and is managed by management control unit, and each figure layer unit all contains a Digital ID and is used to discern this unit.
In the instruction fetch unit device 501, more specifically, can be divided into a plurality of monitoring units, be used to monitor the instruction that relevant device sends at different input equipments; As: mouse monitoring unit, keyboard monitoring unit and network interface monitoring unit etc.; Can be separate but have and use identical interface in each unit, with interpolation or the deletion action that makes things convenient for the follow-up equipment monitoring unit;
In the instruction analysis judging unit 502, also can provide corresponding a plurality of instruction analysis unit, be used to resolve director data from the different device input according to a plurality of monitoring units that the instruction fetch unit device is divided; Separate between each unit, but the data after resolving then have identical data layout;
In the management control unit 503, can comprise an operation note unit more specifically, be used to preserve the record of the performed operation of management control unit, be convenient to finish the two-dimensional scene and the scenario objects control task thereof in a nearly step such as search operation, rolling back action and data restore operation;
By the embodiment of the invention as can be seen, by add the mode of figure layer and coordinate Mapping relation for two-dimensional scene, realized a kind of in two-dimensional scene the method for coordinate conversion, can carry out various coordinate conversion operations to the two-dimentional visual object in the two-dimensional scene, change the dependence between object and the scene, make two-dimentional visual object between the different conditions of scene, need not just can change freely by loaded down with trivial details process; This method can be widely used in that electronic digit map, virtual scene are created and two-dimentional scene of game in, especially can be implemented in the two-dimentional scene of game, character flies, the field such as move of short transverse;
The explanation of above embodiment just is used for helping to understand method of the present invention and core concept; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, in embodiment and with the part that can change in scope.In sum, this description should not be construed as the restriction to invention.