Virtual sound source object setting method, device, electronic device and medium
By obtaining the relative position information of the virtual sound source object and the listener object, and using the collision bounding box to represent the volume shape of the virtual sound source, the problem that the existing technology cannot set up a virtual sound source object with volume is solved, the three-dimensional sound effect of the virtual sound source object is realized, and the realism of the game scene is enhanced.
Patent Information
- Application Number
- CN202111669705.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2041-12-30
AI Technical Summary
Existing technologies cannot support the setting of virtual sound source objects with volume, resulting in insufficient sound generation in game scenes, lack of realism and fit with the real world.
By obtaining the relative position information between the virtual sound source object and the listener object, the collision bounding box is used to represent the volume shape of the virtual sound source, and the position of the virtual sound source object is set according to the position information to achieve three-dimensional sound effects.
The three-dimensional sound effects of virtual sound source objects are realized, which enhances the realism of the game scene and its fit with the real world. The sound volume and sound effects change with the position and volume of the object.
Smart Images

Figure CN114288656B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a method, device, electronic device and medium for setting a virtual sound source object. Background Art
[0002] Sound is an essential element in gaming. A rich sound system can bridge the gap between the virtual and real worlds. Configuring different sounds for different game scenes can enhance the realism of the game and its connection to the real world.
[0003] Currently, the generation and configuration of sounds in game scenes typically involves setting up multiple point sound sources at corresponding locations within the game scene. In other words, existing technologies only support the configuration of point virtual sound sources and are unable to support the configuration of virtual sound sources with volume (i.e., virtual sound source objects). Therefore, a solution that supports the configuration of virtual sound source objects with volume is urgently needed. Summary of the Invention
[0004] The embodiments of the present invention solve the technical problem that the prior art cannot support the setting of virtual sound source objects with volume by providing a method, device, electronic device and medium for setting a virtual sound source object.
[0005] On the one hand, the present invention provides a method for setting a virtual sound source object through an embodiment of the present invention, the method comprising:
[0006] Obtaining relative position information between a virtual sound source object and a listener object in a current game scene, wherein the virtual sound source object is controlled by a virtual character and is provided with a virtual sound source and a collision bounding volume, wherein the collision bounding volume is used to represent the volume of the virtual sound source;
[0007] The virtual sound source object is set to a target position according to the relative position information to achieve a three-dimensional sound effect of the virtual sound source.
[0008] Optionally, setting the virtual sound source object to a target position according to the relative position information includes:
[0009] determining, based on the relative position information, whether the position of the listener object is within the volume of the virtual sound source object;
[0010] If so, setting the position of the virtual sound source object to the position of the listener object;
[0011] If not, the position of the virtual sound source object is set to a target position, where the target position is any target position within the volume range of the virtual sound source object.
[0012] Optionally, the target position is the position of a point on the surface of the virtual sound source object that is closest to the position of the listener object, so as to achieve a function in which the virtual sound source begins to attenuate outside the volume range of the virtual sound source object.
[0013] Optionally, the method further comprises:
[0014] Acquire skeletal animation data of the virtual character, wherein the skeletal animation data includes a skeletal hierarchical structure of the virtual character;
[0015] The virtual sound source object is associated with the skeleton hierarchy structure of the virtual character, and the position change and volume change of the virtual sound source object relative to the target skeleton of the virtual character are realized through the skeleton animation data of the virtual character.
[0016] Optionally, the step of implementing the position change and volume change of the virtual sound source object relative to the target skeleton of the virtual character through the skeleton animation data of the virtual character includes:
[0017] Determining a motion trajectory of the virtual sound source object relative to the target skeleton based on the skeleton animation data of the virtual character;
[0018] The virtual sound source object is controlled to move along the motion trajectory, and the volume of the virtual sound source object is changed synchronously.
[0019] Optionally, controlling the virtual sound source object to move along the motion trajectory and synchronously changing the volume of the virtual sound source object includes:
[0020] Moving the position of the virtual sound source object along the motion trajectory, and scaling the volume of the virtual sound source object according to a preset scaling size during the movement;
[0021] The position movement and volume scaling of the virtual sound source object are transformed into the sound effect presentation of the virtual sound source object through the audio middleware, so that the sound effect of the virtual sound source object changes with the position change and volume change of the virtual sound source object.
[0022] Optionally, the method further includes:
[0023] The face orientation of the listener object is set to be the same as the orientation of the virtual camera corresponding to the listener object.
[0024] On the other hand, the present invention provides a virtual sound source object setting device according to an embodiment of the present invention, the device comprising an acquisition module and a setting module, wherein:
[0025] The acquisition module is configured to acquire relative position information between a virtual sound source object and a listener object in a current game scene, wherein the virtual sound source object is controlled by a virtual character and is provided with a virtual sound source and a collision bounding volume, wherein the collision bounding volume is used to represent the volume of the virtual sound source;
[0026] The setting module is used to set the virtual sound source object to a target position according to the relative position information, so as to realize the three-dimensional sound effect of the virtual sound source.
[0027] For the contents not introduced or described in the embodiments of the present invention, please refer to the relevant introduction in the aforementioned method embodiments, which will not be repeated here.
[0028] On the other hand, the present invention provides an electronic device through an embodiment of the present invention, which includes: a processor, a memory, a communication interface and a bus; the processor, the memory and the communication interface are connected through the bus and communicate with each other; the memory stores executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the virtual sound source object setting method as described above.
[0029] On the other hand, the present invention provides a computer-readable storage medium according to an embodiment of the present invention. The computer-readable storage medium stores a program, and when the program runs on an electronic device, the virtual sound source object setting method as described above is executed.
[0030] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages: the present invention obtains the relative position information between the virtual sound source object and the listener object in the current game scene, wherein the virtual sound source object is controlled by a virtual character, and the virtual sound source object is provided with a virtual sound source and a collision enclosure, and the collision enclosure is used to represent the volumetric form of the virtual sound source. Further, the present invention sets the virtual sound source object to a target position based on the relative position information to achieve the three-dimensional sound effect of the virtual sound source. In the above solution, the present application sets the position of the corresponding virtual sound source object with volume based on the relative position information between the virtual sound source object and the listener object to achieve the three-dimensional sound effect of the virtual sound source object. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0032] Figure 1 It is a flowchart of a method for setting a virtual sound source object provided by an embodiment of the present invention.
[0033] Figure 2 This is a schematic diagram of the effect of a virtual sound source object movement provided by an embodiment of the present invention.
[0034] Figure 3 It is a structural diagram of a virtual sound source object setting device provided by an embodiment of the present invention.
[0035] Figure 4 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to better understand the above technical solution, the above technical solution will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0037] First, the term "and / or" as used herein simply describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. Furthermore, the character " / " in this document generally indicates an "or" relationship between the associated objects.
[0038] See Figure 1 , is a flow chart of a method for setting a virtual sound source object provided by an embodiment of the present invention. Figure 1 The method shown can be applied to electronic devices, such as smartphones, tablet computers, etc., and the present invention is not limited thereto. The method includes the following implementation steps:
[0039] S101. Obtain relative position information between a virtual sound source object and a listener object in a current game scene, wherein the virtual sound source object is controlled by a virtual character, and the virtual sound source object is provided with a virtual sound source and a collision bounding volume, wherein the collision bounding volume is used to represent the volume shape of the virtual sound source.
[0040] The virtual sound source object described in the present invention is provided with a virtual sound source and a collision bounding volume. In game engines (such as the Unity engine), a three-dimensional collision volume (abbreviated as a 3D collision volume) is typically used to simulate / represent the collision bounding volume. The present invention does not limit the shape and size of the 3D collision volume (i.e., the collision bounding volume of the virtual sound source object). For example, the shape of the 3D collision volume may include, but is not limited to, a cuboid, a cube, a capsule, a sphere, a polyhedron, or other custom mesh shapes.
[0041] The virtual sound source described in the present invention refers to the source of the sound produced / emitted by the virtual sound source object when it is manipulated. The virtual sound source is manipulated by a virtual character, which can be understood as any game object in the game that requires sound, such as the game character, opponent character, boss, monster, NPC, or even any scene object requiring sound. The player character described in this solution refers to the current game character controlled by the player. The listener object is a component attached to the player character model that receives audio. The listener object can be understood as a microphone or other sound receiving device that provides audio listening for the player-controlled game character. It is not part of the player character model, but is associated with the player character's position. Changes in the player character's position will cause changes in the player character model's position, thereby causing changes in the listener object's position. For example, when the player is controlling the current game character, the listener object is located at the head position of the player character being manipulated. Alternatively, when playing a cutscene, the listener object can be attached to a virtual camera. Optionally, in the current game scene, the present invention can set the facial orientation of the listener object to be the same as / consistent with the orientation of the virtual camera pre-configured corresponding to the listener object, so as to ensure that the direction of the sound source heard by the listener object (i.e., the direction of the sound source) is consistent with the viewing angle direction of the game screen it is watching.
[0042] Specifically in the game, for example, in a scene where a player joins forces with multiple teammates to attack a huge BOSS, suppose the BOSS attacks with its left and right hands respectively and roars at the same time.
[0043] At this time, it simultaneously manipulates three virtual sound source objects:
[0044] A. Moves with its mouth and plays the roar
[0045] B. Follow the movement of its left hand and play the skill sound effects of the left hand
[0046] C. Follow the movement of the right hand and play the skill sound effects of the right hand
[0047] Assuming the player's character is in front of the boss and facing the boss, since the listener object is on the player's head, the player should hear the following sound performance:
[0048] A. The boss's roar sounds like it comes from the front (because the boss is huge and much taller than the player)
[0049] B. The sound effect of the boss's left hand skill sounds from the right and moves with the boss's left hand
[0050] C. The sound effect of the boss's right hand skill sounds from the left and moves with the boss's right hand
[0051] In a specific embodiment, the present invention may employ collision detection technology to detect whether the position of the listener object in the current game scene is within the volume of the virtual sound source object, thereby obtaining relative position information between the virtual sound source object and the listener object in the current game scene. The relative position information may specifically indicate whether the position of the listener object is within the volume of the virtual sound source object.
[0052] In a specific implementation, the present invention can use a preset collision detection algorithm to detect the position information between the collision bounding volume of the virtual sound source object and the listener object in the current game scene, thereby obtaining the relative position information between the listener object and the virtual sound source object. The collision detection algorithm includes but is not limited to an intersection test collision detection algorithm, a distance query collision detection algorithm, and an interval overlap collision detection algorithm.
[0053] S102: Setting the virtual sound source object to a target position according to the relative position information to achieve a three-dimensional sound effect of the virtual sound source.
[0054] In one embodiment, the present invention determines whether the listener object's position is within the volume of the virtual sound source object based on the relative position information. If so, the virtual sound source object's position is set to the listener object's position; if not, the virtual sound source object's position is set to a target position, which can be any target position within the volume of the virtual sound source object.
[0055] In a specific implementation, the present invention can determine / set the position of the virtual sound source object based on the relative position information. Specifically, when the position of the listener object is determined to be within the volume of the virtual sound source object based on the relative position information, the present invention can set the virtual sound source object at the position of the listener object, that is, setting the position of the virtual sound source object to the position of the listener object. This can achieve the effect of no attenuation of the sound volume of the virtual sound source within the volume range.
[0056] Accordingly, when the listener object's position is determined to be outside the volume of the virtual sound source object based on the relative position information, the present invention can set the virtual sound source object's position to a target position; wherein the target position is any position within the volume of the virtual sound source object, such as any point on the surface of the virtual sound source object. Preferably, the target position is the point on the surface of the virtual sound source object closest to the listener object's position, thereby achieving the effect of gradually attenuating the volume of the virtual sound source outside the volume. The surface of the virtual sound source object is the surface of the virtual sound source object's bounding box.
[0057] Some optional embodiments of the present invention are described below.
[0058] In some optional embodiments, when a virtual character manipulates a virtual sound source object, the present invention can use the virtual character (or a preset body part of the virtual character, such as an arm, hand skeleton, or leg) as a parent and control the virtual sound source (i.e., the virtual sound source object corresponding to the virtual sound source) to move along the parent's preset motion trajectory, thereby enabling the virtual sound source object to follow the virtual character's movements. The preset motion trajectory can be pre-defined by the system, such as a parabolic motion trajectory or a linear motion trajectory.
[0059] Further optionally, the present invention can capture the motion animation of the virtual sound source object as it moves along a preset motion trajectory in real time or periodically. The motion animation can be a skeletal animation or a keyframe animation, which is not limited by the present invention. Among them, the skeletal animation is a type of model animation. In skeletal animation, the model has a skeletal structure composed of interconnected "bones", and the animation generated for the model is generated by changing the orientation and position of the bones. The keyframe animation refers to a frame animation used to represent the key state of the sound source object.
[0060] It can be understood that the present invention utilizes various animation tools provided by the game engine (such as Animation, Timeline and other tools in the Unity engine) to define animation by adding key frames of properties such as position, rotation and scale, and uses the animation to determine the movement of the virtual sound source object.
[0061] In some optional embodiments, the present invention may obtain skeletal animation data of the virtual character, wherein the skeletal animation data includes the skeletal hierarchical structure of the virtual character, such as the skeletal hierarchical structure of each body part of the virtual character, such as the skeletal hierarchical structure of arms, palms, and fingers. Furthermore, the present invention may associate the virtual sound source object with the skeletal hierarchical structure of the virtual character, and achieve positional and volume changes of the virtual sound source object relative to the target skeleton of the virtual character through the skeletal animation data of the virtual character, that is, achieve positional and volume changes of the virtual sound source object following the movement of the virtual character.
[0062] A specific embodiment of the present invention for achieving positional and volume changes of a virtual sound source object relative to a target skeleton of the virtual character using the skeletal animation data of the virtual character may include determining a motion trajectory of the virtual sound source object relative to the target skeleton based on the skeletal animation data of the virtual character. The virtual sound source object is then controlled to move along the motion trajectory, and its volume is simultaneously changed to achieve the effect of the virtual sound source object moving away from or toward the virtual character.
[0063] In a specific implementation, the present invention may collect a series of skeletal animation data generated when the virtual character manipulates the virtual sound source object. The present invention does not limit the number of skeletal animation data, and the number of skeletal animation data may be one or more. Furthermore, the present invention may determine the motion trajectory of the virtual sound source object relative to the target skeleton of the virtual character based on the collected skeletal animation data of the virtual character. Two possible specific implementations of this are described below.
[0064] In an example embodiment, when the virtual character is an opponent character corresponding to the player character, the present invention can parse the skeletal animation data to determine the position of the virtual character in the skeletal animation data (or it can specifically be the position of the target skeleton of the virtual character). The position of the player character can then be obtained, and then the motion trajectory can be generated based on the determined position of the virtual character and the position of the player character. Specifically, the present invention can generate the motion trajectory based on the position of the opponent character, the position of the player character, and the relative position information between the player character and the opponent character (such as relative position direction and relative position distance, etc.). In this example, the starting position of the motion trajectory is the position of the opponent character, and the end position of the motion trajectory is the position of the player character, so that the effect of the virtual sound source object moving from the opponent character to the player character can be achieved. The motion trajectory involved in the present invention includes but is not limited to a straight motion trajectory, a parabolic motion trajectory or other curved motion trajectory.
[0065] In another example embodiment, the present invention can parse the collected skeletal animation data of each frame, and parse therefrom to obtain information such as the position of the virtual character, the control direction and control force of the virtual sound source object. Then the present invention can generate the motion trajectory according to the position of the virtual character, the control direction and control force of the virtual sound source object. Specifically, the present invention can use a preset trajectory prediction model to generate a trajectory for the position of the opponent character, the control direction and control force of the sound source object and other information obtained by analysis. The trajectory prediction model is a pre-trained model, which may include but is not limited to a neural network model, or other deep learning models. In this example, the starting position of the motion trajectory may be the position of the virtual character, and the end position of the motion trajectory is not limited. For example, it may be the position of the opponent character corresponding to the virtual character.
[0066] After obtaining the motion trajectory, the present invention can control the virtual sound source object to move along the motion trajectory, and synchronously change the volume of the virtual sound source object. Specifically, when the virtual sound source object moves along the motion trajectory, the position of the virtual sound source object is also moved, and the volume of the virtual sound source object is synchronously scaled according to the preset scaling size when moving, so as to achieve the position change and volume change of the virtual sound source object following the movement of the target skeleton. The preset scaling size is determined by the preset scaling animation corresponding to the virtual sound source model. For example, the virtual sound source model is a fireball. After the virtual character releases the fireball range attack skill, the fireball will gradually disappear over time. As the volume of the fireball continues to decrease, the sound effect also decreases as the volume decreases.
[0067] In an optional embodiment, the present invention may also transform the position movement and volume scaling of the virtual sound source object to the sound effect presentation of the virtual sound source object through audio middleware, so as to realize that the sound effect of the virtual sound source object changes along with the position change and volume change of the virtual sound source object. For example, when the position and / or volume of the virtual sound source object changes, the present invention may synchronously adjust the volume of the virtual sound source corresponding to the virtual sound source object to be amplified or reduced. For example, when the virtual sound source object moves away from the listener object along the motion trajectory, the volume of the virtual sound source object may be controlled to gradually decrease to produce a volume attenuation effect. For another example, when the volume of the virtual sound source object decreases and then increases as it moves along the motion trajectory, that is, the volume changes from large to small and then from large to small, the volume of the virtual sound source object may be controlled to change from small to large and then from large to small, so as to realize that the sound of the virtual sound source object changes along with the volume change of the virtual sound source object.
[0068] In an optional embodiment, the sound effect change of the virtual sound source object can also change according to the positional relationship between the listener object and the virtual character and the game logic. For example, there is a sneak attack gameplay scene in the game. In the current scene, when the virtual character approaches the player character, it will intelligently judge the distance between it and the player, that is, the position of the virtual sound source object relative to the player character or the listener object changes. The closer the position, the smaller the volume of the virtual sound source controlled by the virtual character becomes, creating a realistic effect of reducing the sound made by the virtual character in order to sneak attack the enemy.
[0069] For example, see Figure 2 A schematic diagram showing a possible effect of the movement of a virtual sound source object is shown. Figure 2During the movement of the virtual sound source object, the present invention can control the volume of the virtual sound source object to change along the movement of the motion trajectory, and simultaneously control the volume of the virtual sound source object to change along the volume of the virtual sound source object. For example, as shown in the figure, during the movement of the virtual sound source object from the opponent character to the player character along the motion trajectory, the volume of the virtual sound source object can be controlled to change in accordance with a preset magnification size. Optionally, the volume of the virtual sound source object can also be controlled to gradually increase according to a preset volume, thereby achieving the effect of the virtual sound source object gradually increasing in volume and volume along the motion trajectory.
[0070] In other words, in an optional embodiment, while the virtual sound source object is in motion, the present invention can also simultaneously perform preset sound source effects on the virtual sound source object. These preset sound source effects are system-defined, such as changes in sound source volume, rotation, position, and volume. The following describes several possible implementations.
[0071] In an exemplary embodiment, during the movement of the virtual sound source object, the present invention may scale the virtual sound source object according to a preset scaling size. For example, when the virtual sound source object moves along the motion trajectory, the virtual sound source object is also magnified and displayed according to a preset magnification size.
[0072] In another example embodiment, during the movement of the virtual sound source object, the present invention controls the volume of the virtual sound source corresponding to the virtual sound source object to change along with the change of the movement trajectory, for example, controlling the volume of the virtual sound source from small to large, that is, the closer the virtual sound source is to the listener object, the louder the volume.
[0073] In another exemplary embodiment, during the movement of the virtual sound source object, the present invention may rotate the virtual sound source object at a preset angle, such as rotating it at a fixed angle / fixed rotational angular velocity along a preset direction, etc., which is not limited by the present invention.
[0074] It should be noted that, in specific implementations, the above three exemplary embodiments may be implemented individually, or any two or more of them may be combined for implementation, and the present invention is not limited thereto. For example, in one specific embodiment, during the movement of the virtual sound source object, the present invention may simultaneously control the volume of the virtual sound source object and the volume of the corresponding virtual sound source, so that the sound attenuation of the virtual sound source object changes with the volume of the virtual sound source object.
[0075] It should be noted that the volume of the virtual sound source object is modified by keyframe animation in the game engine to achieve the scaling of the virtual sound source object. In addition, the present invention provides audio middleware (such as Wwise middleware) in the game engine to achieve the above-mentioned Figure 1-Figure 2 In other words, the embodiments described in the present invention can be applied to audio middleware in game engines, such as Wwise middleware.
[0076] By implementing an embodiment of the present invention, the present invention obtains the relative position information between the virtual sound source object and the listener object in the current game scene, wherein the virtual sound source object is controlled by a virtual character, and the virtual sound source object is provided with a virtual sound source and a collision enclosure, and the collision enclosure is used to represent the volumetric form of the virtual sound source. Further, the present invention sets the virtual sound source object to a target position based on the relative position information to achieve the three-dimensional sound effect of the virtual sound source. In the above scheme, the present application sets the position of the virtual sound source object based on the relative position information between the virtual sound source object and the listener object to achieve the three-dimensional sound effect of the virtual sound source object.
[0077] Based on the same inventive concept, another embodiment of the present invention provides a device and electronic device corresponding to the method for setting up a virtual sound source object described in the embodiment of the present invention.
[0078] See Figure 3 , is a structural diagram of a virtual sound source object setting device provided by an embodiment of the present invention. Figure 3 The device 3 shown includes: an acquisition module 301 and a setting module 302, wherein:
[0079] The acquisition module 301 is configured to acquire relative position information between a virtual sound source object and a listener object in a current game scene, wherein the virtual sound source object is controlled by a virtual character and is provided with a virtual sound source and a collision bounding volume, wherein the collision bounding volume is used to represent the volume of the virtual sound source;
[0080] The setting module 302 is configured to set the virtual sound source object to a target position according to the relative position information, so as to achieve a three-dimensional sound effect of the virtual sound source.
[0081] Optionally, the setting module 302 is specifically configured to:
[0082] determining, based on the relative position information, whether the position of the listener object is within the volume of the virtual sound source object;
[0083] If so, setting the position of the virtual sound source object to the position of the listener object;
[0084] If not, the position of the virtual sound source object is set to a target position, where the target position is any target position within the volume range of the virtual sound source object.
[0085] Optionally, the target position is the position of a point on the surface of the virtual sound source object that is closest to the position of the listener object, so as to achieve a function in which the virtual sound source begins to attenuate outside the volume range of the virtual sound source object.
[0086] Optionally, the apparatus further includes a processing module 303, wherein:
[0087] The acquisition module 301 is further configured to acquire skeletal animation data of the virtual character, wherein the skeletal animation data includes a skeletal hierarchical structure of the virtual character;
[0088] The processing module 303 is used to associate the virtual sound source object with the skeleton hierarchy structure of the virtual character, and realize the position change and volume change of the virtual sound source object relative to the target skeleton of the virtual character through the skeleton animation data of the virtual character.
[0089] Optionally, the processing module 303 is specifically configured to:
[0090] Determining a motion trajectory of the virtual sound source object relative to the target skeleton based on the skeleton animation data of the virtual character;
[0091] The virtual sound source object is controlled to move along the motion trajectory, and the volume of the virtual sound source object is changed synchronously.
[0092] Optionally, the processing module 303 is further specifically configured to:
[0093] Moving the position of the virtual sound source object along the motion trajectory, and scaling the volume of the virtual sound source object according to a preset scaling size during the movement;
[0094] The position movement and volume scaling of the virtual sound source object are transformed into the sound effect presentation of the virtual sound source object through the audio middleware, so that the sound effect of the virtual sound source object changes with the position change and volume change of the virtual sound source object.
[0095] Optionally, the processing module 303 is further configured to:
[0096] The face orientation of the listener object is set to be the same as the orientation of the virtual camera corresponding to the listener object.
[0097] Please also see Figure 4 , is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 4The electronic device 40 shown includes: at least one processor 401, a communication interface 402, a user interface 403 and a memory 404. The processor 401, the communication interface 402, the user interface 403 and the memory 404 can be connected via a bus or other means. In the embodiment of the present invention, the connection via bus 405 is used as an example.
[0098] The processor 401 may be a general-purpose processor, such as a central processing unit (CPU).
[0099] The communication interface 402 may be a wired interface (e.g., an Ethernet interface) or a wireless interface (e.g., a cellular network interface or a wireless local area network interface) for communicating with other terminals or websites. In an embodiment of the present invention, the communication interface 402 is specifically used to obtain character position, relative position information, etc.
[0100] The user interface 403 may be a touch panel, including a touch screen and a touch screen, for detecting operation instructions on the touch panel, a physical button or a mouse, or a display screen for outputting and displaying images or data.
[0101] Memory 404 may include volatile memory, such as random access memory (RAM); non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the aforementioned types of memory. Memory 404 is used to store a set of program codes, and processor 401 is used to call the program codes stored in memory 404 and perform the following operations:
[0102] Obtaining relative position information between a virtual sound source object and a listener object in a current game scene, wherein the virtual sound source object is controlled by a virtual character and is provided with a virtual sound source and a collision bounding volume, wherein the collision bounding volume is used to represent the volume of the virtual sound source;
[0103] The virtual sound source object is set to a target position according to the relative position information to achieve a three-dimensional sound effect of the virtual sound source.
[0104] Optionally, setting the virtual sound source object to a target position according to the relative position information includes:
[0105] determining, based on the relative position information, whether the position of the listener object is within the volume of the virtual sound source object;
[0106] If so, setting the position of the virtual sound source object to the position of the listener object;
[0107] If not, the position of the virtual sound source object is set to a target position, where the target position is any target position within the volume range of the virtual sound source object.
[0108] Optionally, the target position is the position of a point on the surface of the virtual sound source object that is closest to the position of the listener object, so as to achieve a function in which the virtual sound source begins to attenuate outside the volume range of the virtual sound source object.
[0109] Optionally, the processor 401 is further configured to:
[0110] Acquire skeletal animation data of the virtual character, wherein the skeletal animation data includes a skeletal hierarchical structure of the virtual character;
[0111] The virtual sound source object is associated with the skeleton hierarchy structure of the virtual character, and the position change and volume change of the virtual sound source object relative to the target skeleton of the virtual character are realized through the skeleton animation data of the virtual character.
[0112] Optionally, the step of implementing the position change and volume change of the virtual sound source object relative to the target skeleton of the virtual character through the skeleton animation data of the virtual character includes:
[0113] Determining a motion trajectory of the virtual sound source object relative to the target skeleton based on the skeleton animation data of the virtual character;
[0114] The virtual sound source object is controlled to move along the motion trajectory, and the volume of the virtual sound source object is changed synchronously.
[0115] Optionally, controlling the virtual sound source object to move along the motion trajectory and synchronously changing the volume of the virtual sound source object includes:
[0116] Moving the position of the virtual sound source object along the motion trajectory, and scaling the volume of the virtual sound source object according to a preset scaling size during the movement;
[0117] The position movement and volume scaling of the virtual sound source object are transformed into the sound effect presentation of the virtual sound source object through the audio middleware, so that the sound effect of the virtual sound source object changes with the position change and volume change of the virtual sound source object.
[0118] Optionally, the processor 401 is further configured to:
[0119] The face orientation of the listener object is set to be the same as the orientation of the virtual camera corresponding to the listener object.
[0120] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages: the present invention obtains the relative position information between a virtual sound source object and a listener object in the current game scene, wherein the virtual sound source object is provided with a virtual sound source and a collision bounding volume, and the collision bounding volume is used to represent the volumetric shape of the virtual sound source. Further, the present invention sets the virtual sound source object to a target position based on the relative position information to achieve a three-dimensional sound effect of the virtual sound source. In the above solution, the present application sets the position of the virtual sound source object based on the relative position information between the virtual sound source object and the listener object to achieve a three-dimensional sound effect of the virtual sound source object.
[0121] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0122] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0123] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0124] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0125] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0126] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
Claims
1. A method for setting a virtual sound source object, characterized in that: The method comprises: Obtaining relative position information between a virtual sound source object and a listener object in a current game scene, wherein the virtual sound source object is controlled by a virtual character and is provided with a virtual sound source and a collision bounding volume, wherein the collision bounding volume is used to represent the volume of the virtual sound source; Setting the virtual sound source object to a target position according to the relative position information to achieve a three-dimensional sound effect of the virtual sound source; The method further comprises: Acquire skeletal animation data of the virtual character, wherein the skeletal animation data includes a skeletal hierarchical structure of the virtual character; The virtual sound source object is associated with the skeleton hierarchy structure of the virtual character, and the position change and volume change of the virtual sound source object relative to the target skeleton of the virtual character are realized through the skeleton animation data of the virtual character.
2. The method according to claim 1, characterized in that The step of setting the virtual sound source object to the target position according to the relative position information includes: determining, based on the relative position information, whether the position of the listener object is within the volume of the virtual sound source object; If so, setting the position of the virtual sound source object to the position of the listener object; If not, the position of the virtual sound source object is set to a target position, where the target position is any target position within the volume range of the virtual sound source object.
3. The method according to claim 2, characterized in that The target position is the position of the point on the surface of the virtual sound source object that is closest to the position of the listener object, so as to realize the function of the virtual sound source starting to attenuate from outside the volume range of the virtual sound source object.
4. The method according to claim 1, wherein The step of realizing the position change and volume change of the virtual sound source object relative to the target skeleton of the virtual character by using the skeleton animation data of the virtual character includes: Determining a motion trajectory of the virtual sound source object relative to the target skeleton based on the skeleton animation data of the virtual character; The virtual sound source object is controlled to move along the motion trajectory, and the volume of the virtual sound source object is changed synchronously.
5. The method according to claim 4, characterized in that The controlling the virtual sound source object to move along the motion trajectory and synchronously changing the volume of the virtual sound source object includes: Moving the position of the virtual sound source object along the motion trajectory, and scaling the volume of the virtual sound source object according to a preset scaling size during the movement; The position movement and volume scaling of the virtual sound source object are transformed into the sound effect presentation of the virtual sound source object through the audio middleware, so that the sound effect of the virtual sound source object changes with the position change and volume change of the virtual sound source object.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: The face orientation of the listener object is set to be the same as the orientation of the virtual camera corresponding to the listener object.
7. A virtual sound source object setting device, characterized in that: The device includes an acquisition module and a setting module, wherein: The acquisition module is configured to acquire relative position information between a virtual sound source object and a virtual character in a current game scene, wherein the virtual sound source object is provided with a virtual sound source and a collision bounding volume, wherein the collision bounding volume is used to represent the volume of the virtual sound source; The setting module is used to set the virtual sound source object to a target position according to the relative position information, so as to achieve a three-dimensional sound effect of the virtual sound source; The apparatus further comprises a processing module, wherein: The acquisition module is further configured to acquire skeletal animation data of the virtual character, wherein the skeletal animation data includes a skeletal hierarchical structure of the virtual character; The processing module is used to associate the virtual sound source object with the skeleton hierarchy structure of the virtual character, and realize the position change and volume change of the virtual sound source object relative to the target skeleton of the virtual character through the skeleton animation data of the virtual character.
8. An electronic device, characterized in that: The electronic device includes: a processor, a memory, a communication interface and a bus; the processor, the memory and the communication interface are connected through the bus and communicate with each other; the memory stores executable program code; the processor runs the program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the virtual sound source object setting method as described in any one of claims 1 to 6 above.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a program, and when the program is run on an electronic device, the virtual sound source object setting method as described in any one of claims 1 to 6 is executed.
Citation Information
Patent Citations
Processing method and device for sound in three-dimensional virtual scene
CN104869524A
Sound source control method and device, computer equipment and medium
CN111714889A