wip first usable version
parent
e60c449524
commit
38481de18d
|
@ -0,0 +1,2 @@
|
||||||
|
__pycache__
|
||||||
|
*.py[cod]
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Changelog
|
||||||
|
|
||||||
|
0.1.0
|
||||||
|
|
||||||
|
first WIP usable version
|
|
@ -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>.
|
|
@ -0,0 +1,87 @@
|
||||||
|
import bpy
|
||||||
|
from .import gen_vlayer
|
||||||
|
|
||||||
|
class GPEXP_OT_add_layer_to_render(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.add_layer_to_render"
|
||||||
|
bl_label = "Add Gp Layer as render nodes"
|
||||||
|
bl_description = "Create a view_layer for GP > add node > connect to output"
|
||||||
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context.object and context.object.type == 'GPENCIL'
|
||||||
|
|
||||||
|
# mode : bpy.props.StringProperty(options={'SKIP_SAVE'})
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
ob = context.object
|
||||||
|
layer = ob.data.layers.active
|
||||||
|
if not layer:
|
||||||
|
self.report({'ERROR'}, 'No active layer')
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
ct = 0
|
||||||
|
# send scene ?
|
||||||
|
for l in ob.data.layers:
|
||||||
|
if not l.select:
|
||||||
|
continue
|
||||||
|
gen_vlayer.get_set_viewlayer_from_gp(ob, l)
|
||||||
|
ct += 1
|
||||||
|
if ct:
|
||||||
|
self.report({'INFO'}, f'{ct} layer(s) added to scene "Render"')
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
def export_gp_objects(oblist, exclude_list=['MA', 'IN']):
|
||||||
|
# Skip layer containing element in excluyde list
|
||||||
|
if not isinstance(oblist, list):
|
||||||
|
oblist = [oblist]
|
||||||
|
|
||||||
|
for ob in oblist:
|
||||||
|
for l in ob.data.layers:
|
||||||
|
if any(x + '_' in l.info for x in exclude_list):
|
||||||
|
continue
|
||||||
|
if l.hide:
|
||||||
|
continue
|
||||||
|
vl, cp = gen_vlayer.get_set_viewlayer_from_gp(ob, l) # scene=fn.get_render_scene())
|
||||||
|
|
||||||
|
|
||||||
|
## send operator with mode ALL or SELECTED to batch build
|
||||||
|
class GPEXP_OT_add_objects_to_render(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.add_object_to_render"
|
||||||
|
bl_label = "Add all Gp Layer of active object as render nodes"
|
||||||
|
bl_description = "Create a view_layer for GP. Add node > connect to output"
|
||||||
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return context.object and context.object.type == 'GPENCIL'
|
||||||
|
|
||||||
|
mode : bpy.props.StringProperty(default='ALL', options={'SKIP_SAVE'})
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
if self.mode == 'SELECTED':
|
||||||
|
export_gp_objects([o for o in context.selected_objects if o.type == 'GPENCIL'])
|
||||||
|
|
||||||
|
elif self.mode == 'ALL':
|
||||||
|
scn = bpy.data.scenes.get('Scene')
|
||||||
|
if not scn:
|
||||||
|
self.report({'ERROR'}, 'Could not found default scene')
|
||||||
|
return {"CANCELLED"}
|
||||||
|
export_gp_objects([o for o in scn.objects if o.type == 'GPENCIL'])
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
classes=(
|
||||||
|
GPEXP_OT_add_layer_to_render,
|
||||||
|
GPEXP_OT_add_objects_to_render,
|
||||||
|
)
|
||||||
|
|
||||||
|
def register():
|
||||||
|
for cls in classes:
|
||||||
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
for cls in reversed(classes):
|
||||||
|
bpy.utils.unregister_class(cls)
|
|
@ -0,0 +1,52 @@
|
||||||
|
import bpy
|
||||||
|
|
||||||
|
|
||||||
|
class GPEXP_OT_clear_render_tree(bpy.types.Operator):
|
||||||
|
bl_idname = "gp.clear_render_tree"
|
||||||
|
bl_label = "Clear Render Node Tree "
|
||||||
|
bl_description = "Clear node tree from render scene"
|
||||||
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return True
|
||||||
|
|
||||||
|
mode : bpy.props.StringProperty(options={'SKIP_SAVE'})
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
|
||||||
|
render = bpy.data.scenes.get('Render')
|
||||||
|
if not render:
|
||||||
|
print('SKIP, no Render scene')
|
||||||
|
|
||||||
|
# clear all nodes
|
||||||
|
if render.use_nodes:
|
||||||
|
for i in range(len(render.node_tree.nodes))[::-1]:
|
||||||
|
if not render.node_tree.nodes[i].parent:
|
||||||
|
continue
|
||||||
|
render.node_tree.nodes.remove(render.node_tree.nodes[i])
|
||||||
|
|
||||||
|
# clear all view_layers
|
||||||
|
for vl in reversed(render.view_layers):
|
||||||
|
if ' / ' in vl.name:
|
||||||
|
render.view_layers.remove(vl)
|
||||||
|
|
||||||
|
# clear all "NG_" nodegroups
|
||||||
|
for ng in reversed(bpy.data.node_groups):
|
||||||
|
if ng.name.startswith('NG_'):
|
||||||
|
ng.use_fake_user = False
|
||||||
|
bpy.data.node_groups.remove(ng)
|
||||||
|
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
classes=(
|
||||||
|
GPEXP_OT_clear_render_tree,
|
||||||
|
)
|
||||||
|
|
||||||
|
def register():
|
||||||
|
for cls in classes:
|
||||||
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
for cls in reversed(classes):
|
||||||
|
bpy.utils.unregister_class(cls)
|
|
@ -0,0 +1,112 @@
|
||||||
|
import bpy
|
||||||
|
|
||||||
|
|
||||||
|
def merge_layers(rlayers, obname=None):
|
||||||
|
print(f'Merging {len(rlayers)} layers')
|
||||||
|
print('->', [r.layer for r in rlayers])
|
||||||
|
print()
|
||||||
|
|
||||||
|
if not rlayers:
|
||||||
|
return ('ERROR', 'No render layer sent to merge')
|
||||||
|
|
||||||
|
ng = rlayers[0].outputs[0].links[0].to_node
|
||||||
|
rlayers.sort(key=lambda x: x.location.y, reverse=True)
|
||||||
|
|
||||||
|
# change colors of those nodes
|
||||||
|
color = random_color()
|
||||||
|
for n in rlayers:
|
||||||
|
n.use_custom_color = True
|
||||||
|
n.color = color
|
||||||
|
|
||||||
|
|
||||||
|
# get inside socket (group input) from outside socket list (should be already ordered)
|
||||||
|
|
||||||
|
## by name
|
||||||
|
# for i, inp in enumerate(ng.node_tree.inputs):
|
||||||
|
# if inp.name ==
|
||||||
|
|
||||||
|
# by connection order
|
||||||
|
|
||||||
|
socket_list = []
|
||||||
|
grp_sockets = []
|
||||||
|
|
||||||
|
for n in rlayers:
|
||||||
|
if n.outputs[0].links[0].to_node != ng:
|
||||||
|
print(f'Skip {n.layer}, connect to {n.outputs[0].links[0].to_node} instead of {ng.name}')
|
||||||
|
continue
|
||||||
|
|
||||||
|
sock_in = n.outputs[0].links[0].to_socket
|
||||||
|
for i, s in enumerate(ng.inputs):
|
||||||
|
if s == sock_in:
|
||||||
|
print(i, s.name)
|
||||||
|
socket_list.append(s)
|
||||||
|
grp_sockets.append(ng.node_tree.nodes['Group Input'].outputs[i])
|
||||||
|
break
|
||||||
|
|
||||||
|
# debug
|
||||||
|
for inp, grps in zip(socket_list, grp_sockets):
|
||||||
|
if inp.name != grps.name:
|
||||||
|
print(f'\n! Problem ! : {inp.name}, {grps.name}')
|
||||||
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# JUST CREATE ANOTHER GROUP NODE FOR THE MERGE !
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
def merge_selected_layers():
|
||||||
|
'''Merge command from selected GP layers'''
|
||||||
|
ob = bpy.context.object
|
||||||
|
layer_names = [l.info for l in ob.data.layers if l.select and not l.hide]
|
||||||
|
print("layer_names", layer_names)#Dbg
|
||||||
|
|
||||||
|
if len(layer_names) < 2:
|
||||||
|
print(f'Should select multiple layers for merging')
|
||||||
|
return
|
||||||
|
|
||||||
|
render = bpy.data.scenes.get('Render')
|
||||||
|
if render:
|
||||||
|
nodes = render.node_tree.nodes
|
||||||
|
|
||||||
|
clean_ob_name = bpy.path.clean_name(ob.name)
|
||||||
|
rlayers = []
|
||||||
|
for l in layer_names:
|
||||||
|
## identifier is clean_name(ob.name).layer_name
|
||||||
|
|
||||||
|
idname = f'{clean_ob_name}.{l}'
|
||||||
|
|
||||||
|
# check the render layer that have a parent frame
|
||||||
|
rlayer = [n for n in nodes if n.type == 'R_LAYERS' and n.layer == idname and n.parent]
|
||||||
|
if not rlayer:
|
||||||
|
# send to function to generate the rlayer and connect
|
||||||
|
# rlayer = creation
|
||||||
|
continue
|
||||||
|
|
||||||
|
rlayers.append(rlayer)
|
||||||
|
|
||||||
|
merge_layers(rlayers, obname=clean_ob_name)
|
||||||
|
|
||||||
|
|
||||||
|
def merge_selected_render_layers():
|
||||||
|
'''Merge command from selected render layers nodes'''
|
||||||
|
render = bpy.data.scenes.get('Render')
|
||||||
|
if not render:
|
||||||
|
print('No render scene')
|
||||||
|
return
|
||||||
|
|
||||||
|
nodes = render.node_tree.nodes
|
||||||
|
selection = [n for n in nodes if n.select and n.type == 'R_LAYERS']
|
||||||
|
|
||||||
|
# should be from the same object:
|
||||||
|
assert all(selection[0].layer.split('.')[0] == n.layer.split('.')[0] for n in selection), 'Not every nodes start with the same object'
|
||||||
|
|
||||||
|
# obname = selection[0].layer.split('.')[0]
|
||||||
|
merge_layers(selection)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# merge_selected_layers() # function to merge from GP dopesheet
|
||||||
|
|
||||||
|
merge_selected_render_layers() # function to merge from nodegroup
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# GP exporter
|
||||||
|
|
||||||
|
|
||||||
|
## Todo
|
||||||
|
|
||||||
|
- fix frame problem
|
||||||
|
- bring cameras (and lights ?) from original scene
|
|
@ -0,0 +1,39 @@
|
||||||
|
bl_info = {
|
||||||
|
"name": "GP exporter",
|
||||||
|
"description": "Organise export of gp layers through compositor output",
|
||||||
|
"author": "Samuel Bernou",
|
||||||
|
"version": (0, 1, 0),
|
||||||
|
"blender": (2, 93, 0),
|
||||||
|
"location": "View3D",
|
||||||
|
"warning": "",
|
||||||
|
"doc_url": "",
|
||||||
|
"category": "Object" }
|
||||||
|
|
||||||
|
|
||||||
|
from . import OP_add_layer
|
||||||
|
from . import OP_clear
|
||||||
|
from . import ui
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
|
||||||
|
def register():
|
||||||
|
if bpy.app.background:
|
||||||
|
return
|
||||||
|
|
||||||
|
OP_add_layer.register()
|
||||||
|
OP_clear.register()
|
||||||
|
ui.register()
|
||||||
|
# bpy.types.Scene.pgroup_name = bpy.props.PointerProperty(type = PROJ_PGT_settings)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
if bpy.app.background:
|
||||||
|
return
|
||||||
|
|
||||||
|
ui.unregister()
|
||||||
|
OP_clear.unregister()
|
||||||
|
OP_add_layer.unregister()
|
||||||
|
|
||||||
|
# del bpy.types.Scene.pgroup_name
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
register()
|
|
@ -0,0 +1,255 @@
|
||||||
|
import bpy
|
||||||
|
import re
|
||||||
|
from mathutils import Vector
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
|
def create_node(type, tree=None, **kargs):
|
||||||
|
'''Get a type, a tree to add in, and optionnaly multiple attribute to set
|
||||||
|
return created node
|
||||||
|
'''
|
||||||
|
tree = tree or bpy.context.scene.node_tree
|
||||||
|
|
||||||
|
node = tree.nodes.new(type)
|
||||||
|
for k,v in kargs.items():
|
||||||
|
setattr(node, k, v)
|
||||||
|
|
||||||
|
return node
|
||||||
|
|
||||||
|
def new_aa_node(tree):
|
||||||
|
'''create AA node'''
|
||||||
|
aa = create_node('CompositorNodeAntiAliasing', tree) # type = ANTIALIASING
|
||||||
|
aa.threshold = 0.5
|
||||||
|
aa.contrast_limit = 0.5
|
||||||
|
aa.corner_rounding = 0.25
|
||||||
|
aa.hide = True
|
||||||
|
return aa
|
||||||
|
|
||||||
|
|
||||||
|
def set_settings(scene=None):
|
||||||
|
if not scene:
|
||||||
|
scene = bpy.context.scene
|
||||||
|
# specify scene settings for these kind of render
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.eevee.taa_render_samples = 1
|
||||||
|
scene.grease_pencil_settings.antialias_threshold = 0
|
||||||
|
|
||||||
|
def get_render_scene():
|
||||||
|
'''Get / Create a scene named Render'''
|
||||||
|
render = bpy.data.scenes.get('Render')
|
||||||
|
if not render:
|
||||||
|
render = bpy.data.scenes.new('Render')
|
||||||
|
set_settings(render) # setup specific settings
|
||||||
|
render.use_nodes = True
|
||||||
|
return render
|
||||||
|
|
||||||
|
def get_view_layer(name, scene=None):
|
||||||
|
'''get viewlayer name
|
||||||
|
return existing/created viewlayer
|
||||||
|
'''
|
||||||
|
if not scene:
|
||||||
|
scene = get_render_scene()
|
||||||
|
### pass double letter prefix as suffix
|
||||||
|
## pass_name = re.sub(r'^([A-Z]{2})(_)(.*)', r'\3\2\1', 'name')
|
||||||
|
## pass_name = f'{name}_{passe}'
|
||||||
|
pass_vl = scene.view_layers.get(name)
|
||||||
|
if not pass_vl:
|
||||||
|
pass_vl = scene.view_layers.new(name)
|
||||||
|
return pass_vl
|
||||||
|
|
||||||
|
### node location tweaks
|
||||||
|
|
||||||
|
def real_loc(n):
|
||||||
|
if not n.parent:
|
||||||
|
return n.location
|
||||||
|
return n.location + real_loc(n.parent)
|
||||||
|
|
||||||
|
def get_frame_transform(f, node_tree=None):
|
||||||
|
'''Return real transform location of a frame node
|
||||||
|
only works with one level of nesting (not recursive)
|
||||||
|
'''
|
||||||
|
if not node_tree:
|
||||||
|
node_tree = f.id_data
|
||||||
|
if f.type != 'FRAME':
|
||||||
|
return
|
||||||
|
# return real_loc(f), f.dimensions
|
||||||
|
|
||||||
|
childs = [n for n in node_tree.nodes if n.parent == f]
|
||||||
|
# real_locs = [f.location + n.location for n in childs]
|
||||||
|
|
||||||
|
xs = [n.location.x for n in childs] + [n.location.x + n.dimensions.x for n in childs]
|
||||||
|
ys = [n.location.y for n in childs] + [n.location.y - n.dimensions.y for n in childs]
|
||||||
|
xs.sort(key=lambda loc: loc) # x val : ascending
|
||||||
|
ys.sort(key=lambda loc: loc) # ascending # , reversed=True) # y val : descending
|
||||||
|
|
||||||
|
loc = Vector((min(xs), max(ys)))
|
||||||
|
dim = Vector((max(xs) - min(xs) + 60, max(ys) - min(ys) + 60))
|
||||||
|
|
||||||
|
return loc, dim
|
||||||
|
|
||||||
|
|
||||||
|
## get all frames with their real transform.
|
||||||
|
|
||||||
|
def bbox(f, frames):
|
||||||
|
xs=[]
|
||||||
|
ys=[]
|
||||||
|
for n in frames[f]: # nodes of passed frame
|
||||||
|
# Better as Vectors ?
|
||||||
|
if n.type == 'FRAME':
|
||||||
|
if n not in frames.keys():
|
||||||
|
# print(f'frame {n.name} not in frame list')
|
||||||
|
continue
|
||||||
|
all_xs, all_ys = bbox(n, frames) # frames[n]
|
||||||
|
xs += all_xs
|
||||||
|
ys += all_ys
|
||||||
|
|
||||||
|
else:
|
||||||
|
loc = real_loc(n)
|
||||||
|
xs += [loc.x, loc.x + n.dimensions.x] # + (n.dimensions.x/get_dpi_factor())
|
||||||
|
ys += [loc.y, loc.y - n.dimensions.y] # - (n.dimensions.y/get_dpi_factor())
|
||||||
|
|
||||||
|
|
||||||
|
# margin ~= 30
|
||||||
|
# return xs and ys
|
||||||
|
return [min(xs)-30, max(xs)+30], [min(ys)-30, max(ys)+30]
|
||||||
|
|
||||||
|
def get_frames_bbox(node_tree):
|
||||||
|
'''Return a dic with all frames
|
||||||
|
ex: {frame_node: (location, dimension), ...}
|
||||||
|
'''
|
||||||
|
|
||||||
|
# create dic of frame object with his direct child nodes nodes
|
||||||
|
frames = defaultdict(list)
|
||||||
|
frames_bbox = {}
|
||||||
|
for n in node_tree.nodes:
|
||||||
|
if not n.parent:
|
||||||
|
continue
|
||||||
|
# also contains frames
|
||||||
|
frames[n.parent].append(n)
|
||||||
|
|
||||||
|
# Dic for bbox coord
|
||||||
|
for f, nodes in frames.items():
|
||||||
|
if f.parent:
|
||||||
|
continue
|
||||||
|
|
||||||
|
xs, ys = bbox(f, frames)
|
||||||
|
# xs, ys = bbox(nodes, frames)
|
||||||
|
|
||||||
|
## returning: list of corner coords
|
||||||
|
# coords = [
|
||||||
|
# Vector((xs[0], ys[1])),
|
||||||
|
# Vector((xs[1], ys[1])),
|
||||||
|
# Vector((xs[1], ys[0])),
|
||||||
|
# Vector((xs[0], ys[0])),
|
||||||
|
# ]
|
||||||
|
# frames_bbox[f] = coords
|
||||||
|
|
||||||
|
## returning: (loc vector, dimensions vector)
|
||||||
|
frames_bbox[f] = Vector((xs[0], ys[1])), Vector((xs[1] - xs[0], ys[1] - ys[0]))
|
||||||
|
|
||||||
|
return frames_bbox
|
||||||
|
|
||||||
|
|
||||||
|
## nodes helper functions
|
||||||
|
|
||||||
|
def clear_nodegroup(name, full_clear=False):
|
||||||
|
'''remove duplication of a nodegroup (.???)
|
||||||
|
also remove the base one if full_clear True
|
||||||
|
'''
|
||||||
|
|
||||||
|
for ng in reversed(bpy.data.node_groups):
|
||||||
|
pattern = name + r'\.\d{3}'
|
||||||
|
if re.search(pattern, ng.name):
|
||||||
|
bpy.data.node_groups.remove(ng)
|
||||||
|
|
||||||
|
if full_clear and ng.name == name:
|
||||||
|
# if full clear
|
||||||
|
bpy.data.node_groups.remove(ng)
|
||||||
|
|
||||||
|
|
||||||
|
def rearrange_frames(node_tree):
|
||||||
|
frame_d = get_frames_bbox(node_tree) # dic : {frame_node:(loc vector, dimensions vector), ...}
|
||||||
|
if not frame_d:
|
||||||
|
print('no frame found')
|
||||||
|
return
|
||||||
|
|
||||||
|
print([f.name for f in frame_d.keys()])
|
||||||
|
## order the dict by frame.y location
|
||||||
|
frame_d = {key: value for key, value in sorted(frame_d.items(), key=lambda pair: pair[1][0].y - pair[1][1].y, reverse=True)}
|
||||||
|
frames = [[f, v[0], v[1].y] for f, v in frame_d.items()] # [frame_node, real_loc, real dimensions]
|
||||||
|
|
||||||
|
top = frames[0][1].y # upper node location.y
|
||||||
|
offset = 0
|
||||||
|
for f in frames:
|
||||||
|
## f[1] : real loc Vector
|
||||||
|
## f[0] : frame
|
||||||
|
|
||||||
|
## move frame by offset needed (delta between real_loc and "fake" loc , minus offset)
|
||||||
|
f[0].location.y = (f[1].y - f[0].location.y) - top - offset
|
||||||
|
# f[0].location.y = f[1].y - top - offset
|
||||||
|
offset += f[2] + 300 # gap
|
||||||
|
|
||||||
|
f[0].update()
|
||||||
|
|
||||||
|
def reorder_inputs(ng):
|
||||||
|
rl_nodes = [s.links[0].from_node for s in ng.inputs if s.is_linked and s.links and s.links[0].from_node.type == 'R_LAYERS']
|
||||||
|
rl_nodes.sort(key=lambda x: x.location.y, reverse=True)
|
||||||
|
names = [n.layer for n in rl_nodes]
|
||||||
|
inputs_names = [s.name for s in ng.inputs]
|
||||||
|
filtered_names = [n for n in names if n in inputs_names]
|
||||||
|
|
||||||
|
for dest, name in enumerate(filtered_names):
|
||||||
|
## rebuild list at each iteration so index are good
|
||||||
|
inputs_names = [s.name for s in ng.inputs]
|
||||||
|
src = inputs_names.index(name)
|
||||||
|
# reorder on node_tree not directly on node!
|
||||||
|
ng.node_tree.inputs.move(src, dest)
|
||||||
|
|
||||||
|
def reorder_outputs(ng):
|
||||||
|
ordered_out_name = [nis.name for nis in ng.inputs if nis.name in [o.name for o in ng.outputs]]
|
||||||
|
for s_name in ordered_out_name:
|
||||||
|
all_outnames = [o.name for o in ng.outputs]
|
||||||
|
# reorder on nodetree, not on node !
|
||||||
|
ng.node_tree.outputs.move(all_outnames.index(s_name), ordered_out_name.index(s_name))
|
||||||
|
|
||||||
|
def clear_disconnected(fo):
|
||||||
|
for inp in reversed(fo.inputs):
|
||||||
|
if not inp.is_linked:
|
||||||
|
print(f'Deleting unlinked fileout slot: {inp.name}')
|
||||||
|
fo.inputs.remove(inp)
|
||||||
|
|
||||||
|
def reorder_fileout(fo, ng=None):
|
||||||
|
if not ng: # get connected nodegroup
|
||||||
|
for s in fo.inputs:
|
||||||
|
if s.is_linked and s.links and s.links[0].from_node.type == 'GROUP':
|
||||||
|
ng = s.links[0].from_node
|
||||||
|
break
|
||||||
|
if not ng:
|
||||||
|
print(f'No nodegroup to refer to filter {fo.name}')
|
||||||
|
return
|
||||||
|
ordered = [o.links[0].to_socket.name for o in ng.outputs if o.is_linked and o.is_linked and o.links[0].to_node == fo]
|
||||||
|
for s_name in ordered:
|
||||||
|
all_outnames = [s.name for s in fo.inputs] # same as [fs.path for fs in fo.file_slots]
|
||||||
|
fo.inputs.move(all_outnames.index(s_name), ordered.index(s_name))
|
||||||
|
|
||||||
|
def connect_to_group_output(n):
|
||||||
|
for o in n.outputs:
|
||||||
|
if o.is_linked:
|
||||||
|
if o.links[0].to_node.type == 'GROUP_OUTPUT':
|
||||||
|
return o.links[0].to_socket
|
||||||
|
val = connect_to_group_output(o.links[0].to_node)
|
||||||
|
if val:
|
||||||
|
return val
|
||||||
|
return False
|
||||||
|
|
||||||
|
def connect_to_group_input(n):
|
||||||
|
for i in n.inputs:
|
||||||
|
if i.is_linked:
|
||||||
|
if i.links[0].from_node.type == 'GROUP_INPUT':
|
||||||
|
return i.links[0].from_socket
|
||||||
|
val = connect_to_group_input(i.links[0].from_node)
|
||||||
|
if val:
|
||||||
|
return val
|
||||||
|
return False
|
|
@ -0,0 +1,341 @@
|
||||||
|
import bpy
|
||||||
|
from mathutils import Vector
|
||||||
|
from . import fn
|
||||||
|
|
||||||
|
|
||||||
|
def add_rlayer(layer_name, scene=None, location=None, color=None, node_name=None, width=400):
|
||||||
|
'''create a render layer node
|
||||||
|
if node_name is not specified, use passed layer name
|
||||||
|
'''
|
||||||
|
|
||||||
|
if not node_name:
|
||||||
|
node_name = layer_name # 'RL_' +
|
||||||
|
|
||||||
|
if not scene:
|
||||||
|
scene=bpy.context.scene
|
||||||
|
|
||||||
|
nodes = scene.node_tree.nodes
|
||||||
|
|
||||||
|
comp = nodes.get(node_name)
|
||||||
|
if comp:
|
||||||
|
if comp.layer == node_name:
|
||||||
|
return comp
|
||||||
|
else:
|
||||||
|
# TODO : delete rlayer with bad VL name !
|
||||||
|
pass
|
||||||
|
|
||||||
|
comp = nodes.new('CompositorNodeRLayers')
|
||||||
|
comp.name = node_name
|
||||||
|
comp.scene = scene
|
||||||
|
comp.layer = layer_name
|
||||||
|
comp.label = layer_name
|
||||||
|
if location:
|
||||||
|
comp.location = location
|
||||||
|
if color:
|
||||||
|
comp.color = color
|
||||||
|
|
||||||
|
if width:
|
||||||
|
comp.width = width
|
||||||
|
comp.show_preview = False
|
||||||
|
return comp
|
||||||
|
|
||||||
|
def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
||||||
|
scene = fn.get_render_scene()
|
||||||
|
nodes = scene.node_tree.nodes
|
||||||
|
links = scene.node_tree.links
|
||||||
|
|
||||||
|
vl_name = rlayer.layer
|
||||||
|
if not vl_name or vl_name == 'View Layer':
|
||||||
|
print(f'Bad layer for node {rlayer.name}')
|
||||||
|
|
||||||
|
if not ' / ' in vl_name:
|
||||||
|
print(f'no slash (" / ") separator in vl_name {vl_name}, should be "obj.name / layer_name"')
|
||||||
|
return
|
||||||
|
|
||||||
|
obname, lname = vl_name.split(' / ')
|
||||||
|
lname = bpy.path.clean_name(lname)
|
||||||
|
|
||||||
|
if not frame:
|
||||||
|
if rlayer.parent:
|
||||||
|
frame=rlayer.parent
|
||||||
|
else:
|
||||||
|
print(f'render_layer has not parent frame: {rlayer.name}')
|
||||||
|
frame=None
|
||||||
|
|
||||||
|
ng_name = f'NG_{obname}' # only object name
|
||||||
|
|
||||||
|
|
||||||
|
## clear nodes groups duplication (.00?)
|
||||||
|
fn.clear_nodegroup(ng_name, full_clear=False)
|
||||||
|
|
||||||
|
# get set nodegroup from vlayer name
|
||||||
|
if not ng:
|
||||||
|
ng = nodes.get(ng_name)
|
||||||
|
|
||||||
|
if not ng:
|
||||||
|
ngroup = bpy.data.node_groups.get(ng_name)
|
||||||
|
# full clear True if exists but not used
|
||||||
|
if ngroup and ngroup.users == 0:
|
||||||
|
ngroup = None
|
||||||
|
fn.clear_nodegroup(ng_name, full_clear=True)
|
||||||
|
|
||||||
|
if not ngroup:
|
||||||
|
# delete and recreate ?
|
||||||
|
print(f'create nodegroup {ng_name}')
|
||||||
|
ngroup = bpy.data.node_groups.new(ng_name, 'CompositorNodeTree')
|
||||||
|
|
||||||
|
ng = fn.create_node('CompositorNodeGroup', tree=scene.node_tree, location=(fn.real_loc(rlayer)[0] + 600, fn.real_loc(rlayer)[1]), width=400) # (rlayer.location[0] + 600, rlayer.location[1])
|
||||||
|
if frame:
|
||||||
|
ng.parent= frame
|
||||||
|
ng.node_tree = ngroup
|
||||||
|
ng.name = ngroup.name
|
||||||
|
|
||||||
|
ng_in = fn.create_node('NodeGroupInput', tree=ngroup, location=(-600,0))
|
||||||
|
ng_out = fn.create_node('NodeGroupOutput', tree=ngroup, location=(600,0))
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f'found group node {ng.name}')
|
||||||
|
ngroup = ng.node_tree
|
||||||
|
ng_in = ngroup.nodes.get('Group Input')
|
||||||
|
ng_out = ngroup.nodes.get('Group Output')
|
||||||
|
|
||||||
|
# Connect rlayer to nodegroup
|
||||||
|
if not rlayer.outputs['Image'].is_linked:
|
||||||
|
sockin = ng.inputs.get(vl_name)
|
||||||
|
if not sockin:
|
||||||
|
print('creating socket', vl_name)
|
||||||
|
sockin = ng.inputs.new('NodeSocketColor', vl_name)
|
||||||
|
sockin = ng.inputs[-1]
|
||||||
|
|
||||||
|
links.new(rlayer.outputs['Image'], sockin)
|
||||||
|
|
||||||
|
## get nodes from frame
|
||||||
|
rl_nodes = [n for n in nodes if n.type == 'R_LAYERS' and n.layer != 'View Layer' and n.parent == frame]
|
||||||
|
|
||||||
|
# auto clean : if an input exists but is not linked and name not exists in rlayers of current frame
|
||||||
|
for s in reversed(ng.inputs):
|
||||||
|
if not s.is_linked: # and not any(x.layer == s.name for x in rl_nodes)
|
||||||
|
print(f'removing grp unlinked input {s.name}')
|
||||||
|
ng.inputs.remove(s)
|
||||||
|
|
||||||
|
## get nodes from linked NG inputs ??? maybe more clear...
|
||||||
|
# rl_nodes = [s.links[0].from_node for s in ng.inputs if s.links and s.links[0].from_node and s.links[0].from_node.type == 'R_LAYERS']
|
||||||
|
|
||||||
|
## reorder
|
||||||
|
fn.reorder_inputs(ng)
|
||||||
|
ng.update()
|
||||||
|
# CREATE NG outsocket (individual, without taking merge)
|
||||||
|
|
||||||
|
connected = False
|
||||||
|
|
||||||
|
if ng_in.outputs[vl_name].is_linked:
|
||||||
|
# check if connect to the other side
|
||||||
|
socket = fn.connect_to_group_output(ng_in.outputs[vl_name].links[0].to_node) #if ng_in.outputs[vl_name].links[0].to_node.type == 'ALPHAOVER':
|
||||||
|
if socket:
|
||||||
|
connected = True
|
||||||
|
groupout = ng.outputs.get(socket.name)
|
||||||
|
|
||||||
|
ng.update()
|
||||||
|
|
||||||
|
if not connected:
|
||||||
|
print('need to connect')
|
||||||
|
# add AA and connect
|
||||||
|
aa = fn.new_aa_node(ngroup)
|
||||||
|
groupout = ng.outputs.get(vl_name)
|
||||||
|
if not groupout:
|
||||||
|
print('create group out-socket')
|
||||||
|
ng.outputs.new('NodeSocketColor', vl_name) # assigning direcly doesn't link well
|
||||||
|
groupout = ng.outputs[-1]
|
||||||
|
|
||||||
|
print('ng_out.inputs.get(vl_name): ', ng_out.inputs.get(vl_name))
|
||||||
|
# ng_in.outputs[vl_name]
|
||||||
|
ngroup.links.new(ng_in.outputs[vl_name], aa.inputs[0]) # node_tree
|
||||||
|
ngroup.links.new(aa.outputs[0], ng_out.inputs[vl_name]) # node_tree
|
||||||
|
|
||||||
|
# clean outputs
|
||||||
|
for o in reversed(ngroup.outputs):
|
||||||
|
if not o.name in [o.name for o in ngroup.inputs]:
|
||||||
|
print(f'removing group output {o.name} (name not exists in group inputs)')
|
||||||
|
ngroup.outputs.remove(o)
|
||||||
|
|
||||||
|
ng.update()
|
||||||
|
# reorder output to match inputs
|
||||||
|
fn.reorder_outputs(ng)
|
||||||
|
|
||||||
|
ng.update()
|
||||||
|
|
||||||
|
# Clear : delete orphan nodes that are not connected from ng_in
|
||||||
|
for n in reversed(ngroup.nodes):
|
||||||
|
if n.type in ('GROUP_INPUT', 'GROUP_OUTPUT'):
|
||||||
|
continue
|
||||||
|
if not fn.connect_to_group_input(n) and not fn.connect_to_group_output(n): # is disconnected from both side
|
||||||
|
ngroup.nodes.remove(n)
|
||||||
|
# TODO clear nodes that are disconnected from input side ?
|
||||||
|
|
||||||
|
if groupout.links and groupout.links[0].to_node.type == 'OUTPUT_FILE':
|
||||||
|
# if already connected to outfile just skip cause user might have customised the name
|
||||||
|
return
|
||||||
|
|
||||||
|
slot_name = f'{lname}/{lname}_'
|
||||||
|
out_name = f'OUT_{obname}' # or get output from frame
|
||||||
|
if not out:
|
||||||
|
out = nodes.get(out_name)
|
||||||
|
if not out:
|
||||||
|
# color = (0.2,0.3,0.5)
|
||||||
|
out = fn.create_node('CompositorNodeOutputFile', tree=scene.node_tree, location=(fn.real_loc(ng)[0]+600, fn.real_loc(ng)[1]+50), width=600) # =(ng.location[0]+600, ng.location[1]+50)
|
||||||
|
out.name = out_name
|
||||||
|
out.parent = frame
|
||||||
|
out.base_path = f'//render/{bpy.path.clean_name(obname)}'
|
||||||
|
|
||||||
|
out_input = out.inputs.get(slot_name)
|
||||||
|
if not out_input:
|
||||||
|
out.file_slots.new(slot_name)
|
||||||
|
out_input = out.inputs[-1] # assigning directly above doesn't link afterwards
|
||||||
|
print(f'new filouput entry: {out_input}')
|
||||||
|
|
||||||
|
# link to FileOut
|
||||||
|
links.new(groupout, out_input)
|
||||||
|
|
||||||
|
# clean fileout
|
||||||
|
fn.clear_disconnected(out)
|
||||||
|
fn.reorder_fileout(out, ng=ng)
|
||||||
|
|
||||||
|
out.update()
|
||||||
|
return ng, out
|
||||||
|
|
||||||
|
|
||||||
|
def get_set_viewlayer_from_gp(ob, l, scene=None):
|
||||||
|
'''setup ouptut from passed gp obj > layer'''
|
||||||
|
if not scene:
|
||||||
|
# scene = bpy.context.scene
|
||||||
|
scene = fn.get_render_scene() # create if necessary
|
||||||
|
|
||||||
|
node_tree = scene.node_tree
|
||||||
|
nodes = node_tree.nodes
|
||||||
|
|
||||||
|
in_rds = scene.collection.all_objects.get(ob.name)
|
||||||
|
if not in_rds:
|
||||||
|
scene.collection.objects.link(ob)
|
||||||
|
|
||||||
|
# create viewlayer
|
||||||
|
vl_name = f'{ob.name} / {l.info}'
|
||||||
|
vl = fn.get_view_layer(vl_name, scene=scene)
|
||||||
|
vl_name = vl.name
|
||||||
|
# affect layer to this vl
|
||||||
|
l.viewlayer_render = vl_name
|
||||||
|
|
||||||
|
# check if already exists
|
||||||
|
rlayer_list = [n for n in nodes if n.type == 'R_LAYERS' and n.layer == vl_name]
|
||||||
|
|
||||||
|
# get frame object and their contents
|
||||||
|
# dict like : {objname : [layer_nodeA, layer_nodeB,...]}
|
||||||
|
frame_dic = {f.label: [n for n in nodes if n.type == 'R_LAYERS' and n.parent and n.parent.name == f.name and n.layer != 'View Layer']
|
||||||
|
for f in nodes if f.type == 'FRAME'}
|
||||||
|
|
||||||
|
# debug print
|
||||||
|
for k,v in frame_dic.items():
|
||||||
|
print('-', k)
|
||||||
|
for n in v:
|
||||||
|
print('---', n.layer)
|
||||||
|
|
||||||
|
if rlayer_list: # rlayer exists
|
||||||
|
print(f'{len(rlayer_list)} nodes using {vl_name}')
|
||||||
|
|
||||||
|
# affect only the one within an object frame
|
||||||
|
framed_rl = [n for n in rlayer_list if n.parent and n.parent.label == ob.name]
|
||||||
|
if framed_rl:
|
||||||
|
if len(framed_rl) > 1:
|
||||||
|
print(f'! More than one nodes using {vl_name} in a frame ({len(framed_rl)}) !')
|
||||||
|
|
||||||
|
# sort top to bottom and take upper node
|
||||||
|
framed_rl.sort(key=lambda x:x.location.y, reverse=True)
|
||||||
|
cp = framed_rl[0]
|
||||||
|
cp.select = True # select so the user see that it existed
|
||||||
|
return vl, cp
|
||||||
|
|
||||||
|
# Returned if existed and OK
|
||||||
|
|
||||||
|
if not ob.name in frame_dic.keys(): # and len(frame_dic[ob.name])
|
||||||
|
print(f'\n{ob.name} -> {l.info} (first generation)')
|
||||||
|
# frame not exists, add the RL and frame at the very bottom of all render_layers
|
||||||
|
# check position of frame type ? all type ?
|
||||||
|
all_frames = [n for n in nodes if n.type == 'FRAME']
|
||||||
|
# all_rl_x = [n.location.x for n in nodes if n.type == 'R_LAYERS' and n.layer != 'View Layer']
|
||||||
|
if all_frames:
|
||||||
|
print
|
||||||
|
# all_frames.sort(key=lambda x: x.location.y, reverse=True)
|
||||||
|
# loc.y - dim.y
|
||||||
|
y_loc = min(fn.get_frame_transform(f, node_tree)[0].y - fn.get_frame_transform(f, node_tree)[1].y for f in all_frames)
|
||||||
|
print('y_loc: ', y_loc)
|
||||||
|
loc = (0, y_loc)
|
||||||
|
else:
|
||||||
|
loc = (0,0)
|
||||||
|
|
||||||
|
print('loc: ', loc)
|
||||||
|
# create frame at new rl position
|
||||||
|
frame = nodes.new('NodeFrame')
|
||||||
|
frame.label = ob.name
|
||||||
|
frame.label_size = 50
|
||||||
|
frame.location = (loc[0], loc[1] + 20)
|
||||||
|
|
||||||
|
cp = add_rlayer(vl_name, scene=scene, location=loc)
|
||||||
|
cp.parent = frame
|
||||||
|
|
||||||
|
connect_render_layer(cp, frame=frame)
|
||||||
|
|
||||||
|
fn.rearrange_frames(node_tree)
|
||||||
|
|
||||||
|
return vl, cp
|
||||||
|
|
||||||
|
## If ob already was used
|
||||||
|
|
||||||
|
print(f'\n {ob.name} -> {l.info} (connect to existing)')
|
||||||
|
|
||||||
|
## object frame exists: get framing and insert
|
||||||
|
cp = add_rlayer(vl_name, scene=scene, location=(0,0))
|
||||||
|
if cp.layer != vl_name:
|
||||||
|
print(f'problem with {cp}: {cp.layer} != {vl_name}')
|
||||||
|
return
|
||||||
|
|
||||||
|
frame = [f for f in nodes if f.type == 'FRAME' and f.label == ob.name][0]
|
||||||
|
rl_nodes = frame_dic[frame.label] # get nodes from
|
||||||
|
if rl_nodes:
|
||||||
|
# get nodes order to insert
|
||||||
|
rl_nodes.sort(key=lambda n: fn.real_loc(n).y, reverse=True) # descending
|
||||||
|
top_loc = fn.real_loc(rl_nodes[0])
|
||||||
|
print('top_loc: ', top_loc)
|
||||||
|
else:
|
||||||
|
top_loc = fn.get_frame_transform(frame[1], node_tree) - 60
|
||||||
|
|
||||||
|
# cp.location = (top_loc[0], top_loc[1] + 100) # temp location to adjust x loc
|
||||||
|
|
||||||
|
# list of layer names in nodes order
|
||||||
|
rl_names = [n.layer.split(' / ')[1] for n in rl_nodes] # get True layer name from rl
|
||||||
|
# names with the right order WITH the new layer included
|
||||||
|
names = [lay.info for lay in ob.data.layers if lay.info in rl_names or lay == l]
|
||||||
|
|
||||||
|
rl_nodes.append(cp)
|
||||||
|
|
||||||
|
# filter by getting index(layer_name)
|
||||||
|
cp.parent = frame
|
||||||
|
rl_nodes.sort(key=lambda x : names.index(x.layer.split(' / ')[1])) # Sort True layer name from rl
|
||||||
|
|
||||||
|
offset = 0
|
||||||
|
print(f'number of nodes in frame: {len(rl_nodes)}')
|
||||||
|
ref_node = rl_nodes[0]
|
||||||
|
|
||||||
|
print('ref_node: ', ref_node.name, ref_node.location)
|
||||||
|
for n in rl_nodes:
|
||||||
|
# set x loc from first node in list (maybe use leftmost ?)
|
||||||
|
n.location = Vector((fn.real_loc(ref_node)[0], top_loc[1] - offset)) - n.parent.location
|
||||||
|
offset += 180
|
||||||
|
|
||||||
|
n.update()
|
||||||
|
# reorder render layers nodes within frame
|
||||||
|
|
||||||
|
connect_render_layer(cp, frame=frame)
|
||||||
|
|
||||||
|
# re-arrange all frames (since the offset probably overlapped)
|
||||||
|
fn.rearrange_frames(node_tree)
|
||||||
|
|
||||||
|
return vl, cp
|
|
@ -18,18 +18,21 @@ from collections import defaultdict
|
||||||
C = bpy.context
|
C = bpy.context
|
||||||
D = bpy.data
|
D = bpy.data
|
||||||
|
|
||||||
def real_location(n):
|
def real_loc(n):
|
||||||
if not n.parent:
|
if not n.parent:
|
||||||
return n.location
|
return n.location
|
||||||
return n.location + real_location(n.parent)
|
return n.location + real_loc(n.parent)
|
||||||
|
|
||||||
def get_frame_transform(f, node_tree):
|
def get_frame_transform(f, node_tree):
|
||||||
'''only works with one level of nesting (not recursive)'''
|
'''Return real transform location of a frame node
|
||||||
|
only works with one level of nesting (not recursive)
|
||||||
|
'''
|
||||||
|
|
||||||
if f.type != 'FRAME':
|
if f.type != 'FRAME':
|
||||||
return
|
return
|
||||||
# return real_location(f), f.dimensions
|
# return real_loc(f), f.dimensions
|
||||||
|
|
||||||
childs = [n for n in n.node_tree.nodes if n.parent == f]
|
childs = [n for n in node_tree.nodes if n.parent == f]
|
||||||
# real_locs = [f.location + n.location for n in childs]
|
# real_locs = [f.location + n.location for n in childs]
|
||||||
|
|
||||||
xs = [n.location.x for n in childs] + [n.location.x + n.dimensions.x for n in childs]
|
xs = [n.location.x for n in childs] + [n.location.x + n.dimensions.x for n in childs]
|
||||||
|
@ -57,7 +60,7 @@ def bbox(f, frames):
|
||||||
ys += all_ys
|
ys += all_ys
|
||||||
|
|
||||||
else:
|
else:
|
||||||
loc = real_location(n)
|
loc = real_loc(n)
|
||||||
xs += [loc.x, loc.x + n.dimensions.x] # + (n.dimensions.x/get_dpi_factor())
|
xs += [loc.x, loc.x + n.dimensions.x] # + (n.dimensions.x/get_dpi_factor())
|
||||||
ys += [loc.y, loc.y - n.dimensions.y] # - (n.dimensions.y/get_dpi_factor())
|
ys += [loc.y, loc.y - n.dimensions.y] # - (n.dimensions.y/get_dpi_factor())
|
||||||
|
|
||||||
|
@ -275,7 +278,7 @@ def connect_to_group_input(n):
|
||||||
if i.is_linked:
|
if i.is_linked:
|
||||||
if i.links[0].from_node.type == 'GROUP_INPUT':
|
if i.links[0].from_node.type == 'GROUP_INPUT':
|
||||||
return i.links[0].from_socket
|
return i.links[0].from_socket
|
||||||
val = connect_to_group_output(i.links[0].from_node)
|
val = connect_to_group_input(i.links[0].from_node)
|
||||||
if val:
|
if val:
|
||||||
return val
|
return val
|
||||||
return False
|
return False
|
||||||
|
@ -437,6 +440,7 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
||||||
if not scene:
|
if not scene:
|
||||||
# scene = bpy.context.scene
|
# scene = bpy.context.scene
|
||||||
scene = get_render_scene() # create if necessary
|
scene = get_render_scene() # create if necessary
|
||||||
|
node_tree = scene.node_tree
|
||||||
nodes = scene.node_tree.nodes
|
nodes = scene.node_tree.nodes
|
||||||
|
|
||||||
in_rds = scene.collection.all_objects.get(ob.name)
|
in_rds = scene.collection.all_objects.get(ob.name)
|
||||||
|
@ -490,7 +494,7 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
||||||
if all_frames:
|
if all_frames:
|
||||||
# all_frames.sort(key=lambda x: x.location.y, reverse=True)
|
# all_frames.sort(key=lambda x: x.location.y, reverse=True)
|
||||||
# loc.y - dim.y
|
# loc.y - dim.y
|
||||||
y_loc = min(get_frame_transform(f, node_tree)[0].y - get_frame_transform(f, node_tree)[1].y for f in all_frames)
|
y_loc = min(get_frame_transform(f)[0].y - get_frame_transform(f)[1].y for f in all_frames)
|
||||||
loc = (0, y_loc)
|
loc = (0, y_loc)
|
||||||
else:
|
else:
|
||||||
loc = (0,0)
|
loc = (0,0)
|
||||||
|
@ -564,10 +568,10 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
||||||
rl_nodes = frame_dic[frame.label]
|
rl_nodes = frame_dic[frame.label]
|
||||||
if rl_nodes:
|
if rl_nodes:
|
||||||
# get nodes order to insert
|
# get nodes order to insert
|
||||||
rl_nodes.sort(key=lambda n: real_location(n).y, reverse=True)
|
rl_nodes.sort(key=lambda n: real_loc(n).y, reverse=True)
|
||||||
top_loc = real_location(rl_nodes[0])
|
top_loc = real_loc(rl_nodes[0])
|
||||||
else:
|
else:
|
||||||
top_loc = get_frame_transform(frame[1], node_tree) -60
|
top_loc = get_frame_transform(frame[1]) -60
|
||||||
|
|
||||||
# cp.location = (top_loc[0], top_loc[1] + 100) # temp location to adjust x loc
|
# cp.location = (top_loc[0], top_loc[1] + 100) # temp location to adjust x loc
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
import bpy
|
||||||
|
from bpy.types import Panel
|
||||||
|
# from .preferences import get_addon_prefs
|
||||||
|
|
||||||
|
|
||||||
|
# 3D view panel
|
||||||
|
class GPEXP_PT_gp_node_ui(Panel):
|
||||||
|
bl_space_type = "NODE_EDITOR" # "VIEW_3D"
|
||||||
|
bl_region_type = "UI"
|
||||||
|
bl_category = "Item"
|
||||||
|
bl_label = "Gpencil Render Manager"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
|
||||||
|
layout.operator('gp.clear_render_tree', icon='X', text='Full Clear Render Tree')
|
||||||
|
# layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='Layer To Render').mode = 'ALL'
|
||||||
|
# layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='Layer To Render').mode = 'SELECTED'
|
||||||
|
|
||||||
|
# layout.operator('gp.merge_layers', icon='X', text='Merge selected nodes')
|
||||||
|
|
||||||
|
|
||||||
|
def manager_ui(self, context):
|
||||||
|
'''appended to DATA_PT_gpencil_layers'''
|
||||||
|
|
||||||
|
layout = self.layout
|
||||||
|
# on layers
|
||||||
|
if context.object and context.object.type == 'GPENCIL':
|
||||||
|
txt = f'{len([l for l in context.object.data.layers if l.select])} Layer(s) To Render'
|
||||||
|
else:
|
||||||
|
txt = 'Layer To Render'
|
||||||
|
layout.operator('gp.add_layer_to_render', icon='RENDERLAYERS', text=txt)
|
||||||
|
|
||||||
|
# on objects
|
||||||
|
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='Selected Object To Render').mode='SELECTED'
|
||||||
|
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='All GP at once').mode='ALL'
|
||||||
|
|
||||||
|
# ## function to append in a menu
|
||||||
|
# def palette_manager_menu(self, context):
|
||||||
|
# """Palette menu to append in existing menu"""
|
||||||
|
# # GPENCIL_MT_material_context_menu
|
||||||
|
# layout = self.layout
|
||||||
|
# # {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
|
||||||
|
# layout.separator()
|
||||||
|
# prefs = get_addon_prefs()
|
||||||
|
|
||||||
|
# layout.operator("", text='do stuff from material submenu', icon='MATERIAL')
|
||||||
|
|
||||||
|
#-# REGISTER
|
||||||
|
|
||||||
|
classes=(
|
||||||
|
GPEXP_PT_gp_node_ui,
|
||||||
|
)
|
||||||
|
|
||||||
|
def register():
|
||||||
|
for cls in classes:
|
||||||
|
bpy.utils.register_class(cls)
|
||||||
|
bpy.types.DATA_PT_gpencil_layers.prepend(manager_ui)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
bpy.types.DATA_PT_gpencil_layers.remove(manager_ui)
|
||||||
|
for cls in reversed(classes):
|
||||||
|
bpy.utils.unregister_class(cls)
|
Loading…
Reference in New Issue