Virtual object simulation method and device, electronic equipment, computer readable storage medium and computer program product
The programming building block program is obtained through the visual programming editor interface of multiple virtual objects and converted into control code, which solves the problem of poor virtual object simulation results in the prior art, and realizes parallel physical simulation of multiple virtual objects, improving interactivity and applicability.
Patent Information
- Application Number
- CN202410184192.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-18
- Publication Date
- 2025-08-19
AI Technical Summary
In the prior art, only one virtual object is supported for visual programming and simulation, resulting in poor physical simulation of virtual objects and limited interaction.
The programming building block program is obtained through a visual programming editor interface for multiple virtual objects and converted it into executable control code to realize parallel physical simulation of multiple virtual objects.
It improves the physical simulation effect and interactivity of virtual objects, and expands the applicable scenarios and practicality of virtual objects.
Smart Images

Figure CN120502095A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device, computer-readable storage medium, and computer program product for simulating a virtual object. Background Art
[0002] In related technologies, users achieve physical simulation of a virtual object's motion through visual programming on a virtual simulation platform, creating an intuitive and interactive programming experience. However, because these technologies only support visual programming and simulation of a single object, the interactivity of the simulation is limited, resulting in poor physical simulation of the virtual object. Summary of the Invention
[0003] The embodiments of the present application provide a simulation method, device, electronic device, computer-readable storage medium, and computer program product for a virtual object, which can improve the physical simulation effect of the virtual object and increase the applicable scenarios and practicality of the physical simulation of the virtual object.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present invention provides a method for simulating a virtual object, including:
[0006] For each of the plurality of virtual objects, obtaining a programming building block program edited for the virtual object based on a visual programming editor interface of the virtual object;
[0007] When receiving object simulation instructions for the plurality of virtual objects, converting the programming building block programs of the respective virtual objects into executable control codes for the respective virtual objects;
[0008] Based on the executable control code of each virtual object, physical simulation is performed on the movement process of each virtual object in parallel, and the simulated movement process of each virtual object is displayed.
[0009] The present invention also provides a device for simulating a virtual object, including:
[0010] An acquisition module, configured to acquire, for each of the plurality of virtual objects, a programming building block program edited for the virtual object based on a visual programming editor interface of the virtual object;
[0011] a conversion module, configured to, upon receiving an object simulation instruction for the plurality of virtual objects, convert the programming building block program of each of the virtual objects into an executable control code for each of the virtual objects;
[0012] The simulation module is used to perform physical simulation on the motion process of each virtual object in parallel based on the executable control code of each virtual object, and display the simulated motion process of each virtual object.
[0013] An embodiment of the present application further provides an electronic device, including:
[0014] a memory for storing computer-executable instructions;
[0015] The processor is configured to implement the virtual object simulation method provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.
[0016] An embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the virtual object simulation method provided in the embodiment of the present application is implemented.
[0017] An embodiment of the present application further provides a computer program product, comprising computer executable instructions or a computer program, which, when executed by a processor, implements the virtual object simulation method provided in an embodiment of the present application.
[0018] The embodiments of the present application have the following beneficial effects:
[0019] By applying the above-mentioned embodiment of the present application, for each virtual object among multiple virtual objects, a programming building block program for editing the virtual object is obtained based on the visual programming editor interface of the virtual object; when an object simulation instruction for the multiple virtual objects is received, the programming building block program for each virtual object is converted into an executable control code for each virtual object; based on the executable control code for each virtual object, the motion process of each virtual object is physically simulated in parallel, and the simulated motion process of each virtual object is displayed. In this way, by visually programming multiple virtual objects, the physical simulation of multiple virtual objects is realized, which can increase the interactivity of the physical simulation of the virtual objects, improve the physical simulation effect of the virtual objects, and thus increase the applicable scenarios and practicality of the physical simulation of the virtual objects. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 Schematic diagram of the architecture of a virtual object simulation system provided by an embodiment of the present application;
[0021] Figure 2 is a structural diagram of an electronic device provided in an embodiment of the present application;
[0022] Figure 3 Schematic diagram of a virtual object simulation method according to an embodiment of the present application;
[0023] Figure 4 Schematic diagram of the display of a virtual scene provided by an embodiment of the present application;
[0024] Figure 5A is a display schematic diagram of the information display area provided in an embodiment of the present application;
[0025] Figure 5B is a display schematic diagram of the information display area provided in an embodiment of the present application;
[0026] Figure 6 This is a schematic diagram of the display of the visual programming editor interface provided by the embodiment of the present application;
[0027] Figure 7A This is a schematic diagram of the display of the visual programming editor interface provided by the embodiment of the present application;
[0028] Figure 7B This is a schematic diagram of the display of the visual programming editor interface provided by the embodiment of the present application;
[0029] Figure 8 is a schematic diagram of a simulated motion process provided by an embodiment of the present application;
[0030] Figure 9 is a schematic diagram of a simulated motion process provided by an embodiment of the present application;
[0031] Figure 10 This is a diagram showing the conversion relationship between building blocks and codes provided in an embodiment of the present application;
[0032] Figure 11 3 is a flow chart of a method for simulating a virtual object provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solutions and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0034] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0035] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0036] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0037] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0038] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant laws and regulations when applied in examples, and the informed consent or separate consent of the personal information subject should be obtained. Subsequent data use and processing should be carried out within the scope of authorization of laws and regulations and the personal information subject.
[0039] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0040] 1) Client: An application running in a terminal that provides various services, such as a physical simulation client (also called a virtual simulation platform) that supports virtual object simulation.
[0041] 2) In response to: used to indicate the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more operations executed can be in real time or with a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations executed are executed.
[0042] 3) Visual programming is a method of programming using a visual interface and a graphical programming language. Compared to traditional text-based programming, visual programming is more intuitive, easier to understand and operate, and can help programming beginners get started more quickly. Visual programming typically uses a graphical programming language, combining different basic building blocks through dragging and dropping, connecting, and other methods, and performing simple programming operations to form specific program logic.
[0043] 4) A physical simulation platform (also referred to as a virtual simulation platform in this application) is computer software or a system that uses mathematical models and algorithms to simulate the motion and interaction of objects in the real world. Physical simulation platforms typically provide a set of tools and interfaces that enable users to create, edit, and run physical simulation experiments to study real-world physical phenomena and laws. These platforms can be applied in scientific research, education, and training, and other fields.
[0044] 5) Virtual scenes can be simulations of the real world, virtual environments that are partially simulated and partially fictional, or purely fictional. Virtual scenes can be two-dimensional, 2.5-dimensional, or three-dimensional. For example, a virtual scene can include the sky, land, and ocean, with the land including environmental elements such as deserts and cities. Virtual scenes provide a space for virtual objects to display and interact. A virtual scene can be considered a container for hosting and organizing virtual objects.
[0045] 6) Virtual objects are entities in virtual scenes, including characters (such as virtual robots), animals (such as virtual robot dogs), objects (such as virtual cars), buildings, environmental elements, etc. They have various attributes (such as position, size, color, etc.) and behaviors (such as movement, jumping, attacking, interaction, etc.).
[0046] Based on the above description of the nouns and terms involved in the embodiments of this application, the embodiments of this application are described in detail below. The embodiments of this application provide a method, device, electronic device, computer-readable storage medium, and computer program product for simulating virtual objects, which can improve the physical simulation effect of virtual objects and increase the applicable scenarios and practicality of the physical simulation of virtual objects.
[0047] The following describes the simulation system of virtual objects provided by the embodiment of the present application. Figure 1 , Figure 11 is a schematic diagram of the architecture of a virtual object simulation system provided in an embodiment of the present application. To support an exemplary application, virtual object simulation system 100 includes: server 200, network 300, and terminal 400. Terminal 400 is connected to server 200 via network 300. Network 300 can be a wide area network (WAN), a local area network (LAN), or a combination of the two, using wireless or wired links for data transmission.
[0048] Here, the terminal 400 (for example, running a virtual simulation client that supports virtual object simulation) responds to a display instruction for the virtual scene and sends a request to obtain the scene data of the virtual scene to the server 200; the server 200 receives the request to obtain the scene data of the virtual scene sent by the terminal 400; in response to the acquisition request, the scene data of the virtual scene is returned to the terminal 400; based on the scene data of the virtual scene, the virtual scene is rendered and displayed, and the virtual scene includes multiple virtual objects; when a visual programming instruction for multiple virtual objects is received, for each virtual object, based on the visual programming editor interface of the virtual object, a programming building block program for editing the virtual object is obtained; when an object simulation instruction for multiple virtual objects is received, the programming building block program for each virtual object is converted into an executable control code for each virtual object; based on the executable control code of each virtual object, the movement process of each virtual object is physically simulated in parallel, and the simulated movement process of each virtual object is displayed.
[0049] In some embodiments, the virtual object simulation method provided in the embodiments of the present application is implemented by an electronic device, for example, it can be implemented by a terminal alone, it can also be implemented by a server alone, or it can be implemented by a terminal and a server in collaboration. The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, games, metaverse, website development, data science, industrial simulation, simulation teaching, visual programming education, user-generated content (UGC) scenarios, etc.
[0050] In some embodiments, the electronic device for implementing the simulation method of virtual objects provided in the embodiments of the present application may be various types of terminals or servers. Among them, the server (such as server 200) may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. The terminal (such as terminal 400) may be a laptop, a tablet computer, a desktop computer, a smart phone, an intelligent voice interaction device (such as a smart speaker), a smart home appliance (such as a smart TV), a smart watch, a car terminal, a wearable device, a virtual reality (VR) device, an aircraft, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected via wired or wireless communication, and the embodiments of the present application do not limit this.
[0051] In some embodiments, the simulation method of the virtual object provided in the embodiments of the present application can be implemented with the aid of cloud technology. Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and network in a wide area network or a local area network to realize the calculation, storage, processing, and sharing of data. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model application. It can form a resource pool that is used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing resources and storage resources. As an example, the server (such as server 200) can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDNs), and big data and artificial intelligence platforms.
[0052] In some embodiments, the terminal or server can implement the simulation method of the virtual object provided by the embodiment of the present application by running various computer executable instructions or computer programs. For example, the computer executable instructions can be commands, machine instructions or software instructions at the microprogram level. The computer program can be a native program or software module in the operating system; it can be a local (Native) application (Application, APP), that is, a program that needs to be installed in the operating system to run, such as a virtual simulation client that supports virtual object simulation; it can also be a small program that can be embedded in any APP, that is, a program that can be run only by downloading it to a browser environment. In short, the above-mentioned computer executable instructions can be instructions in any form, and the above-mentioned computer program can be an application, module or plug-in in any form.
[0053] The following describes an electronic device for implementing a virtual object simulation method provided by an embodiment of the present application. Figure 2 , Figure 2 Schematic diagram of the structure of the electronic device provided in the embodiment of the present application. The electronic device 500 provided in the embodiment of the present application can be a terminal or a server. Figure 2 As shown, the electronic device 500 includes: at least one processor 510, a memory 550, at least one network interface 520 and a user interface 530. The various components in the electronic device 500 are coupled together via a bus system 540. It is understood that the bus system 540 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 540 is not described in detail. Figure 2 Various buses are labeled as bus system 540 .
[0054] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0055] The user interface 530 includes one or more output devices 531 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0056] The memory 550 may be removable, non-removable, or a combination thereof. The memory 550 may include one or more storage devices physically remote from the processor 510. The memory 550 includes volatile memory or non-volatile memory, or may include both volatile memory and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.
[0057] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplified below.
[0058] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0059] A network communication module 552 for reaching other electronic devices via one or more (wired or wireless) network interfaces 520 , exemplary network interfaces 520 including Bluetooth, Wi-Fi, and Universal Serial Bus (USB);
[0060] a presentation module 553 for enabling presentation of information via one or more output devices 531 (e.g., a display screen, a speaker, etc.) associated with the user interface 530 (e.g., a user interface for operating peripheral devices and displaying content and information);
[0061] The input processing module 554 is configured to detect one or more user inputs or interactions from one of the one or more input devices 532 and to translate the detected inputs or interactions.
[0062] In some embodiments, the virtual object simulation device provided in the embodiments of the present application can be implemented in software. Figure 2 A simulation device 555 of a virtual object stored in a memory 550 is shown, which can be software in the form of a program and a plug-in, including the following software modules: an acquisition module 5551, a conversion module 5552 and a simulation module 5553. These modules are logical, and therefore can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.
[0063] The following describes the simulation method of a virtual object provided by an embodiment of the present application. As mentioned above, the simulation method of a virtual object provided by an embodiment of the present application is implemented by an electronic device, for example, it can be implemented by a server or a terminal alone, or by a server and a terminal in collaboration. Therefore, the execution subject of each step will not be repeated below. Figure 3 , Figure 3 : is a flow chart of a method for simulating a virtual object provided in an embodiment of the present application. The method for simulating a virtual object provided in an embodiment of the present application includes:
[0064] Step 101: For each virtual object among a plurality of virtual objects, a programming building block program for editing the virtual object is obtained based on a visual programming editor interface of the virtual object.
[0065] In step 101, the following processing is performed for each virtual object in the plurality of virtual objects: a programming block program for editing the virtual object is obtained based on a visual programming editor interface of the virtual object. The plurality of virtual objects can be displayed in a virtual scene, and the number of virtual objects is N (N is an integer greater than 1); the virtual object can be pre-built by the user in the virtual scene, for example, a virtual object building interface can be provided, in which object basic modules for forming the virtual object are provided, and the user can build the virtual object by selecting various object basic modules; of course, the virtual object can also be provided together with the virtual scene (for example, provided by a virtual simulation platform), for example, the scene data of the obtained virtual scene includes the data of the virtual object, so when rendering and outputting the virtual scene, the virtual object is also rendered and output based on the data of the virtual object; the types of the plurality of virtual objects can be consistent or inconsistent, for example, the types of the virtual objects can include virtual robots, virtual robot dogs, virtual aircraft, virtual vehicles, etc. The virtual scene can be a virtual scene provided by the virtual simulation platform, such as a virtual city street scene, a virtual environment terrain, etc., which provides an environment for movement and interaction for the virtual objects.
[0066] The visual programming editor interface is the interface of the visual programming editor. Through the visual programming editor interface, users can write and construct control programs for virtual objects. For example, users can write and debug control programs for virtual objects in the visual programming editor interface by dragging, connecting, etc. The control program of the virtual object is the programming building block program edited for the virtual object; each virtual object can have its corresponding visual programming editor interface. For example, when the user triggers a visual programming instruction for a virtual object, the visual programming editor interface of the virtual object is displayed. The visual programming editor interface of each virtual object is generally the same. The number of programming building block programs edited for virtual objects can be M (M is an integer greater than 0). Users can edit corresponding programming building block programs for virtual objects as needed. Each programming building block program is a control instruction for a virtual object, used to control the movement behavior of the virtual object. Specifically, the programming building block program is a control instruction or control program obtained by the user by editing the editable parameters in the basic building block program. The basic building block program is a control instruction or control program written by the user to control the movement behavior of the virtual object.
[0067] In some embodiments, before obtaining the programming building block program for editing virtual objects, the following steps may also be performed: displaying a picture of a virtual scene, and displaying multiple virtual objects in the picture of the virtual scene; for each virtual object, in response to a visual programming instruction for the virtual object triggered based on the picture of the virtual scene, displaying a visual programming editor interface for the virtual object.
[0068] Here, a virtual scene is displayed, and multiple virtual objects are displayed in the virtual scene. For example, see Figure 4 , Figure 4 : This is a schematic diagram of the display of a virtual scene provided by an embodiment of the present application. Here, the virtual scene includes 4 virtual objects (i.e., virtual robot dogs), arranged in a 2*2 layout, and a corresponding name is displayed for each virtual object (e.g., RobotGogo1-RobotGogo4); users can observe the virtual objects in the virtual scene from different perspectives, such as Figure 4 As shown in (1), it is a virtual object from the side view. Figure 4 As shown in (2), it is a virtual object in a top-down perspective. Based on this, the user can trigger the visual programming instructions for each virtual object based on the screen of the virtual scene. For example, for each virtual object, the user can trigger a second trigger operation for the virtual object (including but not limited to a long press operation, a double-click operation, a click operation, etc.), and then receive the visual programming instructions for the virtual object in response to the second trigger operation for the virtual object. Continuously, in response to the visual programming instructions for the virtual object, the visual programming editor interface of the virtual object is displayed. In this way, corresponding visual programming can be implemented for each virtual object in the virtual scene, and then the simulation of multiple virtual objects can be implemented based on the control program of the visual programming, thereby simulating the collaborative interaction between multiple objects on the virtual simulation platform.
[0069] In some embodiments, in response to a first trigger operation (such as a click operation) on a virtual object, an information display area of the virtual object may also be displayed, thereby displaying relevant information of the virtual object in the information display area. Figure 5A and Figure 5B , Figure 5A and Figure 5B This is a schematic diagram of the information display area provided by the embodiment of the present application. Here, see Figure 5A When a click operation is triggered on the virtual object "RobotGogo1", the relevant information of "RobotGogo1" (such as name, coordinate position, rotation angle, speed, etc.) is displayed in the virtual object information display area. Here, the coordinate position of "RobotGogo1" is (203, 663, 0.27); see Figure 5B When a click operation is triggered on the virtual object "RobotGogo4", relevant information of "RobotGogo4" (such as name, coordinate position, rotation angle, speed, etc.) is displayed in the information display area of the virtual object. Here, the coordinate position of "RobotGogo4" is (206, 666, 0.27).
[0070] In some embodiments, the following steps may be performed: in a screen of a virtual scene, an object simulation control is displayed; in response to a trigger operation on the object simulation control, an object simulation instruction for a plurality of virtual objects is received; based on this, based on the executable control code of each virtual object, the following steps may be performed to perform physical simulation on the movement process of each virtual object in parallel: based on the executable control code of each virtual object, the movement process of each virtual object is physically simulated in parallel in the virtual scene.
[0071] Here, an object simulation control can be provided in the virtual scene screen, which is used to physically simulate the motion process of multiple virtual objects in the virtual scene. When a trigger operation is received for the object simulation control, an object simulation instruction for the multiple virtual objects is received in response to the trigger operation for the object simulation control. At this time, based on the executable control code of each virtual object, the motion process of each virtual object can be physically simulated in parallel in the virtual scene, thereby displaying the simulated motion process of each virtual object in the virtual scene. In this way, in a specific scenario, the simulation of multiple virtual objects can be achieved based on visual programming.
[0072] In some embodiments, the following steps may be performed: displaying a virtual scene switching control; based on this, after displaying the simulated movement process of each virtual object, the following steps may also be performed: based on the virtual scene switching control, receiving a scene switching instruction indicating that the virtual scene is to be switched to a target virtual scene; in response to the scene switching instruction, switching the screen displaying the virtual scene to a screen displaying the target virtual scene.
[0073] Here, a virtual scene switching control can also be provided for users to switch virtual scenes for physical simulation. When a trigger operation for the virtual scene switching control is received, multiple candidate virtual scenes for selection are displayed, and in response to the selection operation for the target virtual scene among the multiple candidate virtual scenes, a scene switching instruction is received to instruct the virtual scene to switch to the target virtual scene. At this time, in response to the scene switching instruction, the screen of the displayed virtual scene is switched to the screen showing the target virtual scene, so that based on the executable control code of each virtual object, the motion process of each virtual object can be physically simulated in parallel in the target virtual scene, and the simulated motion process of each virtual object can be displayed in the target virtual scene. In this way, providing multiple virtual scenes for users to choose from can help users realize the simulation of multiple virtual objects based on visual programming in different virtual scenes.
[0074] In some embodiments, the visual programming editor interface displays addition controls for each basic building block program in a plurality of basic building block programs; based on this, the visual programming editor interface based on the virtual object can execute the following steps to obtain the programming building block program for editing the virtual object: based on the addition control, an addition instruction for a target basic building block program in a plurality of basic building block programs is received; in response to the addition instruction for the target basic building block program, an editing control for the target basic building block program is displayed in the visual programming editor interface; in response to the editing operation for the target basic building block program triggered based on the editing control, a programming building block program for editing the virtual object is generated.
[0075] Here, the visual programming editor interface is displayed with the addition control of each basic building block program in a plurality of basic building block programs. For example, the addition control of each basic building block program in a plurality of basic building block programs can be displayed in the building block addition area of the visual programming editor interface. Each addition control is used to add a basic building block program for a user to a virtual object. Based on the addition control, an addition instruction for a target basic building block program in a plurality of basic building block programs is received. For example, in response to a triggering operation (such as a click operation, a long press operation, a drag operation, etc.) of the addition control for the target basic building block program, an addition instruction for the target basic building block program is received. When an addition instruction for the target basic building block program is received, in response to the addition instruction for the target basic building block program, an edit control for the target basic building block program is displayed in the visual programming editor interface. The edit control is used to edit the target basic building block program for the user, such as editing the parameters in the target basic building block program, etc. In response to the edit operation for the target basic building block program triggered based on the edit control, a programming building block program edited for the virtual object is generated. In actual applications, the basic building block program can be a control program for controlling movement, speed, steering, rotation angle, jump height, jump direction, etc. The editing control of the basic building block program can be used to edit the parameters of the basic building block program, such as editing movement, speed, steering, rotation angle, etc., thereby generating a programming building block program through editing operations.
[0076] In some embodiments, the following steps may be performed: displaying an information display area in a visual programming editor interface; and displaying object-related information of a virtual object in the information display area. The visual programming editor interface further includes an information display area for a virtual object, so that object-related information of the virtual object can be displayed in the information display area to help a user understand which virtual object a control program is being written for.
[0077] For example, see Figure 6 , Figure 6: This is a schematic diagram of the display of the visual programming editor interface provided by an embodiment of the present application. Here, when a double-click operation is triggered on the virtual object "RobotGogo1" in the virtual scene screen, the visual programming editor interface of "RobotGogo1" is displayed. The programming toolbar (i.e., the building block addition area) is displayed in the visual programming editor interface, including addition controls for adding basic building block programs, such as "events", "variables", "controls", etc.; in the information display area of the visual programming editor interface, object-related information of "RobotGogo1" is also displayed, such as name, coordinate position, rotation angle, speed, etc. Here, the coordinate position of "RobotGogo1" is (203, 663, 0.27).
[0078] In some embodiments, an editing control is displayed in the building block program editing area of the visual programming editor interface; based on this, based on the adding control, the following steps can be performed to receive an adding instruction for a target basic building block program among multiple basic building block programs: a drag operation of dragging the adding control of the target basic building block program to the building block program editing area is received; in response to a release operation for the drag operation, an adding instruction for the target basic building block program among multiple basic building block programs is received.
[0079] Here, the addition of basic building block programs is achieved through a drag-and-drop operation. Specifically, the user can add a basic building block program by dragging the addition control of the basic building block program to the building block program editing area of the visual programming editor interface. When a drag operation is received to drag the addition control of the target basic building block program to the building block program editing area, if a release operation for the drag operation is received, an addition instruction for the target basic building block program in multiple basic building block programs can be received in response to the release operation for the drag operation. In this way, the addition of basic building block programs is achieved through a drag-and-drop operation, which can simplify human-computer interaction operations and improve the editing efficiency of visual programming. As an example, see Figure 7A and Figure 7B , Figure 7A and Figure 7B This is a schematic diagram showing the display of the visual programming editor interface provided by the embodiment of the present application. Figure 7A As shown, users can perform visual block programming for RobotGogo1 by dragging the basic block program from the programming toolbar to the block program editing area. Here, the programming block program written for RobotGogo1 is as follows: After clicking Run, RobotGogo1 first turns left 45 degrees at 10% power for 3 seconds, and then starts playing the red envelope asking animation. Figure 7B, users can perform visual block programming for RobotGogo2 / 3 / 4 to write control programs to control the operation of RobotGogo2 / 3 / 4. Figure 7B As shown in (1), the programming block program for RobotGogo2 is as follows: After clicking on the run button, RobotGogo2 first turns right 45 degrees with 10% power for 3 seconds, and then starts to play the lying animation. Figure 7B As shown in (2), the programming block program for RobotGogo3 is as follows: After clicking "Run", RobotGogo3 first turns left 135 degrees with 10% power for 3 seconds, and then starts to play the rolling animation. Figure 7B As shown in (3), the programming block program written for RobotGogo4 is as follows: After clicking "Run", RobotGogo4 first turns right 135 degrees with 10% power for 3 seconds, and then starts playing the dancing animation.
[0080] In some embodiments, after obtaining the programming building block program for editing the virtual object, the following steps may also be performed: the object identification information of the virtual object and the programming building block program for editing the virtual object are associated and stored; and the stored programming building block program for editing the virtual object is loaded into the visual programming editor where the visual programming editor interface is located.
[0081] Here, after the user edits the programming building block program for the virtual object, the object identification information of the virtual object and the programming building block program edited for the virtual object can be associated and stored, and the stored programming building block program edited for the virtual object can be loaded into the visual programming editor where the visual programming editor interface is located. In this way, after the user completes editing the programming building block program for one virtual object, he can perform visual programming on the next virtual object, thereby realizing visual programming of multiple virtual objects, and then realizing simulation of multiple virtual objects based on visual programming.
[0082] Step 102: When object simulation instructions for multiple virtual objects are received, the programming building block programs of the virtual objects are converted into executable control codes for the virtual objects.
[0083] In step 102, after the visual programming for multiple virtual objects is completed, object simulation instructions for the multiple virtual objects can be triggered to physically simulate the motion of the multiple virtual objects. For example, an object simulation control can be provided. When a trigger operation is received for the object simulation control, object simulation instructions for the multiple virtual objects are received in response to the trigger operation. At this time, the programming building block program for each virtual object is obtained and converted into executable control code for each virtual object. Here, for each virtual object, the motion behavior of the virtual object can be controlled by executing the executable control code of the virtual object.
[0084] For example, see Figure 8 , Figure 8 This is a schematic diagram of the simulated motion process provided by an embodiment of the present application. Here, in response to the object simulation instruction, RobotGogo1-RobotGogo4 respectively move according to their respective executable control codes, that is, RobotGogo1 turns left 45 degrees at 10% power (duration is 3 seconds), RobotGogo2 turns right 45 degrees at 10% power (duration is 3 seconds), RobotGogo3 turns left 135 degrees at 10% power (duration is 3 seconds), and RobotGogo4 turns right 135 degrees at 10% power (duration is 3 seconds). In this way, Figure 8 As shown in (1) and (2), Figure 8 (1) is the side view. Figure 8 (2) is the top view. Three seconds after the simulation command is triggered, RobotGogo1 faces 45 degrees, RobotGogo2 faces 135 degrees, RobotGogo3 faces -135 degrees, and RobotGogo1 faces -45 degrees. Figure 9 , Figure 9 Schematic diagram of the simulated motion process provided by the embodiment of the present application. Figure 9 As shown, after 3 seconds, the animations of the four virtual objects are played respectively, namely, RobotGogo1 performs the animation of asking for red envelopes, RobotGogo2 performs the animation of lying down, RobotGogo3 performs the animation of dancing, and RobotGogo4 performs the animation of rolling.
[0085] In some embodiments, the following steps can be executed to convert the programming building block program of each virtual object into the executable control code of each virtual object: the following processing is performed for each virtual object: the programming building block program of the virtual object is converted into the main logic code; the script code of the virtual object is obtained, and the script code includes the main logic function; the main logic code is inserted into the main logic function included in the script code to obtain the executable control code of the virtual object.
[0086] Here, the following process can be performed for each virtual object separately: first, the programming building block program of the virtual object is converted into main logic code. This main logic code can be in the target programming language, such as C#. In some embodiments, before converting the programming building block program of each virtual object into the executable control code of each virtual object, the following steps can be performed: register a code generator and define a generator function for the programming building block program of each virtual object. Specifically, first, a custom code generator is registered, such as registering a new code generator named "CSharp", which can be achieved by calling the "Blockly.registerGenerator" method; then, for each programming building block program of each virtual object, a corresponding generator function is defined, which is used to convert the programming building block program into C# code. Based on this, the following steps can be performed to convert the programming building block program of the virtual object into main logic code: calling the code generator, and based on the generator function of the programming building block program of the virtual object, performing parameter parsing on the programming building block program of the virtual object to obtain the main logic code. Here, the code generator is called, and based on the generator function of the programming building block program of the virtual object, performing parameter parsing on the programming building block program of the virtual object to obtain the main logic code. Specifically, a unified data format is used when saving and loading a programming building block program, for example, an extensible markup language (XML) format. The program is then saved in a file according to the connection order of the programming building block program, ensuring that the order and structure of the programming building block program remain unchanged when the programming building block program is imported and exported. At the same time, the programming building block program is converted into C# code using the same code generator, that is, the code generator parses XML in order based on a generator function, parses out each parameter in the programming building block program, and then generates a one-to-one code with the programming building block program. If there are multiple programming building block programs, the code of each programming building block program is combined to obtain the main logic code. If there is only one programming building block program, the code of the programming building block program is the main logic code.
[0087] After obtaining the main logic code of the programming building block program of each virtual object, the script code of the virtual object is obtained, which includes the main logic function (MainLogic function), and then the main logic code is inserted into the main logic function included in the script code to obtain the executable control code of the virtual object.
[0088] Step 103: Based on the executable control code of each virtual object, physically simulate the motion process of each virtual object in parallel, and display the simulated motion process of each virtual object.
[0089] In step 103, the motion of each virtual object is physically simulated in parallel based on the executable control code of each virtual object, thereby displaying the simulated motion of each virtual object. This allows users to construct control programs for multiple objects through visual programming on the virtual simulation platform, thereby simulating the collaborative interaction between multiple objects on the virtual simulation platform based on the control programs. Specifically, the physical property parameters involved in the virtual scene can be initialized first, and then the executable control code of each virtual object can be executed to physically simulate the motion of each virtual object.
[0090] In some embodiments, based on the executable control code of each virtual object, the following steps can be executed in parallel to physically simulate the movement process of each virtual object: call the main logic function of the executable control code of each virtual object to generate object control instructions for each virtual object; control each virtual object in parallel to perform the actions indicated by the corresponding object control instructions to physically simulate the movement process of each virtual object.
[0091] Here, first, the main logic function of the executable control code of each virtual object is called to generate the object control instructions of each virtual object. In some embodiments, the main logic function of the executable control code of each virtual object can be called to generate the object control instructions of each virtual object by performing the following steps: the following processing is performed for each virtual object: the target class instance of the virtual object is instantiated and initialized to obtain the initialization class instance; the initialization class instance is called to execute the main logic function of the executable control code of the virtual object to obtain the object control instructions of the virtual object. Here, the target class instance (i.e., Runtime class) of the virtual object is instantiated and initialized to obtain the initialization class instance, that is, the Runtime class of the virtual object is initialized to obtain the initialization class instance; then the initialization class instance is called to execute the main logic function of the executable control code of the virtual object to obtain the object control instructions of the virtual object. For example, at runtime, the StartCoroutine function can be used to call the Runtime class instance of the virtual object to execute the main logic function of the executable control code of the virtual object, thereby generating the object control instructions of the virtual object. Then, each virtual object is controlled in parallel to perform the actions indicated by the corresponding object control instructions, so as to physically simulate the motion process of each virtual object and output the simulated motion process of each virtual object. For example, the Runtime class instance of a virtual object can give the object control instructions of each virtual object to the game loop of the virtual simulation platform, and the game loop controls each virtual object in parallel to execute the actions indicated by the corresponding object control instructions, so as to physically simulate the movement process of each virtual object and output the simulated movement process of each virtual object.
[0092] In some embodiments, the following steps may be performed: displaying a pause simulation control for each virtual object; and in response to a triggering operation of the pause simulation control for a target virtual object among the multiple virtual objects, pausing the physical simulation of the target virtual object's motion. The provided pause simulation control for the virtual object can be used to pause the physical simulation for one or more target virtual objects, thereby simulating the motion of only the virtual objects other than the target virtual object. This allows for flexible adjustment of the number of simulated virtual objects, increasing the flexibility of virtual object simulation.
[0093] In some embodiments, the following steps may be performed: displaying a simulation selection control for each virtual object; receiving a confirmation selection operation for a target virtual object among multiple virtual objects based on the simulation selection control; converting the programming building block program for the target virtual object into executable control code for the target virtual object in response to an object simulation instruction for the target virtual object triggered based on the confirmation selection operation; physically simulating the motion process of the target virtual object based on the executable control code of the target virtual object, and displaying the simulated motion process of the target virtual object. Here, a target virtual object to be simulated may be selected, and the number of target virtual objects may be one or more. When a confirmation selection operation for a target virtual object among multiple virtual objects is received based on the simulation selection control, physically simulating the motion process of the target virtual object in response to the object simulation instruction for the target virtual object triggered based on the confirmation selection operation. In this way, the virtual object to be simulated can be flexibly adjusted, improving the flexibility of virtual object simulation.
[0094] In some examples, the embodiments of the present application can be applied to game development scenarios. For example, the design of the movement and interaction of multiple game objects in a game scene can be simulated using the simulation method of virtual objects provided by the embodiments of the present application. Specifically, for each game object in a plurality of game objects, based on the visual programming editor interface of the game object, the programming building block program edited for the game object is obtained; when the object simulation instruction for the plurality of game objects is received, the programming building block program for each game object is converted into the executable control code of each game object; based on the executable control code of each game object, the motion process of each game object is physically simulated in parallel, and the simulated motion process of each game object is displayed. In this way, the rapid design and development of game objects can be achieved.
[0095] In some examples, the embodiments of the present application can be applied to simulated teaching scenarios. For example, in a teaching experiment in a simulated teaching scenario, a plurality of experimental objects are involved in the teaching experiment. The simulation method of the virtual object provided by the embodiment of the present application can be used to simulate the teaching experiment. Specifically, for each experimental object in a plurality of experimental objects, based on the visual programming editor interface of the experimental object, the programming building block program edited for the experimental object is obtained; when the object simulation instruction for the plurality of experimental objects is received, the programming building block program for each experimental object is converted into the executable control code of each experimental object; based on the executable control code of each experimental object, the motion process of each experimental object is physically simulated in parallel, and the simulated motion process of each experimental object is displayed. In this way, the physical simulation of the motion process of the experimental object in the teaching experiment can be performed, thereby improving the efficiency and repeatability of the teaching experiment.
[0096] In some examples, the embodiments of the present application can be applied to industrial simulation scenarios. For example, in the control of drone clusters, it is necessary to consider the coordinated flight and task allocation among multiple drones. The simulation method of virtual objects provided by the embodiments of the present application can be used to simulate drones. Specifically, for each drone among multiple drones, based on the visual programming editor interface of the drone, the programming building block program edited for the drone is obtained; when the object simulation instructions for multiple drones are received, the programming building block program of each drone is converted into the executable control code of each drone; based on the executable control code of each drone, the motion process of each drone is physically simulated in parallel, and the simulated motion process of each drone is displayed. In this way, the physical simulation of drone cluster control is achieved, which increases the skill and proficiency of drone cluster control for users.
[0097] In some examples, the embodiments of the present application can be applied to smart traffic scenarios. For example, in an intelligent traffic system, it is necessary to consider the driving rules and obstacle avoidance strategies among multiple cars. The simulation method of virtual objects provided by the embodiments of the present application can be used to simulate the driving of cars. Specifically, for each of the multiple cars, based on the visual programming editor interface of the car, the programming building block program edited for the car is obtained; when the object simulation instructions for the multiple cars are received, the programming building block program of each car is converted into the executable control code of each car; based on the executable control code of each car, the movement process of each car is physically simulated in parallel, and the simulated movement process of each car is displayed. In this way, the physical simulation of car driving control in the intelligent traffic system is realized, which is convenient for users to set driving rules, obstacle avoidance strategies, etc.
[0098] In some examples, the embodiments of the present application can be applied to programming teaching. For example, in programming teaching, it is necessary to realize the visual programming of multiple virtual objects and the viewing of programming effects. The simulation method of virtual objects provided by the embodiments of the present application can be used to simulate virtual objects. Specifically, for each virtual object in a plurality of virtual objects, based on the visual programming editor interface of the virtual object, a programming building block program for editing the virtual object is obtained; when an object simulation instruction for a plurality of virtual objects is received, the programming building block program for each virtual object is converted into an executable control code for each virtual object; based on the executable control code of each virtual object, the motion process of each virtual object is physically simulated in parallel, and the simulated motion process of each virtual object is displayed. In this way, by visually programming multiple virtual objects, the physical simulation of multiple virtual objects is realized, providing users with programming learning and practice for complex scenes of multi-object collaboration, increasing the programming challenge, thereby improving the programming teaching effect and the user's programming level.
[0099] In some examples, the embodiments of the present application can be applied to UGC scenarios. For example, on an Internet platform, when users create and provide their own original content (such as animation videos, dynamic images, etc.), the simulation method of virtual objects provided by the embodiments of the present application can be used to simulate virtual objects (such as animated characters) in the content. Specifically, for each virtual object in the multiple virtual objects included in the creative content, based on the visual programming editor interface of the virtual object, the programming building block program for editing the virtual object is obtained; when the object simulation instructions for multiple virtual objects are received, the programming building block program for each virtual object is converted into an executable control code for each virtual object; based on the executable control code of each virtual object, the motion process of each virtual object is physically simulated in parallel, and the simulated motion process of each virtual object is displayed. In this way, the creation efficiency and creation effect of UCG can be improved, thereby improving the content quality of UCG on the Internet platform and increasing the user stickiness of the Internet platform.
[0100] By applying the above-mentioned embodiment of the present application, for each virtual object among multiple virtual objects, a programming building block program for editing the virtual object is obtained based on the visual programming editor interface of the virtual object; when an object simulation instruction for the multiple virtual objects is received, the programming building block program for each virtual object is converted into an executable control code for each virtual object; based on the executable control code for each virtual object, the motion process of each virtual object is physically simulated in parallel, and the simulated motion process of each virtual object is displayed. In this way, by visually programming multiple virtual objects, the physical simulation of multiple virtual objects is realized, which can increase the interactivity of the physical simulation of the virtual objects, improve the physical simulation effect of the virtual objects, and thus increase the applicable scenarios and practicality of the physical simulation of the virtual objects.
[0101] The following takes a teaching scenario as an example to illustrate an exemplary application of an embodiment of the present application in an actual application scenario. First, the related technology involved in this application is described. In the related technology, a user builds a control program on a virtual simulation platform for a virtual object (3D model, such as a virtual machine dog) provided by the platform to control the virtual object to move in the virtual scene provided by the platform based on the control program, thereby achieving an intuitive and interactive programming experience. However, the virtual simulation platform in the related technology only supports the control of one object, and there are the following problems:
[0102] (1) Limited interactivity. When users perform programming operations on a virtual simulation platform that only supports controlling one object, they cannot simulate the interaction and collaboration between multiple objects, which limits their learning and practice of programming for complex scenarios involving multiple objects. However, many real-world scenarios involve interactions between multiple objects, such as transportation systems and factory assembly lines. Solutions that only support controlling one object cannot meet the simulation requirements of these real-world scenarios, reducing the practicality of the virtual simulation platform.
[0103] (2) Lack of real-world scenario simulation. A virtual simulation platform that only supports controlling one object cannot simulate scenarios involving multiple objects interacting with each other. Therefore, when a virtual simulation platform is used for programming teaching, it will be difficult for users to apply what they have learned to real-world scenarios. For example, in intelligent transportation systems, it is necessary to consider driving rules and obstacle avoidance strategies among multiple vehicles; in drone swarm control, it is necessary to consider collaborative flight and task allocation among multiple drones. However, solutions that only support controlling one object cannot meet the simulation requirements of these real-world scenarios, thus limiting the development of users' programming capabilities.
[0104] (3) Reduce programming challenges. A virtual simulation platform that only supports controlling one object means that the programming challenges faced by users are relatively limited. Therefore, when a virtual simulation platform is used for programming teaching, it will make it difficult for users to further improve after mastering basic programming skills, resulting in a lack of learning interest and enthusiasm, which limits the development of users' programming abilities.
[0105] Based on this, the embodiment of the present application provides a visual programming method that supports multi-object control and interaction, which supports users to build control programs for multiple objects through visual programming on a virtual simulation platform, thereby simulating the collaborative interaction between multiple objects on the virtual simulation platform based on the control program. In this way, by optimizing the game loop of multi-object visual editing and virtual simulation, users can achieve more complex programming control, and can also intuitively simulate and master the collaboration and interaction of multiple objects in complex scenes, thereby solving the problems of interactivity, real-world scene simulation, programming challenges, etc. in related technologies, providing users with a more efficient, convenient and easy-to-use virtual simulation platform in experimental teaching, which will help users better understand and master the programming knowledge of complex scenes and multi-object collaboration, and improve the practicality and teaching value of the platform.
[0106] Next, we will explain the virtual simulation platform. The virtual simulation platform is a platform that combines a game engine and a visual building block programming library (such as Blockly). Users can build control programs for virtual objects provided by the virtual simulation platform, and then simulate them in the virtual scene provided by the virtual simulation platform based on the control program, that is, control the virtual objects to move and interact according to the built control program, thereby achieving an intuitive and interactive programming experience. The core of the virtual simulation platform includes: (1) Virtual scene: Displays the virtual scene provided by the virtual simulation platform (such as virtual city street scenes, virtual environment terrain, etc.), providing an environment for virtual objects to move and interact. (2) Virtual objects (such as virtual robots, virtual robot dogs, virtual aircraft, virtual vehicles, etc.): Virtual characters controlled by users through control programs written in a visual editor. (3) Virtual object information display area: Displays real-time information such as the coordinates, rotation angle, speed, etc. of the virtual object. (4) Visual programming editor: Based on the drag-and-drop programming interface of Blockly, users can write and debug the control program of virtual objects by dragging, connecting, etc.
[0107] Next, the embodiment of the present application will be described from the product side. (1) After the user triggers a viewing operation for a virtual scene on the virtual simulation platform, in response to the viewing operation, the virtual scene is displayed, and the virtual scene includes multiple virtual objects. Figure 4 ,The virtual scene includes four virtual objects arranged in a 2*2 layout, and a corresponding name is displayed for each virtual object; users can observe the virtual objects in the ,virtual scene from different perspectives, such as Figure 4 As shown in (1), it is a virtual object from the side view. Figure 4 (2) shows a virtual object from a bird's-eye view.
[0108] (2) In response to a first trigger operation (such as a click operation) on a target virtual object among the multiple virtual objects, the relevant information of the target virtual object is displayed in the information display area of the virtual object. As an example, see Figure 5A When a click operation is triggered on the target virtual object "RobotGogo1", the relevant information of "RobotGogo1" (such as name, coordinate position, rotation angle, speed, etc.) is displayed in the virtual object information display area. Here, the coordinate position of "RobotGogo1" is (203, 663, 0.27); see Figure 5B When a click operation is triggered on the target virtual object "RobotGogo4", relevant information of "RobotGogo4" (such as name, coordinate position, rotation angle, speed, etc.) is displayed in the information display area of the virtual object. Here, the coordinate position of "RobotGogo4" is (206, 666, 0.27).
[0109] (3) In response to a second trigger operation (such as a double-click operation) on a target virtual object among multiple virtual objects, the user will jump to the visual programming editor, and the visual programming editor interface of the target virtual object will be displayed. In the visual programming editor interface, the user can see a drag-and-drop programming toolbar, which includes controls for adding various control instructions (such as moving, rotating, jumping, etc.). In addition, the visual programming editor interface will also display relevant information about the target virtual object (displayed in the information display area of the virtual object) so that the user can understand which virtual object the control program is being written for. As an example, see Figure 6 When a double-click operation is triggered on the target virtual object "RobotGogo1", the visual programming editor interface of "RobotGogo1" is displayed. The programming toolbar is displayed in the visual programming editor interface, including addition controls for adding control instructions, such as "Event", "Variable", "Control", etc.; the visual programming editor interface also displays relevant information of "RobotGogo1", such as name, coordinate position, rotation angle, speed, etc. Here, the coordinate position of "RobotGogo1" is (203, 663, 0.27).
[0110] (IV) Users can write control programs for the selected target virtual objects by dragging the control instructions in the programming toolbar to the programming editing area of the visual programming editor interface. Figure 7AUsers can perform visual building block programming for RobotGogo1 by dragging control instructions (each control instruction is equivalent to a basic building block program) from the programming toolbar to the programming editing area. Here, the control program written for RobotGogo1 is: After clicking "Run", RobotGogo1 first turns left 45 degrees at 10% power for 3 seconds, and then starts playing the animation of asking for red envelopes.
[0111] See also Figure 7B , users can perform visual block programming for RobotGogo2 / 3 / 4 to write control programs to control the operation of RobotGogo2 / 3 / 4. Figure 7B As shown in (1), the control program for RobotGogo2 is as follows: After clicking on the "Run" button, RobotGogo2 first turns right 45 degrees with 10% power for 3 seconds, and then starts playing the lying animation. Figure 7B As shown in (2), the control program for RobotGogo3 is as follows: After clicking "Run", RobotGogo3 first turns left 135 degrees with 10% power for 3 seconds, and then starts playing the rolling animation. Figure 7B As shown in (3), the control program written for RobotGogo4 is as follows: after clicking on the run button, RobotGogo4 first turns right 135 degrees with 10% power for 3 seconds, and then starts playing the dancing animation.
[0112] (5) After the user has completed writing the control program for each virtual object, the user can trigger a display instruction for the virtual scene. At this time, the virtual scene is displayed in response to the display instruction of the virtual scene. In the virtual scene, the user can start the real-time simulation function for the virtual object to view the effect of the virtual object moving and interacting according to the written control program. When the simulation instruction for the virtual object is received, the control program of each virtual object is executed in response to the simulation instruction to control the virtual object to operate based on the control program. In this way, based on the above (1)-(5), the user can explore how to control the movement and interaction of multiple virtual objects in the virtual scene through programming.
[0113] For example, see Figure 8In response to the simulation instructions triggered by the running control, RobotGogo1-4 move according to their respective control programs, namely, RobotGogo1 turns left 45 degrees at 10% power (lasting 3 seconds), RobotGogo2 turns right 45 degrees at 10% power (lasting 3 seconds), RobotGogo3 turns left 135 degrees at 10% power (lasting 3 seconds), and RobotGogo4 turns right 135 degrees at 10% power (lasting 3 seconds). Figure 8 As shown in (1) and (2), Figure 8 (1) is the side view. Figure 8 (2) is the top view. Three seconds after the simulation command is triggered, RobotGogo1 faces 45 degrees, RobotGogo2 faces 135 degrees, RobotGogo3 faces -135 degrees, and RobotGogo1 faces -45 degrees. Figure 9 As shown, after 3 seconds, the animations of the four virtual objects are played respectively, namely, RobotGogo1 performs the animation of asking for red envelopes, RobotGogo2 performs the animation of lying down, RobotGogo3 performs the animation of dancing, and RobotGogo4 performs the animation of rolling.
[0114] Next, the embodiment of the present application will be described from a technical perspective. In practical applications, the present application can support cross-platform operation on electronic devices with different operating systems such as Windows, MacOS, and Linux.
[0115] First, visual programming and code conversion of multiple objects. In the above example, the user creates control programs for multiple virtual objects through a visual editor interface. The control program consists of building blocks (i.e., programming building block programs), which represent various control commands for virtual objects and will eventually be converted into C# code for execution in the runtime environment of the virtual objects. Blockly is a web-based visual programming tool that allows users to create control programs by dragging and dropping building blocks. These building blocks can be combined into more complex structures to represent more complex program logic. The core components of Blockly include a workspace (for storing and managing building blocks), building blocks (representing various commands and operations in the program), and a code generator (which converts building blocks into code in the target programming language).
[0116] In the above example, the user needs to create control programs for multiple virtual objects separately. To achieve this goal, an embodiment of the present application implements the ability to save and load programming blocks for virtual objects in a visual editor. When a user double-clicks a virtual object, the Save function can be used to bind the user-edited programming block program for that virtual object to the virtual object. The Load function can then be used to load the saved programming block program into the visual programming editor. This allows the user to switch between different virtual objects and write and modify programming blocks for each virtual object. For example, a set of blocks can be defined, such as a block named "move" that accepts four editable parameters: angle, power, direction, and time. A set of animation-related blocks can also be created to control virtual objects to play different animations or actions, such as: marching in place, somersaults, asking for red envelopes, questioning, nodding, lying down, sitting down, rolling, shaking hands, dancing, fear, joy, braking, chasing tails, etc.
[0117] After users control a program by dragging and dropping blocks and combining them into virtual objects, they need to convert these blocks into C# code. To achieve this, you need to use Blockly's code generator. A code generator is a tool used to convert blocks into a target programming language. Blockly provides several built-in code generators, such as JavaScript, Python, and Lua. In this example, you need to create a custom code generator for C#. Creating a custom code generator involves the following steps:
[0118] (1) Register a custom code generator. First, register a new code generator named "CSharp". This can be achieved by calling the "Blockly.registerGenerator" method.
[0119] (2) Define the mapping from blocks to code. Next, define a generator function for each block. These generator functions will be responsible for converting blocks into C# code. For example, for the "move" block, you can define a generator function that converts the block's parameters into method calls in C# code. Similarly, you can define a generator function for the "anim" block that converts the block's parameters into method calls in C# code.
[0120] (3) Generate C# code (i.e. the main logic code mentioned above). Use the "Blockly.CSharp.workspaceToCode" method to convert the Blockly workspace to C# code. This method accepts a Blockly workspace as a parameter and returns the generated C# code.
[0121] After the above process is completed, you will get a string containing C# code. Next, you need to insert this code into a C# class template, for example:
[0122]
[0123] Here, {robotId} is the unique identifier of the virtual object, and {code} is the C# code generated from the Blockly workspace. Repeat this process for each virtual object's building block, and you will end up with four C# classes, one for each virtual object's runtime. For example, the conversion relationship between building blocks and code is as follows: Figure 10 shown.
[0124] Second, virtual simulation execution control of multiple object codes. Figure 11 , Figure 11 This is a flow chart of a method for simulating a virtual object provided by an embodiment of the present application.
[0125] (1) After the user triggers the object simulation instruction, the runtime will start and use the Blockly interface to convert the four robot dog building block programs into executable control codes. Then, the runtime will sequentially instantiate these executable control codes into game engine components and mount them on the four robot dog nodes in the virtual scene.
[0126] (2) Subsequently, multiple robot dog Runtimes will be initialized in sequence during the runtime, including robot dog 1 Runti me - robot dog 4 Runtime.
[0127] (3) After instantiating and initializing the Robot Dog Runtime, the runtime will begin the physics simulation loop. The physics simulation loop is a core concept in the game, which is responsible for handling various updates in the game, such as physical interactions, animations, and inputs.
[0128] (4) While the physical simulation loop is running, the runtime uses StartCoroutine to call the MainLogic functions of all robot dog Runtimes. The coroutine function of the game engine is used here. Coroutine is a programming technique that allows execution to be paused in a function and resumed at a later point in time. In game engines, coroutines are often used to handle tasks that need to be executed between multiple frames, such as animations, delays, etc. In this scenario, coroutines are used to execute the MainLogic functions of multiple robot dog Runtimes so that execution can be paused and resumed during execution to achieve the effect of parallel control of the robot dogs. The pseudo code of the runtime is as follows:
[0129]
[0130]
[0131] The execution sequence of the MainLogic function is as follows:
[0132] (a) When the runtime calls the MainLogic function of RobotDog1Runtime using StartCoroutine, RobotDog1Runtime first executes the move(-45, 10, 3) method. This generates an object control instruction to turn RobotDog1 45 degrees left at 10% power within 3 seconds. Next, RobotDog1Runtime transfers control to the runtime, which begins processing the MainLogic functions of the other RobotDogRuntimes.
[0133] (b) Similarly, the runtime will sequentially call the MainLogic functions of RobotDog2Runtime, RobotDog3Runtime, and RobotDog4Runtime. During this process, each RobotDogRuntime will generate one or more object control instructions and transfer control to the runtime. These object control instructions will be executed concurrently in the game loop.
[0134] (c) In the game loop, the game engine handles various game updates, including physics interactions, animations, and output. In this scenario, the game loop executes the robot dog's movements based on object control commands generated at runtime. For example, the game loop will cause robot dog 1 to turn 45 degrees left at 10% power within 3 seconds. Simultaneously, the game loop will also update the robot dog's information bar in real time, allowing the user to observe changes.
[0135] (d) After the three seconds have passed, the game loop notifies the runtime. The runtime then continues executing the remaining code in the MainLogic function of RobotDog1Runtime. In this example, RobotDog1Runtime executes the anim('redenvelope') method, generating an object control instruction to play the red envelope red envelope animation. Then, RobotDog1Runtime transfers control to the runtime, which begins processing the remaining code in the MainLogic function of the other RobotDogRuntimes.
[0136] (e) Similarly, the runtime will process the remaining code in the MainLogic functions of RobotDog2Runtime, RobotDog3Runtime, and RobotDog4Runtime in sequence. During this process, each RobotDogRuntime will generate one or more object control instructions and transfer control to the runtime. These object control instructions will be executed concurrently in the game loop.
[0137] (f) In the game loop, the game engine handles various game updates, including physics interactions, animations, and other aspects. In this scenario, the game loop executes the robot dogs' animations based on object control instructions generated at runtime. For example, the game loop will play the red envelope-seeking animation of robot dog 1, the sitting animation of robot dog 2, the dancing animation of robot dog 3, and the rolling animation of robot dog 4. Simultaneously, the game loop will also update the data in the robot dog information bar in real time, allowing the user to observe data changes.
[0138] (g) After the animation ends, the game loop notifies the runtime. The runtime will then continue executing the remaining code in the Robot Dog Runtime's MainLogic function, or terminate the program as needed. This process continues until all of the Robot Dog Runtime's MainLogic functions have completed execution.
[0139] It should be noted that in the embodiments of this application, the specific functions of different entities are:
[0140] (1) Visual programming editing interface: As a bridge between users and programs, the visual editing interface provides an intuitive and easy-to-operate way for users to create and edit control programs.
[0141] (2) Blockly is a programming library that adds a visual code editor to web and mobile applications. It is used to support graphical and visual programming.
[0142] (3) Blockly conversion program: During runtime, the Blockly interface is used to convert the block program created by the user in the visual programming editing interface into executable control code.
[0143] (4) Runtime: Responsible for managing the entire program execution process. It instantiates the Robot Dog Runtime from the executable control code generated by the Blockly interface and initializes them. The runtime is also responsible for starting the physics simulation loop, calling the MainLogic function of the Robot Dog Runtime, and handling various updates in the game loop.
[0144] (5) Robot Dog Runtime: This is the specific implementation of the robot dog control program. Each robot dog runtime has a MainLogic function that is responsible for executing the user-defined control program. The robot dog runtime generates instructions based on the control program and passes these instructions to the game loop.
[0145] (6) Game loop: This is the main running loop of a game engine or program in game development. It is a continuously running loop responsible for processing player input, updating game state, and rendering graphics so that the game can run at a certain frame rate and respond to player operations. Specifically, it is responsible for processing various updates such as physical interactions, animations, and input in the game. The game loop executes the robot dog's actions and animations according to the instructions generated at runtime, and updates the data in the robot dog's information bar in real time.
[0146] Applying the above embodiments of the present application, 1) Improve interactivity: The present application provides a more intuitive and easy-to-operate visual programming editing interface, allowing users to more conveniently perform programming control and interaction settings for multiple objects. This helps to lower the threshold for programming learning and increase users' learning interest and participation. 2) Enhanced reality scene simulation: The virtual simulation platform of the present application can more accurately simulate the movement and interaction of multiple objects, allowing users to gain richer experience in actual programming tasks. This helps to improve users' ability to solve practical problems. 3) Improve programming challenge and creativity: By supporting multi-object control and interaction, users are provided with more programming challenges and creative projects, stimulating their learning interest and enthusiasm. This will help improve users' programming skills and hands-on ability. 4) Cultivate concurrency and multi-tasking capabilities: Provide users with more concurrent and multi-tasking training and practice opportunities. For example, users can try to realize the simultaneous flight and task allocation of multiple drones in a virtual scene, thereby cultivating concurrent and multi-tasking capabilities, which helps to improve users' coping ability and experience in actual programming tasks.
[0147] The following continues to describe the exemplary structure of the virtual object simulation device 555 provided in the embodiment of the present application as a software module. In some embodiments, such as Figure 2 As shown, the software modules in the simulation device 555 of the virtual object stored in the memory 550 may include: an acquisition module 5551, which is used to acquire, for each of the multiple virtual objects, a programming building block program edited for the virtual object based on the visual programming editor interface of the virtual object; a conversion module 5552, which is used to convert the programming building block program of each virtual object into an executable control code for each virtual object when receiving an object simulation instruction for the multiple virtual objects; and a simulation module 5553, which is used to physically simulate the movement process of each virtual object in parallel based on the executable control code of each virtual object, and display the simulated movement process of each virtual object.
[0148] In some embodiments, the acquisition module 5551 is also used to display a screen of a virtual scene and display the multiple virtual objects in the screen of the virtual scene before the visual programming editor interface based on the virtual object acquires the programming building block program for editing the virtual object; for each of the virtual objects, in response to the visual programming instructions for the virtual object triggered based on the screen of the virtual scene, the visual programming editor interface of the virtual object is displayed.
[0149] In some embodiments, the simulation module 5553 is also used to display an object simulation control in the screen of the virtual scene; in response to a trigger operation on the object simulation control, an object simulation instruction for the multiple virtual objects is received; the simulation module 5553 is also used to perform physical simulation of the movement process of each virtual object in parallel in the virtual scene based on the executable control code of each virtual object.
[0150] In some embodiments, the simulation module 5553 is also used to display a virtual scene switching control; based on the virtual scene switching control, a scene switching instruction is received indicating that the virtual scene is to be switched to a target virtual scene; in response to the scene switching instruction, the screen of the displayed virtual scene is switched to a screen displaying the target virtual scene.
[0151] In some embodiments, the visual programming editor interface displays an addition control for each of the multiple basic building block programs; the acquisition module 5551 is also used to receive an addition instruction for a target basic building block program among the multiple basic building block programs based on the addition control; in response to the addition instruction for the target basic building block program, an editing control for the target basic building block program is displayed in the visual programming editor interface; in response to an editing operation for the target basic building block program triggered based on the editing control, a programming building block program for editing the virtual object is generated.
[0152] In some embodiments, the acquisition module 5551 is further configured to display an information display area in the visual programming editor interface; and to display object-related information of the virtual object in the information display area.
[0153] In some embodiments, the editing control is displayed in the building block program editing area of the visual programming editor interface; the acquisition module 5551 is also used to receive a drag operation of dragging the add control of the target basic building block program to the building block program editing area; in response to a release operation for the drag operation, an add instruction for the target basic building block program among the multiple basic building block programs is received.
[0154] In some embodiments, the conversion module 5552 is also used to perform the following processing for each virtual object: converting the programming building block program of the virtual object into the main logic code; obtaining the script code of the virtual object, the script code including the main logic function; inserting the main logic code into the main logic function included in the script code to obtain the executable control code of the virtual object.
[0155] In some embodiments, the conversion module 5552 is also used to register a code generator and define a generator function for the programming building block program of each virtual object before converting the programming building block program of each virtual object into the executable control code of each virtual object; the conversion module 5552 is also used to call the code generator, and based on the generator function of the programming building block program of the virtual object, perform parameter parsing on the programming building block program of the virtual object to obtain the main logic code.
[0156] In some embodiments, the simulation module 5553 is also used to call the main logic function of the executable control code of each virtual object to generate object control instructions for each virtual object; and control each virtual object in parallel to perform the actions indicated by the corresponding object control instructions to physically simulate the movement process of each virtual object.
[0157] In some embodiments, the simulation module 5553 is also used to perform the following processing for each virtual object: instantiate a target class instance of the virtual object, and initialize the target class instance to obtain an initialization class instance; call the initialization class instance to execute the main logic function of the executable control code of the virtual object to obtain the object control instruction of the virtual object.
[0158] In some embodiments, the acquisition module 5551 is also used to associate and store the object identification information of the virtual object and the programming building block program for editing the virtual object after acquiring the programming building block program for editing the virtual object in the visual programming editor interface based on the virtual object; and load the stored programming building block program for editing the virtual object into the visual programming editor where the visual programming editor interface is located.
[0159] In some embodiments, the simulation module 5553 is also used to display simulation selection controls for each of the virtual objects; based on the simulation selection controls, a confirmation selection operation for a target virtual object among the multiple virtual objects is received; in response to an object simulation instruction for the target virtual object triggered based on the confirmation selection operation, the programming building block program of the target virtual object is converted into an executable control code for the target virtual object; based on the executable control code of the target virtual object, the movement process of the target virtual object is physically simulated, and the simulated movement process of the target virtual object is displayed.
[0160] In some embodiments, the simulation module 5553 is further used to display a pause simulation control for each of the virtual objects; in response to a triggering operation of the pause simulation control for a target virtual object among the multiple virtual objects, the physical simulation of the movement process of the target virtual object is stopped.
[0161] It should be noted that the description of the device embodiment in this application is similar to the description of the method embodiment described above, and has similar beneficial effects as the method embodiment, and is not repeated here. Any unfinished technical details of the virtual object simulation device provided in the embodiment of this application can be understood based on the description of the technical details in the method embodiment described above.
[0162] The present application also provides a computer program product, which includes computer-executable instructions or a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer-executable instructions or the computer program from the computer-readable storage medium and executes the computer-executable instructions or the computer program, causing the electronic device to perform the virtual object simulation method provided in the present application.
[0163] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will execute the virtual object simulation method provided in the embodiment of the present application.
[0164] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
[0165] In some embodiments, computer-executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0166] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinating files (e.g., files storing one or more modules, subroutines, or code portions).
[0167] By way of example, computer-executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed across multiple sites and interconnected by a communication network.
[0168] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the scope of protection of the present application.
Claims
1. A method for simulating a virtual object, characterized in that: The method comprises: For each of the plurality of virtual objects, obtaining a programming building block program edited for the virtual object based on a visual programming editor interface of the virtual object; When receiving object simulation instructions for the plurality of virtual objects, converting the programming building block programs of the respective virtual objects into executable control codes for the respective virtual objects; Based on the executable control code of each virtual object, the movement process of each virtual object is physically simulated in parallel, and the simulated movement process of each virtual object is displayed.
2. The method according to claim 1, wherein Before obtaining the programming building block program for editing the virtual object through the visual programming editor interface based on the virtual object, the method further includes: Displaying a picture of a virtual scene, and displaying the plurality of virtual objects in the picture of the virtual scene; For each of the virtual objects, in response to a visual programming instruction for the virtual object triggered based on a picture of the virtual scene, a visual programming editor interface of the virtual object is displayed.
3. The method according to claim 2, wherein The method further comprises: In the virtual scene screen, an object simulation control is displayed; In response to a trigger operation on the object simulation control, receiving object simulation instructions for the plurality of virtual objects; The physically simulating the motion process of each virtual object in parallel based on the executable control code of each virtual object includes: Based on the executable control code of each virtual object, a physical simulation is performed on the movement process of each virtual object in parallel in the virtual scene.
4. The method according to claim 3, wherein The method further comprises: Display virtual scene switching controls; Based on the virtual scene switching control, receiving a scene switching instruction instructing to switch the virtual scene to a target virtual scene; In response to the scene switching instruction, the screen displaying the virtual scene is switched to a screen displaying the target virtual scene.
5. The method according to claim 1, wherein The visual programming editor interface displays an add control for each of the basic building block programs in a plurality of basic building block programs; The visual programming editor interface based on the virtual object obtains a programming building block program for editing the virtual object, including: Based on the adding control, receiving an adding instruction for a target basic building block program among the multiple basic building block programs; In response to an add instruction for the target basic building block program, displaying an edit control of the target basic building block program in the visual programming editor interface; In response to an editing operation on the target basic building block program triggered by the editing control, a programming building block program edited for the virtual object is generated.
6. The method according to claim 5, wherein The method further comprises: In the visual programming editor interface, an information display area is displayed; In the information display area, object-related information of the virtual object is displayed.
7. The method according to claim 5, wherein The editing control is displayed in the building block program editing area of the visual programming editor interface; The receiving, based on the adding control, an adding instruction for a target basic building block program among the plurality of basic building block programs comprises: receiving a drag operation of dragging an add control of the target basic building block program to the building block program editing area; In response to a release operation for the drag operation, an add instruction for a target basic building block program among the plurality of basic building block programs is received.
8. The method according to claim 1, wherein The step of converting the programming building block program of each virtual object into an executable control code of each virtual object includes: The following processing is performed for each virtual object: Converting the programming building block program of the virtual object into a main logic code; Obtaining script code of the virtual object, wherein the script code includes a main logic function; The main logic code is inserted into the main logic function included in the script code to obtain the executable control code of the virtual object.
9. The method according to claim 8, wherein Before converting the programming building block programs of the virtual objects into executable control codes of the virtual objects, the method further includes: Registering a code generator and defining a generator function for the programming building block program of each virtual object; Converting the programming building block program of the virtual object into a main logic code includes: The code generator is called, and based on the generator function of the programming building block program of the virtual object, the programming building block program of the virtual object is parameter parsed to obtain the main logic code.
10. The method according to claim 1, wherein The physically simulating the motion process of each virtual object in parallel based on the executable control code of each virtual object includes: calling a main logic function of the executable control code of each virtual object to generate an object control instruction for each virtual object; The virtual objects are controlled in parallel to execute actions indicated by corresponding object control instructions, so as to perform physical simulation on the motion process of the virtual objects.
11. The method according to claim 10, wherein The calling of the main logic function of the executable control code of each virtual object to generate the object control instruction of each virtual object includes: The following processing is performed for each virtual object: Instantiating a target class instance of the virtual object and initializing the target class instance to obtain an initialized class instance; The initialization class instance is called to execute the main logic function of the executable control code of the virtual object to obtain the object control instruction of the virtual object.
12. The method according to claim 1, wherein After obtaining the programming building block program for editing the virtual object through the visual programming editor interface based on the virtual object, the method further includes: storing the object identification information of the virtual object and the programming building block program edited for the virtual object in association with each other; The stored programming building block program for editing the virtual object is loaded into the visual programming editor where the visual programming editor interface is located.
13. The method according to claim 1, wherein The method further comprises: displaying a simulated selection control for each of the virtual objects; Based on the simulation selection control, receiving a confirmation selection operation for a target virtual object among the multiple virtual objects; In response to an object simulation instruction for the target virtual object triggered based on the confirmation selection operation, converting the programming building block program of the target virtual object into executable control code of the target virtual object; Based on the executable control code of the target virtual object, a physical simulation is performed on the movement process of the target virtual object, and the simulated movement process of the target virtual object is displayed.
14. The method according to claim 1, wherein The method further comprises: displaying a pause simulation control for each of the virtual objects; In response to a triggering operation of a pause simulation control for a target virtual object among the multiple virtual objects, the physical simulation of the movement process of the target virtual object is stopped.
15. A simulation device for a virtual object, characterized in that: The device comprises: An acquisition module, configured to acquire, for each of the plurality of virtual objects, a programming building block program edited for the virtual object based on a visual programming editor interface of the virtual object; a conversion module, configured to, upon receiving an object simulation instruction for the plurality of virtual objects, convert the programming building block program of each of the virtual objects into an executable control code for each of the virtual objects; The simulation module is used to perform physical simulation on the motion process of each virtual object in parallel based on the executable control code of each virtual object, and display the simulated motion process of each virtual object.
16. An electronic device, characterized in that: The electronic device comprises: a memory for storing computer-executable instructions; The processor is configured to implement the virtual object simulation method according to any one of claims 1 to 14 when executing the computer executable instructions stored in the memory.
17. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the virtual object simulation method according to any one of claims 1 to 14 is implemented.
18. A computer program product comprising computer executable instructions or a computer program, characterized in that When the computer executable instructions or computer program are executed by a processor, the virtual object simulation method according to any one of claims 1 to 14 is implemented.