Editor operation method, device and electronic device

By converting the operation vector in the three-dimensional space to a two-dimensional plane, the movement information of the object in the three-dimensional space is calculated, which solves the computational complexity problem caused by the complex region division in the existing technology and improves the operation efficiency and accuracy.

CN112686948BActive Publication Date: 2024-09-27BEIJING PIXEL SOFTWARE TECH
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202011557546.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-25
Publication Date
2024-09-27
Estimated Expiration
2040-12-25

AI Technical Summary

Technical Problem

Existing game editors have complicated area divisions in three-dimensional space, which makes calculations complex and inconvenient. In particular, judgment errors may occur at the junctions of various areas, leading to calculation errors and unexpected operation effects.

Method used

By obtaining the operation vector in the three-dimensional space, converting it to the two-dimensional plane, the vector of the two-dimensional plane is obtained, and the motion information of the object in the three-dimensional space is calculated based on the operation vector on the two-dimensional plane, which simplifies the calculation process and avoids The complexity of zoning.

Benefits of technology

It realizes simple calculations for operating objects in three-dimensional space, reduces misjudgments, and improves operating efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112686948B
    Figure CN112686948B
Patent Text Reader

Abstract

The embodiments of the present invention provide an editor operation method, device and electronic device, which relate to the field of computer technology. By responding to the operation of an object in a three-dimensional space, a first vector of the operation in the three-dimensional space is obtained, the first vector is converted to a two-dimensional plane, a second vector of the first vector in the two-dimensional plane is obtained, and then the operation vector of the operation in the two-dimensional plane is obtained. According to the second vector and the operation vector, the motion information of the object in the three-dimensional space can be calculated. In this way, the motion information of the object in the three-dimensional space can be obtained without dividing the area, which simplifies the calculation process and is more convenient to implement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an editor operation method, device and electronic device. Background Art

[0002] Editors are very important tools in the game development process. Whether it is a 2D game or a 3D game, various editors are needed in the production process. Different editors have different functions. Most editors need to use translation, rotation, and scaling to operate the objects. The main purpose is to improve the efficiency of game development. Reasonable operation methods can help improve the production efficiency of users.

[0003] At present, the editors used in game production generally divide different areas in three-dimensional space according to the coordinate system, and then calculate the user's operation on the two-dimensional plane according to the area where the camera is located and the area where the object is located, and realize the movement of the object in three-dimensional space based on the calculation results. Due to the large number of divided areas, the calculation method of each area is different, the calculation is relatively complicated, and the implementation is relatively inconvenient. Summary of the invention

[0004] Based on the above research, the present invention provides an editor operation method, device and electronic device to improve the above problems.

[0005] The embodiments of the present invention can be implemented as follows:

[0006] In a first aspect, the present invention provides an editor operation method, the method comprising:

[0007] In response to an operation on an object in a three-dimensional space, obtaining a first vector of the operation in the three-dimensional space;

[0008] Convert the first vector to a two-dimensional plane to obtain a second vector of the first vector on the two-dimensional plane;

[0009] An operation vector of the operation in the two-dimensional plane is acquired, and motion information of the object in the three-dimensional space is calculated according to the second vector and the operation vector.

[0010] In an optional embodiment, the operation includes a translation operation or a scaling operation; and the step of obtaining a first vector of the operation in the three-dimensional space in response to the operation on the object in the three-dimensional space includes:

[0011] Determine a starting position of the translation operation or the scaling operation on the two-dimensional plane, and calculate position information of the starting position in the three-dimensional space;

[0012] According to the position information and the camera position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated;

[0013] Determine whether the target ray intersects the direction axis of the object;

[0014] If the intersection point exists, the orientation of the target direction axis where the intersection point exists is calculated, and the first vector is obtained according to the unit vector of the orientation.

[0015] In an optional implementation, the step of calculating the orientation of the target direction axis where the intersection point exists includes:

[0016] Get the quaternion of the direction axis of the object;

[0017] The orientation of the target direction axis is calculated according to the initial position of the target direction axis and the quaternion.

[0018] In an optional embodiment, the operation includes a rotation operation, and the step of obtaining a first vector of the operation in the three-dimensional space in response to the operation on the object in the three-dimensional space includes:

[0019] Determine a starting position of the rotation operation on the two-dimensional plane, and calculate position information of the starting position in the three-dimensional space;

[0020] According to the position information and the camera position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated;

[0021] Determine whether the target ray intersects the direction axis of the object;

[0022] If the intersection point exists, calculating a perpendicular vector of the target direction axis where the intersection point exists;

[0023] Acquire the position information of the intersection point and the center position information of the object, and calculate a third vector according to the position information of the intersection point and the center position information of the object;

[0024] The first vector is calculated based on the cross product of the vertical vector and the third vector.

[0025] In an optional implementation, the step of converting the first vector to a two-dimensional plane to obtain a second vector of the first vector in the two-dimensional plane includes:

[0026] According to the world matrix, observation matrix and projection matrix, the transformation matrix is ​​calculated;

[0027] Obtaining a viewport matrix, and calculating the viewport pixel coordinates of the first vector in a viewport pixel coordinate system according to the transformation matrix and the viewport matrix;

[0028] The viewport pixel coordinates are converted into the coordinate system of the two-dimensional plane to obtain a second vector of the viewport pixel coordinates in the two-dimensional plane.

[0029] In an optional implementation, the step of obtaining the operation vector of the operation on the two-dimensional plane and calculating the motion information of the object in the three-dimensional space according to the second vector and the operation vector includes:

[0030] Determine a starting position and an end position of the operation on the two-dimensional plane, and calculate an operation vector according to the starting position and the end position;

[0031] Calculating a cosine value of an angle between the second vector and the operation vector;

[0032] The motion information of the object in the three-dimensional space is obtained according to the cosine value calculation.

[0033] In an optional implementation, the motion information includes a motion direction, and the step of calculating the motion information of the object in the three-dimensional space according to the cosine value includes:

[0034] Determine whether the cosine value is greater than a set value, and if so, determine that the moving direction of the object in the three-dimensional space is the same as the direction of the second vector;

[0035] If it is less than the set value, it is determined that the moving direction of the object in the three-dimensional space is opposite to the direction of the second vector.

[0036] In an optional implementation, the motion information further includes motion data, and the step of calculating the motion information of the object in the three-dimensional space according to the cosine value includes:

[0037] Multiply the length of the operation vector by the cosine value to obtain a parameter value;

[0038] The motion data of the object in the three-dimensional space is calculated according to the parameter value and the preset conversion coefficient.

[0039] In a second aspect, the present invention provides an editor operation device, the device comprising an operation response module, a data conversion module and a data processing module;

[0040] The operation response module is used to respond to the operation on the object in the three-dimensional space and obtain a first vector of the operation in the three-dimensional space;

[0041] The data conversion module is used to convert the first vector to a two-dimensional plane to obtain a second vector of the first vector on the two-dimensional plane;

[0042] The data processing module is used to obtain the operation vector of the operation in the two-dimensional plane, and calculate the motion information of the object in the three-dimensional space according to the second vector and the operation vector.

[0043] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the editor operation method described in any one of the aforementioned implementations when executing the computer program.

[0044] In a fourth aspect, the present invention provides a readable storage medium, wherein the readable storage medium stores a computer program, and when the computer program is executed, the editor operation method described in any one of the aforementioned implementation modes is implemented.

[0045] The editor operation method, device and electronic device provided by the embodiments of the present invention respond to operations on objects in three-dimensional space, obtain a first vector of the operation in three-dimensional space, convert the first vector to a two-dimensional plane, obtain a second vector of the first vector in the two-dimensional plane, and then obtain the operation vector of the operation in the two-dimensional plane. The motion information of the object in the three-dimensional space can be calculated based on the second vector and the operation vector. In this way, the motion information of the object in the three-dimensional space can be obtained without dividing the area, which simplifies the calculation process and is more convenient to implement. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0047] Figure 1 A block diagram of an electronic device provided by an embodiment of the present invention.

[0048] Figure 2 A flowchart of an editor operation method provided by an embodiment of the present invention.

[0049] Figure 3 A schematic diagram of a direction axis provided in an embodiment of the present invention.

[0050] Figure 4 A schematic diagram of an operation vector and a second vector provided in an embodiment of the present invention.

[0051] Figure 5 A block diagram of an editor operating device provided in an embodiment of the present invention.

[0052] Icons: 10-electronic device; 11-editor operating device; 111-operation response module; 112-data conversion module; 113-data processing module; 12-memory; 13-processor; 14-communication unit; 15-display unit; 16-peripheral interface; 17-input and output unit. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0054] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0056] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the invention is usually placed when used. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.

[0057] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.

[0058] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.

[0059] As described in the background technology, at present, the editors used in game production generally divide different areas in three-dimensional space according to the coordinate system, and then calculate the operations performed by the developer in the two-dimensional plane according to the area where the camera is located and the area where the object is located, and realize the movement of the object in three-dimensional space, such as translation, rotation, etc., according to the calculation results. Due to the large number of divided areas, the calculation method of each area is different, the calculation is more complicated, and the implementation is more inconvenient. In addition, due to the large number of divided areas, objects at the junction of various areas may be misjudged, resulting in calculation errors and unexpected operation effects.

[0060] Based on the above research, this embodiment provides an editor operation method, device and electronic device to improve the above problems.

[0061] Please refer to Figure 1 , Figure 1 1 is a block diagram of an electronic device 10 provided in this embodiment. The electronic device 10 provided in this embodiment may be, but is not limited to, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a personal digital assistant (PDA), and the like. This embodiment does not impose any limitation on the specific type of the electronic device 10.

[0062] The internal structure diagram of the electronic device 10 provided in this embodiment can be as follows: Figure 1 As shown, it includes an editor operating device 11, a memory 12, a processor 13, a communication unit 14, a display unit 15, a peripheral interface 16 and an input and output unit 17.

[0063] The memory 12, processor 13, communication unit 14, display unit 15, peripheral interface 16 and input / output unit 17 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines. The memory 12 stores an editor operating device 11, and the editor operating device 11 includes at least one software function module that can be stored in the memory 12 in the form of software or firmware. The processor 13 executes various functional applications and data processing by running the software programs and modules stored in the memory 12, such as the editor operating device 11 in the embodiment of the present invention, that is, the editor operating method in the embodiment of the present invention is realized.

[0064] The memory 12 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 12 is used to store a program, and the processor 13 executes the program after receiving an execution instruction.

[0065] The processor 13 may be an integrated circuit chip with data processing capabilities. The processor 13 may be a general-purpose processor 13, including a central processing unit (CPU), a network processor (NP), etc. The methods, steps, and logic block diagrams disclosed in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.

[0066] The communication unit 14 is used to establish a communication connection between the electronic device 10 and other devices through a network to implement data transmission and reception operations. The above network may include a wireless network or a wired network.

[0067] The display unit 15 is used to provide an interactive interface (e.g., a user operation interface) between the electronic device 10 and the user for displaying information. In this embodiment, the display unit 15 may be a liquid crystal display or a touch display. If it is a touch display, it may be a capacitive touch screen or a resistive touch screen that supports single-point and multi-point touch operations. Supporting single-point and multi-point touch operations means that the touch display can sense touch operations generated from one or more locations on the touch display, and the sensed touch operations are handed over to the processor 13 for calculation and processing.

[0068] The peripheral interface 16 couples various input / output devices (eg, an input / output unit 17 and a display unit 15 ) to the processor 13 and the memory 12 .

[0069] The input-output unit 17 is used to provide input data to the user to implement interaction between the user and the electronic device 10. The input-output unit 17 can be, but is not limited to, a mouse and a keyboard.

[0070] Understandably, Figure 1 The structure shown is for illustration only. The electronic device 10 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0071] based on Figure 1 For the implementation architecture, please refer to Figure 2 , Figure 2 A flowchart of the editor operation method provided in this embodiment is shown in FIG. Figure 1 The electronic device 10 shown in the figure performs the following Figure 2 The process diagram shown is described in detail.

[0072] Step S10: In response to an operation on an object in a three-dimensional space, a first vector of the operation in the three-dimensional space is obtained.

[0073] Step S20: convert the first vector to a two-dimensional plane to obtain a second vector of the first vector in the two-dimensional plane.

[0074] Step S30: Acquire an operation vector operated on a two-dimensional plane, and calculate motion information of the object in a three-dimensional space according to the second vector and the operation vector.

[0075] In the process of game development, objects in the three-dimensional space of the game scene will be displayed on the screen plane, that is, the two-dimensional plane described in this embodiment. If it is necessary to operate the objects in the three-dimensional space, the corresponding operations can be performed on the two-dimensional plane. The electronic device 10 operates the objects in the three-dimensional space by responding to the user's operations on the two-dimensional plane.

[0076] In this embodiment, when a user operates an object in a three-dimensional space in a two-dimensional plane, the electronic device 10 obtains a first vector of the operation in the three-dimensional space, converts the first vector to a two-dimensional plane, obtains a second vector of the first vector in the two-dimensional plane, and then obtains an operation vector of the operation in the two-dimensional plane, calculates motion information of the object in the three-dimensional space based on the second vector and the operation vector, and operates the object to move in the three-dimensional space based on the motion information. In this way, the motion information of the object in the three-dimensional space can be calculated without dividing the area, and the calculation method is independent of the area where the object is located, which simplifies the calculation process and is more convenient to implement.

[0077] In view of the fact that in actual applications, editors generally use translation, rotation, and scaling to operate objects in three-dimensional space, therefore, the operation of the objects in three-dimensional space in this embodiment may be translation, rotation, or scaling.

[0078] When the operation on the object in the three-dimensional space is a translation operation, the first vector of the translation operation in the three-dimensional space is obtained. When the operation on the object in the three-dimensional space is a rotation operation, the first vector of the rotation operation in the three-dimensional space is obtained. When the operation on the object in the three-dimensional space is a scaling operation, the first vector of the scaling operation in the three-dimensional space is obtained.

[0079] In this embodiment, the translation operation and the scaling operation use the same method to obtain the first vector in the three-dimensional space. Therefore, when the operation is a translation operation or a scaling operation, in response to the operation on the object in the three-dimensional space, the step of obtaining the first vector of the operation in the three-dimensional space may include:

[0080] Determine the starting position of the translation operation or the scaling operation on the two-dimensional plane, and calculate the position information of the starting position in the three-dimensional space.

[0081] According to the position information and the camera position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated.

[0082] Determine whether the target ray intersects the direction axis of the object.

[0083] If there is an intersection, the direction of the target direction axis where the intersection exists is calculated, and the first vector is obtained based on the unit vector of the direction.

[0084] Among them, when the user translates or scales an object in the three-dimensional space, it is necessary to perform corresponding operations such as clicking and dragging on the two-dimensional plane. Therefore, when the user translates or scales an object in the three-dimensional space, the electronic device 10 responds to the user's corresponding operation on the two-dimensional plane and determines the starting position of the translation operation or scaling operation on the two-dimensional plane.

[0085] For example, when a user performs a translation operation on an object in a three-dimensional space, he can select a point on a two-dimensional plane and then drag based on the selected point to achieve the translation operation on the object in the three-dimensional space, and the selected point is the starting position of the translation operation. For another example, when a user performs a zoom operation on an object in a three-dimensional space, he can select a point on a two-dimensional plane and then drag based on the selected point to achieve the zoom operation on the object in the three-dimensional space, and the selected point is the starting position of the zoom operation.

[0086] In this embodiment, the starting position is represented by coordinates in a two-dimensional plane coordinate system (screen coordinate system). Therefore, after determining the starting position of the translation operation or zoom operation on the two-dimensional plane, the position information of the starting position in the three-dimensional space, that is, the coordinate information of the starting position in the three-dimensional space, can be calculated by using coordinate conversion.

[0087] After obtaining the position information of the starting position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated according to the camera position in the three-dimensional space and the position information of the starting position in the three-dimensional space, and then it is determined whether the target ray has an intersection with the direction axis of the object. If the target ray and the direction axis of the object have an intersection, it means that the user has selected the direction axis of the object, and the translation or scaling operation of the object can be implemented according to the direction axis with the intersection. If the target ray and the direction axis of the object do not have an intersection, it means that the user has not selected the direction axis of the object, and the translation or scaling operation of the object cannot be implemented, and the user needs to re-select the position on the two-dimensional plane.

[0088] When translating or scaling an object in three-dimensional space, the three directions in which the object can be operated, namely the three directional axes, are calculated based on the object itself. Figure 3 As shown. The direction axis where there is an intersection is the target direction axis. For example, if the target ray and Figure 3 If the X-axis in the target direction has an intersection, then the X-axis is the target direction axis. Figure 3 If the Y axis in the target direction has an intersection, then the Y axis is the target direction axis. Figure 3 If there is an intersection between the Z axes in the image, the Z axis is the target direction axis.

[0089] After the target direction axis is determined, the object can be translated or scaled in three-dimensional space based on the orientation of the target direction axis.

[0090] Optionally, in this embodiment, the step of calculating the orientation of the target direction axis where the intersection point exists includes:

[0091] Get the quaternion of the object's orientation axis.

[0092] Calculate the orientation of the target axis based on the initial position of the target axis and the quaternion.

[0093] Among them, the quaternions of the three direction axes of the object are the same and can be directly obtained. After the quaternion is obtained, the initial position of the target direction axis is multiplied by the quaternion, and the direction of the target direction axis can be calculated.

[0094] For example, Figure 3 The initial positions of the x, y, and z axes are (1, 0, 0), (0, 1, 0), and (0, 0, 1), respectively. If the quaternion qua(x, y, z, w) is obtained, the direction of the x-axis is qua*(1, 0, 0), the direction of the y-axis is qua*(0, 1, 0), and the direction of the z-axis is qua*(0, 0, 1).

[0095] After the orientation of the target direction axis is obtained, the unit vector of the orientation of the target direction axis is the first vector of the translation operation or the scaling operation in the three-dimensional space.

[0096] In this embodiment, the translation operation and the rotation operation use different methods to obtain the first vector in the three-dimensional space. Therefore, when the operation is a rotation operation, in response to the operation on the object in the three-dimensional space, the step of obtaining the first vector of the operation in the three-dimensional space may include:

[0097] Determine the starting position of the rotation operation on the two-dimensional plane, and calculate the position information of the starting position in the three-dimensional space.

[0098] According to the position information and the camera position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated.

[0099] Determine whether the target ray intersects the direction axis of the object.

[0100] If there is an intersection, calculate the perpendicular vector of the target direction axis where the intersection exists.

[0101] The position information of the intersection point and the center position information of the object are obtained, and a third vector is calculated based on the position information of the intersection point and the center position information of the object.

[0102] The first vector is calculated based on the cross product of the perpendicular vector and the third vector.

[0103] Among them, when the user rotates an object in the three-dimensional space, it is necessary to perform corresponding operations such as clicking and dragging on the two-dimensional plane. Therefore, when the user rotates the object in the three-dimensional space, the electronic device 10 responds to the user's corresponding operation on the two-dimensional plane and determines the starting position of the rotation operation on the two-dimensional plane.

[0104] For example, when a user rotates an object in three-dimensional space, he or she can select a point on a two-dimensional plane and then drag the selected point to rotate the object in three-dimensional space, and the selected point is the starting position of the rotation operation.

[0105] In this embodiment, the starting position of the rotation operation is also represented by the coordinates in the coordinate system of the two-dimensional plane (screen coordinate system). Therefore, after determining the starting position of the rotation operation on the two-dimensional plane, the position information of the starting position of the rotation operation in the three-dimensional space, that is, the coordinate information in the three-dimensional space, can be calculated by using coordinate transformation.

[0106] After obtaining the position information of the starting position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated according to the camera position in the three-dimensional space and the position information of the starting position in the three-dimensional space, and then it is determined whether the target ray intersects with the direction axis of the object. If there is an intersection, it means that the user has selected the direction axis of the object, and the object can be rotated according to the direction axis with the intersection. If there is no intersection, it means that the user has not selected the direction axis of the object, and the object cannot be rotated. The user needs to re-select the position on the two-dimensional plane.

[0107] In this embodiment, when a rotation operation is performed on an object in a three-dimensional space, the direction axis of the object is drawn with the object as the center and is composed of three semicircular arcs, wherein the semicircular arc that intersects with the target ray is the target direction axis.

[0108] After the target direction axis is determined, the vertical vector of the target direction axis can be calculated based on the plane where the target direction axis is located, and then the third vector can be calculated based on the position information of the intersection point and the center position information of the object. Since the direction axis of the object is drawn with the object as the center, the center of the direction axis is the center position of the object.

[0109] After obtaining the third vector and the perpendicular vector of the target direction axis, the tangent vector of the selected position in three-dimensional space can be calculated based on the cross product of the perpendicular vector and the third vector. The tangent vector is the first vector of the rotation operation in three-dimensional space. For example, the center position information of the object is pos(x, y, z), and the position information of the intersection is pos1(x1, y1, z1). The third vector vector can be calculated based on pos1 and pos, and then the perpendicular vector of the target direction axis is vector1. The cross product of vector and vector1 is the tangent vector.

[0110] Optionally, in order to achieve free rotation of the object, in this embodiment, a sphere composed of three semicircular arcs can be used, with the center of the sphere being the center of the object. The free rotation of the object can be achieved by rotating the sphere. When a position is randomly selected on the sphere and then dragged in the desired direction, the object will rotate accordingly.

[0111] During the free rotation process, the starting position and the end position of the free rotation operation on the two-dimensional plane can be determined, and an operation vector is calculated based on the starting position and the end position, and then the operation vector is converted into three-dimensional space to obtain the fourth vector corresponding to the operation vector in three-dimensional space. At the same time, the position information of the starting position in three-dimensional space is calculated, and according to the camera position in three-dimensional space and the position information of the starting position in three-dimensional space, a target ray with the camera position as the starting point and passing through the position information is calculated, and when there is an intersection between the target ray and the sphere, the fifth vector is calculated based on the intersection position and the center position of the object, and the sixth vector is calculated based on the center position of the object and the position information of the starting position in three-dimensional space. The vertical vector is calculated based on the cross product of the sixth vector and the fourth vector, and then the tangent vector of the point selection position in three-dimensional space is calculated based on the cross product of the fifth vector and the vertical vector. The tangent vector is the first vector of the free rotation operation in three-dimensional space.

[0112] After obtaining the first vector, the first vector may be converted to a two-dimensional plane to obtain a second vector of the first vector in the two-dimensional plane.

[0113] Optionally, the step of converting the first vector to a two-dimensional plane to obtain a second vector of the first vector in the two-dimensional plane includes:

[0114] The transformation matrix is ​​calculated based on the world matrix, observation matrix and projection matrix.

[0115] The viewport matrix is ​​obtained, and the viewport pixel coordinates of the first vector in the viewport pixel coordinate system are calculated according to the transformation matrix and the viewport matrix.

[0116] The viewport pixel coordinates are converted to the coordinate system of the two-dimensional plane to obtain the second vector of the viewport pixel coordinates in the two-dimensional plane.

[0117] Among them, the world matrix, observation matrix, projection matrix and viewport matrix can be directly obtained by calling the interface, and the transformation matrix can be calculated by multiplying the world matrix, observation matrix and projection matrix.

[0118] After obtaining the transformation matrix and the viewport matrix, the viewport pixel coordinates of the first vector in the viewport pixel coordinate system can be calculated using the following formula.

[0119] (x1, y1, z1, w1)=projectMatrix*modelViewMatrix*(x, y, z, 1)

[0120] X=x1 / w1, Y=y1 / w1.

[0121] Among them, (x, y, z) are the coordinates of the first vector, projectMatrix is ​​the transformation matrix, modelViewMatrix is ​​the viewport matrix, (x1, y1, z1, w1) are the calculated intermediate values, and (X, Y) are the viewport pixel coordinates.

[0122] Since the viewport pixel coordinate system is inconsistent with the coordinate system of the two-dimensional plane, after obtaining the viewport pixel coordinates, it is necessary to convert the viewport pixel coordinates into the coordinate system of the two-dimensional plane. In this embodiment, the viewport pixel coordinate system is located at the center of the screen, and the coordinate origin of the coordinate system of the two-dimensional plane is located at the upper left corner of the screen. Therefore, the conversion can be performed based on the following formula:

[0123] k1*X+b1=x', k2*Y+b2=y', conversion coefficients k1=a / 2, b1=a / 2, k2=-h / 2, b2=h / 2.

[0124] Wherein, a is the width of the screen window, h is the height of the screen window, and (x', y') is the second vector converted from the viewport pixel coordinates to the two-dimensional plane.

[0125] After the second vector is obtained, the motion information of the object in the three-dimensional space can be calculated based on the operation vector and the second vector.

[0126] Optionally, the step of obtaining an operation vector for operation in a two-dimensional plane and calculating motion information of the object in a three-dimensional space according to the second vector and the operation vector includes:

[0127] The starting position and the end position of the operation on the two-dimensional plane are determined, and the operation vector is calculated according to the starting position and the end position.

[0128] Calculates the cosine of the angle between the second vector and the operation vector.

[0129] The motion information of the object in three-dimensional space is obtained based on the cosine value calculation.

[0130] Among them, when the user operates an object in three-dimensional space, it is necessary to perform corresponding operations such as point selection and dragging on the two-dimensional plane. The point selected during the operation is the starting position, and the position at the end of the operation is the end position. For example, when the user performs an operation on an object in three-dimensional space, selects a point on the two-dimensional plane, and then drags according to the selected point. The selected point is the starting position of the operation, and the point where the drag ends is the end position of the operation. After determining the starting position and end position of the operation on the two-dimensional plane, an operation vector can be calculated based on the starting position and end position of the operation on the two-dimensional plane.

[0131] After the operation vector is calculated, the angle between the operation vector and the second vector can be calculated, thereby calculating the cosine value of the angle. After the cosine value is calculated, the motion information of the object in the three-dimensional space can be calculated according to the cosine value.

[0132] In this embodiment, the motion information includes the motion direction. Therefore, the step of calculating the motion information of the object in the three-dimensional space according to the cosine value includes:

[0133] It is determined whether the cosine value is greater than a set value. If so, it is determined that the direction of movement of the object in the three-dimensional space is the same as the direction of the second vector.

[0134] If it is less than the set value, it is determined that the direction of movement of the object in the three-dimensional space is opposite to the direction of the second vector.

[0135] In this embodiment, if Figure 4 As shown, taking the included angle of 90° as the dividing line, the set value is 0. When the included angle is greater than 90°, the cosine value is negative and less than the set value, and the object's movement direction in the three-dimensional space is opposite to the direction of the second vector. When the included angle is less than 90°, the cosine value is greater than the set value, and the object's movement direction in the three-dimensional space is the same as the direction of the second vector.

[0136] After the direction of movement of the object in the three-dimensional space is calculated, the object can be controlled to move according to the direction of movement of the object in the three-dimensional space. For example, when performing a translation operation, assuming that the cosine value of the angle between the second vector and the operation vector is less than the set value, and the direction of the second vector is the positive direction of the x-axis, the object moves in the opposite direction of the x-axis in the three-dimensional space.

[0137] The editor operation direction provided in this embodiment can obtain the movement direction of the object in three-dimensional space by calculating the angle between the second vector and the operation vector, which is simple to calculate and has high processing efficiency.

[0138] After obtaining the movement direction of the object in the three-dimensional space, it is also necessary to calculate the specific movement data of the object in the three-dimensional space. When the movement of the object in the three-dimensional space is translation, the movement data may be the movement distance. When the movement of the object in the three-dimensional space is scaling, the movement data may be scaling data. When the movement of the object in the three-dimensional space is rotation, the movement data may be the rotation angle. Therefore, the movement information provided by this embodiment also includes movement data. The step of calculating the movement information of the object in the three-dimensional space according to the cosine value may also include:

[0139] Multiply the length of the operation vector by the cosine value to get the parameter value.

[0140] According to the parameter value and the preset conversion coefficient, the motion data of the object in three-dimensional space is calculated.

[0141] In this embodiment, the conversion coefficients of different operations are different. When the operation is a translation operation, the conversion coefficient is a distance conversion coefficient. When the operation is a zoom operation, the conversion coefficient is a zoom conversion coefficient. When the operation is a rotation operation, the conversion coefficient is a rotation conversion coefficient.

[0142] After obtaining the parameter value, the corresponding conversion coefficient is selected according to the type of the current operation, and then the motion data of the object in the three-dimensional space under the current operation can be obtained according to the selected conversion coefficient.

[0143] Among them, the distance conversion coefficient can be the correlation between different parameter values ​​and movement distances. For example, the length of the operation vector is multiplied by the cosine value to obtain the parameter value a. According to the distance conversion coefficient, the movement distance b corresponding to the parameter value a can be obtained, and then the object can be translated by b in three-dimensional space. The direction of translation is determined according to the size of the cosine value. If the cosine value is greater than the set value, the translation direction is the same as the direction of the second vector. If the cosine value is less than the set value, the translation direction is opposite to the direction of the second vector.

[0144] The scaling conversion coefficient can be the association between different parameter values ​​and scaling ratios. For example, the length of the operation vector is multiplied by the cosine value to obtain the parameter value a. According to the scaling conversion coefficient, the scaling ratio c corresponding to the parameter value a can be obtained, and then the object can be scaled by c in three-dimensional space, where when the cosine value is greater than the set value, it is enlarged, and when the cosine value is less than the set value, it is reduced.

[0145] The rotation conversion coefficient can be the relationship between different parameter values ​​and rotation angles. For example, multiply the length of the operation vector by the cosine value to obtain the parameter value a. According to the rotation conversion coefficient, the rotation angle d corresponding to the parameter value a can be obtained, and then the object can be rotated d in three-dimensional space, where the direction of rotation is determined according to the size of the cosine value. If the cosine value is greater than the set value, the rotation direction is the same as the direction of the second vector. If the cosine value is less than the set value, the rotation direction is opposite to the direction of the second vector.

[0146] The editor operation method, device and electronic device provided by the embodiments of the present invention can calculate the motion information (motion direction and motion data) of the object in the three-dimensional space by converting the first vector in the three-dimensional space to a two-dimensional plane and combining it with the operation vector on the two-dimensional plane. In this way, the motion information of the object in the three-dimensional space can be calculated without dividing the area. No matter how the operation is performed, it can be converted into calculations between vectors on the two-dimensional plane, which simplifies the calculation process and is more convenient to implement.

[0147] Based on the same invention concept, please refer to Figure 5 This embodiment also provides an editor operating device 11, which is applied to Figure 1The electronic device 10 shown includes an operation response module 111 , a data conversion module 112 and a data processing module 113 .

[0148] The operation response module 111 is used to respond to an operation on an object in the three-dimensional space and obtain a first vector of the operation in the three-dimensional space.

[0149] The data conversion module 112 is used to convert the first vector into a two-dimensional plane to obtain a second vector of the first vector in the two-dimensional plane.

[0150] The data processing module 113 is used to obtain the operation vector of the operation in the two-dimensional plane, and calculate the motion information of the object in the three-dimensional space according to the second vector and the operation vector.

[0151] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the editor operating device 11 described above can refer to the corresponding process in the aforementioned method, and will not be elaborated herein.

[0152] To summarize, the editor operation method, device, and electronic device provided in the present embodiment respond to operations on objects in three-dimensional space, obtain a first vector of the operation in three-dimensional space, convert the first vector to a two-dimensional plane, obtain a second vector of the first vector in the two-dimensional plane, and then obtain an operation vector of the operation in the two-dimensional plane. The motion information of the object in three-dimensional space can be calculated based on the second vector and the operation vector. In this way, the motion information of the object in three-dimensional space can be obtained based on calculations between vectors in the two-dimensional plane. There is no need to divide the area, which simplifies the calculation process and is more convenient to implement.

[0153] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. An editor operation method, characterized in that: The method comprises: In response to an operation on an object in a three-dimensional space, obtaining a first vector of the operation in the three-dimensional space; Convert the first vector to a two-dimensional plane to obtain a second vector of the first vector on the two-dimensional plane; Acquire an operation vector of the operation in the two-dimensional plane, and calculate motion information of the object in the three-dimensional space according to the second vector and the operation vector; The operation includes a translation operation or a scaling operation; and the step of obtaining a first vector of the operation in the three-dimensional space in response to the operation on the object in the three-dimensional space includes: Determine a starting position of the translation operation or the scaling operation on the two-dimensional plane, and calculate position information of the starting position in the three-dimensional space; According to the position information and the camera position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated; Determine whether the target ray intersects the direction axis of the object; If the intersection point exists, the orientation of the target direction axis where the intersection point exists is calculated, and the first vector is obtained according to the unit vector of the orientation.

2. The editor operation method according to claim 1, characterized in that: The step of calculating the orientation of the target direction axis where the intersection point exists comprises: Get the quaternion of the direction axis of the object; The orientation of the target direction axis is calculated according to the initial position of the target direction axis and the quaternion.

3. The editor operation method according to claim 1, characterized in that: The operation includes a rotation operation, and the step of obtaining a first vector of the operation in the three-dimensional space in response to the operation on the object in the three-dimensional space includes: Determine a starting position of the rotation operation on the two-dimensional plane, and calculate position information of the starting position in the three-dimensional space; According to the position information and the camera position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated; Determine whether the target ray intersects the direction axis of the object; If the intersection point exists, calculating a perpendicular vector of the target direction axis where the intersection point exists; Acquire the position information of the intersection point and the center position information of the object, and calculate a third vector according to the position information of the intersection point and the center position information of the object; The first vector is calculated based on the cross product of the vertical vector and the third vector.

4. The editor operation method according to any one of claims 1 to 3, characterized in that: The step of converting the first vector to a two-dimensional plane to obtain a second vector of the first vector on the two-dimensional plane comprises: According to the world matrix, observation matrix and projection matrix, the transformation matrix is ​​calculated; Obtaining a viewport matrix, and calculating the viewport pixel coordinates of the first vector in a viewport pixel coordinate system according to the transformation matrix and the viewport matrix; The viewport pixel coordinates are converted into the coordinate system of the two-dimensional plane to obtain a second vector of the viewport pixel coordinates in the two-dimensional plane.

5. The editor operation method according to claim 1, characterized in that: The step of obtaining the operation vector of the operation in the two-dimensional plane and calculating the motion information of the object in the three-dimensional space according to the second vector and the operation vector comprises: Determine a starting position and an end position of the operation on the two-dimensional plane, and calculate an operation vector according to the starting position and the end position; Calculating a cosine value of an angle between the second vector and the operation vector; The motion information of the object in the three-dimensional space is obtained according to the cosine value calculation.

6. The editor operation method according to claim 5, characterized in that: The motion information includes a motion direction, and the step of calculating the motion information of the object in the three-dimensional space according to the cosine value includes: Determine whether the cosine value is greater than a set value, and if so, determine that the moving direction of the object in the three-dimensional space is the same as the direction of the second vector; If it is less than the set value, it is determined that the moving direction of the object in the three-dimensional space is opposite to the direction of the second vector.

7. The editor operation method according to claim 6, characterized in that: The motion information also includes motion data, and the step of calculating the motion information of the object in the three-dimensional space according to the cosine value includes: Multiply the length of the operation vector by the cosine value to obtain a parameter value; The motion data of the object in the three-dimensional space is calculated according to the parameter value and the preset conversion coefficient.

8. An editor operating device, characterized in that: The device includes an operation response module, a data conversion module and a data processing module; The operation response module is used to respond to an operation on an object in a three-dimensional space and obtain a first vector of the operation in the three-dimensional space; the operation includes a translation operation or a scaling operation; The operation response module is used to determine the starting position of the translation operation or the scaling operation on the two-dimensional plane, and calculate the position information of the starting position in the three-dimensional space; According to the position information and the camera position in the three-dimensional space, a target ray starting from the camera position and passing through the position information is calculated; and whether the target ray intersects with the direction axis of the object; If the intersection point exists, the orientation of the target direction axis where the intersection point exists is calculated, and the first vector is obtained according to the unit vector of the orientation; the data conversion module is used to convert the first vector to a two-dimensional plane to obtain a second vector of the first vector in the two-dimensional plane; The data processing module is used to obtain the operation vector of the operation in the two-dimensional plane, and calculate the motion information of the object in the three-dimensional space according to the second vector and the operation vector.

9. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the editor operation method described in any one of claims 1 to 7 when executing the computer program.

Citation Information

Patent Citations

  • Tri-dimensional application program convex mirror effect simulation method

    CN101149841A

  • Multipurpose six-legged robot remote control system based on Xtion device

    CN107085422A

  • Mobile terminal-based three-dimensional virtual earth interaction method

    CN107506038A

  • 3D transform processing method, device, electronic device and storage medium

    CN109544702A

  • Spatial labeling method based on SLAM

    CN111009038A