Virtual object control method and related device
Through the control methods and related devices of virtual objects, the model building interface and code editing interface of the simulation control system can be used to build and control virtual objects independently, solving the problem of high hardware purchase and learning costs in the existing technology and improving users creativity and independent learning ability.
Patent Information
- Application Number
- CN202311051145.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-18
- Publication Date
- 2025-02-21
AI Technical Summary
In the prior art, the combination of visual programming platform and physical cars is adopted, requiring users to purchase hardware and learn high costs.
It provides a control method and related devices for virtual objects. By simulating the model building interface and code editing interface in the control system, users can independently build virtual objects and set motion parameter configurations to reduce learning costs.
Users can independently build virtual objects in the model construction interface and set motion parameter configurations in the code editing interface, which reduces the difficulty of learning during the programming process and improves users' creativity and independent learning ability.
Smart Images

Figure CN119493556A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a control method and related devices for a virtual object. Background Art
[0002] With the development of artificial intelligence technology, students can be exposed to and understand artificial intelligence during school age, learn programming languages for communicating with machines, and build their own artificial intelligence applications through creative programming. Currently, some visual programming platforms have been developed, which generally use the language of graphic components, such as icons, buttons, and symbols in the form of coding, so that students and other users with low programming skills can easily understand the coding process.
[0003] In the related technology, a combination of a visual programming platform and a physical car is generally used to help users understand the coding process. Specifically, the physical car has various sensors and actuators such as motors, servos, infrared sensors, ultrasonic sensors, etc. These sensors and actuators can be connected to the controller, and the control logic is written through the visual programming platform to control the car to achieve autonomous movement and behavior.
[0004] However, the combination of a visual programming platform and a physical car requires users to purchase hardware related to the physical car, such as sensors, actuators, and controllers, which results in a high learning cost. Summary of the invention
[0005] In order to solve the above technical problems, the present application provides a virtual object control method and related devices to reduce the user's learning cost.
[0006] The embodiments of the present application disclose the following technical solutions:
[0007] On the one hand, an embodiment of the present application provides a control method for a virtual object, the method being applied to a simulation control system, the simulation control system comprising a model building interface and a code editing interface, the method comprising:
[0008] In the model building interface, multiple modules are displayed, and the modules are basic structures required to build the virtual object;
[0009] In response to a selection operation of a target module, a target virtual component corresponding to the target module is displayed in the model building interface, wherein the target module is a module among the multiple modules used to build a target virtual object, the target virtual component is a virtual component corresponding to the target module, and the virtual component is a component included in the target virtual object;
[0010] In the code editing interface, determining the motion parameter configuration corresponding to the target virtual component;
[0011] Obtain the target virtual object based on the target virtual component, and obtain parameter configuration of the target virtual object based on the motion parameter configuration;
[0012] In response to an operation on the target virtual object, the target virtual object is controlled to run based on the parameter configuration.
[0013] On the other hand, an embodiment of the present application provides a control device for a virtual object, the device is built into a simulation control system, the simulation control system includes a model building interface and a code editing interface, the device includes: a display unit, a determination unit, an acquisition unit and a control unit;
[0014] The display unit is used to display a plurality of modules in the model building interface, wherein the modules are basic structures required to build the virtual object;
[0015] The display unit is further used to display a target virtual component corresponding to the target module in the model building interface in response to a selection operation of the target module, wherein the target module is a module among the multiple modules used to build a target virtual object, the target virtual component is a virtual component corresponding to the target module, and the virtual component is a component among the components included in the target virtual object;
[0016] The determining unit is used to determine the motion parameter configuration corresponding to the target virtual component in the code editing interface;
[0017] The acquisition unit is used to obtain the target virtual object based on the target virtual component, and obtain the parameter configuration of the target virtual object based on the motion parameter configuration;
[0018] The control unit is used to control the operation of the target virtual object based on the parameter configuration in response to the operation operation on the target virtual object.
[0019] On the other hand, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:
[0020] The memory is used to store a computer program and transmit the computer program to the processor;
[0021] The processor is configured to execute the method described in the above aspects according to the instructions in the computer program.
[0022] On the other hand, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method described in the above aspects.
[0023] On the other hand, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method described in the above aspects.
[0024] It can be seen from the above technical scheme that the control method of the virtual object provided in the embodiment of the present application is applied in the simulation control system of the virtual object, and the simulation control system includes a model building interface and a code editing interface. Among them, a plurality of basic structures required for building a virtual object, i.e., modules, are displayed in the model building interface. When the user selects the target module, the target virtual component corresponding to the target module is displayed in the model building interface, thereby providing the user with the function of customizing the construction of the virtual object through the model building interface. In the code editing interface, the motion parameter configuration corresponding to the target virtual component is determined, thereby providing the user with the function of writing the control logic for the virtual component through the code editing interface, and only the parameters are configured during the writing process, without writing the code from scratch, which is conducive to the user to better understand the programming process. The target virtual object is obtained based on the target virtual component, and the parameter configuration of the target virtual object is obtained based on the motion parameter configuration corresponding to the target virtual component. When the user performs an operation on the target virtual object, the operation of the target virtual object is controlled based on the parameter configuration of the target virtual object.
[0025] Therefore, by pre-disassembling the virtual object into multiple modules, the user can not only independently build the virtual object in the model building interface, but also set the motion parameter configuration for each virtual component included in the virtual object in the code editing interface. Therefore, the user can not only freely build various module combinations to obtain customized virtual objects, but also control the various virtual components included in the virtual object separately, which not only reduces the learning difficulty for the user in the programming process, but also improves the user's creativity and independent learning ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0027] Figure 1 A schematic diagram of an application scenario of a virtual object control method provided in an embodiment of the present application;
[0028] Figure 2A schematic diagram of a model building interface provided in an embodiment of the present application;
[0029] Figure 3 A schematic diagram of a code editing interface provided in an embodiment of the present application;
[0030] Figure 4 A schematic diagram of a code editing interface provided in an embodiment of the present application;
[0031] Figure 5 A schematic diagram of the operation of a target virtual vehicle provided in an embodiment of the present application;
[0032] Figure 6 A flowchart of a method for controlling a virtual object provided in an embodiment of the present application;
[0033] Figure 7 A schematic diagram of a model building interface provided in an embodiment of the present application;
[0034] Figure 8 A schematic diagram of building a virtual object provided in an embodiment of the present application;
[0035] Fig. 9 A schematic diagram of a virtual scene interface provided in an embodiment of the present application;
[0036] Fig.10 A schematic diagram of a virtual scene interface provided in an embodiment of the present application;
[0037] Fig.11 A schematic diagram of a three-dimensional model provided in an embodiment of the present application;
[0038] Fig.12 A schematic diagram of a module provided in an embodiment of the present application;
[0039] Fig.13 A schematic diagram of a virtual shell provided in an embodiment of the present application;
[0040] Fig.14 A schematic diagram of an adsorption point set for a virtual component corresponding to a camera module provided in an embodiment of the present application;
[0041] Fig.15 A schematic diagram of an adsorption point setting for a virtual component corresponding to a quadrangular pyramid structure module provided in an embodiment of the present application;
[0042] Fig.16 A schematic diagram of an adsorption process provided in an embodiment of the present application;
[0043] Fig.17 A schematic diagram of an adsorption process provided in an embodiment of the present application;
[0044] Fig.18 A schematic diagram of an adsorption process provided in an embodiment of the present application;
[0045] Fig.19 A schematic diagram of a target virtual object provided in an embodiment of the present application;
[0046] Fig. 20 A schematic diagram of a target physical property provided in an embodiment of the present application;
[0047] Fig.21 A schematic diagram of a target physical property provided in an embodiment of the present application;
[0048] Fig. 22 A schematic diagram of a target physical property provided in an embodiment of the present application;
[0049] Fig.23 A schematic diagram of a parameter adjustment interface provided in an embodiment of the present application;
[0050] Fig.24 A schematic diagram of the interaction between a model building interface and a code editing interface provided in an embodiment of the present application;
[0051] Fig.25 A schematic diagram of a simulation control system provided in an embodiment of the present application;
[0052] Fig.26 A schematic diagram of an application scenario of a virtual object control method provided in an embodiment of the present application;
[0053] Fig. 27 A schematic diagram of a model building interface provided in an embodiment of the present application;
[0054] Fig.28 A schematic diagram of a code editing interface provided in an embodiment of the present application;
[0055] Fig.29 A schematic diagram of a code editing interface provided in an embodiment of the present application;
[0056] Fig.30 A schematic diagram of a building block provided in an embodiment of the present application;
[0057] Fig.31 A schematic diagram of a code provided in an embodiment of the present application;
[0058] Fig.32 A schematic diagram of the structure of a virtual object control device provided in an embodiment of the present application;
[0059] Fig.33 A schematic diagram of the structure of a server provided in an embodiment of the present application;
[0060] Fig.34 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] The embodiments of the present application are described below in conjunction with the accompanying drawings.
[0062] Since the visual programming platform is combined with the physical car, users are required to purchase hardware related to the physical car, such as sensors, actuators, and controllers, which results in a high learning cost. Based on this, in order to reduce the learning cost, in related technologies, the function of controlling a virtual car will be added to the visual programming platform. Users can use the built 3D model car on the visual programming platform and write control logic to control the 3D model car to achieve autonomous movement and behavior in the 3D virtual scene, that is, the visual programming platform is combined with the virtual car.
[0063] However, the 3D model car in the combination of the visual programming platform and the virtual car is pre-assembled and only supports users to control the overall movement of the 3D model car through simple commands such as acceleration, braking, steering, etc., but cannot support users to build the 3D model car in a personalized way or control a certain part of the 3D model car (such as wheels, motors, etc.) separately. This method not only limits users from freely building various module combinations to obtain customized virtual objects, but also limits the ability to write control logic for each module, or in other words, users have limited control over the modules, making it difficult for users to understand more complex programming processes, and limiting the improvement of creativity and autonomous learning ability.
[0064] Based on this, the embodiments of the present application provide a control method and related devices for virtual objects. By pre-disassembling the virtual object into multiple modules, the user can not only independently build the virtual object in the model building interface, but also set the motion parameter configuration for each virtual component included in the virtual object in the code editing interface. Therefore, the user can not only freely build various module combinations to obtain customized virtual objects, but also control the various virtual components included in the virtual object separately, which not only reduces the learning difficulty for the user in the programming process, but also improves the user's creativity and independent learning ability.
[0065] The control method of virtual objects provided in the present application can be applied to computer devices with virtual object control capabilities, such as terminal devices and servers. Among them, the terminal device can be a desktop computer, a laptop computer, a mobile phone, a tablet computer, an extended reality (Extended Reality, XR) device, an Internet of Things device and a portable wearable device, the virtual reality device can be a virtual reality (Virtual Reality, VR) device, an augmented reality (Augmented Reality, AR) device, a mixed reality (Mixed Reality, MR) device, etc., the Internet of Things device can be a smart speaker, a smart TV, a smart air conditioner, a smart car device, etc., the smart car device can be a car navigation terminal and a car computer, etc., the portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc., but is not limited to this; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal device and the server may be connected directly or indirectly via wired or wireless communication, which is not limited in this application.
[0066] To facilitate understanding of the virtual object control method provided in the embodiment of the present application, the following uses a server as an example in which the execution subject of the virtual object control method is an example to exemplarily introduce the application scenario of the virtual object control method.
[0067] See also Figure 1 , which is a schematic diagram of an application scenario of a virtual object control method provided by an embodiment of the present application. Figure 1 As shown, the application scenario includes a terminal device 110, on which a simulation control system is running, which can execute the control method of the virtual object provided in the embodiment of the present application, thereby generating and controlling the target virtual object required by the user. The following description takes the virtual object as a virtual vehicle as an example.
[0068] The simulation control system includes a model building interface and a code editing interface, such as Figure 2 As shown, click area 201 (model building) to enter the model building interface, click area 202 (code editing) to enter the code editing interface, the current one is the model building interface
[0069] Before the simulation control system is used by the user, the virtual vehicle will be disassembled into multiple modules based on the basic structure required by the virtual vehicle in advance, so that the multiple modules can be displayed in the model building interface, such as Figure 2 As shown in area 204 in FIG. 1 , the modules can be divided into four categories, namely, the structural foundation category, the actuator category, the sensor category, and the power device category. For example, the modules belonging to the power device category may be the encoder motor module and the R45 power wheel module, such as Figure 2 As shown in area 205 in FIG.
[0070] Users can select the modules they need from the multiple modules displayed on the model building interface to build the target virtual vehicle they need. Figure 2 In the model building interface, the user drags the R45 power wheel module to the 3D operating platform (i.e. Figure 2 In the area 206 in the figure, the user performs a selection operation on the R45 power wheel module, and the target virtual component R1 corresponding to the R45 power wheel module is displayed in the 3D operation platform, such as Figure 2 in area 207.
[0071] Correspondingly, in the code editing interface, the motion parameter configuration corresponding to the target virtual component will be displayed for the user to configure. Figure 3 Taking the modules belonging to the power device category as an example, in the code editing interface, the R45 power wheel module will display R1 and the motion parameter configuration for power rotation. The default value is 30, and the user can change it based on needs. Since the user did not select the coding click in the model building interface, the coding click is not named. In addition, see Figure 4 Taking the modules belonging to the actuator category as an example, the motion parameter configuration of the virtual components corresponding to the modules belonging to the actuator category can also be displayed and set. Therefore, during the writing process, users can only configure the parameters without writing the code from scratch, which is conducive to users to better understand the programming process.
[0072] Similarly, users can continue to select the target module they need and obtain the following through the corresponding target virtual component: Figure 1 The target virtual vehicle shown in FIG. 1 and the motion parameter configuration corresponding to the target virtual component are used to obtain the parameter configuration of the target virtual object, such as Figure 3 As shown in area 302 in FIG. Figure 3 The area 301 in FIG. 1 is to execute the operation for the target virtual vehicle, and control the operation of the target virtual object based on the parameter configuration of the target virtual object, such as Figure 5 shown.
[0073] Therefore, by pre-disassembling the virtual object into multiple modules, the user can not only independently build the virtual object in the model building interface, but also set the motion parameter configuration for each virtual component included in the virtual object in the code editing interface. Therefore, the user can not only freely build various module combinations to obtain customized virtual objects, but also control the various virtual components included in the virtual object separately, which not only reduces the learning difficulty for the user in the programming process, but also improves the user's creativity and independent learning ability.
[0074] The control method of the virtual object provided in the embodiment of the present application can be executed by the terminal device. However, in other embodiments of the present application, the server can also have similar functions as the terminal device, so as to execute the control method of the virtual object provided in the embodiment of the present application, or the terminal device and the server can jointly execute the control method of the virtual object provided in the embodiment of the present application, and this embodiment does not limit this.
[0075] The following is a detailed introduction to the control method of the virtual object provided by the present application through a method embodiment.
[0076] See also Figure 6 , which is a flow chart of a virtual object control method provided by an embodiment of the present application. For ease of description, the following embodiments are still introduced by taking the execution subject of the virtual object control method as a terminal device as an example. Figure 6 As shown, the control method of the virtual object includes S601-S605:
[0077] S601: In the model building interface, multiple modules are displayed.
[0078] The simulation control system provided in the embodiment of the present application includes a model building interface and a code editing interface, wherein the model building interface is used to provide a user with an environment for building virtual objects, and the code editing interface is used to provide a user with an environment for coding to control the movement of virtual objects. The model building interface is first described below.
[0079] Multiple modules are displayed in the model building interface, each of which is a basic structure required to build a virtual object, so that users can select the modules they need from multiple modules to build personalized virtual objects. Among them, virtual objects refer to non-physical objects that are controlled, such as virtual vehicles, virtual robots, virtual aircraft, etc.
[0080] As a possible implementation, the model building interface can be built on Unity, a widely used cross-platform game development engine developed by Unity Technologies. It provides a powerful set of tools and features for creating high-quality games, interactive virtual reality (VR), augmented reality (AR) and other graphical applications.
[0081] As a possible implementation method, the model building interface supports view operations such as zooming, panning, and rotating. Specifically, the position of the virtual camera is determined; a view operation instruction for the model building interface is obtained; and the view for the model building interface is adjusted based on the view operation instruction according to the position of the virtual camera. The view operation instruction can be a zoom, pan, rotate, and other instruction.
[0082] For example, taking the model building interface built on Unity as an example, you can create a new C# script and then attach it to the camera implementation in the scene to determine the position of the virtual camera, where the virtual camera refers to the user's perspective of observing the virtual object. For example, if the view operation instruction is a translation instruction, you can add mouse press and move events to the script. When the user presses the mouse and moves, the camera moves along the plane direction, and the translation instruction is obtained. The translation instruction can be used to observe different areas in the space. If the view operation instruction is a zoom instruction, you can add a mouse wheel scroll event to the script, and adjust the distance from the building area for the camera in the Update function. When the user's mouse wheel rolls, the zoom instruction is obtained. Roll forward to zoom in the view, and roll backward to zoom out the view. If the view operation instruction is a rotation instruction, you can add a mouse drag event to the script. When the user performs a drag operation based on the mouse, a rotation instruction is obtained, and the camera is rotated with the center point as the axis according to the direction and distance of the mouse movement.
[0083] See also Figure 7 , which is a schematic diagram of a model building interface provided in an embodiment of the present application. The model building interface includes a module selection menu, a quick view operation menu, and an operation platform. Among them, the module selection menu includes a variety of modules, allowing users to easily browse and select various modules to build virtual objects. The operation platform is a three-dimensional (3D) space for displaying virtual components. The virtual camera is in the direction of the viewing angle. The quick view operation menu includes a direction axis, and the position of the virtual camera can be quickly adjusted by clicking the direction axis to achieve viewing angle conversion. Figure 7The virtual camera shown is on the Z axis. Not only can the view operation instruction be obtained based on the aforementioned pressing the mouse and moving, rolling the mouse wheel, and dragging the mouse, but the view operation instruction can also be issued based on the quick view operation menu, such as clicking "⊕" to achieve zooming in the view.
[0084] S602: In response to the selection operation of the target module, the target virtual component corresponding to the target module is displayed in the model building interface.
[0085] The target module is a module used to build the target virtual object among the multiple modules included in the model building interface, or a module selected by the user. The target virtual component is a virtual component corresponding to the target module, and the virtual component is a component among the components included in the target virtual object. For example, a module is an image or text displayed in 2D form, and a virtual component can be a three-dimensional structure similar to an entity displayed in 3D form.
[0086] Response is used to indicate the conditions or states on which the executed operation depends. When the conditions or states are met, the executed one or more operations can be executed in real time or with a set delay. Unless otherwise specified, the executed multiple operations are not subject to the order of execution. For example, when a user selects a module from multiple modules, the selected module is the target module. Figure 7 The target virtual component corresponding to the target module is displayed on the operating platform of the 3D space shown.
[0087] See also Figure 8 , which is a schematic diagram of building a virtual object provided by an embodiment of the present application. Figure 8 In the example, the target module is a hemisphere module. Users can drag the hemisphere module to the operating platform to display the target virtual component corresponding to the hemisphere module. Users can obtain the target virtual object they have built by continuously dragging and selecting the module they need, that is, Figure 8 The target virtual vehicle is shown.
[0088] S603: In the code editing interface, determine the motion parameter configuration corresponding to the target virtual component.
[0089] After explaining the model building interface, the following is an explanation of the code editing interface. The code editing interface is used to provide users with a coding environment for controlling the movement of virtual objects. The code editing interface includes the control logic corresponding to each virtual component, but the parameters in the control logic are empty or the parameters are default values, which need to be determined by the user, such as Figure 3 or Figure 4As shown in the figure, virtual components such as power wheels have control logic, and the parameters in the control logic can be adjusted through drop-down boxes or numerical values. Therefore, during the programming process, users can only configure the parameters without having to write code from scratch, which helps users better understand the programming process.
[0090] As a possible implementation, the code editing interface can be built based on Blockly, which is a programming library that adds a visual code editor to web and mobile applications to support graphical and visual programming. The Blockly editor uses snap-together graphic blocks (also known as building blocks, which can be freely matched by users) to represent code concepts such as variables, logical expressions, loops, etc. It allows users to program directly according to programming principles without paying attention to syntax details, which is convenient for users to understand.
[0091] As a possible implementation method, in order to reduce the amount of reading for users and help users quickly understand the control logic corresponding to each virtual component, the virtual components obtained based only on the modules selected by the user in the model building interface can be displayed. Figure 4 If the user selects an LCD display and LED colored lights in the model building interface, only the control logic corresponding to the LCD display and the control logic corresponding to the LED colored lights can be displayed in the code editing interface, so that the user can determine the motion parameter configuration corresponding to the virtual component only for the virtual component he needs.
[0092] As a possible implementation, since a virtual object may include multiple repeated virtual components, each virtual component may be named separately to distinguish them, such as Figure 3 As shown, there are two virtual components R45 power wheels, one is called L1 and the other is called L2.
[0093] As a possible implementation, a virtual component can correspond to multiple control logics. Since not every control logic is needed, the user can select only the required control logic. For example, the code editing interface can be built based on Blockly. Each control logic is a building block. The user can drag the required building block behind the "When Started" building block. Only the building blocks behind the "When Started" building block will be executed. Figure 3 shown.
[0094] S604: Obtain a target virtual object based on the target virtual component, and obtain parameter configuration of the target virtual object based on the motion parameter configuration.
[0095] If the target virtual object includes multiple virtual components, S602 and S603 may be repeatedly executed to continuously select the required target modules and determine the motion parameter configuration of the target virtual components corresponding to the target modules, thereby obtaining the target virtual object and the parameter configuration of the target virtual object.
[0096] As a possible implementation manner, the target virtual object may be obtained by repeatedly executing S602 , and then S603 may be executed for each virtual component included in the target virtual object, thereby obtaining parameter configuration of the target virtual object.
[0097] S605: In response to the operation on the target virtual object, control the target virtual object to run based on the parameter configuration.
[0098] After the user performs an operation on the target virtual object, in response to the operation on the target virtual object, the target virtual object may be controlled to run based on the parameter configuration of the target virtual object.
[0099] As a possible implementation method, the simulation control system can include not only the model building interface and the code editing interface, but also a virtual scene interface, such as clicking Figure 2 The area 203 in the image is used to provide an environment for testing the target virtual object. When the user switches to the virtual scene interface, the virtual object just built by the user can be seen placed in a 3D virtual scene, such as Fig. 9 As shown. Fig. 9 In the default state, the virtual object does not move and is static. At the same time, the display named "Small LCD Display 1" above shows a black background.
[0100] When the user clicks the run button, in response to the run operation on the target virtual object, the target virtual object is controlled to run based on the parameter configuration of the target virtual object. Fig.10 , which is a schematic diagram of a virtual scene interface provided by an embodiment of the present application. Fig.10 In the figure, the display named "Small LCD Display 1" shows a white background (i.e., the display included in area 1001), which proves that the car is no longer stationary and will move based on the parameter configuration of the target virtual object. In the parameter configuration of the target virtual object, the virtual object has 4 wheels, L1 and L2 wheels have power to rotate (i.e., the two wheels included in area 1002), and R1 and R2 wheels have no power to rotate (i.e., the two wheels included in area 1003), so the virtual object will rotate to the left as a whole, as shown in FIG. Figure 5 and continue to rotate to the left.
[0101] Therefore, the simulation control system provided by the embodiment of the present application belongs to a convenient and easy-to-use virtual modular construction and programming platform. When it is used in a teaching scenario, it can not only help teachers and other teaching parties without purchasing hardware or teaching materials such as physical robots, but also carry out teaching work in the simulation control system, explain and display the module construction steps of virtual objects, and reduce the use threshold of students and teachers. It also helps to guide students to contact and learn cutting-edge robot programming knowledge in a lower cost, low threshold, and high immersion way. In addition, the simulation control system has the characteristics of modular construction of virtual objects and modular control of virtual objects, which allows students to write control logic for each module separately. In addition, the simulation control system provided by the embodiment of the present application can also be applied to scenes such as digital people, virtual people, games, virtual reality, and extended reality, and this application does not make specific limitations on this.
[0102] It can be seen from the above technical scheme that the control method of the virtual object provided in the embodiment of the present application is applied in the simulation control system of the virtual object, and the simulation control system includes a model building interface and a code editing interface. Among them, a plurality of basic structures required for building a virtual object, i.e., modules, are displayed in the model building interface. When the user selects the target module, the target virtual component corresponding to the target module is displayed in the model building interface, thereby providing the user with the function of customizing the construction of the virtual object through the model building interface. In the code editing interface, the motion parameter configuration corresponding to the target virtual component is determined, thereby providing the user with the function of writing the control logic for the virtual component through the code editing interface, and only the parameters are configured during the writing process, without writing the code from scratch, which is conducive to the user to better understand the programming process. The target virtual object is obtained based on the target virtual component, and the parameter configuration of the target virtual object is obtained based on the motion parameter configuration corresponding to the target virtual component. When the user performs an operation on the target virtual object, the operation of the target virtual object is controlled based on the parameter configuration of the target virtual object.
[0103] Therefore, by pre-disassembling the virtual object into multiple modules, the user can not only independently build the virtual object in the model building interface, but also set the motion parameter configuration for each virtual component included in the virtual object in the code editing interface. Therefore, the user can not only freely build various module combinations to obtain customized virtual objects, but also control the various virtual components included in the virtual object separately, which not only reduces the learning difficulty for the user in the programming process, but also improves the user's creativity and independent learning ability.
[0104] As a possible implementation method, the module is described below by taking a virtual vehicle as an example.
[0105] It should be noted that in order to fully understand the virtual vehicle, the basic components required to build the virtual vehicle can be determined first, including but not limited to chassis, wheels, motors, sensors (such as ultrasonic sensors, color sensors, etc.), lights, and other auxiliary components (such as displays, etc.). Then, based on the basic components, these basic components are abstracted into four types of modules, namely, structural foundation category, actuator category, sensor category, and power unit category. It is understandable that the modules corresponding to the virtual vehicle can also be directly divided into the aforementioned four types of modules, which are explained below.
[0106] The first category, modules belonging to the structural foundation category, are used to provide support functions or connection functions for virtual objects. These modules provide a structural foundation for the virtual vehicle and can be used to build the overall shape of the virtual vehicle. Modules belonging to the structural foundation category have no additional functions, but provide support and connection for other modules so that the virtual object will not fall apart during operation. These modules can be of various shapes and sizes, such as cubes, cylinders, beams, brackets, etc. Users can choose the appropriate modules according to their needs to build a personalized virtual vehicle design.
[0107] The second category, modules belonging to the actuator category, are used to display state result information related to virtual objects. These modules are used to provide functions related to state result information, where state result information refers to state information obtained based on state acquisition information related to the virtual vehicle (such as the current speed of the virtual vehicle calculated based on rotation information), and state acquisition information refers to state information related to the virtual vehicle obtained by modules belonging to the sensor category (such as the current rotation information of the virtual vehicle obtained based on the gyroscope module). It should be noted that the functions provided by modules belonging to the actuator category have nothing to do with power, but are only related to state result information. These modules can perform actions and tasks, but do not provide driving force. For example, the Liquid Crystal Display (LCD) module can be used to display information about the status of the car in real time, the Light Emitting Diode (LED) module can be used as a car light or indicator light, and the sound player module can be used to play music, broadcasts, etc. There are many types of modules belonging to the actuator category, and they provide rich functions and features for the virtual car.
[0108] The third category, modules belonging to the sensor category, are used to collect state information related to virtual objects. These modules are responsible for sensing the surrounding environment or the state of the virtual vehicle itself. For example, the temperature sensor module can monitor the ambient temperature, the camera module can capture the surrounding scene, the distance sensor module can sense the distance to obstacles, and the gyroscope module can sense the angular velocity and direction of the car. Modules belonging to the sensor category provide virtual vehicles with the ability to interact with the environment, enabling them to act and judge autonomously based on external conditions.
[0109] The fourth category, modules belonging to the power device category, are used to provide power for virtual objects. These modules are responsible for providing the power required for the movement and control of the car and are related to movement. For example, the motor module can drive the wheels to rotate and control the forward, backward and steering of the virtual vehicle, while the power wheel module provides friction for smooth driving. The power device enables the virtual vehicle to move and perform tasks autonomously under programmed control, showing the physical effects and operational performance in the real world.
[0110] Therefore, the various components of the virtual vehicle are modularly split, including the chassis, wheels, motors, sensors, etc. Each module has independent functions and characteristics, which can provide users with a rich variety of component options for building customized virtual vehicles, ensuring that different user needs and creativity are met.
[0111] The embodiment of the present application does not specifically limit the method of obtaining the module. Taking the virtual object as a virtual vehicle, the model building interface is obtained based on Unity as an example. The basic shape of the module corresponding to each basic component can be created in 3D modeling software such as Blender and 3ds Max, starting from inserting simple primitives (cubes, cylinders, spheres, etc.), and modifying and adjusting them to meet specific needs. Fig.11 , which is a schematic diagram of a three-dimensional model provided in an embodiment of the present application. Fig.11 In the figure, the 3D models are the camera model, the wheel model, and the tetrahedral structure model from left to right. As a possible implementation method, the created basic shape can be refined and necessary details (such as grooves, gears, etc.) can be added to make the 3D model more realistic.
[0112] Then export the created 3D model to a format supported by Unity, such as FBX, OBJ, etc. Thus, the 3D model is converted into a module, such as Fig.12As shown in the figure, from left to right, they are the camera module, wheel module, and tetrahedron structure module. Finally, the 3D model can be exported to a format supported by Unity and imported into the Unity project to make them game objects. Among them, the game object (GameObject) is the basic unit of all scene elements in Unity. It can be a character, a prop, a scene, etc., and can be created through code or editor.
[0113] As a possible implementation method, since modules may be reused, each module can be made into a Unity prefab for subsequent program use. Among them, a prefab is a reusable game object template in Unity, which can include predefined components, property settings, and sub-object structures. For example, after saving a game object or a group of game objects as a prefab, the prefab can be instantiated as a new game object for use when needed. In this way, prefabs can be placed in multiple scenes and can be placed multiple times in the same scene, which not only reduces the workload of users to repeatedly build virtual objects, but also increases the speed of creating virtual objects.
[0114] As a possible implementation method, appropriate textures can be set for each model and material parameters can be adjusted to achieve realistic visual rendering effects.
[0115] As a possible implementation method, the user may adjust the virtual components that have been built during the process of building the target virtual object. Therefore, the embodiment of the present application provides a dragging function so that the user can adjust the virtual components that have been built.
[0116] However, after research, it was found that if the model building interface is a three-dimensional (3D) space, when the user performs a drag operation in the model building interface, since the drag operation performed by the user based on the mouse belongs to a two-dimensional plane operation, and the currently built virtual components are in three-dimensional space, the simulation control system may be unable to determine the virtual component selected by the drag operation, or the virtual component to be adjusted, that is, a virtual component in the virtual components corresponding to the module displayed in the model building interface. Based on this, the embodiment of the present application determines the component to be adjusted selected by the drag operation through the ray detection technology. Specifically, the drag operation from the model building interface is obtained, and the virtual component to be adjusted selected by the drag operation is determined based on the ray detection technology.
[0117] It should be noted that the present application does not specifically limit the operation to a drag operation, but may be a two-click operation, i.e., the first click operation selects the virtual component to be adjusted, and the second click operation determines the position of the virtual component after adjustment, etc. The present application does not make specific limitations on this, and technical personnel in this field may make settings according to actual needs.
[0118] Among them, raycasting is a technology in the field of computer graphics, which is used to determine the collisions in 3D space. It emits a ray extending from a starting point in a specific direction, and then checks the intersection between the ray path and the surface of the object. Raycasting is generally used in scenarios such as collision detection, click detection, and line of sight detection. In an embodiment of the present application, the position of the virtual camera in the model building interface can be used as the starting point, and at least one ray can be emitted into the model building interface to identify the virtual component to be adjusted selected by the drag operation.
[0119] Therefore, the virtual components that have been built in the model building interface can be adjusted through dragging operations, and the ray detection technology can avoid the inability to identify the virtual components to be adjusted, thereby improving the user experience.
[0120] As a possible implementation method, after determining the virtual component to be adjusted, the simulation control system can directly display the virtual component to be adjusted at the end point of the dragging operation, or it can continuously determine the real-time spatial position of the dragging operation in the model building interface (or the position indicated by the mouse in the model building interface) during the dragging operation, and based on the real-time spatial position, display the virtual component to be adjusted accordingly in the model building interface. That is to say, as the user drags the operation, the virtual component to be adjusted continues to move with the dragging operation to improve the user experience.
[0121] For example, you can add mouse press, move, and release events to the script file to support the dragging operation of virtual components, and then continuously detect mouse click events, and determine which virtual component the mouse has selected based on ray detection technology, and store it as the virtual component to be adjusted. In the script's Update function. When a virtual component is selected, use ray detection technology to calculate the spatial position of the mouse in the model building interface, and use it as the real-time spatial position of the virtual component to be adjusted. Then, based on the real-time spatial position, update the display position of the virtual component to be adjusted in the model building interface, so as to achieve the effect of making the virtual component to be adjusted follow the mouse movement and improve the user experience.
[0122] As a possible implementation method, since virtual components may have rounded corners, hollows, and other designs in order to pursue realism, although the user wants to adjust the virtual object to be adjusted by dragging, if the user clicks on the rounded corners, hollows, and other parts, it will be determined based on the ray detection technology that the virtual object to be adjusted is not currently selected, resulting in a poor user experience. Based on this, the embodiment of the present application sets a virtual shell on the outside of the virtual component so that the virtual shell covers the surface of the virtual component. It can be understood that there can be a preset distance between the virtual shell and the surface of the virtual component, and then the virtual component to be adjusted is determined based on the ray detection technology.
[0123] Specifically, taking the virtual camera as the starting point, at least one ray is emitted from the spatial position of the virtual camera to the model building interface. If one of the rays has an intersection with the target virtual shell, the virtual component to be adjusted selected by the drag operation is the virtual component corresponding to the target virtual shell. That is to say, the virtual shell is detected based on the ray detection operation, and the virtual component covered by the determined target virtual shell is used as the virtual component to be adjusted.
[0124] As a possible implementation method, the virtual shell can be composed of some standard basic units, such as the size of a standard basic unit of 0.1m*0.1m*0.1m, and the virtual shells of virtual components corresponding to different modules can be integer multiples of the standard basic units, such as 0.2m*0.3m*0.4m.
[0125] See also Fig.13 , which is a schematic diagram of a virtual shell provided in an embodiment of the present application. Fig.13 In order to avoid confusion, only one virtual component is shown, namely the virtual component corresponding to the R45 wheel module. The virtual component is wrapped by a cuboid with a size of 0.3 m*0.3 m*0.1 m.
[0126] Therefore, in the process of detecting the virtual components to be adjusted based on the X-ray detection technology, the virtual shell of the virtual components is used as the detection reference, so that the X-ray detection operation can easily hit the virtual components, which can avoid the problem that the user cannot quickly select the virtual components due to clicking on blank positions in the three-dimensional space, such as rounded corners, hollow parts and other parts of the virtual components, thereby improving the user experience.
[0127] As a possible implementation method, in order to facilitate users to build target virtual objects, the simulation control system provided in the embodiment of the present application also provides an adsorption function. Specifically, an adsorption point is added to the virtual component, and the adsorption point is used to store position information. If it is determined that the distance between the adsorption point of the target virtual component and the adsorption point of the historical virtual component is less than a preset threshold, it means that the distance between the target virtual component and the historical virtual component is close. Based on the adsorption point of the historical virtual component, the target virtual component can be adsorbed to the historical virtual component. Among them, the historical virtual component is a virtual component corresponding to the historical module, and the historical module is a module in the module corresponding to the virtual component displayed in the model building model interface.
[0128] As a possible implementation method, in order to improve the personalization of the target virtual object, a function of allowing the user to set and adjust the adsorption point may be provided.
[0129] The embodiments of the present application do not specifically limit the setting method and position of the adsorption point. For example, if the model building interface can be built based on Unity, an empty game object can be used as an adsorption point, so that two game objects (a virtual component is also a game object) constitute a group of game objects, which are placed in the appropriate position of the virtual component, so that the virtual component can be quickly connected to other virtual components. The following is an example of two modules.
[0130] (1) Camera module.
[0131] See also Fig.14 , this figure is a schematic diagram of an adsorption point set for a virtual component corresponding to a camera module provided in an embodiment of the present application. The virtual component corresponding to the camera module is a cube design with 6 faces, one of which has the appearance of a camera, and an adsorption point is set at the center of each of the other five faces, which are respectively denoted as xp, xn, yp, zp and zn. Among them, the xp adsorption point represents the adsorption point on the left side of the x-axis of the virtual component, the xn adsorption point represents the adsorption point on the right side of the x-axis of the virtual component, the yp adsorption point represents the adsorption point behind the y-axis of the virtual component, the zp adsorption point represents the adsorption point above the z-axis of the virtual component, and the zn adsorption point represents the adsorption point below the z-axis of the virtual component. Fig.14 In the figure, the zp adsorption point is shown.
[0132] (2) Tetrahedral pyramid structure module.
[0133] See also Fig.15 , which is a schematic diagram of an adsorption point set for a virtual component corresponding to a tetrahedral structure module provided in an embodiment of the present application. Although the virtual component corresponding to the tetrahedral structure module has 5 faces, generally only one face is used to connect other virtual objects, so an adsorption point can be set, that is, a zn adsorption point is set at the bottom of the virtual component corresponding to the tetrahedral structure module, indicating an adsorption point below the z axis of the virtual component.
[0134] The embodiment of the present application does not specifically limit the method for calculating the distance between the adsorption point of the target virtual component and the adsorption point of the historical virtual component. As a possible implementation method, the distance between the positions of the two adsorption points in the world coordinate system can be calculated by vector calculation. When the distance is less than a preset threshold (such as 0.05 meters), the two virtual components are considered to be close enough and the two virtual components will be automatically combined together.
[0135] For example, taking the model building interface built based on Unity as an example, you can use the Subtract function of the Vector3 class to calculate the difference between the position vectors of two adsorption points, and then use the Magnitude function of the Vector3 class to calculate the length of the distance vector to get the distance between them. The corresponding script is as follows:
[0136] / / Calculate the difference between the position vectors of the two adsorption points
[0137] Vector3 distanceVector=module2.position-–module1.position;
[0138] / / Calculate the length of the distance vector and get the distance between them
[0139] Float distance=distanceVector.magnitude.
[0140] See also Fig.16 and Fig.17 , which is a schematic diagram of an adsorption process provided in an embodiment of the present application. Fig.16 Schematic diagram of the virtual component (target virtual component) corresponding to the R45 wheel module approaching the virtual component (historical virtual component) corresponding to the L4 column module. During the approach process, the distance between the adsorption point of the virtual component corresponding to the wheel module and the adsorption point of the virtual component corresponding to the L4 column module is continuously calculated. If the distance between the virtual object corresponding to the R45 wheel module and the virtual object corresponding to the L4 column module is greater than or equal to the preset threshold, the two virtual components are in a non-adsorbable state. If the distance is less than the preset threshold, the two virtual components are in an adsorbable state. Based on the adsorption point of the virtual component corresponding to the L4 column module, the virtual object corresponding to the R45 wheel module can be adsorbed to the virtual object corresponding to the L4 column module, such as Fig.17 shown.
[0141] Therefore, adsorption points can be set for the virtual components corresponding to each module according to the connection relationship, so as to help users quickly realize the combination of virtual components in the process of building the target virtual object, thereby improving the user experience.
[0142] As a possible implementation method, in the process of adsorbing the target virtual component to the historical virtual component, if the adsorption points of the target virtual component and the historical virtual component cannot overlap, the target virtual component is controlled to rotate until the adsorption points of the target virtual component and the historical virtual component overlap, thereby realizing the combination of the target virtual component and the historical virtual component and improving the user experience.
[0143] See also Fig.18 , which is a schematic diagram of an adsorption process provided in an embodiment of the present application. Fig.18 The neutron picture (a) shows a historical virtual component, which has one adsorption point. Fig.18The 1*1*4 cuboid shown in sub-image (b) is the target virtual component. The target virtual component also has an adsorption point, which is not shown in sub-image (b) because it is blocked. In the process of the target virtual component approaching the historical virtual component, if it is determined that the distance between the adsorption point of the target virtual component and the adsorption point of the historical virtual component is less than a preset threshold, the target virtual component will be adsorbed to the adsorption point of the historical virtual component. However, due to structural limitations, the target virtual component cannot complete the adsorption well. Therefore, in the process of adsorbing the target virtual component to the historical virtual component, if the adsorption points of the target virtual component and the historical virtual component cannot overlap, the target virtual component is controlled to rotate, such as according to Fig.18 The direction of the arrow in the sub-image (b) is rotated until the adsorption point of the target virtual component coincides with the adsorption point of the historical virtual component, as shown in Fig.18 As shown in the neutron diagram (c).
[0144] It should be noted that the rotation direction can be rotating in one direction and continuously trying to see whether the adsorption points of the target virtual component and the historical virtual component coincide with each other, or it can be a rotation direction obtained based on pre-calculation. This application does not make specific limitations on this, and technicians in this field can set it according to actual needs.
[0145] For example, taking the model building interface built based on Unity as an example, you can use the Lerp function of the Vector3 class and the Slerp function of the Quaternion class to gradually move and rotate the virtual components to the adsorption position and angle. In order to achieve a smooth adsorption process and improve the user experience. The corresponding script is as follows:
[0146]
[0147]
[0148] Therefore, after setting adsorption points for the virtual components corresponding to each module according to the connection relationship, the rotation function can help users quickly realize the combination of virtual components in the process of building the target virtual object, thereby improving the user experience.
[0149] As a possible implementation method, in order to facilitate subsequent management and viewing, if the model building interface is built based on Unity, the virtual components (game objects) required to build the target virtual object can be attached to the root node (such as BuildManager) as child nodes.
[0150] See also Fig.19 , which is a schematic diagram of a target virtual object provided by an embodiment of the present application. Fig.19In the example, the target virtual object includes multiple virtual components (as shown in area 1901), which are virtual components corresponding to the square module (as shown in area 1902), virtual components corresponding to the wheels (as shown in area 1903), virtual components corresponding to the LED display screen (as shown in area 1904), virtual components corresponding to various sensors (as shown in area 1905), virtual components corresponding to the camera (as shown in area 1906), and virtual components corresponding to the 1 / 4 spherical structure module (as shown in area 1907), and all virtual components will be attached to the root node BuildManager as child nodes. The target virtual object includes multiple virtual component codes as shown in area 1911, the virtual component codes corresponding to the square module as shown in area 1912, the virtual component codes corresponding to the wheels as shown in area 1913, the virtual component codes corresponding to the LED display screen as shown in area 1914, the virtual components codes corresponding to various sensors as shown in area 1915, the virtual components codes corresponding to the camera as shown in area 1916, and the virtual components codes corresponding to the 1 / 4 spherical structure module as shown in area 1917.
[0151] As a possible implementation method, the simulation control system of the embodiment of the present application also provides an export for the created target virtual object so as to archive it for subsequent use. Specifically, the simulation control system obtains an export operation for the target virtual object and creates a build file according to the modules included in the target virtual object. The build file includes the module identifiers corresponding to the modules included in the target virtual object, the relative positions between the modules, and the connection relationships between the modules.
[0152] Taking the model building interface built based on Unity as an example, when the user performs an export operation on the target virtual object, the simulation control system will traverse all the modules required to build the target virtual object and create a corresponding data object for each module, or in other words, establish an id for each module as a module identifier, and save the position of each module and the connection relationship between the modules under this id. As a possible implementation method, the rotation angle of each module can also be saved, so that the virtual object can be restored better and faster based on the construction file. As a possible implementation method, the information such as module identification, module location, connection relationship between modules, etc. can be serialized into a JSON string to obtain a construction file so that the construction file can be stored with less storage space.
[0153] Similarly, the simulation control system of the embodiment of the present application also provides an import for the created target virtual object so as to quickly establish the target virtual object. Specifically, the simulation control system obtains the construction file corresponding to the target virtual object, the construction file includes the module identification, position and connection relationship between the modules respectively corresponding to the modules included in the target virtual object, obtains the module included in the target virtual object according to the module identification, adjusts the position of the virtual object corresponding to the module included in the target virtual object in the model construction interface according to the position and the connection relationship between the modules, and obtains the target virtual object.
[0154] Taking the model building interface built based on Unity as an example, when the user performs an import operation on the target virtual object, the simulation control system will obtain the building file and perform operations in the opposite order of the export operation, such as reading the JSON string from the building file, deserializing it into a data object, and then reloading the prefab according to the data, instantiating the generated module object and its link relationship.
[0155] Therefore, through the import and export operations of target virtual objects, users can save and share their own creativity, and at the same time facilitate the loading and editing of customized target virtual objects on multiple platforms, thereby improving the user experience.
[0156] As a possible implementation method, in order to better control virtual objects, the control effect of virtual objects can be accurately calculated in combination with the physics engine, such as the running trajectory of virtual vehicles, thereby helping users better understand physical laws and programming concepts.
[0157] Specifically, in the model building interface, not only multiple modules can be displayed, but also the target physical characteristics required by the target module can be displayed. Among them, the target physical characteristics are the physical characteristics required by the target module. Physical characteristics refer to physical-related characteristics such as friction and whether the virtual component is a rigid body.
[0158] After the user determines, modifies, or adds certain physical properties, the simulation control system responds to the trigger operation for the target physical properties to obtain the physical parameter configuration for the target virtual component. It should be noted that after obtaining the physical parameter configuration, the parameter configuration of the target virtual object can be obtained based on the motion parameter configuration and the physical parameter configuration.
[0159] As a possible implementation, the physical properties that may be used may be set for each module in advance, so as to provide the user with choices and help the user quickly understand the various physical properties. As a possible implementation, after the user selects the target module, the corresponding target physical properties may be displayed only for the target module, so as to purposefully display the object properties that the user may need to configure.
[0160] Taking the model building interface built based on Unity as an example, Unity's built-in PhysX physics engine is used to simulate motion, which can calculate and simulate various physical behaviors in the game, such as gravity, friction, air resistance, etc. Therefore, you can directly use the physical parameter configuration of each virtual component of Unity's built-in PhysX physics engine to make the motion effect of virtual objects more realistic. It should be noted that to use Unity's physics engine, you need to follow the following steps:
[0161] (1) Add physical components to the game object, such as rigid body and collider.
[0162] (2) Set the properties of physical components. For example, for a rigid body, you can set mass, drag, angular drag, enable gravity, etc. Mass is used to set the mass of the game object, which affects force and acceleration calculations. Drag and angular drag are used to set linear drag and angular drag to gradually decelerate the game object. Enable gravity is used to make the game object subject to gravity. For another example, for a collider, you can set material, center point, size, etc. Material is used to specify the physics material for the collider to set physical properties such as friction and elasticity. Center point and size are used to adjust the center point and size of the collider according to the shape and size of the game object.
[0163] (3) Control the physical behavior of game objects. For example, apply force and torque to game objects, freeze and unfreeze game objects, etc. Among them, applying force and torque is used to use the rigid body's methods such as AddForce and AddTorque to add force or torque. Freezing and unfreezing game objects is used to change the rigid body's kinematic (isKinematic) property in order to pause or resume the physical simulation of the game object.
[0164] Since different modules may have different physical properties, for the convenience of setting, physical properties can be set for various categories of modules based on the categories to which the modules belong. The following is an explanation based on the above three categories of modules, taking the target module as an example.
[0165] (1) Corresponding to the first category mentioned above, if the category of the target module is the structural basis category, the target physical characteristics include the target physical components pre-defined for the target module, and the attribute parameters of the target physical components. The modules belonging to the structural basis category are used to provide support functions or connection functions for virtual objects.
[0166] Users can add modules belonging to the structural foundation category to form the body of the virtual car, so they can add colliders and rigid bodies to the modules belonging to the structural foundation category. For example, you can add appropriate collider components, such as box colliders or mesh colliders, to each module belonging to the structural foundation category to ensure that they match the size of the real model. For another example, you can add appropriate rigid body components to each module belonging to the structural foundation category to make it part of the physical system, and you can set the physical properties of the structural module such as mass, friction, elasticity, etc. according to the actual situation.
[0167] See also Fig. 20 , which is a schematic diagram of a target physical property provided in an embodiment of the present application. Fig. 20 The corresponding physical properties of the tetrahedral structure module are shown in Figure 1. The bold lines are the mesh colliders added to the tetrahedral structure module.
[0168] See also Fig.21 , which is a schematic diagram of a target physical property provided in an embodiment of the present application. Fig.21 The physical properties of the cube structure module are shown in Figure 1. The bold lines are the box colliders added to the cube structure module.
[0169] See also Fig. 22 , which is a schematic diagram of a target physical property provided in an embodiment of the present application. Fig. 22 In the figure, the mass of the cubic structure module is increased to 10 kg, the resistance is 0, the angular resistance is 0, etc.
[0170] (2) Corresponding to the third category mentioned above, if the category of the target module is the sensor category, the target physical characteristics include the target state acquisition information that the target module needs to collect, the target state result information obtained according to the target state acquisition information and the preset execution logic, and the calling interface of the target state result information. The module belonging to the sensor category is used to collect the state acquisition information related to the virtual object.
[0171] For example, the state acquisition information required for each module belonging to the actuator category can be set, and the state result information can be obtained based on the state acquisition information and the preset execution logic, so that the actual physical characteristics are combined with the simulation results to provide more realistic and reliable data support. In addition, a calling interface for the state result information needs to be set to pass the state result information to the programming logic so that users can make decisions.
[0172] For example, the gyroscope sensor module will calculate the current acceleration, steering angle, etc. in real time based on the current car rotation information. The calling interface is GetGyroscopeValue("gyroscope id", "attribute"). Another example is that the light sensor will calculate the occlusion relationship between the nearby buildings and modules and the sensor photosensitive module, and calculate the light value in real time. The calling interface is GetLightValue("light sensor id").
[0173] (3) Corresponding to the fourth category, if the category of the target module is a power device category, the target physical properties include a target physical component predefined for the target module, attribute parameters of the target physical component, a calling interface of a physical behavior corresponding to the target physical component, and a rendering effect corresponding to the target physical component. The module belonging to the power device category is used to provide power for the virtual object;
[0174] Taking the wheel module as an example, you can add a wheel collider to (1) the wheel. This physics component allows the wheel to contact the ground and simulate motion effects, such as spring suspension, friction, etc. This physics component is responsible for simulating friction between the wheel and the ground, spring suspension, etc. It is also used to handle the torque and braking force required to drive the car. (2) Adjust the attribute parameters of the wheel collider, such as radius, suspension spring, forward friction, sideways friction, etc. Among them, the radius is used to set the radius of the wheel collider according to the actual wheel model size, such as 0.26 meters. The suspension spring is used to set the spring force and damping, as well as the target stable position percentage. Forward friction and sideways friction are used to adjust the friction coefficient of the tire in the forward direction (driving direction) and sideways (lateral). Appropriately configure these parameters to achieve more realistic driving performance. (3) Set the calling interface of the physical behavior corresponding to the physical component, that is, provide an interface to the outside world. Taking the R45 power wheel module as an example, the bottom layer will call wheelCollider.motorTorque=power value so that the user can set the torque of the module motor, thereby controlling the movement of the wheel and ultimately the movement of the virtual object. (4) The rendering effect corresponding to the physical component, that is, synchronize the wheel model. Since the wheel collider itself does not have a rendering effect, it can be synchronized with the actual wheel model at runtime. For example, create a script to keep the position and rotation of the wheel model consistent with the wheel collider. In the Update function, read the position and rotation information of the wheel collider and apply it to the wheel model to ensure that the wheel module has a rotation effect.
[0175] As a possible implementation method, taking the code editing interface built based on Blockly as an example, users can use the Blockly visual building block programming library to write corresponding control logic for each virtual component of the constructed virtual object to control the movement and effects of the virtual object. Users can write code by dragging building blocks without writing complex syntax and code.
[0176] For example, the above-mentioned calling interface will be converted into building blocks in Blockly. By using building blocks to represent various control instructions, users can easily build, program and debug the motion behavior of virtual objects. For example, if the calling interface is MotorRotate("encoder motor id", 60), where id is the module ID and the encoder motor id is the module ID of the encoder module, the corresponding building blocks can be Figure 3 The building blocks below the encoder motor shown. If the calling interface is WPRotate("R45 power wheel id",30), the corresponding building blocks can be Figure 3 The bricks below the power wheel are shown. Continue to combine Figure 4 To illustrate, the calling interface corresponding to each building block under the LCD display can be expressed as follows:
[0177] SetBackgroundColor("LCD display id","black");
[0178] ClearDisplayScreen("LCD display screen id");
[0179] SetFontSizeAndColor("LCD display id","small","black");
[0180] RotateFont("LCD display screen id",0);
[0181] LCDPrint("LCD display screen id","text");
[0182] LCDPrintln("LCD display screen id","text");
[0183] The calling interface corresponding to each building block under the LED colored light can be expressed as follows:
[0184] LightsDisplayScreenShow("LED color light module id","#ffffff");
[0185] LightsDisplayScreenShow("LED color light module id","#ffffff",1);
[0186] LightsDisplayScreenShow("LED color light module id",255,255,0);
[0187] LightsDisplayScreenShow("LED color light module id",255,255,0,1);
[0188] LightsDisplayChangeBrightness("LED color light module id",10);
[0189] LightsDisplaySetBrightness("LED color light module id",30);
[0190] LightsDisplayGetBrightness("LED colored light module id").
[0191] As a possible implementation method, since the same operation has different control effects on the target virtual object in different scenes, for example, the operation of the target virtual vehicle in the desert is different from that in the city. Based on this, the embodiment of the present application provides a function of adjusting the physical parameter configuration based on the overall virtual scene, so as to improve the control effect while facilitating the user to adjust the physical parameter configuration and improve the user experience.
[0192] Specifically, when the user executes an adjustment instruction for the virtual scene, the simulation control system responds to obtaining the virtual scene adjustment instruction and displays a parameter adjustment interface of the virtual scene where the target virtual object is located. In response to obtaining the virtual scene parameters for the virtual scene, the physical parameter configuration of the virtual components included in the target virtual object is adjusted to obtain an updated physical parameter configuration; subsequently, based on the motion parameter configuration and the updated physical parameter configuration, the parameter configuration of the target virtual object is obtained to achieve overall control of the target virtual object based on the virtual scene.
[0193] See also Fig.23 , which is a schematic diagram of a parameter adjustment interface provided in an embodiment of the present application. Fig.23 In the figure, the adjustment values of dynamic friction, static friction and other physical parameter configurations are displayed, so that virtual scenes including virtual terrain and virtual environments can be built according to actual scenes, such as racetracks, deserts, mountains, etc., and the physical parameter configurations in the scenes, such as ground friction, slope angle, etc., can be adjusted.
[0194] As a possible implementation method, the simulation control system provided in the embodiment of the present application also provides a data storage function. Specifically, the simulation control system also includes a module data center, which is used to obtain target data related to the target virtual object from the model interface in real time, and save the target data. For example, the module data center continuously detects the user's operations in the model building interface, such as the user adding, deleting or modifying modules, and obtains the target data related to the modules. Moreover, the module data center can also save the target data in real time to ensure data consistency. Among them, the target data refers to the relevant data of the module used by the user in the process of building the target virtual object through the model building interface, such as module identification, module type, location and connection relationship between modules, etc.
[0195] As a possible implementation method, since the visual programming platform provided in the relevant technology generally only supports specific operating systems, for example, generally only supports high-version Windows TM The system cannot meet the compatibility requirements between different operating systems and devices. This limits the user experience and promotion to a certain extent. Based on this, in the embodiment of the present application, the model building interface can be built based on Unity, and the code editing interface can be built based on Blockly. Since Unity can be applied to platforms such as Windows TM , macOS TM , Linux TM 、iOS TM 、Android TM It can also provide functions such as a three-dimensional virtual environment and a physical engine, so that the simulation control system supports multiple operating systems from a basic technical level, thereby achieving cross-platform compatibility, allowing users to use the simulation control system provided by the embodiment of the present application on different devices. Moreover, the code editing interface built on Blockly can provide visual programming, providing a user-friendly programming experience, supporting the writing of control logic for each module of the built virtual object, and controlling the movement of the virtual object and the module effect. It can be applied to the field of education and the field of visual programming for young people, helping students to better understand physical laws and programming concepts, and improve their creativity and problem-solving skills.
[0196] As a possible implementation method, a communication channel can be established in advance to facilitate data transmission between the model building interface and the code editing interface. If the module data center obtains the target data, the target data is converted into a target message and the target message is sent to the code editing interface through the communication channel.
[0197] The embodiment of the present application does not specifically limit the way of establishing the communication channel. For example, it can be implemented by using technologies such as WebSocket (a network transmission protocol), WebRTC (a real-time communication technology), JSBridge (a bridge), etc. to achieve real-time, two-way data transmission between Unity and Blockly pages. Through the communication channel, Unity and Blockly pages can send and receive messages to each other to achieve synchronization of module information.
[0198] As a possible implementation method, ZFBrowser can be used to realize data transmission between Unity and Blockly pages. Among them, the model building interface built based on Unity can be based on the functions of 3d and 2d game engines provided by c# language, and the code editing interface built based on Blockly can be based on the building block functions provided by js language. ZFBrowser is a Unity plug-in written in c# language, and then the underlying library of browser components is called (it can be understood that the achievement is a browser that can open pages), which is used to embed the Web browser into the Unity project. With the help of ZFBrowser, Web-based applications can be run in the Unity project, which can not only run in the unity environment, but also allow the web page to display and execute normally, thus realizing cross-platform applications.
[0199] See also Fig.24 , which is a schematic diagram of the interaction between a model building interface and a code editing interface provided in an embodiment of the present application. Fig.24 In the , the model building interface can be built based on Unity, the code editing interface can be built based on Blockly, and ZFBrowser is a plug-in that embeds the web application into Unity. When the three components are used in combination, their respective cross-platform advantages can be fully utilized to achieve a flexible and widely compatible application. Therefore, the simulation control system developed based on these three components can be used on multiple operating systems to meet a wide range of learning needs and scenarios.
[0200] In order to facilitate further understanding of the technical solution provided in the embodiments of the present application, the following takes the execution subject of the virtual object control method provided in the embodiments of the present application as a terminal device and the virtual object as a virtual vehicle as an example to provide an overall exemplary introduction to the virtual object control method.
[0201] The simulation control system is first explained below.
[0202] The model control system includes a model building interface, a module data center and a code editing interface. The model building interface can be built based on Unity, the code editing interface can be built based on Blockly, and a communication channel is pre-established between the model building interface and the code editing interface, which can be built based on ZFBrowser.
[0203] See also Fig.25 , which is a schematic diagram of a simulation control system provided by an embodiment of the present application. Fig.25 In the model building interface, multiple modules are displayed so that users can build target virtual objects through the model building interface. The module data center detects the model building interface and continuously detects the user's operations in the model building interface so as to obtain the target data related to the target virtual object from the model interface in real time and save the target data. In addition, the target data is converted into a target message, and the target message is sent to the code editing interface through the communication channel. For example, in response to the selection operation of the target module, not only the target virtual component corresponding to the target module is displayed in the model building interface, but the module data center also converts the target data of the lake area into a target message, and sends the target message to the code editing interface through the communication channel. The code editing interface needs to write message processing logic for receiving and parsing messages from the Unity side. When a message about module information update is received, the Blockly page will update the drop-down options, parameter values, etc. in the visual programming building blocks according to the message content.
[0204] After introducing the simulation control system, it explains how users can use the simulation control system.
[0205] See also Fig.26 , which is a schematic diagram of an application scenario of a control method for a virtual object provided in an embodiment of the present application. In the module building interface, multiple modules are displayed. In order to facilitate users to quickly find the required modules, the simulation control system constructs functional areas such as a module selection menu and an operating platform in the model building interface. In the module selection menu, the modules are divided into 4 categories, namely, the structural foundation category, the actuator category, the sensor category, and the power device category.
[0206] Users can start building a virtual vehicle through the module building interface, such as through the module selection menu in the model building interface, using the structural basic category modules (i.e. modules belonging to the structural basic category, the same applies to the following, no further description will be given), actuator category modules, sensor category modules and power device category modules to build the target virtual vehicle. After the user drags the required module from the module selection menu to the operating platform, the module will be instantiated as a virtual component. Fig. 27As shown, the user can select the R45 power wheel module in the power device category from the module selection menu and drag it to the operating platform to display the virtual component corresponding to the R45 power wheel module. In addition, the user can also name the virtual component corresponding to the R45 power wheel module as "Wheel 1". In addition, in the model building interface, the target physical properties required by the target module are displayed so that the user can add physical parameter configurations for each virtual component.
[0207] In the code editing interface, the control logic, or building blocks, corresponding to each module will be displayed. Users can drag and drop the required building blocks to the back of the "When running" building block and determine the motion parameter configuration they need. In order to facilitate users to quickly find the required modules, the simulation control system has built functional areas such as building block selection menus and operation logic menus in the model building interface. In the building block selection menu, the building blocks are divided into multiple categories, such as structural foundation categories, actuator categories, sensor categories, and power unit categories. Users can click on the required category to enter the building block selection menu included in the required category. Fig.28 As shown, the user has selected the power device category, which includes the encoder motor building block and the power wheel building block. The user can drag the building block corresponding to the R45 power wheel module behind the "When Start Running" building block and determine "Wheel 1 (L1)" and 30 power rotations.
[0208] Similarly, users can continue to build the target virtual vehicle through the model building interface, such as Figure 2 As shown, the user continues to drag the R45 power wheel through the model building interface, and the R45 power wheel can be named "wheel 2 (L2)". Fig.29 As shown, the user can also drag the building block corresponding to the R45 power wheel module behind the "When starting to run" building block in the code editing interface. Since there are currently 2 building blocks corresponding to the R45 power wheel module, select the building block for which the motion parameter configuration needs to be determined through the drop-down box, such as the motion parameter configuration corresponding to wheel 1.
[0209] Therefore, users can select the required modules based on the module building interface to build the virtual vehicle they want, and determine the motion parameter configuration corresponding to each virtual component based on the code editing interface to obtain the parameter configuration of the target virtual vehicle.
[0210] When the user performs a run operation on the target virtual vehicle point, the simulation control system responds to the run operation on the target virtual vehicle and controls the operation of the target virtual vehicle based on the parameter configuration, thereby achieving the purpose of controlling the operation of different modules of the virtual vehicle through visual programming. For example, after the user clicks the run operation through the model building interface, the code editing interface converts the currently required building blocks into C# code that can be executed in Unity, such as Fig.30 The diagram shown is a schematic diagram of a building block, which can be transformed into Fig.31 The schematic diagram of the code shown. Fill the code into a script named Runtime, execute the script and mount it on the root node of the virtual vehicle to control the movement of the virtual vehicle. In the process of controlling the operation of the virtual vehicle, if the virtual vehicle includes a module belonging to the power device type, the power module interface can be called, that is, the calling interface corresponding to the module belonging to the power device category, and the physical simulation calculation is performed through the physical engine, and the movement of the virtual components corresponding to the module belonging to the power device category is controlled, and the movement of the virtual vehicle as a whole is controlled, and the virtual components corresponding to the module belonging to the actuator category are controlled.
[0211] Therefore, the simulation control system provided in the embodiment of the present application can run on different operating systems, allowing users to freely build a platform for virtual objects. At the same time, it provides a visual building block programming library, supports writing control logic for each module of the built virtual object, and is used to control the movement of the virtual object and the module effects. It can be applied to the field of education and the field of youth visual programming, which helps students better understand the laws of physics and programming concepts, and improve their creativity and problem-solving skills.
[0212] If it is applied in the field of teaching, the following technical effects can be achieved:
[0213] (1) Lower the learning threshold for students. By providing a simple and easy-to-use virtual construction and visual programming environment, students can easily learn programming without having to master complex hardware knowledge and programming syntax.
[0214] (2) Improve the accessibility of educational resources. Compared with physical hardware, virtual platforms are less expensive and can allow more schools and students to access and learn cutting-edge robot programming knowledge, effectively bringing educational resources to a wider range.
[0215] (3) Cultivate creativity and problem-solving skills. The solution supports modular construction and programming, allowing students to freely build and write control logic according to textbooks, teaching tasks, and creative ideas. This will help students better understand physical laws and programming concepts, and improve their creativity and problem-solving skills.
[0216] (4) Support for custom modules and control logic. Programmable virtual object control allows students to customize the physical properties and behavior of each module to adapt it to a variety of scenarios and needs. Students can optimize and adjust the behavior of virtual objects according to specific tasks or goals, increasing the flexibility and scalability of the system.
[0217] With respect to the virtual object control method described above, the present application also provides a corresponding virtual object control device, so that the virtual object control method described above can be applied and implemented in practice.
[0218] See also Fig.32 , which is a schematic diagram of the structure of a control device for a virtual object provided in an embodiment of the present application. Fig.32 As shown, the control device 3200 of the virtual object includes: a display unit 3201, a determination unit 3202, an acquisition unit 3203 and a control unit 3204;
[0219] The display unit 3201 is used to display multiple modules in the model building interface, where the modules are basic structures required to build the virtual object;
[0220] The display unit 3201 is further used to display a target virtual component corresponding to the target module in the model building interface in response to a selection operation of the target module, wherein the target module is a module among the multiple modules used to build a target virtual object, the target virtual component is a virtual component corresponding to the target module, and the virtual component is a component included in the target virtual object;
[0221] The determining unit 3202 is used to determine the motion parameter configuration corresponding to the target virtual component in the code editing interface;
[0222] The acquisition unit 3203 is used to obtain the target virtual object based on the target virtual component, and obtain the parameter configuration of the target virtual object based on the motion parameter configuration;
[0223] The control unit 3204 is used to control the operation of the target virtual object based on the parameter configuration in response to the operation operation on the target virtual object.
[0224] It can be seen from the above technical scheme that the control method of the virtual object provided in the embodiment of the present application is applied in the simulation control system of the virtual object, and the simulation control system includes a model building interface and a code editing interface. Among them, a plurality of basic structures required for building a virtual object, i.e., modules, are displayed in the model building interface. When the user selects the target module, the target virtual component corresponding to the target module is displayed in the model building interface, thereby providing the user with the function of customizing the construction of the virtual object through the model building interface. In the code editing interface, the motion parameter configuration corresponding to the target virtual component is determined, thereby providing the user with the function of writing the control logic for the virtual component through the code editing interface, and only the parameters are configured during the writing process, without writing the code from scratch, which is conducive to the user to better understand the programming process. The target virtual object is obtained based on the target virtual component, and the parameter configuration of the target virtual object is obtained based on the motion parameter configuration corresponding to the target virtual component. When the user performs an operation on the target virtual object, the operation of the target virtual object is controlled based on the parameter configuration of the target virtual object.
[0225] Therefore, by pre-disassembling the virtual object into multiple modules, the user can not only independently build the virtual object in the model building interface, but also set the motion parameter configuration for each virtual component included in the virtual object in the code editing interface. Therefore, the user can not only freely build various module combinations to obtain customized virtual objects, but also control the various virtual components included in the virtual object separately, which not only reduces the learning difficulty for the user in the programming process, but also improves the user's creativity and independent learning ability.
[0226] As a possible implementation, if the virtual object is a virtual vehicle, the module includes a structural basis category, an actuator category, a sensor category and a power device category; wherein the module belonging to the structural basis category is used to provide a support function or a connection function for the virtual object, the module belonging to the actuator category is used to display status result information related to the virtual object, the module belonging to the sensor category is used to collect status collection information related to the virtual object, and the module belonging to the power device category is used to provide power for the virtual object.
[0227] As a possible implementation, the model building interface is a three-dimensional space, and the determining unit 3202 is further used to:
[0228] Obtaining a drag operation from the model building interface;
[0229] The virtual component to be adjusted selected by the dragging operation is determined based on the ray detection technology, and the virtual component to be adjusted is a virtual component among the virtual components corresponding to the modules displayed in the model building interface.
[0230] As a possible implementation, the determining unit 3202 is further configured to continuously determine the real-time spatial position of the dragging operation in the model building interface during the process of performing the dragging operation;
[0231] The display unit 3201 is further used to display the virtual component to be adjusted in the model building interface based on the real-time spatial position.
[0232] As a possible implementation manner, the surface of the virtual component is covered with a virtual shell, and the determining unit 3202 is specifically configured to:
[0233] From the spatial position of the virtual camera in the model building interface, emitting rays into the model building interface;
[0234] If the ray and the target virtual shell have an intersection, the virtual component to be adjusted selected by the drag operation is the virtual component corresponding to the target virtual shell, and the target virtual shell is one of the virtual shells displayed in the model building interface.
[0235] As a possible implementation manner, the virtual component has an adsorption point, and the adsorption point is used to store position information. The device also includes an adsorption unit, which is used to:
[0236] If it is determined that the distance between the adsorption point of the target virtual component and the adsorption point of the historical virtual component is less than a preset threshold, the target virtual component is adsorbed to the historical virtual component based on the adsorption point of the historical virtual component, and the historical virtual component is a virtual component corresponding to a historical module, and the historical module is one of the modules corresponding to the virtual component displayed in the model building model interface.
[0237] As a possible implementation, the device further includes an adsorption unit, which is used to:
[0238] In the process of adsorbing the target virtual component to the historical virtual component, if the adsorption points of the target virtual component and the historical virtual component cannot overlap, the target virtual component is controlled to rotate until the adsorption points of the target virtual component and the historical virtual component overlap.
[0239] As a possible implementation manner, the device further includes a creating unit;
[0240] The acquisition unit 3203 is further used to acquire an export operation for the target virtual object;
[0241] The creation unit is used to create a construction file according to the modules included in the target virtual object, and the construction file includes module identifiers and positions respectively corresponding to the modules included in the target virtual object, and connection relationships between the modules.
[0242] As a possible implementation manner, the obtaining unit 3203 is further configured to:
[0243] Acquire a construction file corresponding to the target virtual object, wherein the construction file includes module identifiers, positions and connection relationships between modules respectively corresponding to the modules included in the target virtual object;
[0244] The module included in the target virtual object is obtained according to the module identifier, and the position of the virtual object corresponding to the module included in the target virtual object in the model building interface is adjusted according to the position and the connection relationship between the modules to obtain the target virtual object.
[0245] As a possible implementation manner, the obtaining unit 3203 is specifically configured to:
[0246] In the model building interface, the target physical properties required by the target module are displayed;
[0247] In response to a trigger operation for the target physical property, obtaining a physical parameter configuration for the target virtual component;
[0248] The obtaining the parameter configuration of the target virtual object based on the motion parameter configuration includes:
[0249] Based on the motion parameter configuration and the physical parameter configuration, a parameter configuration of the target virtual object is obtained.
[0250] As a possible implementation, if the category of the target module is a power device category, the target physical properties include a target physical component predefined for the target module, attribute parameters of the target physical component, a calling interface of a physical behavior corresponding to the target physical component, and a rendering effect corresponding to the target physical component. The module belonging to the power device category is used to provide power for the virtual object.
[0251] If the category of the target module is a structural basis category, the target physical properties include a target physical component predefined for the target module and an attribute parameter of the target physical component, and the module belonging to the structural basis category is used to provide a support function or a connection function for the virtual object;
[0252] If the category of the target module is a sensor category, the target physical characteristics include the target state collection information that the target module needs to collect, the target state result information is obtained according to the target state collection information and the preset execution logic, and the calling interface of the target state result information. The module belonging to the sensor category is used to collect the state collection information related to the virtual object.
[0253] As a possible implementation manner, the device further includes an adjustment unit;
[0254] The display unit 3201 is further configured to display a parameter adjustment interface of the virtual scene where the target virtual object is located in response to obtaining a virtual scene adjustment instruction;
[0255] The adjusting unit is configured to adjust the physical parameter configuration of the virtual component included in the target virtual object in response to acquiring the virtual scene parameter for the virtual scene, so as to obtain an updated physical parameter configuration;
[0256] The acquisition unit 3203 is specifically configured to obtain the parameter configuration of the target virtual object based on the motion parameter configuration and the updated physical parameter configuration.
[0257] As a possible implementation, the simulation control system further includes a module data center for acquiring target data related to the target virtual object from the model interface in real time and storing the target data.
[0258] As a possible implementation manner, the device further includes an establishing unit and a sending unit;
[0259] The establishing unit is used to pre-establish a communication channel for data transmission between the model building interface and the code editing interface;
[0260] The sending unit is used to convert the target data into a target message if the module data center obtains the target data, and send the target message to the code editing interface through the communication channel.
[0261] As a possible implementation, the model building interface is applicable to multiple operating systems.
[0262] The present application also provides a computer device, which is the computer device described above. The computer device can be a server or a terminal device. The control device of the virtual object described above can be built into the server or the terminal device. The computer device provided by the present application will be introduced from the perspective of hardware entity. Fig.33 The following is a schematic diagram of the server structure. Fig.34Shown is a schematic diagram of the structure of the terminal equipment.
[0263] See also Fig.33 , which is a schematic diagram of a server structure provided in an embodiment of the present application. The server 1400 may have relatively large differences due to different configurations or performances, and may include one or more processors 1422, such as central processing units (CPU), memory 1432, one or more application programs 1442 or storage media 1430 (such as one or more massive storage devices) for data 1444. Among them, the memory 1432 and the storage medium 1430 may be temporary storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the processor 1422 may be configured to communicate with the storage medium 1430 to execute a series of instruction operations in the storage medium 1430 on the server 1400.
[0264] The server 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458, and / or one or more operating systems 1441, such as Windows Server 2003. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM etc.
[0265] The steps performed by the server in the above embodiment can be based on the Fig.33 The server structure shown.
[0266] The CPU 1422 is used to execute the following steps:
[0267] In the model building interface, multiple modules are displayed, and the modules are basic structures required to build the virtual object;
[0268] In response to a selection operation of a target module, a target virtual component corresponding to the target module is displayed in the model building interface, wherein the target module is a module among the multiple modules used to build a target virtual object, the target virtual component is a virtual component corresponding to the target module, and the virtual component is a component included in the target virtual object;
[0269] In the code editing interface, determining the motion parameter configuration corresponding to the target virtual component;
[0270] Obtain the target virtual object based on the target virtual component, and obtain parameter configuration of the target virtual object based on the motion parameter configuration;
[0271] In response to an operation on the target virtual object, the target virtual object is controlled to run based on the parameter configuration.
[0272] Optionally, the CPU 1422 may also execute method steps of any specific implementation of the method for controlling a virtual object in the embodiments of the present application.
[0273] See also Fig.34 , which is a structural diagram of a terminal device provided in an embodiment of the present application. Fig.34 The block diagram shows a partial structure of a smart phone related to a terminal device provided in an embodiment of the present application, and the smart phone includes: a radio frequency (RF) circuit 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a processor 1580, and a power supply 1590. Those skilled in the art can understand that Fig.34 The structure of the smartphone shown in the figure does not constitute a limitation of the smartphone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0274] Combine the following Fig.34 A detailed introduction to the various components of a smartphone:
[0275] The RF circuit 1510 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information from the base station, it is sent to the processor 1580 for processing; in addition, the designed uplink data is sent to the base station.
[0276] The memory 1520 may be used to store software programs and modules. The processor 1580 implements various functional applications and data processing of the smartphone by running the software programs and modules stored in the memory 1520 .
[0277] The input unit 1530 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the smartphone. Specifically, the input unit 1530 may include a touch panel 1531 and other input devices 1532. The touch panel 1531, also known as a touch screen, can collect user touch operations on or near it and drive the corresponding connection device according to a pre-set program. In addition to the touch panel 1531, the input unit 1530 may also include other input devices 1532. Specifically, other input devices 1532 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
[0278] The display unit 1540 may be used to display information input by the user or information provided to the user and various menus of the smartphone. The display unit 1540 may include a display panel 1541, and the display panel 1541 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0279] The smartphone may also include at least one sensor 1550, such as a light sensor, a motion sensor, and other sensors. As for other sensors that may be configured in the smartphone, such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., they will not be described in detail here.
[0280] The audio circuit 1560, the speaker 1561, and the microphone 1562 can provide an audio interface between the user and the smartphone. The audio circuit 1560 can transmit the received audio data to the speaker 1561 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 1562 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1560 and converted into audio data, and then the audio data is output to the processor 1580 for processing, and then sent to another smartphone through the RF circuit 1510, or the audio data is output to the memory 1520 for further processing.
[0281] The processor 1580 is the control center of the smartphone, and uses various interfaces and lines to connect various parts of the entire smartphone, and executes various functions of the smartphone and processes data by running or executing software programs and / or modules stored in the memory 1520, and calling data stored in the memory 1520. Optionally, the processor 1580 may include one or more processing units.
[0282] The smart phone also includes a power supply 1590 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 1580 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption management.
[0283] Although not shown, the smartphone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0284] In the embodiment of the present application, the memory 1520 included in the smart phone can store program codes and transmit the program codes to the processor.
[0285] The processor 1580 included in the smart phone can execute the virtual object control method provided in the above embodiment according to the instructions in the program code.
[0286] An embodiment of the present application also provides a computer-readable storage medium for storing a computer program, wherein the computer program is used to execute the virtual object control method provided in the above embodiment.
[0287] The embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the control method of the virtual object provided in various optional implementations of the above aspects.
[0288] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the above storage medium can be at least one of the following media: read-only memory (English: Read-Only Memory, abbreviated: ROM), RAM, magnetic disk or optical disk, etc. Various media that can store program codes.
[0289] It should be noted that each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0290] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a technician familiar with the technical field within the technical scope disclosed in the present application should be included in the protection scope of the present application. Based on the implementation methods provided in the above aspects, the present application can also be further combined to provide more implementation methods. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for controlling a virtual object, characterized in that: The method is applied to a simulation control system, the simulation control system includes a model building interface and a code editing interface, and the method includes: In the model building interface, multiple modules are displayed, and the modules are basic structures required to build the virtual object; In response to a selection operation of a target module, a target virtual component corresponding to the target module is displayed in the model building interface, wherein the target module is a module among the multiple modules used to build a target virtual object, the target virtual component is a virtual component corresponding to the target module, and the virtual component is a component included in the target virtual object; In the code editing interface, determining the motion parameter configuration corresponding to the target virtual component; Obtain the target virtual object based on the target virtual component, and obtain parameter configuration of the target virtual object based on the motion parameter configuration; In response to an operation on the target virtual object, the target virtual object is controlled to run based on the parameter configuration.
2. The method according to claim 1, characterized in that If the virtual object is a virtual vehicle, the module includes a structural basis category, an actuator category, a sensor category, and a power device category; Among them, the module belonging to the structural foundation category is used to provide a support function or a connection function for the virtual object, the module belonging to the actuator category is used to display the status result information related to the virtual object, the module belonging to the sensor category is used to collect status collection information related to the virtual object, and the module belonging to the power device category is used to provide power for the virtual object.
3. The method according to claim 1, characterized in that The model building interface is a three-dimensional space, and the method further includes: Obtaining a drag operation from the model building interface; The virtual component to be adjusted selected by the dragging operation is determined based on the ray detection technology, and the virtual component to be adjusted is a virtual component among the virtual components corresponding to the modules displayed in the model building interface.
4. The method according to claim 3, characterized in that The method further comprises: During the process of performing the dragging operation, continuously determining the real-time spatial position of the dragging operation in the model building interface; Based on the real-time spatial position, the virtual component to be adjusted is correspondingly displayed in the model building interface.
5. The method according to claim 3, characterized in that: The surface of the virtual component is covered with a virtual shell, and the method of determining the virtual component to be adjusted selected by the dragging operation based on the ray detection technology includes: From the spatial position of the virtual camera in the model building interface, emitting rays into the model building interface; If the ray and the target virtual shell have an intersection, the virtual component to be adjusted selected by the drag operation is the virtual component corresponding to the target virtual shell, and the target virtual shell is one of the virtual shells displayed in the model building interface.
6. The method according to claim 1, characterized in that The virtual component has an adsorption point, and the adsorption point is used to store position information. The method further includes: If it is determined that the distance between the adsorption point of the target virtual component and the adsorption point of the historical virtual component is less than a preset threshold, the target virtual component is adsorbed to the historical virtual component based on the adsorption point of the historical virtual component, and the historical virtual component is a virtual component corresponding to a historical module, and the historical module is one of the modules corresponding to the virtual component displayed in the model building model interface.
7. The method according to claim 6, characterized in that The step of adsorbing the target virtual component to the historical virtual component based on the adsorption point of the historical virtual component includes: In the process of adsorbing the target virtual component to the historical virtual component, if the adsorption points of the target virtual component and the historical virtual component cannot overlap, the target virtual component is controlled to rotate until the adsorption points of the target virtual component and the historical virtual component overlap.
8. The method according to claim 1, characterized in that: The method further comprises: Obtaining an export operation for the target virtual object; A build file is created according to the modules included in the target virtual object, wherein the build file includes module identifiers, positions and connection relationships between the modules respectively corresponding to the modules included in the target virtual object.
9. The method according to claim 1, characterized in that: The method further comprises: Acquire a construction file corresponding to the target virtual object, wherein the construction file includes module identifiers, positions and connection relationships between modules respectively corresponding to the modules included in the target virtual object; The module included in the target virtual object is obtained according to the module identifier, and the position of the virtual object corresponding to the module included in the target virtual object in the model building interface is adjusted according to the position and the connection relationship between the modules to obtain the target virtual object.
10. The method according to claim 1, characterized in that The step of obtaining the target virtual object based on the target virtual component includes: In the model building interface, the target physical properties required by the target module are displayed; In response to a trigger operation for the target physical property, obtaining a physical parameter configuration for the target virtual component; The obtaining the parameter configuration of the target virtual object based on the motion parameter configuration includes: Based on the motion parameter configuration and the physical parameter configuration, a parameter configuration of the target virtual object is obtained.
11. The method according to claim 10, characterized in that If the category of the target module is a power device category, the target physical properties include a target physical component predefined for the target module, attribute parameters of the target physical component, a calling interface of a physical behavior corresponding to the target physical component, and a rendering effect corresponding to the target physical component. The module belonging to the power device category is used to provide power for the virtual object; If the category of the target module is a structural basis category, the target physical properties include a target physical component predefined for the target module and an attribute parameter of the target physical component, and the module belonging to the structural basis category is used to provide a support function or a connection function for the virtual object; If the category of the target module is a sensor category, the target physical characteristics include the target state collection information that the target module needs to collect, the target state result information is obtained according to the target state collection information and the preset execution logic, and the calling interface of the target state result information. The module belonging to the sensor category is used to collect the state collection information related to the virtual object.
12. The method according to claim 10, characterized in that The method further comprises: In response to obtaining the virtual scene adjustment instruction, displaying a parameter adjustment interface of the virtual scene where the target virtual object is located; In response to acquiring virtual scene parameters for the virtual scene, adjusting physical parameter configurations of virtual components included in the target virtual object to obtain updated physical parameter configurations; The obtaining the parameter configuration of the target virtual object based on the motion parameter configuration and the physical parameter configuration includes: Based on the motion parameter configuration and the updated physical parameter configuration, a parameter configuration of the target virtual object is obtained.
13. The method according to claim 1, characterized in that The simulation control system also includes a module data center, which is used to obtain target data related to the target virtual object from the model interface in real time and save the target data.
14. The method according to claim 13, characterized in that: The method further comprises: Pre-establishing a communication channel for data transmission between the model building interface and the code editing interface; If the module data center obtains the target data, the target data is converted into a target message, and the target message is sent to the code editing interface through the communication channel.
15. The method according to any one of claims 1 to 14, wherein the model building interface is applicable to multiple operating systems.
16. A control device for a virtual object, characterized in that: The device is built into a simulation control system, the simulation control system includes a model building interface and a code editing interface, and the device includes: a display unit, a determination unit, an acquisition unit and a control unit; The display unit is used to display a plurality of modules in the model building interface, wherein the modules are basic structures required to build the virtual object; The display unit is further used to display a target virtual component corresponding to the target module in the model building interface in response to a selection operation of the target module, wherein the target module is a module among the multiple modules used to build a target virtual object, the target virtual component is a virtual component corresponding to the target module, and the virtual component is a component among the components included in the target virtual object; The determining unit is used to determine the motion parameter configuration corresponding to the target virtual component in the code editing interface; The acquisition unit is used to obtain the target virtual object based on the target virtual component, and obtain the parameter configuration of the target virtual object based on the motion parameter configuration; The control unit is used to control the operation of the target virtual object based on the parameter configuration in response to the operation operation on the target virtual object.
17. A computer device, characterized in that: The computer device comprises a processor and a memory: The memory is used to store a computer program and transmit the computer program to the processor; The processor is configured to execute the method according to any one of claims 1 to 15 according to the computer program.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 15.
19. A computer program product comprising a computer program, characterized in that When the method is executed on a computer device, the computer device is enabled to execute the method according to any one of claims 1 to 15.