Local weather control method in virtual environment, electronic device, and storage medium
By setting the direction and speed of local weather movement in a 3D virtual environment, the problem of lack of directional change in local weather rendering is solved, improving the visual experience and reducing the computational burden on the main server.
Patent Information
- Application Number
- CN202211502634.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-28
- Publication Date
- 2026-08-04
- Estimated Expiration
- 2042-11-28
AI Technical Summary
In a 3D virtual environment, the rendering of local weather lacks directional changes, resulting in insufficient visual experience. At the same time, the main server's computational load is too large, leading to high performance consumption.
The main server pre-sets the direction and speed of local weather movement, calculates the current location of the target local weather, and renders it in the area where the virtual character is located according to the set direction and speed, reducing the amount of computation on the main server.
It enhances the visual perception of weather moving from far to near, while reducing the computational burden on the main server and lowering performance consumption.
Smart Images

Figure CN115738252B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method for local weather control in a virtual environment, an electronic device, and a storage medium. Background Technology
[0002] In applications with 3D virtual environments, such as massively multiplayer online role-playing games, the game application presents simulated weather in the real world, giving users a more realistic experience when controlling virtual characters to play the game.
[0003] Taking a rainy scene as an example, the local weather (rain) does not show a linear change in direction. It only exists within the overall area and there is no change process like from left to right. It lacks the visual feeling brought by controlling the movement from far to near. Summary of the Invention
[0004] The main objective of this application is to propose a method, electronic device, and storage medium for controlling local weather in a virtual environment. The aim is to control the rendering of local weather according to a pre-set direction and speed of motion, resulting in a directional change in the rendering of the local weather, which enhances the visual experience of the weather moving from far to near; simultaneously, it effectively reduces the computational load and performance consumption of the main server.
[0005] To achieve the above objectives, a first aspect of this application proposes a method for local weather control in a virtual environment, the method comprising:
[0006] Based on the first data sent by the main server, the current location of the target local weather is calculated. The first data includes the start time, starting position, direction of movement, and speed of movement of the target local weather.
[0007] When the current location of the target local weather enters the target area, it is determined whether the target area meets the conditions for the occurrence of the target local weather. The target area is the area where the virtual character is located in the virtual environment.
[0008] When the target area meets the conditions for the occurrence of the target local weather, the target local weather is rendered in the target area according to the direction and speed of movement.
[0009] In some embodiments, the current location of the target local weather is calculated based on the first data sent by the master server, including:
[0010] The duration of the movement of the target local weather is calculated based on the current time and the start time of the target local weather.
[0011] The movement distance of the target local weather is calculated based on the movement direction, movement speed, and movement duration of the target local weather.
[0012] The current location of the target local weather is calculated based on the starting location of the target local weather and the movement distance.
[0013] In some embodiments, after calculating the current location of the target local weather based on the first data sent by the master server, the method includes:
[0014] Determine a first position, which is the position furthest from the target local weather in the target area;
[0015] When the current position of the target local weather exceeds the first position, it is determined that the current position of the target local weather has entered the target area.
[0016] In some embodiments, after controlling the target local weather to be rendered in the target area according to the direction and speed of movement, the method includes:
[0017] When the second data sent by the main server is received, the system controls the rendering of the target local weather to stop in the target area. The second data is the end marker of the target local weather, and the end marker includes an end time or an end command.
[0018] To achieve the above objectives, a second aspect of this application proposes a method for local weather control in a virtual environment, the method comprising:
[0019] Pre-set the movement direction and speed of various types of local weather in the local weather group;
[0020] Select at least one type of local weather from the group of local weather as the target local weather;
[0021] When the target local weather is detected to be triggered, the start time of the target local weather is recorded;
[0022] The starting location of the target local weather is determined based on the location of each virtual character in the virtual environment.
[0023] The first data is sent to the slave server to which each virtual character belongs in the virtual environment. The first data includes the start time, starting position, direction of movement, and speed of movement of the target local weather.
[0024] In some embodiments, determining the starting location of the target local weather based on the location of each virtual character in the virtual environment includes:
[0025] Obtain a first set, which is the set of areas where each virtual character is located in the virtual environment;
[0026] A first region is selected from the first set, wherein the first region is the region in the first set that is furthest from the direction of movement of the target local weather;
[0027] A second location is determined from the first region, the second location being the location in the first region furthest from the direction of movement of the target local weather;
[0028] The second position can be used as the starting position of the target local weather, or any position can be selected from the second position in the region away from the direction of movement of the target local weather as the starting position of the target local weather.
[0029] In some embodiments, after sending the first data to the slave server to which each virtual character belongs in the virtual environment, the method includes:
[0030] The total duration of the local weather events affecting the target area is recorded.
[0031] When the duration of the occurrence exceeds the preset duration of the target local weather, second data is sent to each of the slave servers. The second data is an end marker of the target local weather, and the end marker includes an end time or an end command.
[0032] In some embodiments, the method further includes:
[0033] The occurrence conditions and duration of various types of local weather in the local weather group are preset;
[0034] At preset time intervals, the first data of at least one target local weather is sent to each of the slave servers, so that each of the slave servers controls whether to render the corresponding target local weather in the area where each virtual character is located according to the movement direction and movement speed based on the first data.
[0035] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.
[0036] To achieve the above objectives, a fourth aspect of the present application provides a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the method described in the first aspect.
[0037] This application proposes a method, electronic device, and storage medium for controlling local weather in a virtual environment. The method includes: calculating the current position of a target local weather based on first data sent by a master server, wherein the first data includes the start time, starting position, direction of movement, and speed of movement of the target local weather; when the current position of the target local weather enters a target area, determining whether the target area meets the conditions for the occurrence of the target local weather, wherein the target area is the area where a virtual character is located in the virtual environment; and when the target area meets the conditions for the occurrence of the target local weather, controlling the target local weather to be rendered in the target area according to the direction of movement and speed of movement. Since the local weather is rendered according to a pre-set direction of movement and speed of movement, there is a directional change process, which can enhance the visual experience of the weather moving from far to near; at the same time, the master server only needs to send the first data to each slave server to control the rendering of local weather, without the master server needing to continuously traverse the terrain content of each virtual character's area, nor the master server needing to determine whether each virtual character's area meets the conditions for the occurrence of the target local weather, which can effectively reduce the computational load of the master server, thereby reducing the performance consumption of the master server. Attached Figure Description
[0038] Figure 1 This is an application environment diagram of the weather rendering method for game scenes provided in the embodiments of this application;
[0039] Figure 2 This is a flowchart of the steps of the local weather control method in a virtual environment provided in the embodiments of this application;
[0040] Figure 3 This is a flowchart of the steps for determining the starting position of target local weather based on the location of each virtual character in a virtual environment, as provided in an embodiment of this application.
[0041] Figure 4 This is a flowchart of the steps performed after sending the first data to the slave server to which each virtual character belongs in the virtual environment, as provided in the embodiments of this application;
[0042] Figure 5 This is another step flowchart of the local weather control method in a virtual environment according to an embodiment of this application;
[0043] Figure 6 This is a flowchart of the steps for calculating the current location of the target local weather based on the first data sent by the master server, provided in an embodiment of this application.
[0044] Figure 7 This is a flowchart of the steps performed after calculating the current location of the target local weather based on the first data sent by the master server, as provided in an embodiment of this application.
[0045] Figure 8 This is a schematic diagram illustrating the interaction between the master server and each slave server provided in an embodiment of this application;
[0046] Figure 9 This is a flowchart of local weather control in a virtual environment provided in an embodiment of this application;
[0047] Figure 10 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0049] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0051] Virtual characters: These are movable objects within a virtual scene. These movable objects can be virtual people, virtual animals, anime characters, etc., such as people, animals, plants, oil drums, walls, and rocks displayed in a 3D virtual scene. Optionally, virtual characters are 3D models created using animation skeletal technology. Each virtual character has its own shape and volume within the 3D virtual scene, occupying a portion of the scene's space. The term "virtual character" generally refers to one or more virtual characters within a virtual scene. Taking a game application as an example, a virtual character is a movable object controlled by the user during gameplay.
[0052] Massively Multiplayer Online Role-Playing Game (MMORPG): This refers to a type of online game that supports multiple players simultaneously. Different clients can play in the same environment, cooperate to complete tasks, communicate online, and interact with non-player characters (NPCs). Typically, users control virtual characters by logging into their accounts on the client; each virtual character corresponds uniquely to a user account (ID). These user-controlled virtual characters play different roles in the virtual environment, such as generals, mages, scholars, and dancers. MMORPGs include genres such as strategy, action, adventure, simulation, sports, racing, and role-playing. The following example uses a game client as the illustration.
[0053] The methods provided in this application can be applied to 3D map programs, military simulation programs, first-person shooter (FPS) games, multiplayer online battle arena (MOBA) games, MMORPG games, virtual reality (VR) applications, augmented reality (AR) applications, etc. The following embodiments are illustrated using game applications as examples.
[0054] Virtual-scene-based games consist of maps of one or more game worlds. The virtual environment in the game simulates the environment of the real world. Users can control virtual characters in the game to walk, run, jump, shoot, fight, drive, be attacked by other virtual characters (other virtual characters are virtual characters controlled by other users), be damaged in the virtual environment, and attack other virtual characters. The game is highly interactive, and multiple users can team up online to play competitive games.
[0055] A 3D game scene is a 3D virtual scene displayed when an application runs on a terminal. This 3D game scene can be a simulation of the real world, a semi-simulated / semi-fictional virtual environment, or a purely fictional virtual environment. 3D game scenes feature changing weather conditions, such as sunny days, rainy days, snowy days, sandstorms, thunderstorms, heavy rain, heavy snow, sunrise, and sunset. Similar to the real world, the virtual environment is divided into different time periods, each corresponding to different weather effects. For example, 6:00 AM to 7:00 AM is sunrise time, and the virtual scene corresponds to sunrise weather effects; 4:00 PM to 5:00 PM is sunset time, and the virtual scene corresponds to twilight weather effects.
[0056] In video game applications, when the application is running, it renders weather that simulates the real world when entering a 3D game scene, giving players a more realistic experience when controlling virtual characters. Taking sandbox games as an example, sandbox games are a type of simulation game. The core of these games is "freedom and openness." The games typically lack explicit objectives; players are free to move, build, or pursue any goal permitted by the game's design. Alternatively, players can assume a role to complete the game's story and assigned tasks. These 3D game scenes often simulate real-world weather, providing a more realistic experience. For instance, in a rainy 3D game scene, raindrop textures are added to the front of the virtual camera for rendering, simulating real-world rain. However, in related technologies, the local weather in sandbox worlds lacks directional linear changes; it exists only within the overall area, lacking a left-to-right movement or the visual impact of controlling movement from far to near. Furthermore, in multiplayer online scenarios, the more players on the server, the more the main server needs to continuously traverse the terrain for different virtual characters' locations, resulting in excessive performance consumption. Moreover, since each map is randomly generated and located differently, it's impossible to reduce computational load by storing terrain data based on location.
[0057] To solve the above technical problems, such as Figure 1The diagram illustrates an application environment for a weather rendering method in a game scene, as shown in one embodiment. In this environment, the weather rendering method is applied to a terminal device 110, which has a client application installed that supports the operation of a 3D game scene. This application is a game application. Specifically, the terminal device can be a desktop terminal or a mobile terminal; a mobile terminal can be a mobile phone, tablet, laptop, wearable device, etc. The client corresponds to a weather system 120, which simulates various weather environments in the 3D game scene, such as lighting scenes, cloud scenes, rain scenes, snow scenes, hail scenes, and sandstorm scenes. For example, depending on the scene, the weather system can be further divided into a lighting subsystem, a cloud subsystem, and a particle subsystem. The lighting subsystem simulates lighting scenes in the 3D game scene, such as at least one of the following: sunrise lighting scene, sunset lighting scene, and moonlight lighting scene at night. The cloud subsystem simulates cloud scenes in the 3D game scene, such as at least one of the following: cloudy scene, overcast scene, etc. The particle subsystem is used to simulate at least one of the following scenarios in a 3D game scene: heavy rain, torrential rain, thunderstorms, sleet, hail, light snow, heavy snow, and sandstorms. The weather system calculates a target weather map corresponding to the local weather environment based on weather configuration data; this target weather map is a two-dimensional texture image. During client runtime, the terminal device 110 renders the target local weather map onto a two-dimensional image formed based on the 3D game scene, thereby creating the target local weather environment within the 3D game scene.
[0058] Reference Figure 2 , Figure 2 This is a flowchart of the steps of a local weather control method in a virtual environment provided in this application embodiment, which is executed by the main server and includes, but is not limited to, steps S201 to S205.
[0059] Step S201: Pre-set the movement direction and speed of various types of local weather in the local weather group;
[0060] Step S202: Randomly select at least one type of local weather from the local weather group as the target local weather;
[0061] Step S203: When the target local weather is detected to be triggered, record the start time of the target local weather.
[0062] Step S204: Determine the starting position of the target local weather based on the location of each virtual character in the virtual environment;
[0063] Step S205: Send the first data to the slave server to which each virtual character belongs in the virtual environment. The first data includes the start time, starting position, direction of movement, and speed of movement of the target local weather.
[0064] In this embodiment, the execution entity is the main server, which primarily handles game processes, performs game logic calculations, and provides game data to the slave servers belonging to each virtual character. The main server can pre-set the movement direction and speed of various types of local weather in a local weather group through the weather system, and then arbitrarily select at least one type of local weather as the target local weather. When the target local weather is detected as being triggered, its start time is recorded. Next, the location of each virtual character in the virtual environment is obtained, and the starting position of the target local weather is determined based on the location of each virtual character. Finally, the start time, starting position, movement direction, and movement speed of the target local weather are sent to the slave servers belonging to each virtual character in the virtual environment, so that virtual characters at any location in the virtual environment can know the start time, starting position, movement direction, and movement speed of the target local weather, and can calculate the movement trajectory of the target local weather in real time based on this information.
[0065] It should be noted that, in this embodiment, any direction (north, south, east, or west) can be randomly selected as the direction of movement of the target local weather, or any direction such as southeast, southwest, or 30 degrees east of east can be selected. This embodiment does not specifically limit the direction of movement of the target local weather; it can be determined based on the virtual environment type, the map type in the virtual environment, and the actual situation. Similarly, in this embodiment, the target local weather can be set to move at a constant speed and direction in a straight line, or it can be set to move at a constant acceleration and direction in a straight line, accelerating to a certain speed before moving at a constant speed. Other more complex speed settings are also possible, but this embodiment does not specifically limit the speed of movement of the target local weather.
[0066] It should be noted that the main server in this application embodiment can pre-set trigger events to detect whether the target local weather has been triggered. For example, the trigger event can be that a player triggers a certain local weather after completing certain preset tasks, or that a player triggers a certain local weather after entering some preset game modes, such as adventure game mode, disaster game mode, etc.; or that a player triggers a certain local weather by triggering a preset non-player character (NPC). Different trigger events correspond to corresponding trigger operations, and each trigger event has its own corresponding local weather. The specific trigger operation methods that may correspond to the trigger events, as well as the local weather corresponding to each trigger event, can be pre-configured or adjusted according to user needs. It should be understood that the above embodiments are only illustrative examples and are not limited thereto.
[0067] For example, a sandstorm could be triggered as a localized weather event after all players have been in the desert for 2 minutes. Alternatively, rain could be triggered for 1 minute after 10 minutes of gameplay. The triggering events for localized weather events in this embodiment can be set and adjusted according to specific circumstances and needs.
[0068] It should be noted that when local weather conditions within a local weather group meet the condition of simultaneous occurrence, multiple local weather conditions within the local weather group can be selected as multiple target local weather conditions. Then, the first data for these multiple target local weather conditions can be sent simultaneously to each slave server. This allows each slave server to control whether to render multiple target local weather conditions simultaneously in the area where each virtual character is located. For example, if rain and thunder can occur simultaneously, the first data for rain and thunder can be sent simultaneously to each slave server, allowing each slave server to control whether to render rain and thunder simultaneously in the area where each virtual character is located.
[0069] Reference Figure 3 , Figure 3 This is a flowchart of the steps for determining the starting position of target local weather based on the location of each virtual character in a virtual environment, as provided in the embodiments of this application, including but not limited to steps S301 to S304.
[0070] Step S301: Obtain the first set, which is the set of areas where each virtual character is located in the virtual environment;
[0071] Step S302: Select a first region from the first set. The first region is the region in the first set that is furthest from the direction of movement of the target local weather.
[0072] Step S303: Determine the second position from the first region. The second position is the position in the first region that is furthest from the direction of movement of the target local weather.
[0073] Step S304: Take the second position as the starting position of the target local weather, or arbitrarily select a position from the second position in the region away from the direction of movement of the target local weather as the starting position of the target local weather.
[0074] In this embodiment, the main server first obtains the locations of all virtual characters in the virtual environment in real time, and then determines the starting position of the target local weather based on the location of each virtual character. Instead of randomly selecting any location on the map as the starting position of the target local weather, it first obtains a first set, which is the set of locations of all virtual characters in the virtual environment; then, it selects a first region from the first set, which is the region in the first set furthest from the target local weather in the direction of movement; then, it determines a second position from the first region, which is the position in the first region furthest from the target local weather in the direction of movement; finally, it uses the second position as the starting position of the target local weather, or arbitrarily selects a position from the region furthest from the second position in the direction of movement of the target local weather. This method ensures that each virtual character in the virtual environment has the opportunity to render the target local weather, and prevents the target local weather from appearing in the area where a virtual character is located from the beginning because the selected starting position is behind the character.
[0075] For example, a virtual environment contains four players: A, B, C, and D. None of these players are in the desert area on the map. If a sandstorm were to randomly select a location in the desert terrain as the starting point, the sandstorm would be meaningless for these four players. Therefore, to avoid this situation, we first obtain the regions where each of the four players is located and sort them according to the pre-defined direction of movement of the target local weather. Specifically, the regions can be sorted from farthest to closest in terms of distance from the direction of movement of the target local weather. For example, if the sorting result is ABCD, then player A's region is determined to be the region farthest from the direction of movement of the target local weather, and player D's region is the region closest in terms of distance from the direction of movement of the target local weather. Then, we continue to find the position farthest from the direction of movement of the target local weather within player A's region, and mark it as the second position. This second position is then used as the starting point of the target local weather, or any position within the region farthest from the target local weather from the second position can be selected as the starting point of the target local weather. In this way, if the duration of the target local weather is long enough, and the areas where the four players are located meet the conditions for the occurrence of the local weather, then the target local weather will occur in the areas where the four players are located.
[0076] Understandably, after the main server sends the initial data—the start time, starting position, direction of movement, and speed of the target local weather—to the slave servers belonging to each virtual character, each slave server can calculate the real-time location of the target local weather, thus understanding its trajectory. Consequently, each slave server can also know which areas are currently experiencing the target local weather and when it should begin to appear in those areas.
[0077] Reference Figure 4 , Figure 4 This is a flowchart of the steps to be executed after the first data is sent to the slave server to which each virtual character belongs in the virtual environment, as provided in the embodiments of this application, including but not limited to steps S401 to S402.
[0078] Step S401: Accumulate the duration of the target local weather event;
[0079] Step S402: When the duration of the local weather exceeds the preset duration of the target local weather, send second data to each slave server. The second data is the end marker of the target local weather. The end marker includes the end time or the end command.
[0080] In this embodiment, after the master server sends the start time, starting position, direction of movement, and speed of the target local weather to the slave servers belonging to each virtual character, it begins to accumulate the duration of the target local weather. When the accumulated duration exceeds the preset duration of the target local weather, it sends second data to each slave server. The second data is an end marker for the target local weather, which includes an end time or an end command. This allows slave servers that are currently rendering the target local weather to stop rendering, and allows slave servers that have not yet started rendering the target local weather (where the target local weather's trajectory has not yet entered the virtual character's area) to know that the target local weather has ended and no longer need to continue calculating its trajectory in real time.
[0081] It should be noted that in this embodiment, the master server pre-sets the occurrence conditions and duration of various types of local weather in the local weather group. Then, the occurrence conditions of various types of local weather can be pre-sent to each slave server. This allows each slave server to determine whether the virtual character's location meets the occurrence conditions of the target local weather when the target local weather enters the virtual character's area. If it does, the slave server controls the target local weather to be rendered in the virtual character's area according to a pre-set movement direction and speed. If it does not meet the conditions, the slave server controls the target local weather not to be rendered in the virtual character's area. Simultaneously, after sending the first data to each slave server, the occurrence duration of the target local weather needs to be accumulated. When the occurrence duration exceeds the duration, an end marker for the target local weather is sent to each slave server.
[0082] It is understood that the conditions for the occurrence of localized weather in this embodiment can be set according to specific circumstances. For example, they can be set based on topography, landforms, and the buildings and organisms within the area. For instance, if the terrain is set to desert, sandstorms may occur.
[0083] In this embodiment, at least one type of target local weather data is sent to each slave server at preset time intervals. This allows each slave server to control whether to render the corresponding target local weather in the area where each virtual character is located, according to the direction and speed of movement, based on the first data. In other words, after the master server sends the end marker of the target local weather to each slave server, it can start the next round of target local weather control after a certain time interval. The target local weather in the next round can be the same as or different from the target local weather in the current round.
[0084] Reference Figure 5 , Figure 5 This is another step of the local weather control method in a virtual environment according to an embodiment of this application. It is executed by the slave server to which each virtual character belongs in the virtual environment, including but not limited to steps S501 to S503.
[0085] Step S501: Calculate the current location of the target local weather based on the first data sent by the main server. The first data includes the start time, starting location, direction of movement, and speed of movement of the target local weather.
[0086] Step S502: When the current location of the target local weather enters the target area, determine whether the target area meets the conditions for the occurrence of the target local weather. The target area is the area where the virtual character is located in the virtual environment.
[0087] Step S503: When the target area meets the conditions for the occurrence of target local weather, control the target local weather to be rendered in the target area according to the direction and speed of movement.
[0088] In this embodiment, the execution entity is the slave server to which each virtual character belongs in the virtual environment. Each slave server is mainly used to render the scene where the virtual character is currently located based on game data received from the master server. The current scene includes the game environment, buildings, creatures, and weather. In this embodiment, after receiving the start time, starting position, direction of movement, and speed of the target local weather, the slave server to which each virtual character belongs in the virtual environment can calculate the trajectory of the target local weather in real time. When the current position of the target local weather enters the area where the virtual character is located, it will determine whether the area where the virtual character is located meets the conditions for the appearance of the target local weather. If the area where the virtual character is located meets the conditions for the appearance of the target local weather, the target local weather is rendered in the target area according to its direction of movement and speed. If the area where the virtual character is located does not meet the conditions for the appearance of the target local weather, the target local weather is not rendered in the target area.
[0089] Reference Figure 6 , Figure 6 This is a flowchart of the steps for calculating the current location of the target local weather based on the first data sent by the master server, provided in the embodiments of this application, including but not limited to steps S601 to S603.
[0090] Step S601: Calculate the duration of the movement of the target local weather based on the current time and the start time of the target local weather.
[0091] Step S602: Calculate the movement distance of the target local weather based on its movement direction, speed, and duration.
[0092] Step S603: Calculate the current position of the target local weather based on the starting position and movement distance of the target local weather.
[0093] In this embodiment, since each slave server obtains the start time, starting position, direction of movement, and speed of movement of the target local weather sent by the master server, each slave server can calculate the real-time movement trajectory of the target local weather. Specifically, it can calculate the movement duration of the target local weather based on the current time and the acquired start time. Then, it can calculate the movement distance of the target local weather based on the movement direction, speed, and duration. Finally, it can calculate the current position of the target local weather based on its starting position and movement distance.
[0094] For example, the master server sends a target local weather forecast with a start time of t0, a direction of movement eastward, a speed of V0, and an initial position coordinate of (X0, Y0). Each slave server can calculate the real-time trajectory of the target local weather forecast based on this information. Specifically, if the current time is t1, the duration of the target local weather forecast's movement can be calculated as T = t1 - t0. Then, based on the eastward direction and the speed of movement V0, the distance traveled by the target local weather forecast can be calculated. For example, if the target local weather forecast is assumed to move at a constant speed of V0 in the eastward direction, the distance traveled by the target local weather forecast is S = V0 × T. Further, based on the initial position of the target local weather forecast, the current position of the target local weather forecast can be calculated as (X0 + S, Y0). In this way, the position of the target local weather forecast at any given time can be calculated, and thus the real-time trajectory of the target local weather forecast can be determined.
[0095] Reference Figure 7 , Figure 7 This is a flowchart of the steps performed after calculating the current location of the target local weather based on the first data sent by the master server, as provided in the embodiments of this application, including but not limited to steps S701 to S702.
[0096] Step S701: Determine the first position, which is the position furthest from the target local weather within the target area in terms of movement direction;
[0097] Step S702: When the current position of the target local weather exceeds the first position, determine that the current position of the target local weather has entered the target area.
[0098] In this embodiment, since each slave server can calculate the real-time movement trajectory of the target local weather, each slave server can determine whether the movement position of the target local weather has entered the virtual character's area. Specifically, it is necessary to first determine a first position in the virtual character's area, which is the position furthest from the movement direction of the target local weather within the virtual character's area. Then, it is determined whether the current position of the target local weather has exceeded the first position. If the current position of the target local weather has exceeded the first position, it is determined that the current position of the target local weather has entered the virtual character's area; if the current position of the target local weather has not exceeded the first position, it is determined that the current position of the target local weather has not yet entered the virtual character's area. At this time, it is necessary to continue to obtain the real-time movement position of the target local weather and continue to determine whether the movement position of the target local weather has entered the virtual character's area at the next moment.
[0099] In this embodiment, when it is determined that the current location of the target local weather has entered the area where the virtual character is located, if the area where the virtual character is located meets the conditions for the appearance of the target local weather, the target local weather is rendered in the target area according to the direction and speed of movement. Rendering of the target local weather stops in the target area only when an end marker for the target local weather is received from the main server. The end marker includes an end time or an end command.
[0100] For example, when the slave server belonging to player A determines that the current location of the sandstorm has entered player A's area, it first checks whether player A's area meets the conditions for the occurrence of a sandstorm, such as whether the terrain of player A's area is a desert. If player A's area meets the conditions for the occurrence of a sandstorm, such as the terrain of player A's area being a desert, then it controls the sandstorm to move eastward in a straight line at a constant speed V0 within player A's area. At this time, if the direction approaching player A is eastward, player A can see the sandstorm slowly approaching. If, before the sandstorm reaches player A's location, it receives a sandstorm end marker sent by the master server, then the slave server belonging to player A will control the sandstorm to stop rendering in player A's area. At this time, player A can see that the sandstorm has ended and no sandstorm has appeared at player A's location.
[0101] Reference Figure 8 , Figure 8 This is a schematic diagram illustrating the interaction between the master server and each slave server provided in an embodiment of this application. Figure 8As shown, there can be N slave servers, the specific number of which is determined by the number of virtual characters participating in the virtual environment game. For example, if there are 4 different players, the slave servers interacting with the master server are the slave servers belonging to these 4 players. The master server sends the calculated first data, namely the start time, starting position, direction of movement, and speed of movement of the target local weather, to each slave server so that each slave server can calculate the real-time movement trajectory of the target local weather based on the first data. When the calculated current position of the target local weather enters the area where the virtual character is located, it determines whether the area where the virtual character is located meets the conditions for the appearance of the target local weather. If it does, it controls the target local weather to be rendered in the area where the virtual character is located according to the obtained direction of movement and speed of movement; if it does not meet the conditions, it controls the target local weather not to be rendered in the area where the virtual character is located. When the master server sends the second data, namely the end marker of the target local weather, the slave servers that are currently rendering the target local weather will stop rendering and stop calculating the real-time movement position of the target local weather; the slave servers that have not yet rendered the target local weather will stop calculating the real-time movement position of the target local weather.
[0102] Reference Figure 9 , Figure 9 This is a flowchart of local weather control in a virtual environment provided in this application embodiment. It is executed interactively by the master server and the slave servers to which each virtual character belongs in the virtual environment, including but not limited to steps S901 to S911.
[0103] Step S901: The main server pre-sets the movement direction and speed of various types of local weather in the local weather group;
[0104] Step S902: Randomly select at least one type of local weather from the local weather group as the target local weather;
[0105] Step S903: When the target local weather is detected to be triggered, record the start time of the target local weather.
[0106] Step S904: Determine the starting position of the target local weather based on the location of each virtual character in the virtual environment;
[0107] Step S905: Send the first data to the slave server to which each virtual character belongs in the virtual environment. The first data includes the start time, starting position, direction of movement, and speed of movement of the target local weather.
[0108] Step S906: The server calculates the current location of the target local weather based on the first data sent by the master server;
[0109] Step S907: When the current location of the target local weather enters the target area, determine whether the target area meets the conditions for the occurrence of the target local weather. The target area is the area where the virtual character is located in the virtual environment.
[0110] Step S908: When the target area meets the conditions for the occurrence of local weather, control the local weather in the target area to be rendered according to the direction and speed of movement.
[0111] Step S909: The main server accumulates the duration of the target local weather occurrence;
[0112] Step S910: When the duration of the local weather exceeds the preset duration of the target local weather, send the second data to each slave server. The second data is the end marker of the target local weather. The end marker includes the end time or the end command.
[0113] Step S911: Receive the second data sent by the main server from the server and control the local weather in the target area to stop rendering.
[0114] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned local weather control method in a virtual environment. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.
[0115] Please see Figure 10 , Figure 10 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:
[0116] The processor 1001 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.
[0117] The memory 1002 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1002 and is called and executed by the processor 1001 in the virtual environment of the embodiments of this application for local weather control method.
[0118] Input / output interface 1003 is used to implement information input and output;
[0119] The communication interface 1004 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0120] Bus 1005 transmits information between various components of the device (e.g., processor 1001, memory 1002, input / output interface 1003, and communication interface 1004);
[0121] The processor 1001, memory 1002, input / output interface 1003 and communication interface 1004 are connected to each other within the device via bus 1005.
[0122] This application embodiment also provides a storage medium, which is a computer-readable storage medium, storing a computer program that, when executed by a processor, implements the aforementioned local weather control method in a virtual environment.
[0123] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0124] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0125] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.
[0126] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0127] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0128] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0129] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0130] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0131] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0132] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0133] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0134] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.
Claims
1. A method for local weather control in a virtual environment, characterized in that, The method, executed by the slave server to which each virtual character belongs in the virtual environment, includes: Based on the first data sent by the main server, the current position of the target local weather is calculated. The first data includes the start time, starting position, direction of movement, and speed of movement of the target local weather. The first data is determined by the main server through the following steps: pre-setting the direction of movement and speed of movement of various types of local weather in a local weather group; arbitrarily selecting at least one type of local weather from the local weather group as the target local weather; when the target local weather is detected to be triggered, recording the start time of the target local weather; determining the starting position of the target local weather based on the location of each virtual character in the virtual environment. Specifically, determining the starting position of the target local weather based on the location of each virtual character in the virtual environment includes: obtaining a first set, which is a set of locations of each virtual character in the virtual environment; selecting a first region from the first set, which is the region in the first set furthest from the direction of movement of the target local weather; determining a second position from the first region, which is the position in the first region furthest from the direction of movement of the target local weather; and using the second position as the starting position of the target local weather, or arbitrarily selecting a position from the region furthest from the second position as the starting position of the target local weather. Determine a first position, which is the position furthest from the target local weather in the target area; the target area is the area where the virtual character is located in the virtual environment. When the current position of the target local weather exceeds the first position, it is determined that the current position of the target local weather has entered the target area; When the current location of the target local weather enters the target area, it is determined whether the target area meets the occurrence conditions of the target local weather. The occurrence conditions are preset by the main server and sent to the slave servers to which each virtual character in the virtual environment belongs. When the target area meets the conditions for the occurrence of the target local weather, the target local weather is rendered in the target area according to the direction and speed of movement.
2. The method according to claim 1, characterized in that, Based on the first data sent by the main server, the current location of the target local weather is calculated, including: The duration of the movement of the target local weather is calculated based on the current time and the start time of the target local weather. The movement distance of the target local weather is calculated based on the movement direction, movement speed, and movement duration of the target local weather. The current location of the target local weather is calculated based on the starting location of the target local weather and the movement distance.
3. The method according to claim 1, characterized in that, After controlling the rendering of the target local weather in the target area according to the movement direction and speed, the method includes: When the second data sent by the main server is received, the system controls the rendering of the target local weather to stop in the target area. The second data is the end marker of the target local weather, and the end marker includes an end time or an end command.
4. A method for local weather control in a virtual environment, characterized in that, The method, executed by the master server, includes: Pre-set the movement direction and speed of various types of local weather in the local weather group; Select at least one type of local weather from the group of local weather as the target local weather; When the target local weather is detected to be triggered, the start time of the target local weather is recorded; Based on the location of each virtual character in the virtual environment, the starting position of the target local weather is determined. This determination includes: obtaining a first set, which is a set of locations of each virtual character in the virtual environment; selecting a first region from the first set, where the first region is the region in the first set furthest from the direction of movement of the target local weather; determining a second position from the first region, where the second position is the position in the first region furthest from the direction of movement of the target local weather; and using the second position as the starting position of the target local weather, or arbitrarily selecting any position from the region furthest from the second position in the direction of movement of the target local weather as the starting position of the target local weather. The first data is sent to the slave servers belonging to each virtual character in the virtual environment, so that the slave servers can calculate the current position of the target local weather based on the first data sent by the master server, and determine the first position, which is the position furthest from the target local weather in the direction of movement within the target area. The target area is the area where the virtual character is located in the virtual environment. When the current position of the target local weather exceeds the first position, it is determined that the current position of the target local weather has entered the target area. When the current position of the target local weather has entered the target area, it is determined whether the target area meets the occurrence conditions of the target local weather. When the target area meets the occurrence conditions of the target local weather, the target local weather is controlled to be rendered in the target area according to the movement direction and movement speed. The first data includes the start time, starting position, movement direction and movement speed of the target local weather. The occurrence conditions are preset by the master server and sent to the slave servers belonging to each virtual character in the virtual environment.
5. The method according to claim 4, characterized in that, After sending the first data to the slave server to which each virtual character belongs in the virtual environment, the method includes: The total duration of the local weather events affecting the target area is recorded. When the duration of the occurrence exceeds the preset duration of the target local weather, second data is sent to each of the slave servers. The second data is an end marker of the target local weather, and the end marker includes an end time or an end command.
6. The method according to claim 4, characterized in that, The method further includes: The duration of various types of local weather in the local weather group is preset; At preset time intervals, at least one type of the first data of the target local weather is sent to each of the slave servers, so that each of the slave servers controls whether to render the corresponding target local weather in the area where each virtual character is located according to the movement direction and movement speed based on the first data.
7. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1 to 6.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.