CN110538456A - Sound source setting method, device, equipment and storage medium in virtual environment - Google Patents

Sound source setting method, device, equipment and storage medium in virtual environment Download PDF

Info

Publication number
CN110538456A
CN110538456A CN201910849482.0A CN201910849482A CN110538456A CN 110538456 A CN110538456 A CN 110538456A CN 201910849482 A CN201910849482 A CN 201910849482A CN 110538456 A CN110538456 A CN 110538456A
Authority
CN
China
Prior art keywords
environment
boundary
sound source
target
character
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
CN201910849482.0A
Other languages
Chinese (zh)
Other versions
CN110538456B (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.)
Zhuhai Kingsoft Digital Network Technology Co Ltd
Original Assignee
Beijing Xishanju Interactive Entertainment Technology 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 Xishanju Interactive Entertainment Technology Co Ltd filed Critical Beijing Xishanju Interactive Entertainment Technology Co Ltd
Priority to CN201910849482.0A priority Critical patent/CN110538456B/en
Publication of CN110538456A publication Critical patent/CN110538456A/en
Application granted granted Critical
Publication of CN110538456B publication Critical patent/CN110538456B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/54Controlling the output signals based on the game progress involving acoustic signals, e.g. for simulating revolutions per minute [RPM] dependent engine sounds in a driving game or reverberation against a virtual wall
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/60Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/6063Methods for processing data by generating or executing the game program for sound processing
    • A63F2300/6081Methods for processing data by generating or executing the game program for sound processing generating an output signal, e.g. under timing constraints, for spatialization

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • Acoustics & Sound (AREA)
  • Stereophonic System (AREA)

Abstract

The application provides a method, a device, equipment and a storage medium for setting a sound source in a virtual environment. The method comprises the following steps: acquiring a target environment boundary and a role position; judging whether the role is in the target environment or not based on the target environment boundary and the role position; if the role is in the target environment, setting position data which are the same as the role for a virtual sound source; if the character is not in the target environment, calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance; and setting a virtual sound source according to the position data of the virtual sound source. The method, the device, the equipment and the storage medium for setting the sound source in the virtual environment can effectively improve the continuity of virtual sound source sound, effectively reduce the consumption of system calculation and greatly improve the game performance.

Description

sound source setting method, device, equipment and storage medium in virtual environment
Technical Field
the present disclosure relates to the field of internet technologies, and in particular, to a method, an apparatus, a device, and a computer-readable storage medium for setting a sound source in a virtual environment.
background
In a game, sound is one of indispensable important elements, and the rich sound configuration in the game can be brought closer to the distance between the virtual world and the real world. Different types of sounds can be configured based on different scenes, so that the sense of reality, the sense of fineness, the richness and the fit degree with the real world of the game scene can be increased.
at present, regarding sound generation setting of a game scene, a plurality of virtual sound sources matching the sound due to the position are generally set at the corresponding position in the game scene. However, this sound effect design method needs to design multiple sound sources, and needs to consider the position distribution problem among the multiple sound sources. When a character moves, the relative directional distribution between the plurality of sound sources and the character changes, and thus, the sound tends to change discontinuously. In addition, the setting of a plurality of sound sources is expensive in system calculation, and affects game performance.
disclosure of Invention
in view of the above, embodiments of the present application provide a method, an apparatus, a device, and a computer-readable storage medium for setting a sound source in a virtual environment, so as to solve technical defects in the prior art.
The embodiment of the application discloses a sound source setting method in a virtual environment, which comprises the following steps:
Acquiring a target environment boundary and a role position;
judging whether the role is in the target environment or not based on the target environment boundary and the role position;
if the role is in the target environment, setting position data which are the same as the role for a virtual sound source;
If the character is not in the target environment, calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance;
And setting a virtual sound source according to the position data of the virtual sound source.
Further, before the obtaining the target environment boundary and the role position, the method further includes:
establishing a target environment model;
The acquiring of the target environment boundary includes: and acquiring a target environment boundary according to the target environment model.
further, the acquiring the target environment boundary and the role position includes:
And acquiring the boundary of the target environment and the position of the role at regular time according to a preset time interval.
Further, the calculating a distance between the character and the boundary of the target environment and setting position data for the virtual sound source based on the calculated distance includes:
Calculating the shortest distance between the role and the boundary of the target environment;
obtaining a target position which is closest to the role on the boundary of the target environment based on the calculated shortest distance;
Setting the target position as position data of the analog sound source.
Further, the setting the target position as position data of the analog sound source includes:
in a case where the target position includes two or more positions, the same position data as any one of the target positions is set for the virtual sound source.
Further, the setting the target position as position data of the analog sound source includes:
Under the condition that the target position comprises two or more positions, converting the target environment boundary to obtain a conversion environment boundary;
and calculating the distance between the character and the boundary of the conversion environment, and setting position data for the virtual sound source based on the calculated distance.
Further, the calculating a distance between the character and the boundary of the conversion environment and setting position data for the virtual sound source based on the calculated distance includes:
calculating a shortest distance between the character and the transition environment boundary;
Based on the calculated shortest distance, obtaining a position which is closest to the role on the boundary of the conversion environment;
and setting the position closest to the character on the boundary of the conversion environment as the position data of the analog sound source.
The embodiment of the application discloses sound source setting device in virtual environment includes:
An acquisition module configured to acquire a target environment boundary and a role position;
A determining module configured to determine whether the character is in a target environment based on the target environment boundary and the character position;
if the role is in the target environment, setting position data which are the same as the role for a virtual sound source;
If the character is not in the target environment, calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance;
a setting module configured to set a virtual sound source according to the position data of the virtual sound source.
Optionally, the sound source setting apparatus in the virtual environment further includes:
an establishing module configured to establish a target environment model;
the acquisition module is specifically configured to: and acquiring a target environment boundary according to the target environment model.
Optionally, the obtaining module is further configured to:
And acquiring the boundary of the target environment and the position of the role at regular time according to a preset time interval.
Optionally, the computing module is further configured to:
calculating the shortest distance between the role and the boundary of the target environment;
obtaining a target position which is closest to the role on the boundary of the target environment based on the calculated shortest distance;
setting the target position as position data of the analog sound source.
optionally, the computing module is further configured to:
In a case where the target position includes two or more positions, the same position data as any one of the target positions is set for the virtual sound source.
optionally, the computing module is further configured to:
Under the condition that the target position comprises two or more positions, converting the target environment boundary to obtain a conversion environment boundary;
And calculating the distance between the character and the boundary of the conversion environment, and setting position data for the virtual sound source based on the calculated distance.
optionally, the computing module is further configured to:
Calculating a shortest distance between the character and the transition environment boundary;
Based on the calculated shortest distance, obtaining a position which is closest to the role on the boundary of the conversion environment;
And setting the position closest to the character on the boundary of the conversion environment as the position data of the analog sound source.
a computing device comprising a memory, a processor and computer instructions stored on the memory and executable on the processor, the processor when executing the instructions implementing the steps of a method of sound source setting in the virtual environment.
a computer readable storage medium storing computer instructions which, when executed by a processor, implement the steps of a method of setting a sound source in a virtual environment.
According to the sound source setting method, the sound source setting device, the sound source setting equipment and the computer readable storage medium in the virtual environment, the virtual sound sources in a single scene are combined into one virtual sound source, and the positions of the virtual sound sources change along with the change of the positions of the characters, so that the continuity of the sound of the virtual sound sources can be effectively improved, the consumption of system calculation is effectively reduced, and the game performance is greatly improved.
Drawings
FIG. 1 is a schematic diagram of a computer device according to an embodiment of the present application;
Fig. 2 is a schematic flowchart illustrating a method for setting a sound source in a virtual environment according to an embodiment of the present application;
Fig. 3 is a schematic flowchart illustrating a method for setting a sound source in a virtual environment according to an embodiment of the present application;
Fig. 4 is a schematic structural diagram of an audio source setting apparatus in a virtual environment according to an embodiment of the present application.
Detailed Description
in the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.
The terminology used in the description of the one or more embodiments is for the purpose of describing the particular embodiments only and is not intended to be limiting of the description of the one or more embodiments. As used in one or more embodiments of the present specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any and all possible combinations of one or more of the associated listed items.
it will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first can also be referred to as a second and, similarly, a second can also be referred to as a first without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
in the present application, a method, an apparatus, a device and a storage medium for setting a sound source in a virtual environment are provided, and detailed descriptions are individually provided in the following embodiments.
fig. 1 is a block diagram illustrating a configuration of a computing device 100 according to an embodiment of the present specification. The components of the computing device 100 include, but are not limited to, memory 110 and processor 120. The processor 120 is coupled to the memory 110 via a bus 130 and a database 150 is used to store data.
computing device 100 also includes access device 140, access device 140 enabling computing device 100 to communicate via one or more networks 160. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. Access device 140 may include one or more of any type of network interface (e.g., a Network Interface Card (NIC)) whether wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the present description, the above-described components of computing device 100 and other components not shown in FIG. 1 may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 1 is for purposes of example only and is not limiting as to the scope of the description. Those skilled in the art may add or replace other components as desired.
Computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), a mobile phone (e.g., smartphone), a wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 100 may also be a mobile or stationary server.
wherein the processor 120 may perform the steps of the method shown in fig. 2.
As shown in fig. 2, fig. 2 is a schematic flowchart illustrating a sound source setting method in a virtual environment according to an embodiment of the present application, including steps S210 to S230.
Step S210: and acquiring the boundary of the target environment and the position of the role.
In an embodiment of the present application, the target environment may be various environments in a virtual scene of interest, such as a snow mountain, a lake, a sea, a street, an amusement park, and the like, which is not limited in this application. The method for determining the target environment may be various, and the method may be determined according to whether the distance between the role and the center of the environment area is greater than a preset threshold, where the environment area does not belong to the target environment when the distance between the role and the center of the environment area is greater than the preset threshold, and the environment area belongs to the target environment when the distance between the role and the center of the environment area is less than or equal to the preset threshold; when the character moves, the scene in the game interface is continuously changed along with the movement of the character, and the environment area presented in the game interface at the same time when the position of the character is obtained or in the same frame of picture can be used as the target environment, or the target environment can be determined by other methods.
The boundary is a landmark boundary for dividing the environment region, and may be an outer contour line of the environment region of various shapes. The target environment boundary may be an outer boundary of the virtual environment model of interest in connection with the character position. The position of the character can be the place and the direction of the character.
For example, suppose that three environment areas, namely a forest, a waterfall and a street, are set in a game, a character is located among the forest environment area, the waterfall environment area and the street environment area, and the distances between the character and the forest environment area, the waterfall environment area and the street environment area are equal to each other and are smaller than a preset threshold value, the forest environment, the waterfall environment and the street environment all belong to target environments, and the boundary of the forest environment area, the boundary of the waterfall environment area and the boundary of the street environment area all belong to target environment boundaries; under the condition that the role is located between the forest environment area and the waterfall environment area and the distance between the role and the street environment area is larger than a set threshold value, the street environment does not belong to a target environment, the boundary of the street environment area does not belong to the boundary of the target environment, under the condition that the role is located at an intermediate point between the forest environment area and the waterfall environment area, the forest environment and the waterfall environment both belong to the target environment, and the boundary of the forest environment area and the boundary of the waterfall environment area are both the boundaries of the target environment.
in practical application, the target environment boundary and the role position can be obtained at regular time according to a preset time interval.
The preset time interval may be determined according to actual requirements, for example, the target environment boundary and the role position (n is an integer greater than or equal to 1) may be obtained n times per second, or the target environment boundary and the role position (x is an integer greater than or equal to 1) may be obtained once per x frames.
Step S220: and judging whether the role is in the target environment or not based on the target environment boundary and the role position, if so, executing step S221, and if not, executing step S222.
step S221: and setting the same position data as the character for the virtual sound source. After the position data identical to the character is set for the virtual sound source, the process proceeds to step S230.
Step S222: and calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance. After the position data is set for the virtual sound source, the process proceeds to step S230.
For example, a coordinate system may be established based on the target environment, a central point in the target environment is used as a coordinate origin, a target environment boundary and a role position are represented in a coordinate form, a distance between the target environment boundary and the role position is calculated, if the distance between the target environment boundary and the role position is greater than a preset value, it is determined that the role is located outside the target environment, if the distance between the target environment boundary and the role position is less than the preset value, it is determined that the role is located in the target environment, and if the distance between the target environment boundary and the role position is equal to the preset value, it is determined that the role is located on the target environment boundary. In addition, whether the role is in the target environment can be judged by other methods, and the application does not limit the method.
if the character is in the target environment, setting position data which is the same as the position data of the character for the virtual sound source, and if the character moves in the target environment, moving the virtual sound source along with the movement of the character; if the character moves from the target environment to the outside of the target environment, the virtual sound source still moves along with the movement of the character when the character is still in the target environment, the distance between the character and the target environment is calculated after the character moves to the outside of the target environment, and position data is set for the virtual sound source based on the distance between the character and the target environment.
For example, the intersection point of the character position and the target environment boundary may be obtained by taking the character position as a starting point and making any ray intersecting the target environment boundary, the linear distance between the character position and the intersection point may be calculated, and the calculated linear distance may be used as the distance between the character and the target environment. In addition, the distance between the role and the target environment can be calculated by other methods, which is not limited in the present application.
Further, a shortest distance between the character and the target environment boundary is calculated.
and obtaining the target position which is closest to the role on the boundary of the target environment based on the calculated shortest distance.
Setting the target position as position data of the analog sound source.
The method for calculating the shortest distance between the character and the boundary of the target environment may be various, for example, several rays intersecting the boundary of the target environment may be made using the position of the character as a starting point, intersection points of several rays at the position of the character and the boundary of the target environment are generated, the linear distance between the position of the character and each intersection point is calculated, the calculated shortest distance is taken as the shortest distance between the character and the target environment, and the position of the point on the boundary of the target environment, which is the shortest distance from the character, is taken as the target position. In addition, the distance between the role and the target environment can be calculated by other methods, which is not limited in the present application.
The target position is a position of a point closest to the character on the boundary of the target environment, and the target position moves with the movement of the character and changes with the change of the position of the character.
in practical applications, in a case where the target position includes two or more positions, the same position data as any one of the target positions may be set for the virtual sound source.
specifically, if two or more points closest to the character exist on the boundary of the target environment and the distances between the two or more points and the character are equal, the positions of the two or more points closest to the character are all target positions, and since the distances between the character and the two or more target positions are equal, the same position data as the position of any one of the target positions can be set for the virtual sound source, in which case, the difference in the selection of the target positions does not affect the finally presented sound effect.
for example, assuming that the target environment boundary is a concave-shaped boundary, and the concave-shaped boundary has a hidden central line which can equally divide the concave-shaped boundary into two parts, when the character moves to the hidden central line in the concave region of the concave-shaped boundary, two or more points closest to the character exist on the target environment boundary, the positions of the two or more points closest to the character on the target environment are target positions, one of the target positions is arbitrarily selected, and position data which is the same as the position of the target position is set for the virtual sound source.
Step S230: and setting a virtual sound source according to the position data of the virtual sound source.
Specifically, the virtual sound source may be a timbre resource in a virtual game scene, and the type of the sound of the virtual sound source includes multiple types, such as wind sound, rain sound, thunder sound, and the like, or a mixed sound of wind sound, rain sound, and thunder sound, which may be determined according to the target environment and the game scene, which is not limited in this application.
for example, if the target environment is a lawn, the sound of the virtual sound source may include a worm sound, a joy sound, and the like, in the case where the specific game scene is a cool lawn, the sound of the virtual sound source may be a worm sound, and in the case where the specific game scene is a lawn suitable for stepping on green and picnics, the sound of the virtual sound source may be a mixed sound of the worm sound, the laughing sound, the joy sound, and the speech sound; if the target environment is an ocean, the virtual sound source may include wind sound, sea sound, and the like, and in the case that the specific game scene is an ocean in the world of clear sky, the sound of the virtual sound source may be the sea sound, ship whistle sound, and the like, or may be a mixed sound including the sea sound and the ship whistle sound, and in the case that the specific game scene is an ocean with lightning, the sound of the virtual sound source may include a mixed sound of thunder sound, wind sound, sea sound, and the like.
If the target environment is a train station, the sound of the virtual sound source may be speech sound, whistling sound, broadcast sound, and the like, and when the specific game scene is the train station where no train arrives, the sound of the virtual sound source may include vendor sound, crowd speech sound, and station broadcast sound, and the volume ratios of the vendor sound, the crowd speech sound, and the station broadcast sound in the sound of the virtual sound source may be determined according to actual requirements, if the volume ratio of the station broadcast sound in the sound of the virtual sound source is 40%, the volume ratios of the vendor sound and the crowd speech sound in the virtual sound source are both 30%, and the present application does not limit this.
The position data of the virtual sound source may include one or more, and the virtual sound source may also include one or more, which may be determined according to the specific situation, and the present application does not limit this.
The above embodiments will be further described with reference to specific examples.
For example, if an initial character position is obtained when a character enters a game scene, and the game interface further includes four environment areas, namely a creek environment area, a pasture environment area, a bamboo forest environment area and a flower field area, under the condition that the initial character position is the center of the game interface, the creek environment area, the pasture environment area, the bamboo forest environment area and the flower field environment area are all target environment areas, and the boundary of the creek environment area, the boundary of the pasture environment area, the boundary of the bamboo forest environment area and the boundary of the flower field environment area are all target environment boundaries.
assuming that a two-dimensional coordinate system is established by using an initial character position coordinate origin, each extracted target environment boundary and character positions of different frames are represented in a coordinate form, the target environment boundary and the character positions are acquired once per frame, assuming that the obtained character positions at the 10 th frame are (x10, y10) and (x10, y10) are located in the boundary of the pasture environment area, the position data of the virtual sound source at the 10 th frame is (x10, y10), and the virtual sound source plays the boeing sound and the eweing sound of the pasture environment area. Assuming that the acquired character position of the 12 th frame is (x12, y12) and (x12, y12) is still located within the boundary of the pasture environment area, the position data of the virtual sound source in the 12 th frame is updated to (x12, y12), and the virtual sound source still plays the boating and sheep howling in the pasture environment area.
Assuming that the character position acquired at the 15 th frame is (x15, y15), (x15, y15) is not in any target environment, the shortest distance between the character position (x15, y15) and each target environment is calculated respectively, and the distance between the character position (x15, y15) and the point a (xa, ya) on the boundary of the pasture environment area is obtained to be shortest, the position data set by the virtual sound source is updated to be (xa, ya), and the virtual sound source plays the bodes and bodes of the pasture environment area. Assuming that the character position acquired at the 18 th frame is (x18, y18), (x18, y18) is not in any target environment, respectively calculating the shortest distance between the character position (x18, y18) and each target environment to obtain the shortest distance between the character position (x18, y18) and the point b (xb, yb) on the boundary of the pasture environment area, updating the position data set by the virtual sound source to be (xb, yb), and the virtual sound source still plays the cattle and sheep sounds in the pasture environment area.
assuming that the character position acquired in the 22 nd frame is (x22, y22), (x22, y22) in none of the target environments, the shortest distance between the character position (x22, y22) and each of the target environments is calculated, and the distance between the character position (x22, y22) and the point c (xc, yc) and the point d (xd, yd) on the boundary of the brook environment area is obtained, and the distance between the character position (x22, y22) and the point c (xc, yc) and the distance between the character position (x22, y22) and the point d (xd, yd) are equal, the position data of the virtual sound source may be updated to (xc, yc) or (xd, yd), and the virtual sound source plays the sound of the brook environment area.
Assuming that the obtained angular positions of the 30 th frame are (x30, y30), (x30, y30) in none of the target environments, the shortest distance between the character positions (x30, y30) and each of the target environments is calculated, respectively, and the distance between the character positions (x30, y30) and the point e (xe, ye) on the boundary of the brook environment area and the point f (xf, yf) on the boundary of the flower field environment area is shortest, and the distance between the character positions (x30, y30) and the point e (xe, ye) on the boundary of the brook environment area and the distance between the character positions (x30, y30) and the point f (xf, yf) on the boundary of the flower field environment area are equal, the stream sound source is set at the point e (xe, ye) on the boundary of the brook environment area and the point f (xf, yf) on the boundary of the flower field environment area, respectively, and the virtual sound source area of the stream sound source area at the point e (ye) is played at the same time, the virtual sound source at point f (xf, yf) plays a bird song of the flower field environment area.
assuming that the character position acquired at the 36 th frame is (x36, y36), (x36, y36) in none of the target environments, the shortest distance between the character position (x36, y36) and each target environment is calculated, respectively, and the distance between the character position (x36, y36) and the point g (xg, yg), the point h (xh, yh) on the boundary of the bamboo forest environment area and the point i (xi, yi) on the boundary of the flower field environment area is shortest, and the distance between the character position (x36, y36) and the point g (xg, yg), the point h (xh, yh) on the boundary of the bamboo forest environment area and the distance between the character position (x36, y36) and the point i (xi, yi) on the boundary of the flower field environment area are equal, a virtual sound source area boundary (xi, xi) is set at the point g (xg, yg) or the point h, yh) on the boundary of the bamboo forest environment area, yi), two virtual sound sources are played simultaneously, the virtual sound source at the point g (xg, yg) or the point h (xh, yh) plays the wind sound of the bamboo forest environment area, and the virtual sound source at the point i (xi, yi) plays the bird song of the flower field environment area.
in the sound source setting method in a virtual environment according to an embodiment of the present application, when a character is located in a target environment area, a position of a virtual sound source is the same as a position of the character and moves along with movement of the character, and when the character is located outside the target environment, the position of the virtual sound source is a position of a point on a boundary of the target environment, the point being closest to the position of the character, and moves along with movement of the character, so that continuity and clarity of sound of the virtual sound source can be effectively ensured, and discontinuous or unclear sound of the virtual sound source caused by too far distance from the position of the virtual sound source due to movement of the character is avoided, thereby improving fineness and reality of the virtual sound source in a scene, and enhancing experience of a player.
as shown in fig. 3, fig. 3 is a schematic flowchart of a sound source setting method in a virtual environment according to an embodiment of the present application, including steps S310 to S340.
Step S310: and establishing a target environment model.
the target environment may be various environmental regions in the virtual scene of interest, such as a forest, a lake, a sea, a street, a market, a bar, and the like, which is not limited in this application. Various tools such as 3D max can be selected to build the target environment model, which is not limited in this application.
Step S320: and acquiring the boundary of the target environment and the position of the role according to the target environment model.
The method for obtaining the boundary of the target environment according to the target environment model may be various methods such as edge extraction, which is not limited in the present application.
step S330: and judging whether the role is in the target environment or not based on the target environment boundary and the role position. If so, step S331 is executed, and if not, step S332 is executed.
Step S331: and setting the same position data as the character for the virtual sound source. After the position data identical to the character is set for the virtual sound source, the process proceeds to step S340.
Step S332: and calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance. After the position data is set for the virtual sound source, step S340 is continuously performed.
Further, a shortest distance between the character and the target environment boundary is calculated.
And obtaining the target position which is closest to the role on the boundary of the target environment based on the calculated shortest distance.
setting the target position as position data of the analog sound source.
under the condition that the target position comprises two or more positions, the target environment boundary can be converted to obtain a conversion environment boundary; and calculating the distance between the character and the boundary of the conversion environment, and setting position data for the virtual sound source based on the calculated distance.
Specifically, if a ray passes through the target environment boundary of the target environment model and the target environment model to generate more than two intersection points, the target environment model is a concave model; if any ray passes through the target environment boundary of the target environment model and the target environment model to generate only two intersection points, the target environment model is a convex model.
In the case where the target position includes two or more positions, the target environment model is a concave model, and when the position data of the virtual sound source is determined, the uniquely obtained target position can be obtained by conversion between the concave model and the convex model. The target environment model can be converted into a convex model, the boundary of the target environment model after being converted into the convex model is extracted through methods such as edge extraction and the like, the boundary of the conversion environment is obtained, the distance between the role and the boundary of the conversion environment is calculated, and position data is set for the virtual sound source. The method for converting the female mold into the male mold is not limited in the present application. The method for calculating the distance between the role and the transition boundary may include various methods, and refer to step S220 described above, which is not described herein again.
Further, calculating a shortest distance between the character and the transition environment boundary; based on the calculated shortest distance, obtaining a position which is closest to the role on the boundary of the conversion environment; and setting the position closest to the character on the boundary of the conversion environment as the position data of the analog sound source.
The method for calculating the shortest distance between the role and the boundary of the transformation environment includes various methods, which can refer to the step S220, and is not described herein again.
For example, after the edge extraction is performed on the target environment model, an M-type target environment boundary with a closed bottom is obtained, when the character is within the boundary of the target environment, the position data which is the same as the position of the character is configured for the virtual sound source, in the case that the character is outside the boundary of the target environment, the shortest distance between the character and the boundary of the target environment is calculated, since, in the case of a transverse ray crossing the boundary of the object environment, there are more than two intersection points between the transverse ray and the boundary of the object environment, the target environment model is a concave model, the target environment model is converted to obtain a convex model, the converted target environment model is supposed to be subjected to edge extraction to obtain a conversion environment with a rectangular boundary, the shortest distance between the character and the rectangular conversion environment boundary is calculated, and position data which is not configured for the virtual sound source at the position on the conversion boundary closest to the character is obtained.
Step S340: and setting a virtual sound source according to the position data of the virtual sound source.
The position data of the virtual sound source may include one or more virtual sound sources, and the virtual sound source may also include one or more virtual sound sources, which may be determined according to specific situations, and refer to step S230 described above, which is not described herein again.
the above embodiments are further described below with reference to specific examples.
For example, if an initial character position is obtained when a character enters a game scene, and the game interface further includes two environment regions, namely a snack street and a bar, when the initial character position is the center of the game interface, the snack street environment region and the bar environment region are both target environment regions, and the boundary of the snack street environment region and the boundary of the bar environment region are both target environment boundaries.
a two-dimensional coordinate system is established by an initial role position coordinate origin, each extracted target environment boundary and the role positions with different frame numbers are expressed in a coordinate mode, and the target environment boundary and the role positions are acquired once per frame.
Assuming that the acquired character position in the 6 th frame is (x6, y6), (x6, y6) in none of the target environments, the shortest distance between the character position (x6, y6) and each target environment is calculated, respectively, the distance between the character position (x6, y6) and the point a (xa, ya) and the point b (xb, yb) on the bar environment area boundary is obtained as the shortest, and the distance between the character position (x6, y6) and the point a (xa, ya) and the distance between the character position (x6, y6) and the point b (xb, yb) are equal, the bar environment model is converted, the conversion model is obtained, the boundary of the conversion environment is obtained, the distance between the character position (x6, y6) and the boundary of the conversion environment is calculated, the shortest distance between the character position (x6, y6) and the point c, yc on the conversion environment boundary is obtained, the position data of the virtual sound source is set to the point c (xc, yc) and the virtual sound source plays the music sound of the bar environment area.
Assuming that the character position acquired at the 18 th frame is (x18, y18), (x18, y18) in none of the target environments, the shortest distance between the character position (x18, y18) and each target environment is calculated, respectively, and the distance between the character position (x18, y18) and the point d (xd, yd) and the point e (xe, ye) on the bar environment region boundary and the distance between the character position (x18, y18) and the point d (xd, yd), the distance between the point e (xe, ye) and the distance between the point q (xq, yq) are all equal, the bar environment model is converted to obtain a conversion model, the boundary of the conversion model is acquired to obtain a conversion environment boundary, the distance between the character position (x18, y18) and the conversion environment boundary are calculated, and the character position (x 18) is acquired, y18) and the point f (xf, yf) on the boundary of the conversion environment are the shortest, then virtual sound sources are respectively set at the point f (xf, yf) on the boundary of the conversion environment of the bar environment region and at the point q (xq, yq) on the boundary of the snack street environment region to play simultaneously, and the virtual sound source at the point f (xf, yf) on the boundary of the conversion environment of the bar environment region plays the music sound of the bar environment region, and the virtual sound source at the point q (xq, yq) on the boundary of the snack street environment region plays the call sound of the snack street environment region.
In the method for setting a sound source in a virtual environment, the target environment model and the target environment boundary are converted under the condition that two or more positions closest to the character exist on the target environment boundary, so that the only position closest to the character is determined to set the virtual sound source, the accuracy of the position of the virtual sound source can be effectively improved, the sound effect of the virtual sound source is effectively improved, and better experience is brought to a player.
As shown in fig. 4, fig. 4 is a schematic structural diagram illustrating an audio source setting apparatus in a virtual environment according to an embodiment of the present application.
an audio source setting apparatus in a virtual environment, comprising:
An obtaining module 410 configured to obtain the target environment boundary and the role position.
A determining module 420 configured to determine whether the character is in the target environment based on the target environment boundary and the character position.
and if the character is in the target environment, setting the same position data as the character for the virtual sound source.
and if the character is not in the target environment, calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance.
A setting module 430 configured to set a virtual sound source according to the position data of the virtual sound source.
Optionally, the sound source setting apparatus in the virtual environment further includes:
An establishing module configured to establish a target environment model.
the obtaining module 410 is specifically configured to: and acquiring a target environment boundary according to the target environment model.
And acquiring a target environment boundary according to the target environment model.
Optionally, the obtaining module 410 is further configured to:
And acquiring the boundary of the target environment and the position of the role at regular time according to a preset time interval.
Optionally, the computing module is further configured to:
Calculating the shortest distance between the character and the boundary of the target environment.
and obtaining the target position which is closest to the role on the boundary of the target environment based on the calculated shortest distance.
setting the target position as position data of the analog sound source.
Optionally, the computing module is further configured to:
In a case where the target position includes two or more positions, the same position data as any one of the target positions is set for the virtual sound source.
Optionally, the computing module is further configured to:
And under the condition that the target position comprises two or more positions, converting the target environment boundary to obtain a conversion environment boundary.
and calculating the distance between the character and the boundary of the conversion environment, and setting position data for the virtual sound source based on the calculated distance.
optionally, the computing module is further configured to:
calculating a shortest distance between the character and the transition environment boundary.
And obtaining the position which is closest to the role on the boundary of the conversion environment based on the calculated shortest distance.
And setting the position closest to the character on the boundary of the conversion environment as the position data of the analog sound source.
The sound source setting device in the virtual environment can effectively reduce consumption of virtual sound sources to system calculation and greatly improve game performance.
an embodiment of the present application further provides a computing device, including a memory, a processor, and computer instructions stored on the memory and executable on the processor, where the processor executes the instructions to implement the following steps:
and acquiring the boundary of the target environment and the position of the role.
And judging whether the role is in the target environment or not based on the target environment boundary and the role position.
And if the character is in the target environment, setting the same position data as the character for the virtual sound source.
And if the character is not in the target environment, calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance.
And setting a virtual sound source according to the position data of the virtual sound source.
an embodiment of the present application further provides a computer-readable storage medium, which stores computer instructions, and when the instructions are executed by a processor, the steps of the sound source setting method in the virtual environment are implemented.
The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium belongs to the same concept as the technical solution of the sound source setting method in the virtual environment, and details that are not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the sound source setting method in the virtual environment.
The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
it should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The preferred embodiments of the present application disclosed above are intended only to aid in the explanation of the application. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the application and the practical application, to thereby enable others skilled in the art to best understand and utilize the application. The application is limited only by the claims and their full scope and equivalents.

Claims (16)

1. a method for setting a sound source in a virtual environment, comprising:
acquiring a target environment boundary and a role position;
Judging whether the role is in the target environment or not based on the target environment boundary and the role position;
If the role is in the target environment, setting position data which are the same as the role for a virtual sound source;
If the character is not in the target environment, calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance;
And setting a virtual sound source according to the position data of the virtual sound source.
2. The method of setting a sound source in a virtual environment according to claim 1, wherein before the obtaining the boundary of the target environment and the position of the character, the method further comprises:
Establishing a target environment model;
The acquiring of the target environment boundary includes:
and acquiring a target environment boundary according to the target environment model.
3. The method of claim 1, wherein the obtaining the boundary of the target environment and the position of the character comprises:
and acquiring the boundary of the target environment and the position of the role at regular time according to a preset time interval.
4. The method of claim 1, wherein the calculating a distance between the character and the boundary of the target environment and setting position data for the virtual sound source based on the calculated distance comprises:
Calculating the shortest distance between the role and the boundary of the target environment;
Obtaining a target position which is closest to the role on the boundary of the target environment based on the calculated shortest distance;
setting the target position as position data of the analog sound source.
5. The method of claim 4, wherein the setting the target position as the position data of the simulated sound source comprises:
In a case where the target position includes two or more positions, the same position data as any one of the target positions is set for the virtual sound source.
6. the method of claim 4, wherein the setting the target position as the position data of the simulated sound source comprises:
Under the condition that the target position comprises two or more positions, converting the target environment boundary to obtain a conversion environment boundary;
And calculating the distance between the character and the boundary of the conversion environment, and setting position data for the virtual sound source based on the calculated distance.
7. The method of claim 6, wherein the calculating a distance between the character and the boundary of the conversion environment and setting position data for the virtual sound source based on the calculated distance comprises:
calculating a shortest distance between the character and the transition environment boundary;
Based on the calculated shortest distance, obtaining a position which is closest to the role on the boundary of the conversion environment;
And setting the position closest to the character on the boundary of the conversion environment as the position data of the analog sound source.
8. An apparatus for setting a sound source in a virtual environment, comprising:
An acquisition module configured to acquire a target environment boundary and a role position;
A determining module configured to determine whether the character is in a target environment based on the target environment boundary and the character position;
If the role is in the target environment, setting position data which are the same as the role for a virtual sound source;
if the character is not in the target environment, calculating the distance between the character and the boundary of the target environment, and setting position data for the virtual sound source based on the calculated distance;
a setting module configured to set a virtual sound source according to the position data of the virtual sound source.
9. the apparatus for setting sound source in virtual environment according to claim 8, further comprising:
An establishing module configured to establish a target environment model;
The acquisition module is specifically configured to: and acquiring a target environment boundary according to the target environment model.
10. the apparatus for setting sound source in virtual environment according to claim 8, wherein said obtaining module is further configured to:
and acquiring the boundary of the target environment and the position of the role at regular time according to a preset time interval.
11. The audio source setting apparatus in a virtual environment according to claim 8, wherein the computing module is further configured to:
Calculating the shortest distance between the role and the boundary of the target environment;
Obtaining a target position which is closest to the role on the boundary of the target environment based on the calculated shortest distance;
setting the target position as position data of the analog sound source.
12. The audio source setting apparatus in a virtual environment according to claim 11, wherein the computing module is further configured to:
In a case where the target position includes two or more positions, the same position data as any one of the target positions is set for the virtual sound source.
13. the audio source setting apparatus in a virtual environment according to claim 11, wherein the computing module is further configured to:
Under the condition that the target position comprises two or more positions, converting the target environment boundary to obtain a conversion environment boundary;
And calculating the distance between the character and the boundary of the conversion environment, and setting position data for the virtual sound source based on the calculated distance.
14. The audio source setting apparatus in a virtual environment according to claim 13, wherein the computing module is further configured to:
Calculating a shortest distance between the character and the transition environment boundary;
Based on the calculated shortest distance, obtaining a position which is closest to the role on the boundary of the conversion environment;
And setting the position closest to the character on the boundary of the conversion environment as the position data of the analog sound source.
15. A computing device comprising a memory, a processor and computer instructions stored on the memory and executable on the processor, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the instructions.
16. a computer-readable storage medium storing computer instructions which, when executed by a processor, implement the steps of the method of any one of claims 1 to 7.
CN201910849482.0A 2019-09-09 2019-09-09 Sound source setting method, device and equipment in virtual environment and storage medium Active CN110538456B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910849482.0A CN110538456B (en) 2019-09-09 2019-09-09 Sound source setting method, device and equipment in virtual environment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910849482.0A CN110538456B (en) 2019-09-09 2019-09-09 Sound source setting method, device and equipment in virtual environment and storage medium

Publications (2)

Publication Number Publication Date
CN110538456A true CN110538456A (en) 2019-12-06
CN110538456B CN110538456B (en) 2023-08-08

Family

ID=68713099

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910849482.0A Active CN110538456B (en) 2019-09-09 2019-09-09 Sound source setting method, device and equipment in virtual environment and storage medium

Country Status (1)

Country Link
CN (1) CN110538456B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111135572A (en) * 2019-12-24 2020-05-12 北京像素软件科技股份有限公司 Game sound effect management method and device, storage medium and electronic equipment
CN111714889A (en) * 2020-06-19 2020-09-29 网易(杭州)网络有限公司 Sound source control method, sound source control device, computer equipment and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005046270A (en) * 2003-07-31 2005-02-24 Konami Computer Entertainment Yokyo Inc Game device, control method of computer and program
CN107281753A (en) * 2017-06-21 2017-10-24 网易(杭州)网络有限公司 Scene audio reverberation control method and device, storage medium and electronic equipment
CN107885417A (en) * 2017-11-03 2018-04-06 腾讯科技(深圳)有限公司 Object localization method, device and computer-readable recording medium in virtual environment
CN108579084A (en) * 2018-04-27 2018-09-28 腾讯科技(深圳)有限公司 Method for information display, device, equipment in virtual environment and storage medium
CN108939535A (en) * 2018-06-25 2018-12-07 网易(杭州)网络有限公司 The sound effect control method and device of virtual scene, storage medium, electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005046270A (en) * 2003-07-31 2005-02-24 Konami Computer Entertainment Yokyo Inc Game device, control method of computer and program
CN107281753A (en) * 2017-06-21 2017-10-24 网易(杭州)网络有限公司 Scene audio reverberation control method and device, storage medium and electronic equipment
CN107885417A (en) * 2017-11-03 2018-04-06 腾讯科技(深圳)有限公司 Object localization method, device and computer-readable recording medium in virtual environment
CN108579084A (en) * 2018-04-27 2018-09-28 腾讯科技(深圳)有限公司 Method for information display, device, equipment in virtual environment and storage medium
CN108939535A (en) * 2018-06-25 2018-12-07 网易(杭州)网络有限公司 The sound effect control method and device of virtual scene, storage medium, electronic equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111135572A (en) * 2019-12-24 2020-05-12 北京像素软件科技股份有限公司 Game sound effect management method and device, storage medium and electronic equipment
CN111714889A (en) * 2020-06-19 2020-09-29 网易(杭州)网络有限公司 Sound source control method, sound source control device, computer equipment and medium
CN111714889B (en) * 2020-06-19 2024-06-25 网易(杭州)网络有限公司 Sound source control method, device, computer equipment and medium

Also Published As

Publication number Publication date
CN110538456B (en) 2023-08-08

Similar Documents

Publication Publication Date Title
CN106815881B (en) A kind of color control method and device of actor model
CN106097443B (en) City indoor and outdoor integrated three-dimensional scenario building and spatially adaptive air navigation aid
CN111127624A (en) Illumination rendering method and device based on AR scene
CN107437272B (en) Interactive entertainment method and device based on augmented reality and terminal equipment
CN111670463B (en) Geometric grid simplification based on machine learning
CN109472764B (en) Method, apparatus, device and medium for image synthesis and image synthesis model training
CN110538456A (en) Sound source setting method, device, equipment and storage medium in virtual environment
CN112489171A (en) Animation effect simulation method and device
KR20210004862A (en) Method, system and non-transitory computer-readable recording medium for supporting user experience sharing
CN110070616A (en) Memory, statistical data rendering method, device and equipment based on GIS platform
CN111383349A (en) Terrain scene editing method and device, computing equipment and storage medium
CN110298925B (en) Augmented reality image processing method, device, computing equipment and storage medium
KR20220073684A (en) Method, system and non-transitory computer-readable recording medium for supporting user experience sharing
CN108205820B (en) Plane reconstruction method, fusion method, device, equipment and storage medium
CN112604279A (en) Special effect display method and device
CN112604280A (en) Game terrain generating method and device
CN112070901A (en) AR scene construction method and device for garden, storage medium and terminal
CN111915479A (en) Image processing method and device, electronic equipment and computer readable storage medium
CN110825250A (en) Optimization method and device for brush track
CN110860084A (en) Virtual picture processing method and device
CN109529349B (en) Image drawing method and device, computing equipment and storage medium
CN108122273A (en) A kind of number animation generation system and method
CN111744196B (en) Task target guiding method and device in game task
CN112221150B (en) Ripple simulation method and device in virtual scene
CN116883708A (en) Image classification method, device, electronic equipment and storage medium

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 001, Floor 03, Floor 3, No. 33, Xiaoying West Road, Haidian District, Beijing 100085

Applicant after: Beijing Jinshan Shiyou Interactive Entertainment Technology Co.,Ltd.

Address before: 2f04, No. 33, Xiaoying West Road, Haidian District, Beijing 100085

Applicant before: Beijing Xishanju Interactive Entertainment Technology Co.,Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20221101

Address after: 519000 Room 102, 202, 302 and 402, No. 325, Qiandao Ring Road, Tangjiawan Town, high tech Zone, Zhuhai City, Guangdong Province, Room 102 and 202, No. 327 and Room 302, No. 329

Applicant after: Zhuhai Jinshan Digital Network Technology Co.,Ltd.

Address before: Room 001, Floor 03, Floor 3, No. 33, Xiaoying West Road, Haidian District, Beijing 100085

Applicant before: Beijing Jinshan Shiyou Interactive Entertainment Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant