Array scene construction method, system, device and medium based on three-dimensional engine
Through the array scene construction method of the 3D engine, the rotation quaternion and scaling matrix are used to dynamically build model instances, which solves the problems of low scene construction efficiency and insufficient performance in the existing technology, and achieves fast and efficient scene construction and performance optimization. .
Patent Information
- Application Number
- CN202410464915.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-18
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-04-18
AI Technical Summary
The existing technology requires building basic scenes in advance when building complex scenes, causing users to spend a lot of time and energy, reducing computing processing efficiency, and the software performance burden is too heavy when building large batches of models, and cannot meet the requirements for performance improvement.
The array scene construction method based on the three-dimensional engine is adopted, and the model instance is dynamically constructed through the combination of rotation quaternion, scaling matrix and position transformation matrix to form an array scene, which avoids the steps of building a basic scene in advance and improves the construction efficiency.
Without the need to build basic scenes, it reduces the time and effort to build complex scenes, improves scene construction efficiency, and optimizes software performance, making it suitable for rapid construction of large batches of models.
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of 3D modeling of computer graphics, and in particular to an array scene construction method, system, device and medium based on a three-dimensional engine. Background Art
[0002] The model display on the browser side requires scene production based on the Blender 3D engine. Currently, the model is often built in proportion in the software and then exported. However, when a large number of models need to be built, each model is an independent object, which greatly increases the performance burden of the software and cannot meet the requirements for improving performance.
[0003] The invention patent with application number CN202310158716.3 discloses a method, device and equipment for quickly and conveniently building a three-dimensional scene based on a three-dimensional engine. The method is to perform ray picking with a mesh model in the scene, create a model instance according to the world coordinate position of the picking point, and render and display it in real time, so that the world can be freely constructed; although the method disclosed in the patent can solve the above two problems of reducing the software performance burden and improving software performance. However, the method disclosed in the patent requires the user to build a basic scene in advance, and prepare the mesh model of the world coordinate position of the model to be placed in advance before the brush picking and construction of the model can be performed; this method has a high degree of freedom, and it takes more time and effort to build a rich scene, which will reduce the computing efficiency. Summary of the invention
[0004] The purpose of the present invention is to provide an array scene construction method, system, device and medium based on a three-dimensional engine, which does not require the construction of basic scenes in advance, can reduce time and effort, and improve the efficiency of rich scene construction.
[0005] The technical solution of the present invention is as follows:
[0006] A method for constructing an array scene based on a three-dimensional engine, comprising the following operations:
[0007] S1. Based on the rotation angle of the three-dimensional model to be processed on the spatial axis, the model rotation quaternion is obtained; the model rotation quaternion and the corresponding scaling ratio and translation distance are constructed by the rotation matrix, and then multiplied with the rotation center matrix to obtain the rotation transformation matrix; the scaling of the three-dimensional model to be processed is respectively multiplied with the corresponding scaling ratio on the spatial axis, and then constructed by the matrix to obtain the scaling matrix; the scaling matrix is multiplied with the rotation transformation matrix and the scaling center matrix to obtain the scaling transformation matrix; the base point position of the three-dimensional model to be processed in the scene is multiplied with the scaling transformation matrix to obtain the position transformation matrix;
[0008] S2, obtaining the initial world matrix of the three-dimensional model to be processed, and using the initial world matrix as the coordinate system matrix of the first array; multiplying the coordinate system matrix of the previous array with the position transformation matrix and the inverse of the initial world matrix to obtain the coordinate system matrix of the current array and the coordinate system matrix of all arrays, thereby forming an array coordinate system matrix set;
[0009] S3. Based on the array coordinate system matrix set, the three-dimensional model to be processed is updated to obtain a plurality of array construction models for forming an array scene.
[0010] The model rotation quaternion is composed of the horizontal axis rotation element, the vertical axis rotation element, the vertical axis rotation element and the rotation angle element; the horizontal axis rotation element, the vertical axis rotation element, the vertical axis rotation element and the rotation angle element are all obtained based on the horizontal axis rotation angle, the vertical axis rotation angle and the vertical axis rotation angle.
[0011] The methods for obtaining the number of horizontal axis rotation elements, the number of vertical axis rotation elements, the number of vertical axis rotation elements, and the number of rotation angle elements are respectively implemented by the following formulas: Y x =cos(r y / 2)·sin(r x / 2)·cos(r z / 2)+sin(r y / 2)·cos(r x / 2)·sin(r z / 2),Y y =sin(r y / 2)·cos(r x / 2)·cos(r z / 2)-cos(r y / 2)·sin(r x / 2)·sin(r z / 2) , Y z =cos(r y / 2)·cos(r x / 2)·sin(r z / 2)-sin(r y / 2)·sin(r x / 2)·cos(r z / 2) , Y w =cos(r y / 2)·cos(r x / 2)·cos(r z / 2)+sin(r y / 2)·sin(r x / 2)·sin(r z / 2) , Y x is the number of horizontal axis rotations, Y y is the number of rotations along the vertical axis, Y z is the number of rotations along the vertical axis, Y w is the rotation angle element, r x The rotation angle corresponding to the horizontal axis rotation angle , r y is the rotation radian corresponding to the vertical axis rotation angle, r z The rotation angle of the vertical axis corresponds to the rotation radian.
[0012] If the three-dimensional model to be processed is composed of multiple modules with a hierarchical relationship, the tree data in the form of parent-child cascade of each module is obtained respectively, and after segmentation processing, multiple tree data with the parent node as the head node are obtained to form a parent node tree data set; the flattened position data of all descendant nodes of each parent node in the parent node tree data set are obtained to obtain the flattened data of the descendants of each parent node; the flattened data of the descendants of each parent node are used as a three-dimensional model to be processed to execute the array scene construction method based on the three-dimensional engine.
[0013] An array scene construction system based on a three-dimensional engine, comprising:
[0014] The position transformation matrix generation module is used to obtain the model rotation quaternion based on the rotation angle of the three-dimensional model to be processed on the spatial axis; the model rotation quaternion and the corresponding scaling ratio and translation distance are constructed by the rotation matrix and then multiplied with the rotation center matrix to obtain the rotation transformation matrix; the scaling of the three-dimensional model to be processed is respectively multiplied with the corresponding scaling ratio on the spatial axis and then constructed by the matrix to obtain the scaling matrix; the scaling matrix is multiplied with the rotation transformation matrix and the scaling center matrix to obtain the scaling transformation matrix; the base point position of the three-dimensional model to be processed in the scene is multiplied with the scaling transformation matrix to obtain the position transformation matrix;
[0015] The array coordinate system matrix set generation module is used to obtain the initial world matrix of the three-dimensional model to be processed, and use the initial world matrix as the coordinate system matrix of the first array; the coordinate system matrix of the previous array is multiplied by the position transformation matrix and the inverse of the initial world matrix to obtain the coordinate system matrix of the current array; the coordinate system matrices of all arrays form an array coordinate system matrix set;
[0016] A plurality of array-type construction model generation modules are used to update the three-dimensional model to be processed based on the array coordinate system matrix set to obtain a plurality of array-type construction models for forming an array-type scene.
[0017] A three-dimensional engine-based array scene construction device comprises a processor and a memory, wherein the processor implements the above-mentioned three-dimensional engine-based array scene construction method when executing a computer program stored in the memory.
[0018] A computer-readable storage medium is used to store a computer program, wherein the computer program implements the above-mentioned array scene construction method based on a three-dimensional engine when executed by a processor.
[0019] The beneficial effects of the present invention are:
[0020] The present invention provides an array scene construction method based on a three-dimensional engine. First, based on the rotation information of the three-dimensional model to be processed, a position transformation matrix of the three-dimensional model to be processed is defined to achieve rapid changes in the position and size of the model while ensuring that the position and size transformation of the model are correct; then, the initial world matrix of the three-dimensional model to be processed is used as the coordinate system matrix of the first array to retain the initial information of the three-dimensional model to be processed; and based on the display number of the model, the coordinate system matrix of the previous array is multiplied by the position transformation matrix and the initial world matrix to obtain the current coordinate array matrix; the coordinate system matrices of all arrays form an array coordinate system matrix set corresponding to a plurality of instances; finally, based on the array coordinate system matrix set, the matrix data and instance length of the three-dimensional model to be processed are updated to obtain a plurality of array construction models; without the need to build a basic scene, the time and energy for building a rich scene are reduced, and the efficiency of building a scene is improved. DETAILED DESCRIPTION
[0021] This embodiment provides an array scene construction method based on a three-dimensional engine, including the following operations:
[0022] S1. Based on the rotation angle of the three-dimensional model to be processed on the spatial axis, the model rotation quaternion is obtained; the model rotation quaternion and the corresponding scaling ratio and translation distance are constructed by the rotation matrix, and then multiplied with the rotation center matrix to obtain the rotation transformation matrix; the scaling of the three-dimensional model to be processed is respectively multiplied with the corresponding scaling ratio on the spatial axis, and then constructed by the matrix to obtain the scaling matrix; the scaling matrix is multiplied with the rotation transformation matrix and the scaling center matrix to obtain the scaling transformation matrix; the base point position of the three-dimensional model to be processed in the scene is multiplied with the scaling transformation matrix to obtain the position transformation matrix;
[0023] S2, obtaining the initial world matrix of the three-dimensional model to be processed, and using the initial world matrix as the coordinate system matrix of the first array; multiplying the coordinate system matrix of the previous array with the position transformation matrix and the inverse of the initial world matrix to obtain the coordinate system matrix of the current array and the coordinate system matrix of all arrays, thereby forming an array coordinate system matrix set;
[0024] S3. Based on the array coordinate system matrix set, the three-dimensional model to be processed is updated to obtain a plurality of array construction models for forming an array scene.
[0025] S1. Based on the rotation angle of the three-dimensional model to be processed on the spatial axis, the model rotation quaternion is obtained; the model rotation quaternion and the corresponding scaling ratio and translation distance are constructed through a rotation matrix, and then multiplied with the rotation center matrix to obtain a rotation transformation matrix; the scaling of the three-dimensional model to be processed is multiplied with the corresponding scaling ratio on the spatial axis, and then constructed through a matrix to obtain a scaling matrix; the scaling matrix is multiplied with the rotation transformation matrix and the scaling center matrix to obtain a scaling transformation matrix; the base point position of the three-dimensional model to be processed in the scene is multiplied with the scaling transformation matrix to obtain a position transformation matrix.
[0026] Based on the rotation angle and other information of the 3D model to be processed, the position transformation matrix of the 3D model to be processed is defined to achieve rapid transformation of the model's position and size while ensuring the correct transformation of the model's position and size, thereby improving the efficiency of subsequent array-based scene construction.
[0027] First, determine the base point position of the 3D model to be processed (the rotation paste position of the 3D model to be processed when pasted into the software scene, which is the position data of the preset array-type construction data), rotation angle, rotation center, scaling, and scaling center, which are used to complete the position and volume transformation of the 3D model to be processed. For example, you can set the placement to {x:1, y:1, z:1}, the rotation angle to {x:30, y:30, z:30}, the rotation center to {x:0, y:0, z:0}, the scaling to {x:1, y:1, z:1}, and the scaling center to {x:0, y:0, z:0}.
[0028] Then, based on the rotation angle of the three-dimensional model to be processed on the spatial axis, the model rotation quaternion is obtained.
[0029] Among them, the model rotation quaternion is composed of the horizontal axis rotation element (the component of rotation around the horizontal axis), the vertical axis rotation element (the component of rotation around the vertical axis), the vertical axis rotation element (the component of rotation around the vertical axis) and the rotation angle element (the angle of rotation); the horizontal axis rotation element, the vertical axis rotation element, the vertical axis rotation element and the rotation angle element are all obtained based on the horizontal axis rotation angle, the vertical axis rotation angle and the vertical axis rotation angle.
[0030] The methods for obtaining the horizontal axis rotation element number, the vertical axis rotation element number, the vertical axis rotation element number and the rotation angle element number can be implemented by the following formulas respectively:
[0031] Y x =cos(r y / 2)·sin(r x / 2)·cos(r z / 2)+sin(r y / 2)·cos(r x / 2)·sin(r z / 2) ,
[0032] Y y =sin(r y / 2)·cos(r x / 2)·cos(r z / 2)-cos(r y / 2)·sin(r x / 2)·sin(r z / 2) ,
[0033] Y z =cos(r y / 2)·cos(r x / 2)·sin(r z / 2)-sin(r y / 2)·sin(r x / 2)·cos(r z / 2) ,
[0034] Y w =cos(ry / 2)·cos(r x / 2)·cos(r z / 2)+sin(r y / 2)·sin(r x / 2)·sin(r z / 2) ,
[0035] Y x is the number of horizontal axis rotations, Y y is the number of rotations along the vertical axis, Y z is the number of rotations along the vertical axis, Y w is the rotation angle element, r x The rotation angle corresponding to the horizontal axis rotation angle , r y is the rotation radian corresponding to the vertical axis rotation angle, r z The rotation angle is the rotation radian corresponding to the vertical axis rotation angle. The rotation angle is divided by 180︒ and then multiplied by π to get the rotation radian.
[0036] For example, the horizontal axis rotation angle, the vertical axis rotation angle and the vertical axis rotation angle are all 30︒, that is, the above rotation angle is {x:30,y:30,z:30}, then the corresponding rotation radian is {x:0.5235987755982988,y:0.52359878,z:0.52359878}.
[0037] Horizontal axis rotation Y x The solution process is: 0.9659258262890683 cos(r y / 2) and 0.25881904510252074 sin(r x / 2) and cos(r z / 2), the product A1 is 0.24148145657226705; 0.25881904510252074 sin(r y / 2) and cos(r) of 0.9659258262890683 x / 2) and 0.25881904510252074 sin(r z / 2) to obtain the product A2, which is 0.06470476127563017. The product A1 plus the product A2 is used to calculate the number of rotations along the vertical axis. Yx It is 0.30618621784789724.
[0038] Vertical axis rotation element Y y The solution process is: 0.25881904510252074 sin(r y / 2) and cos(r) of 0.9659258262890683 x / 2) and cos(r z / 2), the product B1 is 0.24148145657226705; cos(r y / 2) and 0.25881904510252074 sin(r x / 2) and 0.25881904510252074 sin(r z / 2) to obtain the product B2, which is 0.06470476127563017. The product B1 minus the product B2 is used to calculate the vertical axis rotation element Y. y It is 0.17677669529663687.
[0039] Vertical axis rotation element Y z The solution process is: 0.9659258262890683 cos(r y / 2) and cos(r) of 0.9659258262890683 x / 2) and 0.25881904510252074 sin(r z / 2), the product C1 is 0.24148145657226708; 0.25881904510252074 sin(r y / 2) and 0.25881904510252074 sin(r x / 2) and cos(r z / 2) to obtain the product C2, which is 0.06470476127563017. The vertical axis rotation element Y is obtained by subtracting the product C2 from the product C1. z It is 0.17677669529663692.
[0040] Vertical axis rotation element Y w The solution process is: 0.9659258262890683 cos(r y / 2) and cos(r) of 0.9659258262890683 x / 2) and cos(r z / 2), the product D1 is 0.9012210650134382; 0.25881904510252074 sin(r y / 2) and 0.25881904510252074 sin(r x / 2) and 0.25881904510252074 sin(r z / 2) to obtain the product D2, which is 0.017337588530253686. The product D1 plus the product D2 is used to calculate the vertical axis rotation element Y. w It is 0.9185586535436919.
[0041] Next, the model rotation quaternion and the corresponding scaling ratio and translation distance are constructed through the rotation matrix and multiplied with the rotation center matrix to obtain the rotation transformation matrix.
[0042] Among them, the process of obtaining the rotation matrix based on the model rotation quaternion (horizontal axis rotation element, vertical axis rotation element, longitudinal axis rotation element, rotation angle element) and the corresponding scaling ratio and translation distance is the prior art. In order to save space, it will not be described in detail here. The array data of the rotation matrix obtained based on the above data is [0.875, 0.4330126941204071, -0.21650634706020355, 0, -0.21650634706020355, 0.75, 0.625, 0, 0.4330126941204071, -0.5, 0.75, 0, 0, 0, 0, 1]. In addition, the rotation center matrix is a unit matrix constructed based on the above rotation center {x:0,y:0,z:0}, and the array data of the rotation center matrix is [1,0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]. The array data of the rotation transformation matrix obtained by multiplying the rotation matrix and the rotation center matrix is [0.875, 0.4330126941204071, -0.21650634706020355,0, -0.21650634706020355, 0.75, 0.625, 0, 0.4330126941204071, -0.5, 0.75, 0,0, 0, 0, 1].
[0043] Subsequently, the scaling of the 3D model to be processed is multiplied by the corresponding scaling ratios on the spatial axis, and then a scaling matrix is obtained through matrix construction. Specifically, the scaling of the 3D model to be processed is multiplied by the scaling ratios of the x-axis, y-axis, and z-axis to construct a matrix to obtain the scaling matrix. For example, after the scaling {x:1, y:1, z:1} is multiplied by the corresponding scaling ratios of the rotation axes x, y, and z (all 1), the scaling matrix array data is obtained, and the scaling matrix array data is [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1].
[0044] Next, the scaling matrix is multiplied by the rotation transformation matrix and the scaling center matrix to obtain the scaling transformation matrix. For example, the scaling matrix (whose array data is [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1]) and the rotation matrix (whose array data is [0.875, 0.4330126941204071, -0.21650634706020355, 0, -0.21650634706020355, 0.75, 0.625, 0, 0.4330126941204071, -0.5, 0.75, 0, 0, 0, 1]) and the rotation center matrix (whose array data is [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,0, 1]) to get the scaling transformation matrix (the array data is [0.875, 0.4330126941204071, -0.21650634706020355, 0, -0.21650634706020355, 0.75, 0.625, 0,0.4330126941204071, -0.5, 0.75, 0, 0, 0, 0, 1]).
[0045] Finally, the base point position of the 3D model to be processed in the scene is multiplied by the scaling transformation matrix to obtain the position transformation matrix. Specifically, the position matrix corresponding to the base point position of the 3D model to be processed in the scene (whose array data is [1,0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1]) is multiplied by the scaling transformation matrix (whose array data is [0.875, 0.4330126941204071, -0.21650634706020355, 0, -0.21650634706020355,0.75, 0.625, 0, 0.4330126941204071, -0.5, 0.75, 0, 0, 0, 0, 1]) to obtain the position transformation matrix (whose array data is [0.875, , 0.4330126941204071, -0.21650634706020355, 0, -0.21650634706020355, 0.75, 0.625, 0, 0.4330126941204071, -0.5, 0.75, 0, 1, 1,1, 1].
[0046] S2. Obtain the initial world matrix of the three-dimensional model to be processed, and use the initial world matrix as the coordinate system matrix of the first array; multiply the coordinate system matrix of the previous array with the position transformation matrix and the inverse of the initial world matrix to obtain the coordinate system matrix of the current array; the coordinate system matrices of all arrays form an array coordinate system matrix set.
[0047] The initial world matrix of the three-dimensional model to be processed is used as the coordinate system matrix of the first array, so that the initial information of the three-dimensional model to be processed can be retained; then, based on the number of models that the user wants to display, several array instances are customized, and the coordinate system matrix of the previous array is combined with the position transformation matrix and the initial world matrix to obtain the current coordinate array matrix; the coordinate system matrices of all arrays form an array coordinate system matrix set corresponding to several array instances, which realizes the construction of multiple array data in complex scenes without building basic scenes, reduces the time and energy in building rich scenes, and improves the efficiency of array-based scene construction.
[0048] Specifically, the display quantity is set to 5, and a matrix length of 16 is calculated to create a space for storing data in the format of a 32-bit floating-point array. The matrix length multiplied by the display quantity gives a space length of 80 for storing data. It is divided into 5 segment lengths, each with a segment length of 16, which are used to store the coordinate array matrix data of the 5 arrays, respectively, to obtain an initial total storage space in which the values corresponding to positions 0-79 are all 0. In the initial total storage space, when the coordinate system matrix of each array in the array coordinate system matrix set replaces the data of the initial total storage space, the replaced initial total storage space is output to obtain the array coordinate system matrix set.
[0049] First, replace the data at positions 0-15 in the initial total storage space with the array data corresponding to the initial world matrix (the coordinate system matrix of the first array), that is, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1].
[0050] Next, the coordinate system matrix of the first array (initial world matrix) is combined with the above position transformation matrix (whose array data is [0.875, 0.4330126941204071, -0.21650634706020355, 0, -0.21650634706020355, 0.75, 0.625, 0, 0.4330126941204071, -0.5, 0.75, 0, 1, 1,1, 1]) and the inverse of the initial world matrix (whose array data is [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,0, 0, 1]) to obtain the coordinate matrix of the second array (whose array data is [0.875,0.4330126941204071, -0.21650634706020355, 0, -0.21650634706020355, 0.75,0.625, 0, 0.4330126941204071, -0.5, 0.75, 0, 1, 1, 1, 1]), replacing the data at positions 16-31 in the initial total storage space.
[0051] 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0.875, 0.4330126941204071, -0.21650634706020355, 0.75, 0.625, 0,0.4330126941204071, -0.5, 0.75, 0, 1, 1, 1, 1, 0.578125, 0.8118988275527954,-0.08118987828493118, 0, -0.08118987828493118, 0.15625, 0.984375, 0,0.8118988275527954, -0.5625, 0.15625, 0, 2.091506242752075,1.6830127239227295, 2.158493757247925, 1, 0.294921875, 0.8998545408248901,0.32137662172317505, 0, , 0.32137662172317505, -0.41015625, 0.853515625, 0,0.8998545408248901, -0.1484375, -0.41015625, 0, 3.4003403186798096,2.0886614322662354, 3.217928886413574, 1, 0.202392578125, 0.6419075131416321,0.7395890951156616, 0, 0.7395890951156616, , -0.59521484375, 0.314208984375, 0,0.6419075131416321, 0.4833984375, -0.59521484375, 0, 4.9164934158325195,2.429922103881836, 3.9826648235321045, 1].
[0052] S3. Based on the array coordinate system matrix set, the three-dimensional model to be processed is updated to obtain a plurality of array construction models for forming an array scene.
[0053] An array coordinate system matrix set containing several array coordinate system matrices is assigned to the matrix data of the three-dimensional model to be processed, so as to update the model matrix data and instance length of the three-dimensional model to be processed multiple times, and obtain several array construction models for forming a scene.
[0054] In addition, if the three-dimensional model to be processed is composed of multiple modules with a hierarchical relationship, the tree data in the form of parent-child cascade of each module is obtained respectively, and after segmentation processing, multiple tree data with the parent node as the head node are obtained to form a parent node tree data set; the flattened position data of all descendant nodes of each parent node in the parent node tree data set are obtained to obtain the flattened data of the descendants of each parent node; the flattened data of the descendants of each parent node are respectively used as a three-dimensional model to be processed to execute the array scene construction method based on the three-dimensional engine (that is, execute steps S1, S2 and S3).
[0055] Specifically, if the structure of the three-dimensional model to be processed is complex, the data volume is large, and it is composed of multiple modules with hierarchical relationships, in order to save time and energy and improve computing efficiency, first obtain the tree data in the form of parent-child cascade for each module, the highest-level structure in the module is the parent node, the parent node can be an empty node, and the structures of other levels are child nodes or grandchild nodes; then the tree data in the form of parent-child cascade for each module is segmented and processed to obtain multiple tree data with the parent node as the head node, forming a parent node tree data set; then, the parent node tree data set is concentrated, and the data of all descendant nodes of each parent node tree data are flattened to obtain the flattened data of descendants of each parent node; the flattened data of descendants of each parent node can be used as a three-dimensional model to be processed for calculation based on the array scene construction method of the three-dimensional engine, so as to realize scene construction that saves time and energy.
[0056] This embodiment also provides an array scene construction system based on a three-dimensional engine, including:
[0057] The position transformation matrix generation module is used to obtain the model rotation quaternion based on the rotation angle of the three-dimensional model to be processed on the spatial axis; the model rotation quaternion and the corresponding scaling ratio and translation distance are constructed by the rotation matrix and then multiplied with the rotation center matrix to obtain the rotation transformation matrix; the scaling of the three-dimensional model to be processed is respectively multiplied with the corresponding scaling ratio on the spatial axis and then constructed by the matrix to obtain the scaling matrix; the scaling matrix is multiplied with the rotation transformation matrix and the scaling center matrix to obtain the scaling transformation matrix; the base point position of the three-dimensional model to be processed in the scene is multiplied with the scaling transformation matrix to obtain the position transformation matrix;
[0058] The array coordinate system matrix set generation module is used to obtain the initial world matrix of the three-dimensional model to be processed, and use the initial world matrix as the coordinate system matrix of the first array; the coordinate system matrix of the previous array is multiplied by the position transformation matrix and the inverse of the initial world matrix to obtain the coordinate system matrix of the current array; the coordinate system matrices of all arrays form an array coordinate system matrix set;
[0059] A plurality of array-type construction model generation modules are used to update the three-dimensional model to be processed based on the array coordinate system matrix set to obtain a plurality of array-type construction models for forming an array-type scene.
[0060] This embodiment also provides an array scene construction device based on a three-dimensional engine, including a processor and a memory, wherein the processor implements the above-mentioned array scene construction method based on the three-dimensional engine when executing a computer program stored in the memory.
[0061] This embodiment further provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the above-mentioned array scene construction method based on a three-dimensional engine.
[0062] The present embodiment provides an array scene construction method based on a three-dimensional engine. First, based on the rotation information of the three-dimensional model to be processed, a position transformation matrix of the three-dimensional model to be processed is defined to achieve rapid changes in the position and size of the model while ensuring that the position and size transformation of the model are correct; then, the initial world matrix of the three-dimensional model to be processed is used as the coordinate system matrix of the first array to retain the initial information of the three-dimensional model to be processed; and based on the number of models displayed, the coordinate system matrix of the previous array is multiplied by the position transformation matrix and the initial world matrix to obtain the current coordinate array matrix; the coordinate system matrices of all arrays form an array coordinate system matrix set corresponding to several instances; finally, based on the array coordinate system matrix set, the matrix data and instance length of the three-dimensional model to be processed are updated to obtain several array construction models; without the need to build a basic scene, the time and effort in building rich scenes is reduced, and the efficiency of building scenes is improved.
Claims
1. A method for constructing an array scene based on a three-dimensional engine, characterized in that: The following operations are included: S1. Obtaining a model rotation quaternion based on the rotation angle of the three-dimensional model to be processed on the spatial axis; The model rotation quaternion and the corresponding scaling ratio and translation distance are constructed by a rotation matrix, and then multiplied with a rotation center matrix to obtain a rotation transformation matrix; the rotation center matrix is a unit matrix constructed based on the rotation center; specifically: a rotation matrix is obtained based on the model rotation quaternion and the corresponding scaling ratio and translation distance; a rotation transformation matrix is obtained by multiplying the rotation matrix and the rotation center matrix; The scaling of the 3D model to be processed is multiplied by the corresponding scaling ratio on the spatial axis, and then constructed through a matrix to obtain a scaling matrix; The scaling matrix is multiplied by the rotation transformation matrix and the scaling center matrix to obtain a scaling transformation matrix; The base point position of the three-dimensional model to be processed in the scene is multiplied by the scaling transformation matrix to obtain a position transformation matrix; the base point position of the three-dimensional model to be processed in the scene is the rotational pasting position of the three-dimensional model to be processed when pasted into the software scene, which is the position data of the preset array-type construction data; S2, obtaining an initial world matrix of the three-dimensional model to be processed, and using the initial world matrix as a coordinate system matrix of the first array; The coordinate system matrix of the previous array is multiplied by the position transformation matrix and the inverse of the initial world matrix to obtain the coordinate system matrix of the current array; The coordinate system matrices of all arrays form an array coordinate system matrix set; S3, based on the array coordinate system matrix set, updating the three-dimensional model to be processed to obtain a plurality of array construction models for forming an array scene; If the three-dimensional model to be processed is composed of multiple modules with a hierarchical relationship, the tree data in the form of parent-child cascade of each module is obtained respectively, and after segmentation processing, multiple tree data with the parent node as the head node are obtained to form a parent node tree data set; the flattened position data of all descendant nodes of each parent node in the parent node tree data set are obtained to obtain the flattened data of the descendants of each parent node; the flattened data of the descendants of each parent node are respectively used as a three-dimensional model to be processed to execute the operations in S1, S2 and S3.
2. The array scene construction method based on a three-dimensional engine according to claim 1, characterized in that: The model rotation quaternion is composed of a horizontal axis rotation element, a vertical axis rotation element, a vertical axis rotation element and a rotation angle element; The horizontal axis rotation element number, the vertical axis rotation element number, the vertical axis rotation element number and the rotation angle element number are all obtained based on the horizontal axis rotation angle, the vertical axis rotation angle and the vertical axis rotation angle.
3. The array scene construction method based on a three-dimensional engine according to claim 2, characterized in that: The method for obtaining the number of horizontal axis rotation elements is implemented by the following formula: Y x =cos(r y / 2)·sin(r x / 2)·cos(r z / 2)+sin(r y / 2)·cos(r x / 2)·sin(r z / 2) , Y x is the number of rotations along the horizontal axis, r x The rotation angle corresponding to the horizontal axis rotation angle ,r y is the rotation radian corresponding to the vertical axis rotation angle, r z The rotation angle of the vertical axis corresponds to the rotation radian.
4. The array scene construction method based on a three-dimensional engine according to claim 2, characterized in that: The method for obtaining the number of the vertical axis rotation element is: Y y =sin(r y / 2)·cos(r x / 2)·cos(r z / 2)-cos(r y / 2)·sin(r x / 2)·sin(r z / 2) , Y y is the rotation dimension of the longitudinal axis.
5. The array scene construction method based on a three-dimensional engine according to claim 2, characterized in that: The method for obtaining the vertical axis rotation element number is: Y z =cos(r y / 2)·cos(r x / 2)·sin(r z / 2)-sin(r y / 2)·sin(r x / 2)·cos(r z / 2) , Y z is the rotation dimension of the longitudinal axis.
6. The array scene construction method based on a three-dimensional engine according to claim 2, characterized in that: The method for obtaining the rotation angle element is: Y w =cos(r y / 2)·cos(r x / 2)·cos(r z / 2)+sin(r y / 2)·sin(r x / 2)·sin(r z / 2) , Y w is the rotation angle element.
7. An array scene construction system based on a three-dimensional engine, characterized in that: include: The position transformation matrix generation module is used to obtain the model rotation quaternion based on the rotation angle of the three-dimensional model to be processed on the spatial axis; the model rotation quaternion and the corresponding scaling ratio and translation distance are constructed through a rotation matrix, and then multiplied with the rotation center matrix to obtain a rotation transformation matrix; the rotation center matrix is a unit matrix constructed based on the rotation center; specifically: the rotation matrix is obtained based on the model rotation quaternion and the corresponding scaling ratio and translation distance; the rotation matrix and the rotation center matrix are multiplied to obtain a rotation transformation matrix; The scaling of the three-dimensional model to be processed is multiplied by the corresponding scaling ratio on the spatial axis, and then constructed by a matrix to obtain a scaling matrix; the scaling matrix is multiplied by the rotation transformation matrix and the scaling center matrix to obtain a scaling transformation matrix; The base point position of the three-dimensional model to be processed in the scene is multiplied by the scaling transformation matrix to obtain a position transformation matrix; the base point position of the three-dimensional model to be processed in the scene is the rotational pasting position of the three-dimensional model to be processed when pasted into the software scene, which is the position data of the preset array-type construction data; An array coordinate system matrix set generation module is used to obtain an initial world matrix of a three-dimensional model to be processed, and use the initial world matrix as a coordinate system matrix of a first array; the coordinate system matrix of a previous array is multiplied by the position transformation matrix and the inverse of the initial world matrix to obtain a coordinate system matrix of a current array; the coordinate system matrices of all arrays form an array coordinate system matrix set; A plurality of array-type construction model generation modules, used for updating the three-dimensional model to be processed based on the array coordinate system matrix set to obtain a plurality of array-type construction models for forming an array-type scene; If the three-dimensional model to be processed is composed of multiple modules with a hierarchical relationship, the tree data in the form of parent-child cascade of each module is obtained respectively, and after segmentation processing, multiple tree data with the parent node as the head node are obtained to form a parent node tree data set; the flattened position data of all descendant nodes of each parent node in the parent node tree data set are obtained to obtain the flattened data of the descendants of each parent node; the flattened data of the descendants of each parent node are respectively used as a three-dimensional model to be processed, and are respectively used as a three-dimensional model to be processed to execute the operations in the position transformation matrix generation module, the array coordinate system matrix set generation module and several array-type construction model generation modules.
8. An array scene construction device based on a three-dimensional engine, characterized in that: It comprises a processor and a memory, wherein when the processor executes the computer program stored in the memory, the array scene construction method based on the three-dimensional engine as described in any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the array scene construction method based on a three-dimensional engine as described in any one of claims 1 to 6 is implemented.
