Blender: Bake Wrangler Wrapper
This commit is contained in:
parent
9222104a1a
commit
10d5ed451a
23 changed files with 11362 additions and 5 deletions
674
cg/blender/scripts/addons/BakeWrangler/LICENSE
Normal file
674
cg/blender/scripts/addons/BakeWrangler/LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
207
cg/blender/scripts/addons/BakeWrangler/__init__.py
Normal file
207
cg/blender/scripts/addons/BakeWrangler/__init__.py
Normal file
|
@ -0,0 +1,207 @@
|
|||
'''
|
||||
Copyright (C) 2019-2023 Dancing Fortune Software All Rights Reserved
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
'''
|
||||
|
||||
bl_info = {
|
||||
'name': 'Bake Wrangler',
|
||||
'description': 'Bake Wrangler aims to improve all baking tasks with a node based interface and provides additional bake passes',
|
||||
'author': 'DFS',
|
||||
'version': (1, 5, 'b11'),
|
||||
'blender': (3, 6, 0),
|
||||
'location': 'Editor Type > Bake Node Editor',
|
||||
"warning": "Beta Version",
|
||||
'doc_url': 'https://bake-wrangler.readthedocs.io',
|
||||
"tracker_url": "https://blenderartists.org/t/bake-wrangler-node-based-baking-tool-set/",
|
||||
"support": "COMMUNITY",
|
||||
'category': 'Baking'}
|
||||
|
||||
|
||||
import bpy
|
||||
from . import nodes
|
||||
from . import status_bar
|
||||
|
||||
|
||||
# Preferences
|
||||
class BakeWrangler_Preferences(bpy.types.AddonPreferences):
|
||||
bl_idname = __package__
|
||||
|
||||
def update_icon(self, context):
|
||||
if not self.show_icon:
|
||||
status_bar.status_bar_icon.disable_bw_icon()
|
||||
else:
|
||||
status_bar.status_bar_icon.ensure_bw_icon()
|
||||
|
||||
# Message prefs
|
||||
show_icon: bpy.props.BoolProperty(name="Show BW Icon in Status Bar", description="Shows an icon that changes color based on baking state and can be clicked on to bring up the log", default=True, update=update_icon)
|
||||
text_msgs: bpy.props.BoolProperty(name="Messages to Text editor", description="Write messages to a text block in addition to the console", default=True)
|
||||
clear_msgs: bpy.props.BoolProperty(name="Clear Old Messages", description="Clear the text block before each new bake", default=True)
|
||||
wind_msgs: bpy.props.BoolProperty(name="Open Text in new Window", description="A new window will be opened displaying the text block each time a new bake is started", default=False)
|
||||
wind_close: bpy.props.BoolProperty(name="Auto Close Text Window", description="Close the text window on successful bake completion", default=False)
|
||||
|
||||
# Node prefs
|
||||
show_node_prefs: bpy.props.BoolProperty(name="Node Defaults", description="Default general node options", default=False)
|
||||
def_filter_mesh: bpy.props.BoolProperty(name="Meshes", description="Show mesh type objects", default=True)
|
||||
def_filter_curve: bpy.props.BoolProperty(name="Curves", description="Show curve type objects", default=True)
|
||||
def_filter_surface: bpy.props.BoolProperty(name="Surfaces", description="Show surface type objects", default=True)
|
||||
def_filter_meta: bpy.props.BoolProperty(name="Metas", description="Show meta type objects", default=True)
|
||||
def_filter_font: bpy.props.BoolProperty(name="Fonts", description="Show font type objects", default=True)
|
||||
def_filter_light: bpy.props.BoolProperty(name="Lights", description="Show light type objects", default=True)
|
||||
def_filter_collection: bpy.props.BoolProperty(name="Collections", description="Toggle only collections", default=False)
|
||||
def_show_adv: bpy.props.BoolProperty(name="Expand Advanced Settings", description="Expand advanced settings on node creation instead of starting with them collapsed", default=False)
|
||||
invert_bakemod: bpy.props.BoolProperty(name="Invert Selected in Bake Modifiers", description="Inverts the selection method used by the Bake Modifiers option from ignoring viewport hidden modifiers to baking them", default=False)
|
||||
|
||||
# Render prefs
|
||||
show_render_prefs: bpy.props.BoolProperty(name="Render Defaults", description="Default settings for rendering options", default=False)
|
||||
def_samples: bpy.props.IntProperty(name="Default Bake Samples", description="The number of samples per pixel that new Pass nodes will be set to when created", default=1, min=1)
|
||||
def_xres: bpy.props.IntProperty(name="Default Bake X Resolution", description="The X resolution new Pass nodes will be set to when created", default=1024, min=1, subtype='PIXEL')
|
||||
def_yres: bpy.props.IntProperty(name="Default Bake Y Resolution", description="The Y resolution new Pass nodes will be set to when created", default=1024, min=1, subtype='PIXEL')
|
||||
def_device: bpy.props.EnumProperty(name="Default Device", description="The render device new Pass nodes will be set to when created", items=nodes.node_tree.BakeWrangler_PassSettings.cycles_devices, default='CPU')
|
||||
def_raydist: bpy.props.FloatProperty(name="Default Ray Distance", description="The ray distance that new Mesh nodes will use when created", default=0.01, step=1, min=0.0, unit='LENGTH')
|
||||
def_max_ray_dist: bpy.props.FloatProperty(name="Default Max Ray Dist", description="The max ray distance that new Mesh nodes will use when created", default=0.0, step=1, min=0.0, unit='LENGTH')
|
||||
def_margin: bpy.props.IntProperty(name="Default Margin", description="The margin that new Mesh nodes will use when created", default=0, min=0, subtype='PIXEL')
|
||||
def_mask_margin: bpy.props.IntProperty(name="Default Mask Margin", description="The mask margin that new Mesh nodes will use when created", default=0, min=0, subtype='PIXEL')
|
||||
ignore_vis: bpy.props.BoolProperty(name="Objects Always Visible", description="Enable to ignore the visibility of selected objects when baking, making them visible regardless of settings in blender", default=False)
|
||||
|
||||
# Ouput prefs
|
||||
show_output_prefs: bpy.props.BoolProperty(name="Output Defaults", description="Default settings for output options", default=False)
|
||||
def_format: bpy.props.EnumProperty(name="Default Output Format", description="The format new Output nodes will use when created", items=nodes.node_tree.BakeWrangler_OutputSettings.img_format, default='PNG')
|
||||
def_xout: bpy.props.IntProperty(name="Default Output X Resolution", description="The X resolution new Output nodes will be set to when created", default=1024, min=1, subtype='PIXEL')
|
||||
def_yout: bpy.props.IntProperty(name="Default Output Y Resolution", description="The Y resolution new Output nodes will be set to when created", default=1024, min=1, subtype='PIXEL')
|
||||
def_outpath: bpy.props.StringProperty(name="Default Output Path", description="The path new Output nodes will use when created", default="", subtype='DIR_PATH')
|
||||
def_outname: bpy.props.StringProperty(name="Default Output Name", description="The name new Output nodes will use when created", default="Image", subtype='FILE_NAME')
|
||||
make_dirs: bpy.props.BoolProperty(name="Create Paths", description="If selected path doesn't exist, try to create it", default=False)
|
||||
auto_open: bpy.props.BoolProperty(name="Auto open bakes", description="Automatically open the baked image in blender if it isn't already open", default=True)
|
||||
save_packed: bpy.props.BoolProperty(name="Save packed images", description="Prior to baking, save any packed images with changes or they will not apply during the bake", default=False)
|
||||
save_images: bpy.props.BoolProperty(name="Save unpacked images", description="Prior to baking, save any unpacked images with changes or they will not apply during the bake", default=False)
|
||||
img_non_color: bpy.props.EnumProperty(name="Non-Color", description="Color space to use as non-color when alternative color spaces are in use", items=nodes.node_tree.BakeWrangler_OutputSettings.img_color_spaces)
|
||||
|
||||
# Performance prefs
|
||||
fact_start: bpy.props.BoolProperty(name="Disable Add-ons", description="Disable add-ons in the background baking instance (faster load times and some 3rd party add-ons can crash the process)", default=True)
|
||||
retrys: bpy.props.IntProperty(name="Retries", description="On bake failure retry this many times", default=0)
|
||||
|
||||
# Dev prefs
|
||||
debug: bpy.props.BoolProperty(name="Debug", description="Enable additional debugging output", default=False)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
colprefs = layout.column(align=False)
|
||||
|
||||
coltext = colprefs.column(align=False)
|
||||
coltext.prop(self, "show_icon")
|
||||
coltext.prop(self, "text_msgs")
|
||||
if self.text_msgs:
|
||||
box = coltext.box()
|
||||
box.prop(self, "clear_msgs")
|
||||
box.prop(self, "wind_msgs")
|
||||
row = box.row(align=True)
|
||||
row.label(icon='THREE_DOTS')
|
||||
row.prop(self, "wind_close")
|
||||
if self.wind_msgs:
|
||||
row.enabled = True
|
||||
else:
|
||||
row.enabled = False
|
||||
|
||||
# Node prefs
|
||||
box = colprefs.box()
|
||||
if not self.show_node_prefs:
|
||||
box.prop(self, "show_node_prefs", icon="DISCLOSURE_TRI_RIGHT", emboss=False)
|
||||
else:
|
||||
box.prop(self, "show_node_prefs", icon="DISCLOSURE_TRI_DOWN", emboss=False)
|
||||
col = box.column(align=False)
|
||||
row = col.row(align=True)
|
||||
row.alignment = 'LEFT'
|
||||
row.label(text="Filter:")
|
||||
row1 = row.row(align=True)
|
||||
row1.alignment = 'LEFT'
|
||||
row1.prop(self, "def_filter_mesh", text="", icon='MESH_DATA')
|
||||
row1.prop(self, "def_filter_curve", text="", icon='CURVE_DATA')
|
||||
row1.prop(self, "def_filter_surface", text="", icon='SURFACE_DATA')
|
||||
row1.prop(self, "def_filter_meta", text="", icon='META_DATA')
|
||||
row1.prop(self, "def_filter_font", text="", icon='FONT_DATA')
|
||||
row1.prop(self, "def_filter_light", text="", icon='LIGHT_DATA')
|
||||
if self.def_filter_collection:
|
||||
row1.enabled = False
|
||||
row2 = row.row(align=False)
|
||||
row2.alignment = 'LEFT'
|
||||
row2.prop(self, "def_filter_collection", text="", icon='GROUP')
|
||||
col.prop(self, "def_show_adv")
|
||||
col.prop(self, "invert_bakemod")
|
||||
|
||||
# Render prefs
|
||||
box = colprefs.box()
|
||||
if not self.show_render_prefs:
|
||||
box.prop(self, "show_render_prefs", icon="DISCLOSURE_TRI_RIGHT", emboss=False)
|
||||
else:
|
||||
box.prop(self, "show_render_prefs", icon="DISCLOSURE_TRI_DOWN", emboss=False)
|
||||
col = box.column(align=False)
|
||||
col.prop(self, "def_samples", text="Samples")
|
||||
col1 = col.column(align=True)
|
||||
col1.prop(self, "def_xres", text="X")
|
||||
col1.prop(self, "def_yres", text="Y")
|
||||
col.prop(self, "def_device", text="Device")
|
||||
col.prop(self, "def_margin", text="Margin")
|
||||
col.prop(self, "def_mask_margin", text="Mask Margin")
|
||||
col.prop(self, "def_raydist", text="Ray Distance")
|
||||
col.prop(self, "def_max_ray_dist", text="Max Ray Dist")
|
||||
col.prop(self, "ignore_vis")
|
||||
|
||||
# Output prefs
|
||||
box = colprefs.box()
|
||||
if not self.show_output_prefs:
|
||||
box.prop(self, "show_output_prefs", icon="DISCLOSURE_TRI_RIGHT", emboss=False)
|
||||
else:
|
||||
box.prop(self, "show_output_prefs", icon="DISCLOSURE_TRI_DOWN", emboss=False)
|
||||
col = box.column(align=False)
|
||||
col.prop(self, "def_format", text="Format")
|
||||
col1 = col.column(align=True)
|
||||
col1.prop(self, "def_xout", text="X")
|
||||
col1.prop(self, "def_yout", text="Y")
|
||||
col2 = col.column(align=True)
|
||||
col2.prop(self, "def_outpath", text="Image Path")
|
||||
col2.prop(self, "def_outname", text="Image Name")
|
||||
col.prop(self, "make_dirs")
|
||||
col.prop(self, "auto_open")
|
||||
|
||||
# Dev prefs
|
||||
col = colprefs.column(align=True)
|
||||
col.prop(self, "fact_start")
|
||||
col.prop(self, "save_packed")
|
||||
col.prop(self, "save_images")
|
||||
col.prop(self, "retrys")
|
||||
if 'Non-Color' not in bpy.types.ColorManagedInputColorspaceSettings.bl_rna.properties['name'].enum_items.keys():
|
||||
col.prop(self, "img_non_color")
|
||||
col.prop(self, "debug")
|
||||
|
||||
|
||||
|
||||
def register():
|
||||
from bpy.utils import register_class
|
||||
register_class(BakeWrangler_Preferences)
|
||||
# Add status property to the window manager
|
||||
bpy.types.WindowManager.bw_status = bpy.props.IntProperty(name="Bake Wrangler Status", default=0)
|
||||
bpy.types.WindowManager.bw_lastlog = bpy.props.StringProperty(name="Bake Wangler Log", default="")
|
||||
bpy.types.WindowManager.bw_lastfile = bpy.props.StringProperty(name="Bake Wangler Temp Blend", default="")
|
||||
nodes.register()
|
||||
status_bar.register()
|
||||
|
||||
|
||||
def unregister():
|
||||
from bpy.utils import unregister_class
|
||||
nodes.unregister()
|
||||
status_bar.unregister()
|
||||
unregister_class(BakeWrangler_Preferences)
|
||||
# Remove status property from window manager
|
||||
delattr(bpy.types.WindowManager, 'bw_status')
|
3030
cg/blender/scripts/addons/BakeWrangler/baker.py
Normal file
3030
cg/blender/scripts/addons/BakeWrangler/baker.py
Normal file
File diff suppressed because it is too large
Load diff
162
cg/blender/scripts/addons/BakeWrangler/marginer.py
Normal file
162
cg/blender/scripts/addons/BakeWrangler/marginer.py
Normal file
|
@ -0,0 +1,162 @@
|
|||
import numpy as np
|
||||
|
||||
# Main loop over image broken into segments. Will try to calculate pixel values outside of
|
||||
# the masked area using the preconfigured weighting system.
|
||||
def worker(hunk, shm_pixels, shm_mask, shm_bools, shm_margin, margin, limit, hit_target):
|
||||
np_pixels = np.ndarray(shm_pixels[1], dtype=shm_pixels[2], buffer=shm_pixels[0].buf)
|
||||
np_mask = np.ndarray(shm_mask[1], dtype=shm_mask[2], buffer=shm_mask[0].buf)
|
||||
np_bools = np.ndarray(shm_bools[1], dtype=shm_bools[2], buffer=shm_bools[0].buf)
|
||||
margins_bool = np.ndarray(shm_margin[1], dtype=shm_margin[2], buffer=shm_margin[0].buf)
|
||||
hit_stub = np.zeros((0,3))
|
||||
lim = len(margins_bool) if not limit else limit
|
||||
for multi_index in hunk:
|
||||
# Index ranges to create local view of arrays centred on pixel
|
||||
view_idx = [multi_index[0],
|
||||
multi_index[0]+(margin*2)+1,
|
||||
multi_index[1],
|
||||
multi_index[1]+(margin*2)+1]
|
||||
bool_view = np_bools[view_idx[0]:view_idx[1],view_idx[2]:view_idx[3]]
|
||||
hit_max = np.count_nonzero(bool_view) # Count number of non alpha pixels in view
|
||||
if hit_max:
|
||||
pixel_view = np_pixels[view_idx[0]:view_idx[1],view_idx[2]:view_idx[3]] # Get view of pixel data
|
||||
hit_targ = hit_max if hit_max < hit_target else hit_target
|
||||
hits = hit_stub
|
||||
iteration = 0
|
||||
# Majority of time cost is here due to arrays being copied in every case
|
||||
while hits.shape[0] < hit_targ and iteration < lim:
|
||||
sub_bool = bool_view[margins_bool[iteration]]
|
||||
if np.count_nonzero(sub_bool):
|
||||
sub_pixel = pixel_view[margins_bool[iteration]]
|
||||
hits = np.append(hits, sub_pixel[sub_bool,:3], axis=0) if hits.shape[0] else sub_pixel[sub_bool,:3]
|
||||
iteration += 1
|
||||
# Get average of selected pixels colour and write value
|
||||
if hits.shape[0] >= hit_target:
|
||||
np_pixels[multi_index[0]+margin, multi_index[1]+margin,:3] = hits.sum(0) / hits.shape[0]
|
||||
np_mask[multi_index[0]+margin, multi_index[1]+margin] = 1.0
|
||||
|
||||
|
||||
# Simply writes pixels to a bpy.image. This is to keep bpy outside of the main working loop
|
||||
def write_back(image, pixels):
|
||||
import bpy
|
||||
image.pixels.foreach_set(pixels.ravel())
|
||||
image.update()
|
||||
|
||||
|
||||
# Create numpy arrays of the image and mask as well as set up a weighting system for sampling
|
||||
# pixels within the margin step area
|
||||
def set_up(image, mask, margin):
|
||||
import bpy
|
||||
# Load numpy array from input image and mask
|
||||
w, h = image.size
|
||||
np_pixels = np.zeros((w, h, 4), 'f')
|
||||
np_mask = np.zeros((w, h, 4), 'f')
|
||||
image.pixels.foreach_get(np_pixels.ravel())
|
||||
mask.pixels.foreach_get(np_mask.ravel())
|
||||
|
||||
# Create a weighting system for pixel samples within the margin area
|
||||
px_offsets = np.array(np.meshgrid(np.arange(0,margin*2+1), np.arange(0,margin*2+1)))
|
||||
px_offsets = np.moveaxis(px_offsets, 0, -1) # Change to X by Y by 2
|
||||
px_offsets = np.absolute(px_offsets - [margin,margin])
|
||||
# Manhattan distance array
|
||||
#px_manhat = px_offsets.sum(2)
|
||||
# Euclid distances
|
||||
px_euclid = np.sqrt(np.power(px_offsets[:,:,0],2) + np.power(px_offsets[:,:,1],2))
|
||||
px_euclid_c = np.int_(np.ceil(px_euclid))
|
||||
px_euclid_r = np.int_(np.round(px_euclid))
|
||||
# Bool arrays for each weight level starting at 1
|
||||
margins_bool = []
|
||||
for i in range(1,margin+1):
|
||||
margins_bool.append(px_euclid_r == i)
|
||||
|
||||
# Expand pixel data by margin size by copying the start onto the end to hopefully make iteration faster
|
||||
# (negative array indexes work, but you can't exceed array bounds)
|
||||
np_pixels = np.vstack((np_pixels, np_pixels[0:margin,:,:])) # Add <margin> rows from the bottom to the top
|
||||
np_pixels = np.vstack((np_pixels[h-margin:h,:,:], np_pixels)) # Add <margin> rows from old top to the new top
|
||||
np_pixels = np.hstack((np_pixels, np_pixels[:,0:margin,:])) # Add <margin> cols from left to right
|
||||
np_pixels = np.hstack((np_pixels[:,w-margin:w,:], np_pixels)) # Add <margin> cols from old right to new right
|
||||
# Do same for mask
|
||||
np_mask = np.vstack((np_mask, np_mask[0:margin,:,:])) # Add <margin> rows from the bottom to the top
|
||||
np_mask = np.vstack((np_mask[h-margin:h,:,:], np_mask)) # Add <margin> rows from old top to the new top
|
||||
np_mask = np.hstack((np_mask, np_mask[:,0:margin,:])) # Add <margin> cols from left to right
|
||||
np_mask = np.hstack((np_mask[:,w-margin:w,:], np_mask)) # Add <margin> cols from old right to new right
|
||||
# Reduce mask values to just reds to save space
|
||||
np_mask = np_mask[...,0].copy()
|
||||
np_bool = np_mask > 0.9
|
||||
|
||||
return np_pixels, np_mask, np_bool, np.asarray(margins_bool), w, h, margin
|
||||
|
||||
|
||||
# Takes all the outputs from the setup routine (not called from within to avoid interacting with
|
||||
# bpy in the subprocesses). Creates shared memory versions of the data and spawns a bunch of
|
||||
# processes to work on smaller hunks of pixels in parallel.
|
||||
def add_margin(pixels, mask, bools, margins, w, h, margin_step, margin, hit_target):
|
||||
import concurrent.futures
|
||||
from multiprocessing.managers import SharedMemoryManager
|
||||
m_step = margin_step if margin >= margin_step or margin == -1 else margin
|
||||
with SharedMemoryManager() as smm:
|
||||
# Create shared memory versions of these arrays for the processes to share
|
||||
shm_pixels = smm.SharedMemory(size=pixels.nbytes)
|
||||
shm_mask = smm.SharedMemory(size=mask.nbytes)
|
||||
shm_bools = smm.SharedMemory(size=bools.nbytes)
|
||||
shm_margin = smm.SharedMemory(size=margins.nbytes)
|
||||
np_pixels = np.ndarray(pixels.shape, dtype=pixels.dtype, buffer=shm_pixels.buf)
|
||||
np_pixels[:] = pixels[:]
|
||||
del pixels
|
||||
np_mask = np.ndarray(mask.shape, dtype=mask.dtype, buffer=shm_mask.buf)
|
||||
np_mask[:] = mask[:]
|
||||
del mask
|
||||
np_bools = np.ndarray(bools.shape, dtype=bools.dtype, buffer=shm_bools.buf)
|
||||
np_bools[:] = bools[:]
|
||||
del bools
|
||||
margins_bool = np.ndarray(margins.shape, dtype=margins.dtype, buffer=shm_margin.buf)
|
||||
margins_bool[:] = margins
|
||||
del margins
|
||||
|
||||
# Split work into smaller hunks to split between cpu cores
|
||||
import os
|
||||
cpus = os.cpu_count() * 2
|
||||
mask_where = np.argwhere(np_bools[margin_step:w+margin_step,margin_step:h+margin_step] == False)
|
||||
hunks = np.array_split(mask_where, cpus)
|
||||
|
||||
# Do the processing in parallel
|
||||
with concurrent.futures.ProcessPoolExecutor() as executor:
|
||||
futures = []
|
||||
limit = 0
|
||||
# Negative margin indicates complete fill is wanted
|
||||
if margin == -1:
|
||||
# Simply keep processing hunks until they come back empty
|
||||
while len(hunks[0]) > 0:
|
||||
for i in hunks:
|
||||
futures.append(executor.submit(worker, i, [shm_pixels, np_pixels.shape, np_pixels.dtype], [shm_mask, np_mask.shape, np_mask.dtype], [shm_bools, np_bools.shape, np_bools.dtype], [shm_margin, margins_bool.shape, margins_bool.dtype], m_step, limit, hit_target))
|
||||
# Wait for this steps hunks to finish, then calculate the next set
|
||||
concurrent.futures.wait(futures)
|
||||
np_bools[:] = np_mask > 0.9
|
||||
mask_where = np.argwhere(np_bools[margin_step:w+margin_step,margin_step:h+margin_step] == False)
|
||||
hunks = np.array_split(mask_where, cpus)
|
||||
# Check the margin actually has a size before doing anything
|
||||
elif margin > 0:
|
||||
# Work out how many steps are needed and if a last sub step size pass will be needed at the end
|
||||
steps = int(margin / m_step)
|
||||
lasts = margin % m_step
|
||||
if lasts: steps += 1
|
||||
# Process all hunks for each step in parallel
|
||||
for step in range(steps):
|
||||
# If the margin step didn't fit evenly a last sub sized step will be done to fill it
|
||||
if lasts and step == steps-1:
|
||||
limit = lasts
|
||||
for i in hunks:
|
||||
futures.append(executor.submit(worker, i, [shm_pixels, np_pixels.shape, np_pixels.dtype], [shm_mask, np_mask.shape, np_mask.dtype], [shm_bools, np_bools.shape, np_bools.dtype], [shm_margin, margins_bool.shape, margins_bool.dtype], m_step, limit, hit_target))
|
||||
# Wait for this steps hunks to finish, then calculate the next set if there are more steps
|
||||
concurrent.futures.wait(futures)
|
||||
if step < steps-1:
|
||||
np_bools[:] = np_mask > 0.9
|
||||
mask_where = np.argwhere(np_bools[margin_step:w+margin_step,margin_step:h+margin_step] == False)
|
||||
hunks = np.array_split(mask_where, cpus)
|
||||
|
||||
# Copy pixels from shared memory before the smm exits
|
||||
output_px = np_pixels[margin_step:w+margin_step,margin_step:h+margin_step].copy()
|
||||
return output_px
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
17
cg/blender/scripts/addons/BakeWrangler/nodes/__init__.py
Normal file
17
cg/blender/scripts/addons/BakeWrangler/nodes/__init__.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from . import node_tree
|
||||
from . import node_msgbus
|
||||
from . import node_panel
|
||||
from . import node_update
|
||||
|
||||
def register():
|
||||
node_tree.register()
|
||||
node_msgbus.register()
|
||||
node_panel.register()
|
||||
node_update.register()
|
||||
|
||||
|
||||
def unregister():
|
||||
node_tree.unregister()
|
||||
node_msgbus.unregister()
|
||||
node_panel.unregister()
|
||||
node_update.unregister()
|
370
cg/blender/scripts/addons/BakeWrangler/nodes/node_mexport.py
Normal file
370
cg/blender/scripts/addons/BakeWrangler/nodes/node_mexport.py
Normal file
|
@ -0,0 +1,370 @@
|
|||
from bl_operators.presets import AddPresetBase
|
||||
from bl_ui.utils import PresetPanel
|
||||
from bpy.types import Panel, Menu, Operator
|
||||
import bpy
|
||||
|
||||
|
||||
# Helper functions and data for exporting meshes
|
||||
|
||||
|
||||
# Classes to manage FBX preset panel/menu
|
||||
class BW_PT_PresetsFBX(PresetPanel, Panel):
|
||||
bl_label = 'FBX Presets'
|
||||
preset_subdir = 'bake_wrangler\export.fbx'
|
||||
preset_operator = 'script.execute_preset'
|
||||
preset_add_operator = 'bake_wrangler.add_preset_fbx'
|
||||
|
||||
class BW_MT_PresetsFBX(Menu):
|
||||
bl_label = 'FBX Presets'
|
||||
preset_subdir = 'bake_wrangler\export.fbx'
|
||||
preset_operator = 'script.execute_preset'
|
||||
draw = Menu.draw_preset
|
||||
|
||||
class BW_OT_AddPresetFBX(AddPresetBase, Operator):
|
||||
'''Add new FBX preset'''
|
||||
bl_idname = 'bake_wrangler.add_preset_fbx'
|
||||
bl_label = 'Add FBX preset'
|
||||
preset_menu = 'BW_MT_PresetsFBX'
|
||||
|
||||
# Common variable used for all preset values
|
||||
preset_defines = [
|
||||
'node = bpy.context.active_node.FBX',
|
||||
]
|
||||
|
||||
# Properties to store in the preset
|
||||
preset_values = []
|
||||
for key in bpy.ops.export_scene.fbx.get_rna_type().properties.keys()[2:]:
|
||||
preset_values.append("node." + key)
|
||||
|
||||
# Directory to store the presets
|
||||
preset_subdir = 'bake_wrangler\export.fbx'
|
||||
|
||||
|
||||
#Helper functions and data
|
||||
export_supported = {
|
||||
'FBX': [BW_PT_PresetsFBX, 'export_scene.fbx', None],
|
||||
}
|
||||
exporters = {}
|
||||
|
||||
|
||||
def get_exporters():
|
||||
presets_enum = []
|
||||
for key, val in exporters.items():
|
||||
if key == 'FBX':
|
||||
presets_enum.append(('FBX', "FBX", "Export to FBX"))
|
||||
return tuple(presets_enum)
|
||||
|
||||
|
||||
def draw_presets(preset, layout):
|
||||
exporters[preset][0].draw_menu(layout)
|
||||
|
||||
|
||||
def draw_properties(node, preset, layout):
|
||||
props = getattr(node, preset)
|
||||
#for prop in props.rna_type.properties.keys():
|
||||
# if prop not in ["rna_type", "name"]:
|
||||
# layout.prop(props, prop)
|
||||
# Go the road to hell and have custom layouts for each format mostly stolen from their panels
|
||||
# instead of just displaying all the properties and letting god sort them out
|
||||
if preset == 'FBX':
|
||||
# Main section
|
||||
layout.use_property_decorate = False
|
||||
row = layout.row(align=True)
|
||||
row.prop(props, "path_mode")
|
||||
sub = row.row(align=True)
|
||||
sub.enabled = (props.path_mode == 'COPY')
|
||||
sub.prop(props, "embed_textures", text="", icon='PACKAGE' if props.embed_textures else 'UGLYPACKAGE')
|
||||
box = layout.box()
|
||||
if not node.show_pt_1:
|
||||
box.prop(node, "show_pt_1", icon="DISCLOSURE_TRI_RIGHT", emboss=False, text="Include")
|
||||
else:
|
||||
box.prop(node, "show_pt_1", icon="DISCLOSURE_TRI_DOWN", emboss=False, text="Include")
|
||||
box.use_property_split = True
|
||||
box.column().prop(props, "object_types")
|
||||
box.prop(props, "use_custom_props")
|
||||
box = layout.box()
|
||||
if not node.show_pt_2:
|
||||
box.prop(node, "show_pt_2", icon="DISCLOSURE_TRI_RIGHT", emboss=False, text="Transform")
|
||||
else:
|
||||
box.prop(node, "show_pt_2", icon="DISCLOSURE_TRI_DOWN", emboss=False, text="Transform")
|
||||
box.use_property_split = True
|
||||
box.prop(props, "global_scale")
|
||||
box.prop(props, "apply_scale_options")
|
||||
|
||||
box.prop(props, "axis_forward")
|
||||
box.prop(props, "axis_up")
|
||||
|
||||
box.prop(props, "apply_unit_scale")
|
||||
box.prop(props, "use_space_transform")
|
||||
row = box.row()
|
||||
row.prop(props, "bake_space_transform")
|
||||
row.label(text="", icon='ERROR')
|
||||
box = layout.box()
|
||||
if not node.show_pt_3:
|
||||
box.prop(node, "show_pt_3", icon="DISCLOSURE_TRI_RIGHT", emboss=False, text="Geometry")
|
||||
else:
|
||||
box.prop(node, "show_pt_3", icon="DISCLOSURE_TRI_DOWN", emboss=False, text="Geometry")
|
||||
box.use_property_split = True
|
||||
box.prop(props, "mesh_smooth_type")
|
||||
box.prop(props, "use_subsurf")
|
||||
box.prop(props, "use_mesh_modifiers")
|
||||
box.prop(props, "use_mesh_edges")
|
||||
sub = box.row()
|
||||
sub.prop(props, "use_tspace")
|
||||
box = layout.box()
|
||||
if not node.show_pt_4:
|
||||
box.prop(node, "show_pt_4", icon="DISCLOSURE_TRI_RIGHT", emboss=False, text="Armature")
|
||||
else:
|
||||
box.prop(node, "show_pt_4", icon="DISCLOSURE_TRI_DOWN", emboss=False, text="Armature")
|
||||
box.use_property_split = True
|
||||
box.prop(props, "primary_bone_axis")
|
||||
box.prop(props, "secondary_bone_axis")
|
||||
box.prop(props, "armature_nodetype")
|
||||
box.prop(props, "use_armature_deform_only")
|
||||
box.prop(props, "add_leaf_bones")
|
||||
box = layout.box()
|
||||
hed = box.row()
|
||||
if not node.show_pt_5:
|
||||
hed.prop(node, "show_pt_5", icon="DISCLOSURE_TRI_RIGHT", emboss=False, text="")
|
||||
hed.prop(props, "bake_anim", text="")
|
||||
hed.prop(node, "show_pt_5", icon="NONE", emboss=False, text="Bake Animation")
|
||||
else:
|
||||
hed.prop(node, "show_pt_5", icon="DISCLOSURE_TRI_DOWN", emboss=False, text="")
|
||||
hed.prop(props, "bake_anim", text="")
|
||||
hed.prop(node, "show_pt_5", icon="NONE", emboss=False, text="Bake Animation")
|
||||
box.use_property_split = True
|
||||
col = box.column()
|
||||
col.enabled = props.bake_anim
|
||||
col.prop(props, "bake_anim_use_all_bones")
|
||||
col.prop(props, "bake_anim_use_nla_strips")
|
||||
col.prop(props, "bake_anim_use_all_actions")
|
||||
col.prop(props, "bake_anim_force_startend_keying")
|
||||
col.prop(props, "bake_anim_step")
|
||||
col.prop(props, "bake_anim_simplify_factor")
|
||||
|
||||
|
||||
# Creates a property group from an operators properties
|
||||
def prop_grp_from_op(opName, grpName):
|
||||
oppath, opnm = opName.split(".")
|
||||
op = getattr(bpy.ops, oppath, None)
|
||||
if op is None:
|
||||
return op
|
||||
op = getattr(op, opnm, None)
|
||||
if op is None:
|
||||
return op
|
||||
props = op.get_rna_type()
|
||||
props = props.properties
|
||||
grp_props = {'__annotations__' : {}}
|
||||
for prop in props:
|
||||
if prop.identifier in ["rna_type", "filepath"]:
|
||||
continue
|
||||
if prop.type == 'BOOLEAN':
|
||||
grp_props['__annotations__'][prop.identifier] = bpy.props.BoolProperty(
|
||||
name=prop.name,
|
||||
description=prop.description,
|
||||
default=prop.default,
|
||||
subtype=prop.subtype)
|
||||
elif prop.type == 'ENUM':
|
||||
eitems = []
|
||||
eopts = set()
|
||||
ende =prop.default
|
||||
if prop.is_enum_flag:
|
||||
eopts = set({'ENUM_FLAG'})
|
||||
ende = prop.default_flag
|
||||
for key in prop.enum_items.keys():
|
||||
eitems.append((key, prop.enum_items[key].name, prop.enum_items[key].description))
|
||||
grp_props['__annotations__'][prop.identifier] = bpy.props.EnumProperty(
|
||||
items=tuple(eitems),
|
||||
name=prop.name,
|
||||
description=prop.description,
|
||||
options=eopts,
|
||||
default=ende)
|
||||
elif prop.type == 'STRING':
|
||||
grp_props['__annotations__'][prop.identifier] = bpy.props.StringProperty(
|
||||
name=prop.name,
|
||||
description=prop.description,
|
||||
default=prop.default,
|
||||
maxlen=prop.length_max,
|
||||
subtype=prop.subtype)
|
||||
elif prop.type == 'POINTER':
|
||||
grp_props['__annotations__'][prop.identifier] = bpy.props.PointerProperty(
|
||||
type=getattr(bpy.types, prop.fixed_type.name),
|
||||
name=prop.name,
|
||||
description=prop.description)
|
||||
elif prop.type == 'FLOAT':
|
||||
grp_props['__annotations__'][prop.identifier] = bpy.props.FloatProperty(
|
||||
name=prop.name,
|
||||
description=prop.description,
|
||||
default=prop.default,
|
||||
min=prop.hard_min,
|
||||
max=prop.hard_max,
|
||||
soft_min=prop.soft_min,
|
||||
soft_max=prop.soft_max,
|
||||
step=prop.step,
|
||||
precision=prop.precision,
|
||||
subtype=prop.subtype,
|
||||
unit=prop.unit)
|
||||
else:
|
||||
print("Unknown type: %s on %s" % (prop.type, prop.identifier))
|
||||
# Create and return prop group class from the props
|
||||
return type(grpName, tuple([bpy.types.PropertyGroup]), grp_props)
|
||||
|
||||
|
||||
# Node to export baked models in some format
|
||||
class BakeWrangler_Output_Export_Mesh(Node, BakeWrangler_Tree_Node):
|
||||
'''Node to export baked models to the selected format'''
|
||||
bl_label = 'Output Export Mesh'
|
||||
|
||||
# Makes sure there is always one empty input socket at the bottom by adding and removing sockets
|
||||
def update_inputs(self):
|
||||
BakeWrangler_Tree_Node.update_inputs(self, 'BakeWrangler_Socket_Mesh', "Mesh")
|
||||
|
||||
# Check node settings are valid to bake. Returns true/false, plus error message(s).
|
||||
def validate(self, is_primary=False):
|
||||
valid = [True]
|
||||
# Validate inputs
|
||||
has_valid_input = False
|
||||
for input in self.inputs:
|
||||
if not is_primary:
|
||||
has_valid_input = True
|
||||
break
|
||||
else:
|
||||
input_valid = get_input(input).validate()
|
||||
valid[0] = input_valid.pop(0)
|
||||
if valid[0]:
|
||||
has_valid_input = True
|
||||
valid += input_valid
|
||||
errs = len(valid)
|
||||
if not has_valid_input and errs < 2:
|
||||
valid[0] = False
|
||||
valid.append([_print("Input error", node=self, ret=True), ": No valid inputs connected"])
|
||||
# Validate file path
|
||||
self.get_full_path(bpy.context)
|
||||
if not os.path.isdir(os.path.abspath(self.out_path)):
|
||||
# Try creating the path if enabled in prefs
|
||||
if _prefs("make_dirs") and not os.path.exists(os.path.abspath(self.out_path)):
|
||||
try:
|
||||
os.makedirs(os.path.abspath(self.out_path))
|
||||
except OSError as err:
|
||||
valid[0] = False
|
||||
valid.append([_print("Path error", node=self, ret=True), ": Trying to create path at '%s'" % (err.strerror)])
|
||||
return valid
|
||||
else:
|
||||
valid[0] = False
|
||||
valid.append([_print("Path error", node=self, ret=True), ": Invalid path '%s'" % (os.path.abspath(self.out_path))])
|
||||
return valid
|
||||
# Check if there is read/write access to the file/directory
|
||||
file_path = os.path.join(os.path.abspath(self.out_path), self.name_with_ext())
|
||||
if os.path.exists(file_path):
|
||||
if os.path.isfile(file_path):
|
||||
# It exists so try to open it r/w
|
||||
try:
|
||||
file = open(file_path, "a")
|
||||
except OSError as err:
|
||||
valid[0] = False
|
||||
valid.append([_print("File error", node=self, ret=True), ": Trying to open file at '%s'" % (err.strerror)])
|
||||
else:
|
||||
# It exists but isn't a file
|
||||
valid[0] = False
|
||||
valid.append([_print("File error", node=self, ret=True), ": File exists but isn't a regular file '%s'" % (file_path)])
|
||||
else:
|
||||
# See if it can be created
|
||||
try:
|
||||
file = open(file_path, "a")
|
||||
except OSError as err:
|
||||
valid[0] = False
|
||||
valid.append([_print("File error", node=self, ret=True), ": %s trying to create file at '%s'" % (err.strerror, file_path)])
|
||||
else:
|
||||
file.close()
|
||||
os.remove(file_path)
|
||||
# Validated
|
||||
return valid
|
||||
|
||||
# Get full path, removing any relative references
|
||||
def get_full_path(self, context):
|
||||
cwd = os.path.dirname(bpy.data.filepath)
|
||||
self.out_path = os.path.normpath(os.path.join(cwd, bpy.path.abspath(self.disp_path)))
|
||||
|
||||
# Deal with any path components that may be in the filename
|
||||
def update_filename(self, context):
|
||||
fullpath = os.path.normpath(bpy.path.abspath(self.out_name))
|
||||
path, name = os.path.split(fullpath)
|
||||
if path:
|
||||
self.disp_path = self.out_name[:-len(name)]
|
||||
if name and self.out_name != name:
|
||||
self.out_name = name
|
||||
|
||||
# Return the file name with the correct extension and suffix
|
||||
def name_with_ext(self, suffix=""):
|
||||
return self.out_name + suffix + self.exporter.lower()
|
||||
|
||||
def get_exporters(self, context):
|
||||
return node_mexport.get_exporters()
|
||||
|
||||
# Core settings
|
||||
disp_path: bpy.props.StringProperty(name="Output Path", description="Path to save mesh in", default="", subtype='DIR_PATH', update=get_full_path)
|
||||
out_path: bpy.props.StringProperty(name="Output Path", description="Path to save mesh in", default="", subtype='DIR_PATH')
|
||||
out_name: bpy.props.StringProperty(name="Output File", description="File prefix to save mesh as", default="Mesh", subtype='FILE_PATH', update=update_filename)
|
||||
exporter: bpy.props.EnumProperty(name="Format", description="Export file format", items=get_exporters)
|
||||
|
||||
show_pt_1: bpy.props.BoolProperty(default=True)
|
||||
show_pt_2: bpy.props.BoolProperty(default=False)
|
||||
show_pt_3: bpy.props.BoolProperty(default=False)
|
||||
show_pt_4: bpy.props.BoolProperty(default=False)
|
||||
show_pt_5: bpy.props.BoolProperty(default=False)
|
||||
|
||||
def init(self, context):
|
||||
super().init(context)
|
||||
# Sockets IN
|
||||
self.inputs.new('BakeWrangler_Socket_Mesh', "Mesh")
|
||||
# Sockets OUT
|
||||
self.outputs.new('BakeWrangler_Socket_Bake', "Bake")
|
||||
# Prefs
|
||||
self.disp_path = _prefs("def_meshpath")
|
||||
self.out_name = _prefs("def_meshname")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
colnode = layout.column(align=False)
|
||||
colpath = colnode.column(align=True)
|
||||
colpath.prop(self, "disp_path", text="")
|
||||
colpath.prop(self, "out_name", text="")
|
||||
colpath.prop(self, "exporter")
|
||||
|
||||
def draw_buttons_ext(self, context, layout):
|
||||
node_mexport.draw_presets(self.exporter, layout.row())
|
||||
col = layout.column()
|
||||
node_mexport.draw_properties(self, self.exporter, col)
|
||||
|
||||
|
||||
# Classes to register
|
||||
classes = (
|
||||
BW_PT_PresetsFBX,
|
||||
BW_MT_PresetsFBX,
|
||||
BW_OT_AddPresetFBX,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
for exp in export_supported.keys():
|
||||
if getattr(bpy.ops, exp[1], None) is not None:
|
||||
prop_grp = prop_grp_from_op(export_supported[exp][1], "BW_PropGrp" + exp)
|
||||
exporters[exp] = [export_supported[exp][0], export_supported[exp][1], prop_grp]
|
||||
register_class(prop_grp)
|
||||
from .node_tree import BakeWrangler_Output_Export_Mesh
|
||||
setattr(BakeWrangler_Output_Export_Mesh, exp, bpy.props.PointerProperty(type=prop_grp))
|
||||
|
||||
|
||||
def unregister():
|
||||
from bpy.utils import unregister_class
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
for exp in exporters.keys():
|
||||
unregister_class(exporters[exp][2])
|
||||
exporters = {}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
114
cg/blender/scripts/addons/BakeWrangler/nodes/node_msgbus.py
Normal file
114
cg/blender/scripts/addons/BakeWrangler/nodes/node_msgbus.py
Normal file
|
@ -0,0 +1,114 @@
|
|||
import bpy
|
||||
from .node_tree import _prefs, _print, BW_TREE_VERSION
|
||||
|
||||
|
||||
# Msgbus will call this when the loaded node tree changes. Checks on tree version etc can be done
|
||||
def BakeWrangler_Msgbus_NodeTreeChange(*args):
|
||||
debug = _prefs('debug')
|
||||
if debug: _print("Node Tree Changed")
|
||||
wm = bpy.context.window_manager
|
||||
ar = bpy.context.area
|
||||
if debug: _print("Context Area: %s" % (ar))
|
||||
# First find all the open node editors that belong to BW
|
||||
spaces = []
|
||||
for window in wm.windows:
|
||||
for area in window.screen.areas:
|
||||
if area.ui_type == 'BakeWrangler_Tree':
|
||||
if len(area.spaces) > 0:
|
||||
for spc in area.spaces:
|
||||
if spc.type == 'NODE_EDITOR' and hasattr(spc, 'node_tree'):
|
||||
if debug: _print("Node editor found: %s" % (spc))
|
||||
spaces.append(spc)
|
||||
break
|
||||
for space in spaces:
|
||||
tree = space.node_tree
|
||||
# Init a new tree
|
||||
if tree and not tree.initialised:
|
||||
if debug: _print("New/Uninitialized node tree active")
|
||||
tree.use_fake_user = True
|
||||
# Give tree a nice name
|
||||
'''if tree.name.startswith("NodeTree"):
|
||||
num = 0
|
||||
for nodes in bpy.data.node_groups:
|
||||
if nodes.name.startswith("Bake Recipe"):
|
||||
if num == 0:
|
||||
num = 1
|
||||
splt = nodes.name.split('.')
|
||||
if len(splt) > 1 and splt[1].isnumeric:
|
||||
num = int(splt[1]) + 1
|
||||
if num == 0:
|
||||
name = "Bake Recipe"
|
||||
else:
|
||||
name = "Bake Recipe.%03d" % (num)
|
||||
tree.name = tree.name.replace("NodeTree", name, 1)'''
|
||||
# Add initial basic node set up
|
||||
if len(tree.nodes) == 0:
|
||||
bake_mesh = tree.nodes.new('BakeWrangler_Bake_Mesh')
|
||||
bake_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
output_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
global_mesh_set = tree.nodes.new('BakeWrangler_MeshSettings')
|
||||
global_mesh_set.pinned = True
|
||||
global_pass_set = tree.nodes.new('BakeWrangler_PassSettings')
|
||||
global_pass_set.pinned = True
|
||||
global_outp_set = tree.nodes.new('BakeWrangler_OutputSettings')
|
||||
global_outp_set.pinned = True
|
||||
global_samp_set = tree.nodes.new('BakeWrangler_SampleSettings')
|
||||
global_samp_set.pinned = True
|
||||
|
||||
bake_mesh.location[0] -= 300
|
||||
output_img.location[0] += 200
|
||||
global_mesh_set.location[0] -= 300
|
||||
global_mesh_set.location[1] += 210
|
||||
global_pass_set.location[0] += 100
|
||||
global_pass_set.location[1] += 210
|
||||
global_outp_set.location[0] += 280
|
||||
global_outp_set.location[1] += 210
|
||||
global_samp_set.location[0] -= 80
|
||||
global_samp_set.location[1] += 210
|
||||
|
||||
tree.links.new(bake_pass.inputs[1], bake_mesh.outputs[0])
|
||||
tree.links.new(output_img.inputs[2], bake_pass.outputs[0])
|
||||
output_img.inputs[2].valid = True
|
||||
|
||||
tree.tree_version = BW_TREE_VERSION
|
||||
tree.initialised = True
|
||||
if debug: _print("Tree initialized")
|
||||
|
||||
|
||||
# Reregister message bus subscription
|
||||
bw_subscriber = object()
|
||||
from bpy.app.handlers import persistent
|
||||
@persistent
|
||||
def BakeWrangler_Hook_Post_Load(dummy):
|
||||
BakeWrangler_Msgbus_Subscribe(bw_subscriber)
|
||||
|
||||
|
||||
# Subscribe to message bus
|
||||
def BakeWrangler_Msgbus_Subscribe(owner, sub=True):
|
||||
if owner is not None:
|
||||
bpy.msgbus.clear_by_owner(owner)
|
||||
if sub:
|
||||
subscribe_to = bpy.types.SpaceNodeEditor, "node_tree"
|
||||
bpy.msgbus.subscribe_rna(key=subscribe_to,
|
||||
owner=owner,
|
||||
args=(1,2),
|
||||
notify=BakeWrangler_Msgbus_NodeTreeChange)
|
||||
|
||||
|
||||
def register():
|
||||
BakeWrangler_Msgbus_Subscribe(bw_subscriber)
|
||||
bpy.app.handlers.load_post.append(BakeWrangler_Hook_Post_Load)
|
||||
|
||||
|
||||
def unregister():
|
||||
hook_index = None
|
||||
for idx in range(len(bpy.app.handlers.load_post)):
|
||||
if bpy.app.handlers.load_post[idx] == BakeWrangler_Hook_Post_Load:
|
||||
hook_index = idx
|
||||
if hook_index != None:
|
||||
bpy.app.handlers.load_post.pop(hook_index)
|
||||
BakeWrangler_Msgbus_Subscribe(bw_subscriber, False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
299
cg/blender/scripts/addons/BakeWrangler/nodes/node_panel.py
Normal file
299
cg/blender/scripts/addons/BakeWrangler/nodes/node_panel.py
Normal file
|
@ -0,0 +1,299 @@
|
|||
import bpy
|
||||
from .node_tree import _prefs, _print, BW_TREE_VERSION, BakeWrangler_Operator
|
||||
|
||||
|
||||
# Panel displaying info about recipe version and containing update button
|
||||
class BakeWrangler_RecipeInfo(bpy.types.Panel):
|
||||
'''Panel in node editor to show recipe information'''
|
||||
bl_label = "Recipe Info"
|
||||
bl_idname = "OBJECT_PT_BW_RecipeInfo"
|
||||
bl_space_type = 'NODE_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_context = "area"
|
||||
bl_category = "Bake Wrangler"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
# Only display if the edited tree is of the correct type
|
||||
return (context.area and context.area.ui_type == 'BakeWrangler_Tree')
|
||||
|
||||
def draw(self, context):
|
||||
tree = context.space_data.node_tree
|
||||
layout = self.layout
|
||||
if tree is None:
|
||||
layout.label(text="No recipe loaded")
|
||||
return
|
||||
tree_ver = getattr(tree, "tree_version", 0)
|
||||
curr_ver = BW_TREE_VERSION
|
||||
nodes = len(tree.nodes)
|
||||
|
||||
col = layout.column()
|
||||
op = col.operator("bake_wrangler.show_log", icon='TEXT')
|
||||
op.tree = tree.name
|
||||
col.label(text="Recipe version: " + str(tree_ver))
|
||||
col.label(text="Add-on version: " + str(curr_ver))
|
||||
col.label(text="Nodes: " + str(nodes))
|
||||
|
||||
if tree_ver != curr_ver:
|
||||
row = col.row()
|
||||
if tree_ver > curr_ver:
|
||||
row.label(text="Status: Add-on requires update")
|
||||
else:
|
||||
row.label(text="Status: Recipe requires update")
|
||||
op_row = col.row()
|
||||
if tree_ver >= 5:
|
||||
op = op_row.operator("bake_wrangler_op.update_recipe", icon='FILE_REFRESH', text="Update Recipe")
|
||||
op.tree = tree.name
|
||||
else:
|
||||
op_row.operator("bake_wrangler_op.update_recipe", icon='CANCEL', text="Update Unavailable")
|
||||
op_row.enabled = False
|
||||
|
||||
|
||||
# Panel for automatic cage management tasks
|
||||
class BakeWrangler_AutoCages(bpy.types.Panel):
|
||||
'''Panel in node editor to manage automatic cages'''
|
||||
bl_label = "Auto Cages"
|
||||
bl_idname = "OBJECT_PT_BW_AutoCages"
|
||||
bl_space_type = 'NODE_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_context = "area"
|
||||
bl_category = "Bake Wrangler"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
# Only display if the edited tree is of the correct type
|
||||
return (context.area and context.area.ui_type == 'BakeWrangler_Tree')
|
||||
|
||||
def draw(self, context):
|
||||
tree = context.space_data.node_tree
|
||||
layout = self.layout
|
||||
if tree is None:
|
||||
layout.label(text="No recipe loaded")
|
||||
return
|
||||
col = layout.column()
|
||||
op = col.operator("bake_wrangler.auto_cage_create")
|
||||
op.tree = tree.name
|
||||
op = col.operator("bake_wrangler.auto_cage_update")
|
||||
op.tree = tree.name
|
||||
op = col.operator("bake_wrangler.auto_cage_remove")
|
||||
op.tree = tree.name
|
||||
|
||||
|
||||
# Show log file
|
||||
class BakeWrangler_Operator_ShowLog(BakeWrangler_Operator, bpy.types.Operator):
|
||||
'''Show last log created by this recipe'''
|
||||
bl_idname = "bake_wrangler.show_log"
|
||||
bl_label = "Show Log"
|
||||
bl_options = {"REGISTER"}
|
||||
|
||||
# Called either after invoke from UI or directly from script
|
||||
def execute(self, context):
|
||||
return {'FINISHED'}
|
||||
|
||||
# Called from button press, set modifier key states
|
||||
def invoke(self, context, event):
|
||||
tree = bpy.data.node_groups[self.tree]
|
||||
if tree.last_log:
|
||||
bpy.ops.screen.area_dupli('INVOKE_DEFAULT')
|
||||
open_ed = bpy.context.window_manager.windows[len(bpy.context.window_manager.windows) - 1].screen.areas[0]
|
||||
open_ed.type = 'TEXT_EDITOR'
|
||||
log = bpy.data.texts.load(tree.last_log)
|
||||
open_ed.spaces[0].text = log
|
||||
open_ed.spaces[0].show_line_numbers = False
|
||||
open_ed.spaces[0].show_syntax_highlight = False
|
||||
return {'FINISHED'}
|
||||
else:
|
||||
self.report({'WARNING'}, "No log file set")
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
# Generate auto cages
|
||||
class BakeWrangler_Operator_AutoCageCreate(BakeWrangler_Operator, bpy.types.Operator):
|
||||
'''Create cages in current scene for objects in recipe that don't have a cage set.\nShift-Click to exclude hidden objects'''
|
||||
bl_idname = "bake_wrangler.auto_cage_create"
|
||||
bl_label = "Generate Cages"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
# Called either after invoke from UI or directly from script
|
||||
def execute(self, context):
|
||||
return {'FINISHED'}
|
||||
|
||||
# Called from button press, set modifier key states
|
||||
def invoke(self, context, event):
|
||||
mod_shift = event.shift
|
||||
objs = get_auto_caged(bpy.data.node_groups[self.tree], mod_shift, context)
|
||||
if len(objs):
|
||||
# Check if cage collection exists and create it if needed
|
||||
if 'BW Cages' not in bpy.data.collections.keys():
|
||||
bpy.data.collections.new('BW Cages')
|
||||
# Check if cage collection is in current scene and link if needed
|
||||
if 'BW Cages' not in context.scene.collection.children.keys():
|
||||
context.scene.collection.children.link(bpy.data.collections['BW Cages'])
|
||||
bw_cages = bpy.data.collections['BW Cages'].objects
|
||||
# Create and link cages to the collection for all objects
|
||||
for obj in objs:
|
||||
if not obj[0].bw_auto_cage:
|
||||
generate_auto_cage(obj[0], obj[1], obj[2], context)
|
||||
if obj[0].bw_auto_cage not in bw_cages.values():
|
||||
bw_cages.link(obj[0].bw_auto_cage)
|
||||
return {'FINISHED'}
|
||||
else:
|
||||
self.report({'WARNING'}, "No objects with auto cages found")
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
# Update auto cages
|
||||
class BakeWrangler_Operator_AutoCageUpdate(BakeWrangler_Operator, bpy.types.Operator):
|
||||
'''Update cages in current scene for objects in recipe. Overwrites user changes if 'bw_cage' modifier has been removed.\nShift-Click to exclude hidden objects'''
|
||||
bl_idname = "bake_wrangler.auto_cage_update"
|
||||
bl_label = "Update Cages"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
# Called either after invoke from UI or directly from script
|
||||
def execute(self, context):
|
||||
return {'FINISHED'}
|
||||
|
||||
# Called from button press, set modifier key states
|
||||
def invoke(self, context, event):
|
||||
mod_shift = event.shift
|
||||
objs = get_auto_caged(bpy.data.node_groups[self.tree], mod_shift, context)
|
||||
if len(objs):
|
||||
for obj in objs:
|
||||
if obj[0].bw_auto_cage:
|
||||
cage = obj[0].bw_auto_cage
|
||||
# If the modifier is still on the object just change it instead of making a new object
|
||||
if "bw_cage" in cage.modifiers:
|
||||
cage.modifiers["bw_cage"].strength = obj[1]
|
||||
cage.data.auto_smooth_angle = obj[2]
|
||||
elif 'BW Cages' in bpy.data.collections.keys():
|
||||
bpy.data.collections['BW Cages'].objects.unlink(cage)
|
||||
generate_auto_cage(obj[0], obj[1], obj[2], context)
|
||||
return {'FINISHED'}
|
||||
else:
|
||||
self.report({'WARNING'}, "No objects with auto cages found")
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
# Remove auto cages
|
||||
class BakeWrangler_Operator_AutoCageRemove(BakeWrangler_Operator, bpy.types.Operator):
|
||||
'''Remove cages in current scene for objects in recipe.\nShift-Click to exclude hidden objects'''
|
||||
bl_idname = "bake_wrangler.auto_cage_remove"
|
||||
bl_label = "Remove Cages"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
# Called either after invoke from UI or directly from script
|
||||
def execute(self, context):
|
||||
return {'FINISHED'}
|
||||
|
||||
# Called from button press, set modifier key states
|
||||
def invoke(self, context, event):
|
||||
mod_shift = event.shift
|
||||
if 'BW Cages' in bpy.data.collections.keys():
|
||||
bw_cages = bpy.data.collections['BW Cages'].objects
|
||||
objs = context.scene.collection.all_objects
|
||||
for obj in objs:
|
||||
if obj.bw_auto_cage and (not mod_shift or obj.visible_get()):
|
||||
bw_cages.unlink(obj.bw_auto_cage)
|
||||
obj.bw_auto_cage = None
|
||||
if 'BW Cages' in context.scene.collection.children:
|
||||
context.scene.collection.children.unlink(bw_cages.id_data)
|
||||
return {'FINISHED'}
|
||||
else:
|
||||
self.report({'WARNING'}, "No objects with auto cages found")
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
# Return a list of objects that would get a cage auto generated
|
||||
def get_auto_caged(tree, vis, context):
|
||||
nodes = tree.nodes
|
||||
objs = []
|
||||
for node in nodes:
|
||||
if node.bl_idname == 'BakeWrangler_Output_Image_Path':
|
||||
objs += node.get_unique_objects('TARGET', for_auto_cage=True)
|
||||
# Get a list of all objects in the scene and cull it down to only visible ones
|
||||
vl_objs = context.scene.collection.all_objects.values()
|
||||
if vis:
|
||||
vl_vis = []
|
||||
for obj in vl_objs:
|
||||
if obj.visible_get() and obj not in vl_vis:
|
||||
vl_vis.append(obj)
|
||||
vl_objs = vl_vis
|
||||
# Return a list of unique objects that are in the scene and visible and would have a cage
|
||||
objs_prune = []
|
||||
for obj in objs:
|
||||
if obj not in objs_prune and obj[0] in vl_objs:
|
||||
objs_prune.append(obj)
|
||||
return objs_prune
|
||||
|
||||
|
||||
# Create an auto cage for the given mesh
|
||||
def generate_auto_cage(mesh, cage_exp, smooth, context):
|
||||
# Create a copy of the base mesh with modifiers applied to use a the base cage
|
||||
cage = mesh.copy()
|
||||
cage.data = mesh.data.copy()
|
||||
cage.name = mesh.name + '.cage'
|
||||
cage.name = mesh.name + '.cage'
|
||||
cage.data.materials.clear()
|
||||
cage.data.polygons.foreach_set('material_index', [0] * len(cage.data.polygons))
|
||||
cage.display_type = 'WIRE'
|
||||
if cage not in bpy.data.collections['BW Cages'].objects.values():
|
||||
bpy.data.collections['BW Cages'].objects.link(cage)
|
||||
if len(cage.modifiers):
|
||||
prev_active = bpy.context.view_layer.objects.active
|
||||
bpy.context.view_layer.objects.active = cage
|
||||
for mod in cage.modifiers:
|
||||
if mod.show_render:
|
||||
try:
|
||||
bpy.ops.object.modifier_apply(modifier=mod.name)
|
||||
except:
|
||||
_print("Error applying modifier '%s' to object '%s'" % (mod.name, mesh.name))
|
||||
bpy.ops.object.modifier_remove(modifier=mod.name)
|
||||
else:
|
||||
bpy.ops.object.modifier_remove(modifier=mod.name)
|
||||
bpy.context.view_layer.objects.active = prev_active
|
||||
# Expand cage on normals
|
||||
cage_disp = cage.modifiers.new("bw_cage", 'DISPLACE')
|
||||
cage_disp.strength = cage_exp
|
||||
cage_disp.direction = 'NORMAL'
|
||||
cage_disp.mid_level = 0.0
|
||||
cage_disp.show_in_editmode = True
|
||||
cage_disp.show_on_cage = True
|
||||
cage_disp.show_expanded = False
|
||||
# Smooth normals and clear sharps
|
||||
cage.data.use_auto_smooth = True
|
||||
cage.data.auto_smooth_angle = smooth
|
||||
for poly in cage.data.polygons:
|
||||
poly.use_smooth = True
|
||||
for edge in cage.data.edges:
|
||||
edge.use_edge_sharp = False
|
||||
# Link cage via property on mesh
|
||||
mesh.bw_auto_cage = cage
|
||||
|
||||
|
||||
# Classes to register
|
||||
classes = (
|
||||
BakeWrangler_RecipeInfo,
|
||||
BakeWrangler_AutoCages,
|
||||
BakeWrangler_Operator_ShowLog,
|
||||
BakeWrangler_Operator_AutoCageCreate,
|
||||
BakeWrangler_Operator_AutoCageUpdate,
|
||||
BakeWrangler_Operator_AutoCageRemove,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
# Add pointer to generated cage
|
||||
bpy.types.Object.bw_auto_cage = bpy.props.PointerProperty(name="Cage", description="Bake Wrangler auto generated cage", type=bpy.types.Object)
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
|
||||
|
||||
def unregister():
|
||||
from bpy.utils import unregister_class
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
5218
cg/blender/scripts/addons/BakeWrangler/nodes/node_tree.py
Normal file
5218
cg/blender/scripts/addons/BakeWrangler/nodes/node_tree.py
Normal file
File diff suppressed because it is too large
Load diff
329
cg/blender/scripts/addons/BakeWrangler/nodes/node_update.py
Normal file
329
cg/blender/scripts/addons/BakeWrangler/nodes/node_update.py
Normal file
|
@ -0,0 +1,329 @@
|
|||
import bpy
|
||||
from .node_tree import _prefs, _print, BW_TREE_VERSION, get_input, follow_input_link
|
||||
|
||||
|
||||
class BakeWrangler_Operator_UpdateRecipe(bpy.types.Operator):
|
||||
'''Update older recipe version to current version'''
|
||||
bl_idname = "bake_wrangler_op.update_recipe"
|
||||
bl_label = "Update Recipe"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
tree: bpy.props.StringProperty()
|
||||
|
||||
@classmethod
|
||||
def poll(type, context):
|
||||
return context.area.type == "NODE_EDITOR" and context.space_data.tree_type == "BakeWrangler_Tree"
|
||||
|
||||
def execute(self, context):
|
||||
tree = bpy.data.node_groups[self.tree]
|
||||
nodes = tree.nodes
|
||||
links = tree.links
|
||||
fail = False
|
||||
RGB = ['R', 'G', 'B']
|
||||
# Helper to get lists of desired nodes
|
||||
def get_bw_nodes(nodes, before_version=-1, idnames=[]):
|
||||
bw_nodes = []
|
||||
for node in nodes:
|
||||
if node.bl_idname in ['NodeFrame', 'NodeReroute']:
|
||||
continue
|
||||
if before_version > -1 and getattr(node, "tree_version", before_version) >= before_version:
|
||||
continue
|
||||
if len(idnames) and node.bl_idname not in idnames:
|
||||
continue
|
||||
bw_nodes.append(node)
|
||||
return bw_nodes
|
||||
def link_route(input, node, socket, links):
|
||||
# If the input is linked via reroutes, this will get the tail reroutes input
|
||||
if len(input.links):
|
||||
input = follow_input_link(input.links[0]).to_socket
|
||||
# If the specified node is a reroute, follow to the source, and change the link at that end
|
||||
if node.bl_idname == 'NodeReroute':
|
||||
tail = follow_input_link(node.inputs[0].links[0])
|
||||
tail_node = tail.from_node
|
||||
tail_sock = tail.to_socket
|
||||
links.new(tail_node.outputs[socket], tail_sock)
|
||||
if input == tail_sock: return
|
||||
socket = 0
|
||||
links.new(input, node.outputs[socket])
|
||||
# 5 -> 6
|
||||
if getattr(tree, "tree_version", 0) == 5:
|
||||
# Load out dated nodes
|
||||
from .prev_trees import node_tree_v5 as node_tree_v5
|
||||
node_tree_v5.register()
|
||||
try:
|
||||
glob_bake = []
|
||||
glob_outp = []
|
||||
# First the active global res node should be found (if exists) and the values stored
|
||||
for node in tree.nodes:
|
||||
if node.bl_idname == 'BakeWrangler_Global_Resolution' and node.is_active:
|
||||
glob_bake.append(node.res_bake_x)
|
||||
glob_bake.append(node.res_bake_y)
|
||||
glob_outp.append(node.res_outp_x)
|
||||
glob_outp.append(node.res_outp_y)
|
||||
break
|
||||
# Go through all the nodes and update them as needed based on idname
|
||||
for node in get_bw_nodes(nodes, 6, ['BakeWrangler_Global_Resolution', 'BakeWrangler_Bake_Mesh', 'BakeWrangler_Bake_Pass', 'BakeWrangler_Output_Image_Path']):
|
||||
if node.bl_idname == 'BakeWrangler_Global_Resolution':
|
||||
nodes.remove(node) # No longer used
|
||||
continue
|
||||
socket_type = None
|
||||
node_type = None
|
||||
if node.bl_idname == 'BakeWrangler_Bake_Mesh':
|
||||
socket_type = 'BakeWrangler_Socket_MeshSetting'
|
||||
node_type = 'BakeWrangler_MeshSettings'
|
||||
elif node.bl_idname == 'BakeWrangler_Bake_Pass':
|
||||
socket_type = 'BakeWrangler_Socket_PassSetting'
|
||||
node_type = 'BakeWrangler_PassSettings'
|
||||
elif node.bl_idname == 'BakeWrangler_Output_Image_Path':
|
||||
socket_type = 'BakeWrangler_Socket_OutputSetting'
|
||||
node_type = 'BakeWrangler_OutputSettings'
|
||||
# Setting input needs to be added and settings placed in the correct settings node
|
||||
if 'Settings' not in node.inputs.keys():
|
||||
sset = node.inputs.new(socket_type, "Settings")
|
||||
node.inputs.move(len(node.inputs)-1, 0)
|
||||
mset = nodes.new(node_type)
|
||||
mset.location = [node.location[0] - 10, node.location[1] + 10]
|
||||
links.new(sset, mset.outputs[0])
|
||||
for key in node.keys():
|
||||
if key == 'pause_update': continue
|
||||
mset[key] = node[key]
|
||||
# Finished with Mesh node
|
||||
if node.bl_idname == 'BakeWrangler_Bake_Mesh':
|
||||
node.tree_version = 6
|
||||
# Extra work for bake pass
|
||||
elif node.bl_idname == 'BakeWrangler_Bake_Pass':
|
||||
xres = getattr(node, 'bake_xres', 0)
|
||||
usex = getattr(node, 'bake_usex', False)
|
||||
if not usex:
|
||||
if len(glob_bake):
|
||||
mset.res_bake_x = glob_bake[0]
|
||||
else:
|
||||
mset.res_bake_x = xres
|
||||
yres = getattr(node, 'bake_yres', 0)
|
||||
usey = getattr(node, 'bake_usey', False)
|
||||
if not usey:
|
||||
if len(glob_bake):
|
||||
mset.res_bake_y = glob_bake[1]
|
||||
else:
|
||||
mset.res_bake_y = yres
|
||||
# A pass was added to 'WRANG' cat at pos 3, so selected pass needs to move down one
|
||||
if node.bake_cat == 'WRANG':
|
||||
# It's an enum and stored as an int, but when addon loads becomes a string..
|
||||
enum = 0
|
||||
enum2str = {}
|
||||
str2enum = {}
|
||||
for wpass in node.passes_wrang:
|
||||
str2enum[wpass[0]] = enum
|
||||
enum2str[enum] = wpass[0]
|
||||
enum += 1
|
||||
if str2enum[node.bake_wrang] >= 3:
|
||||
enum = str2enum[node.bake_wrang] + 1
|
||||
node.bake_wrang = enum2str[enum]
|
||||
# Version will get set when working back from an Output
|
||||
# Extra work for output
|
||||
elif node.bl_idname == 'BakeWrangler_Output_Image_Path':
|
||||
node.inputs.new('BakeWrangler_Socket_ChanMap', "Alpha")
|
||||
xres = getattr(node, 'img_xres', 0)
|
||||
usex = getattr(node, 'img_usex', False)
|
||||
if not usex:
|
||||
if len(glob_bake):
|
||||
mset.img_xres = glob_outp[0]
|
||||
else:
|
||||
mset.img_xres = xres
|
||||
yres = getattr(node, 'img_yres', 0)
|
||||
usey = getattr(node, 'img_usey', False)
|
||||
if not usey:
|
||||
if len(glob_bake):
|
||||
mset.img_yres = glob_outp[1]
|
||||
else:
|
||||
mset.img_yres = yres
|
||||
# Loop over all the nodes again, just back tracking from outputs this time
|
||||
for node in get_bw_nodes(nodes, 6, ['BakeWrangler_Output_Image_Path']):
|
||||
# Unless the only input is color and alpha, a mapping node needs to be set up
|
||||
map = None
|
||||
for input in node.inputs:
|
||||
if input.name in ['R', 'G', 'B', 'A'] and input.islinked() and input.valid:
|
||||
if map is None and not input.name == 'A':
|
||||
# Create map node and connect the color socket
|
||||
map = nodes.new('BakeWrangler_Channel_Map')
|
||||
map.location = [node.location[0] - 20, node.location[1] - 20]
|
||||
if node.inputs['Color'].islinked() and node.inputs['Color'].valid:
|
||||
link_route(map.inputs['Color'], node.inputs['Color'].links[0].from_node, 'Color', links)
|
||||
# Connect up this input and set mapping
|
||||
if input.name == 'A':
|
||||
sock = node.inputs['Alpha']
|
||||
else:
|
||||
sock = map.inputs[input.name]
|
||||
chan = follow_input_link(input.links[0]).from_socket.name[:1]
|
||||
link_route(sock, input.links[0].from_node, 'Color', links)
|
||||
_print("Input:" + str(input.name))
|
||||
if chan == 'C':
|
||||
if input.name == 'A':
|
||||
chan = 'V'
|
||||
else:
|
||||
chan = input.name
|
||||
sock.input_channel = chan
|
||||
# Remove the old link
|
||||
links.remove(input.links[0])
|
||||
# If map wasn't created then just link the color input, else link the map
|
||||
if map is None:
|
||||
link_route(node.inputs['Color'], node.inputs['Color'].links[0].from_node, 'Color', links)
|
||||
else:
|
||||
link_route(node.inputs['Color'], map, 'Color', links)
|
||||
# Remove the now unused sockets
|
||||
for input in node.inputs:
|
||||
if input.name in ['R', 'G', 'B', 'A']:
|
||||
node.inputs.remove(input)
|
||||
node.tree_version = 6
|
||||
# Go through all the pass nodes, only their color outputs should be linked now
|
||||
for node in get_bw_nodes(nodes, 6):
|
||||
if node.bl_idname == 'BakeWrangler_Bake_Pass':
|
||||
for output in node.outputs:
|
||||
if output.name != 'Color':
|
||||
node.outputs.remove(output)
|
||||
node.tree_version = 6
|
||||
# Helper fn to compare and group settings
|
||||
def consolidate_settings(settings):
|
||||
def group_settings(settings, groups={}, idx=0):
|
||||
def compare_settings(this, that):
|
||||
for key in this.keys():
|
||||
if key == 'pause_update': continue
|
||||
if getattr(that, key, None) == getattr(this, key, None): continue
|
||||
return False
|
||||
return True
|
||||
excluded = []
|
||||
if len(settings):
|
||||
comp = settings[0]
|
||||
groups[idx] = [comp]
|
||||
for sett in settings[1:]:
|
||||
if compare_settings(comp, sett):
|
||||
groups[idx].append(sett)
|
||||
else:
|
||||
excluded.append(sett)
|
||||
return group_settings(excluded, groups, idx+1)
|
||||
return groups
|
||||
if len(settings) > 1:
|
||||
# Create groups of same
|
||||
grps = group_settings(settings)
|
||||
for key in grps.keys():
|
||||
merge = grps[key][0].outputs[0]
|
||||
mlinks = []
|
||||
# Collect all the link dests
|
||||
for sett in grps[key][1:]:
|
||||
for link in sett.outputs[0].links:
|
||||
mlinks.append(link.to_socket)
|
||||
# Link all the dests to the first setting node
|
||||
for link in mlinks:
|
||||
links.new(merge, link)
|
||||
# Delete extra nodes
|
||||
for sett in grps[key][1:]:
|
||||
nodes.remove(sett)
|
||||
# Consolidate duplicate settings nodes
|
||||
consolidate_settings(get_bw_nodes(nodes, -1, ['BakeWrangler_MeshSettings']))
|
||||
consolidate_settings(get_bw_nodes(nodes, -1, ['BakeWrangler_PassSettings']))
|
||||
consolidate_settings(get_bw_nodes(nodes, -1, ['BakeWrangler_OutputSettings']))
|
||||
# Everything should be updated to version 6
|
||||
tree.tree_version = 6
|
||||
except Exception as err:
|
||||
_print("Updating recipe from v5 to v6 failed: %s" % (str(err)))
|
||||
self.report({'ERROR'}, "Updating recipe from v5 to v6 failed: %s" % (str(err)))
|
||||
fail = True
|
||||
else:
|
||||
_print("Recipe updated from v5 to v6")
|
||||
node_tree_v5.unregister()
|
||||
if fail: return {'CANCELLED'}
|
||||
# 6 -> 7
|
||||
if getattr(tree, "tree_version", 0) == 6:
|
||||
try:
|
||||
# Output path nodes are changed up a bit
|
||||
for node in get_bw_nodes(nodes, 7):
|
||||
if node.bl_idname == 'BakeWrangler_Output_Image_Path':
|
||||
node.inputs.new('BakeWrangler_Socket_SplitOutput', "Split Output")
|
||||
node.inputs.move(len(node.inputs)-1, 0)
|
||||
node.update_inputs()
|
||||
node.tree_version = 7
|
||||
tree.tree_version = 7
|
||||
except Exception as err:
|
||||
_print("Updating recipe from v6 to v7 failed: %s" % (str(err)))
|
||||
self.report({'ERROR'}, "Updating recipe from v6 to v7 failed: %s" % (str(err)))
|
||||
fail = True
|
||||
else:
|
||||
_print("Recipe updated from v6 to v7")
|
||||
if fail: return {'CANCELLED'}
|
||||
# 7 -> 8
|
||||
if getattr(tree, "tree_version", 0) == 7:
|
||||
try:
|
||||
# Output paths moved to socket properties
|
||||
for node in get_bw_nodes(nodes, 8):
|
||||
if node.bl_idname == 'BakeWrangler_Output_Image_Path':
|
||||
socket = node.inputs["Split Output"]
|
||||
for key in node.keys():
|
||||
if key == 'disp_path' and node[key]: socket.disp_path = node[key]
|
||||
if key == 'img_path' and node[key]: socket.img_path = node[key]
|
||||
if key == 'img_name' and node[key]: socket.img_name = node[key]
|
||||
node.tree_version = 8
|
||||
tree.tree_version = 8
|
||||
except Exception as err:
|
||||
_print("Updating recipe from v7 to v8 failed: %s" % (str(err)))
|
||||
self.report({'ERROR'}, "Updating recipe from v7 to v8 failed: %s" % (str(err)))
|
||||
fail = True
|
||||
else:
|
||||
_print("Recipe updated from v7 to v8")
|
||||
if fail: return {'CANCELLED'}
|
||||
# 8 -> 9
|
||||
if getattr(tree, "tree_version", 0) == 8:
|
||||
try:
|
||||
# RGB sockets have changed to Red, Green, Blue and PassSettings gains a samples socket
|
||||
for node in get_bw_nodes(nodes, 9):
|
||||
if node.bl_idname in ['BakeWrangler_Channel_Map', 'BakeWrangler_Post_SplitRGB', 'BakeWrangler_Post_JoinRGB']:
|
||||
soks = node.inputs
|
||||
if node.bl_idname == 'BakeWrangler_Post_SplitRGB': soks = node.outputs
|
||||
for sok in soks:
|
||||
if sok.name == 'R': sok.name = 'Red'
|
||||
elif sok.name == 'G': sok.name = 'Green'
|
||||
elif sok.name == 'B': sok.name = 'Blue'
|
||||
soks = node.outputs
|
||||
if node.bl_idname == 'BakeWrangler_Post_SplitRGB': soks = node.inputs
|
||||
for sok in soks:
|
||||
if sok.name == 'Image': sok.name = 'Color'
|
||||
elif node.bl_idname == 'BakeWrangler_PassSettings':
|
||||
node.inputs.new('BakeWrangler_Socket_SampleSetting', "Samples")
|
||||
elif node.bl_idname == 'BakeWrangler_OutputSettings':
|
||||
if not hasattr(node, 'img_color_space'):
|
||||
node.img_color_space = bpy.data.scenes[0].sequencer_colorspace_settings.name
|
||||
node.tree_version = 9
|
||||
tree.tree_version = 9
|
||||
except Exception as err:
|
||||
_print("Updating recipe from v8 to v9 failed: %s" % (str(err)))
|
||||
self.report({'ERROR'}, "Updating recipe from v8 to v9 failed: %s" % (str(err)))
|
||||
fail = True
|
||||
else:
|
||||
_print("Recipe updated from v8 to v9")
|
||||
if fail: return {'CANCELLED'}
|
||||
return {'FINISHED'}
|
||||
|
||||
# Ask the user if they really want to update
|
||||
def invoke(self, context, event):
|
||||
return context.window_manager.invoke_confirm(self, event)
|
||||
|
||||
|
||||
# Classes to register
|
||||
classes = (
|
||||
BakeWrangler_Operator_UpdateRecipe,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
|
||||
|
||||
def unregister():
|
||||
from bpy.utils import unregister_class
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,66 @@
|
|||
import bpy
|
||||
from bpy.types import NodeTree, Node, NodeSocket
|
||||
from ..node_tree import BakeWrangler_Tree_Socket, BakeWrangler_Tree_Node
|
||||
|
||||
# Node to globally set bake and output resolutions
|
||||
class BakeWrangler_Global_Resolution(Node, BakeWrangler_Tree_Node):
|
||||
'''Global resolution settings node'''
|
||||
bl_label = 'Resolutions'
|
||||
|
||||
# Inputs are static on this node
|
||||
def update_inputs(self):
|
||||
pass
|
||||
|
||||
# When toggled as active, any other nodes of the same type need to be deactivated
|
||||
def toggle_active(self, context):
|
||||
pass
|
||||
|
||||
is_active: bpy.props.BoolProperty(name="Active", description="Causes this nodes settings to be used globally (only one can be active at a time)", default=False, update=toggle_active)
|
||||
res_bake_x: bpy.props.IntProperty(name="Bake X resolution ", description="Width (X) to bake maps at", default=2048, min=1, subtype='PIXEL')
|
||||
res_bake_y: bpy.props.IntProperty(name="Bake Y resolution ", description="Height (Y) to bake maps at", default=2048, min=1, subtype='PIXEL')
|
||||
res_outp_x: bpy.props.IntProperty(name="Image X resolution ", description="Width (X) to output images at (bake will be scaled up or down to match, use this to smooth maps by down sampling)", default=2048, min=1, subtype='PIXEL')
|
||||
res_outp_y: bpy.props.IntProperty(name="Image Y resolution ", description="Height (Y) to output images at (bake will be scaled up or down to match, use this to smooth maps by down sampling)", default=2048, min=1, subtype='PIXEL')
|
||||
|
||||
def copy(self, node):
|
||||
self.is_active = False
|
||||
|
||||
def init(self, context):
|
||||
pass
|
||||
#BakeWrangler_Tree_Node.init(self, context)
|
||||
# Sockets IN
|
||||
# Sockets OUT
|
||||
# Prefs
|
||||
#self.res_bake_x = _prefs("def_glob_bakx")
|
||||
#self.res_bake_y = _prefs("def_glob_baky")
|
||||
#self.res_outp_x = _prefs("def_glob_outx")
|
||||
#self.res_outp_y = _prefs("def_glob_outy")
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
colres = layout.column(align=True)
|
||||
colres.prop(self, "is_active", toggle=True)
|
||||
colres.label(text="Bake Resolution:")
|
||||
colres.prop(self, "res_bake_x", text="X")
|
||||
colres.prop(self, "res_bake_y", text="Y")
|
||||
colres.label(text="Output Resolution:")
|
||||
colres.prop(self, "res_outp_x", text="X")
|
||||
colres.prop(self, "res_outp_y", text="Y")
|
||||
|
||||
|
||||
classes = (
|
||||
BakeWrangler_Global_Resolution,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
|
||||
def unregister():
|
||||
from bpy.utils import unregister_class
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
|||
from . import status_bar_icon
|
||||
|
||||
def register():
|
||||
status_bar_icon.register()
|
||||
|
||||
|
||||
def unregister():
|
||||
status_bar_icon.unregister()
|
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -0,0 +1,106 @@
|
|||
import bpy
|
||||
|
||||
|
||||
# An operator to open a new window and display the text log when you click on the icon
|
||||
class click_bw_icon(bpy.types.Operator):
|
||||
'''Open baking log'''
|
||||
bl_idname = "bake_wrangler.open_log"
|
||||
bl_label = ""
|
||||
|
||||
@classmethod
|
||||
def poll(type, context):
|
||||
return getattr(bpy.context.window_manager, 'bw_status', -1) > -1
|
||||
|
||||
def invoke(self, context, event):
|
||||
text = None
|
||||
if event.alt and event.ctrl:
|
||||
file = getattr(bpy.context.window_manager, 'bw_lastfile', "")
|
||||
if file:
|
||||
import subprocess
|
||||
sub = subprocess.Popen([bpy.path.abspath(bpy.app.binary_path), file])
|
||||
elif event.ctrl:
|
||||
log = getattr(bpy.context.window_manager, 'bw_lastlog', "")
|
||||
if log: text = bpy.data.texts.load(log)
|
||||
else:
|
||||
if "BakeWrangler" in bpy.data.texts: text = bpy.data.texts["BakeWrangler"]
|
||||
if text:
|
||||
bpy.ops.wm.window_new()
|
||||
log_win = context.window_manager.windows[-1]
|
||||
log_ed = log_win.screen.areas[0]
|
||||
log_ed.type = 'TEXT_EDITOR'
|
||||
log_ed.spaces[0].text = text
|
||||
log_ed.spaces[0].show_line_numbers = False
|
||||
log_ed.spaces[0].show_syntax_highlight = False
|
||||
bpy.ops.text.move(type='FILE_TOP')
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
# Draw a different icon depending on the current bake state
|
||||
def draw_bw_icon(self, context):
|
||||
row = self.layout.row(align=True)
|
||||
bake_status = getattr(bpy.context.window_manager, 'bw_status', -1)
|
||||
if bake_status == 0: #Good (green)
|
||||
row.operator("bake_wrangler.open_log", text="", icon_value=status_icons['main']['bw_good'].icon_id)
|
||||
elif bake_status == 1: #Baking (blue)
|
||||
row.operator("bake_wrangler.open_log", text="", icon_value=status_icons['main']['bw_working'].icon_id)
|
||||
elif bake_status == 2: #Error (red)
|
||||
row.operator("bake_wrangler.open_log", text="", icon_value=status_icons['main']['bw_error'].icon_id)
|
||||
|
||||
|
||||
# Make the status bar redraw itself
|
||||
def redraw_status_bar(context):
|
||||
# This causes the status bar to redraw without deleting any custom drawing fns appended to it
|
||||
context.workspace.status_text_set_internal(None)
|
||||
|
||||
|
||||
# Remove and then re-add icon draw function to the status bar to make sure it's there
|
||||
def ensure_bw_icon():
|
||||
bpy.types.STATUSBAR_HT_header.remove(draw_fn)
|
||||
bpy.types.STATUSBAR_HT_header.append(draw_fn)
|
||||
|
||||
|
||||
# Remove the icon if it is turned off
|
||||
def disable_bw_icon():
|
||||
bpy.types.STATUSBAR_HT_header.remove(draw_fn)
|
||||
|
||||
|
||||
# Classes to register
|
||||
classes = (
|
||||
click_bw_icon,
|
||||
)
|
||||
|
||||
draw_fn = draw_bw_icon
|
||||
status_icons = {}
|
||||
|
||||
def register():
|
||||
# Set up custom status icon collection
|
||||
import os
|
||||
import bpy.utils.previews
|
||||
icons_col = bpy.utils.previews.new()
|
||||
icons_dir = os.path.join(os.path.dirname(__file__), "icons")
|
||||
# Load icons in
|
||||
icons_col.load("bw_good", os.path.join(icons_dir, "bw_good.png"), 'IMAGE')
|
||||
icons_col.load("bw_working", os.path.join(icons_dir, "bw_working.png"), 'IMAGE')
|
||||
icons_col.load("bw_error", os.path.join(icons_dir, "bw_error.png"), 'IMAGE')
|
||||
status_icons["main"] = icons_col
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
# Add the icon drawing function to the status bar
|
||||
bpy.types.STATUSBAR_HT_header.append(draw_fn)
|
||||
|
||||
|
||||
def unregister():
|
||||
# Remove the icon drawing function from the status bar
|
||||
bpy.types.STATUSBAR_HT_header.remove(draw_fn)
|
||||
from bpy.utils import unregister_class
|
||||
for cls in reversed(classes):
|
||||
unregister_class(cls)
|
||||
# Remove custom icons
|
||||
for icon_col in status_icons.values():
|
||||
bpy.utils.previews.remove(icon_col)
|
||||
status_icons.clear()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
133
cg/blender/scripts/addons/BakeWrangler/vert/ipc.py
Normal file
133
cg/blender/scripts/addons/BakeWrangler/vert/ipc.py
Normal file
|
@ -0,0 +1,133 @@
|
|||
import os
|
||||
import pickle
|
||||
import bpy
|
||||
import sys
|
||||
try:
|
||||
from BakeWrangler.nodes.node_tree import _print
|
||||
except:
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
from nodes.node_tree import _print
|
||||
|
||||
|
||||
# Complete process of putting baked verts into a temp file ready for reimport
|
||||
def bake_verts(verts=None, object=None, name=None, type=None, domain=None):
|
||||
# Create temp file
|
||||
err = 0
|
||||
fd, fname = next_pickle_jar()
|
||||
if fd:
|
||||
# Export vert data to python list
|
||||
vcols = export_verts(name=name, cols=verts)
|
||||
# Add object name and data type to data list
|
||||
vcols.insert(0, [object, type, domain])
|
||||
if vcols:
|
||||
# Pickle the vcols in the jar, this also closes the file
|
||||
err = pickle_verts(file=fd, verts=vcols)
|
||||
if err:
|
||||
_print(" Error - Pickling failed.", tag=True, wrap=True)
|
||||
else:
|
||||
_print(" Error - Exporting data failed.", tag=True, wrap=True)
|
||||
err = 1
|
||||
else:
|
||||
_print(" Error - Creating temp file failed.", tag=True, wrap=True)
|
||||
err = 1
|
||||
if err:
|
||||
return 1, None
|
||||
_print(" Done", tag=True)
|
||||
return 0, fname
|
||||
|
||||
|
||||
# Import vertex colors into currently open blend find, returns 0 on success else 1
|
||||
def import_verts(cols=None):
|
||||
object = name = type = domain = None
|
||||
try:
|
||||
objinfo = cols.pop(0)
|
||||
object = objinfo[0]
|
||||
type = objinfo[1]
|
||||
domain = objinfo[2]
|
||||
name = cols.pop(0)
|
||||
blend_obj = bpy.data.objects[object]
|
||||
# See if the object already has data with the provided name, adding if needed
|
||||
if name not in blend_obj.data.color_attributes.keys():
|
||||
blend_obj.data.color_attributes.new(name, type, domain)
|
||||
elif blend_obj.data.color_attributes[name].domain != domain or blend_obj.data.color_attributes[name].data_type != type:
|
||||
blend_obj.data.color_attributes.remove(blend_obj.data.color_attributes[name])
|
||||
blend_obj.data.color_attributes.new(name, type, domain)
|
||||
# Use internal setter function to apply array
|
||||
obj_cols = blend_obj.data.color_attributes[name]
|
||||
obj_cols.data.foreach_set('color', cols)
|
||||
|
||||
except:
|
||||
return 1, "Object: %s, Data: %s, Type %s, Domain %s" % (object, name, type, domain)
|
||||
else:
|
||||
return 0, "Object: %s, Data: %s, Type %s, Domain %s" % (object, name, type, domain)
|
||||
|
||||
|
||||
# Extract vertex colors into a py list and return it or None on error
|
||||
def export_verts(name=None, cols=None):
|
||||
# List needs to be set to the correct size first, which is the length of the data * 4
|
||||
vlist = [0.0] * (len(cols.data) * 4)
|
||||
try:
|
||||
# Use internal foreach get function on the data
|
||||
cols.data.foreach_get('color', vlist)
|
||||
except:
|
||||
return None
|
||||
else:
|
||||
# Insert the color data name at the front of the list and return it
|
||||
vlist.insert(0, name)
|
||||
return vlist
|
||||
|
||||
|
||||
# Pickle vertex color dict, return 1 on error, else 0
|
||||
def pickle_verts(file=None, verts=None):
|
||||
try:
|
||||
pickle.dump(verts, file, pickle.HIGHEST_PROTOCOL)
|
||||
file.close()
|
||||
except:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
# Depickle vertex color dict from file, return None on error, else verts
|
||||
def depickle_verts(file=None):
|
||||
try:
|
||||
verts = pickle.load(file)
|
||||
except:
|
||||
return None
|
||||
else:
|
||||
return verts
|
||||
|
||||
|
||||
# Create temp file to hold pickle, return None, filename on error, else opened file, filename
|
||||
def next_pickle_jar():
|
||||
blend = bpy.data.filepath
|
||||
pickl = blend + ".vert"
|
||||
fd = None
|
||||
# Find free file name by adding numbers
|
||||
if os.path.exists(pickl):
|
||||
fno = 1
|
||||
while os.path.exists(pickl):
|
||||
fno = fno + 1
|
||||
pickl = pickl + "_%03i" % (fno)
|
||||
# Open the file for binary write
|
||||
try:
|
||||
fd = open(pickl, "wb")
|
||||
except:
|
||||
return None, pickl
|
||||
else:
|
||||
return fd, pickl
|
||||
|
||||
|
||||
# Open pickled temp, return None on error, else opened file
|
||||
def open_pickle_jar(file=None):
|
||||
#Open the file for binary read
|
||||
try:
|
||||
fd = open(file, 'rb')
|
||||
except:
|
||||
return None
|
||||
else:
|
||||
return fd
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
42
cg/blender/scripts/startup/cg_environment.py
Normal file
42
cg/blender/scripts/startup/cg_environment.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
__doc__ = 'Environment for use Blender with Robossembler Framework'
|
||||
__version__ = '0.1'
|
||||
|
||||
import os
|
||||
import bpy
|
||||
from bpy.app.handlers import persistent
|
||||
import addon_utils
|
||||
|
||||
|
||||
@persistent
|
||||
def rs_env():
|
||||
'''Scripts environment'''
|
||||
rs_blender_scripts_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
|
||||
if rs_blender_scripts_dir not in bpy.utils.script_paths_pref():
|
||||
script_directories = bpy.context.preferences.filepaths.script_directories
|
||||
new_dir = script_directories.new()
|
||||
new_dir.directory = rs_blender_scripts_dir
|
||||
new_dir.name = 'RS_BLENDER_SCRIPTS_DIR'
|
||||
bpy.ops.wm.save_userpref()
|
||||
bpy.ops.wm.quit_blender()
|
||||
else:
|
||||
if not addon_utils.check('BakeWrangler')[0]:
|
||||
addon_utils.enable('BakeWrangler', default_set=True)
|
||||
bpy.ops.wm.save_userpref()
|
||||
|
||||
print('Robossembler Framework Environment activated!')
|
||||
|
||||
rs_env()
|
272
cg/blender/texturing/bake_submitter.py
Normal file
272
cg/blender/texturing/bake_submitter.py
Normal file
|
@ -0,0 +1,272 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
'''
|
||||
DESCRIPTION.
|
||||
Basic mesh processing for asset pipeline.
|
||||
'''
|
||||
__version__ = '0.2'
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
'''
|
||||
DESCRIPTION.
|
||||
Preparing and execution methods for the baking process.
|
||||
'''
|
||||
__version__ = '0.1'
|
||||
|
||||
import logging
|
||||
import os
|
||||
import bpy
|
||||
import addon_utils
|
||||
import BakeWrangler
|
||||
from BakeWrangler.nodes.node_tree import BW_TREE_VERSION
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
# COLLECTIONS NAMIG CONVENTION
|
||||
parts_col_name = 'Parts'
|
||||
lcs_col_name = 'LCS'
|
||||
hierarchy_col_name = 'Hierarchy'
|
||||
lowpoly_col_name = 'Lowpoly'
|
||||
# LCS POINT'S SUFFIXES CONVENTION
|
||||
inlet = '_in'
|
||||
outlet = '_out'
|
||||
root = '_root'
|
||||
# CG ASSETS SUFFIXES CONVENTION
|
||||
hightpoly = '_hp'
|
||||
midpoly = 'mp'
|
||||
lowpoly = '_lp'
|
||||
render = '_render'
|
||||
|
||||
|
||||
def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area=None):
|
||||
''' Submit session and bake textures with BakeWrangler addon. '''
|
||||
BakeWrangler.register()
|
||||
|
||||
asm_name = os.path.basename(bpy.context.blend_data.filepath).split('.')[0]
|
||||
asm_path = os.path.dirname(bpy.context.blend_data.filepath)
|
||||
textures_path = os.path.join(asm_path,"textures").replace('\\', '/')
|
||||
bake_path = os.path.join(textures_path,"bake")
|
||||
os.makedirs(bake_path, exist_ok=True)
|
||||
|
||||
# create node tree
|
||||
tree = bpy.data.node_groups.new(name=tree_name, type='BakeWrangler_Tree')
|
||||
|
||||
# for default used Compositing Node Editor area
|
||||
if not area:
|
||||
if 'Compositing' in bpy.data.workspaces:
|
||||
for target_area in bpy.data.workspaces['Compositing'].screens[0].areas:
|
||||
if target_area.type == 'NODE_EDITOR':
|
||||
area = target_area
|
||||
break
|
||||
elif 'Rendering' in bpy.data.workspaces:
|
||||
# only if fail for Compositing Workspace
|
||||
for target_area in bpy.data.workspaces['Rendering'].screens[0].areas:
|
||||
if target_area.type == 'IMAGE_EDITOR':
|
||||
area = target_area
|
||||
break
|
||||
else:
|
||||
logger.info('Please, set default Bledner settings or set "area" parameter!')
|
||||
area.spaces[0].tree_type = 'BakeWrangler_Tree'
|
||||
area.spaces[0].path.start(tree)
|
||||
|
||||
tree.tree_version = BW_TREE_VERSION
|
||||
tree.initialised = True
|
||||
|
||||
# clear default nodes
|
||||
for node in tree.nodes:
|
||||
tree.nodes.remove(node)
|
||||
|
||||
# bw settings
|
||||
tree.nodes.new('BakeWrangler_MeshSettings').location = (0, 0)
|
||||
tree.nodes.new('BakeWrangler_SampleSettings').location = (200, 0)
|
||||
tree.nodes.new('BakeWrangler_PassSettings').location = (400, 0)
|
||||
tree.nodes.new('BakeWrangler_OutputSettings').location = (600, 0)
|
||||
|
||||
tree.nodes['Mesh Settings'].pinned = True
|
||||
tree.nodes['Mesh Settings']['margin'] = 8
|
||||
tree.nodes['Mesh Settings']['ray_dist'] = 0.002
|
||||
tree.nodes['Sample Settings'].pinned = True
|
||||
tree.nodes['Sample Settings']['bake_samples'] = 4
|
||||
tree.nodes['Pass Settings'].pinned = True
|
||||
tree.nodes['Pass Settings']['res_bake_x'] = resolution
|
||||
tree.nodes['Pass Settings']['res_bake_y'] = resolution
|
||||
tree.nodes['Output Settings'].pinned = True
|
||||
tree.nodes['Output Settings']['img_xres'] = resolution
|
||||
tree.nodes['Output Settings']['img_yres'] = resolution
|
||||
tree.nodes['Output Settings']['img_type'] = 2 # PNG
|
||||
tree.nodes['Output Settings']['img_compression'] = 50
|
||||
tree.nodes['Output Settings']['img_color_mode'] = 1 # RGB
|
||||
|
||||
## batch bake node
|
||||
node_batch = tree.nodes.new('BakeWrangler_Output_Batch_Bake')
|
||||
node_batch.location = (1000, -500)
|
||||
|
||||
node_y_pos = 0
|
||||
pass_socket = 0
|
||||
for lp_name in lowpoly_obj_names:
|
||||
""" run for eatch low poly object """
|
||||
lp = bpy.data.objects[lp_name]
|
||||
mp = bpy.data.objects['_'.join(lp.name.split('_')[:-1] + [midpoly])]
|
||||
img_name = '_'.join(lp.name.split('_')[:-1]) + '_'
|
||||
|
||||
node_inputs = tree.nodes.new('BakeWrangler_Bake_Mesh')
|
||||
node_inputs.location = (-700, node_y_pos -500)
|
||||
|
||||
node_inputs.inputs['Target'].value = lp
|
||||
node_inputs.inputs['Source'].value = mp
|
||||
|
||||
# bake passes
|
||||
## Diffuse
|
||||
node_d_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_d_pass.location = (-200, node_y_pos -500)
|
||||
node_d_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_d_img.location = (200, node_y_pos -500)
|
||||
|
||||
tree.links.new(node_d_pass.outputs['Color'], node_d_img.inputs['Color'])
|
||||
|
||||
node_d_pass.bake_cat = 'PBR'
|
||||
node_d_pass.bake_pbr = 'ALBEDO'
|
||||
node_d_img.inputs['Color'].suffix = 'D'
|
||||
node_d_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_d_img.inputs['Split Output'].img_name = img_name
|
||||
'''
|
||||
## Curvature
|
||||
node_c_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_c_pass.location = (-200, node_y_pos -1000)
|
||||
node_c_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_c_img.location = (200, node_y_pos -1000)
|
||||
|
||||
tree.links.new(node_c_pass.outputs['Color'], node_c_img.inputs['Color'])
|
||||
|
||||
node_c_pass.bake_cat = 'WRANG'
|
||||
node_c_pass.bake_wrang = 'CURVATURE'
|
||||
node_c_img.inputs['Color'].suffix = 'C'
|
||||
node_c_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_c_img.inputs['Split Output'].img_name = img_name
|
||||
'''
|
||||
## Normal
|
||||
node_n_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
#tree.nodes['Bake Pass.001'].name = 'normal_pass'
|
||||
node_n_pass.location = (-200, node_y_pos -1500)
|
||||
node_n_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_n_img.location = (200, node_y_pos -1500)
|
||||
|
||||
tree.links.new(node_n_pass.outputs['Color'], node_n_img.inputs['Color'])
|
||||
|
||||
node_n_pass.bake_cat = 'CORE'
|
||||
node_n_pass.bake_core = 'NORMAL'
|
||||
node_n_img.inputs['Color'].suffix = 'N'
|
||||
node_n_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_n_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
## AO
|
||||
node_ao_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_ao_pass.location = (-200, node_y_pos -2000)
|
||||
node_ao_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_ao_img.location = (200, node_y_pos -2000)
|
||||
|
||||
tree.links.new(node_ao_pass.outputs['Color'], node_ao_img.inputs['Color'])
|
||||
|
||||
node_ao_pass.bake_cat = 'CORE'
|
||||
node_ao_pass.bake_core = 'AO'
|
||||
node_ao_pass.bake_samples = 32
|
||||
node_ao_img.inputs['Color'].suffix = 'AO'
|
||||
node_ao_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_ao_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
## Roughness
|
||||
node_r_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_r_pass.location = (-200, node_y_pos -2500)
|
||||
node_r_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_r_img.location = (200, node_y_pos -2500)
|
||||
|
||||
tree.links.new(node_r_pass.outputs['Color'], node_r_img.inputs['Color'])
|
||||
|
||||
node_r_pass.bake_cat = 'CORE'
|
||||
node_r_pass.bake_core = 'ROUGHNESS'
|
||||
node_r_img.inputs['Color'].suffix = 'R'
|
||||
node_r_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_r_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
## Metallic
|
||||
node_m_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_m_pass.location = (-200, node_y_pos -3000)
|
||||
node_m_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_m_img.location = (200, node_y_pos -3000)
|
||||
|
||||
tree.links.new(node_m_pass.outputs['Color'], node_m_img.inputs['Color'])
|
||||
|
||||
node_m_pass.bake_cat = 'PBR'
|
||||
node_m_pass.bake_pbr = 'METALLIC'
|
||||
node_m_img.inputs['Color'].suffix = 'M'
|
||||
node_m_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_m_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
## UV
|
||||
node_uv_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_uv_pass.location = (-200, node_y_pos -3500)
|
||||
node_uv_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_uv_img.location = (200, node_y_pos -3500)
|
||||
|
||||
tree.links.new(node_uv_pass.outputs['Color'], node_uv_img.inputs['Color'])
|
||||
|
||||
node_uv_pass.bake_cat = 'WRANG'
|
||||
node_uv_pass.bake_wrang = 'ISLANDID'
|
||||
node_uv_img.inputs['Color'].suffix = 'UV'
|
||||
node_uv_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_uv_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
# connect meshes to passes
|
||||
tree.links.new(node_inputs.outputs['Mesh'], node_d_pass.inputs[1])
|
||||
'''
|
||||
tree.links.new(node_inputs.outputs['Mesh'], node_c_pass.inputs[1])
|
||||
'''
|
||||
tree.links.new(node_inputs.outputs['Mesh'], node_n_pass.inputs[1])
|
||||
tree.links.new(node_inputs.outputs['Mesh'], node_ao_pass.inputs[1])
|
||||
tree.links.new(node_inputs.outputs['Mesh'], node_r_pass.inputs[1])
|
||||
tree.links.new(node_inputs.outputs['Mesh'], node_m_pass.inputs[1])
|
||||
tree.links.new(node_inputs.outputs['Mesh'], node_uv_pass.inputs[1])
|
||||
|
||||
## batch bake node
|
||||
tree.links.new(node_d_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
'''
|
||||
pass_socket += 1
|
||||
tree.links.new(node_c_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
'''
|
||||
pass_socket += 1
|
||||
tree.links.new(node_n_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
pass_socket += 1
|
||||
tree.links.new(node_ao_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
pass_socket += 1
|
||||
tree.links.new(node_r_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
pass_socket += 1
|
||||
tree.links.new(node_m_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
pass_socket += 1
|
||||
tree.links.new(node_uv_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
pass_socket += 1
|
||||
|
||||
node_y_pos -= 4000
|
||||
|
||||
return bpy.ops.bake_wrangler.bake_pass(tree=tree_name, node="Batch Bake", sock=-1)
|
|
@ -22,6 +22,7 @@ from blender.processing.highpoly_setup import setup_meshes
|
|||
from blender.processing.midpoly_setup import hightpoly_collections_to_midpoly
|
||||
from blender.processing.lowpoly_setup import parts_to_shells
|
||||
from blender.processing.uv_setup import uv_unwrap
|
||||
from blender.texturing.bake_submitter import bw_submit
|
||||
from blender.export.dae import export_dae
|
||||
from blender.export.stl import export_stl
|
||||
import bpy
|
||||
|
@ -74,6 +75,7 @@ def cg_pipeline(**kwargs):
|
|||
config = kwargs.pop('config', None)
|
||||
|
||||
# prepare blend file
|
||||
|
||||
remove_collections()
|
||||
cleanup_orphan_data()
|
||||
|
||||
|
@ -88,16 +90,16 @@ def cg_pipeline(**kwargs):
|
|||
)
|
||||
)
|
||||
|
||||
# restructuring hierarchy by lcs points
|
||||
if imported_objects['objs_lcs']:
|
||||
restruct_hierarchy(imported_objects['objs_lcs'])
|
||||
|
||||
# save import in blender scene
|
||||
if blend_path is not None:
|
||||
if not os.path.isdir(os.path.dirname(blend_path)):
|
||||
os.makedirs(os.path.dirname(blend_path))
|
||||
bpy.ops.wm.save_as_mainfile(filepath=blend_path)
|
||||
|
||||
# restructuring hierarchy by lcs points
|
||||
if imported_objects['objs_lcs']:
|
||||
restruct_hierarchy(imported_objects['objs_lcs'])
|
||||
|
||||
# prepare highpoly
|
||||
if imported_objects['objs_foreground']:
|
||||
setup_meshes(imported_objects['objs_foreground'], sharpness=True, shading=True)
|
||||
|
@ -115,7 +117,6 @@ def cg_pipeline(**kwargs):
|
|||
)
|
||||
hightpoly_collections_to_midpoly(part_names)
|
||||
|
||||
|
||||
# prepare lowpoly
|
||||
lowpoly_obj_names = parts_to_shells(part_names)
|
||||
uv_unwrap(lowpoly_obj_names)
|
||||
|
@ -126,6 +127,10 @@ def cg_pipeline(**kwargs):
|
|||
os.makedirs(os.path.dirname(blend_path))
|
||||
bpy.ops.wm.save_as_mainfile(filepath=blend_path)
|
||||
|
||||
# bake textures
|
||||
bpy.ops.wm.open_mainfile(filepath=blend_path)
|
||||
bw_submit(lowpoly_obj_names)
|
||||
|
||||
# export object meshes and urdf
|
||||
to_urdf = collections.defaultdict(list)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue