CN110716683A - Generation method, device and equipment of collision object - Google Patents

Generation method, device and equipment of collision object Download PDF

Info

Publication number
CN110716683A
CN110716683A CN201910935841.4A CN201910935841A CN110716683A CN 110716683 A CN110716683 A CN 110716683A CN 201910935841 A CN201910935841 A CN 201910935841A CN 110716683 A CN110716683 A CN 110716683A
Authority
CN
China
Prior art keywords
collision
information
collision object
touch point
touch
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910935841.4A
Other languages
Chinese (zh)
Other versions
CN110716683B (en
Inventor
王正威
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Internet Security Software Co Ltd
Original Assignee
Beijing Kingsoft Internet Security Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Internet Security Software Co Ltd filed Critical Beijing Kingsoft Internet Security Software Co Ltd
Priority to CN201910935841.4A priority Critical patent/CN110716683B/en
Publication of CN110716683A publication Critical patent/CN110716683A/en
Application granted granted Critical
Publication of CN110716683B publication Critical patent/CN110716683B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/04845Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range for image manipulation, e.g. dragging, rotation, expansion or change of colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
    • G06F3/0488Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the invention provides a method, a device and equipment for generating a collision object. The method for generating the collision object comprises the steps of acquiring touch point information of a plurality of touch points generated on a touch screen and width information of lines used for drawing the object when a generation instruction of the collision object is detected; obtaining shape information of the collision object based on the width information and the touch point information; and generating a collision object corresponding to the shape information by using a preset physical engine. The scheme can generate the self-defined collision object.

Description

Generation method, device and equipment of collision object
Technical Field
The present invention relates to the field of virtual object generation technologies, and in particular, to a method, an apparatus, and a device for generating a collision object.
Background
In order to improve the sense of realism of the virtual scene, the same phenomenon as the physical phenomenon of the real world may be realized in the virtual scene. For example, rigid body collision between a virtual object and another virtual object can be realized in virtual scenes such as electronic games and desktop backgrounds of mobile terminals. For example, a collision between a ball and a club in a virtual table game, a collision between a fruit and the ground in a table background of a mobile terminal, and the like are rigid body collisions. Wherein, the virtual object which initiates the collision can be regarded as the target object, and the other virtual object which the target object collides with can be regarded as the collision object.
In the related art, rigid body collision may be implemented in a virtual scene using a physical engine. The physical engine is a component for simulating a physical phenomenon in a virtual scene based on a real world physical law. However, when a rigid body collision of a virtual object is realized by using a physical engine, the collision object is often a fixed virtual object owned by the physical engine, for example, a sphere, a cuboid, a wheel, and the like, so that a user cannot customize the collision object. Therefore, how to generate a customized collision object in the rigid body collision of the virtual scene is an urgent problem to be solved.
Disclosure of Invention
The embodiment of the invention aims to provide a method, a device and equipment for generating a collision object, so as to realize the effect of generating a self-defined collision object in rigid body collision of a virtual scene. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a method for generating a collision object, which is applied to an electronic device connected in communication with a touch screen, and the method includes:
when a generation instruction of a collision object is detected, acquiring touch point information of a plurality of touch points generated on the touch screen and width information of lines used for drawing the object;
obtaining shape information of the collision object based on the width information and the touch point information;
and generating a collision object corresponding to the shape information by using a preset physical engine.
Optionally, the touch point information includes: the position coordinates of the touch point on the touch screen;
the obtaining shape information of the colliding object based on the width information and the touch point information includes:
calculating the length of a connecting line between two adjacent touch points in the plurality of touch points by using the position coordinates of each touch point;
for each connecting line length, determining a rectangular area which takes the connecting line length as the length and the width information as the width;
for each rectangular area, acquiring vertex coordinates of four vertexes of the rectangular area by using the width information and the position coordinates of the two touch points for acquiring the rectangular area;
the obtained coordinates of the vertices of all the rectangular areas are used as the shape information of the colliding object.
Optionally, after the generating, by using a preset physics engine, a collision object corresponding to the shape information, the method further includes:
inputting the object identification of the collision object into a collision attribute interface of a rigid body component of the physical engine, and adding collision attributes to the collision object; the collision attribute is an attribute that affects a collision effect of the rigid body collision.
Optionally, the acquiring touch point information of a plurality of touch points generated on the touch screen includes:
and reading the touch point information of the plurality of touch points meeting the preset touch point interval condition from the plurality of touch point information recorded by the electronic equipment by using a preset script.
Optionally, the number of the collision objects is multiple;
after the generating, by the preset physics engine, the collision object corresponding to the shape information, the method further includes:
for each collision object, obtaining the priority of the collision object according to a preset priority rule and/or the generation sequence of the collision object;
and aiming at each collision object, searching the object identification corresponding to the priority of the collision object from the corresponding relation between the prestored object identification and the priority, and marking the searched object identification for the collision object.
In a second aspect, an embodiment of the present invention provides an apparatus for generating an impact object, which is applied to an electronic device communicatively connected to a touch screen, and includes:
the touch point information acquisition module is used for acquiring touch point information of a plurality of touch points generated on the touch screen and width information of lines used for drawing an object when a generation instruction of a collision object is detected;
the shape information acquisition module is used for acquiring the shape information of the collision object based on the width information and the touch point information;
and the collision object generation module is used for generating a collision object corresponding to the shape information by using a preset physical engine.
Optionally, the touch point information includes: the position coordinates of the touch point on the touch screen;
the shape information acquisition module is specifically configured to:
calculating the length of a connecting line between two adjacent touch points in the plurality of touch points by using the position coordinates of each touch point;
for each connecting line length, determining a rectangular area which takes the connecting line length as the length and the width information as the width;
for each rectangular area, acquiring vertex coordinates of four vertexes of the rectangular area by using the width information and the position coordinates of the two touch points for acquiring the rectangular area;
the obtained coordinates of the vertices of all the rectangular areas are used as the shape information of the colliding object.
Optionally, the apparatus further comprises: a collision attribute adding module to:
after the collision object generating module generates a collision object corresponding to the shape information by using a preset physical engine, inputting an object identifier of the collision object into a collision attribute interface of a rigid body component of the physical engine, and adding a collision attribute to the collision object; the collision attribute is an attribute that affects a collision effect of the rigid body collision.
Optionally, the touch point information obtaining module is specifically configured to:
and reading the touch point information of the plurality of touch points meeting the preset touch point interval condition from the plurality of touch point information recorded by the electronic equipment by using a preset script.
Optionally, the number of the collision objects is multiple;
the device further comprises: a collision object management module to:
after the collision object generating module generates a collision object corresponding to the shape information by using a preset physical engine, for each collision object, obtaining the priority of the collision object according to a preset priority rule and/or the generation order of the collision object;
and aiming at each collision object, searching the object identification corresponding to the priority of the collision object from the corresponding relation between the prestored object identification and the priority, and marking the searched object identification for the collision object.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
the system comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the bus; a memory for storing a computer program; a processor for executing the program stored in the memory to implement the steps of the collision object generation method provided by the first aspect.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the generation method of the collision object provided in the first aspect.
In the scheme provided by the embodiment of the invention, when a generation instruction of a collision object is detected, touch point information of a plurality of touch points generated on a touch screen and width information of lines used for drawing the object are acquired; further, based on the width information and the touch point information, shape information of the colliding object is obtained, and the colliding object corresponding to the shape information is generated. Therefore, the collision object with the shape corresponding to the track formed by the touch points is generated by using the touch point information of the touch screen, and the collision object can be ensured to have the shape customized by the touch points and is not limited to the self-fixed shape of the physical engine. Therefore, the scheme can generate the self-defined collision object in the rigid body collision of the virtual scene.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a schematic flow chart of a method for generating an impact object according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a collision object generation method according to another embodiment of the present invention;
FIG. 3 is a diagram illustrating an example of a collision object in the collision object generation method according to another embodiment of the present invention;
FIG. 4 is another exemplary diagram of an impact object in a method for generating an impact object according to another embodiment of the present invention;
fig. 5 is a schematic structural diagram of a collision object generation device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
First, a method of generating a collision object according to an embodiment of the present invention will be described.
The generation method of the collision object provided by the embodiment of the invention can be applied to electronic equipment in communication connection with the touch screen. The touch screen may be included on the electronic device or may be independent of the electronic device. In a specific application, the electronic device may be various, and specifically, the electronic device may include a desktop computer, a portable computer, an internet television, an intelligent mobile terminal, a server, a wearable intelligent terminal, and the like, which are not limited herein, and any electronic device that can implement the embodiment of the present invention belongs to the protection scope of the embodiment of the present invention.
As shown in fig. 1, a flow of a method for generating a collision object according to an embodiment of the present invention may include:
s101, when a generation instruction of a collision object is detected, touch point information of a plurality of touch points generated on a touch screen and width information of a line used for drawing the object are acquired.
In a particular application, the generation instruction of the impact object may be various. By way of example, the generating instructions for the impacting object may include: information for indicating the start of a virtual game, information for indicating the opening of a table rigid body collision special effect, and the like. Also, the detection method of the generation instruction of the virtual object may be various. For example, a client having a collision object generation requirement may be monitored for generating a collision object generation instruction. The client having the collision object generation requirement may specifically be an electronic device as an execution subject of the present invention, or an App (Application program). Alternatively, it may be detected whether a generation instruction of the impact object is received, for example.
The touch points generated on the touch screen may be specifically points generated on the touch screen by the touch and sliding of a finger in the process that the finger slides on the screen until the finger leaves the touch screen when the finger touches the screen. The touch point information is information indicating a position of the touch point on the touch screen, for example, a position coordinate of the touch point on the touch screen. The manner of acquiring the touch point information of the plurality of touch points generated on the touch screen may be various. For example, the touch point information of a plurality of touch points may be read from the electronic device by using a preset script, or the touch point information of a plurality of touch points transmitted by the touch screen through the communication connection may be received.
The collision object is a virtual object, and a line is required for generating the collision object. Therefore, it is necessary to acquire width information of a line used when drawing an object. The width information of the line used when drawing the object may be obtained in various ways. For example, the line width of the collision rigid body in the physics engine may be read as the width information. Alternatively, for example, when the physical engine is included in the game engine, the width of a line used by a built-in drawing component of the game engine may be used as the width information.
Any means of generating an instruction to collide with an object, generating an instruction to detect a collision object, and acquiring touch point information and width information of a line used when drawing an object may be used in the present invention, which is not limited in this embodiment.
S102, obtaining the shape information of the collision object based on the width information and the touch point information.
In specific application, the touch point information of a plurality of touch points can indicate a sliding track of a finger on the touch screen, and the sliding track can reflect the user-defined requirement of a user on a collision object; in addition, it is necessary to use a line having a line width equal to the width information when generating the virtual object. Therefore, in order to ensure that a custom collision object is subsequently generated, shape information of the collision object may be obtained based on the width information and the touch point information.
For easy understanding and reasonable layout, the following embodiment of fig. 2 of the present invention specifically describes a process for obtaining shape information of an impact object based on the width information and the touch point information.
And S103, generating a collision object corresponding to the shape information by using a preset physical engine.
In a specific application, the physics engine is a component for simulating a physical phenomenon in a virtual scene based on a real-world physical law, and the physical engine can be various. Illustratively, the physics Engine may be a physics Engine in a game Engine, hawok, a PhysX physics Engine, and ODE (Open Dynamics Engine), among others. The physical engine can simulate physical phenomena in a virtual scene, and the collision object is a virtual object for generating the physical phenomena of rigid body collision with a certain target object; therefore, in order to facilitate the subsequent rigid body collision and improve the generation efficiency of the collision object, the collision object corresponding to the shape information may be generated by using a preset physical engine.
The generating of the collision object corresponding to the shape information by using the preset physical engine may specifically include: and transmitting the shape information into a preset physical engine so that the physical engine generates a collision object corresponding to the shape information. Also, the collision object corresponding to the shape information may be various. For example, the collision object corresponding to the shape information may be a collision object having a shape reflected by the shape information and the same size as the shape. For example, the shape reflected by the shape information is a pentagon, the shape of the collision object is the same as the shape, and the size is the same as the pentagon reflected by the shape information. Alternatively, the collision object corresponding to the shape information may be, for example, a collision object having a shape reflected by the shape information and having a size adapted to the size of the display window. The physical engine can adjust the size of the collision object according to a preset reduction or enlargement ratio, wherein the preset reduction or enlargement ratio is a ratio set according to the size of the display window.
In the scheme provided by the embodiment of the invention, when a generation instruction of a collision object is detected, touch point information of a plurality of touch points generated on a touch screen and width information of lines used for drawing the object are acquired; further, based on the width information and the touch point information, shape information of the colliding object is obtained, and the colliding object corresponding to the shape information is generated. Therefore, the collision object with the shape corresponding to the track formed by the touch points is generated by using the touch point information of the touch screen, and the collision object can be ensured to have the shape customized by the touch points and is not limited to the self-fixed shape of the physical engine. Therefore, the scheme can generate the self-defined collision object in the rigid body collision of the virtual scene.
Optionally, after the collision object corresponding to the shape information is generated by using the preset physics engine, the method for generating a collision object according to the embodiment of the present invention may further include the following steps:
inputting the object identification of the collision object into a collision attribute interface of a rigid body component of a physical engine, and adding collision attributes to the collision object; the collision property is a property that affects the collision effect of a rigid body collision.
The collision attribute added to the colliding object is an attribute that can affect the collision effect of the rigid body collision, and the attribute may be various. Exemplary collision attributes may include: the collision elasticity, whether the collision is influenced by gravity, the friction coefficient and the like. The rigid body component of the physics engine provides different impact property interfaces for use corresponding to different impact properties. Therefore, according to the specific requirement for the collision attribute, the object identifier of the collision object can be input into the corresponding collision attribute interface, so that the collision attribute corresponding to the collision attribute interface is added to the collision rigid body with the object identifier.
In this optional embodiment, a collision attribute interface of a rigid body component of the physical engine is used to add a collision attribute to a collision object, and when a customized collision object is generated, the diversity of collision effects can be increased by adding the collision attribute.
Optionally, the number of the collision objects is multiple;
after the collision object corresponding to the shape information is generated by using the preset physics engine, the method for generating a collision object according to the embodiment of the present invention may further include the following steps:
for each collision object, obtaining the priority of the collision object according to a preset priority rule and/or the generation sequence of the collision object;
and aiming at each collision object, searching the object identification corresponding to the priority of the collision object from the corresponding relation between the prestored object identification and the priority, and marking the searched object identification for the collision object.
The preset priority rule may be a rule for defining an order in which the plurality of colliding objects collide with the rigid body. For example, in a fishing game, the preset priority rules may include: in a rigid body collision with the water surface, the priority of the fishhook is higher than that of the fish: the fishhook firstly collides with the water surface in a rigid body mode, and then the fish collides with the water surface in a rigid body mode. When the priorities of the collision objects are obtained, the priorities of different collision objects can be determined according to a preset priority rule. Alternatively, the order of generation of the colliding objects is regarded as the priority of the colliding objects. Alternatively, the priority of the colliding object may include: the priority of rigid body collision and the hierarchy of storage, wherein the hierarchy of storage is used for indicating the depth of the collision object in the storage directory, and the highest hierarchy is stored in the root directory. At this time, the priority for performing a rigid body collision may be determined for the colliding object according to a preset priority rule, and the hierarchy for storing may be determined for the colliding object according to the generation order of the colliding object.
Illustratively, the correspondence between the pre-stored object identifiers and the priorities includes: the object identification CO1 corresponds to the priority CP1, and the object identification CO2 corresponds to the priority CP 2. In the virtual fishing game, the priority of the collision object fish hook is priority CP1, and the priority of the collision object fish is priority CP 2. Thus, object CO1 is marked for the collision object fish hook and object CO2 is marked for the collision object fish. In managing the colliding object, since the priority is associated with the mark of the colliding object, the colliding object fish hook having the object mark CO1 may collide with the rigid body of the water surface first, and then the colliding object fish having the object mark CO2 may collide with the water surface.
In the present alternative embodiment, in managing a plurality of collision objects, the priorities of the collision objects are directly associated with the identifications of the collision objects. Based on the above, when the collision objects are managed at each time, the collision objects can be directly managed according to the identifiers, so that the increase of the searching times caused by searching the priorities according to the identifiers is reduced when the identifiers of the collision objects are only used for distinguishing different collision objects, and the management efficiency of a plurality of collision objects is improved.
As shown in fig. 2, a flow of a generation method of a collision object according to another embodiment of the present invention may include:
s201, when a generation instruction of a collision object is detected, touch point information of a plurality of touch points generated on the touch screen and width information of a line used for drawing the object are acquired. Wherein the touch point information includes: the position coordinates of the touch point on the touch screen.
The above S201 is similar to S101 of the embodiment of fig. 1 of the present invention, except that the touch point information in S201 includes: the position coordinates of the touch point on the touch screen. For the same parts, detailed description is omitted here, and the detailed description is given in the above description of the embodiment of fig. 1 of the present invention.
S202, calculating the length of a connecting line between two adjacent touch points in the plurality of touch points by using the position coordinates of each touch point.
In a specific application, the position coordinate of each touch point is the coordinate of the touch point in a two-dimensional coordinate system of the touch screen, and in a plurality of touch points, two adjacent touch points are touch points with adjacent position coordinates. Therefore, the position coordinates of two adjacent touch points can be input into a distance formula between the two touch points, and the connecting line length between the two adjacent touch points can be obtained.
S203, for each link length, determining a rectangular area with the link length as long and the width information as wide.
And S204, aiming at each rectangular area, obtaining vertex coordinates of four vertexes of the rectangular area by using the width information and the position coordinates of the two touch points for obtaining the rectangular area.
And S205, taking the vertex coordinates of all the obtained rectangular areas as the shape information of the collision object.
For example, as shown in fig. 3, in an application scenario in which a target object 301 is caused to fall into a prop 303 by colliding with a rigid body of a collision object 302, the collision object 302 may be regarded as a virtual object obtained by connecting position coordinates of a plurality of touch points. Also, since the line used for the link has a width, it is necessary to determine a rectangular region having the link length as a long length and the width information as a wide width for each link length by step S203 after calculating the link length between two adjacent touch points among the plurality of touch points by step S202. For example, the enlarged outline of a part 3021 of the impact body 302 is a rectangular area in which the link length is long and the width information is wide.
After the plurality of rectangular regions are determined, the shape of the collision object to be finally generated is defined due to the vertex coordinates of the four vertices of each rectangular region; therefore, in order to obtain the shape information of the collision object, the vertex coordinates of the four vertices of each rectangular region may be obtained by step S204 using the width information and the position coordinates of the two touch points used to obtain the rectangular region; further in step S205, the obtained vertex coordinates of all the rectangular regions are taken as the shape information of the colliding object. In order to facilitate understanding of a specific manner of acquiring the coordinates of the four vertices of the rectangular area, the rectangular area 3021 will be described as an example.
In the rectangular area 3021, the touch point t1 and the touch point t2 are located at the middle position of the width of the rectangle, and the length of the rectangle is the link length obtained in step S202. Therefore, the abscissa in the position coordinates of the touch point t1 may be taken as the abscissas of the two vertexes near the touch point t1, and the difference between the ordinate in the position coordinates of the touch point t1 and one-half of the width information may be taken as the ordinate of the lower vertex in the two vertexes near the touch point t 1; the sum of the ordinate in the position coordinate of the touch point t2 and one-half of the width information is taken as the ordinate of the upper vertex of the two vertices near the touch point t 1. Similarly, the vertex coordinates of two vertices near the touch point t2 can be obtained in the same manner using the position coordinates and the width information of the touch point t 2.
And S206, generating a collision object corresponding to the shape information by using a preset physical engine.
S206 is the same as S103 in the embodiment of fig. 1, and is not repeated herein, for details, see the description of the embodiment of fig. 1.
In the embodiment of fig. 2 of the present invention, the shape information of the collision object is determined by using a plurality of rectangular areas related to the width information of the touch points and the lines used in drawing the object, so that the generation of the custom collision object is realized.
Optionally, the obtaining of the touch point information of the multiple touch points generated on the touch screen specifically includes the following steps:
and reading touch point information of a plurality of touch points meeting a preset touch point interval condition from a plurality of touch point information recorded by the electronic equipment by using a preset script.
The preset touch point interval condition is a condition for ensuring that the interval distance between every two adjacent touch points on the touch screen is equal to the preset distance in the plurality of touch points corresponding to the read touch point information.
In specific application, the larger the number of touch point information is, the smoother the lines on the collision object generated based on the touch point information are relatively; the smaller the number of touch point information is, the more obvious the crease exists in the line on the collision object generated based on the touch point information later. For example, as shown in fig. 4, in an application scenario where a customized collision object 402 performs a rigid body collision with a virtual apple 401 as a target object, so that a collision effect of the virtual apple 401 by the rigid body collision falls into the mouth of a virtual animal 403, on the collision object 402, the number of touch point information corresponding to a line 4021 is smaller than that of touch point information corresponding to a line 4022, and therefore, a fold of the line 4021 is more obvious than that of the line 4022, and the line 4022 is relatively smooth. In the preset touch point interval condition, the larger the preset distance is, the less the read touch point information is, and the smaller the preset distance is, the more the read touch point information is.
Therefore, corresponding to the above-described case, when it is necessary to improve the generation efficiency of the colliding object, the amount of calculation can be reduced by setting a relatively large preset distance to acquire a relatively small number of pieces of touch point information. When the attractiveness of the collision object needs to be improved, the preset distance which is relatively small can be set to acquire the touch point information of a relatively large number, so that the smoothness of lines on the collision object is improved. In addition, in the optional embodiment, the preset script is used for acquiring the touch point information, so that the acquisition function of the touch point information and the generation function of the collision object can be decoupled, and the generation stability of the collision object can be ensured.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a generation apparatus for a collision object.
As shown in fig. 5, an apparatus for generating an impact object according to an embodiment of the present invention is applied to an electronic device communicatively connected to a touch screen, and the apparatus may include:
a touch point information obtaining module 501, configured to obtain touch point information of multiple touch points generated on the touch screen and width information of a line used when drawing an object when a generation instruction of a collision object is detected;
a shape information obtaining module 502, configured to obtain shape information of the collision object based on the width information and the touch point information;
and a collision object generating module 503, configured to generate a collision object corresponding to the shape information by using a preset physics engine.
In the scheme provided by the embodiment of the invention, when a generation instruction of a collision object is detected, touch point information of a plurality of touch points generated on a touch screen and width information of lines used for drawing the object are acquired; further, based on the width information and the touch point information, shape information of the colliding object is obtained, and the colliding object corresponding to the shape information is generated. Therefore, the collision object with the shape corresponding to the track formed by the touch points is generated by using the touch point information of the touch screen, and the collision object can be ensured to have the shape customized by the touch points and is not limited to the self-fixed shape of the physical engine. Therefore, the scheme can generate the self-defined collision object in the rigid body collision of the virtual scene.
Optionally, the touch point information includes: the position coordinates of the touch point on the touch screen;
the shape information obtaining module 502 is specifically configured to:
calculating the length of a connecting line between two adjacent touch points in the plurality of touch points by using the position coordinates of each touch point;
for each connecting line length, determining a rectangular area which takes the connecting line length as the length and the width information as the width;
for each rectangular area, acquiring vertex coordinates of four vertexes of the rectangular area by using the width information and the position coordinates of the two touch points for acquiring the rectangular area;
the obtained coordinates of the vertices of all the rectangular areas are used as the shape information of the colliding object.
Optionally, the apparatus further comprises: a collision attribute adding module to:
after the colliding object generating module 503 generates a colliding object corresponding to the shape information by using a preset physical engine, inputting an object identifier of the colliding object into a collision attribute interface of a rigid body component of the physical engine, and adding a collision attribute to the colliding object; the collision attribute is an attribute that affects a collision effect of the rigid body collision.
Optionally, the touch point information obtaining module 501 is specifically configured to:
and reading the touch point information of the plurality of touch points meeting the preset touch point interval condition from the plurality of touch point information recorded by the electronic equipment by using a preset script.
Optionally, the number of the collision objects is multiple;
the device further comprises: a collision object management module to:
after the collision object generation module 503 generates a collision object corresponding to the shape information by using a preset physical engine, for each collision object, obtaining the priority of the collision object according to a preset priority rule and/or the generation order of the collision object;
and aiming at each collision object, searching the object identification corresponding to the priority of the collision object from the corresponding relation between the prestored object identification and the priority, and marking the searched object identification for the collision object.
Corresponding to the above embodiment, an embodiment of the present invention further provides an electronic device, as shown in fig. 6, where the electronic device may include:
the system comprises a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602 and the memory complete mutual communication through the communication bus 604 through the 603;
a memory 603 for storing a computer program;
the processor 601 is configured to implement the steps of any one of the above-described embodiments of the collision object generation method applied to the electronic device communicatively connected to the touch screen when executing the computer program stored in the memory 603.
It is understood that in a specific application, the electronic device in the present embodiment is communicatively connected to the touch screen.
In the scheme provided by the embodiment of the invention, when a generation instruction of a collision object is detected, touch point information of a plurality of touch points generated on a touch screen and width information of lines used for drawing the object are acquired; further, based on the width information and the touch point information, shape information of the colliding object is obtained, and the colliding object corresponding to the shape information is generated. Therefore, the collision object with the shape corresponding to the track formed by the touch points is generated by using the touch point information of the touch screen, and the collision object can be ensured to have the shape customized by the touch points and is not limited to the self-fixed shape of the physical engine. Therefore, the scheme can generate the self-defined collision object in the rigid body collision of the virtual scene.
The Memory may include a RAM (Random Access Memory) or an NVM (Non-Volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
The computer-readable storage medium provided by an embodiment of the present invention is included in an electronic device, and a computer program is stored in the computer-readable storage medium, and when being executed by a processor, the computer program implements any of the steps of the above-described embodiments of the method for generating a collision object applied to the electronic device in communication connection with a touch screen.
In the scheme provided by the embodiment of the invention, when a generation instruction of a collision object is detected, touch point information of a plurality of touch points generated on a touch screen and width information of lines used for drawing the object are acquired; further, based on the width information and the touch point information, shape information of the colliding object is obtained, and the colliding object corresponding to the shape information is generated. Therefore, the collision object with the shape corresponding to the track formed by the touch points is generated by using the touch point information of the touch screen, and the collision object can be ensured to have the shape customized by the touch points and is not limited to the self-fixed shape of the physical engine. Therefore, the scheme can generate the self-defined collision object in the rigid body collision of the virtual scene.
In a further embodiment provided by the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method of generating a collision object according to any one of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in or transmitted from a computer-readable storage medium to another computer-readable storage medium, for example, from a website, computer, server, or data center, over a wired (e.g., coaxial cable, fiber optic, DSL (Digital Subscriber Line), or wireless (e.g., infrared, radio, microwave, etc.) network, to another website, computer, server, or data center, to any available medium that is accessible by a computer or that is a data storage device including one or more integrated servers, data centers, etc. the available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD (Digital Versatile Disc, digital versatile disc)), or a semiconductor medium (e.g.: SSD (Solid state disk)), etc.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the device and electronic apparatus embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference may be made to some descriptions of the method embodiments for relevant points.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A collision object generation method is applied to an electronic device connected with a touch screen in communication, and comprises the following steps:
when a generation instruction of a collision object is detected, acquiring touch point information of a plurality of touch points generated on the touch screen and width information of lines used for drawing the object;
obtaining shape information of the collision object based on the width information and the touch point information;
and generating a collision object corresponding to the shape information by using a preset physical engine.
2. The method of claim 1, wherein the touch point information comprises: the position coordinates of the touch point on the touch screen;
the obtaining shape information of the colliding object based on the width information and the touch point information includes:
calculating the length of a connecting line between two adjacent touch points in the plurality of touch points by using the position coordinates of each touch point;
for each connecting line length, determining a rectangular area which takes the connecting line length as the length and the width information as the width;
for each rectangular area, acquiring vertex coordinates of four vertexes of the rectangular area by using the width information and the position coordinates of the two touch points for acquiring the rectangular area;
the obtained coordinates of the vertices of all the rectangular areas are used as the shape information of the colliding object.
3. The method of claim 1, wherein after the generating, with a preset physics engine, a collision object corresponding to the shape information, the method further comprises:
inputting the object identification of the collision object into a collision attribute interface of a rigid body component of the physical engine, and adding collision attributes to the collision object; the collision attribute is an attribute that affects a collision effect of the rigid body collision.
4. The method according to any one of claims 1 to 3, wherein the acquiring touch point information of a plurality of touch points generated on the touch screen comprises:
and reading the touch point information of the plurality of touch points meeting the preset touch point interval condition from the plurality of touch point information recorded by the electronic equipment by using a preset script.
5. The method according to claim 1, wherein the number of the colliding object is plural;
after the generating, by the preset physics engine, the collision object corresponding to the shape information, the method further includes:
for each collision object, obtaining the priority of the collision object according to a preset priority rule and/or the generation sequence of the collision object;
and aiming at each collision object, searching the object identification corresponding to the priority of the collision object from the corresponding relation between the prestored object identification and the priority, and marking the searched object identification for the collision object.
6. An apparatus for generating an impact object, the apparatus being applied to an electronic device communicatively connected to a touch screen, the apparatus comprising:
the touch point information acquisition module is used for acquiring touch point information of a plurality of touch points generated on the touch screen and width information of lines used for drawing an object when a generation instruction of a collision object is detected;
the shape information acquisition module is used for acquiring the shape information of the collision object based on the width information and the touch point information;
and the collision object generation module is used for generating a collision object corresponding to the shape information by using a preset physical engine.
7. The apparatus of claim 6, wherein the touch point information comprises: the position coordinates of the touch point on the touch screen;
the shape information acquisition module is specifically configured to:
calculating the length of a connecting line between two adjacent touch points in the plurality of touch points by using the position coordinates of each touch point;
for each connecting line length, determining a rectangular area which takes the connecting line length as the length and the width information as the width;
for each rectangular area, acquiring vertex coordinates of four vertexes of the rectangular area by using the width information and the position coordinates of the two touch points for acquiring the rectangular area;
the obtained coordinates of the vertices of all the rectangular areas are used as the shape information of the colliding object.
8. The apparatus of claim 6, further comprising: a collision attribute adding module to:
after the collision object generating module generates a collision object corresponding to the shape information by using a preset physical engine, inputting an object identifier of the collision object into a collision attribute interface of a rigid body component of the physical engine, and adding a collision attribute to the collision object; the collision attribute is an attribute that affects a collision effect of the rigid body collision.
9. An electronic device is in communication connection with a touch screen and comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are in communication with each other through the bus; the memory is used for storing a computer program; the processor, configured to execute the program stored in the memory, to implement the method steps according to any one of claims 1-5.
10. A computer-readable storage medium, characterized in that a computer program is stored in the storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1-5.
CN201910935841.4A 2019-09-29 2019-09-29 Generation method, device and equipment of collision object Expired - Fee Related CN110716683B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910935841.4A CN110716683B (en) 2019-09-29 2019-09-29 Generation method, device and equipment of collision object

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910935841.4A CN110716683B (en) 2019-09-29 2019-09-29 Generation method, device and equipment of collision object

Publications (2)

Publication Number Publication Date
CN110716683A true CN110716683A (en) 2020-01-21
CN110716683B CN110716683B (en) 2021-03-26

Family

ID=69211177

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910935841.4A Expired - Fee Related CN110716683B (en) 2019-09-29 2019-09-29 Generation method, device and equipment of collision object

Country Status (1)

Country Link
CN (1) CN110716683B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102023786A (en) * 2009-09-23 2011-04-20 韩鼎楠 Man-machine interaction method and structure
JP2011096080A (en) * 2009-10-30 2011-05-12 Nintendo Co Ltd Object control program and object controller
CN102194248A (en) * 2011-05-05 2011-09-21 上海大学 Method for detecting and responding false-true collision based on augmented reality
US20120136757A1 (en) * 2010-11-26 2012-05-31 Taranbir Singh Chopra Methods and Systems for Operating a Virtual World
CN103853423A (en) * 2012-11-28 2014-06-11 三星电子株式会社 Method for providing user interface based on physical engine and an electronic device thereof
CN105469406A (en) * 2015-11-30 2016-04-06 东北大学 Bounding box and space partitioning-based virtual object collision detection method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102023786A (en) * 2009-09-23 2011-04-20 韩鼎楠 Man-machine interaction method and structure
JP2011096080A (en) * 2009-10-30 2011-05-12 Nintendo Co Ltd Object control program and object controller
US20120136757A1 (en) * 2010-11-26 2012-05-31 Taranbir Singh Chopra Methods and Systems for Operating a Virtual World
CN102194248A (en) * 2011-05-05 2011-09-21 上海大学 Method for detecting and responding false-true collision based on augmented reality
CN103853423A (en) * 2012-11-28 2014-06-11 三星电子株式会社 Method for providing user interface based on physical engine and an electronic device thereof
CN105469406A (en) * 2015-11-30 2016-04-06 东北大学 Bounding box and space partitioning-based virtual object collision detection method

Also Published As

Publication number Publication date
CN110716683B (en) 2021-03-26

Similar Documents

Publication Publication Date Title
CN111770047B (en) Abnormal group detection method, device and equipment
CN110096929A (en) Target detection neural network based
JP2020042773A (en) Method, device for optimizing simulation data, and storage medium
CN113010896B (en) Method, apparatus, device, medium and program product for determining abnormal object
CN105809471B (en) Method and device for acquiring user attribute and electronic equipment
WO2021253789A1 (en) Relocation effect evaluation method and apparatus, electronic device, and storage medium
CN107294974A (en) The method and apparatus for recognizing target clique
CN105531756A (en) Information processing device, information processing method, and computer program
US20170252653A1 (en) Matching method and matching system for users in game
CN109740352A (en) A kind of account processing method, device and electronic equipment
CN111047332B (en) Model training and risk identification method, device and equipment
CN112381616A (en) Item recommendation guiding method and device and computer equipment
CN113838217B (en) Information display method and device, electronic equipment and readable storage medium
CN109858402B (en) Image detection method, device, terminal and storage medium
CN110716683B (en) Generation method, device and equipment of collision object
CN110110010A (en) Data processing method and device
CN108985831B (en) Offline transaction distinguishing method and device and computer equipment
CN109444905B (en) Dynamic object detection method and device based on laser and terminal equipment
CN114924822A (en) Screenshot method and device of three-dimensional topological structure, electronic equipment and storage medium
CN112491916B (en) Vulnerability assessment method, device, equipment and storage medium
CN110569459A (en) statistical method and device for webpage information
WO2021208170A1 (en) Method and apparatus for determining target algorithm in vr scene, and computing device
CN109993529B (en) Method and device for evaluating decentralized application program and electronic equipment
CN109362027B (en) Positioning method, device, equipment and storage medium
CN106802856A (en) The performance test methods of game application, server and game application client

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20210326

CF01 Termination of patent right due to non-payment of annual fee