CN113554753A - Method and system for dynamically constructing 3D scene - Google Patents

Method and system for dynamically constructing 3D scene Download PDF

Info

Publication number
CN113554753A
CN113554753A CN202110870446.XA CN202110870446A CN113554753A CN 113554753 A CN113554753 A CN 113554753A CN 202110870446 A CN202110870446 A CN 202110870446A CN 113554753 A CN113554753 A CN 113554753A
Authority
CN
China
Prior art keywords
scene
data
processor
type
yes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110870446.XA
Other languages
Chinese (zh)
Other versions
CN113554753B (en
Inventor
刘德建
温荣泉
陈宏展
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian TQ Digital Co Ltd
Original Assignee
Fujian TQ Digital Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian TQ Digital Co Ltd filed Critical Fujian TQ Digital Co Ltd
Priority to CN202110870446.XA priority Critical patent/CN113554753B/en
Publication of CN113554753A publication Critical patent/CN113554753A/en
Application granted granted Critical
Publication of CN113554753B publication Critical patent/CN113554753B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/05Geographic models
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/10Constructive solid geometry [CSG] using solid primitives, e.g. cylinders, cubes

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Geometry (AREA)
  • Software Systems (AREA)
  • Computer Graphics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Remote Sensing (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention provides a method for dynamically constructing a 3D scene, which generates a uniform universal scene data structure based on a Json data format of the scene, and comprises the following steps: the object factory module registers processors in all program sets, wherein the processors comprise scene component processors and scene processors; inputting scene creation data, acquiring a scene by an object factory module, creating a processor instance, judging whether the processor instance is effective or not by the object factory module, and re-creating the processor instance if the processor instance is not effective; if yes, creating a scene component processor or a scene processor; the data conversion module converts the Json data format of the scene creation data into a scene data structure, the scene processor distributes scene component creation data, the scene component processor receives the scene component creation data to create a scene component, when the user interaction data is received, a corresponding processing event is triggered, the scene processor distributes the scene interaction data to update the scene component, and a complete scene interaction system is achieved.

Description

Method and system for dynamically constructing 3D scene
Technical Field
The invention relates to the technical field of 3D scene manufacturing, in particular to a method and a system for dynamically constructing a 3D scene.
Background
The existing 3D scene production method: the use of a terrain-generating editor has great advantages in simulating the effects of natural terrain, but also has limitations. Such limitations exist in the representation of relatively regular terrain, such as a modern city, a town of rudimentary scale, an underground palace, and the like. When the terrain editor is used for establishing the terrain, the number of the surface maps cannot be too large, the running efficiency of the game is lower when the number of the selected surface maps is larger, and the method is suitable for selecting 2-3 maps. The number of maps needed on the ground in a city is very large, more than three lanes, sidewalks, lawns and the like are needed, and the streets in cities and towns are very regular, which cannot be achieved by a terrain generation editor.
The 3D scene generation mode by the editor has high limitation on 3D scene generation, generally only aims at a certain type of scene, does not support scene behavior generation and control, is difficult to expand and cannot be widely used.
Disclosure of Invention
In order to overcome the problems, the invention aims to provide a method for dynamically constructing a 3D scene, which solves the problems that the 3D scene is complex to use and cannot be dynamically constructed.
The invention is realized by adopting the following scheme: a method for dynamically constructing a 3D scene, the method generating a unified general scene data structure based on Json data format of the scene, the method comprising:
the object factory module registers processors in all program sets, wherein the processors comprise scene component processors and scene processors;
inputting scene creation data, acquiring a scene by an object factory module, creating a processor instance, judging whether the processor instance is effective or not by the object factory module, and re-creating the processor instance if the processor instance is not effective; if yes, creating a scene component processor or a scene processor;
the data conversion module converts the Json data format of the scene creation data into a scene data structure, and reads scene component creation data from the scene data structure;
the scene component creating data is distributed through the scene processor, the scene component processor receives the scene component creating data, creates the scene component through the scene component creating data, triggers a corresponding processing event when the user interaction data is received, distributes the scene interaction data through the scene processor, and the scene component processor module updates the scene component through the scene interaction data, so that a complete scene interaction system is realized.
Furthermore, the Json data format or Json file path of the scene is converted into a unified general scene data structure by a data conversion module, and the implementation manner of the data conversion module specifically is as follows: step S41, inputting scene creating data, judging whether the type of the input scene creating data is in a Json data format, if so, entering step S42; if not, continuously judging whether the file path is a Json file path; if not, ending the process; if yes, reading Json data in the Json file, and entering the step S42;
step S42, identifying the Json data as a Json instance type, and creating a new scene data structure;
and step S43, filling basic data in the Json data into corresponding field values of a scene data structure, and filling data without matching fields into an extended field queue of the scene data structure, thereby forming a general scene data structure.
Further, the registering of the object factory module with the processors in all the program sets includes: step S11, acquiring a program set where a processor base is located, and acquiring all program sets in the current application program;
s12, screening all program sets which have reference relation with the program set of the basis;
step S13, adding the program sets into a program set queue, judging whether the program set queue is empty, if yes, finishing registration and exiting the process; otherwise, the process proceeds to step S14;
step S14, reading a assembly from the assembly queue,
step S15, obtaining all classes in the program set, screening the classes inheriting the basic classes of the processor, and adding the classes into a type queue;
step S16, judging whether the type queue is empty; if not, the process proceeds to step S17, where if yes, it is determined whether there is another assembly in the assembly queue; if not, completing registration and exiting the process; yes, go to step S14;
step S17, reading a class type from the type queue, and creating an instance of the class type;
step S18, judging whether the creation is successful, if yes, obtaining the type field on the instance; step S19 is proceeded, if not, it is judged whether there is any other type in the type queue, if yes, step S17 is proceeded, if not, it is judged whether there is any other program set in the program set queue; if not, completing registration and exiting the process; yes, go to step S14;
step S19, judging whether the fields of the type are registered by the processor set, if not, registering the fields of the type in the processor set; proceeding to step S20; if yes, judging whether the type of the registered type is the same as that of the type field, if yes, printing a prompt message of 'repeated registration', and exiting the process; if not, printing a prompt message of 'change of registration type'; overriding the registration in the processor pool with such type;
step S20, judging whether the type is inherited from the static processor base; if not, destroy an instance of such type; proceeding to step S22; it is, that an instance of such a type is initialized,
step S21, judging whether the type field is registered by the static processor set, if yes, covering the type example with the registration in the static processor set; if not, registering the type instance into the static processor set;
step S22, judging whether other types exist in the type queue; if yes, the process proceeds to step S17, and if no, it is determined whether or not another assembly exists in the assembly queue; if not, completing registration and exiting the process; yes, the process proceeds to step S14.
Further, the scene processor distributes scene creation data, specifically: step S31, inputting scene creating data; judging whether the scene creation data contains data needing network request; if yes, the network requests to acquire scene creation data, and the process goes to step S32, otherwise, the process goes directly to step S32;
step S32, judging whether the scene creating data contains Json data needing to be converted, if yes, converting the Json data into a scene data structure by the data conversion module, and entering step S33; otherwise, the process proceeds to step S33;
step S33, recording the scene data structure into the scene processor, reading the scene component creation data from the scene data structure, adding the scene component creation data into a creation data queue,
step S34, judging whether the created data queue is empty, if yes, completing the creation of the scene component; otherwise, the process proceeds to step S35;
step S35, reading a piece of creating data from the creating data queue, obtaining the processor type recorded in the creating data, and obtaining the processor instance of the corresponding type by the object factory module;
step S36, judging whether the processor instance is effective, if yes, recording the corresponding type scene component processor instance into the scene component processor queue of the scene processor; proceeding to step S37; if not; proceeding to step S38;
step S37, the corresponding type of scenic component processor module creates corresponding type of scenic component objects from the creation data
Step S38, judging whether other creation data exist in the creation data queue, if yes, entering step S35; and if not, finishing the creation of the scene component and ending the flow.
Further, the scene component processor receives scene creation data, and creates a scene component by using the scene creation data, specifically: step S51, inputting scene component creation data, and recording the scene component creation data into a scene component processor;
step S52, creating a scene component processor node object in the scene, and adding a sub data set in the creation data of the reading component into a creation data queue;
step S53, judging whether the created data queue is empty, if yes, completing the creation of the scene component object; otherwise, the process proceeds to step S54;
step S54, reading a piece of creation data from the creation data queue;
step S55, obtaining the template type recorded in the created data, and loading the created template required by the created data from the template library;
step S56, judging whether the created template is valid, if not, entering step S58, instantiating the created template to obtain an instance object, and recording the instance object into a scene component instance object set;
step S57, placing the instance object node under the scene component processor node object, and updating the instance object configuration data according to the creation data;
step S58, judging whether other creating data exist in the creating data queue; yes, the flow proceeds to step S54, no, and scene component object creation is completed.
Further, the scene processor distributes scene interaction data, specifically: step S61, inputting scene interaction data; judging whether the interactive data contains data needing network request; if yes, the network requests to acquire interactive data, step S62, otherwise, the process directly goes to step S62;
step S62, judging whether the interactive data contain Json data needing to be converted, if yes, converting the Json data into a scene data structure by a data conversion module, and entering step S63; otherwise, go directly to step S63;
step S63, recording the scene data structure into the scene processor, reading the scene component interaction data from the scene data, adding the interaction data into an interaction data queue,
step S64, judging whether the interactive data queue is empty, if yes, finishing scene creation; otherwise, the process proceeds to step S65;
step S65, reading an interactive data from the interactive data queue, obtaining the processor type recorded in the interactive data, and obtaining the corresponding scene component processor instance from the scene component processor queue of the scene processor;
step S66, judging whether the processor instance is effective, if yes, the corresponding type scene component processor module updates the corresponding type scene component object according to the interactive data; proceeding to step S67; otherwise, the process proceeds to step S67;
step S67, judging whether other interactive data exist in the interactive data queue, if yes, entering step S65; otherwise, completing scene interaction.
Further, the scene component processor module updates the scene component through the scene interaction data, specifically: step S71, inputting scene component interaction data, comparing the data recorded in the scene component processor to obtain a change data queue,
step S72, judging whether the change data queue is empty, if yes, finishing the scene component object updating, ending the process, if no, entering step S73;
step S73, reading a changed data from the changed data queue, and acquiring the node ID recorded in the changed data; acquiring a corresponding instance object from the instance object set according to the node ID;
step S74, judging whether the instance object is effective, if yes, updating the instance object configuration data according to the change data, and entering step S75, if no, entering step S75;
step S75, determine whether there is any other changed data in the changed data queue, if yes, go to step S73, if no, complete the scene component object update, and end the process.
Further, the scene components include, but are not limited to, scene terrain, scene static objects, scene interactable objects, non-player characters, physical environment, scene UI, scene camera, scene lights, scene routing control, and scene post-processing.
Further, the user interaction data includes, but is not limited to, data triggered by controlling character movement, controlling perspective changes, adjusting scene setting parameters, interacting with interactable objects or non-player characters, and exiting scene interactions, which are types of user interactions.
The invention also provides a system for dynamically constructing the 3D scene, which comprises a server, wherein the server is internally provided with an object factory module, a scene processor, a scene component processor and a data conversion module; the object factory module registers processors in all program sets, and the processors comprise scene component processors and scene processors;
inputting scene creation data, acquiring a scene by an object factory module, creating a processor instance, judging whether the processor instance is effective or not by the object factory module, and re-creating the processor instance if the processor instance is not effective; if yes, creating a scene component processor or a scene processor;
the data conversion module converts the Json data format of the scene creation data into a scene data structure, and reads scene component creation data from the scene data structure;
the scene component creating data is distributed through the scene processor, the scene component processor receives the scene component creating data, creates the scene component through the scene component creating data, triggers a corresponding processing event when the user interaction data is received, distributes the scene interaction data through the scene processor, and the scene component processor module updates the scene component through the scene interaction data, so that a complete scene interaction system is realized.
Furthermore, the data conversion module converts the Json data or Json file paths of the scene into a unified general scene data structure, and the implementation manner of the data conversion module specifically is as follows: step S41, inputting scene creating data, judging whether the type of the input scene creating data is in a Json data format, if so, entering step S42; if not, continuously judging whether the file path is a Json file path; if not, ending the process; if yes, reading Json data in the Json file, and entering the step S42;
step S42, identifying the Json data as a Json instance type, and creating a new scene data structure;
and step S43, filling basic data in the Json data into corresponding field values of a scene data structure, and filling data without matching fields into an extended field queue of the scene data structure, thereby forming a general scene data structure.
Further, the registering of the object factory module with the processors in all the program sets includes: step S11, acquiring a program set where a processor base is located, and acquiring all program sets in the current application program;
s12, screening all program sets which have reference relation with the program set of the basis;
step S13, adding the program sets into a program set queue, judging whether the program set queue is empty, if yes, finishing registration and exiting the process; otherwise, the process proceeds to step S14;
step S14, reading a assembly from the assembly queue,
step S15, obtaining all classes in the program set, screening the classes inheriting the basic classes of the processor, and adding the classes into a type queue;
step S16, judging whether the type queue is empty; if not, the process proceeds to step S17, where if yes, it is determined whether there is another assembly in the assembly queue; if not, completing registration and exiting the process; yes, go to step S14;
step S17, reading a class type from the type queue, and creating an instance of the class type;
step S18, judging whether the creation is successful, if yes, obtaining the type field on the instance; step S19 is proceeded, if not, it is judged whether there is any other type in the type queue, if yes, step S17 is proceeded, if not, it is judged whether there is any other program set in the program set queue; if not, completing registration and exiting the process; yes, go to step S14;
step S19, judging whether the fields of the type are registered by the processor set, if not, registering the fields of the type in the processor set; proceeding to step S20; if yes, judging whether the type of the registered type is the same as that of the type field, if yes, printing a prompt message of 'repeated registration', and exiting the process; if not, printing a prompt message of 'change of registration type'; overriding the registration in the processor pool with such type;
step S20, judging whether the type is inherited from the static processor base; if not, destroy an instance of such type; proceeding to step S22; it is, that an instance of such a type is initialized,
step S21, judging whether the type field is registered by the static processor set, if yes, covering the type example with the registration in the static processor set; if not, registering the type instance into the static processor set;
step S22, judging whether other types exist in the type queue; if yes, the process proceeds to step S17, and if no, it is determined whether or not another assembly exists in the assembly queue; if not, completing registration and exiting the process; yes, the process proceeds to step S14.
The invention has the beneficial effects that: the method is applied to the generation and interaction processes of all types of 3D scenes, is different from the conventional 3D scene development, and can quickly generate the 3D scene and execute the interaction behavior of the scene by extracting the scene creation and the description information of the interaction behavior and support the feedback of interaction logic; the problems that the 3D scene is complex to use and cannot be dynamically constructed are solved.
Drawings
FIG. 1 is a schematic flow chart of a method according to an embodiment of the present invention.
Fig. 2 is a schematic diagram of a data conversion module converting Json data into a scene data structure according to an embodiment of the present invention.
FIG. 3 is a flow diagram of an object factory module acquisition processor according to an embodiment of the invention.
FIG. 4 is a flow diagram illustrating the process of registering an object factory module with a handler in an ownership process set, in accordance with an embodiment of the present invention.
Fig. 5 is a schematic diagram of a scene processor module distributing scene component creation data according to an embodiment of the present invention.
FIG. 6 is a flowchart of the scene part processor module creating a scene part object from the creation data according to an embodiment of the invention.
Fig. 7 is a schematic flow chart of the scene processor module distributing scene interaction data according to an embodiment of the present invention.
FIG. 8 is a flowchart of a scene component processor module updating scene component objects based on interaction data, in accordance with an embodiment of the present invention.
Detailed Description
The invention is further described below with reference to the accompanying drawings.
The invention provides a method for dynamically constructing a 3D scene, which generates a uniform universal scene data structure based on a Json data format of the scene, and comprises the following steps:
the object factory module registers processors in all program sets, wherein the processors comprise scene component processors and scene processors;
inputting scene creation data, acquiring a scene by an object factory module, creating a processor instance, judging whether the processor instance is effective or not by the object factory module, and re-creating the processor instance if the processor instance is not effective; if yes, creating a scene component processor or a scene processor;
the data conversion module converts the Json data format of the scene creation data into a scene data structure, and reads scene component creation data from the scene data structure;
the scene component creating data is distributed through the scene processor, the scene component processor receives the scene component creating data, creates the scene component through the scene component creating data, triggers a corresponding processing event when the user interaction data is received, distributes the scene interaction data through the scene processor, and the scene component processor module updates the scene component through the scene interaction data, so that a complete scene interaction system is realized.
The invention is further illustrated below with reference to an example:
referring to fig. 1, in the method for dynamically constructing a 3D scene, a unified general scene data structure is generated based on a scene Json data format, then scene creation data is distributed through a scene processor module, a data conversion module converts the Json data format of the scene creation data into a scene data structure, and scene component creation data is read from the scene data structure; the scenic component processor module creates a scenic component based on the scenic component creation data. And when the user interaction data is received, triggering a processing event, distributing the scene interaction data through the scene processor module, and updating the scene components by the scene component processor module based on the interaction data to realize a complete scene interaction system.
The definition of the scene component in the invention includes, but is not limited to, scene terrain, scene static objects, scene interactive objects, non-player characters, natural environment (weather, cloud, fog, wind, etc.), scene UI, scene camera, scene light, scene routing control, scene post-processing, etc.
The definition of the user interaction data in the invention includes but is not limited to the data triggered by the user interaction types of controlling the movement of the character, controlling the change of the visual angle, adjusting the setting parameters of the scene, interacting with an interactive object or a non-player character, exiting the scene interaction and the like.
In the invention, the definition of the processing event in the "triggering processing event when the user interacts data" is an event obtained after analyzing the user interaction data, for example, the processing event triggered when the quitting scene interaction data is received is a quitting scene event, the character moving data is triggered when the control character moving interaction data is received, and the like.
Wherein the content of the first and second substances,
1) data conversion module
The module provides data conversion capability for the scene processor module, and converts the Json data format or Json file path into a unified scene data structure.
2) Object factory module
The module comprises two functions of an object factory module acquisition processor and processors registered in all program sets, and provides the acquisition capability of the processors for the scene processor module.
The definition of processors in the object factory module includes, but is not limited to, scene processors, all types of scene component processors, and the like.
All program sets are defined as a collection of all executable program code in the current software or game in which any code in all current software or game may be retrieved.
The definition of a processor in all the program sets includes, but is not limited to, the program code of the type of processor that can be retrieved in the current software or game.
3) Scene processor module
The module comprises two functions of distributing scene creating data and scene interaction data, analyzes the scene data into data required by the scene component module, and promotes the scene component module to create and update the scene component data.
4) Scene component processor module
The module comprises two functions of scene component creation and updating, scene component templates are instantiated into scene component instances, scene component data are updated according to creation data or interaction data, and data management of the scene components is achieved.
The scene component processor and the scene processor are both processor-type program code. The scene processor is responsible for the overall logic processing of the scene; the scene component processors are various, each scene component processor corresponds to a defined scene component and is responsible for logic processing of a corresponding scene component type; one scene processor may control a plurality of scene component processors.
Referring to fig. 2, the Json data format or Json file path of the scene is converted into a unified general scene data structure by a data conversion module, and the implementation manner of the data conversion module is specifically: step S41, inputting scene creating data, judging whether the type of the input scene creating data is Json data, if yes, entering step S42; if not, continuously judging whether the file path is a Json file path; if not, ending the process; if yes, reading Json data in the Json file, and entering the step S42;
step S42, identifying the Json data as a Json instance type, and creating a new scene data structure;
and step S43, filling basic data in the Json data into corresponding field values of a scene data structure, and filling data without matching fields into an extended field queue of the scene data structure, thereby forming a general scene data structure.
Step S44, judging whether the data is root node data, if yes, recording the data as root node scene data; if not, adding the data into the subdata of the scene data of the father node;
step S45, judging whether the Json data contain the subdata; if not, returning the created root node scene data; and ending the flow; if yes, a new scene data structure is newly created, and the process proceeds to step S43.
As shown in fig. 3, the registering of the object factory module with the processors in all the program sets of the present invention specifically includes: step S11, acquiring a program set where a processor base is located, and acquiring all program sets in the current application program;
s12, screening all program sets which have reference relation with the program set of the basis;
step S13, adding the program sets into a program set queue, judging whether the program set queue is empty, if yes, finishing registration and exiting the process; otherwise, the process proceeds to step S14;
step S14, reading a assembly from the assembly queue,
step S15, obtaining all classes in the program set, screening the classes inheriting the basic classes of the processor, and adding the classes into a type queue;
step S16, judging whether the type queue is empty; if not, the process proceeds to step S17, where if yes, it is determined whether there is another assembly in the assembly queue; if not, completing registration and exiting the process; yes, go to step S14;
step S17, reading a class type from the type queue, and creating an instance of the class type;
step S18, judging whether the creation is successful, if yes, obtaining the type field on the instance; step S19 is proceeded, if not, it is judged whether there is any other type in the type queue, if yes, step S17 is proceeded, if not, it is judged whether there is any other program set in the program set queue; if not, completing registration and exiting the process; yes, go to step S14;
step S19, judging whether the fields of the type are registered by the processor set, if not, registering the fields of the type in the processor set; proceeding to step S20; if yes, judging whether the type of the registered type is the same as that of the type field, if yes, printing a prompt message of 'repeated registration', and exiting the process; if not, printing a prompt message of 'change of registration type'; overriding the registration in the processor pool with such type;
step S20, judging whether the type is inherited from the static processor base; if not, destroy an instance of such type; proceeding to step S22; it is, that an instance of such a type is initialized,
step S21, judging whether the type field is registered by the static processor set, if yes, covering the type example with the registration in the static processor set; if not, registering the type instance into the static processor set;
step S22, judging whether other types exist in the type queue; if yes, the process proceeds to step S17, and if no, it is determined whether or not another assembly exists in the assembly queue; if not, completing registration and exiting the process; yes, the process proceeds to step S14.
As shown in FIG. 4, the object factory module of the present invention obtains the specific flow of the processor: inputting a processor type; judging whether the processor of the type is included or not, if not, returning to the abnormal condition of the creation failure, stopping and ending the process; if so, judging whether the processor is a static processor, if so, returning the recorded static processor example, stopping and ending the process; if not, creating a processor instance of the type, returning to the created processor, stopping and ending the process.
As shown in fig. 5, the scene processor of the present invention distributes scene creation data, specifically: step S31, inputting scene creating data; judging whether the scene creation data contains data needing network request; if yes, the network requests to acquire scene creation data, and the process goes to step S32, otherwise, the process goes directly to step S32;
step S32, judging whether the scene creating data contains Json data needing to be converted, if yes, converting the Json data into a scene data structure by the data conversion module, and entering step S33; otherwise, the process proceeds to step S33;
step S33, recording the scene data structure into the scene processor, reading the scene component creation data from the scene data structure, adding the scene component creation data into a creation data queue,
step S34, judging whether the created data queue is empty, if yes, completing the creation of the scene component; otherwise, the process proceeds to step S35;
step S35, reading a piece of creating data from the creating data queue, obtaining the processor type recorded in the creating data, and obtaining the processor instance of the corresponding type by the object factory module;
step S36, judging whether the processor instance is effective, if yes, recording the corresponding type scene component processor instance into the scene component processor queue of the scene processor; proceeding to step S37; if not; proceeding to step S38;
step S37, the corresponding type of scenic component processor module creates corresponding type of scenic component objects from the creation data
Step S38, judging whether other creation data exist in the creation data queue, if yes, entering step S35; and if not, finishing the creation of the scene component and ending the flow.
As shown in fig. 6, the scene component processor of the present invention receives scene creation data, and creates a scene component by using the scene creation data, specifically: step S51, inputting scene component creation data, and recording the scene component creation data into a scene component processor;
step S52, creating a scene component processor node object in the scene, and adding a sub data set in the creation data of the reading component into a creation data queue;
step S53, judging whether the created data queue is empty, if yes, completing the creation of the scene component object; otherwise, the process proceeds to step S54;
step S54, reading a piece of creation data from the creation data queue;
step S55, obtaining the template type recorded in the created data, and loading the created template required by the created data from the template library;
step S56, judging whether the created template is valid, if not, entering step S58, instantiating the created template to obtain an instance object, and recording the instance object into a scene component instance object set;
step S57, placing the instance object node under the scene component processor node object, and updating the instance object configuration data according to the creation data;
step S58, judging whether other creating data exist in the creating data queue; yes, the flow proceeds to step S54, no, and scene component object creation is completed.
As shown in fig. 7, the scene processor of the present invention distributes scene interaction data, specifically: step S61, inputting scene interaction data; judging whether the interactive data contains data needing network request; if yes, the network requests to acquire interactive data, step S62, otherwise, the process directly goes to step S62;
step S62, judging whether the interactive data contain Json data needing to be converted, if yes, converting the Json data into a scene data structure by a data conversion module, and entering step S63; otherwise, go directly to step S63;
step S63, recording the scene data structure into the scene processor, reading the scene component interaction data from the scene data, adding the interaction data into an interaction data queue,
step S64, judging whether the interactive data queue is empty, if yes, finishing scene creation; otherwise, the process proceeds to step S65;
step S65, reading an interactive data from the interactive data queue, obtaining the processor type recorded in the interactive data, and obtaining the corresponding scene component processor instance from the scene component processor queue of the scene processor;
step S66, judging whether the processor instance is effective, if yes, the corresponding type scene component processor module updates the corresponding type scene component object according to the interactive data; proceeding to step S67; otherwise, the process proceeds to step S67;
step S67, judging whether other interactive data exist in the interactive data queue, if yes, entering step S65; otherwise, completing scene interaction.
As shown in fig. 8, the scene component processor module of the present invention updates the scene component through the scene interaction data, specifically: step S71, inputting scene component interaction data, comparing the data recorded in the scene component processor to obtain a change data queue,
step S72, judging whether the change data queue is empty, if yes, finishing the scene component object updating, ending the process, if no, entering step S73;
step S73, reading a changed data from the changed data queue, and acquiring the node ID recorded in the changed data; acquiring a corresponding instance object from the instance object set according to the node ID;
step S74, judging whether the instance object is effective, if yes, updating the instance object configuration data according to the change data, and entering step S75, if no, entering step S75;
step S75, determine whether there is any other changed data in the changed data queue, if yes, go to step S73, if no, complete the scene component object update, and end the process.
In addition, the invention also provides a system for dynamically constructing the 3D scene, which comprises a server, wherein an object factory module, a scene processor, a scene component processor and a data conversion module are installed in the server; the object factory module registers processors in all program sets, and the processors comprise scene component processors and scene processors;
inputting scene creation data, acquiring a scene by an object factory module, creating a processor instance, judging whether the processor instance is effective or not by the object factory module, and re-creating the processor instance if the processor instance is not effective; if yes, creating a scene component processor or a scene processor;
the data conversion module converts the Json data format of the scene creation data into a scene data structure, and reads scene component creation data from the scene data structure;
the scene component creating data is distributed through the scene processor, the scene component processor receives the scene component creating data, creates the scene component through the scene component creating data, triggers a corresponding processing event when the user interaction data is received, distributes the scene interaction data through the scene processor, and the scene component processor module updates the scene component through the scene interaction data, so that a complete scene interaction system is realized.
The data conversion module converts Json data or Json file paths of a scene into a unified general scene data structure, and the implementation mode of the data conversion module is specifically as follows: step S41, inputting scene creating data, judging whether the type of the input scene creating data is Json data, if yes, entering step S42; if not, continuously judging whether the file path is a Json file path; if not, ending the process; if yes, reading Json data in the Json file, and entering the step S42;
step S42, identifying the Json data as a Json instance type, and creating a new scene data structure;
and step S43, filling basic data in the Json data into corresponding field values of a scene data structure, and filling data without matching fields into an extended field queue of the scene data structure, thereby forming a general scene data structure.
Step S44, judging whether the data is root node data, if yes, recording the data as root node scene data; if not, adding the data into the subdata of the scene data of the father node;
step S45, judging whether the Json data contain the subdata; if not, returning the created root node scene data; and ending the flow; if yes, a new scene data structure is newly created, and the process proceeds to step S43.
The object factory module registers processors in all program sets, specifically: step S11, acquiring a program set where a processor base is located, and acquiring all program sets in the current application program;
s12, screening all program sets which have reference relation with the program set of the basis;
step S13, adding the program sets into a program set queue, judging whether the program set queue is empty, if yes, finishing registration and exiting the process; otherwise, the process proceeds to step S14;
step S14, reading a assembly from the assembly queue,
step S15, obtaining all classes in the program set, screening the classes inheriting the basic classes of the processor, and adding the classes into a type queue;
step S16, judging whether the type queue is empty; if not, the process proceeds to step S17, where if yes, it is determined whether there is another assembly in the assembly queue; if not, completing registration and exiting the process; yes, go to step S14;
step S17, reading a class type from the type queue, and creating an instance of the class type;
step S18, judging whether the creation is successful, if yes, obtaining the type field on the instance; step S19 is proceeded, if not, it is judged whether there is any other type in the type queue, if yes, step S17 is proceeded, if not, it is judged whether there is any other program set in the program set queue; if not, completing registration and exiting the process; yes, go to step S14;
step S19, judging whether the fields of the type are registered by the processor set, if not, registering the fields of the type in the processor set; proceeding to step S20; if yes, judging whether the type of the registered type is the same as that of the type field, if yes, printing a prompt message of 'repeated registration', and exiting the process; if not, printing a prompt message of 'change of registration type'; overriding the registration in the processor pool with such type;
step S20, judging whether the type is inherited from the static processor base; if not, destroy an instance of such type; proceeding to step S22; it is, that an instance of such a type is initialized,
step S21, judging whether the type field is registered by the static processor set, if yes, covering the type example with the registration in the static processor set; if not, registering the type instance into the static processor set;
step S22, judging whether other types exist in the type queue; if yes, the process proceeds to step S17, and if no, it is determined whether or not another assembly exists in the assembly queue; if not, completing registration and exiting the process; yes, the process proceeds to step S14.
In a word, the method is applied to the generation and interaction processes of all types of 3D scenes, and is different from the conventional 3D scene development, the method is used for rapidly generating the 3D scenes and executing the interaction behaviors of the scenes by extracting the description information of the scene creation and the interaction behaviors thereof, and supports the feedback of interaction logic; the problems that the 3D scene is complex to use and cannot be dynamically constructed are solved.
The above description is only a preferred embodiment of the present invention, and all equivalent changes and modifications made in accordance with the claims of the present invention should be covered by the present invention.

Claims (12)

1. A method for dynamically constructing a 3D scene is characterized in that: the method is used for generating a unified general scene data structure based on a Json data format of a scene, and comprises the following steps:
the object factory module registers processors in all program sets, wherein the processors comprise scene component processors and scene processors;
inputting scene creation data, acquiring a scene by an object factory module, creating a processor instance, judging whether the processor instance is effective or not by the object factory module, and re-creating the processor instance if the processor instance is not effective; if yes, creating a scene component processor or a scene processor;
the data conversion module converts the Json data format of the scene creation data into a scene data structure, and reads scene component creation data from the scene data structure;
the scene component creating data is distributed through the scene processor, the scene component processor receives the scene component creating data, creates the scene component through the scene component creating data, triggers a corresponding processing event when the user interaction data is received, distributes the scene interaction data through the scene processor, and the scene component processor module updates the scene component through the scene interaction data, so that a complete scene interaction system is realized.
2. The method for dynamically constructing 3D scene according to claim 1, wherein: the Json data format or Json file path of the scene is converted into a unified general scene data structure through a data conversion module, and the data conversion module is specifically implemented in the following mode: step S41, inputting scene creating data, judging whether the type of the input scene creating data is in a Json data format, if so, entering step S42; if not, continuously judging whether the file path is a Json file path; if not, ending the process; if yes, reading Json data in the Json file, and entering the step S42;
step S42, identifying the Json data as a Json instance type, and creating a new scene data structure;
and step S43, filling basic data in the Json data into corresponding field values of a scene data structure, and filling data without matching fields into an extended field queue of the scene data structure, thereby forming a general scene data structure.
3. The method for dynamically constructing 3D scene according to claim 1, wherein: the object factory module registers processors in all program sets, specifically: step S11, acquiring a program set where a processor base is located, and acquiring all program sets in the current application program;
s12, screening all program sets which have reference relation with the program set of the basis;
step S13, adding the program sets into a program set queue, judging whether the program set queue is empty, if yes, finishing registration and exiting the process; otherwise, the process proceeds to step S14;
step S14, reading a assembly from the assembly queue,
step S15, obtaining all classes in the program set, screening the classes inheriting the basic classes of the processor, and adding the classes into a type queue;
step S16, judging whether the type queue is empty; if not, the process proceeds to step S17, where if yes, it is determined whether there is another assembly in the assembly queue; if not, completing registration and exiting the process; yes, go to step S14;
step S17, reading a class type from the type queue, and creating an instance of the class type;
step S18, judging whether the creation is successful, if yes, obtaining the type field on the instance; step S19 is proceeded, if not, it is judged whether there is any other type in the type queue, if yes, step S17 is proceeded, if not, it is judged whether there is any other program set in the program set queue; if not, completing registration and exiting the process; yes, go to step S14;
step S19, judging whether the fields of the type are registered by the processor set, if not, registering the fields of the type in the processor set; proceeding to step S20; if yes, judging whether the type of the registered type is the same as that of the type field, if yes, printing a prompt message of 'repeated registration', and exiting the process; if not, printing a prompt message of 'change of registration type'; overriding the registration in the processor pool with such type;
step S20, judging whether the type is inherited from the static processor base; if not, destroy an instance of such type; proceeding to step S22; it is, that an instance of such a type is initialized,
step S21, judging whether the type field is registered by the static processor set, if yes, covering the type example with the registration in the static processor set; if not, registering the type instance into the static processor set;
step S22, judging whether other types exist in the type queue; if yes, the process proceeds to step S17, and if no, it is determined whether or not another assembly exists in the assembly queue; if not, completing registration and exiting the process; yes, the process proceeds to step S14.
4. The method for dynamically constructing 3D scene according to claim 1, wherein: the scene processor distributes scene creation data, specifically: step S31, inputting scene creating data; judging whether the scene creation data contains data needing network request; if yes, the network requests to acquire scene creation data, and the process goes to step S32, otherwise, the process goes directly to step S32;
step S32, judging whether the scene creating data contains Json data needing to be converted, if yes, converting the Json data into a scene data structure by the data conversion module, and entering step S33; otherwise, the process proceeds to step S33;
step S33, recording the scene data structure into the scene processor, reading the scene component creation data from the scene data structure, adding the scene component creation data into a creation data queue,
step S34, judging whether the created data queue is empty, if yes, completing the creation of the scene component; otherwise, the process proceeds to step S35;
step S35, reading a piece of creating data from the creating data queue, obtaining the processor type recorded in the creating data, and obtaining the processor instance of the corresponding type by the object factory module;
step S36, judging whether the processor instance is effective, if yes, recording the corresponding type scene component processor instance into the scene component processor queue of the scene processor; proceeding to step S37; if not; proceeding to step S38;
step S37, the corresponding type of scenic component processor module creates corresponding type of scenic component objects from the creation data
Step S38, judging whether other creation data exist in the creation data queue, if yes, entering step S35; and if not, finishing the creation of the scene component and ending the flow.
5. The method for dynamically constructing 3D scene according to claim 1, wherein: the scene component processor receives scene creation data and creates a scene component through the scene creation data, specifically: step S51, inputting scene component creation data, and recording the scene component creation data into a scene component processor;
step S52, creating a scene component processor node object in the scene, and adding a sub data set in the creation data of the reading component into a creation data queue;
step S53, judging whether the created data queue is empty, if yes, completing the creation of the scene component object; otherwise, the process proceeds to step S54;
step S54, reading a piece of creation data from the creation data queue;
step S55, obtaining the template type recorded in the created data, and loading the created template required by the created data from the template library;
step S56, judging whether the created template is valid, if not, entering step S58, instantiating the created template to obtain an instance object, and recording the instance object into a scene component instance object set;
step S57, placing the instance object node under the scene component processor node object, and updating the instance object configuration data according to the creation data;
step S58, judging whether other creating data exist in the creating data queue; yes, the flow proceeds to step S54, no, and scene component object creation is completed.
6. The method for dynamically constructing 3D scene according to claim 1, wherein: the scene processor distributes scene interaction data, specifically: step S61, inputting scene interaction data; judging whether the interactive data contains data needing network request; if yes, the network requests to acquire interactive data, step S62, otherwise, the process directly goes to step S62;
step S62, judging whether the interactive data contain Json data needing to be converted, if yes, converting the Json data into a scene data structure by a data conversion module, and entering step S63; otherwise, go directly to step S63;
step S63, recording the scene data structure into the scene processor, reading the scene component interaction data from the scene data, adding the interaction data into an interaction data queue,
step S64, judging whether the interactive data queue is empty, if yes, finishing scene creation; otherwise, the process proceeds to step S65;
step S65, reading an interactive data from the interactive data queue, obtaining the processor type recorded in the interactive data, and obtaining the corresponding scene component processor instance from the scene component processor queue of the scene processor;
step S66, judging whether the processor instance is effective, if yes, the corresponding type scene component processor module updates the corresponding type scene component object according to the interactive data; proceeding to step S67; otherwise, the process proceeds to step S67;
step S67, judging whether other interactive data exist in the interactive data queue, if yes, entering step S65; otherwise, completing scene interaction.
7. The method for dynamically constructing 3D scene according to claim 1, wherein: the scene component processor module updates scene components through scene interaction data, and specifically comprises: step S71, inputting scene component interaction data, comparing the data recorded in the scene component processor to obtain a change data queue,
step S72, judging whether the change data queue is empty, if yes, finishing the scene component object updating, ending the process, if no, entering step S73;
step S73, reading a changed data from the changed data queue, and acquiring the node ID recorded in the changed data; acquiring a corresponding instance object from the instance object set according to the node ID;
step S74, judging whether the instance object is effective, if yes, updating the instance object configuration data according to the change data, and entering step S75, if no, entering step S75;
step S75, determine whether there is any other changed data in the changed data queue, if yes, go to step S73, if no, complete the scene component object update, and end the process.
8. The method for dynamically constructing 3D scene according to claim 1, wherein: the scene components include, but are not limited to, scene terrain, scene static objects, scene interactable objects, non-player characters, natural environment, scene UI, scene camera, scene lights, scene routing control, and scene post-processing.
9. The method for dynamically constructing 3D scene according to claim 1, wherein: the user interaction data includes, but is not limited to, data triggered by the types of user interactions, controlling character movement, controlling perspective changes, adjusting scene setting parameters, interacting with interactable objects or non-player characters, and exiting a scene interaction.
10. A system for dynamic construction of 3D scenes, characterized by: the system comprises a server, wherein the object factory module, the scene processor, the scene component processor and the data conversion module are installed in the server, and the object factory module, the scene processor, the scene component processor and the data conversion module are installed in the server; the object factory module registers processors in all program sets, and the processors comprise scene component processors and scene processors;
inputting scene creation data, acquiring a scene by an object factory module, creating a processor instance, judging whether the processor instance is effective or not by the object factory module, and re-creating the processor instance if the processor instance is not effective; if yes, creating a scene component processor or a scene processor;
the data conversion module converts the Json data format of the scene creation data into a scene data structure, and reads scene component creation data from the scene data structure;
the scene component creating data is distributed through the scene processor, the scene component processor receives the scene component creating data, creates the scene component through the scene component creating data, triggers a corresponding processing event when the user interaction data is received, distributes the scene interaction data through the scene processor, and the scene component processor module updates the scene component through the scene interaction data, so that a complete scene interaction system is realized.
11. The system for dynamically constructing 3D scene according to claim 10, wherein: the data conversion module converts Json data or Json file paths of a scene into a unified general scene data structure, and the implementation mode of the data conversion module specifically comprises the following steps: step S41, inputting scene creating data, judging whether the type of the input scene creating data is in a Json data format, if so, entering step S42; if not, continuously judging whether the file path is a Json file path; if not, ending the process; if yes, reading Json data in the Json file, and entering the step S42;
step S42, identifying the Json data as a Json instance type, and creating a new scene data structure;
and step S43, filling basic data in the Json data into corresponding field values of a scene data structure, and filling data without matching fields into an extended field queue of the scene data structure, thereby forming a general scene data structure.
12. The system for dynamically constructing 3D scene according to claim 10, wherein: the object factory module registers processors in all program sets, specifically: step S11, acquiring a program set where a processor base is located, and acquiring all program sets in the current application program;
s12, screening all program sets which have reference relation with the program set of the basis;
step S13, adding the program sets into a program set queue, judging whether the program set queue is empty, if yes, finishing registration and exiting the process; otherwise, the process proceeds to step S14;
step S14, reading a assembly from the assembly queue,
step S15, obtaining all classes in the program set, screening the classes inheriting the basic classes of the processor, and adding the classes into a type queue;
step S16, judging whether the type queue is empty; if not, the process proceeds to step S17, where if yes, it is determined whether there is another assembly in the assembly queue; if not, completing registration and exiting the process; yes, go to step S14;
step S17, reading a class type from the type queue, and creating an instance of the class type;
step S18, judging whether the creation is successful, if yes, obtaining the type field on the instance; step S19 is proceeded, if not, it is judged whether there is any other type in the type queue, if yes, step S17 is proceeded, if not, it is judged whether there is any other program set in the program set queue; if not, completing registration and exiting the process; yes, go to step S14;
step S19, judging whether the fields of the type are registered by the processor set, if not, registering the fields of the type in the processor set; proceeding to step S20; if yes, judging whether the type of the registered type is the same as that of the type field, if yes, printing a prompt message of 'repeated registration', and exiting the process; if not, printing a prompt message of 'change of registration type';
overriding the registration in the processor pool with such type;
step S20, judging whether the type is inherited from the static processor base; if not, destroy an instance of such type;
proceeding to step S22; it is, that an instance of such a type is initialized,
step S21, judging whether the type field is registered by the static processor set, if yes, covering the type example with the registration in the static processor set; if not, registering the type instance into the static processor set;
step S22, judging whether other types exist in the type queue; if yes, the process proceeds to step S17, and if no, it is determined whether or not another assembly exists in the assembly queue; if not, completing registration and exiting the process; yes, the process proceeds to step S14.
CN202110870446.XA 2021-07-30 2021-07-30 Method and system for dynamically constructing 3D scene Active CN113554753B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110870446.XA CN113554753B (en) 2021-07-30 2021-07-30 Method and system for dynamically constructing 3D scene

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110870446.XA CN113554753B (en) 2021-07-30 2021-07-30 Method and system for dynamically constructing 3D scene

Publications (2)

Publication Number Publication Date
CN113554753A true CN113554753A (en) 2021-10-26
CN113554753B CN113554753B (en) 2023-11-10

Family

ID=78104993

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110870446.XA Active CN113554753B (en) 2021-07-30 2021-07-30 Method and system for dynamically constructing 3D scene

Country Status (1)

Country Link
CN (1) CN113554753B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108132788A (en) * 2017-12-22 2018-06-08 广州泼墨神网络科技有限公司 A kind of development device of real time multi-human interaction systems, method and system
CN109725788A (en) * 2018-12-19 2019-05-07 网易(杭州)网络有限公司 Processing method, device, processor and the terminal of user interface interaction
US20190289276A1 (en) * 2016-08-18 2019-09-19 Relay Cars LLC Cubic or Spherical Mapped Content for Presentation of Pre-Rendered Images Viewed from a Fixed Point of View in HTML, Javascript and/or XML for Virtual Reality Applications
US10732797B1 (en) * 2017-01-10 2020-08-04 Lucasfilm Entertainment Company Ltd. Virtual interfaces for manipulating objects in an immersive environment
CN112905272A (en) * 2021-03-23 2021-06-04 武汉众邦银行股份有限公司 Account-opening checking method suitable for multi-scene prototype combination

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190289276A1 (en) * 2016-08-18 2019-09-19 Relay Cars LLC Cubic or Spherical Mapped Content for Presentation of Pre-Rendered Images Viewed from a Fixed Point of View in HTML, Javascript and/or XML for Virtual Reality Applications
US10732797B1 (en) * 2017-01-10 2020-08-04 Lucasfilm Entertainment Company Ltd. Virtual interfaces for manipulating objects in an immersive environment
CN108132788A (en) * 2017-12-22 2018-06-08 广州泼墨神网络科技有限公司 A kind of development device of real time multi-human interaction systems, method and system
CN109725788A (en) * 2018-12-19 2019-05-07 网易(杭州)网络有限公司 Processing method, device, processor and the terminal of user interface interaction
CN112905272A (en) * 2021-03-23 2021-06-04 武汉众邦银行股份有限公司 Account-opening checking method suitable for multi-scene prototype combination

Also Published As

Publication number Publication date
CN113554753B (en) 2023-11-10

Similar Documents

Publication Publication Date Title
US8527943B1 (en) System and method of application development
Emilien et al. Procedural generation of villages on arbitrary terrains
US8839192B2 (en) System and method for presentation of cross organizational applications
JP2004259286A (en) Optimization of display and navigation in multidirection of hierarchical data, and display area consumption
CN101751383A (en) Method for describing network topology by using SVG
CN114064024A (en) Method, apparatus, device, storage medium, and program product for developing micro-application
CN102215209A (en) Online game engine for large-scale multiplayer online role playing
CN113069769B (en) Cloud game interface display method and device, electronic equipment and storage medium
JP2021009665A (en) Method, apparatus, and device for generating file, and storage medium
CN109513212B (en) 2D mobile game UI (user interface) and scenario editing method and system
CN110928710B (en) Information prompting method and device, electronic equipment and storage medium
CN112717414A (en) Game scene editing method and device, electronic equipment and storage medium
CN116681835A (en) Virtual engine-based three-dimensional model manufacturing method and system
Boaventura et al. Mendiga: A minimal engine for digital games
CN113554753A (en) Method and system for dynamically constructing 3D scene
Jing Design and implementation of 3D virtual digital campus-based on unity3d
CN112973130A (en) Playback model construction method, device, equipment and storage medium of virtual scene
KR20090000199A (en) Web server application framework, web application processing method using the framework and computer readable medium processing the method
Thorn Moving from Unity to Godot
CN113760250B (en) Method and system for realizing automatic construction of role interaction logic
Shahbazian et al. An end-to-end domain specific modeling and analysis platform
Ra et al. Software architecture for efficiently designing cloud applications using node. js
Flintham Painting the town red: configuring location-based games by colouring maps
Belfore et al. VRML for urban visualization
Narsoo et al. The Application of Design Patterns to Develop Games for Mobile Devices using Java 2 Micro Edition.

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant