WO2023241212A1 - 对象处理方法、装置、设备、计算机可读存储介质及计算机程序产品 - Google Patents
对象处理方法、装置、设备、计算机可读存储介质及计算机程序产品 Download PDFInfo
- Publication number
- WO2023241212A1 WO2023241212A1 PCT/CN2023/089104 CN2023089104W WO2023241212A1 WO 2023241212 A1 WO2023241212 A1 WO 2023241212A1 CN 2023089104 W CN2023089104 W CN 2023089104W WO 2023241212 A1 WO2023241212 A1 WO 2023241212A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- resource object
- resource
- expansion
- objects
- determined
- Prior art date
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 31
- 238000004590 computer program Methods 0.000 title claims abstract description 14
- 238000003860 storage Methods 0.000 title claims abstract description 13
- 238000000034 method Methods 0.000 claims abstract description 86
- 230000008569 process Effects 0.000 claims description 49
- 238000012545 processing Methods 0.000 claims description 46
- 230000015654 memory Effects 0.000 claims description 27
- 238000000926 separation method Methods 0.000 claims description 15
- 238000009877 rendering Methods 0.000 claims description 4
- 238000004422 calculation algorithm Methods 0.000 description 21
- 238000010586 diagram Methods 0.000 description 17
- 230000000694 effects Effects 0.000 description 17
- 238000005457 optimization Methods 0.000 description 9
- 238000005516 engineering process Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 238000000265 homogenisation Methods 0.000 description 6
- 238000013507 mapping Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 5
- 230000001788 irregular Effects 0.000 description 5
- 238000012856 packing Methods 0.000 description 5
- 230000009286 beneficial effect Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 3
- 238000013461 design Methods 0.000 description 3
- 230000002068 genetic effect Effects 0.000 description 3
- 230000005484 gravity Effects 0.000 description 3
- 230000006872 improvement Effects 0.000 description 3
- 230000003044 adaptive effect Effects 0.000 description 2
- 230000000740 bleeding effect Effects 0.000 description 2
- 238000005094 computer simulation Methods 0.000 description 2
- 230000001186 cumulative effect Effects 0.000 description 2
- 125000004122 cyclic group Chemical group 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000004519 manufacturing process Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000013515 script Methods 0.000 description 2
- 241000208199 Buxus sempervirens Species 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000003190 augmentative effect Effects 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 210000000349 chromosome Anatomy 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 230000008303 genetic mechanism Effects 0.000 description 1
- 230000008676 import Effects 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 238000012067 mathematical method Methods 0.000 description 1
- 230000035772 mutation Effects 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 238000012858 packaging process Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 108090000623 proteins and genes Proteins 0.000 description 1
- 238000007670 refining Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000001568 sexual effect Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/10—Geometric CAD
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/005—General purpose rendering architectures
Definitions
- the present application relates to the field of computer technology, and in particular, to an object processing method, device, equipment, computer-readable storage medium and computer program product.
- Polygonal models are the most popular, important, and widely supported model representation method in computer graphics.
- the basic process of two-dimensional boxing is: put each polygon into the container in turn according to certain rules; update the placeable area of the container after each placement, and then place the next polygon until all polygons have been placed or the container Full.
- Figure 1 shows an intermediate state of the boxing process, where the left side is the polygon that has not yet been placed, and the right side is the placed polygon and the remaining space of the container.
- the binning problem has not only been widely studied in academia, but its results have also been widely used in industry.
- the binning algorithms provided by existing related technologies often have large gaps after obtaining the binning results. Even if further optimization is performed, only some polygons are expanded, or all polygons are expanded with the same type, and boxing and filling are performed. The efficiency improvement effect is limited and cannot surpass the manual binning optimization effect.
- Embodiments of the present application provide an object processing method, device, computer-readable storage medium, and computer program product, which can improve the filling rate of resource objects in a target container.
- Embodiments of the present application provide an object processing method that is applied to texture rendering scenes.
- the method is applied to computer equipment and includes:
- the extension type of each resource object based on the symmetric attribute information and inclusion relationship information of each resource object, wherein the extension type includes one of isotropic extension and anisotropic extension;
- an extension process is performed on each resource object to obtain each processed resource object.
- An embodiment of the present application provides an object processing device, including:
- the first acquisition module is configured to obtain the initial filling results of multiple resource objects to be processed in the target container
- the first moving module is configured to move each resource object to the center position of its respective corresponding available space based on the initial filling result
- the second acquisition module is configured to acquire the symmetric attribute information and inclusion relationship information of each resource object
- the first determination module is configured to determine the extension type of each resource object based on the symmetric attribute information and the inclusion relationship information of each resource object, wherein the extension type includes one of isotropic extension and anisotropic extension. kind;
- the first expansion module is configured to perform expansion processing on each resource object based on the extension type of each resource object, and obtain each processed resource object.
- the embodiment of the present application provides a device, including:
- Memory used to store executable instructions
- the processor is configured to implement the object processing method provided by the embodiment of the present application when executing executable instructions stored in the memory.
- Embodiments of the present application provide a computer-readable storage medium that stores executable instructions for causing the processor to implement the object processing method provided by the embodiments of the present application when executed.
- An embodiment of the present application provides a computer program product, which includes a computer program or instructions.
- the computer program or instructions are executed by a processor, the object processing method provided by the embodiment of the present application is implemented.
- extension, and the extension type of the resource object is determined adaptively based on the symmetric attribute information and inclusion information of the resource object.
- the extension type includes isotropic extension and anisotropic extension. Compared with the related technology, which can only The object is isotropically expanded. In the embodiment of the present application, resource objects that can only be expanded isotropically are expanded isotropically. However, resource objects that can be expanded anisotropically can be expanded through anisotropic expansion. The resource object is expanded to the greatest extent, so that the effect of manual boxing adjustment can be simulated, thereby maximizing the fill rate.
- Figure 1 is a schematic diagram of the boxing problem
- Figure 2 is a schematic architectural diagram of the object processing system 100 provided by the embodiment of the present application.
- Figure 3 is a schematic structural diagram of the second terminal 400 provided by the embodiment of the present application.
- Figure 4A is a schematic flow chart of an implementation of the object processing method provided by the embodiment of the present application.
- Figure 4B is a schematic flow diagram of another implementation of the object processing method provided by the embodiment of the present application.
- Figure 5 is a schematic flow chart of the implementation of moving each resource object to the corresponding available space center provided by the embodiment of the present application;
- Figure 6 is a schematic flowchart of the implementation of moving the first target object to the first target available space provided by an embodiment of the present application
- Figure 7 is a schematic diagram of manual modification of the boxing results
- Figure 8 is a schematic diagram of the polygon classification extension provided by the embodiment of the present application.
- Figure 9 is a schematic diagram of yet another implementation process of the object processing method provided by the embodiment of the present application.
- FIG. 10 is a schematic diagram showing that the UV island provided by the embodiment of the present application is not in the center of the local expansion gap;
- Figure 11 is a schematic diagram of anisotropic expansion provided by an embodiment of the present application.
- Figure 12 is a schematic diagram of isotropic expansion provided by the embodiment of the present application.
- Figure 13 is a schematic diagram of the implementation process of anisotropic expansion provided by the embodiment of the present application.
- Figure 14 is a schematic diagram of the implementation process of isotropic expansion provided by the embodiment of the present application.
- Figure 15 is a comparison chart of the binning effect before and after the expansion of small, medium and large-scale UV islands provided by the embodiment of the present application.
- first/second/third are merely used to distinguish similar objects and do not represent a specific ordering of objects. It is understandable that "first/second/third” Where permitted, the specific order or sequence may be interchanged so that the embodiments of the application described herein can be practiced in an order other than that illustrated or described herein.
- Packing Problem in a general sense, the packing problem refers to arranging a set of regular or irregular two-dimensional or three-dimensional objects in a given regular or irregular container according to certain rules. to achieve a specific purpose.
- the binning problem involved in the embodiment of this application focuses on packing two-dimensional irregular polygons into a two-dimensional container, as shown in Figure 1 .
- the two-dimensional irregular polygon to be boxed is also called a UV island.
- the two-dimensional irregular polygon is called a resource object.
- Non-fit polygon refers to the polygon formed by the trajectory of a reference point on the boundary of polygon B when it slides along the inner wall of another polygon A. NFP defines the feasible area where the reference point is placed when binning polygon B within the area defined by polygon A.
- GM Genetic Algorithm
- Genetic Algorithm is a computational model of the biological evolution process that simulates the natural selection and genetic mechanisms of Darwin's biological evolution theory. It is a method of searching for optimal solutions by simulating the natural evolution process. This algorithm uses mathematical methods and computer simulation operations to convert the problem-solving process into a process similar to the crossover and mutation of chromosome genes in biological evolution. When solving more complex combinatorial optimization problems, better optimization results can usually be obtained faster than some conventional optimization algorithms.
- AABB Tree A spatial search tree based on the K-d tree principle, each node of which represents a spatial bounding box of a three-dimensional geometric primitive. This data structure can quickly report whether the query primitive intersects with the primitives in the tree, as well as the specific intersection type, intersection position, etc.
- Bleeding value A professional art term in the packaging problem, which refers to the spacing protection between UV islands during the packaging process to leave a certain gap.
- the common practice in UV island binning is to use one pixel for every 128 pixels as the bleed value based on the binning space resolution. For example, 256*256 resolution usually uses 2 pixel values as the bleed value.
- commonly used binning algorithms include methods based on NFP and the lowest center of gravity. When implemented, multiple candidate angles are determined for each polygon to be placed and multiple candidate positions are determined based on the candidate angles. The method with the lowest center of gravity is Place the corresponding polygon at the candidate location. When placed according to this packing method, there will be larger voids in the container and therefore a lower fill rate.
- embodiments of the present application provide an object processing method, device, equipment, computer-readable storage medium and computer program product, which can maximize the installation efficiency while maintaining the isotropic/anisotropic characteristics of resource objects. box utilization to meet specific needs.
- the following describes exemplary applications of the computer equipment provided by the embodiments of the present application.
- the equipment provided by the embodiments of the present application can be implemented as a notebook computer, a tablet computer, a desktop computer, a set-top box, a mobile device (for example, a mobile phone, a portable music player, a personal computer).
- Various types of user terminals such as digital assistants, dedicated messaging devices, portable gaming devices, etc., can also be implemented as servers.
- exemplary applications when the device is implemented as a terminal will be described.
- Figure 2 is a schematic architectural diagram of an object processing system 100 provided by an embodiment of the present application.
- the system includes a first terminal 200, a network 300 and a second terminal 400, where the first terminal 200 and The second terminal 400 establishes a communication connection through a network.
- the network 300 may be a wide area network or a local area network, or a combination of the two.
- the user can use the first terminal 200 to complete the three-dimensional model design of the virtual object.
- the virtual object can be a virtual object in a game scene, a virtual object in a virtual reality scene or an augmented reality scene, for example, it can be a virtual character or a virtual building.
- Objects, virtual plants, etc., and the virtual objects displayed in the virtual scene are obtained by texture mapping the three-dimensional model of the virtual object through texture mapping technology, which can improve the virtual objects displayed in the game screen. authenticity and vividness.
- the first terminal 200 after completing the three-dimensional model design of the virtual object, sends the three-dimensional model data to the second terminal 400.
- the second terminal 400 can perform patching on the three-dimensional model of the virtual object.
- two-dimensional resource object in some embodiments, it may be called a UV island or a polygon
- boxing processing on the two-dimensional resource object.
- two-dimensional resource objects can be boxed to obtain an initial filling result.
- the initial filling result can be obtained by using a preset boxing algorithm to box multiple resource objects, or it can be obtained by using a preset boxing algorithm.
- each resource object is moved to the center position of its corresponding available space; and then the extension type of each resource object is determined through the symmetric attribute information and containment relationship information of each resource object, wherein the extension type Including one of isotropic expansion and anisotropic expansion, and then based on the expansion type of each resource object, the expansion process is performed on each resource object to obtain each processed resource object. Since the first target object The occupied space is less than the maximum gap, and the first target object is moved and enlarged, thereby making the total free space of the container smaller and improving the filling rate.
- the first terminal 200 and the second terminal 400 may be the same terminal, that is, the object design and texture rendering functions are completed through the same terminal.
- the second terminal 400 may also be a slave service
- the three-dimensional virtual object to be rendered is obtained from the processor, and then the second terminal 400 performs patching on the three-dimensional virtual object to obtain multiple two-dimensional resource objects, and performs boxing processing and global optimization processing on the multiple resource objects, thereby Improve fill rate.
- the server here can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, and cloud communications. , middleware services, domain name services, security services, CDN, and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.
- the first terminal 200 and the second terminal 400 may be a smartphone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a vehicle-mounted smart terminal, etc., but are not limited thereto.
- the terminal and the server can be connected directly or indirectly through wired or wireless communication methods, which are not limited in the embodiments of this application.
- FIG. 3 is a schematic structural diagram of a second terminal 400 provided by an embodiment of the present application.
- the second terminal 400 shown in Figure 3 includes: at least one processor 410, a memory 450, at least one network interface 420 and a user interface 430 .
- the various components in terminal 400 are coupled together by bus system 440. It can be understood that the bus system 440 is used to implement connection communication between these components.
- the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, the various buses are labeled as bus system 440 in FIG. 3 .
- the processor 410 may be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware Components, etc., wherein the general processor can be a microprocessor or any conventional processor, etc.
- DSP Digital Signal Processor
- User interface 430 includes one or more output devices 431 that enable the presentation of media content, including one or more speakers and/or one or more visual displays.
- User interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, and other input buttons and controls.
- Memory 450 may be removable, non-removable, or a combination thereof.
- Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, etc.
- Memory 450 optionally includes one or more storage devices physically located remotely from processor 410 .
- Memory 450 includes volatile memory or non-volatile memory, and may include both volatile and non-volatile memory.
- Non-volatile memory can be read-only memory (ROM, Read Only Memory), and volatile memory can be random access memory (RAM, Random Access Memory).
- RAM Random Access Memory
- the memory 450 described in the embodiments of this application is intended to include any suitable type of memory.
- the memory 450 is capable of storing data to support various operations, examples of which include programs, modules, and data structures, or subsets or supersets thereof, as exemplarily described below.
- the operating system 451 includes system programs used to process various basic system services and perform hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., which are used to implement various basic services and process hardware-based tasks;
- Network communications module 452 for reaching other computing devices via one or more (wired or wireless) network interfaces 420
- example network interfaces 420 include: Bluetooth, Wireless Compliance Certified (WiFi), and Universal Serial Bus ( USB, Universal Serial Bus), etc.;
- Presentation module 453 for enabling the presentation of information (e.g., a user interface for operating peripheral devices and displaying content and information) via one or more output devices 431 (e.g., display screens, speakers, etc.) associated with user interface 430 );
- information e.g., a user interface for operating peripheral devices and displaying content and information
- output devices 431 e.g., display screens, speakers, etc.
- An input processing module 454 for detecting one or more user inputs or interactions from one or more input devices 432 and translating the detected inputs or interactions.
- the device provided by the embodiment of the present application can be implemented in software.
- Figure 3 shows the memory
- the object processing device 455 stored in the memory 450 can be software in the form of programs, plug-ins, etc., including the following software modules: a first acquisition module 4551, a first movement module 4552, a second acquisition module 4553, and a first determination module 4554 and the first expansion module 4555. These modules are logical, so they can be combined or further split in any way according to the functions implemented. The functions of each module are explained below.
- the device provided by the embodiment of the present application can be implemented in hardware.
- the device provided by the embodiment of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the present application.
- the object processing method provided by the embodiment for example, the processor in the form of a hardware decoding processor can adopt one or more Application Specific Integrated Circuits (ASIC, Application Specific Integrated Circuit), DSP, Programmable Logic Device (PLD, Programmable Logic Device) ), Complex Programmable Logic Device (CPLD, Complex Programmable Logic Device), Field Programmable Gate Array (FPGA, Field-Programmable Gate Array) or other electronic components.
- ASIC Application Specific Integrated Circuit
- DSP Programmable Logic Device
- PLD Programmable Logic Device
- CPLD Complex Programmable Logic Device
- FPGA Field Programmable Gate Array
- the embodiment of the present application provides an object processing method, which is applied to a computer device.
- the computer device may be a terminal or a server.
- the computer device is used as a terminal as an example for explanation.
- FIG. 4A is a schematic flow diagram of an implementation of the object processing method provided by the embodiment of the present application.
- the object processing method provided by the embodiment of the present application will be described below with reference to FIG. 4A .
- Step S101 Obtain the initial filling results of multiple resource objects to be processed in the target container.
- multiple resource objects may refer to two or more resource objects.
- the resource objects may be two-dimensional polygons (hereinafter referred to as polygons) obtained by dividing the three-dimensional model of the virtual object.
- the polygon can be a polygon with holes or a polygon without holes.
- the resource object may be a UV island in the game production industry, where the essence of the UV island is the above-mentioned polygon.
- the resource object can also be obtained by expanding and dividing the actual object.
- the target container is used to host resource objects.
- the target container can also be a two-dimensional object with a polygon shape.
- the initial filling result may be obtained by sequentially adding multiple resource objects to be processed to the target container using a preset boxing algorithm. For example, you can use the boxing algorithm based on NFP+genetic algorithm, the automatic boxing algorithm based on NFP and the lowest center of gravity principle, etc.
- the initial filling result may also be obtained by global position optimization of the binning result determined using a preset binning algorithm.
- the initial filling result may include the location of the center point of each resource object, the location information of the outer contour vertices of each resource object, the free location of the target container, etc.
- Step S102 Based on the initial filling result, move the object center of each resource object to the center position of the respective corresponding available space.
- the movement information for moving the object center of each resource object to the center position of the available space where the i-th resource object is located may be determined sequentially based on the initial filling result, and based on the movement information, the movement information is determined.
- the moving distance of the i-th resource object is greater than the preset distance threshold, the object center of the i-th resource object is moved to the center position of the available space.
- Step S103 Obtain the symmetric attribute information and inclusion relationship information of each resource object.
- the symmetry attribute information of the resource object may include left-right symmetry attribute information and top-bottom symmetry attribute information of the resource object.
- the left-right symmetry attribute information can characterize whether the resource object is left-right symmetrical
- the upper-bottom symmetry attribute information can characterize whether the resource object is upper-bottom symmetrical.
- the inclusion relationship information of each resource object may include a first object set and a second object set, where the first object set includes the object identifiers of the resource objects contained in the resource object, and the second object set includes The object ID of the other resource object that contains this resource object.
- the resource object may be a two-dimensional polygon.
- the included polygon may be called a hole of the two-dimensional polygon.
- Each hole information of the resource object may include the name of each vertex on the hole, the position of the vertex, and the connection relationship between the vertices. Then a reference point is randomly determined from the outer boundary of the p-th resource object to determine whether the reference point is located inside the hole in the i-th resource object.
- Step S104 Determine the extension type of each resource object based on the symmetric attribute information and inclusion relationship information of each resource object.
- the expansion type includes one of isotropic expansion and anisotropic expansion.
- Isotropic expansion means that the expansion ratio of the resource object in all directions is the same, and anisotropic expansion means that the resource object expands in different directions.
- the expansion ratios can be the same or different.
- the extension type of the resource object can be determined as isotropic extension. If the resource object also contains Other sub-resource objects, then the extension types of other sub-resource objects are also isotropic extensions; when the resource object has internal symmetry characteristics, determine whether the resource object is included by the parent resource object.
- the extension type of this resource object is anisotropic extension; if it is included by other parent resource objects, if the extension type of its parent resource object is isotropic extension, then the resource object will also be isotropic extension; if its parent resource object The extension type is anisotropic expansion, then it is also necessary to determine whether its sibling resource objects have internal symmetry characteristics. If its sibling resource objects all have internal symmetry characteristics, determine that the extension type of this resource object and its sibling resource objects is anisotropic. Heterogeneous expansion; if there is at least one sibling resource object that does not have internal symmetry characteristics, the expansion type of the resource object and its sibling resource objects is determined to be isotropic expansion.
- Step S105 Extension processing is performed on each resource object based on the extension type of each resource object, and each processed resource object is obtained.
- the first expansion ratio of the resource object is first determined.
- the resource object is expanded according to the first expansion ratio. Expand to obtain the expanded resource object; if the resource object contains other sub-resource objects, then the expansion type of other sub-resource objects is also isotropic expansion. At this time, the resource object and the sub-resource objects contained in the resource object will be expanded.
- the resource object is simultaneously expanded according to the first expansion ratio, which not only avoids overlap between the resource object and the sub-resource objects it contains, but also improves expansion efficiency.
- the expansion type of the resource object is anisotropic expansion, then determine the second expansion ratio of the resource object in each expansion direction. If the resource object does not contain other sub-resource objects, then expand the resource object in each expansion direction according to the corresponding Just expand by the second expansion ratio. If the resource object contains other sub-resource objects, and the expansion type of other sub-resource objects is also anisotropic expansion, then the resource object and its sub-resource objects will be expanded in each expansion direction.
- extension, and the extension type of the resource object is determined adaptively based on the symmetric attribute information and inclusion information of the resource object.
- the extension type includes isotropic extension and anisotropic extension. Compared with the related technology, which can only The object is isotropically expanded. In the embodiment of the present application, resource objects that can only be expanded isotropically are expanded isotropically. However, resource objects that can be expanded anisotropically can be expanded through anisotropic expansion. The resource object is expanded to the greatest extent, so that the effect of manual boxing adjustment can be simulated, thereby maximizing the fill rate.
- Step S105 in order to further determine whether the expansion result obtained in step S105 has reached the expected filling rate and whether there is a better expansion result, as shown in Figure 4B, the following may also be performed. Steps S106 to S112:
- Step S106 After performing expansion processing on the 1st to Nth resource objects, determine the first filling rate of the target container.
- step S105 expansion is performed sequentially from the first resource object to the Nth resource object according to the identification of the resource object. After the expansion, the expansion can be based on the total capacity of the target container and the space occupied by each expanded resource object. Determine the first filling rate of the target container, that is, sum the space occupied by each resource object to obtain the total occupied space, and then divide the total occupied space by the total capacity of the target container to obtain the first filling rate.
- Step S107 determine whether the first filling rate is less than a preset filling rate threshold.
- step S108 when it is determined that the first filling rate is less than the preset filling rate threshold, step S108 is entered; when it is determined that the first filling rate is greater than or equal to the filling rate threshold, it means that the expected expansion effect has been achieved, and then step S108 is entered. S112.
- Step S108 Expand the Nth to first resource objects in sequence according to their corresponding extension types to obtain the Nth to first resource objects after the second processing.
- each resource object in the initial filling result is expanded in reverse order from the Nth resource object to the first resource object based on the extension type of the respective object, and the Nth resource object after the second processing is obtained. Resource object to the first resource object.
- extension process is similar to the implementation of extending the resource object sequentially, except that the processing order is different.
- Step S109 Determine the second filling rate of the target container.
- step S109 is similar to the implementation process of determining the first filling rate in step S106.
- step S109 reference may be made to the implementation process of step S106.
- Step S110 determine whether the second filling rate is greater than the first filling rate.
- step S111 when the second filling rate is greater than the first filling rate, it means that the filling rate of the target container has been improved after the re-expansion process of step S108, and then step S111 is entered; when the second filling rate is less than or equal to the first filling rate, the filling rate of the target container is improved.
- the filling rate is 1, it means that the filling rate of the target container has not been improved after the re-expansion process in step S108, and the process proceeds to step S112.
- Step S111 Determine the Nth to first resource objects after the second processing as target expansion results.
- Step S112 Determine the processed first to Nth resource objects as target expansion results.
- each resource object in the target container is expanded sequentially, through the above Steps S106 to S112, when it is determined that the first filling rate of the target container does not reach the preset filling rate threshold, each resource object in the target container is expanded in reverse order, and the second filling rate is obtained, and finally the first filling rate is The expansion result corresponding to the larger value of the rate and the second filling rate is determined as the target expansion result, so that the filling rate of the target container can be further improved.
- step S102 “Move the object center of each resource object to the center position of the respective corresponding available space based on the initial filling result" can be implemented by steps S21 to S212 as shown in Figure 5, Each step will be described below with reference to Figure 5.
- Step S21 Obtain the preset threshold of the number of movement iterations and the threshold of the number of movements of a single resource object.
- the threshold of the number of movement iterations is greater than or equal to the threshold of the number of movements of a single resource object.
- the threshold of the number of movement iterations and the threshold of the number of movements can be determined based on the total number of resource objects, or can be set by the user according to their own needs.
- Step S22 Obtain the current number of movement iterations.
- the current movement iteration number variable can be set to an initial value of 0. After each round of movement from the 1st resource object to the Nth resource object is completed, the current movement iteration number is incremented by 1.
- Step S23 Determine whether the current number of movement iterations is less than a threshold value of the number of movement iterations.
- step S24 when the current number of movement iterations is less than the threshold of the number of movement iterations, proceed to step S24; when the current number of iterations of movement is greater than or equal to the threshold of the number of movement iterations, proceed to step S103.
- Step S24 Obtain the current number of moves of the i-th resource object.
- N is the total number of resource objects, and N is an integer greater than 2.
- Step S25 Determine whether the current number of moves of the i-th resource object is less than the number of moves threshold.
- step S26 When the current number of moves of the i-th resource object is less than the threshold of the number of moves, step S26 is entered.
- step S29 When the current number of moves of the i-th resource object is greater than or equal to the threshold of number of moves, step S29 is entered.
- Step S26 Determine movement information for moving the object center of the i-th resource object to the center position of the available space where the i-th resource object is located.
- the object center of the i-th resource object can be characterized by the center of the bounding box corresponding to the i-th resource object, where the bounding box of the i-th resource object can be the coordinate axis of the i-th resource object.
- the aligned bounding box can also be a compact bounding box of the i-th resource object.
- the bounding box of the resource object is generally a rectangle, and the center of the bounding box is the intersection of the two diagonals of the rectangle.
- the amount of rightward movement during contact is calculated according to (amount of rightward movement - amount of leftward movement)/2 to calculate the movement information of the i-th resource object in the x-axis direction.
- the movement information may include movement amount and movement direction, where the absolute value of (movement to the right - movement to the left)/2 represents the movement amount, and the positive and negative values of (movement to the right - movement to the left)/2 represent the movement.
- Step S27 Determine whether the moving distance of the i-th resource object is greater than a preset distance threshold.
- the movement distance of the i-th resource object is first determined based on the movement information determined in step S26, because the movement information determined in step S26 includes movement information d 1 in the x-axis direction and d 1 in the y-axis direction. Moving information d 2 , then the moving distance corresponding to the i-th resource is Then determine whether the movement distance of the i-th resource object is greater than the preset distance threshold. When it is determined that the movement distance of the i-th resource object is greater than the preset distance threshold, step S28 is entered; when it is determined that the movement distance of the i-th resource object is greater than the preset distance threshold. When the moving distance is less than or equal to the distance threshold, step S29 is entered.
- Step S28 Move the object center of the i-th resource object to the center position of the available space according to the movement information, and update the current number of moves of the i-th resource object.
- this step it can be determined whether the i-th resource object contains other sub-resource objects. If the i-th resource object contains sub-resource objects, then when moving the i-th resource object, the i-th resource object and other sub-resource objects are moved. The included sub-resource objects are moved at the same time. At this time, when the i-th resource object is moved, the relative relationship between the i-th resource object and its contained sub-resource objects remains unchanged. Therefore, only the i-th resource object is updated in this step. The current number of moves of the resource object, without updating the current number of moves of the child resource object of the i-th resource object.
- Step S210 determine whether i is equal to N+1.
- step S211 when i equals N+1, it means that the current iteration process of moving the first resource object to the Nth resource object has been completed, and step S211 is entered at this time.
- i when i is not equal to N+1, it means that the current round of movement iteration process has not been completed, and step S24 is entered at this time.
- Step S211 After completing the current movement iteration process from the 1st resource object to the Nth resource object, update the current movement iteration number to obtain the updated current movement iteration number.
- Update the current number of movement iterations that is, add 1 to the current number of movement iterations.
- Step S212 Determine whether the updated current number of movement iterations is less than a threshold value of the number of movement iterations.
- step S24 when it is determined that the updated current movement iteration number is less than the movement iteration number threshold, step S24 is entered, and the first resource object is continued to be moved to the Nth resource object; the updated current movement iteration is determined When the number of times is greater than or equal to the threshold of the number of movement iterations, it means that the movement end condition has been reached, and step S103 is entered.
- the movement of one resource object will affect the relative positions of other adjacent resource objects in the corresponding available space. For example, before moving a resource object, the adjacent resource object of the resource object is located at the center of the available space corresponding to the adjacent resource object. After moving the edge between the resource pairs, the image of the adjacent resource object will change. The size of the available space corresponding to the adjacent resource object and the outer edge of the available space will change, so that the adjacent resource object is no longer located at the center of the available space. Therefore, performing one round of movement iteration often cannot realize that most resource objects are located at the center of their respective corresponding available spaces. Therefore, multiple rounds of movement iteration can be performed on the resource objects.
- the number of moves of a single resource object is The threshold and the overall movement iteration threshold are set.
- timeouts caused by the cyclic movement of one or some resource objects can be avoided; by setting the movement iteration threshold, Avoid multiple iterations with insignificant effects and eventual timeout when there are too many resource object islands.
- the threshold of the number of movement iterations and the threshold of the number of movements of a single resource object can be set according to the total number of resource objects, so as to achieve the best movement effect while ensuring execution efficiency, so as to achieve a balance between execution efficiency and execution effect. adaptive balance between.
- step S104 of "determining the extension type of each resource object based on the symmetric attribute information and inclusion relationship information of each resource object" can be implemented through steps S41 to S48 shown in Figure 6, as follows: Each step is explained with reference to Figure 6.
- Step S41 Determine whether the i-th resource object has internal symmetry characteristics based on the symmetry attribute information of the i-th resource object.
- N is the total number of resource objects, and N is an integer greater than 2.
- step S42 when it is determined that the i-th resource object is left-right symmetry based on the left-right symmetry attribute information, or when it is determined based on the top-bottom symmetry attribute information, step S42 is entered; when it is determined based on the left-right symmetry attribute information that the i-th resource object is not left-right symmetrical, and it is determined based on the up-down symmetry attribute information The i-th resource object is not symmetrical up and down. When it is determined that the i-th resource object does not have internal symmetry characteristics, step S45 is entered.
- the i-th resource object when the i-th resource object satisfies at least one of left-right symmetry and top-bottom symmetry, it is determined that the i-th resource object has internal symmetry characteristics; when the i-th resource object neither satisfies left-right symmetry nor top-bottom symmetry, it is determined that the i-th resource object Resource objects do not have internal symmetry.
- Step S42 Determine whether the i-th resource object is included in the parent resource object based on the inclusion relationship information of the i-th resource object.
- the inclusion relationship information of the i-th resource object includes a first object set and a second object set, where the first object set includes the object identifiers of the sub-resource objects contained in the resource object, and the second object set includes Included is the object identifier of the parent resource object that contains the resource object.
- Step S43 Obtain the extension type of the parent resource object.
- Step S44 Determine whether the extension type of the parent resource object is isotropic extension.
- step S45 When the extension type of the parent resource object is isotropic extension, step S45 is entered; when the extension type of the parent resource object is anisotropic extension, step S46 is entered.
- Step S45 Determine the extension type of the i-th resource object to be isotropic extension.
- Step S46 Obtain other child resource objects contained in the parent resource object.
- Step S47 Determine whether other sub-resource objects have internal symmetry characteristics.
- step S48 when it is determined based on the symmetry attribute information of the other sub-resource objects that all the other sub-resource objects have internal symmetry characteristics, step S48 is entered; when it is determined based on the symmetry attribute information of the other sub-resource objects that there is at least one When other sub-resource objects do not have internal symmetry characteristics, step S45 is entered.
- Step S48 Determine the expansion type of the i-th resource object to be anisotropic expansion.
- the extension type of the i-th resource object when determining the extension type of the i-th resource object, if the i-th resource object does not have internal symmetry characteristics, the extension type of the i-th resource object is directly determined as each Expand isotropically to ensure that no deformation occurs after the expansion process. If the i-th resource object has internal symmetry characteristics, it is necessary to further determine whether the i-th resource object is included by the parent resource object. If it is not included, it can be The expansion type of the i-th resource object is determined to be anisotropic expansion, which can achieve the maximum expansion in all directions.
- the expansion type of the parent resource object is also determined to be isotropic expansion, and if the expansion type of the parent resource object is anisotropic expansion, then if the parent resource
- the expansion type of the i-th resource object and other sub-resource objects can be determined as anisotropic expansion. In this way, conflicts between different resource objects can be avoided during the expansion process. Overlap can also ensure that the maximum proportion of expansion is carried out in each expansion direction, thereby improving the filling rate of the target container.
- the initial filling result obtained may include one resource object that contains other resource objects nested inside it, or there may be several resource objects.
- the above-mentioned step S105 "based on the extension type of each resource object, perform expansion processing on each resource object to obtain each processed resource object" through the following steps S51 to steps S519 implementation, each step is explained below.
- Step S51 Determine whether there is a symmetric object of the i-th resource object in the target container.
- Step S52 Determine whether the extension type of the i-th resource object is isotropic extension.
- step S53 is entered; when it is determined that the extension type of the i-th resource object is anisotropic extension, step S58 is entered.
- Step S53 Move the object center of the i-th resource object to the center position of the corresponding available space.
- step S102 The implementation process of this step is similar to the implementation process of step S102, and the implementation process of step S102 can be referred to during implementation.
- step S102 after the resource objects are expanded, the positions of the resource objects that have not been expanded will be affected. , thus causing the resource object to no longer be at the center of the corresponding visible space, because before expanding the i-th resource object, the object center of the i-th resource object is again moved to the center of the corresponding available space to ensure The maximum expansion ratio determined.
- Step S54 Determine the first expansion ratio of the i-th resource object.
- a two-way ray method can be used to determine the first expansion ratio of the i-th resource object: first, emit rays outward from the object center of the i-th resource object along the outer boundary vertices of the i-th resource object. , obtain the intersection points of other resource objects outside the i-th resource object, and calculate the corresponding first candidate expansion ratio accordingly; then, from the vertices of the outer boundaries of other resource objects outside the i-th resource object, towards the i-th resource The object center of the object emits a ray to obtain the nearest intersection point with the outer boundary of the i-th resource object, and calculate the corresponding second candidate expansion ratio accordingly. The smallest of the first candidate expansion ratio and the second candidate expansion ratio is used as the first expansion ratio to avoid overlapping with other resource objects during expansion.
- step S54 determining the first expansion ratio of the i-th resource object
- Step S541 Obtain the outer boundary information of other resource objects located outside the i-th resource object, the outer boundary information of the i-th resource object, and the object center of the i-th resource object.
- the edge When obtaining the outer boundary information of the i-th resource object, you can first obtain each edge on the resource object and the two adjacent faces of each edge, and then determine whether the adjacent faces of each edge belong to the resource object. Internally, if the adjacent faces of an edge all belong to the interior of the resource object, the edge is determined to be an internal edge; otherwise, the edge is determined to be an external boundary. Connecting the external boundaries of a resource object constitutes the resource object. outer boundary.
- the object center of the i-th resource object can be represented by the center of the bounding box of the i-th resource object.
- the outer boundary information of other resource objects outside the i-th resource object may include information such as vertex identifiers and vertex indexes on the outer boundaries of other resource objects outside the i-th resource object.
- the outer boundary information of the i-th resource object includes Vertex identifier, vertex index and other information on the outer boundary of the i-th resource object.
- Step S542 Emit first rays from the object center of the i-th resource object to each first vertex on the outer boundary of the i-th resource object, and determine the relationship between each first ray and the outer boundary of the other resource objects. Each first nearest intersection point of the boundary.
- a first spatial search tree can be constructed based on the outer boundary information of other resource objects outside the i-th resource object, and the primitives on the first spatial search tree are connecting edges on the outer boundaries of other resource objects. , and then determine each first closest intersection point between each first ray and the outer boundary of other resource objects through the first spatial search tree.
- Step S543 based on the center coordinate of the object center, the first vertex coordinate of each first vertex and The first intersection point coordinates of each first nearest intersection point determine the first candidate expansion ratio corresponding to each first vertex.
- this step can be achieved by:
- Step S5431 Obtain the separation distance.
- the separation distance corresponds to the bleeding value in other embodiments.
- the separation distance can be preset or automatically determined based on the resolution of the binning space. For example, it can be assumed that one pixel is taken for every 128 pixels as the separation distance. , then 256*256 resolution usually uses 2 pixel values as the separation distance. In this way, the separation distance is automatically calculated and reserved according to the resolution of the binning space, which can effectively avoid errors that may be caused by manual binning and manual reservation of the separation distance.
- Step S5432 Determine the first target coordinates of the first target point corresponding to each first nearest intersection point based on the separation distance and the intersection coordinates of each first nearest intersection point.
- the first target point is a point on the first ray
- the distance between the first target point and the first nearest intersection point is the separation distance
- the first target point is between the first nearest intersection point and the center of the object.
- Step S5433 Determine the first distance corresponding to each first vertex based on the center coordinate of the object center and the first vertex coordinate of each first vertex.
- the first distance corresponding to each first vertex can be determined based on the distance formula.
- the first distance is the distance between the first vertex and the center of the object.
- Step S5434 Determine the second distance corresponding to each first vertex based on the center coordinate of the object center and the first target coordinate of each first target point.
- the second distance corresponding to each first vertex can be determined based on the distance formula.
- the second distance is the distance between the first target point and the center of the object.
- Step S5435 Determine the first candidate expansion ratio corresponding to each first vertex based on the first distance and the second distance corresponding to each first vertex.
- the first candidate expansion ratio corresponding to each first vertex is obtained by dividing the second distance corresponding to each first vertex by the first distance.
- Step S544 Emit second rays from each second vertex on the outer boundary of the other resource object to the object center of the i-th resource object, and determine the relationship between each second ray and the outer boundary of the i-th resource object. Each second nearest intersection point of the boundary.
- a second spatial search tree can be constructed based on the outer boundary information of the i-th resource object.
- the primitives on the second spatial search tree are connecting edges on the outer boundary of the i-th resource object, and then through The second spatial search tree determines each second closest intersection point of each second ray with the outer boundary of the other resource object.
- Step S545 Determine the second candidate expansion ratio corresponding to each second vertex based on the center coordinate of the object center, the second vertex coordinate of each second vertex, and the second intersection coordinate of each second nearest intersection point.
- the second target coordinates of the second target point corresponding to each second nearest intersection point are determined based on the separation distance and the intersection coordinates of each second nearest intersection point.
- the second target point is a point on the second ray
- the distance between the second target point and the second vertex is the separation distance
- the second target point is between the second vertex and the center of the object.
- determine the fifth distance corresponding to each second vertex based on the center coordinate of the object center and the intersection coordinate of each second nearest intersection point
- the two target coordinates determine the sixth distance corresponding to each second vertex; the sixth distance corresponding to each second vertex is divided by the corresponding fifth distance to obtain the second candidate expansion ratio corresponding to each second vertex.
- Step S546 Determine the minimum value among the plurality of first candidate expansion ratios and the plurality of second candidate expansion ratios as the first expansion ratio of the i-th resource object.
- step S541 to step S546 after determining that the i-th resource object is to be isotropically
- the two-way ray method is used. First, the first ray is emitted outward from the object center of the i-th resource object along the outer boundary vertex of the i-th resource object to obtain the i-th resource.
- the first closest intersection point outside the object with other resource objects and calculate the corresponding first candidate expansion ratio accordingly; then from the vertices of the outer boundaries of other resource objects outside the i-th resource object, towards the i-th resource object
- the center of the object emits a second ray to obtain the second closest intersection point with the outer boundary of the i-th resource object, and calculate the corresponding second candidate expansion ratio accordingly, and calculate the first candidate expansion ratio and the second candidate expansion ratio.
- a spacing distance is reserved, that is, some gaps are reserved, so as to avoid overlapping with other resource objects when the resource object is expanded.
- Step S55 Determine whether the i-th resource object contains other sub-resource objects.
- step S56 when it is determined that the i-th resource object contains other sub-resource objects based on the inclusion relationship information of the i-th resource object, step S56 is entered; when it is determined that the i-th resource object does not contain other sub-resource objects. When, enter step S57.
- Step S56 Expand the i-th resource object and other sub-resource objects contained in the i-th resource object according to the first expansion ratio to obtain the processed i-th resource object and the processed i-th resource object. Other sub-resource objects.
- the object center of the i-th resource object is used as the expansion center, and the i-th resource object and other sub-resource objects contained in the i-th resource object are expanded according to the first expansion ratio to obtain the processing.
- Step S57 Expand the i-th resource object according to the first expansion ratio to obtain the processed i-th resource object.
- the object center of the i-th resource object is used as the expansion center according to the An expansion ratio is used to perform isotropic expansion processing on the i-th resource object, and the processed i-th resource object is obtained.
- Step S58 Obtain the main axis information of the i-th resource object, and determine the rotation angle and the first rotation direction based on the main axis information of the i-th resource object.
- the main axis of the i-th resource object refers to the baseline with the largest width among multiple baselines passing through the object center of the i-th resource object.
- the main axis information of the i-th resource object is a kind of attribute information of the i-th resource object.
- the main axis information of the i-th resource object includes the angle between the main axis and the x-axis. After filling the i-th resource object into the target container Or when moving the i-th resource object, the spindle information of the i-th resource object will change. Assume that the main axis information of the i-th resource object is 45 degrees, then based on the main axis information, it can be determined that the rotation angle is 45 degrees, and the first rotation direction is clockwise.
- Step S59 Rotate the N resource objects by the rotation angle according to the first rotation direction to obtain rotated N resource objects.
- all N resource objects in the target container are rotated to ensure that the relative position between the i-th resource object and other resource objects remains unchanged.
- the main axis of the rotated i-th resource object is in the horizontal direction, that is, the main axis of the rotated i-th resource object is parallel to the x-axis.
- Step S510 Move the object center of the rotated i-th resource object to the center position of the corresponding available space.
- step S102 The implementation process of this step is similar to the implementation process of step S102, and the implementation process of step S102 can be referred to during implementation.
- Step S511 Determine the second expansion ratio of the rotated i-th resource object in each preset expansion direction.
- multiple candidate points corresponding to each expansion direction can be determined from the outer boundary of the rotated i-th resource object; third rays are emitted from each candidate point along each corresponding expansion direction to determine each of the i-th resource objects.
- Three shots The nearest intersection point between the line and the outer boundary of the other resource object is determined based on the nearest intersection point, and the second expansion ratio of the rotated i-th resource object in each expansion direction is determined.
- step S511 determining the second expansion ratio of the rotated i-th resource object in each preset expansion direction
- Step S5111 Obtain the outer boundary information of other resource objects located outside the rotated i-th resource object and the bounding box of the rotated i-th resource object.
- Step S5112 Determine multiple candidate points corresponding to the j-th expansion direction from the outer boundary of the rotated i-th resource object.
- the vertices of the outer boundary of the resource object are sorted in a counterclockwise direction, in some embodiments, if the j-th expansion direction is upward, then the starting point x coordinate on the outer boundary of the i-th resource object will be greater than the end point x coordinate.
- the connecting edges of are determined as candidate connecting edges, the vertices of the candidate connecting edges are determined as candidate points, and then the vertices on the outer boundary of other resource objects outside the i-th resource object are determined along the j-th expansion direction (that is, upward) Project in the opposite direction (that is, downward), and the points projected onto the candidate connection edges are also determined as candidate points in the j-th expansion direction.
- the connecting edge on the outer boundary of the i-th resource object whose starting point x coordinate is less than the end point x coordinate is determined as a candidate connecting edge, and the vertex of the candidate connecting edge is determined as a candidate point.
- the vertex of the candidate connecting edge is determined as a candidate point.
- the point of is also determined as a candidate point in the jth expansion direction.
- Step S5113 Emit third rays from each candidate point along the j-th expansion direction, and determine the third closest intersection point between each third ray and the outer boundary of the other resource object.
- a second spatial search tree can be constructed based on the outer boundary information of the i-th resource object.
- the primitives on the second spatial search tree are connecting edges on the outer boundary of the i-th resource object, and then through The second spatial search tree determines each third closest intersection point of each third ray with the outer boundary of the other resource object.
- Step S5114 Determine each third distance from each candidate point to the target edge of the bounding box, and determine each fourth distance from each third closest intersection point to the target edge.
- the target edge is an edge on the bounding box corresponding to the opposite direction of the j-th expansion direction. For example, if the j-th expansion direction is upward, then the target edge is the lower horizontal edge of the bounding box, and if the j-th expansion direction is to the left, then the target edge is the right vertical edge of the bounding box.
- Step S5115 Determine the third candidate expansion ratio corresponding to each candidate point based on each of the third distances and the corresponding fourth distances.
- the third candidate expansion ratio corresponding to each candidate point is obtained by dividing the fourth distance of each candidate point by the corresponding third distance.
- Step S5116 Determine the minimum value among the plurality of third candidate expansion ratios as the second expansion ratio corresponding to the j-th expansion direction.
- the outer boundary of the i-th resource object when determining the second expansion ratio in each expansion direction when anisotropically expanding the i-th resource object, the outer boundary of the i-th resource object can first be determined. Determine a plurality of candidate points corresponding to each expansion direction, then emit third rays from each candidate point to each expansion direction, determine the third closest intersection point between each third ray and the outer boundary of the other resource object, and determine the third ray according to the i-th The target edge, the third nearest intersection point and the candidate point corresponding to the opposite direction of each expansion direction on the bounding box of each resource object determine the second expansion ratio corresponding to each expansion direction. This can realize the expansion ratio of the i-th resource object in each expansion direction. for maximum expansion.
- Step S512 Determine whether the rotated i-th resource object contains other sub-resource objects.
- step S513 is entered; when it is determined that the rotated i-th resource object If no other resource objects are included, proceed to step S514.
- Step S513 Expand the rotated i-th resource object and other sub-resource objects contained in the rotated i-th resource object in the respective expansion directions according to their corresponding second expansion proportions, Get the expanded i-th resource object and other expanded sub-resource objects.
- the expansion direction can be At least one of the four directions of up, down, left, and right.
- the i-th resource object and the i-th resource object are The other included sub-resource objects are expanded in each expansion direction according to their corresponding second expansion proportions, and the expanded i-th resource object and the expanded other sub-resource objects are obtained.
- the horizontal edge below the bounding box of the i-th resource object is used as the reference (that is, the horizontal edge below remains unchanged), and the i-th resource object and the i-th resource are Other sub-resource objects contained in the object are expanded upward by the corresponding second expansion ratio.
- Step S514 Expand the rotated i-th resource object in each expansion direction according to the corresponding second expansion ratio to obtain the expanded i-th resource object.
- Step S515 Rotate the expanded i-th resource object and the expanded other sub-resource objects by the rotation angle according to the second rotation direction to obtain the processed i-th resource object and the processed other sub-resource objects.
- Resource object Rotate the expanded i-th resource object and the expanded other sub-resource objects by the rotation angle according to the second rotation direction to obtain the processed i-th resource object and the processed other sub-resource objects.
- the second rotation direction is the opposite direction of the first rotation direction.
- the N resource objects in the target container are rotated by the rotation angle in a direction opposite to the first rotation direction, thereby restoring the N resource objects in the target container to the posture before rotation.
- Step S516 Based on the extension type of the i-th resource object, determine the first reference extension ratio of the i-th resource object and the second reference extension ratio of the symmetric object.
- the extended type of the i-th resource object is the same as the extended type of its symmetric object.
- the expansion type of the i-th resource object is isotropic expansion
- a process similar to the following step S541 to step S546 can be used to determine the first reference expansion ratio of the i-th resource object. and the second reference expansion ratio of the symmetric object; if the expansion type of the i-th resource object is anisotropic expansion, then the first expansion ratio of the i-th resource object in each expansion direction can be determined with reference to the above steps S58 to S511. a reference expansion ratio and a second reference expansion ratio of the symmetrical object in each direction.
- Step S517 Determine the minimum value of the first reference expansion ratio and the second reference expansion ratio as the target expansion ratio of the i-th resource object and the symmetric object.
- the extension type of the i-th resource object is isotropic extension
- the i-th resource object and the symmetric object each correspond to a reference extension ratio
- the first reference extension ratio and at least one second reference extension The minimum value in the ratio is determined as the target expansion ratio of the i-th resource object and the symmetric object
- the expansion type of the i-th resource object is anisotropic expansion
- the i-th resource object and the symmetric object are in each expansion direction.
- Each of the above corresponds to a reference expansion ratio. Assuming that there are four expansion directions, namely up, down, left, and right, then determine the minimum value of the reference expansion ratio corresponding to the i-th resource object and the symmetric object in each expansion direction. Target expansion ratio for each expansion direction.
- Step S518 Expand the i-th resource object and the symmetric object according to the target expansion ratio to obtain the processed i-th resource object and the processed symmetric object.
- the i-th resource object and the symmetric object are expanded, and other resource objects If overlap occurs, restore the i-th resource object and symmetric object to before expansion.
- step S518 when extending the i-th resource object, different expansion methods can be performed based on whether the i-th resource object has a symmetric object and the extension type of the i-th resource, where the i-th resource object When there is no symmetric object, then it is directly extended based on the extension type of the i-th resource object.
- the i-th resource object and the i-th resource object can also be The sub-resource objects are expanded at the same time, which not only avoids the overlap between the i-th resource object and its internal sub-resource objects when it is expanded, but also expands multiple resource objects at the same time, thereby improving object processing efficiency; and when the i-th resource object has a symmetric object, it is necessary to determine the first reference expansion ratio of the i-th resource object and the second reference expansion ratio of the symmetric object, and take the minimum value as the target expansion ratio, thereby ensuring that the i-th resource Objects and symmetrical objects can remain the same size after expansion.
- the object processing method provided by the embodiment of the present application can be applied to the automatic 2UV expansion tool, and can realize the automation of 2UV expansion for a variety of game scene models with baking requirements, including character models, vehicle models, building models, etc.
- the terminal responds to the operation instruction for "model import" in the automatic 2UV unfolding tool, presents the model selection interface, and determines the target three-dimensional model data based on the model selection operation received through the model selection interface, and the terminal responds Based on the received UV unfolding operation command, the target 3D model is divided into patches through the automatic 2UV tool, thereby obtaining multiple two-dimensional UV islands (resource objects), and then the multiple UV islands are boxed to obtain the initial Bin the results, and determine the expansion type of each UV island based on the symmetry attribute information and containment relationship information of each UV island.
- the expansion type includes one of isotropic expansion and anisotropic expansion, based on the expansion of each UV island.
- Type expand each UV island to obtain each processed UV island.
- Each UV island in the original binning result is expanded, and the UV island is moved to the center position before expansion, so that the maximum proportion of expansion can be achieved in a limited space, thus minimizing free space. Thereby improving the filling rate of the target container.
- the final binning result is then used to map the three-dimensional model.
- the target UV island for mapping is determined.
- the terminal responds to the mapping operation for the target UV island and presents Multiple candidate map images of the target UV island, and then the terminal receives the map selection operation, determines the target map image based on the map selection operation, and performs map processing on the target UV island based on the target map image. Since the UV islands are expanded during the binning process, the resolution of the texture mapping can be increased when mapping each UV island in the 3D model.
- the corresponding algorithm is designed by analyzing the artificial practice of artists and refining the ideas contained in manual operations.
- each UV island will be moved so that the spacing between different UV islands is roughly the same; and then the different UV islands will be classified and expanded.
- the UV island with internal symmetry shown in the rectangular frame 8011 on the upper right side in order to maximize the use of the surrounding space, it will be stretched more in the vertical direction and slightly stretched in the horizontal direction, resulting in the following:
- Step S901 global equalization processing.
- all UV islands are globally homogenized so that the spacing between different UV islands is approximately the same.
- Step S902 Classification expansion.
- the UV island shown in Figure 9 only contains its outer boundaries and internal holes, but no longer contains the internal edges of the polygon area. This is because the internal edges of the region do not have any impact on the binning process and results. Therefore, in order to improve calculation efficiency, the outer contour of each UV island (including outer boundaries and internal holes) is first extracted, and only the outer contour of each UV island is considered in subsequent binning optimization.
- the UV island to be expanded may not be at the center of the gap where it is located, as shown by the UV islands in the two circles 1001 and 1002 in Figure 10 .
- This situation will cause its expansion to be affected.
- the principle of global homogenization processing is to imagine that there are "virtual springs" in the gaps between each UV island. Its elastic force will promote the movement of each UV island due to mutual repulsion, and finally achieve a force balance. Based on this idea, global homogenization processing can be implemented through the following steps:
- Step S9011 Define the maximum number of iterations P and the maximum number of moves Q of a single UV island according to the number of UV islands.
- P is a positive integer
- Q is a positive integer less than or equal to P.
- Step S9012 for each UV island, if it is determined that its cumulative number of moves is less than N, calculate the center point of the local gap where it is located, and move the UV island so that the center point of its bounding box coincides with the center point of the local gap, and update Its cumulative number of moves.
- Step S9013 if no UV island is moved in step S9012, the algorithm ends.
- Step S9014 update the current number of iterations. If it is determined that the maximum number of iterations M has been reached, the algorithm ends, otherwise, go to step S9012.
- AABB Tree axis-aligned bounding box
- Axis- Aligned Bounding Box Tree AABB Tree, Axis- Aligned Bounding Box Tree
- the AABB tree is a spatial search tree based on the K-tree principle, where each node represents a spatial bounding box of a geometric primitive. This data structure can quickly report whether the query primitive intersects with the primitives in the tree, as well as the specific intersection type, intersection position, etc. If the query element is a point, you can also query the nearest distance.
- edges of polygons are used to construct a spatial search tree.
- classification expansion can be achieved through the following steps:
- Step S9021 record the set of UV islands contained in the holes of each UV island
- Step S9022 Perform step S9023 on each UV island in positive order to obtain the sequential expansion result
- Step S9023 if the UV island currently to be expanded has internal symmetry characteristics, perform anisotropic expansion, otherwise perform isotropic expansion;
- Step S9024 if the filling rate of the sequential expansion result has met the requirements, the algorithm ends, otherwise, go to step S9025;
- Step S9025 Perform step 3) again for each UV island in reverse order to obtain the reverse order expansion result
- Step S9026 Compare the sequential expansion results and the reverse order expansion results, and select the one with the highest filling rate as the final expansion result.
- the reason why the set of UV islands contained in the holes of each UV is first recorded in step S9021 is because if the holes of the current UV island contain other UV islands, then during the expansion process, its internal UV The island also needs to be expanded simultaneously. This not only avoids overlapping with internal UV islands, but also improves expansion efficiency.
- the following describes the implementation process of anisotropic expansion and isotropic expansion.
- Anisotropic expansion allows UV islands to have different expansion ratios in different directions, so they can be expanded independently in different directions.
- the implementation process of anisotropic expansion may include the following steps:
- Step S231 Rotate all UV islands so that the main axis of the current UV island is parallel to the x-axis, and record the rotation angle.
- the rotation angle and direction when the main axis is rotated to be parallel to the x-axis can be determined through the main axis information of the current UV island, and then all UV islands are rotated so that the main axis of the current UV island is parallel to the x-axis.
- Step S232 Extract the boundary line segments of all UV islands outside the current UV island, and construct a corresponding spatial search tree T.
- Step S233 Move the current UV island to the center of its local gap.
- the center of the bounding box of the current UV island is moved to the center of the local gap corresponding to the current UV island.
- Step S234 Maximum expansion is performed along the four directions of up, down, left, and right through the following two steps:
- Step S235 Rotate all UV islands back to their original positions according to the rotation angle recorded in step S231.
- Figure 13 is a schematic diagram of the implementation process of anisotropic expansion provided by the embodiment of the present application.
- 1301 is part of the original binning result
- the UV island to be expanded is a rectangle in the center of 1301. Since the UV to be expanded The island has internal symmetry, so it expands anisotropically. It expands upward, downward, left, and right during implementation. As can be seen from 1302 in Figure 13, when expanding upward, it can be extended from the edge of the upper boundary of the rectangle.
- Isotropic expansion In order to avoid texture distortion, isotropic expansion is required for UV islands that do not have internal symmetry. In the embodiment of this application, the implementation process of isotropic expansion can be achieved through the following steps:
- Step S241 Extract all UV island boundaries outside the current UV island and construct a corresponding spatial search tree T 1 .
- Step S242 move the current UV island to its local gap center.
- Step S243 Extract the boundary of the current UV island and construct its corresponding spatial search tree T 2 .
- Step S244 use the two-way ray method to determine the maximum expansion ratio:
- Step S245 Calculate the smallest of all expansion ratios obtained in step S244 as the final expansion ratio, and then perform isotropic equal-proportion expansion on the current UV island and its internal islands.
- Figure 14 is a schematic diagram of the implementation process of isotropic expansion provided by the embodiment of the present application, wherein 1401 in Figure 14 is the original UV island to be expanded; 1402 is a part of the rays emitted outwards; 1403 is a part of the rays emitted inwards. ;1404 is the final expansion result. Since each ray shown in 1402 and 1403 corresponds to an expansion ratio, as long as you select the smallest expansion ratio corresponding to all rays and expand the current UV island accordingly, you can ensure that it will not interact with the surrounding UV Islands overlap. The expansion ratio at this time is also the maximum ratio that the UV island can expand without overlapping with other UV islands.
- Step S9021' record the set of UV islands contained in the holes of each UV island.
- Step S9022' extract symmetric UV islands, mark the set of symmetric UV islands as A, and mark the set of other asymmetric UV islands as B.
- Step S9023’ for each group of symmetric UV islands in set A, perform the following steps:
- step S9024' for each asymmetric UV island in set B, classification expansion is still performed according to the method provided in step S9023.
- step S9023' In this step, first determine whether the symmetric UV island of the current group has internal symmetry characteristics. If so, use an anisotropic method to calculate the maximum expansion ratio; otherwise, use an isotropic method to calculate the maximum expansion ratio. After calculating the maximum expansion ratio of all UV islands in the group, the smallest one is taken as the final expansion ratio to ensure that no overlap occurs to the greatest extent. However, the same group of symmetric UV islands may also be adjacent, so that they still overlap according to the minimum proportion. Therefore, it is necessary to check after the substantial expansion. Once an overlap is found, it will be restored to the original state and the expansion of the group of symmetric UV islands will be skipped. In this way, it is possible to ensure that the symmetrical UV island is The scale can be expanded to meet the specific needs of artists.
- the software module stored in the object processing device 455 of the memory 450 may include :
- the first acquisition module 4551 is configured to acquire the initial filling results of multiple resource objects to be processed in the target container;
- the first moving module 4552 is configured to move each resource object to the center position of its corresponding available space based on the initial filling result
- the second acquisition module 4553 is configured to acquire the symmetric attribute information and inclusion relationship information of each resource object
- the first determination module 4554 is configured to determine the extension type of each resource object based on the symmetric attribute information and the inclusion relationship information of each resource object, wherein the extension type includes isotropic extension and anisotropic extension. A sort of;
- the first expansion module 4555 is configured to perform expansion processing on each resource object based on the extension type of each resource object, and obtain each processed resource object.
- the first mobile module is further configured to:
- movement information is determined to move the object center of the i-th resource object to the center position of the available space where the i-th resource object is located.
- the device further includes:
- the first update module is configured to update the current movement iteration number after completing the current movement iteration process from the 1st resource object to the Nth resource object, and obtain the updated current movement iteration number;
- the second moving module is configured to continue moving the first resource object to the Nth resource object when it is determined that the updated current number of moving iterations is less than the threshold number of moving iterations.
- the first determining module is further configured to:
- the first determining module is further configured to:
- the expansion type of the i-th resource object is isotropic expansion.
- the first determining module is further configured to:
- extension type of the parent resource object is isotropic extension
- the first determining module is further configured to:
- extension type of the parent resource object is anisotropic extension, obtain other child resource objects contained in the parent resource object;
- the expansion type of the i-th resource object is anisotropic expansion
- the expansion type of the i-th resource object is isotropic expansion.
- the first expansion module is also configured to:
- the i-th resource object and the sub-resource objects contained in the i-th resource object are Other sub-resource objects perform expansion processing on the i-th resource object and other sub-resource objects included in the i-th resource object according to the first expansion ratio to obtain the processed i-th resource object and the processed other sub-resource objects after.
- the first expansion module is also configured to:
- the second vertex coordinates of each second vertex, and the second intersection coordinates of each second nearest intersection point determine the second candidate expansion ratio corresponding to each second vertex
- the minimum value among the plurality of first candidate expansion ratios and the plurality of second candidate expansion ratios is determined as the first expansion ratio of the i-th resource object.
- the first expansion module is also configured to:
- a first candidate expansion ratio corresponding to each first vertex is determined.
- the first expansion module is also configured to:
- the expansion type of the i-th resource object is anisotropic expansion
- the rotated i-th resource object contains other sub-resource objects based on the inclusion relationship information of the rotated i-th resource object
- the rotated i-th resource object and the Other sub-resource objects included in the rotated i-th resource object are expanded in each expansion direction according to their corresponding second expansion ratios, and the expanded i-th resource object and the expanded other sub-resources are obtained.
- the second rotation direction is the opposite direction of the first rotation direction.
- the first expansion module is also configured to:
- the minimum value among the plurality of third candidate expansion ratios is determined as the second expansion ratio of the j-th expansion direction.
- the device further includes:
- the second determination module is configured to determine the first reference of the i-th resource object based on the extension type of the i-th resource object when it is determined that the symmetric object of the i-th resource object exists in the target container. an expansion ratio and a second reference expansion ratio of said symmetrical object;
- a third determination module configured to determine the minimum value of the first reference expansion ratio and the second reference expansion ratio as the target expansion ratio of the i-th resource object and the symmetric object;
- the second expansion module is configured to expand the i-th resource object and the symmetric object according to the target expansion ratio to obtain the processed i-th resource object and the processed symmetric object.
- the device further includes:
- the fourth determination module is configured to determine the first filling rate of the target container after performing expansion processing on the 1st to Nth resource objects;
- the third expansion module is configured to, when it is determined that the first filling rate is less than the preset filling rate threshold, sequentially expand the Nth resource object to the 1st resource object according to their respective corresponding expansion types to obtain the second The Nth resource object to the 1st resource object after processing;
- a fifth determination module configured to determine a second filling rate of the target container
- the sixth determination module is configured to determine the Nth to 1st resource objects after the second processing as target expansion results when the second filling rate is greater than the first filling rate.
- Embodiments of the present application provide a computer program product or computer program.
- the computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium.
- the processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the object processing method described above in the embodiment of the present application.
- Embodiments of the present application provide a computer-readable storage medium storing executable instructions.
- the executable instructions are stored therein.
- the executable instructions When executed by a processor, they will cause the processor to execute the object processing method provided by the embodiments of the present application. For example, the object processing methods shown in FIG. 4A, FIG. 4B, FIG. 5 and FIG. 6.
- the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; it may also include one or any combination of the above memories.
- Various equipment may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; it may also include one or any combination of the above memories.
- Various equipment may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; it may also include one or any combination of the above memories.
- executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and their May be deployed in any form, including deployed as a stand-alone program or deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.
- executable instructions may, but do not necessarily correspond to, files in a file system and may be stored as part of a file holding other programs or data, for example, in a HyperText Markup Language (HTML) document. in one or more scripts, stored in a single file specific to the program in question, or in multiple collaborative files (e.g., files storing one or more modules, subroutines, or portions of code).
- HTML HyperText Markup Language
- executable instructions may be deployed to execute on one computing device, or on multiple computing devices located at one location, or alternatively, on multiple computing devices distributed across multiple locations and interconnected by a communications network execute on.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Software Systems (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computer Graphics (AREA)
- Geometry (AREA)
- Mathematical Analysis (AREA)
- Evolutionary Computation (AREA)
- Computer Hardware Design (AREA)
- Pure & Applied Mathematics (AREA)
- Mathematical Optimization (AREA)
- Computational Mathematics (AREA)
- Processing Or Creating Images (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
本申请提供了一种对象处理方法、装置、设备、计算机可读存储介质及计算机程序产品;方法包括:获取待处理的多个资源对象在目标容器中的初始填充结果;基于所述初始填充结果,将各个资源对象移动至各自对应的可用空间的中心位置;获取所述各个资源对象的对称属性信息和包含关系信息;基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,其中,所述扩展类型包括各向同性扩展和各向异性扩展中的一种;基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象。
Description
相关申请的交叉引用
本申请基于申请号为202210684708.8、申请日为2022年6月17日的中国专利申请提出,并要求以上中国专利申请的优先权,以上中国专利申请的全部内容在此引入本申请作为参考。
本申请涉及计算机技术领域,尤其涉及一种对象处理方法、装置、设备、计算机可读存储介质及计算机程序产品。
多边形模型是计算机图形中最流行、最重要,且得到最广泛支持的模型表示方法。而二维装箱的基本过程是:依次将每个多边形按照某种规则放入容器;每次放入之后更新容器的可放置区域,然后再放置下一个多边形,直到所有多边形已放入或者容器已满。图1给出了装箱过程的一个中间状态,其中左侧是尚未放置的多边形,右侧是已被放置好的多边形以及容器的剩余空间。装箱问题不仅在学术界得到了广泛研究,其成果在工业界也得到了大量应用。已有相关技术提供的装箱算法在得到装箱结果之后,往往会存在较大的空隙,即便进行进一步的优化仅仅是对部分多边形进行扩展,或者对所有多边形进行同类型的扩展,装箱填充率的提升效果有限,无法超越人工装箱优化效果。
发明内容
本申请实施例提供一种对象处理方法、装置、计算机可读存储介质及计算机程序产品,能够提高目标容器中资源对象的填充率。
本申请实施例的技术方案是这样实现的:
本申请实施例提供一种对象处理方法,应用于贴图渲染场景,所述方法应用于计算机设备,包括:
获取待处理的多个资源对象在目标容器中的初始填充结果;
基于所述初始填充结果,将各个资源对象移动至各自对应的可用空间的中心位置;
获取所述各个资源对象的对称属性信息和包含关系信息;
基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,其中,所述扩展类型包括各向同性扩展和各向异性扩展中的一种;
基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象。
本申请实施例提供一种对象处理装置,包括:
第一获取模块,配置为获取待处理的多个资源对象在目标容器中的初始填充结果;
第一移动模块,配置为基于所述初始填充结果,将各个资源对象移动至各自对应的可用空间的中心位置;
第二获取模块,配置为获取所述各个资源对象的对称属性信息和包含关系信息;
第一确定模块,配置为基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,其中,所述扩展类型包括各向同性扩展和各向异性扩展中的一种;
第一扩展模块,配置为基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象。
本申请实施例提供一种装置,包括:
存储器,用于存储可执行指令;
处理器,用于执行所述存储器中存储的可执行指令时,实现本申请实施例提供的对象处理方法。
本申请实施例提供一种计算机可读存储介质,存储有可执行指令,用于引起处理器执行时,实现本申请实施例提供的对象处理方法。
本申请实施例提供一种计算机程序产品,包括计算机程序或指令,所述计算机程序或指令被处理器执行时实现本申请实施例提供的对象处理方法。
本申请实施例具有以下有益效果:
在本申请实施例提供的对象处理方法中,在获取待处理的多个资源对象的初始填充结果之后,首先基于该初始填充结果进行全局均匀化处理,以将各个资源对象移动至各自对应的可用空间的中心位置;然后再获取所述各个资源对象的对称属性信息和包含关系信息,并基于资源对象的对称属性信息和包含关系信息确定各个资源对象的扩展类型,最后基于各个资源对象的扩展类型进行扩展处理,得到处理后的各个资源对象,由于是对目标容器中的每个资源对象都进行了扩展,并且在扩展之前将资源对象移动至中心位置,从而能够在有限的空间内实现最大比例的扩展,而且资源对象的扩展类型是基于资源对象的对称属性信息和包含信息自适应确定出的,其中扩展类型包括各向同性扩展和各向异性扩展,相较于相关技术中仅能够对资源对象进行各向同性扩展,在本申请实施例中,对于只能够进行各向同性扩展的资源对象进行各向同性扩展,但是对于能够进行各向异性扩展的资源对象通过各向异性扩展能够实现对资源对象最大程度上的扩展,如此能够模拟出人工装箱调整的效果,进而最大限度的提高填充率。
图1为装箱问题的示意图;
图2是本申请实施例提供的对象处理系统100的架构示意图;
图3是本申请实施例提供的第二终端400的结构示意图;
图4A是本申请实施例提供的对象处理方法的一种实现流程示意图;
图4B是本申请实施例提供的对象处理方法的另一种实现流程示意图
图5是本申请实施例提供的将各个资源对象移动至对应可用空间中心的实现流程示意图;
图6是本申请实施例提供的将所述第一目标对象移动至第一目标可用空间的实现流程示意图;
图7是人工修改装箱结果的示意图;
图8是本申请实施例提供的多边形分类扩展的示意图;
图9是本申请实施例提供的对象处理方法的再一种实现过程示意图;
图10是本申请实施例提供的UV岛不处于局部扩展空隙中心的示意图;
图11是本申请实施例提供的各向异性扩展的示意图;
图12为本申请实施例提供的各向同性扩展的示意图;
图13为本申请实施例提供的各向异性扩展的实现过程示意图;
图14为本申请实施例提供的各向同性扩展的实现过程示意图;
图15为本申请实施例提供的小中大规模UV岛扩展前后的装箱效果对比图。
为了使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请作进一步地详细描述,所描述的实施例不应视为对本申请的限制,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。
在以下的描述中,涉及到“一些实施例”,其描述了所有可能实施例的子集,但是可以理解,“一些实施例”可以是所有可能实施例的相同子集或不同子集,并且可以在不冲突的情况下相互结合。
在以下的描述中,所涉及的术语“第一/第二/第三”仅仅是是区别类似的对象,不代表针对对象的特定排序,可以理解地,“第一/第二/第三”在允许的情况下可以互换特定的顺序或先后次序,以使这里描述的本申请实施例能够以除了在这里图示或描述的以外的顺序实施。
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。
对本申请实施例进行进一步详细说明之前,对本申请实施例中涉及的名词和术语进行说明,本申请实施例中涉及的名词和术语适用于如下的解释。
1)装箱问题(Packing Problem),一般意义上的装箱问题是指将一组规则或者不规则的二维或者三维物体,按照某种规则排列在一个给定的规则或者不规则容器中,从而达到特定目的。本申请实施例所涉及的装箱问题聚焦于将二维不规则多边形装箱在一个二维容器中,如图1所示。在美术制作术语中,也将待装箱的二维不规则多边形称为UV岛,在本申请实施例中,将二维不规则多边形称为资源对象。
2)非拟合多边形(NFP,No Fit Polygon),是指一个多边形B沿着另外一个多边形A的内壁进行滑动时,其边界上的某个参考点的轨迹所形成的多边形。NFP定义了对多边形B在多边形A所定义的区域内进行装箱时,该参考点被放置的可行区域。
3)闵可夫斯基和(Minkowski Sum),给定向量集合A和B,定义它们的闵可夫斯基和为A+B={a+b|a∈A,b∈B}。
4)遗传算法(GM,Genetic Algorithm),是模拟达尔文生物进化论的自然选择和遗传学机理的生物进化过程的计算模型,是一种通过模拟自然进化过程搜索最优解的方法。该算法通过数学的方式,利用计算机仿真运算,将问题的求解过程转换成类似生物进化中的染色体基因的交叉、变异等过程。在求解较为复杂的组合优化问题时,相对一些常规的优化算法,通常能够较快地获得较好的优化结果。
5)空间搜索树(AABB Tree):一种基于K-d树原理实现的空间搜索树,其每个节点代表一个三维几何图元的空间包围盒。该数据结构可以快速报告查询图元是否与树中的图元相交,以及具体的相交类型、相交位置等。
6)出血值(Padding):装箱问题中的美术专业用语,指装箱过程中对UV岛间进行间距保护使之留有一定空隙。一般UV岛装箱中常用的做法是根据装箱空间分辨率,每128个像素取一个像素作为出血值,例如256*256分辨率通常采用2个像素值作为出血值。
为了更好地理解本申请实施例提供的用于装箱优化的对象处理方法,首先对相关技术中的装箱算法进行说明。
在相关技术中,常用的装箱算法有基于NFP和最低重心的方法,在实现时,依次为每个待放置的多边形确定多个候选角度以及依据候选角度确定多个候选位置,按照重心最低的候选位置放置相应多边形。按照这种装箱方法放置后,容器中会存在较大空隙,因此填充率较低。
在相关技术中,提出一种针对已有装箱结果进行位置优化以提升填充率的方案。通过迭代地将一些UV岛进行各向同性扩展并且放入更大的空隙中,来逐步提高整个装箱的填充率。这种方法通过近似均匀地扩大已装箱的UV岛并优化它们的位置,可以使得装箱效果得到大幅提升。但是它依然无法最大限度地提高填充率,其原因有二:1)UV岛只有在进行位置更新的时候才可以进行等比例扩大,这样就限制了对没有进行位置更新的UV岛的扩展;2)对于部分允许进行各向异性扩展的UV岛,该算法并不支持,从而影响了填充率的进一步提升。
基于此,本申请实施例提供一种对象处理方法、装置、设备、计算机可读存储介质及计算机程序产品,可以在保持资源对象各向同性/各向异性特征的前提下,最大限度地提高装箱利用率,从而满足特定需求。下面说明本申请实施例提供的计算机设备的示例性应用,本申请实施例提供的设备可以实施为笔记本电脑,平板电脑,台式计算机,机顶盒,移动设备(例如,移动电话,便携式音乐播放器,个人数字助理,专用消息设备,便携式游戏设备)等各种类型的用户终端,也可以实施为服务器。下面,将说明设备实施为终端时示例性应用。
参见图2,图2是本申请实施例提供的对象处理系统100的架构示意图,如图2所示,该系统包括第一终端200、网络300和第二终端400,其中,第一终端200和第二终端400通过网络建立有通信连接,网络300可以是广域网或者局域网,又或者是二者的组合。
用户可以利用第一终端200完成虚拟对象的三维模型设计,该虚拟对象可以是游戏场景中的虚拟对象,还可以是虚拟现实场景或者增强现实场景中的虚拟对象,例如可以是虚拟人物,虚拟建筑物,以及虚拟植物等,而显示在虚拟场景中的虚拟对象是通过纹理映射技术(Texture Mapping)对该虚拟对象的三维模型进行纹理贴图后得到的,从而可提升显示在游戏画面中的虚拟对象的真实性和生动性。在本申请实施例中,第一终端200在完成对虚拟对象的三维模型设计后,将三维模型数据发送至第二终端400,第二终端400可以对虚拟对象的三维模型进行面片剖分,得到二维的资源对象(在一些实施例中,可以称为UV岛或者多边形),然后在对二维的资源对象进行装箱处理。在实现时可以对二维的资源对象进行装箱处理,从而得到初始填充结果,该初始填充结果可以是利用预设的装箱算法对多个资源对象进行装箱处理得到的,还可以是在利用预设的装箱算法对多个资源对象进行装箱处理后,再对得到的装箱结果进行进一步的全局优化得到的,在本申请实施例中,在获取到初始填充结果后,基于所述初始填充结果,将各个资源对象移动至各自对应的可用空间的中心位置;然后再通过各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,其中,所述扩展类型包括各向同性扩展和各向异性扩展中的一种,之后是基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象,由于第一目标对象占用的空间小于该最大空隙,并且将第一目标对象移动之后进行了放大处理,从而使得容器的总空余空间变小,提升填充率。
在一些实施例中,第一终端200和第二终端400可以是同一个终端,也即通过同一个终端完成对象设计和纹理渲染功能。在一些实施例中,第二终端400还可以是从服务
器中获取待渲染的三维虚拟对象,然后第二终端400对三维虚拟对象进行面片剖分,得到多个二维的资源对象,并将多个资源对象进行装箱处理以及全局优化处理,从而提高填充率。
这里的服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN、以及大数据和人工智能平台等基础云计算服务的云服务器。第一终端200和第二终端400可以是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表、车载智能终端等,但并不局限于此。终端以及服务器可以通过有线或无线通信方式进行直接或间接地连接,本申请实施例中不做限制。
参见图3,图3是本申请实施例提供的第二终端400的结构示意图,图3所示的第二终端400包括:至少一个处理器410、存储器450、至少一个网络接口420和用户接口430。终端400中的各个组件通过总线系统440耦合在一起。可理解,总线系统440用于实现这些组件之间的连接通信。总线系统440除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,在图3中将各种总线都标为总线系统440。
处理器410可以是一种集成电路芯片,具有信号的处理能力,例如通用处理器、数字信号处理器(DSP,Digital Signal Processor),或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等,其中,通用处理器可以是微处理器或者任何常规的处理器等。
用户接口430包括使得能够呈现媒体内容的一个或多个输出装置431,包括一个或多个扬声器和/或一个或多个视觉显示屏。用户接口430还包括一个或多个输入装置432,包括有助于用户输入的用户接口部件,比如键盘、鼠标、麦克风、触屏显示屏、摄像头、其他输入按钮和控件。
存储器450可以是可移除的,不可移除的或其组合。示例性的硬件设备包括固态存储器,硬盘驱动器,光盘驱动器等。存储器450可选地包括在物理位置上远离处理器410的一个或多个存储设备。
存储器450包括易失性存储器或非易失性存储器,也可包括易失性和非易失性存储器两者。非易失性存储器可以是只读存储器(ROM,Read Only Memory),易失性存储器可以是随机存取存储器(RAM,Random Access Memory)。本申请实施例描述的存储器450旨在包括任意适合类型的存储器。
在一些实施例中,存储器450能够存储数据以支持各种操作,这些数据的示例包括程序、模块和数据结构或者其子集或超集,下面示例性说明。
操作系统451,包括用于处理各种基本系统服务和执行硬件相关任务的系统程序,例如框架层、核心库层、驱动层等,用于实现各种基础业务以及处理基于硬件的任务;
网络通信模块452,用于经由一个或多个(有线或无线)网络接口420到达其他计算设备,示例性的网络接口420包括:蓝牙、无线相容性认证(WiFi)、和通用串行总线(USB,Universal Serial Bus)等;
呈现模块453,用于经由一个或多个与用户接口430相关联的输出装置431(例如,显示屏、扬声器等)使得能够呈现信息(例如,用于操作外围设备和显示内容和信息的用户接口);
输入处理模块454,用于对一个或多个来自一个或多个输入装置432之一的一个或多个用户输入或互动进行检测以及翻译所检测的输入或互动。
在一些实施例中,本申请实施例提供的装置可以采用软件方式实现,图3示出了存
储在存储器450中的对象处理装置455,其可以是程序和插件等形式的软件,包括以下软件模块:第一获取模块4551、第一移动模块4552、第二获取模块4553、第一确定模块4554和第一扩展模块4555,这些模块是逻辑上的,因此根据所实现的功能可以进行任意的组合或进一步拆分。将在下文中说明各个模块的功能。
在另一些实施例中,本申请实施例提供的装置可以采用硬件方式实现,作为示例,本申请实施例提供的装置可以是采用硬件译码处理器形式的处理器,其被编程以执行本申请实施例提供的对象处理方法,例如,硬件译码处理器形式的处理器可以采用一个或多个应用专用集成电路(ASIC,Application Specific Integrated Circuit)、DSP、可编程逻辑器件(PLD,Programmable Logic Device)、复杂可编程逻辑器件(CPLD,Complex Programmable Logic Device)、现场可编程门阵列(FPGA,Field-Programmable Gate Array)或其他电子元件。
将结合本申请实施例提供的终端的示例性应用和实施,说明本申请实施例提供的对象处理方法。
本申请实施例提供一种对象处理方法,应用于计算机设备,该计算机设备可以是终端也可以是服务器,在本申请实施例中,以计算机设备为终端为例进行说明。图4A是本申请实施例提供的对象处理方法的一种实现流程示意图,以下将结合图4A对本申请实施例提供的对象处理方法进行说明。
步骤S101,获取待处理的多个资源对象在目标容器中的初始填充结果。
这里,多个资源对象可以是指两个或两个以上资源对象,在本申请实施例中,资源对象可以是对虚拟对象的三维模型进行剖分得到的二维多边形(下述简称为多边形),该多边形可以是带孔洞的多边形,也可以是不带孔洞的多边形。在一些实施例中,该资源对象可以是游戏制作行业中的UV岛,其中,UV岛的本质即为上述的多边形。另外,该资源对象还可以是对实际对象进行展开及分块处理后得到的。目标容器用于承载资源对象,该目标容器也可以为形状为多边形的二维物体。
作为示例,初始填充结果可以是利用预设的装箱算法,将待处理的多个资源对象依次添加到目标容器得到的。例如可以利用基于NFP+遗传算法的装箱算法、基于NFP和最低重心原则的自动装箱算法等等。另外,初始填充结果还可以是对利用预设的装箱算法确定出的装箱结果进行全局位置优化之后得到的。初始填充结果可以包括各个资源对象的中心点所在的位置,还可以包括各个资源对象的外轮廓顶点的位置信息、目标容器的空余位置等。
步骤S102,基于所述初始填充结果,将各个资源对象的对象中心移动至各自对应的可用空间的中心位置。
在一些实施例中,可以根据初始填充结果依次确定将各个资源对象的对象中心移动至所述第i个资源对象所在可用空间的中心位置的移动信息,并在基于所述移动信息,确定所述第i个资源对象的移动距离大于预设的距离阈值时,将所述第i个资源对象的对象中心移动至所述可用空间的中心位置。
步骤S103,获取所述各个资源对象的对称属性信息和包含关系信息。
资源对象的对称属性信息可以包括资源对象的左右对称属性信息和上下对称属性信息。左右对称属性信息能够表征资源对象是否为左右对称的,上下对称属性信息能够表征资源对象是否为上下对称的。在判断资源对象是否为左右对称时,将资源对象以经过资源对象的对象中心点且垂直于x轴的竖直中心线为分割线进行划分,得到左右两个部分,并确定左右两部分的重合率,如果两者重合率大于预设的重合阈值(例如90%),则确定该资源对象是左右对称的。判断资源对象是否为上下对称的实现过程与上述过程是类似的。
每个资源对象的包含关系信息可以包括第一对象集合和第二对象集合,其中,第一对象集合中包括的是该资源对象所包含的资源对象的对象标识,第二对象集合中包括的是包含该资源对象的其他资源对象的对象标识。
判断第i个资源对象是否包含第p个资源对象在实现时,可以首先获取第i个资源对象的各个孔洞信息。在本申请实施例中,资源对象可以是二维多边形,当一个二维多边形内部包含有其他多边形时,被包含的多边形可以称为是该二维多边形的孔洞。资源对象的各个孔洞信息可以包括孔洞上的各个顶点名称、顶点位置以及顶点之间的连接关系。然后再从第p个资源对象的外边界上随机确定一个参考点,判断所述参考点是否位于第i个资源对象中的孔洞内部。作为示例,可以利用CGAL提供的库函数检查该参考点是否在第i个资源对象中的孔洞内部。在一些实施例中,依次判断该参考点是否位于第i个资源对象中的各个孔洞内部,如果该参考点不位于第i个资源对象中所有孔洞内部,那么确定该参考点不位于第i个资源对象中的孔洞内部,确定第i个资源对象不包含第p个资源对象;如果该参考点位于第i个资源对象中某个孔洞内部,则确定该参考点位于第i个资源对象中孔洞内部,确定所述第i个资源对象包含第p个资源对象。
步骤S104,基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型。
其中,所述扩展类型包括各向同性扩展和各向异性扩展中的一种,各向同性扩展是指资源对象在各个方向的扩展比例是相同的,各向异性扩展是指资源对象在不同方向的扩展比例可以是相同的,也可以是不同的。
在一些实施例中,可以首先判断资源对象是否具备内部对称特征,当该资源对象不具备内部对称特征时,可以将该资源对象的扩展类型确定为各向同性扩展,如果该资源对象还包含有其他子资源对象,那么其他子资源对象的扩展类型也为各向同性扩展;当资源对象具备内部对称特征时,确定该资源对象是否被父资源对象包含,如果未被父资源对象包含,那么确定该资源对象的扩展类型为各向异性扩展;如果被其他父资源对象包含,如果其父资源对象的扩展类型为各向同性扩展,那么该资源对象也为各向同性扩展;如果其父资源对象的扩展类型为各向异性扩展,那么还需要确定其兄弟资源对象的是否具备内部对称特征,如果其兄弟资源对象均具备内部对称特征,确定该资源对象和其兄弟资源对象的扩展类型为各向异性扩展;如果存在至少一个不具备内部对称特征的兄弟资源对象,则确定该资源对象和其兄弟资源对象的扩展类型为各向同性扩展。
步骤S105,基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象。
在一些实施例中,如果资源对象的扩展类型为各向同性扩展,首先确定出资源对象的第一扩展比例,确定该资源对象不包含其他子资源对象时,按照第一扩展比例对该资源对象进行扩展,得到扩展后的资源对象;如果该资源对象包含其他子资源对象时,那么其他子资源对象的扩展类型也为各向同性扩展,此时会对该资源对象和该资源对象包含的子资源对象同时按照第一扩展比例进行扩展,如此不仅可以避免该资源对象和其包含的子资源对象发生交叠,而且可以提高扩展效率。如果资源对象的扩展类型为各向异性扩展,那么确定资源对象在各个扩展方向的第二扩展比例,如果该资源对象不包含其他子资源对象,那么将该资源对象在各个扩展方向上按照对应的第二扩展比例进行扩展即可,如果该资源对象包含其他子资源对象,且其他子资源对象的扩展类型也为各向异性扩展时,那么将该资源对象和其子资源对象在各个扩展方向上按照对应的第二扩展比例同时进行扩展,从而提高扩展比例;如果该资源对象包含的子资源对象的扩展类型不为各向异性扩展时,那么则不能同时扩展该资源对象和子资源对象,从而避免该资源对象和子资源对象产生重叠。
在本申请实施例提供的对象处理方法中,在获取待处理的多个资源对象的初始填充结果之后,首先基于该初始填充结果进行全局均匀化处理,以将各个资源对象移动至各自对应的可用空间的中心位置;然后再获取所述各个资源对象的对称属性信息和包含关系信息,并基于资源对象的对称属性信息和包含关系信息确定各个资源对象的扩展类型,最后基于各个资源对象的扩展类型进行扩展处理,得到处理后的各个资源对象,由于是对目标容器中的每个资源对象都进行了扩展,并且在扩展之前将资源对象移动至中心位置,从而能够在有限的空间内实现最大比例的扩展,而且资源对象的扩展类型是基于资源对象的对称属性信息和包含信息自适应确定出的,其中扩展类型包括各向同性扩展和各向异性扩展,相较于相关技术中仅能够对资源对象进行各向同性扩展,在本申请实施例中,对于只能够进行各向同性扩展的资源对象进行各向同性扩展,但是对于能够进行各向异性扩展的资源对象通过各向异性扩展能够实现对资源对象最大程度上的扩展,如此能够模拟出人工装箱调整的效果,进而最大限度的提高填充率。
在一些实施例中,在步骤S105之后,为了再进一步确定步骤S105得到的扩展结果是否已经达到预期的填充率,是否还具有更优的扩展结果,如图4B所示,还可以执行下述的步骤S106至S112:
步骤S106,在对第1个至第N个资源对象进行扩展处理后,确定所述目标容器的第一填充率。
步骤S105中是按照资源对象的标识,从第1个资源对象到第N个资源对象进行顺序扩展的,在扩展之后,可以基于目标容器的总容量和扩展后的各个资源对象已占用的空间,确定出目标容器的第一填充率,也即将各个资源对象已占用的空间求和,得到已占用总空间,再将已占用总空间除以目标容器的总容量即得到第一填充率。
步骤S107,确定第一填充率是否小于预设的填充率阈值。
其中,当确定所述第一填充率小于预设的填充率阈值时,进入步骤S108;当确定第一填充率大于或者等于该填充率阈值时,说明已经达到预期的扩展效果,此时进入步骤S112。
步骤S108,依次对第N个资源对象至第1个资源对象按照各自对应的扩展类型进行扩展处理,得到第二次处理后的第N个资源对象至第1个资源对象。
在该步骤中,将初始填充结果中的各个资源对象按照倒序,从第N个资源对象至第1个资源对象依次基于各自对象的扩展类型进行扩展处理,得到第二次处理后的第N个资源对象至第1个资源对象。
需要说明的是,在倒序对资源对象进行扩展处理时,对于单个资源对象来说,扩展过程与顺序对资源对象进行扩展处理的实现方式是类似的,只是处理顺序不同。
步骤S109,确定所述目标容器的第二填充率。
步骤S109的实现过程与步骤S106确定第一填充率的实现过程是类似的,步骤S109在实现时,可参考步骤S106的实现过程。
步骤S110,判断第二填充率是否大于第一填充率。
其中,当所述第二填充率大于所述第一填充率时,说明经过步骤S108的再次扩展处理,提高了目标容器的填充率,此时进入步骤S111;当第二填充率小于或者等于第一填充率时,说明经过步骤S108的再次扩展处理,并没有提高目标容器的填充率,此时进入步骤S112。
步骤S111,将所述第二次处理后的第N个资源对象至第1个资源对象确定为目标扩展结果。
步骤S112,将处理后的第1个资源对象至第N个资源对象确定为目标扩展结果。
在本申请实施例中,在顺序对目标容器中的各个资源对象进行扩展之后,通过上述
步骤S106至步骤S112,在确定目标容器的第一填充率未达到预设的填充率阈值时,按照倒序对目标容器中的各个资源对象进行扩展,并得到第二填充率,最终将第一填充率和第二填充率中的较大值对应的扩展结果确定为目标扩展结果,从而能够进一步提升目标容器的填充率。
在一些实施例中,上述步骤S102“基于所述初始填充结果,将各个资源对象的对象中心移动至各自对应的可用空间的中心位置”可以通过如图5所示的步骤S21至步骤S212实现,以下结合图5对各个步骤进行说明。
步骤S21,获取预设的移动迭代次数阈值和单个资源对象的移动次数阈值。
其中,移动迭代次数阈值是大于或者等于单个资源对象的移动次数阈值的,移动迭代次数阈值和移动次数阈值可以是根据资源对象总数确定的,还可以是用户根据自身需求自行设定的。
步骤S22,获取当前移动迭代次数。
在本申请实施例中,可以设定当前移动迭代次数变量,初始值为0,每完成第1个资源对象至第N个资源对象的一轮移动之后,当前移动迭代次数加1。
步骤S23,判断当前移动迭代次数是否小于移动迭代次数阈值。
其中,当所述当前移动迭代次数小于所述移动迭代次数阈值时,进入步骤S24;当前移动迭代次数大于或者等于该移动迭代次数阈值时,进入步骤S103。
步骤S24,获取第i个资源对象的当前移动次数。
i=1,2,…N,N为资源对象总数,N为大于2的整数。
步骤S25,判断第i个资源对象的当前移动次数是否小于移动次数阈值。
其中,当所述第i个资源对象的当前移动次数小于所述移动次数阈值时,进入步骤S26,当第i个资源对象的当前移动次数大于或者等于移动次数阈值时,进入步骤S29。
步骤S26,确定将所述第i个资源对象的对象中心移动至所述第i个资源对象所在可用空间的中心位置的移动信息。
在本申请实施例中,第i个资源对象的对象中心可以用第i个资源对象对应的包围盒中心来表征,其中,第i个资源对象的包围盒可以是第i个资源对象的坐标轴对齐包围盒,也可以是第i个资源对象的紧致包围盒,资源对象的包围盒一般为矩形,包围盒中心为矩形的两个对角线的交点。
在一些实施例中,可以将第i个资源对象沿x轴分别向左、向右移动,确定向左移动到与其他资源对象接触时的向左移动量,确定向右移动到与其他资源对象接触时的向右移动量,按照(向右移动量-向左移动量)/2计算出第i个资源对象在x轴方向的移动信息。移动信息可以包括移动量和移动方向,其中,(向右移动量-向左移动量)/2的绝对值表征移动量,(向右移动量-向左移动量)/2的正负表征移动方向,正表示向右移动,负表示向左移动。同样地,将第i个资源对象沿y轴分别向上、向下移动,确定向上移动到与其他资源对象接触时的向上移动量,确定向下移动到与其他资源对象接触时的向下移动量,按照(向上移动量-向下移动量)/2计算出第i个资源对象在y轴方向的移动信息。
举例来说,第i个资源对象向左移动量为3,向右移动量为5,向上移动量为4,向下移动量为8,那么在x轴方向的移动信息为(5-3)/2=1,也即移动量为1,移动方向为向右,在y轴方向的移动信息为(4-8)/2=-2,也即移动量为2,移动方向为向下。
步骤S27,判断所述第i个资源对象的移动距离是否大于预设的距离阈值。
在一些实施例中,首先基于步骤S26确定出来的移动信息确定出第i个资源对象的移动距离,由于步骤S26确定出的移动信息包括x轴方向的移动信息d1和y轴方向的
移动信息d2,那么第i个资源对应的移动距离即为然后判断第i个资源对象的移动距离是否大于预设的距离阈值,当确定所述第i个资源对象的移动距离大于预设的距离阈值时,进入步骤S28;当确定第i个资源对象的移动距离小于或者等于该距离阈值时,进入步骤S29。
步骤S28,按照所述移动信息将所述第i个资源对象的对象中心移动至所述可用空间的中心位置,并更新所述第i个资源对象的当前移动次数。
该步骤在实现,可以确定第i个资源对象是否包含其他子资源对象,如果第i个资源对象包含有子资源对象,那么在移动第i个资源对象时,是将第i个资源对象和其包含的子资源对象同时进行移动,此时在移动第i个资源对象时,第i个资源对象与其包含的子资源对象之间的相对关系不变,因此,在该步骤中仅更新第i个资源对象的当前移动次数,而不用更新第i个资源对象的子资源对象的当前移动次数。
步骤S29,将i=i+1。
步骤S210,判断i是否等于N+1。
其中,当i等于N+1,说明已经完成第1个资源对象至第N个资源对象的本轮移动迭代过程,此时进入步骤S211。当i不等于N+1,说明还没有完成本轮移动迭代过程,此时进入步骤S24。
步骤S211,在完成第1个资源对象至第N个资源对象的当前移动迭代过程后,更新所述当前移动迭代次数,得到更新后的当前移动迭代次数。
更新当前移动迭代次数,也即将当前移动迭代次数加1。
步骤S212,判断更新后的当前移动迭代次数是否小于移动迭代次数阈值。
其中,确定所述更新后的当前移动迭代次数小于所述移动迭代次数阈值时,进入步骤S24,继续移动所述第1个资源对象至第N个资源对象;确定所述更新后的当前移动迭代次数大于或者等于所述移动迭代次数阈值时,说明已经达到移动结束条件,进入步骤S103。
由于在将各个资源对象移动至各自对应的可用空间的中心位置时,一个资源对象的移动会对其邻近的其他资源对象在对应可用空间的相对位置产生影响。比如说,在移动一个资源对象之前,该资源对象的相邻资源对象位于该相邻资源对象对应可用空间的中心位置,而移动该资源对间的边缘会发生改象之后,该资源对象的相邻资源对象对应的可用空间的大小、可用空间的外边缘会发生变化,从而使得相邻资源对象不再位于该可用空间的中心位置。因此进行一轮移动迭代,往往不能实现大多数资源对象位于各自对应的可用空间的中心位置,因此,可以对资源对象进行多轮移动迭代,在本申请实施例中,对单个资源对象的移动次数阈值和整体的移动迭代次数阈值进行设定,通过设定单个资源对象的移动次数阈值,能够避免由于某个或某些资源对象发生循环移动而导致的超时;通过设定移动迭代次数阈值,能够避免在资源对象岛特别多的情况下,导致效果不明显的多次迭代并最终超时。在一些实施例中,可以根据资源对象的总数设定移动迭代次数阈值和单个资源对象的移动次数阈值,从而能够在保证执行效率的同时,达到最佳移动效果,以实现执行效率和执行效果之间的自适应平衡。
在一些实施例中,上述步骤S104“基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型”,可以通过图6所示的步骤S41至步骤S48实现,以下结合图6对各个步骤进行说明。
步骤S41,基于第i个资源对象的对称属性信息判断第i个资源对象是否具备内部对称特征。
其中,i=1,2,…N,N为资源对象总数,N为大于2的整数。
由于第i个资源对象的对象属性信息包括左右对称属性信息和上下对称属性信息,在一些实施例中,当基于左右对称属性信息确定第i个资源对象是左右对称,或者当基于上下对称属性信息确定第i个资源对象是上下对称的,确定第i个资源对象具备内部对称特征时,进入步骤S42;当基于左右对称属性信息确定第i个资源对象不是左右对称,并且基于上下对称属性信息确定第i个资源对象不是上下对称的,确定第i个资源对象不具备内部对称特征时,进入步骤S45。
也就是说,第i个资源对象满足左右对称和上下对称至少之一时,确定第i个资源对象具备内部对称特征;第i个资源对象既不满足左右对称又不满足上下对称,确定第i个资源对象不具备内部对称特征。
步骤S42,基于第i个资源对象的包含关系信息判断第i个资源对象是否被父资源对象包含。
由于第i个资源对象的包含关系信息中包括第一对象集合和第二对象集合,其中,第一对象集合中包括的是该资源对象所包含的子资源对象的对象标识,第二对象集合中包括的是包含该资源对象的父资源对象的对象标识,在一些实施例中,可以判断第二对象集合是否为空,当第二对象集合不为空,说明第i个资源对象被父资源对象包含,此时进入步骤S43。当第二对象集合为空,说明第i个资源对象未被父资源对象包含,此时进入步骤S48。
步骤S43,获取所述父资源对象的扩展类型。
步骤S44,判断该父资源对象的扩展类型是否为各向同性扩展。
其中,当所述父资源对象的扩展类型为各向同性扩展时,进入步骤S45;当该父资源对象的扩展类型为各向异性扩展时,进入步骤S46。
步骤S45,确定第i个资源对象的扩展类型为各向同性扩展。
步骤S46,获取所述父资源对象包含的其他子资源对象。
步骤S47,判断其他子资源对象是否均具备内部对称特征。
其中,当基于所述其他子资源对象的对称属性信息,确定所述其他子资源对象均具备内部对称特征时,进入步骤S48;当基于所述其他子资源对象的对称属性信息,确定至少存在一个其他子资源对象不具备内部对称特征时,进入步骤S45。
步骤S48,确定第i个资源对象的扩展类型为各向异性扩展。
在上述步骤S41至步骤S48所在实施例中,在确定第i个资源对象的扩展类型时,如果第i个资源对象不具备内部对称特征,则直接将第i个资源对象的扩展类型确定为各向同性扩展,从而保证在进行扩展处理后不发生形变,而如果第i个资源对象具备内部对称特征时,需要进一步确定第i个资源对象是否被父资源对象包含,如果没有被包含就可以将第i个资源对象的扩展类型确定为各向异性扩展,进而能够实现各个方向的最大扩展,而如果第i个资源对象被父资源对象包含时,如果父资源对象的扩展类型为各向同性扩展,那么为了避免扩展后造成资源对象之间的重叠,将第i个资源对象的扩展类型也确定为各向同性扩展,而如果父资源对象的扩展类型为各向异性扩展,那么如果该父资源对象的所有子资源对象均具备内部对称特征时,就可以将第i个资源对象以及其他子资源对象的扩展类型确定为各向异性扩展,如此在扩展过程中不仅能避免不同资源对象之间的重叠,还能保证在各个扩展方向都进行了最大比例的扩展,从而提高目标容器的填充率。
在本申请实施例中,在对多个资源对象进行装箱处理,所得到的初始填充结果中,会存在一个资源对象内部还嵌套包含有其他资源对象的情况,也可能存在几个资源对象为对称关系的情况,此时,上述步骤S105“基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象”通过以下步骤S51至步骤
S519实现,以下对各个步骤进行说明。
步骤S51,判断目标容器中是否存在第i个资源对象的对称对象。
其中,i=1,2,…N,N为资源对象总数,N为大于2的整数;当确定所述目标容器中不存在第i个资源对象的对称对象时,进入步骤S52;当确定目标容器中存在第i个资源对象的对称对象时,进入步骤S517。
步骤S52,判断第i个资源对象的扩展类型是否为各向同性扩展。
当确定第i个资源对象的扩展类型为各向同性扩展时,进入步骤S53;当确定第i个资源对象的扩展类型为各向异性扩展时,进入步骤S58。
步骤S53,将所述第i个资源对象的对象中心移动至对应的可用空间的中心位置。
该步骤的实现过程与步骤S102的实现过程是类似的,在实现时可参考步骤S102的实现过程。
需要说明的是,虽然在步骤S102中已经将目标容器中的多个资源对象进行了全局均匀化处理,但是在对资源对象进行扩展处理后,会对未进行扩展处理的资源对象的位置产生影响,因此会使得资源对象不再处于对应可见空间的中心位置,因为在对第i个资源对象进行扩展之前,再次将第i个资源对象的对象中心移动至对应的可用空间的中心位置,以保证确定出的最大扩展比例。
步骤S54,确定所述第i个资源对象的第一扩展比例。
在一些实施例中,可以采用双向射线法确定第i个资源对象的第一扩展比例:首先从当第i个资源对象的对象中心,沿着第i个资源对象的外边界顶点朝外发射射线,得到第i个资源对象外部的其他资源对象的交点,并据此计算对应的第一候选扩展比例;然后从第i个资源对象外部的其他资源对象的外边界的顶点,朝第i个资源对象的对象中心发射射线,得到和第i个资源对象的外边界的最近交点,并据此计算对应的第二候选扩展比例。将第一候选扩展比例和第二候选扩展比例中的最小者作为第一扩展比例,从而避免进行扩展时与其他资源对象重叠。
在一些实施例中,上述步骤S54“确定所述第i个资源对象的第一扩展比例”可以通过以下步骤实现:
步骤S541,获取位于所述第i个资源对象外部的其他资源对象的外边界信息、所述第i个资源对象的外边界信息和所述第i个资源对象的对象中心。
获取第i个资源对象的外边界信息在实现时,可以首先获取资源对象上的每条边,以及各条边的两个相邻面,然后判断各条边的相邻面是否均属于资源对象内部,如果一条边的相邻面均属于资源对象内部,则确定该条边为内部边,否则确定该条边为外边界,将一个资源对象的各个外边界连接起来,就构成了该资源对象的外边界。
第i个资源对象的对象中心可以用第i个资源对象的包围盒的中心来表示。第i个资源对象外部的其他资源对象的外边界信息可以包括第i个资源对象外部的其他资源对象外边界上的顶点的顶点标识、顶点索引等信息,第i个资源对象的外边界信息包括第i个资源对象外边界上的顶点标识、顶点索引等信息。
步骤S542,从所述第i个资源对象的对象中心向所述第i个资源对象的外边界上的各个第一顶点发射第一射线,确定各条第一射线与所述其他资源对象的外边界的各个第一最近交点。
在一些实施例中,可以基于第i个资源对象外部的其他资源对象的外边界信息构建第一空间搜索树,该第一空间搜索树上的图元为其他资源对象的外边界上的连接边,然后通过第一空间搜索树确定各条第一射线与其他资源对象的外边界的各个第一最近交点。
步骤S543,基于所述对象中心的中心坐标、所述各个第一顶点的第一顶点坐标和
各个第一最近交点的第一交点坐标,确定各个第一顶点对应的第一候选扩展比例。
在一些实施例中,该步骤可以通过以下步骤实现:
步骤S5431,获取间隔距离。
该间隔距离对应其他实施例中的出血值,该间隔距离可以是预先设置的,也可以是根据装箱空间的分辨率自动确定出来的,例如,可以假设每128个像素取一个像素作为间隔距离,那么256*256分辨率通常采用2个像素值作为间隔距离,如此根据装箱空间的分辨率自动计算并预留间隔距离,能够有效避免人工装箱手动保留间隔距离可能引起的错误。
步骤S5432,基于该间隔距离和所述各个第一最近交点的交点坐标确定各个第一最近交点对应的第一目标点的第一目标坐标。
其中,第一目标点为第一射线上的点,第一目标点与第一最近交点之间的距离为该间隔距离,且第一目标点在所述第一最近交点和对象中心之间。
步骤S5433,基于所述对象中心的中心坐标和所述各个第一顶点的第一顶点坐标确定所述各个第一顶点对应的第一距离。
在一些实施例中,在已知对象中心的中心坐标和各个第一顶点的第一顶点坐标时,可以基于距离公式,确定出各个第一顶点对应的第一距离。该第一距离也即第一顶点与对象中心之间的距离。
步骤S5434,基于所述对象中心的中心坐标和各个第一目标点的第一目标坐标确定所述各个第一顶点对应的第二距离。
与步骤5433类似,在已知对象中心的中心坐标和各个第一目标点的第一目标坐标的前提下,基于距离公式即可确定出各个第一顶点对应的第二距离。第二距离也即第一目标点与对象中心之间的距离。
步骤S5435,基于所述各个第一顶点对应的第一距离和第二距离,确定各个第一顶点对应的第一候选扩展比例。
在一些实施例中,将各个第一顶点对应的第二距离除以第一距离即得到了各个第一顶点对应的第一候选扩展比例。
步骤S544,从所述其他资源对象的外边界上的各个第二顶点向所述第i个资源对象的对象中心发射第二射线,确定各条第二射线与所述第i个资源对象的外边界的各个第二最近交点。
在一些实施例中,可以基于第i个资源对象的外边界信息构建第二空间搜索树,该第二空间搜索树上的图元为第i个资源对象的外边界上的连接边,然后通过第二空间搜索树确定各条第二射线与其他资源对象的外边界的各个第二最近交点。
步骤S545,基于所述对象中心的中心坐标、所述各个第二顶点的第二顶点坐标和各个第二最近交点的第二交点坐标,确定各个第二顶点对应的第二候选扩展比例。
这里,首先基于该间隔距离和所述各个第二最近交点的交点坐标确定各个第二最近交点对应的第二目标点的第二目标坐标。其中,第二目标点为第二射线上的点,第二目标点与第二顶点之间的距离为该间隔距离,且第二目标点在所述第二顶点和对象中心之间。再基于所述对象中心的中心坐标和所述各个第二最近交点的交点坐标确定所述各个第二顶点对应的第五距离,并基于所述对象中心的中心坐标和各个第二目标点的第二目标坐标确定所述各个第二顶点对应的第六距离;各个第二顶点对应的第六距离除以对应的第五距离,得到各个第二顶点对应的第二候选扩展比例。
步骤S546,将多个第一候选扩展比例和多个第二候选扩展比例中的最小值确定为所述第i个资源对象的第一扩展比例。
在上述步骤S541至步骤S546所在的实施例中,在确定第i个资源对象进行各向同
性扩展时采用的第一扩展比例时,采用双向射线法,首先从第i个资源对象的对象中心,沿着第i个资源对象的外边界顶点朝外发射第一射线,得到第i个资源对象外部的与其他资源对象的第一最近交点,并据此计算对应的第一候选扩展比例;然后从第i个资源对象外部的其他资源对象的外边界的顶点,朝第i个资源对象的对象中心发射第二射线,得到和第i个资源对象的外边界的第二最近交点,并据此计算对应的第二候选扩展比例,并且在计算第一候选扩展比例和第二候选扩展比例的时候,预留出了间隔距离,也即预留出了部分空隙,从而能够避免在进行资源对象扩展时与其他资源对象发生交叠。
下面接续步骤S54继续进行说明。
步骤S55,确定第i个资源对象是否包含其他子资源对象。
其中,当基于所述第i个资源对象的包含关系信息,确定所述第i个资源对象中包含有其他子资源对象时,进入步骤S56;当确定第i个资源对象不包含其他子资源对象时,进入步骤S57。
步骤S56,将所述第i个资源对象和所述第i个资源对象中包含的其他子资源对象按照所述第一扩展比例进行扩展处理,得到处理后的第i个资源对象和处理后的其他子资源对象。
在一些实施例中,是以第i个资源对象的对象中心为扩展中心,将第i个资源对象和第i个资源对象中包含的其他子资源对象按照第一扩展比例进行扩展处理,得到处理后的第i个资源对象和处理后的其他子资源对象。
步骤S57,将所述第i个资源对象按照所述第一扩展比例进行扩展处理,得到处理后的第i个资源对象。
当确定第i个资源对象不包含其他子资源对象时,就仅需要对第i个资源对象进行扩展处理即可,在一些实施例中,以第i个资源对象的对象中心为扩展中心按照第一扩展比例对第i个资源对象进行各向同性扩展处理,得到处理后的第i个资源对象。
步骤S58,获取所述第i个资源对象的主轴信息,并基于所述第i个资源对象的主轴信息确定旋转角度和第一旋转方向。
第i个资源对象的主轴是指经过第i个资源对象的对象中心的多条基线中宽度最大的一条基线。第i个资源对象的主轴信息为第i个资源对象的一种属性信息,第i个资源对象的主轴信息包括主轴与x轴之间的夹角,在将第i个资源对象填充至目标容器或者在移动第i个资源对象时,第i个资源对象的主轴信息会发生变化。假设第i个资源对象的主轴信息为45度,那么根据该主轴信息,可以确定旋转角度为45度,第一旋转方向为顺时针。
步骤S59,将N个资源对象按照所述第一旋转方向旋转所述旋转角度,得到旋转后的N个资源对象。
在该步骤中,是将目标容器中的N个资源对象均进行了旋转,从而保证第i个资源对象与其他资源对象之间的相对位置保持不变。其中,旋转后的第i个资源对象的主轴为水平方向,也即旋转后的第i个资源对象的主轴与x轴平行。
步骤S510,将所述旋转后的第i个资源对象的对象中心移动至对应的可用空间的中心位置。
该步骤的实现过程与步骤S102的实现过程是类似的,在实现时可参考步骤S102的实现过程。
步骤S511,确定所述旋转后的第i个资源对象在预设的各个扩展方向上的第二扩展比例。
在一些实施例中,可以从旋转后的第i个资源对象的外边界上确定各个扩展方向对应的多个候选点;从各个候选点延对应的各个扩展方向发射第三射线,确定各条第三射
线与所述其他资源对象的外边界的最近交点,基于最近交点确定旋转后的第i个资源对象在各个扩展方向上的第二扩展比例。
在一些实施例中,上述步骤S511“确定所述旋转后的第i个资源对象在预设的各个扩展方向上的第二扩展比例”可以通过以下步骤实现:
步骤S5111,获取位于所述旋转后的第i个资源对象外部的其他资源对象的外边界信息和所述旋转后的第i个资源对象的包围盒。
步骤S5112,从所述旋转后的第i个资源对象的外边界上确定第j个扩展方向对应的多个候选点。
由于资源对象的外边界的顶点是按照逆时针方向排序的,在一些实施例中,如果第j个扩展方向为向上方向,那么将第i个资源对象的外边界上起点x坐标大于终点x坐标的连接边确定为候选连接边,将候选连接边的顶点确定为候选点,然后将第i个资源对象外部的其他资源对象上的外边界上的顶点沿第j个扩展方向(也即向上)的反方向(也即向下)做投影,将投影到候选连接边上的点也确定为第j个扩展方向上的候选点。类似的,如果第j个扩展方向为向下,那么将第i个资源对象的外边界上起点x坐标小于终点x坐标的连接边确定为候选连接边,将候选连接边的顶点确定为候选点,然后将第i个资源对象外部的其他资源对象上的外边界上的顶点沿第j个扩展方向(也即向下)的反方向(也即向上)做投影,将投影到候选连接边上的点也确定为第j个扩展方向上的候选点。
步骤S5113,从各个候选点沿所述第j个扩展方向发射第三射线,确定各条第三射线与所述其他资源对象的外边界的第三最近交点。
j为小于或者等于M的正整数,M为扩展方向总数,M为大于或者等于1的整数。在一些实施例中,可以基于第i个资源对象的外边界信息构建第二空间搜索树,该第二空间搜索树上的图元为第i个资源对象的外边界上的连接边,然后通过第二空间搜索树确定各条第三射线与其他资源对象的外边界的各个第三最近交点。
步骤S5114,确定所述各个候选点到所述包围盒的目标边的各个第三距离,并确定所述各个第三最近交点到所述目标边的各个第四距离。
所述目标边为所述包围盒上与所述第j个扩展方向的相反方向对应的边。比如第j个扩展方向为向上,那么目标边为包围盒上的下侧水平边,第j个扩展方向为向左,那么目标边为包围盒上的右侧竖直边。
步骤S5115,基于所述各个第三距离和对应的所述各个第四距离,确定各个候选点对应的第三候选扩展比例。
在一些实施例中,将各个候选点的第四距离除以对应的第三距离,即得到了各个候选点对应的第三候选扩展比例。
步骤S5116,将多个第三候选扩展比例中的最小值确定为所述第j个扩展方向对应的的第二扩展比例。
在上述步骤S5111至步骤S5116所在的实施例中,确定对第i个资源对象进行各向异性扩展时在各个扩展方向上的第二扩展比例时,可以首先从第i个资源对象的外边界上确定各个扩展方向对应的多个候选点,然后从各个候选点向各个扩展方向发射第三射线,确定各条第三射线与所述其他资源对象的外边界的第三最近交点,并根据第i个资源对象的包围盒上各个扩展方向的反方向对应的目标边、第三最近交点以及候选点确定出各个扩展方向对应的第二扩展比例,如此能够实现对第i个资源对象在各个扩展方向上进行最大程度的扩展。
下面接续步骤S511继续进行说明。
步骤S512,确定所述旋转后的第i个资源对象中是否包含有其他子资源对象。
其中,当基于所述第i个资源对象的包含关系信息,确定所述旋转后的第i个资源对象中包含有其他子资源对象时,进入步骤S513;当确定旋转后的第i个资源对象未包含其他资源对象时,进入步骤S514。
步骤S513,将所述旋转后的第i个资源对象和所述旋转后的第i个资源对象中包含的其他子资源对象在所述各个扩展方向上按照各自对应的第二扩展比例进行扩展,得到扩展后的第i个资源对象和扩展后的其他子资源对象。
由于在步骤S58和步骤S59中已经将第i个资源对象的主轴旋转至水平方向,那么第i个资源对象的包围盒的相邻边一个是水平方向,一个是竖直方向,扩展方向可以是上下左右四个方向至少之一,在一些实施例中,以第i个资源对象的包围盒上各个扩展方向对应的反方向上的边为基准,将第i个资源对象和第i个资源对象中包含的其他子资源对象在各个扩展方向上按照各自对应的第二扩展比例进行扩展,得到扩展后的第i个资源对象和扩展后的其他子资源对象。
以扩展方向为向上为例进行说明,是以第i个资源对象包围盒下侧的水平边为基准(也即下侧的水平边保持不动),将第i个资源对象和第i个资源对象中包含的其他子资源对象向上扩展对应的第二扩展比例。
步骤S514,将旋转后的第i个资源对象在所述各个扩展方向上按照各自对应的第二扩展比例进行扩展,得到扩展后的第i个资源对象。
步骤S515,将所述扩展后的第i个资源对象和所述扩展后的其他子资源对象按照第二旋转方向旋转所述旋转角度,得到处理后的第i个资源对象和处理后的其他子资源对象。
所述第二旋转方向为所述第一旋转方向的反方向。在该步骤中,将该目标容器中的N个资源对象按照与第一旋转方向的反方向旋转该旋转角度,从而将目标容器中的N个资源对象恢复至旋转前的姿态。
步骤S516,基于所述第i个资源对象的扩展类型,分别确定所述第i个资源对象的第一参考扩展比例和所述对称对象的第二参考扩展比例。
当第i个资源对象具有对称对象时,那么第i个资源对象的扩展类型和其对称对象的扩展类型是相同的。在一些实施例中,如果第i个资源对象的扩展类型为各向同性扩展,那么可以利用参考下述步骤S541至步骤S546类似的过程,分别确定出第i个资源对象的第一参考扩展比例和所述对称对象的第二参考扩展比例;如果第i个资源对象的扩展类型为各向异性扩展,那么可以参考上述步骤S58至步骤S511确定出第i个资源对象在各个扩展方向的第一参考扩展比例和所述对称对象在各个方向的第二参考扩展比例。
步骤S517,将所述第一参考扩展比例和所述第二参考扩展比例中的最小值,确定为所述第i个资源对象和所述对称对象的目标扩展比例。
在一些实施例中,如果第i个资源对象的扩展类型为各向同性扩展,那么第i资源对象和对称对象各自对应一个参考扩展比例,那么将第一参考扩展比例和至少一个第二参考扩展比例中的最小值确定为第i个资源对象和所述对称对象的目标扩展比例;如果第i个资源对象的扩展类型为各向异性扩展,那么第i个资源对象和对称对象在各个扩展方向上均对应一个参考扩展比例,假设扩展方向有四个,分别为上、下、左、右,那么将第i个资源对象和对称对象在每个扩展方向上对应的参考扩展比例中最小值确定为各个扩展方向的目标扩展比例。
步骤S518,按照所述目标扩展比例对所述第i个资源对象和所述对称对象进行扩展处理,得到处理后的第i个资源对象和处理后的对称对象。
在一些实施例中,如果对第i个资源对象和对称对象进行扩展后,与其他资源对象
发生交叠,那么将第i个资源对象和对称对象恢复至扩展前。
通过上述步骤S51至步骤S518,能够在对第i个资源对象进行扩展时,基于第i个资源对象是否具有对称对象以及第i个资源的扩展类型进行不同的扩展方式,其中第i个资源对象不具有对称对象时,那么就直接基于第i个资源对象的扩展类型进行扩展,然而当第i个资源对象中包含其他子资源对象时,还可以将第i个资源对象和第i个资源对象的子资源对象同时进行扩展,如此不仅能够避免第i个资源对象扩展时与其内部包含的子资源对象之间发生交叠,并且还能同时扩展多个资源对象,从而提高对象处理效率;而当第i个资源对象具有对称对象时,需要分别确定出第i个资源对象的第一参考扩展比例和对称对象的第二参考扩展比例,并取最小值作为目标扩展比例,从而保证第i个资源对象和对称对象在扩展后仍能够保持大小一致。
下面,将说明本申请实施例在一个实际的应用场景中的示例性应用。
对于诸如2UV展开这一特定类型的装箱问题,往往允许对UV岛进行一定幅度的扩展,从而改进装箱效果。例如对于图7所示的2UV展开,原始装箱结果如左侧701所示,那么大部分美术工作人员会对这部分UV岛进行扩展,达到右侧702所示的效果,以便于在渲染时提高内存利用率,从而最大化纹理分辨率。
本申请实施例提供的对象处理方法,可以应用于自动2UV展开工具中,可以对具有烘焙需求的多种游戏场景模型实现2UV展开的自动化,包括角色模型、车辆模型、建筑模型等等。在一些实施例中,终端响应于针对自动2UV展开工具中的“模型导入”的操作指令,呈现模型选择界面,并基于通过模型选择界面接收到的模型选择操作,确定目标三维模型数据,终端响应于接收到的UV展开操作指令,通过自动2UV工具对目标三维模型进行面片剖分,从而得到多个二维的UV岛(资源对象),再对多个UV岛进行装箱处理,得到初始装箱结果,并基于各个UV岛的对称属性信息和包含关系信息确定各个UV岛的扩展类型,其中,扩展类型包括各向同性扩展和各向异性扩展中的一种,基于各个UV岛的扩展类型,对各个UV岛进行扩展处理,得到处理后的各个UV岛。对原始装箱结果中的每个UV岛都进行了扩展,并且在扩展之前将UV岛移动至中心位置,从而能够在有限的空间内实现最大比例的扩展,如此能够最大限度的减少空余空间,从而提高目标容器的填充率。之后利用最终的装箱结果对三维模型进行贴图处理,在实现时,响应于接收到的UV岛选择指令,确定本次进行贴图的目标UV岛,终端响应于针对目标UV岛的贴图操作,呈现目标UV岛的多个候选贴图图像,然后终端接收贴图选择操作,并基于该贴图选择操作确定目标贴图图像,基于该目标贴图图像对目标UV岛进行贴图处理。由于在装箱过程中对UV岛进行了扩展处理,因此在对三维模型中的各个UV岛进行贴图时,能够提高纹理映射的分辨率。
在本申请实施例中,通过分析美术人工的做法,提炼蕴含在人工操作中的思想来设计对应的算法。以图8左侧的初始装箱结果801为例,对于美术人工而言,会移动各个UV岛,使得不同UV岛之间的间距大致相同;然后开始对不同的UV岛进行分类扩展。例如对于右上侧矩形框8011所示的具有的内部对称特征的UV岛,为了最大限度地利用其周围空间,会较多地进行垂直方向的拉伸,同时稍微进行水平方向的拉伸,得到如图8中802右上侧矩形框8021所示的扩展结果。虽然这种各向异性的拉伸会导致发生一定的形变,但是由于该UV岛相对比较规整,所以并不会引起纹理的扭曲。而对于左下侧矩形框8012所示的没有内部对称特征的UV岛,为了避免引起纹理扭曲,往往对它进行各向同性的等比例扩展。得到如图8中802左下侧矩形框8022所示的扩展结果。
基于以上分析,本申请实施例提供的对象处理方法在实现时,可以分为图9所示的两个步骤:
步骤S901,全局均匀化处理。
在一些实施例中,对所有UV岛进行全局均匀化处理,以使得不同UV岛之间的间距大致相同。
步骤S902,分类扩展。
其中,图9所示的UV岛仅仅包含其外部边界和内部孔洞,而不再包含多边形区域的内部边。这是因为区域内部边并不会对装箱过程和结果有任何影响。所以为了提高计算效率,首先提取各个UV岛的外轮廓(包含外部边界和内部孔洞),并且在后续装箱优化中仅仅考虑各个UV岛的外轮廓。
以下对上述步骤S901和步骤S902的实现过程进行说明。
一、全局均匀化
对于一个给定的装箱结果,所要扩展的UV岛未必处于其所在空隙的中心位置,如图10的两个圆圈1001和1002中的UV岛所示。这种情况将导致其扩展受到影响。为了最大程度地消除这种影响,需要首先对所有UV岛进行全局“摇匀”,也即全局均匀化处理。进行全局均匀化处理的原理是:想象各个UV岛之间的空隙处存在着“虚拟弹簧”,其弹力将促使各个UV岛之间因相互排斥而运动,最终达到受力平衡。基于这一思想,全局均匀化处理在实现时可以通过以下步骤实现:
步骤S9011,根据UV岛数量,定义最大迭代次数P和单UV岛最大移动次数Q。
其中,P为正整数,Q为小于或者等于P的正整数。
步骤S9012,对于每个UV岛,如果确定其累计移动次数小于N,则计算它所在的局部空隙的中心点,并移动该UV岛,使其包围盒中心点同局部空隙中心点重合,并更新其累计移动次数。
步骤S9013,如果在步骤S9012中没有UV岛被移动,则算法结束。
如果在一轮移动迭代中,所有的UV岛的包围盒中心点均位于各自对应的局部空隙中心,那么在本轮迭代中没有UV岛被移动,此时全局均匀化处理结束。
步骤S9014,更新当前迭代次数,如果确定已经达到了最大迭代次数M,则算法结束,否则转步骤S9012。
在本申请实施例中,之所以定义单个UV岛的最大移动次数Q,是因为在实践中发现在某些情况下会发生循环移动导致超时;之所以定义最大迭代次数P,也是发现对于UV岛特别多的情况,如果不定义最大迭代次数,则容易导致效果不明显的多次迭代并最终超时。在实践中,为了达到效率和效果之间的自适应平衡,可以设置当UV岛数量小于10个时,P=Q=8;当UV岛数量小于20时,P=Q=5;而当UV岛数量大于20时,P=Q=3。
二、分类扩展
在诸如2UV展开这类应用中,往往对不同的UV岛存在不同的扩展需求。例如对于图11左侧中圆圈1101和1102内的UV岛,由于它们存在明显的内部对称特征,所以对其x方向和y方向分别施加不同的扩展比例并不会引起纹理扭曲。在这种情况下,在本申请实施例中,原则是尽量充分扩展UV岛,以最大限度地提高填充率。将这种扩展方式称为各向异性扩展,得到的扩展结果如图11右侧椭圆1103和1104所示。
而对于不存在内部对称特征的UV岛,如图12中左侧的圆圈1201内所示,一旦进行各向异性的扩展,则容易引起纹理扭曲。在这种情况下,原则是首先保证纹理不扭曲,然后再对UV岛进行尽量充分的扩展。此时,必须对UV岛的各个方向施加相同的扩展比例。在本申请实施例中,称这种扩展方式为各向同性扩展,其扩展结果如图12中的右侧中圆圈1202所示。
以上多边形分类仅仅是针对2UV展开这一特定需求而设计的。对于其它需求,可以设计不同的UV岛分类,并对其实施不同类型的扩展。
在对各向同性扩展和各向异性扩展的实现过程进行说明之前,首先对各向同性扩展和各向异性扩展的一种数据结构:基于轴对齐包围盒的空间搜索树(AABB Tree,Axis-Aligned Bounding Box Tree)进行说明。AABB树是一种基于K-树原理的空间搜索树,其每个节点代表一个几何图元的空间包围盒。该数据结构可以快速报告查询图元是否与树中的图元相交,以及具体相交类型、相交位置等。如果查询图元是点,则还可以查询最近距离。
在本申请实施例中,采用(带孔)多边形的边来构造空间搜索树。基于这种数据结构,分类扩展可以通过以下步骤实现:
步骤S9021,记录每个UV岛的孔洞所包含的UV岛集合;
步骤S9022,按照正序,对每个UV岛分别执行步骤S9023,得到顺序扩展结果;
步骤S9023,如果当前待扩展UV岛具有内部对称特征,则执行各向异性扩展,否则执行各向同性扩展;
步骤S9024,如果顺序扩展结果的填充率已经满足要求,则算法结束,否则转步骤S9025;
步骤S9025,按照逆序,对每个UV岛再次分别执行步骤3),得到逆序扩展结果;
步骤S9026,比较顺序扩展结果和逆序扩展结果,选择填充率最高者,作为最终的扩展结果。
在本申请实施例中,之所以在步骤S9021中首先记录每个UV的孔洞中所包含的UV岛集合,是因为如果当前UV岛的孔洞中包含其它UV岛,那么在扩展过程中其内部UV岛也需要做同步扩展。这样不仅可以避免和内部UV岛发生交叠,而且可以提高扩展效率。以下对各向异性扩展和各向同性扩展的实现过程进行说明。
各向异性扩展:各向异性扩展允许UV岛在不同方向上具有不同的扩展比例,因此可以在不同方向上分别进行独立扩展。在本申请实施例中,各向异性扩展的实现过程可以包括以下步骤:
步骤S231,旋转所有UV岛,使得当前UV岛的主轴和x轴平行,并记录旋转角度。
在一些实施例中,可以通过当前UV岛的主轴信息确定将主轴旋转至与x轴平行时的旋转角度和旋转方向,然后旋转所有UV岛,从而使得当前UV岛的主轴和x轴平行。
步骤S232,提取当前UV岛外部的所有UV岛的边界线段,并构建对应的空间搜索树T。
步骤S233,将当前UV岛移动到其局部间隙的中心。
在一些实施例中,将当前UV岛的包围盒的中心移动到当前UV岛对应的局部间隙的中心。
步骤S234,沿着上、下、左、右四个方向通过下述两个步骤分别做最大扩展:
A)对于当前UV岛外边界上的每个候选点,沿着当前方向向外发射射线,利用空间搜索树T计算最近交点,从而确定当前顶点(线段)朝外的最大扩展比例;
B)在所有的最大扩展比例中,选择最小者作为该方向上的最终扩展比例,以其反方向为基准,扩展该UV岛及其孔洞中所包含的所有UV岛。
步骤S235,根据步骤S231所记录的旋转角度,将所有UV岛旋转回原始位置。
图13为本申请实施例提供的各向异性扩展的实现过程示意图,其中,图13中1301为原始装箱结果中的一部分,其中待扩展UV岛为1301中心部位的矩形,由于该待扩展UV岛具备内部对称特征,因此进行各向异性扩展,在实现时向上、下、左、右扩展,其中,通过图13中的1302可以看出,在向上扩展时,可以从矩形上边界的边上选择3个点作为候选点,向上发射射线,以确定向上扩展的扩展比例;向下扩展时,可以如图13中的1303所示,从矩形的下边界上选择2个点作为候选点,向下发射射线,以确定
向下扩展的扩展比例;向左进行扩展时,可以如图13中的1304所示,从矩形的左边界上选择9个候选点,向左发射射线,以确定向左扩展时的扩展比例;向右进行扩展时,可以如图13中的1305所示,从矩形的右边界上选择5个候选点,向右发射射线,以确定向右扩展时的扩展比例,在上下左右四个方向进行扩展后,可以得到图13中右下角1306所示的最终扩展结果。可以看到在这种情况下,原始UV岛在不同方向上扩展了不同的比例,并且均得到了最充分的扩展。
各向同性扩展:为了避免纹理扭曲,对于不具备内部对称特征的UV岛需要采用各向同性扩展。在本申请实施例中,各向同性扩展的实现过程可以通过以下步骤实现:
步骤S241,提取当前UV岛外部的所有UV岛边界并构建对应的空间搜索树T1。
步骤S242,将当前UV岛移动到其局部间隙中心。
步骤S243,提取当前UV岛的边界,并构建其对应的空间搜索树T2。
步骤S244,采用双向射线法确定最大扩展比例:
A)从当前UV岛中心,沿着其边界顶点朝外发射射线,得到和T1的最近交点,并据此计算对应的扩展比例;
B)从其余UV岛边界顶点,朝当前UV岛的中心发射射线,得到和T2的最近交点,并据此计算对应的扩展比例;
步骤S245,计算步骤S244中得到的所有扩展比例中的最小者作为最终扩展比例,然后对当前UV岛及其内部岛进行各向同性的等比例扩展。
图14为本申请实施例提供的各向同性扩展的实现过程示意图,其中,图14中的1401是原始待扩展的UV岛;1402是部分朝外发射的射线;1403是部分朝内发射的射线;1404是最终的扩展结果。由于1402和1403中所示的每条射线都对应一个扩展比例,所以只要选择所有射线所对应的扩展比例中的最小者,并据此对当前UV岛进行扩展,就可以确保不会和周围UV岛发生交叠。而此时的扩展比例也是该UV岛在不和其它UV岛发生交叠的前提下所能扩展的最大比例。
在实施自动2UV展开项目的美术资源中,往往存在一组或者多组对称UV岛。有时用户希望在装箱过程中保持这些对称UV岛的大小。基于此,在进行分类扩展时,可以通过以下步骤实现:
步骤S9021’,记录每个UV岛的孔洞所包含的UV岛集合。
步骤S9022’,提取对称UV岛,将对称UV岛集合记为A,其余非对称UV岛集合记为B。
步骤S9023’,对于集合A中的每组对称UV岛,执行以下步骤:
a)对于该组对称UV岛中的每个UV岛,将其移动到局部空隙中心,并根据其分类计算最大扩展比例;
b)获得a)中所有扩展比例中的最小者,作为该组对称UV岛的最终扩展比例,并对该组所有对称UV岛进行同比例扩展;如果扩展导致发生了交叠,则恢复原样。
步骤S9024’,对于集合B中的每个非对称UV岛,仍然按照步骤S9023提供的方法进行分类扩展。
在上述步骤S9021’至步骤S9024’中,优先考虑针对对称UV岛的分类扩展。这里的关键之处在于步骤S9023’。在该步骤中,首先判断当前组的对称UV岛是否是具备内部对称特征的,如果是,则采用各向异性方式计算最大扩展比例;否则采用各向同性方式来计算最大扩展比例。在组内所有UV岛计算出最大扩展比例后,取其中的最小者作为最终扩展比例,以便最大限度地保证不发生交叠。然而同组对称UV岛也有可能相邻,使得按照最小比例扩展依然发生交叠。所以在实质扩展之后需要进行检查,一旦发现发生了交叠则恢复原样,并跳过对该组对称UV岛的扩展。如此,能够保证对称UV岛同
比例的扩展,因而能够满足美术人员的特定需求。
利用本申请实施例提供的模型处理方法,分别针对小规模UV岛、中等规模UV岛以及大规模UV岛进行了实验,得到了如图15所示的扩展结果。其中,在图15中,1501、1503和1505分别为小规模UV岛、中等规模UV岛以及大规模UV岛扩展之前的装箱效果,1502、1504和1506分别为小规模UV岛、中等规模UV岛以及大规模UV岛扩展之后的装箱效果,通过对比可以看出,经过多边形分类扩展之后,不仅装箱填充率得到了最大限度的提高,而且UV岛各向同性/各向异性的特性也得到了完好的保存。这两点非常符合2UV展开中美术工作人员的需求。
为了进一步验证本申请实施例提供的模型处理方法对自动2UV展开项目的填充率提升,在某游戏公司的14个项目的美术资源上进行了批量测试,得到了如表1所示的统计结果。将美术资源的名称分别用A,B,…,N来代替。
表1、多边形分类扩展算法有益效果的统计对比
通过表1可以看出,在加了多边形分类扩展之后,填充率有了10%-15%的提高。尤其尤其值得注意的是,无多边形分类扩展之前的平均填充率往往不及人工装箱结果;但是加了多边形扩展之后,自动装箱结果的平均填充率除了项目D之外全部超越人工填充率。表1同样揭示出,增加了多边形分类扩展之后,装箱填充率超越人工的占比可以有平均30%左右的提升。
下面继续说明本申请实施例提供的对象处理装置455的实施为软件模块的示例性结构,在一些实施例中,如图3所示,存储在存储器450的对象处理装置455中的软件模块可以包括:
第一获取模块4551,配置为获取待处理的多个资源对象在目标容器中的初始填充结果;
第一移动模块4552,配置为基于所述初始填充结果,将各个资源对象移动至各自对应的可用空间的中心位置;
第二获取模块4553,配置为获取所述各个资源对象的对称属性信息和包含关系信息;
第一确定模块4554,配置为基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,其中,所述扩展类型包括各向同性扩展和各向异性扩展中的一种;
第一扩展模块4555,配置为基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象。
在一些实施例中,该第一移动模块,还配置为:
获取预设的移动迭代次数阈值和单个资源对象的移动次数阈值;
获取当前移动迭代次数,当所述当前移动迭代次数小于所述移动迭代次数阈值时,获取第i个资源对象的当前移动次数,i=1,2,…N,N为资源对象总数,N为大于2的整数;
当所述第i个资源对象的当前移动次数小于所述移动次数阈值时,确定将所述第i个资源对象的对象中心移动至所述第i个资源对象所在可用空间的中心位置的移动信息;
基于所述移动信息,确定所述第i个资源对象的移动距离大于预设的距离阈值时,将所述第i个资源对象的对象中心移动至所述可用空间的中心位置,并更新所述第i个资源对象的当前移动次数。
在一些实施例中,该装置还包括:
第一更新模块,配置为在完成第1个资源对象至第N个资源对象的当前移动迭代过程后,更新所述当前移动迭代次数,得到更新后的当前移动迭代次数;
第二移动模块,配置为确定所述更新后的当前移动迭代次数小于所述移动迭代次数阈值时,继续移动所述第1个资源对象至第N个资源对象。
在一些实施例中,该第一确定模块,还配置为:
当基于第i个资源对象的对称属性信息表征所述第i个资源对象具备内部对称特征,且基于所述第i个资源对象的包含关系信息确定所述第i个资源对象未被父资源对象包含时,确定所述第i个资源对象的扩展类型为各向异性扩展,其中,i=1,2,…N,N为资源对象总数,N为大于2的整数。
在一些实施例中,该第一确定模块,还配置为:
当基于第i个资源对象的对称属性信息表征所述第i个资源对象不具备内部对称特
征时,确定所述第i个资源对象的扩展类型为各向同性扩展。
在一些实施例中,该第一确定模块,还配置为:
当所述第i个资源对象被父资源对象包含时,获取所述父资源对象的扩展类型;
当所述父资源对象的扩展类型为各向同性扩展时,确定所述第i个资源对象的扩展类型为各向同性扩展。
在一些实施例中,该第一确定模块,还配置为:
当所述父资源对象的扩展类型为各向异性扩展时,获取所述父资源对象包含的其他子资源对象;
当基于所述其他子资源对象的对称属性信息,确定所述其他子资源对象均具备内部对称特征时,确定所述第i个资源对象的扩展类型为各向异性扩展;
当基于所述其他子资源对象的对称属性信息,确定至少存在一个其他子资源对象不具备内部对称特征时,确定所述第i个资源对象的扩展类型为各向同性扩展。
在一些实施例中,该第一扩展模块,还配置为:
当确定所述目标容器中不存在第i个资源对象的对称对象,且第i个资源对象的扩展类型为各向同性扩展时,确定所述第i个资源对象的第一扩展比例,i=1,2,…N,N为资源对象总数,N为大于2的整数;
当基于所述第i个资源对象的包含关系信息,确定所述第i个资源对象中包含有其他子资源对象时,将所述第i个资源对象和所述第i个资源对象中包含的其他子资源对象按照所述第一扩展比例,对所述第i个资源对象和所述第i个资源对象中包含的其他子资源对象进行扩展处理,得到处理后的第i个资源对象和处理后的其他子资源对象。
在一些实施例中,该第一扩展模块,还配置为:
获取位于所述第i个资源对象外部的其他资源对象的外边界信息、所述第i个资源对象的外边界信息和所述第i个资源对象的对象中心;
从所述第i个资源对象的对象中心向所述第i个资源对象的外边界上的各个第一顶点发射第一射线,确定各条第一射线与所述其他资源对象的外边界的各个第一最近交点;
基于所述对象中心的中心坐标、所述各个第一顶点的第一顶点坐标和各个第一最近交点的第一交点坐标,确定各个第一顶点对应的第一候选扩展比例;
从所述其他资源对象的外边界上的各个第二顶点向所述第i个资源对象的对象中心发射第二射线,确定各条第二射线与所述第i个资源对象的外边界的各个第二最近交点;
基于所述对象中心的中心坐标、所述各个第二顶点的第二顶点坐标和各个第二最近交点的第二交点坐标,确定各个第二顶点对应的第二候选扩展比例;
将多个第一候选扩展比例和多个第二候选扩展比例中的最小值确定为所述第i个资源对象的第一扩展比例。
在一些实施例中,该第一扩展模块,还配置为:
获取预设的间隔距离,基于所述间隔距离和所述各个第一最近交点的交点坐标确定各个第一最近交点对应的第一目标点的第一目标坐标;
基于所述对象中心的中心坐标和所述各个第一顶点的第一顶点坐标确定所述各个第一顶点对应的第一距离;
基于所述对象中心的中心坐标和各个第一目标点的第一目标坐标确定所述各个第一顶点对应的第二距离;
基于所述各个第一顶点对应的第一距离和第二距离,确定各个第一顶点对应的第一候选扩展比例。
在一些实施例中,该第一扩展模块,还配置为:
当第i个资源对象的扩展类型为各向异性扩展时,获取所述第i个资源对象的主轴信息,并基于所述第i个资源对象的主轴信息确定旋转角度和第一旋转方向,i=1,2,…N,N为资源对象总数,N为大于2的整数;
将N个资源对象按照所述第一旋转方向旋转所述旋转角度,得到旋转后的N个资源对象,其中,旋转后的第i个资源对象的主轴为水平方向;
将所述旋转后的第i个资源对象的对象中心移动至对应的可用空间的中心位置;
确定所述旋转后的第i个资源对象在预设的各个扩展方向上的第二扩展比例;
当基于所述旋转后的第i个资源对象的包含关系信息,确定所述旋转后的第i个资源对象中包含有其他子资源对象时,将所述旋转后的第i个资源对象和所述旋转后的第i个资源对象中包含的其他子资源对象在所述各个扩展方向上按照各自对应的第二扩展比例进行扩展,得到扩展后的第i个资源对象和扩展后的其他子资源对象;
将所述扩展后的第i个资源对象和所述扩展后的其他子资源对象按照第二旋转方向旋转所述旋转角度,得到处理后的第i个资源对象和处理后的其他子资源对象,所述第二旋转方向为所述第一旋转方向的反方向。
在一些实施例中,该第一扩展模块,还配置为:
获取位于所述旋转后的第i个资源对象外部的其他资源对象的外边界信息和所述旋转后的第i个资源对象的包围盒;
从所述旋转后的第i个资源对象的外边界上确定第j个扩展方向对应的多个候选点;
从各个候选点沿所述第j个扩展方向发射第三射线,确定各条第三射线与所述其他资源对象的外边界的第三最近交点;
确定所述各个候选点到所述包围盒的目标边的各个第三距离,并确定所述各个第三最近交点到所述目标边的各个第四距离,所述目标边为所述包围盒上与所述第j个扩展方向的相反方向对应的边;
基于所述各个第三距离和对应的所述各个第四距离,确定各个候选点对应的第三候选扩展比例;
将多个第三候选扩展比例中的最小值确定为所述第j个扩展方向的第二扩展比例。
在一些实施例中,该装置还包括:
第二确定模块,配置为当确定所述目标容器中存在第i个资源对象的对称对象时,基于所述第i个资源对象的扩展类型,分别确定所述第i个资源对象的第一参考扩展比例和所述对称对象的第二参考扩展比例;
第三确定模块,配置为将所述第一参考扩展比例和所述第二参考扩展比例中的最小值,确定为所述第i个资源对象和所述对称对象的目标扩展比例;
第二扩展模块,配置为按照所述目标扩展比例对所述第i个资源对象和所述对称对象进行扩展处理,得到处理后的第i个资源对象和处理后的对称对象。
在一些实施例中,该装置还包括:
第四确定模块,配置为在对第1个至第N个资源对象进行扩展处理后,确定所述目标容器的第一填充率;
第三扩展模块,配置为当确定所述第一填充率小于预设的填充率阈值时,依次对第N个资源对象至第1个资源对象按照各自对应的扩展类型进行扩展处理,得到第二次处理后的第N个资源对象至第1个资源对象;
第五确定模块,配置为确定所述目标容器的第二填充率;
第六确定模块,配置为当所述第二填充率大于所述第一填充率时,将所述第二次处理后的第N个资源对象至第1个资源对象确定为目标扩展结果。
需要说明的是,本申请实施例针对对象处理装置的描述,与上述方法实施例的描述
是类似的,具有同方法实施例相似的有益效果。对于本装置实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。
本申请实施例提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行本申请实施例上述的对象处理方法。
本申请实施例提供一种存储有可执行指令的计算机可读存储介质,其中存储有可执行指令,当可执行指令被处理器执行时,将引起处理器执行本申请实施例提供的对象处理方法,例如,如图4A、图4B、图5和图6示出的对象处理方法。
在一些实施例中,计算机可读存储介质可以是FRAM、ROM、PROM、EPROM、EEPROM、闪存、磁表面存储器、光盘、或CD-ROM等存储器;也可以是包括上述存储器之一或任意组合的各种设备。
在一些实施例中,可执行指令可以采用程序、软件、软件模块、脚本或代码的形式,按任意形式的编程语言(包括编译或解释语言,或者声明性或过程性语言)来编写,并且其可按任意形式部署,包括被部署为独立的程序或者被部署为模块、组件、子例程或者适合在计算环境中使用的其它单元。
作为示例,可执行指令可以但不一定对应于文件系统中的文件,可以被存储在保存其它程序或数据的文件的一部分,例如,存储在超文本标记语言(HTML,Hyper Text Markup Language)文档中的一个或多个脚本中,存储在专用于所讨论的程序的单个文件中,或者,存储在多个协同文件(例如,存储一个或多个模块、子程序或代码部分的文件)中。
作为示例,可执行指令可被部署为在一个计算设备上执行,或者在位于一个地点的多个计算设备上执行,又或者,在分布在多个地点且通过通信网络互连的多个计算设备上执行。
以上所述,仅为本申请的实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和范围之内所作的任何修改、等同替换和改进等,均包含在本申请的保护范围之内。
Claims (18)
- 一种对象处理方法,应用于贴图渲染场景,所述方法应用于计算机设备,包括:获取待处理的多个资源对象在目标容器中的初始填充结果;基于所述初始填充结果,将各个资源对象移动至各自对应的可用空间的中心位置;获取所述各个资源对象的对称属性信息和包含关系信息;基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,其中,所述扩展类型包括各向同性扩展和各向异性扩展中的一种;基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象。
- 根据权利要求1中所述的方法,其中,所述基于所述初始填充结果,将各个资源对象移动至各自对应的可用空间的中心位置,包括:获取预设的移动迭代次数阈值和单个资源对象的移动次数阈值;获取当前移动迭代次数,当所述当前移动迭代次数小于所述移动迭代次数阈值时,获取第i个资源对象的当前移动次数,i=1,2,…N,N为资源对象总数,N为大于2的整数;当所述第i个资源对象的当前移动次数小于所述移动次数阈值时,确定将所述第i个资源对象的对象中心移动至所述第i个资源对象所在可用空间的中心位置的移动信息;当基于所述移动信息,确定所述第i个资源对象的移动距离大于预设的距离阈值时,将所述第i个资源对象的对象中心移动至所述可用空间的中心位置,并更新所述第i个资源对象的当前移动次数。
- 根据权利要求2中所述的方法,其中,所述方法还包括:在完成第1个资源对象至第N个资源对象的当前移动迭代过程后,更新所述当前移动迭代次数,得到更新后的当前移动迭代次数;确定所述更新后的当前移动迭代次数小于所述移动迭代次数阈值时,继续移动所述第1个资源对象至第N个资源对象。
- 根据权利要求1中所述的方法,其中,所述基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,包括:当基于第i个资源对象的对称属性信息表征所述第i个资源对象具备内部对称特征,且基于所述第i个资源对象的包含关系信息确定所述第i个资源对象未被父资源对象包含时,确定所述第i个资源对象的扩展类型为各向异性扩展,其中,i=1,2,…N,N为资源对象总数,N为大于2的整数。
- 根据权利要求4中所述的方法,其中,所述基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,包括:当基于第i个资源对象的对称属性信息表征所述第i个资源对象不具备内部对称特征时,确定所述第i个资源对象的扩展类型为各向同性扩展。
- 根据权利要求4中所述的方法,其中,所述基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,包括:当所述第i个资源对象被父资源对象包含时,获取所述父资源对象的扩展类型;当所述父资源对象的扩展类型为各向同性扩展时,确定所述第i个资源对象的扩展类型为各向同性扩展。
- 根据权利要求6中所述的方法,其中,所述基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,包括:当所述父资源对象的扩展类型为各向异性扩展时,获取所述父资源对象包含的其他 子资源对象;当基于所述其他子资源对象的对称属性信息,确定所述其他子资源对象均具备内部对称特征时,确定所述第i个资源对象的扩展类型为各向异性扩展;当基于所述其他子资源对象的对称属性信息,确定至少存在一个其他子资源对象不具备内部对称特征时,确定所述第i个资源对象的扩展类型为各向同性扩展。
- 根据权利要求1中所述的方法,其中,所述基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象,包括:当确定所述目标容器中不存在第i个资源对象的对称对象,且第i个资源对象的扩展类型为各向同性扩展时,确定所述第i个资源对象的第一扩展比例,i=1,2,…N,N为资源对象总数,N为大于2的整数;当基于所述第i个资源对象的包含关系信息,确定所述第i个资源对象中包含有其他子资源对象时,将所述第i个资源对象和所述第i个资源对象中包含的其他子资源对象按照所述第一扩展比例,对所述第i个资源对象和所述第i个资源对象中包含的其他子资源对象进行扩展处理,得到处理后的第i个资源对象和处理后的其他子资源对象。
- 根据权利要求8中所述的方法,其中,所述确定所述第i个资源对象的第一扩展比例,包括:获取位于所述第i个资源对象外部的其他资源对象的外边界信息、所述第i个资源对象的外边界信息和所述第i个资源对象的对象中心;从所述第i个资源对象的对象中心向所述第i个资源对象的外边界上的各个第一顶点发射第一射线,确定各条第一射线与所述其他资源对象的外边界的各个第一最近交点;基于所述对象中心的中心坐标、所述各个第一顶点的第一顶点坐标和各个第一最近交点的第一交点坐标,确定各个第一顶点对应的第一候选扩展比例;从所述其他资源对象的外边界上的各个第二顶点向所述第i个资源对象的对象中心发射第二射线,确定各条第二射线与所述第i个资源对象的外边界的各个第二最近交点;基于所述对象中心的中心坐标、所述各个第二顶点的第二顶点坐标和各个第二最近交点的第二交点坐标,确定各个第二顶点对应的第二候选扩展比例;将多个第一候选扩展比例和多个第二候选扩展比例中的最小值确定为所述第i个资源对象的第一扩展比例。
- 根据权利要求9所述的方法,其中,所述基于所述对象中心的中心坐标、所述各个第一顶点的第一顶点坐标和各个第一最近交点的第一交点坐标,确定各个第一顶点对应的第一候选扩展比例,包括:获取预设的间隔距离,基于所述间隔距离和所述各个第一最近交点的交点坐标确定各个第一最近交点对应的第一目标点的第一目标坐标;基于所述对象中心的中心坐标和所述各个第一顶点的第一顶点坐标确定所述各个第一顶点对应的第一距离;基于所述对象中心的中心坐标和各个第一目标点的第一目标坐标确定所述各个第一顶点对应的第二距离;基于所述各个第一顶点对应的第一距离和第二距离,确定各个第一顶点对应的第一候选扩展比例。
- 根据权利要求1中所述的方法,其中,所述基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象,包括:当第i个资源对象的扩展类型为各向异性扩展时,获取所述第i个资源对象的主轴信息,并基于所述第i个资源对象的主轴信息确定旋转角度和第一旋转方向,i=1,2,…N,N为大于2的整数,表示资源对象总数;将N个资源对象按照所述第一旋转方向旋转所述旋转角度,得到旋转后的N个资源对象,其中,旋转后的第i个资源对象的主轴为水平方向;将所述旋转后的第i个资源对象的对象中心移动至对应的可用空间的中心位置;确定所述旋转后的第i个资源对象在预设的各个扩展方向上的第二扩展比例;当基于所述第i个资源对象的包含关系信息,确定所述旋转后的第i个资源对象中包含有其他子资源对象时,将所述旋转后的第i个资源对象和所述旋转后的第i个资源对象中包含的其他子资源对象在所述各个扩展方向上按照各自对应的第二扩展比例进行扩展,得到扩展后的第i个资源对象和扩展后的其他子资源对象;将所述扩展后的第i个资源对象和所述扩展后的其他子资源对象按照第二旋转方向旋转所述旋转角度,得到处理后的第i个资源对象和处理后的其他子资源对象,所述第二旋转方向为所述第一旋转方向的反方向。
- 根据权利要求11中所述的方法,其中,所述确定所述旋转后的第i个资源对象在预设的各个扩展方向上的第二扩展比例,包括:获取位于所述旋转后的第i个资源对象外部的其他资源对象的外边界信息和所述旋转后的第i个资源对象的包围盒;从所述旋转后的第i个资源对象的外边界上确定第j个扩展方向对应的多个候选点,j为小于或者等于M的正整数,M为扩展方向总数,M为大于或者等于1的整数;从各个候选点沿所述第j个扩展方向发射第三射线,确定各条第三射线与所述其他资源对象的外边界的第三最近交点;确定所述各个候选点到所述包围盒的目标边的各个第三距离,并确定所述各个第三最近交点到所述目标边的各个第四距离,所述目标边为所述包围盒上与所述第j个扩展方向的相反方向对应的边;基于所述各个第三距离和对应的所述各个第四距离,确定各个候选点对应的第三候选扩展比例;将多个第三候选扩展比例中的最小值确定为所述第j个扩展方向的第二扩展比例。
- 根据权利要求1中所述的方法,其中,所述方法还包括:当确定所述目标容器中存在第i个资源对象的对称对象时,基于所述第i个资源对象的扩展类型,分别确定所述第i个资源对象的第一参考扩展比例和所述对称对象的第二参考扩展比例;将所述第一参考扩展比例和所述第二参考扩展比例中的最小值,确定为所述第i个资源对象和所述对称对象的目标扩展比例;按照所述目标扩展比例对所述第i个资源对象和所述对称对象进行扩展处理,得到处理后的第i个资源对象和处理后的对称对象。
- 根据权利要求1至13任一项所述的方法,其中,所述方法还包括:在对第1个至第N个资源对象进行扩展处理后,确定所述目标容器的第一填充率;当确定所述第一填充率小于预设的填充率阈值时,依次对第N个资源对象至第1个资源对象按照各自对应的扩展类型进行扩展处理,得到第二次处理后的第N个资源对象至第1个资源对象;确定所述目标容器的第二填充率;当所述第二填充率大于所述第一填充率时,将所述第二次处理后的第N个资源对象至第1个资源对象确定为目标扩展结果。
- 一种对象处理装置,所述装置包括:第一获取模块,配置为获取待处理的多个资源对象在目标容器中的的初始填充结果;第一移动模块,配置为基于所述初始填充结果,将各个资源对象移动至各自对应的 可用空间的中心位置;第二获取模块,配置为获取所述各个资源对象的对称属性信息和包含关系信息;第一确定模块,配置为基于所述各个资源对象的对称属性信息和包含关系信息确定所述各个资源对象的扩展类型,其中,所述扩展类型包括各向同性扩展和各向异性扩展中的一种;第一扩展模块,配置为基于所述各个资源对象的扩展类型,对所述各个资源对象进行扩展处理,得到处理后的各个资源对象。
- 一种计算机设备,所述计算机设备包括:存储器,用于存储可执行指令;处理器,用于执行所述存储器中存储的可执行指令时,实现权利要求1至14任一项所述的对象处理方法。
- 一种计算机可读存储介质,存储有可执行指令,所述可执行指令被处理器执行时实现权利要求1至14任一项所述的对象处理方法。
- 一种计算机程序产品,包括计算机程序或指令,所述计算机程序或指令被处理器执行时实现权利要求1至14任一项所述的对象处理方法。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US18/435,778 US20240177396A1 (en) | 2022-06-17 | 2024-02-07 | Object processing method and apparatus, device, computer-readable storage medium, and computer program product |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210684708.8A CN114781014B (zh) | 2022-06-17 | 2022-06-17 | 对象处理方法、装置、设备及计算机可读存储介质 |
CN202210684708.8 | 2022-06-17 |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US18/435,778 Continuation US20240177396A1 (en) | 2022-06-17 | 2024-02-07 | Object processing method and apparatus, device, computer-readable storage medium, and computer program product |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023241212A1 true WO2023241212A1 (zh) | 2023-12-21 |
Family
ID=82421428
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2023/089104 WO2023241212A1 (zh) | 2022-06-17 | 2023-04-19 | 对象处理方法、装置、设备、计算机可读存储介质及计算机程序产品 |
Country Status (3)
Country | Link |
---|---|
US (1) | US20240177396A1 (zh) |
CN (1) | CN114781014B (zh) |
WO (1) | WO2023241212A1 (zh) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114781014B (zh) * | 2022-06-17 | 2022-09-09 | 腾讯科技(深圳)有限公司 | 对象处理方法、装置、设备及计算机可读存储介质 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020083314A1 (en) * | 2000-12-21 | 2002-06-27 | Microsoft Corporation | Extensible actions and container types in an extensible scene graph system |
US20150160979A1 (en) * | 2013-12-06 | 2015-06-11 | International Business Machines Corporation | Multi-dimensional computing and communication resource allocation using bin-packing with per-branch combination tries |
CN113791914A (zh) * | 2021-11-17 | 2021-12-14 | 腾讯科技(深圳)有限公司 | 对象处理方法、装置、计算机设备、存储介质及产品 |
CN114255160A (zh) * | 2022-02-28 | 2022-03-29 | 腾讯科技(深圳)有限公司 | 数据处理方法、装置、设备及存储介质 |
CN114781014A (zh) * | 2022-06-17 | 2022-07-22 | 腾讯科技(深圳)有限公司 | 对象处理方法、装置、设备及计算机可读存储介质 |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104504469A (zh) * | 2014-12-19 | 2015-04-08 | 西安电子科技大学 | 基于三维移动模式序列与多智能体遗传算法的装箱方法 |
CN104504468B (zh) * | 2014-12-19 | 2018-03-13 | 西安电子科技大学 | 基于三维移动模式序列与密母算法的三维装箱方法 |
CN113920184B (zh) * | 2021-12-13 | 2022-03-11 | 腾讯科技(深圳)有限公司 | 多边形简化方法、装置、设备及计算机可读存储介质 |
-
2022
- 2022-06-17 CN CN202210684708.8A patent/CN114781014B/zh active Active
-
2023
- 2023-04-19 WO PCT/CN2023/089104 patent/WO2023241212A1/zh active Application Filing
-
2024
- 2024-02-07 US US18/435,778 patent/US20240177396A1/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020083314A1 (en) * | 2000-12-21 | 2002-06-27 | Microsoft Corporation | Extensible actions and container types in an extensible scene graph system |
US20150160979A1 (en) * | 2013-12-06 | 2015-06-11 | International Business Machines Corporation | Multi-dimensional computing and communication resource allocation using bin-packing with per-branch combination tries |
CN113791914A (zh) * | 2021-11-17 | 2021-12-14 | 腾讯科技(深圳)有限公司 | 对象处理方法、装置、计算机设备、存储介质及产品 |
CN114255160A (zh) * | 2022-02-28 | 2022-03-29 | 腾讯科技(深圳)有限公司 | 数据处理方法、装置、设备及存储介质 |
CN114781014A (zh) * | 2022-06-17 | 2022-07-22 | 腾讯科技(深圳)有限公司 | 对象处理方法、装置、设备及计算机可读存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN114781014B (zh) | 2022-09-09 |
US20240177396A1 (en) | 2024-05-30 |
CN114781014A (zh) | 2022-07-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11544900B2 (en) | Primitive-based 3D building modeling, sensor simulation, and estimation | |
CN109145366B (zh) | 基于Web3D的建筑信息模型轻量级可视化方法 | |
CN112734641B (zh) | 目标检测模型的训练方法、装置、计算机设备及介质 | |
CN112085840B (zh) | 语义分割方法、装置、设备及计算机可读存储介质 | |
WO2023226583A1 (zh) | 对象处理方法、装置、设备、计算机可读存储介质及计算机程序产品 | |
US10885707B1 (en) | Network, system and method for multi-view 3D mesh generation via deformation | |
US20240338895A1 (en) | Three-Dimensional Model Expansion Methods and Systems | |
WO2022166681A1 (zh) | 一种虚拟场景生成方法、装置、设备和存储介质 | |
KR20180080051A (ko) | 기계 학습 방법 및 장치 | |
WO2023241212A1 (zh) | 对象处理方法、装置、设备、计算机可读存储介质及计算机程序产品 | |
CN107798725A (zh) | 基于Android的二维住房户型识别和三维呈现方法 | |
US20230298237A1 (en) | Data processing method, apparatus, and device and storage medium | |
WO2023193523A1 (zh) | 一种模型展开方法、装置、电子设备、计算机可读存储介质及计算机程序产品 | |
CN116246012A (zh) | 一种虚拟建筑模型的生成方法、装置、以及电子设备 | |
WO2023159882A1 (zh) | 一种空间碰撞检测方法、装置及电子设备 | |
KR20230163921A (ko) | 목표 대상의 상호작용적 재구성을 위한 제어 방법, 장치, 기기 및 저장 매체 | |
JP2023529790A (ja) | フロアプランを生成するための方法、装置およびプログラム | |
CN107016732A (zh) | 使用描述符的3d对象定位 | |
US20230342715A1 (en) | Placement location obtaining method, model training method, and related device | |
US20230351696A1 (en) | Data processing method and apparatus, device, computer-readable storage medium, and computer program product | |
CN116309993A (zh) | 一种服务器、人物模型表情基的驱动方法及存储介质 | |
CN111291717A (zh) | 基于图像的物体检测方法、装置、设备及可读存储介质 | |
CN107066926A (zh) | 使用描述符的3d对象定位 | |
US9043742B1 (en) | Methods, systems, and articles of manufacture for implementing physical design using force models with custom connectivity | |
CN112231800B (zh) | Bim图形的优化方法、装置以及计算机存储介质 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 23822783 Country of ref document: EP Kind code of ref document: A1 |
|
WWE | Wipo information: entry into national phase |
Ref document number: 11202401739S Country of ref document: SG |