diff options
Diffstat (limited to 'Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins')
78 files changed, 5030 insertions, 0 deletions
diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise.meta new file mode 100644 index 00000000..5ab9f3d6 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b8ae2a1a1e3f06043946795bf88db726 +folderAsset: yes +timeCreated: 1502695119 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.LESSER.txt b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.LESSER.txt new file mode 100644 index 00000000..65c5ca88 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.LESSER.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser 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 +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.LESSER.txt.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.LESSER.txt.meta new file mode 100644 index 00000000..46a47724 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.LESSER.txt.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 95ee612b2757f48569ed91e17b141883 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.txt b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.txt new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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 +<http://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 +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.txt.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.txt.meta new file mode 100644 index 00000000..2b35e52a --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/COPYING.txt.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 8390780810d5f4732a6a41190622d691 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator.meta new file mode 100644 index 00000000..b37c722d --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 01d2ad28d1dda48d091ca1d68c49dfb4 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Billow.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Billow.cs new file mode 100644 index 00000000..5c1f4a0a --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Billow.cs @@ -0,0 +1,148 @@ +using System; +using UnityEngine; + +namespace LibNoise.Generator +{ + /// <summary> + /// Provides a noise module that outputs a three-dimensional billowy noise. [GENERATOR] + /// </summary> + public class Billow : ModuleBase + { + #region Fields + + private double _frequency = 1.0; + private double _lacunarity = 2.0; + private QualityMode _quality = QualityMode.Medium; + private int _octaveCount = 6; + private double _persistence = 0.5; + private int _seed; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Billow. + /// </summary> + public Billow() + : base(0) + { + } + + /// <summary> + /// Initializes a new instance of Billow. + /// </summary> + /// <param name="frequency">The frequency of the first octave.</param> + /// <param name="lacunarity">The lacunarity of the billowy noise.</param> + /// <param name="persistence">The persistence of the billowy noise.</param> + /// <param name="octaves">The number of octaves of the billowy noise.</param> + /// <param name="seed">The seed of the billowy noise.</param> + /// <param name="quality">The quality of the billowy noise.</param> + public Billow(double frequency, double lacunarity, double persistence, int octaves, int seed, + QualityMode quality) + : base(0) + { + Frequency = frequency; + Lacunarity = lacunarity; + OctaveCount = octaves; + Persistence = persistence; + Seed = seed; + Quality = quality; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the frequency of the first octave. + /// </summary> + public double Frequency + { + get { return _frequency; } + set { _frequency = value; } + } + + /// <summary> + /// Gets or sets the lacunarity of the billowy noise. + /// </summary> + public double Lacunarity + { + get { return _lacunarity; } + set { _lacunarity = value; } + } + + /// <summary> + /// Gets or sets the quality of the billowy noise. + /// </summary> + public QualityMode Quality + { + get { return _quality; } + set { _quality = value; } + } + + /// <summary> + /// Gets or sets the number of octaves of the billowy noise. + /// </summary> + public int OctaveCount + { + get { return _octaveCount; } + set { _octaveCount = Mathf.Clamp(value, 1, Utils.OctavesMaximum); } + } + + /// <summary> + /// Gets or sets the persistence of the billowy noise. + /// </summary> + public double Persistence + { + get { return _persistence; } + set { _persistence = value; } + } + + /// <summary> + /// Gets or sets the seed of the billowy noise. + /// </summary> + public int Seed + { + get { return _seed; } + set { _seed = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + var value = 0.0; + var curp = 1.0; + x *= _frequency; + y *= _frequency; + z *= _frequency; + for (var i = 0; i < _octaveCount; i++) + { + var nx = Utils.MakeInt32Range(x); + var ny = Utils.MakeInt32Range(y); + var nz = Utils.MakeInt32Range(z); + var seed = (_seed + i) & 0xffffffff; + var signal = Utils.GradientCoherentNoise3D(nx, ny, nz, seed, _quality); + signal = 2.0 * Math.Abs(signal) - 1.0; + value += signal * curp; + x *= _lacunarity; + y *= _lacunarity; + z *= _lacunarity; + curp *= _persistence; + } + return value + 0.5; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Billow.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Billow.cs.meta new file mode 100644 index 00000000..77a61f00 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Billow.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: f9f0293dd46394b779bf22259c6dad97 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Checker.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Checker.cs new file mode 100644 index 00000000..a4bc557d --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Checker.cs @@ -0,0 +1,41 @@ +using System; + +namespace LibNoise.Generator +{ + /// <summary> + /// Provides a noise module that outputs a checkerboard pattern. [GENERATOR] + /// </summary> + public class Checker : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Checker. + /// </summary> + public Checker() + : base(0) + { + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + var ix = (int) (Math.Floor(Utils.MakeInt32Range(x))); + var iy = (int) (Math.Floor(Utils.MakeInt32Range(y))); + var iz = (int) (Math.Floor(Utils.MakeInt32Range(z))); + return (ix & 1 ^ iy & 1 ^ iz & 1) != 0 ? -1.0 : 1.0; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Checker.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Checker.cs.meta new file mode 100644 index 00000000..f865935a --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Checker.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: eb233ecbeadf94f018307ccdfb683ec9 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Const.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Const.cs new file mode 100644 index 00000000..5d4f2a79 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Const.cs @@ -0,0 +1,65 @@ +namespace LibNoise.Generator +{ + /// <summary> + /// Provides a noise module that outputs a constant value. [GENERATOR] + /// </summary> + public class Const : ModuleBase + { + #region Fields + + private double _value; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Const. + /// </summary> + public Const() + : base(0) + { + } + + /// <summary> + /// Initializes a new instance of Const. + /// </summary> + /// <param name="value">The constant value.</param> + public Const(double value) + : base(0) + { + Value = value; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the constant value. + /// </summary> + public double Value + { + get { return _value; } + set { _value = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + return _value; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Const.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Const.cs.meta new file mode 100644 index 00000000..f17ff45c --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Const.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: c6cec7c8a26b54cd3ab29b44d6360a9f diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Cylinders.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Cylinders.cs new file mode 100644 index 00000000..4195919e --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Cylinders.cs @@ -0,0 +1,73 @@ +using System; + +namespace LibNoise.Generator +{ + /// <summary> + /// Provides a noise module that outputs concentric cylinders. [GENERATOR] + /// </summary> + public class Cylinders : ModuleBase + { + #region Fields + + private double _frequency = 1.0; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Cylinders. + /// </summary> + public Cylinders() + : base(0) + { + } + + /// <summary> + /// Initializes a new instance of Cylinders. + /// </summary> + /// <param name="frequency">The frequency of the concentric cylinders.</param> + public Cylinders(double frequency) + : base(0) + { + Frequency = frequency; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the frequency of the concentric cylinders. + /// </summary> + public double Frequency + { + get { return _frequency; } + set { _frequency = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + x *= _frequency; + z *= _frequency; + var dfc = Math.Sqrt(x * x + z * z); + var dfss = dfc - Math.Floor(dfc); + var dfls = 1.0 - dfss; + var nd = Math.Min(dfss, dfls); + return 1.0 - (nd * 4.0); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Cylinders.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Cylinders.cs.meta new file mode 100644 index 00000000..e6efbde4 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Cylinders.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: b9fae44e80dd846dd9781b972e97c6e6 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Perlin.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Perlin.cs new file mode 100644 index 00000000..cca8e21e --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Perlin.cs @@ -0,0 +1,146 @@ +using UnityEngine; + +namespace LibNoise.Generator +{ + /// <summary> + /// Provides a noise module that outputs a three-dimensional perlin noise. [GENERATOR] + /// </summary> + public class Perlin : ModuleBase + { + #region Fields + + private double _frequency = 1.0; + private double _lacunarity = 2.0; + private QualityMode _quality = QualityMode.Medium; + private int _octaveCount = 6; + private double _persistence = 0.5; + private int _seed; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Perlin. + /// </summary> + public Perlin() + : base(0) + { + } + + /// <summary> + /// Initializes a new instance of Perlin. + /// </summary> + /// <param name="frequency">The frequency of the first octave.</param> + /// <param name="lacunarity">The lacunarity of the perlin noise.</param> + /// <param name="persistence">The persistence of the perlin noise.</param> + /// <param name="octaves">The number of octaves of the perlin noise.</param> + /// <param name="seed">The seed of the perlin noise.</param> + /// <param name="quality">The quality of the perlin noise.</param> + public Perlin(double frequency, double lacunarity, double persistence, int octaves, int seed, + QualityMode quality) + : base(0) + { + Frequency = frequency; + Lacunarity = lacunarity; + OctaveCount = octaves; + Persistence = persistence; + Seed = seed; + Quality = quality; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the frequency of the first octave. + /// </summary> + public double Frequency + { + get { return _frequency; } + set { _frequency = value; } + } + + /// <summary> + /// Gets or sets the lacunarity of the perlin noise. + /// </summary> + public double Lacunarity + { + get { return _lacunarity; } + set { _lacunarity = value; } + } + + /// <summary> + /// Gets or sets the quality of the perlin noise. + /// </summary> + public QualityMode Quality + { + get { return _quality; } + set { _quality = value; } + } + + /// <summary> + /// Gets or sets the number of octaves of the perlin noise. + /// </summary> + public int OctaveCount + { + get { return _octaveCount; } + set { _octaveCount = Mathf.Clamp(value, 1, Utils.OctavesMaximum); } + } + + /// <summary> + /// Gets or sets the persistence of the perlin noise. + /// </summary> + public double Persistence + { + get { return _persistence; } + set { _persistence = value; } + } + + /// <summary> + /// Gets or sets the seed of the perlin noise. + /// </summary> + public int Seed + { + get { return _seed; } + set { _seed = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + var value = 0.0; + var cp = 1.0; + x *= _frequency; + y *= _frequency; + z *= _frequency; + for (var i = 0; i < _octaveCount; i++) + { + var nx = Utils.MakeInt32Range(x); + var ny = Utils.MakeInt32Range(y); + var nz = Utils.MakeInt32Range(z); + var seed = (_seed + i) & 0xffffffff; + var signal = Utils.GradientCoherentNoise3D(nx, ny, nz, seed, _quality); + value += signal * cp; + x *= _lacunarity; + y *= _lacunarity; + z *= _lacunarity; + cp *= _persistence; + } + return value; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Perlin.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Perlin.cs.meta new file mode 100644 index 00000000..f9fef821 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Perlin.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: f4531ed2ca2bf4002a1b9515f754ea6a diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/RidgedMultifractal.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/RidgedMultifractal.cs new file mode 100644 index 00000000..b0afdbb6 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/RidgedMultifractal.cs @@ -0,0 +1,164 @@ +using System; +using UnityEngine; + +namespace LibNoise.Generator +{ + /// <summary> + /// Provides a noise module that outputs 3-dimensional ridged-multifractal noise. [GENERATOR] + /// </summary> + public class RidgedMultifractal : ModuleBase + { + #region Fields + + private double _frequency = 1.0; + private double _lacunarity = 2.0; + private QualityMode _quality = QualityMode.Medium; + private int _octaveCount = 6; + private int _seed; + private readonly double[] _weights = new double[Utils.OctavesMaximum]; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of RidgedMultifractal. + /// </summary> + public RidgedMultifractal() + : base(0) + { + UpdateWeights(); + } + + /// <summary> + /// Initializes a new instance of RidgedMultifractal. + /// </summary> + /// <param name="frequency">The frequency of the first octave.</param> + /// <param name="lacunarity">The lacunarity of the ridged-multifractal noise.</param> + /// <param name="octaves">The number of octaves of the ridged-multifractal noise.</param> + /// <param name="seed">The seed of the ridged-multifractal noise.</param> + /// <param name="quality">The quality of the ridged-multifractal noise.</param> + public RidgedMultifractal(double frequency, double lacunarity, int octaves, int seed, QualityMode quality) + : base(0) + { + Frequency = frequency; + Lacunarity = lacunarity; + OctaveCount = octaves; + Seed = seed; + Quality = quality; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the frequency of the first octave. + /// </summary> + public double Frequency + { + get { return _frequency; } + set { _frequency = value; } + } + + /// <summary> + /// Gets or sets the lacunarity of the ridged-multifractal noise. + /// </summary> + public double Lacunarity + { + get { return _lacunarity; } + set + { + _lacunarity = value; + UpdateWeights(); + } + } + + /// <summary> + /// Gets or sets the quality of the ridged-multifractal noise. + /// </summary> + public QualityMode Quality + { + get { return _quality; } + set { _quality = value; } + } + + /// <summary> + /// Gets or sets the number of octaves of the ridged-multifractal noise. + /// </summary> + public int OctaveCount + { + get { return _octaveCount; } + set { _octaveCount = Mathf.Clamp(value, 1, Utils.OctavesMaximum); } + } + + /// <summary> + /// Gets or sets the seed of the ridged-multifractal noise. + /// </summary> + public int Seed + { + get { return _seed; } + set { _seed = value; } + } + + #endregion + + #region Methods + + /// <summary> + /// Updates the weights of the ridged-multifractal noise. + /// </summary> + private void UpdateWeights() + { + var f = 1.0; + for (var i = 0; i < Utils.OctavesMaximum; i++) + { + _weights[i] = Math.Pow(f, -1.0); + f *= _lacunarity; + } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + x *= _frequency; + y *= _frequency; + z *= _frequency; + var value = 0.0; + var weight = 1.0; + var offset = 1.0; // TODO: Review why Offset is never assigned + var gain = 2.0; // TODO: Review why gain is never assigned + for (var i = 0; i < _octaveCount; i++) + { + var nx = Utils.MakeInt32Range(x); + var ny = Utils.MakeInt32Range(y); + var nz = Utils.MakeInt32Range(z); + long seed = (_seed + i) & 0x7fffffff; + var signal = Utils.GradientCoherentNoise3D(nx, ny, nz, seed, _quality); + signal = Math.Abs(signal); + signal = offset - signal; + signal *= signal; + signal *= weight; + weight = signal * gain; + weight = Mathf.Clamp01((float) weight); + value += (signal * _weights[i]); + x *= _lacunarity; + y *= _lacunarity; + z *= _lacunarity; + } + return (value * 1.25) - 1.0; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/RidgedMultifractal.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/RidgedMultifractal.cs.meta new file mode 100644 index 00000000..26b1b9aa --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/RidgedMultifractal.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 80802e8c5f463441795212412a4cf4ef diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Spheres.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Spheres.cs new file mode 100644 index 00000000..99d8d8ef --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Spheres.cs @@ -0,0 +1,74 @@ +using System; + +namespace LibNoise.Generator +{ + /// <summary> + /// Provides a noise module that outputs concentric spheres. [GENERATOR] + /// </summary> + public class Spheres : ModuleBase + { + #region Fields + + private double _frequency = 1.0; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Spheres. + /// </summary> + public Spheres() + : base(0) + { + } + + /// <summary> + /// Initializes a new instance of Spheres. + /// </summary> + /// <param name="frequency">The frequency of the concentric spheres.</param> + public Spheres(double frequency) + : base(0) + { + Frequency = frequency; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the frequency of the concentric spheres. + /// </summary> + public double Frequency + { + get { return _frequency; } + set { _frequency = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + x *= _frequency; + y *= _frequency; + z *= _frequency; + var dfc = Math.Sqrt(x * x + y * y + z * z); + var dfss = dfc - Math.Floor(dfc); + var dfls = 1.0 - dfss; + var nd = Math.Min(dfss, dfls); + return 1.0 - (nd * 4.0); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Spheres.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Spheres.cs.meta new file mode 100644 index 00000000..cf8eba9b --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Spheres.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 9cd65dace5b2b41c4bc8d1d344da6cfc diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Voronoi.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Voronoi.cs new file mode 100644 index 00000000..876e7aa8 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Voronoi.cs @@ -0,0 +1,150 @@ +using System; + +namespace LibNoise.Generator +{ + /// <summary> + /// Provides a noise module that outputs Voronoi cells. [GENERATOR] + /// </summary> + public class Voronoi : ModuleBase + { + #region Fields + + private double _displacement = 1.0; + private double _frequency = 1.0; + private int _seed; + private bool _distance; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Voronoi. + /// </summary> + public Voronoi() + : base(0) + { + } + + /// <summary> + /// Initializes a new instance of Voronoi. + /// </summary> + /// <param name="frequency">The frequency of the first octave.</param> + /// <param name="displacement">The displacement of the ridged-multifractal noise.</param> + /// <param name="seed">The seed of the ridged-multifractal noise.</param> + /// <param name="distance">Indicates whether the distance from the nearest seed point is applied to the output value.</param> + public Voronoi(double frequency, double displacement, int seed, bool distance) + : base(0) + { + Frequency = frequency; + Displacement = displacement; + Seed = seed; + UseDistance = distance; + Seed = seed; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the displacement value of the Voronoi cells. + /// </summary> + public double Displacement + { + get { return _displacement; } + set { _displacement = value; } + } + + /// <summary> + /// Gets or sets the frequency of the seed points. + /// </summary> + public double Frequency + { + get { return _frequency; } + set { _frequency = value; } + } + + /// <summary> + /// Gets or sets the seed value used by the Voronoi cells. + /// </summary> + public int Seed + { + get { return _seed; } + set { _seed = value; } + } + + /// <summary> + /// Gets or sets a value whether the distance from the nearest seed point is applied to the output value. + /// </summary> + public bool UseDistance + { + get { return _distance; } + set { _distance = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + x *= _frequency; + y *= _frequency; + z *= _frequency; + var xi = (x > 0.0 ? (int) x : (int) x - 1); + var iy = (y > 0.0 ? (int) y : (int) y - 1); + var iz = (z > 0.0 ? (int) z : (int) z - 1); + var md = 2147483647.0; + double xc = 0; + double yc = 0; + double zc = 0; + for (var zcu = iz - 2; zcu <= iz + 2; zcu++) + { + for (var ycu = iy - 2; ycu <= iy + 2; ycu++) + { + for (var xcu = xi - 2; xcu <= xi + 2; xcu++) + { + var xp = xcu + Utils.ValueNoise3D(xcu, ycu, zcu, _seed); + var yp = ycu + Utils.ValueNoise3D(xcu, ycu, zcu, _seed + 1); + var zp = zcu + Utils.ValueNoise3D(xcu, ycu, zcu, _seed + 2); + var xd = xp - x; + var yd = yp - y; + var zd = zp - z; + var d = xd * xd + yd * yd + zd * zd; + if (d < md) + { + md = d; + xc = xp; + yc = yp; + zc = zp; + } + } + } + } + double v; + if (_distance) + { + var xd = xc - x; + var yd = yc - y; + var zd = zc - z; + v = (Math.Sqrt(xd * xd + yd * yd + zd * zd)) * Utils.Sqrt3 - 1.0; + } + else + { + v = 0.0; + } + return v + (_displacement * Utils.ValueNoise3D((int) (Math.Floor(xc)), (int) (Math.Floor(yc)), + (int) (Math.Floor(zc)), 0)); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Voronoi.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Voronoi.cs.meta new file mode 100644 index 00000000..559371fb --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Generator/Voronoi.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 0d715628644034e579a398e471e978bf diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/GradientPresets.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/GradientPresets.cs new file mode 100644 index 00000000..91920a6c --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/GradientPresets.cs @@ -0,0 +1,132 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace LibNoise +{ + /// <summary> + /// Provides a series of gradient presets + /// </summary> + public static class GradientPresets + { + #region Fields + + private static readonly Gradient _empty; + private static readonly Gradient _grayscale; + private static readonly Gradient _rgb; + private static readonly Gradient _rgba; + private static readonly Gradient _terrain; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Gradient. + /// </summary> + static GradientPresets() + { + // Grayscale gradient color keys + var grayscaleColorKeys = new List<GradientColorKey> + { + new GradientColorKey(Color.black, 0), + new GradientColorKey(Color.white, 1) + }; + + // RGB gradient color keys + var rgbColorKeys = new List<GradientColorKey> + { + new GradientColorKey(Color.red, 0), + new GradientColorKey(Color.green, 0.5f), + new GradientColorKey(Color.blue, 1) + }; + + // RGBA gradient color keys + var rgbaColorKeys = new List<GradientColorKey> + { + new GradientColorKey(Color.red, 0), + new GradientColorKey(Color.green, 1 / 3f), + new GradientColorKey(Color.blue, 2 / 3f), + new GradientColorKey(Color.black, 1) + }; + + // RGBA gradient alpha keys + var rgbaAlphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(0, 2 / 3f), new GradientAlphaKey(1, 1)}; + + // Terrain gradient color keys + var terrainColorKeys = new List<GradientColorKey> + { + new GradientColorKey(new Color(0, 0, 0.5f), 0), + new GradientColorKey(new Color(0.125f, 0.25f, 0.5f), 0.4f), + new GradientColorKey(new Color(0.25f, 0.375f, 0.75f), 0.48f), + new GradientColorKey(new Color(0, 0.75f, 0), 0.5f), + new GradientColorKey(new Color(0.75f, 0.75f, 0), 0.625f), + new GradientColorKey(new Color(0.625f, 0.375f, 0.25f), 0.75f), + new GradientColorKey(new Color(0.5f, 1, 1), 0.875f), + new GradientColorKey(Color.white, 1) + }; + + // Generic gradient alpha keys + var alphaKeys = new List<GradientAlphaKey> {new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1)}; + + _empty = new Gradient(); + + _rgb = new Gradient(); + _rgb.SetKeys(rgbColorKeys.ToArray(), alphaKeys.ToArray()); + + _rgba = new Gradient(); + _rgba.SetKeys(rgbaColorKeys.ToArray(), rgbaAlphaKeys.ToArray()); + + _grayscale = new Gradient(); + _grayscale.SetKeys(grayscaleColorKeys.ToArray(), alphaKeys.ToArray()); + + _terrain = new Gradient(); + _terrain.SetKeys(terrainColorKeys.ToArray(), alphaKeys.ToArray()); + } + + #endregion + + #region Properties + + /// <summary> + /// Gets the empty instance of Gradient. + /// </summary> + public static Gradient Empty + { + get { return _empty; } + } + + /// <summary> + /// Gets the grayscale instance of Gradient. + /// </summary> + public static Gradient Grayscale + { + get { return _grayscale; } + } + + /// <summary> + /// Gets the RGB instance of Gradient. + /// </summary> + public static Gradient RGB + { + get { return _rgb; } + } + + /// <summary> + /// Gets the RGBA instance of Gradient. + /// </summary> + public static Gradient RGBA + { + get { return _rgba; } + } + + /// <summary> + /// Gets the terrain instance of Gradient. + /// </summary> + public static Gradient Terrain + { + get { return _terrain; } + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/GradientPresets.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/GradientPresets.cs.meta new file mode 100644 index 00000000..b0ba020d --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/GradientPresets.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 7274fe25a8f9642c9b3e34a7e54ecd6f diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/ModuleBase.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/ModuleBase.cs new file mode 100644 index 00000000..c6cef0f1 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/ModuleBase.cs @@ -0,0 +1,187 @@ +using System; +using System.Xml.Serialization; +using UnityEngine; +using Debug = System.Diagnostics.Debug; + +namespace LibNoise +{ + + #region Enumerations + + /// <summary> + /// Defines a collection of quality modes. + /// </summary> + public enum QualityMode + { + Low, + Medium, + High, + } + + #endregion + + /// <summary> + /// Base class for noise modules. + /// </summary> + public abstract class ModuleBase : IDisposable + { + #region Fields + + private ModuleBase[] _modules; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Helpers. + /// </summary> + /// <param name="count">The number of source modules.</param> + protected ModuleBase(int count) + { + if (count > 0) + { + _modules = new ModuleBase[count]; + } + } + + #endregion + + #region Indexers + + /// <summary> + /// Gets or sets a source module by index. + /// </summary> + /// <param name="index">The index of the source module to aquire.</param> + /// <returns>The requested source module.</returns> + public virtual ModuleBase this[int index] + { + get + { + Debug.Assert(_modules != null); + Debug.Assert(_modules.Length > 0); + if (index < 0 || index >= _modules.Length) + { + throw new ArgumentOutOfRangeException("Index out of valid module range"); + } + if (_modules[index] == null) + { + throw new ArgumentNullException("Desired element is null"); + } + return _modules[index]; + } + set + { + Debug.Assert(_modules.Length > 0); + if (index < 0 || index >= _modules.Length) + { + throw new ArgumentOutOfRangeException("Index out of valid module range"); + } + if (value == null) + { + throw new ArgumentNullException("Value should not be null"); + } + _modules[index] = value; + } + } + + #endregion + + #region Properties + protected ModuleBase[] Modules + { + get { return _modules; } + } + + /// <summary> + /// Gets the number of source modules required by this noise module. + /// </summary> + public int SourceModuleCount + { + get { return (_modules == null) ? 0 : _modules.Length; } + } + + #endregion + + #region Methods + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public abstract double GetValue(double x, double y, double z); + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="coordinate">The input coordinate.</param> + /// <returns>The resulting output value.</returns> + public double GetValue(Vector3 coordinate) + { + return GetValue(coordinate.x, coordinate.y, coordinate.z); + } + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="coordinate">The input coordinate.</param> + /// <returns>The resulting output value.</returns> + public double GetValue(ref Vector3 coordinate) + { + return GetValue(coordinate.x, coordinate.y, coordinate.z); + } + + #endregion + + #region IDisposable Members + + [XmlIgnore] +#if !XBOX360 && !ZUNE + [NonSerialized] +#endif + private bool _disposed; + + /// <summary> + /// Gets a value whether the object is disposed. + /// </summary> + public bool IsDisposed + { + get { return _disposed; } + } + + /// <summary> + /// Immediately releases the unmanaged resources used by this object. + /// </summary> + public void Dispose() + { + if (!_disposed) + { + _disposed = Disposing(); + } + GC.SuppressFinalize(this); + } + + /// <summary> + /// Immediately releases the unmanaged resources used by this object. + /// </summary> + /// <returns>True if the object is completely disposed.</returns> + protected virtual bool Disposing() + { + if (_modules != null) + { + for (var i = 0; i < _modules.Length; i++) + { + _modules[i].Dispose(); + _modules[i] = null; + } + _modules = null; + } + return true; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/ModuleBase.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/ModuleBase.cs.meta new file mode 100644 index 00000000..db4a6d78 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/ModuleBase.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: e90c63f5533e4400583745edd03b9a44 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Noise2D.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Noise2D.cs new file mode 100644 index 00000000..fdc2c6d1 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Noise2D.cs @@ -0,0 +1,575 @@ +using System; +using System.Xml.Serialization; +using UnityEngine; + +namespace LibNoise +{ + /// <summary> + /// Provides a two-dimensional noise map. + /// </summary> + /// <remarks>This covers most of the functionality from LibNoise's noiseutils library, but + /// the method calls might not be the same. See the tutorials project if you're wondering + /// which calls are equivalent.</remarks> + public class Noise2D : IDisposable + { + #region Constants + + public static readonly double South = -90.0; + public static readonly double North = 90.0; + public static readonly double West = -180.0; + public static readonly double East = 180.0; + public static readonly double AngleMin = -180.0; + public static readonly double AngleMax = 180.0; + public static readonly double Left = -1.0; + public static readonly double Right = 1.0; + public static readonly double Top = -1.0; + public static readonly double Bottom = 1.0; + + #endregion + + #region Fields + + private int _width; + private int _height; + private float[,] _data; + private readonly int _ucWidth; + private readonly int _ucHeight; + private int _ucBorder = 1; // Border size of extra noise for uncropped data. + + private readonly float[,] _ucData; + // Uncropped data. This has a border of extra noise data used for calculating normal map edges. + + private float _borderValue = float.NaN; + private ModuleBase _generator; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Noise2D. + /// </summary> + protected Noise2D() + { + } + + /// <summary> + /// Initializes a new instance of Noise2D. + /// </summary> + /// <param name="size">The width and height of the noise map.</param> + public Noise2D(int size) + : this(size, size, null) + { + } + + /// <summary> + /// Initializes a new instance of Noise2D. + /// </summary> + /// <param name="size">The width and height of the noise map.</param> + /// <param name="generator">The generator module.</param> + public Noise2D(int size, ModuleBase generator) + : this(size, size, generator) + { + } + + /// <summary> + /// Initializes a new instance of Noise2D. + /// </summary> + /// <param name="width">The width of the noise map.</param> + /// <param name="height">The height of the noise map.</param> + /// <param name="generator">The generator module.</param> + public Noise2D(int width, int height, ModuleBase generator = null) + { + _generator = generator; + _width = width; + _height = height; + _data = new float[width, height]; + _ucWidth = width + _ucBorder * 2; + _ucHeight = height + _ucBorder * 2; + _ucData = new float[width + _ucBorder * 2, height + _ucBorder * 2]; + } + + #endregion + + #region Indexers + + /// <summary> + /// Gets or sets a value in the noise map by its position. + /// </summary> + /// <param name="x">The position on the x-axis.</param> + /// <param name="y">The position on the y-axis.</param> + /// <param name="isCropped">Indicates whether to select the cropped (default) or uncropped noise map data.</param> + /// <returns>The corresponding value.</returns> + public float this[int x, int y, bool isCropped = true] + { + get + { + if (isCropped) + { + if (x < 0 && x >= _width) + { + throw new ArgumentOutOfRangeException("Invalid x position"); + } + if (y < 0 && y >= _height) + { + throw new ArgumentOutOfRangeException("Invalid y position"); + } + return _data[x, y]; + } + if (x < 0 && x >= _ucWidth) + { + throw new ArgumentOutOfRangeException("Invalid x position"); + } + if (y < 0 && y >= _ucHeight) + { + throw new ArgumentOutOfRangeException("Invalid y position"); + } + return _ucData[x, y]; + } + set + { + if (isCropped) + { + if (x < 0 && x >= _width) + { + throw new ArgumentOutOfRangeException("Invalid x position"); + } + if (y < 0 && y >= _height) + { + throw new ArgumentOutOfRangeException("Invalid y position"); + } + _data[x, y] = value; + } + else + { + if (x < 0 && x >= _ucWidth) + { + throw new ArgumentOutOfRangeException("Invalid x position"); + } + if (y < 0 && y >= _ucHeight) + { + throw new ArgumentOutOfRangeException("Invalid y position"); + } + _ucData[x, y] = value; + } + } + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the constant value at the noise maps borders. + /// </summary> + public float Border + { + get { return _borderValue; } + set { _borderValue = value; } + } + + /// <summary> + /// Gets or sets the generator module. + /// </summary> + public ModuleBase Generator + { + get { return _generator; } + set { _generator = value; } + } + + /// <summary> + /// Gets the height of the noise map. + /// </summary> + public int Height + { + get { return _height; } + } + + /// <summary> + /// Gets the width of the noise map. + /// </summary> + public int Width + { + get { return _width; } + } + + #endregion + + #region Methods + + /// <summary> + /// Gets normalized noise map data with all values in the set of {0..1}. + /// </summary> + /// <param name="isCropped">Indicates whether to select the cropped (default) or uncropped noise map data.</param> + /// <param name="xCrop">This value crops off data from the right of the noise map data.</param> + /// <param name="yCrop">This value crops off data from the bottom of the noise map data.</param> + /// <returns>The normalized noise map data.</returns> + public float[,] GetNormalizedData(bool isCropped = true, int xCrop = 0, int yCrop = 0) + { + return GetData(isCropped, xCrop, yCrop, true); + } + + /// <summary> + /// Gets noise map data. + /// </summary> + /// <param name="isCropped">Indicates whether to select the cropped (default) or uncropped noise map data.</param> + /// <param name="xCrop">This value crops off data from the right of the noise map data.</param> + /// <param name="yCrop">This value crops off data from the bottom of the noise map data.</param> + /// <param name="isNormalized">Indicates whether to normalize noise map data.</param> + /// <returns>The noise map data.</returns> + public float[,] GetData(bool isCropped = true, int xCrop = 0, int yCrop = 0, bool isNormalized = false) + { + int width, height; + float[,] data; + if (isCropped) + { + width = _width; + height = _height; + data = _data; + } + else + { + width = _ucWidth; + height = _ucHeight; + data = _ucData; + } + width -= xCrop; + height -= yCrop; + var result = new float[width, height]; + for (var x = 0; x < width; x++) + { + for (var y = 0; y < height; y++) + { + float sample; + if (isNormalized) + { + sample = (data[x, y] + 1) / 2; + } + else + { + sample = data[x, y]; + } + result[x, y] = sample; + } + } + return result; + } + + /// <summary> + /// Clears the noise map. + /// </summary> + /// <param name="value">The constant value to clear the noise map with.</param> + public void Clear(float value = 0f) + { + for (var x = 0; x < _width; x++) + { + for (var y = 0; y < _height; y++) + { + _data[x, y] = value; + } + } + } + + /// <summary> + /// Generates a planar projection of a point in the noise map. + /// </summary> + /// <param name="x">The position on the x-axis.</param> + /// <param name="y">The position on the y-axis.</param> + /// <returns>The corresponding noise map value.</returns> + private double GeneratePlanar(double x, double y) + { + return _generator.GetValue(x, 0.0, y); + } + + /// <summary> + /// Generates a non-seamless planar projection of the noise map. + /// </summary> + /// <param name="left">The clip region to the left.</param> + /// <param name="right">The clip region to the right.</param> + /// <param name="top">The clip region to the top.</param> + /// <param name="bottom">The clip region to the bottom.</param> + /// <param name="isSeamless">Indicates whether the resulting noise map should be seamless.</param> + public void GeneratePlanar(double left, double right, double top, double bottom, bool isSeamless = true) + { + if (right <= left || bottom <= top) + { + throw new ArgumentException("Invalid right/left or bottom/top combination"); + } + if (_generator == null) + { + throw new ArgumentNullException("Generator is null"); + } + var xe = right - left; + var ze = bottom - top; + var xd = xe / ((double) _width - _ucBorder); + var zd = ze / ((double) _height - _ucBorder); + var xc = left; + for (var x = 0; x < _ucWidth; x++) + { + var zc = top; + for (var y = 0; y < _ucHeight; y++) + { + float fv; + if (isSeamless) + { + fv = (float) GeneratePlanar(xc, zc); + } + else + { + var swv = GeneratePlanar(xc, zc); + var sev = GeneratePlanar(xc + xe, zc); + var nwv = GeneratePlanar(xc, zc + ze); + var nev = GeneratePlanar(xc + xe, zc + ze); + var xb = 1.0 - ((xc - left) / xe); + var zb = 1.0 - ((zc - top) / ze); + var z0 = Utils.InterpolateLinear(swv, sev, xb); + var z1 = Utils.InterpolateLinear(nwv, nev, xb); + fv = (float) Utils.InterpolateLinear(z0, z1, zb); + } + _ucData[x, y] = fv; + if (x >= _ucBorder && y >= _ucBorder && x < _width + _ucBorder && + y < _height + _ucBorder) + { + _data[x - _ucBorder, y - _ucBorder] = fv; // Cropped data + } + zc += zd; + } + xc += xd; + } + } + + /// <summary> + /// Generates a cylindrical projection of a point in the noise map. + /// </summary> + /// <param name="angle">The angle of the point.</param> + /// <param name="height">The height of the point.</param> + /// <returns>The corresponding noise map value.</returns> + private double GenerateCylindrical(double angle, double height) + { + var x = Math.Cos(angle * Mathf.Deg2Rad); + var y = height; + var z = Math.Sin(angle * Mathf.Deg2Rad); + return _generator.GetValue(x, y, z); + } + + /// <summary> + /// Generates a cylindrical projection of the noise map. + /// </summary> + /// <param name="angleMin">The maximum angle of the clip region.</param> + /// <param name="angleMax">The minimum angle of the clip region.</param> + /// <param name="heightMin">The minimum height of the clip region.</param> + /// <param name="heightMax">The maximum height of the clip region.</param> + public void GenerateCylindrical(double angleMin, double angleMax, double heightMin, double heightMax) + { + if (angleMax <= angleMin || heightMax <= heightMin) + { + throw new ArgumentException("Invalid angle or height parameters"); + } + if (_generator == null) + { + throw new ArgumentNullException("Generator is null"); + } + var ae = angleMax - angleMin; + var he = heightMax - heightMin; + var xd = ae / ((double) _width - _ucBorder); + var yd = he / ((double) _height - _ucBorder); + var ca = angleMin; + for (var x = 0; x < _ucWidth; x++) + { + var ch = heightMin; + for (var y = 0; y < _ucHeight; y++) + { + _ucData[x, y] = (float) GenerateCylindrical(ca, ch); + if (x >= _ucBorder && y >= _ucBorder && x < _width + _ucBorder && + y < _height + _ucBorder) + { + _data[x - _ucBorder, y - _ucBorder] = (float) GenerateCylindrical(ca, ch); + // Cropped data + } + ch += yd; + } + ca += xd; + } + } + + /// <summary> + /// Generates a spherical projection of a point in the noise map. + /// </summary> + /// <param name="lat">The latitude of the point.</param> + /// <param name="lon">The longitude of the point.</param> + /// <returns>The corresponding noise map value.</returns> + private double GenerateSpherical(double lat, double lon) + { + var r = Math.Cos(Mathf.Deg2Rad * lat); + return _generator.GetValue(r * Math.Cos(Mathf.Deg2Rad * lon), Math.Sin(Mathf.Deg2Rad * lat), + r * Math.Sin(Mathf.Deg2Rad * lon)); + } + + /// <summary> + /// Generates a spherical projection of the noise map. + /// </summary> + /// <param name="south">The clip region to the south.</param> + /// <param name="north">The clip region to the north.</param> + /// <param name="west">The clip region to the west.</param> + /// <param name="east">The clip region to the east.</param> + public void GenerateSpherical(double south, double north, double west, double east) + { + if (east <= west || north <= south) + { + throw new ArgumentException("Invalid east/west or north/south combination"); + } + if (_generator == null) + { + throw new ArgumentNullException("Generator is null"); + } + var loe = east - west; + var lae = north - south; + var xd = loe / ((double) _width - _ucBorder); + var yd = lae / ((double) _height - _ucBorder); + var clo = west; + for (var x = 0; x < _ucWidth; x++) + { + var cla = south; + for (var y = 0; y < _ucHeight; y++) + { + _ucData[x, y] = (float) GenerateSpherical(cla, clo); + if (x >= _ucBorder && y >= _ucBorder && x < _width + _ucBorder && + y < _height + _ucBorder) + { + _data[x - _ucBorder, y - _ucBorder] = (float) GenerateSpherical(cla, clo); + // Cropped data + } + cla += yd; + } + clo += xd; + } + } + + /// <summary> + /// Creates a grayscale texture map for the current content of the noise map. + /// </summary> + /// <returns>The created texture map.</returns> + public Texture2D GetTexture() + { + return GetTexture(GradientPresets.Grayscale); + } + + /// <summary> + /// Creates a texture map for the current content of the noise map. + /// </summary> + /// <param name="gradient">The gradient to color the texture map with.</param> + /// <returns>The created texture map.</returns> + public Texture2D GetTexture(Gradient gradient) + { + var texture = new Texture2D(_width, _height); + var pixels = new Color[_width * _height]; + for (var x = 0; x < _width; x++) + { + for (var y = 0; y < _height; y++) + { + float sample; + if (!float.IsNaN(_borderValue) && + (x == 0 || x == _width - _ucBorder || y == 0 || y == _height - _ucBorder)) + { + sample = _borderValue; + } + else + { + sample = _data[x, y]; + } + pixels[x + y * _width] = gradient.Evaluate((sample + 1) / 2); + } + } + texture.SetPixels(pixels); + texture.wrapMode = TextureWrapMode.Clamp; + texture.Apply(); + return texture; + } + + /// <summary> + /// Creates a normal map for the current content of the noise map. + /// </summary> + /// <param name="intensity">The scaling of the normal map values.</param> + /// <returns>The created normal map.</returns> + public Texture2D GetNormalMap(float intensity) + { + var texture = new Texture2D(_width, _height); + var pixels = new Color[_width * _height]; + for (var x = 0; x < _ucWidth; x++) + { + for (var y = 0; y < _ucHeight; y++) + { + var xPos = (_ucData[Mathf.Max(0, x - _ucBorder), y] - + _ucData[Mathf.Min(x + _ucBorder, _height + _ucBorder), y]) / 2; + var yPos = (_ucData[x, Mathf.Max(0, y - _ucBorder)] - + _ucData[x, Mathf.Min(y + _ucBorder, _width + _ucBorder)]) / 2; + var normalX = new Vector3(xPos * intensity, 0, 1); + var normalY = new Vector3(0, yPos * intensity, 1); + // Get normal vector + var normalVector = normalX + normalY; + normalVector.Normalize(); + // Get color vector + var colorVector = Vector3.zero; + colorVector.x = (normalVector.x + 1) / 2; + colorVector.y = (normalVector.y + 1) / 2; + colorVector.z = (normalVector.z + 1) / 2; + // Start at (x + _ucBorder, y + _ucBorder) so that resulting normal map aligns with cropped data + if (x >= _ucBorder && y >= _ucBorder && x < _width + _ucBorder && + y < _height + _ucBorder) + { + pixels[(x - _ucBorder) + (y - _ucBorder) * _width] = new Color(colorVector.x, + colorVector.y, colorVector.z); + } + } + } + texture.SetPixels(pixels); + texture.wrapMode = TextureWrapMode.Clamp; + texture.Apply(); + return texture; + } + + #endregion + + #region IDisposable Members + + [XmlIgnore] +#if !XBOX360 && !ZUNE + [NonSerialized] +#endif + private bool _disposed; + + /// <summary> + /// Gets a value whether the object is disposed. + /// </summary> + public bool IsDisposed + { + get { return _disposed; } + } + + /// <summary> + /// Immediately releases the unmanaged resources used by this object. + /// </summary> + public void Dispose() + { + if (!_disposed) + { + _disposed = Disposing(); + } + GC.SuppressFinalize(this); + } + + /// <summary> + /// Immediately releases the unmanaged resources used by this object. + /// </summary> + /// <returns>True if the object is completely disposed.</returns> + protected virtual bool Disposing() + { + _data = null; + _width = 0; + _height = 0; + return true; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Noise2D.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Noise2D.cs.meta new file mode 100644 index 00000000..5355cce2 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Noise2D.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 9b7ba00b7ee094d618be890f09a59f95 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator.meta new file mode 100644 index 00000000..1c8e0e85 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: dc5e0fafbdfd44742b85ea173f0ac76f diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Abs.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Abs.cs new file mode 100644 index 00000000..789b99d0 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Abs.cs @@ -0,0 +1,51 @@ +using System; +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs the absolute value of the output value from + /// a source module. [OPERATOR] + /// </summary> + public class Abs : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Abs. + /// </summary> + public Abs() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Abs. + /// </summary> + /// <param name="input">The input module.</param> + public Abs(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + return Math.Abs(Modules[0].GetValue(x, y, z)); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Abs.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Abs.cs.meta new file mode 100644 index 00000000..36b83ade --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Abs.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 23b1f62fc46bd4ea79b73bdfa896b034 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Add.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Add.cs new file mode 100644 index 00000000..4e91bba0 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Add.cs @@ -0,0 +1,53 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs the sum of the two output values from two + /// source modules. [OPERATOR] + /// </summary> + public class Add : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Add. + /// </summary> + public Add() + : base(2) + { + } + + /// <summary> + /// Initializes a new instance of Add. + /// </summary> + /// <param name="lhs">The left hand input module.</param> + /// <param name="rhs">The right hand input module.</param> + public Add(ModuleBase lhs, ModuleBase rhs) + : base(2) + { + Modules[0] = lhs; + Modules[1] = rhs; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + return Modules[0].GetValue(x, y, z) + Modules[1].GetValue(x, y, z); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Add.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Add.cs.meta new file mode 100644 index 00000000..d7938fc6 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Add.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: d7ac90f93a2ab427c831c60c111bf54f diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Blend.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Blend.cs new file mode 100644 index 00000000..d7e57ade --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Blend.cs @@ -0,0 +1,76 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs a weighted blend of the output values from + /// two source modules given the output value supplied by a control module. [OPERATOR] + /// </summary> + public class Blend : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Blend. + /// </summary> + public Blend() + : base(3) + { + } + + /// <summary> + /// Initializes a new instance of Blend. + /// </summary> + /// <param name="lhs">The left hand input module.</param> + /// <param name="rhs">The right hand input module.</param> + /// <param name="controller">The controller of the operator.</param> + public Blend(ModuleBase lhs, ModuleBase rhs, ModuleBase controller) + : base(3) + { + Modules[0] = lhs; + Modules[1] = rhs; + Modules[2] = controller; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the controlling module. + /// </summary> + public ModuleBase Controller + { + get { return Modules[2]; } + set + { + Debug.Assert(value != null); + Modules[2] = value; + } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + Debug.Assert(Modules[2] != null); + var a = Modules[0].GetValue(x, y, z); + var b = Modules[1].GetValue(x, y, z); + var c = (Modules[2].GetValue(x, y, z) + 1.0) / 2.0; + return Utils.InterpolateLinear(a, b, c); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Blend.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Blend.cs.meta new file mode 100644 index 00000000..d993a1eb --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Blend.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 26925e2038d704fcfb699b013c25ae69 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Cache.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Cache.cs new file mode 100644 index 00000000..38a28b6f --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Cache.cs @@ -0,0 +1,83 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that caches the last output value generated by a source + /// module. [OPERATOR] + /// </summary> + public class Cache : ModuleBase + { + #region Fields + + private double _value; + private bool _cached; + private double _x; + private double _y; + private double _z; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Cache. + /// </summary> + public Cache() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Cache. + /// </summary> + /// <param name="input">The input module.</param> + public Cache(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Gets or sets a source module by index. + /// </summary> + /// <param name="index">The index of the source module to aquire.</param> + /// <returns>The requested source module.</returns> + public override ModuleBase this[int index] + { + get { return base[index]; } + set + { + base[index] = value; + _cached = false; + } + } + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + if (!(_cached && _x == x && _y == y && _z == z)) + { + _value = Modules[0].GetValue(x, y, z); + _x = x; + _y = y; + _z = z; + } + _cached = true; + return _value; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Cache.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Cache.cs.meta new file mode 100644 index 00000000..494c9f4d --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Cache.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 97d943450f43c42f8a85dd94d870b34e diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Clamp.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Clamp.cs new file mode 100644 index 00000000..eeafe487 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Clamp.cs @@ -0,0 +1,124 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that clamps the output value from a source module to a + /// range of values. [OPERATOR] + /// </summary> + public class Clamp : ModuleBase + { + #region Fields + + private double _min = -1.0; + private double _max = 1.0; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Clamp. + /// </summary> + public Clamp() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Clamp. + /// </summary> + /// <param name="input">The input module.</param> + public Clamp(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + /// <summary> + /// Initializes a new instance of Clamp. + /// </summary> + /// <param name="input">The input module.</param> + /// <param name="min">The minimum value.</param> + /// <param name="max">The maximum value.</param> + public Clamp(double min, double max, ModuleBase input) + : base(1) + { + Minimum = min; + Maximum = max; + Modules[0] = input; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the maximum to clamp to. + /// </summary> + public double Maximum + { + get { return _max; } + set { _max = value; } + } + + /// <summary> + /// Gets or sets the minimum to clamp to. + /// </summary> + public double Minimum + { + get { return _min; } + set { _min = value; } + } + + #endregion + + #region Methods + + /// <summary> + /// Sets the bounds. + /// </summary> + /// <param name="min">The minimum value.</param> + /// <param name="max">The maximum value.</param> + public void SetBounds(double min, double max) + { + Debug.Assert(min < max); + _min = min; + _max = max; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + if (_min > _max) + { + var t = _min; + _min = _max; + _max = t; + } + var v = Modules[0].GetValue(x, y, z); + if (v < _min) + { + return _min; + } + if (v > _max) + { + return _max; + } + return v; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Clamp.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Clamp.cs.meta new file mode 100644 index 00000000..d22542ff --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Clamp.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 1f614701fffbe4d6881a735ef849eb92 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Curve.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Curve.cs new file mode 100644 index 00000000..e973762a --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Curve.cs @@ -0,0 +1,133 @@ +using System.Collections.Generic; +using UnityEngine; +using Debug = System.Diagnostics.Debug; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that maps the output value from a source module onto an + /// arbitrary function curve. [OPERATOR] + /// </summary> + public class Curve : ModuleBase + { + #region Fields + + private readonly List<KeyValuePair<double, double>> _data = new List<KeyValuePair<double, double>>(); + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Curve. + /// </summary> + public Curve() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Curve. + /// </summary> + /// <param name="input">The input module.</param> + public Curve(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets the number of control points. + /// </summary> + public int ControlPointCount + { + get { return _data.Count; } + } + + /// <summary> + /// Gets the list of control points. + /// </summary> + public List<KeyValuePair<double, double>> ControlPoints + { + get { return _data; } + } + + #endregion + + #region Methods + + /// <summary> + /// Adds a control point to the curve. + /// </summary> + /// <param name="input">The curves input value.</param> + /// <param name="output">The curves output value.</param> + public void Add(double input, double output) + { + var kvp = new KeyValuePair<double, double>(input, output); + if (!_data.Contains(kvp)) + { + _data.Add(kvp); + } + _data.Sort( + delegate(KeyValuePair<double, double> lhs, KeyValuePair<double, double> rhs) + { + return lhs.Key.CompareTo(rhs.Key); + }); + } + + /// <summary> + /// Clears the control points. + /// </summary> + public void Clear() + { + _data.Clear(); + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(ControlPointCount >= 4); + var smv = Modules[0].GetValue(x, y, z); + int ip; + for (ip = 0; ip < _data.Count; ip++) + { + if (smv < _data[ip].Key) + { + break; + } + } + var i0 = Mathf.Clamp(ip - 2, 0, _data.Count - 1); + var i1 = Mathf.Clamp(ip - 1, 0, _data.Count - 1); + var i2 = Mathf.Clamp(ip, 0, _data.Count - 1); + var i3 = Mathf.Clamp(ip + 1, 0, _data.Count - 1); + if (i1 == i2) + { + return _data[i1].Value; + } + //double ip0 = _data[i1].Value; + //double ip1 = _data[i2].Value; + var ip0 = _data[i1].Key; + var ip1 = _data[i2].Key; + var a = (smv - ip0) / (ip1 - ip0); + return Utils.InterpolateCubic(_data[i0].Value, _data[i1].Value, _data[i2].Value, + _data[i3].Value, a); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Curve.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Curve.cs.meta new file mode 100644 index 00000000..833518a9 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Curve.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: d429892d39ef845f392933debac7bfa9 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Displace.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Displace.cs new file mode 100644 index 00000000..c14b8365 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Displace.cs @@ -0,0 +1,106 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that uses three source modules to displace each + /// coordinate of the input value before returning the output value from + /// a source module. [OPERATOR] + /// </summary> + public class Displace : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Displace. + /// </summary> + public Displace() + : base(4) + { + } + + /// <summary> + /// Initializes a new instance of Displace. + /// </summary> + /// <param name="input">The input module.</param> + /// <param name="x">The displacement module of the x-axis.</param> + /// <param name="y">The displacement module of the y-axis.</param> + /// <param name="z">The displacement module of the z-axis.</param> + public Displace(ModuleBase input, ModuleBase x, ModuleBase y, ModuleBase z) + : base(4) + { + Modules[0] = input; + Modules[1] = x; + Modules[2] = y; + Modules[3] = z; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the controlling module on the x-axis. + /// </summary> + public ModuleBase X + { + get { return Modules[1]; } + set + { + Debug.Assert(value != null); + Modules[1] = value; + } + } + + /// <summary> + /// Gets or sets the controlling module on the z-axis. + /// </summary> + public ModuleBase Y + { + get { return Modules[2]; } + set + { + Debug.Assert(value != null); + Modules[2] = value; + } + } + + /// <summary> + /// Gets or sets the controlling module on the z-axis. + /// </summary> + public ModuleBase Z + { + get { return Modules[3]; } + set + { + Debug.Assert(value != null); + Modules[3] = value; + } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + Debug.Assert(Modules[2] != null); + Debug.Assert(Modules[3] != null); + var dx = x + Modules[1].GetValue(x, y, z); + var dy = y + Modules[2].GetValue(x, y, z); + var dz = z + Modules[3].GetValue(x, y, z); + return Modules[0].GetValue(dx, dy, dz); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Displace.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Displace.cs.meta new file mode 100644 index 00000000..56558e44 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Displace.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: ae7f5b41abbf54441933a154a7da8df8 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Exponent.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Exponent.cs new file mode 100644 index 00000000..a8d7db95 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Exponent.cs @@ -0,0 +1,83 @@ +using System; +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that maps the output value from a source module onto an + /// exponential curve. [OPERATOR] + /// </summary> + public class Exponent : ModuleBase + { + #region Fields + + private double _exponent = 1.0; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Exponent. + /// </summary> + public Exponent() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Exponent. + /// </summary> + /// <param name="input">The input module.</param> + public Exponent(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + /// <summary> + /// Initializes a new instance of Exponent. + /// </summary> + /// <param name="exponent">The exponent to use.</param> + /// <param name="input">The input module.</param> + public Exponent(double exponent, ModuleBase input) + : base(1) + { + Modules[0] = input; + Value = exponent; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the exponent. + /// </summary> + public double Value + { + get { return _exponent; } + set { _exponent = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + var v = Modules[0].GetValue(x, y, z); + return (Math.Pow(Math.Abs((v + 1.0) / 2.0), _exponent) * 2.0 - 1.0); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Exponent.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Exponent.cs.meta new file mode 100644 index 00000000..ce41330e --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Exponent.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: c3edd0e0a654443fd92d4418bffa8a5d diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Invert.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Invert.cs new file mode 100644 index 00000000..89ff52ff --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Invert.cs @@ -0,0 +1,49 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that inverts the output value from a source module. [OPERATOR] + /// </summary> + public class Invert : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Invert. + /// </summary> + public Invert() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Invert. + /// </summary> + /// <param name="input">The input module.</param> + public Invert(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + return -Modules[0].GetValue(x, y, z); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Invert.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Invert.cs.meta new file mode 100644 index 00000000..1565bd3a --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Invert.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 32c3770b72d4a4b47b1703ca8240448a diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Max.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Max.cs new file mode 100644 index 00000000..b6845cbc --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Max.cs @@ -0,0 +1,56 @@ +using System; +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs the larger of the two output values from two + /// source modules. [OPERATOR] + /// </summary> + public class Max : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Max. + /// </summary> + public Max() + : base(2) + { + } + + /// <summary> + /// Initializes a new instance of Max. + /// </summary> + /// <param name="lhs">The left hand input module.</param> + /// <param name="rhs">The right hand input module.</param> + public Max(ModuleBase lhs, ModuleBase rhs) + : base(2) + { + Modules[0] = lhs; + Modules[1] = rhs; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + var a = Modules[0].GetValue(x, y, z); + var b = Modules[1].GetValue(x, y, z); + return Math.Max(a, b); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Max.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Max.cs.meta new file mode 100644 index 00000000..d5753784 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Max.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 3d783a2fe1eb44925b1dfca3fccfa3c5 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Min.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Min.cs new file mode 100644 index 00000000..c6c74316 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Min.cs @@ -0,0 +1,56 @@ +using System; +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs the smaller of the two output values from two + /// source modules. [OPERATOR] + /// </summary> + public class Min : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Min. + /// </summary> + public Min() + : base(2) + { + } + + /// <summary> + /// Initializes a new instance of Min. + /// </summary> + /// <param name="lhs">The left hand input module.</param> + /// <param name="rhs">The right hand input module.</param> + public Min(ModuleBase lhs, ModuleBase rhs) + : base(2) + { + Modules[0] = lhs; + Modules[1] = rhs; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + var a = Modules[0].GetValue(x, y, z); + var b = Modules[1].GetValue(x, y, z); + return Math.Min(a, b); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Min.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Min.cs.meta new file mode 100644 index 00000000..26da0955 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Min.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: e0ff3830dd0434df994555aef62c8b9a diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Multiply.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Multiply.cs new file mode 100644 index 00000000..3346d4ba --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Multiply.cs @@ -0,0 +1,53 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs the product of the two output values from + /// two source modules. [OPERATOR] + /// </summary> + public class Multiply : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Multiply. + /// </summary> + public Multiply() + : base(2) + { + } + + /// <summary> + /// Initializes a new instance of Multiply. + /// </summary> + /// <param name="lhs">The left hand input module.</param> + /// <param name="rhs">The right hand input module.</param> + public Multiply(ModuleBase lhs, ModuleBase rhs) + : base(2) + { + Modules[0] = lhs; + Modules[1] = rhs; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + return Modules[0].GetValue(x, y, z) * Modules[1].GetValue(x, y, z); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Multiply.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Multiply.cs.meta new file mode 100644 index 00000000..3cdc1179 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Multiply.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 70b45911e3d204f82a1b4a9c74b8657c diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Power.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Power.cs new file mode 100644 index 00000000..137b75c7 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Power.cs @@ -0,0 +1,54 @@ +using System; +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs value from a first source module + /// to the power of the output value from a second source module. [OPERATOR] + /// </summary> + public class Power : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Power. + /// </summary> + public Power() + : base(2) + { + } + + /// <summary> + /// Initializes a new instance of Power. + /// </summary> + /// <param name="lhs">The left hand input module.</param> + /// <param name="rhs">The right hand input module.</param> + public Power(ModuleBase lhs, ModuleBase rhs) + : base(2) + { + Modules[0] = lhs; + Modules[1] = rhs; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + return Math.Pow(Modules[0].GetValue(x, y, z), Modules[1].GetValue(x, y, z)); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Power.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Power.cs.meta new file mode 100644 index 00000000..b9085829 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Power.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: ab5f89d2b3238431891abbc5b670cb9b diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Rotate.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Rotate.cs new file mode 100644 index 00000000..53e229fd --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Rotate.cs @@ -0,0 +1,150 @@ +using System; +using UnityEngine; +using Debug = System.Diagnostics.Debug; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that rotates the input value around the origin before + /// returning the output value from a source module. [OPERATOR] + /// </summary> + public class Rotate : ModuleBase + { + #region Fields + + private double _x; + private double _x1Matrix; + private double _x2Matrix; + private double _x3Matrix; + private double _y; + private double _y1Matrix; + private double _y2Matrix; + private double _y3Matrix; + private double _z; + private double _z1Matrix; + private double _z2Matrix; + private double _z3Matrix; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Rotate. + /// </summary> + public Rotate() + : base(1) + { + SetAngles(0.0, 0.0, 0.0); + } + + /// <summary> + /// Initializes a new instance of Rotate. + /// </summary> + /// <param name="input">The input module.</param> + public Rotate(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + /// <summary> + /// Initializes a new instance of Rotate. + /// </summary> + /// <param name="x">The rotation around the x-axis.</param> + /// <param name="y">The rotation around the y-axis.</param> + /// <param name="z">The rotation around the z-axis.</param> + /// <param name="input">The input module.</param> + public Rotate(double x, double y, double z, ModuleBase input) + : base(1) + { + Modules[0] = input; + SetAngles(x, y, z); + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the rotation around the x-axis in degree. + /// </summary> + public double X + { + get { return _x; } + set { SetAngles(value, _y, _z); } + } + + /// <summary> + /// Gets or sets the rotation around the y-axis in degree. + /// </summary> + public double Y + { + get { return _y; } + set { SetAngles(_x, value, _z); } + } + + /// <summary> + /// Gets or sets the rotation around the z-axis in degree. + /// </summary> + public double Z + { + get { return _x; } + set { SetAngles(_x, _y, value); } + } + + #endregion + + #region Methods + + /// <summary> + /// Sets the rotation angles. + /// </summary> + /// <param name="x">The rotation around the x-axis.</param> + /// <param name="y">The rotation around the y-axis.</param> + /// <param name="z">The rotation around the z-axis.</param> + private void SetAngles(double x, double y, double z) + { + var xc = Math.Cos(x * Mathf.Deg2Rad); + var yc = Math.Cos(y * Mathf.Deg2Rad); + var zc = Math.Cos(z * Mathf.Deg2Rad); + var xs = Math.Sin(x * Mathf.Deg2Rad); + var ys = Math.Sin(y * Mathf.Deg2Rad); + var zs = Math.Sin(z * Mathf.Deg2Rad); + _x1Matrix = ys * xs * zs + yc * zc; + _y1Matrix = xc * zs; + _z1Matrix = ys * zc - yc * xs * zs; + _x2Matrix = ys * xs * zc - yc * zs; + _y2Matrix = xc * zc; + _z2Matrix = -yc * xs * zc - ys * zs; + _x3Matrix = -ys * xc; + _y3Matrix = xs; + _z3Matrix = yc * xc; + _x = x; + _y = y; + _z = z; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + var nx = (_x1Matrix * x) + (_y1Matrix * y) + (_z1Matrix * z); + var ny = (_x2Matrix * x) + (_y2Matrix * y) + (_z2Matrix * z); + var nz = (_x3Matrix * x) + (_y3Matrix * y) + (_z3Matrix * z); + return Modules[0].GetValue(nx, ny, nz); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Rotate.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Rotate.cs.meta new file mode 100644 index 00000000..fda425c9 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Rotate.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 798fa977dd6f54c2e843b49808125267 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Scale.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Scale.cs new file mode 100644 index 00000000..85c9479e --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Scale.cs @@ -0,0 +1,105 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that scales the coordinates of the input value before + /// returning the output value from a source module. [OPERATOR] + /// </summary> + public class Scale : ModuleBase + { + #region Fields + + private double _x = 1.0; + private double _y = 1.0; + private double _z = 1.0; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Scale. + /// </summary> + public Scale() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Scale. + /// </summary> + /// <param name="input">The input module.</param> + public Scale(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + /// <summary> + /// Initializes a new instance of Scale. + /// </summary> + /// <param name="x">The scaling on the x-axis.</param> + /// <param name="y">The scaling on the y-axis.</param> + /// <param name="z">The scaling on the z-axis.</param> + /// <param name="input">The input module.</param> + public Scale(double x, double y, double z, ModuleBase input) + : base(1) + { + Modules[0] = input; + X = x; + Y = y; + Z = z; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the scaling factor on the x-axis. + /// </summary> + public double X + { + get { return _x; } + set { _x = value; } + } + + /// <summary> + /// Gets or sets the scaling factor on the y-axis. + /// </summary> + public double Y + { + get { return _y; } + set { _y = value; } + } + + /// <summary> + /// Gets or sets the scaling factor on the z-axis. + /// </summary> + public double Z + { + get { return _z; } + set { _z = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + return Modules[0].GetValue(x * _x, y * _y, z * _z); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Scale.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Scale.cs.meta new file mode 100644 index 00000000..8a70c2cb --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Scale.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: d8b3b32e2ea7d4b649e21bb7c8efdfc1 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/ScaleBias.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/ScaleBias.cs new file mode 100644 index 00000000..8da7799d --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/ScaleBias.cs @@ -0,0 +1,79 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that applies a scaling factor and a bias to the output + /// value from a source module. [OPERATOR] + /// </summary> + public class ScaleBias : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of ScaleBias. + /// </summary> + public ScaleBias() + : base(1) + { + Scale = 1; + } + + /// <summary> + /// Initializes a new instance of ScaleBias. + /// </summary> + /// <param name="input">The input module.</param> + public ScaleBias(ModuleBase input) + : base(1) + { + Modules[0] = input; + Scale = 1; + } + + /// <summary> + /// Initializes a new instance of ScaleBias. + /// </summary> + /// <param name="scale">The scaling factor to apply to the output value from the source module.</param> + /// <param name="bias">The bias to apply to the scaled output value from the source module.</param> + /// <param name="input">The input module.</param> + public ScaleBias(double scale, double bias, ModuleBase input) + : base(1) + { + Modules[0] = input; + Bias = bias; + Scale = scale; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the bias to apply to the scaled output value from the source module. + /// </summary> + public double Bias { get; set; } + + /// <summary> + /// Gets or sets the scaling factor to apply to the output value from the source module. + /// </summary> + public double Scale { get; set; } + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + return Modules[0].GetValue(x, y, z) * Scale + Bias; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/ScaleBias.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/ScaleBias.cs.meta new file mode 100644 index 00000000..f6c79870 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/ScaleBias.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 5e791d0bd67434b428188c7342ff8789 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Select.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Select.cs new file mode 100644 index 00000000..c7320e43 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Select.cs @@ -0,0 +1,192 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs the value selected from one of two source + /// modules chosen by the output value from a control module. [OPERATOR] + /// </summary> + public class Select : ModuleBase + { + #region Fields + + private double _fallOff; + private double _raw; + private double _min = -1.0; + private double _max = 1.0; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Select. + /// </summary> + public Select() + : base(3) + { + } + + /// <summary> + /// Initializes a new instance of Select. + /// </summary> + /// <param name="inputA">The first input module.</param> + /// <param name="inputB">The second input module.</param> + /// <param name="controller">The controller module.</param> + public Select(ModuleBase inputA, ModuleBase inputB, ModuleBase controller) + : base(3) + { + Modules[0] = inputA; + Modules[1] = inputB; + Modules[2] = controller; + } + + /// <summary> + /// Initializes a new instance of Select. + /// </summary> + /// <param name="min">The minimum value.</param> + /// <param name="max">The maximum value.</param> + /// <param name="fallOff">The falloff value at the edge transition.</param> + /// <param name="inputA">The first input module.</param> + /// <param name="inputB">The second input module.</param> + public Select(double min, double max, double fallOff, ModuleBase inputA, ModuleBase inputB) + : this(inputA, inputB, null) + { + _min = min; + _max = max; + FallOff = fallOff; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the controlling module. + /// </summary> + public ModuleBase Controller + { + get { return Modules[2]; } + set + { + Debug.Assert(value != null); + Modules[2] = value; + } + } + + /// <summary> + /// Gets or sets the falloff value at the edge transition. + /// </summary> + /// <remarks> + /// Called SetEdgeFallOff() on the original LibNoise. + /// </remarks> + public double FallOff + { + get { return _fallOff; } + set + { + var bs = _max - _min; + _raw = value; + _fallOff = (value > bs / 2) ? bs / 2 : value; + } + } + + /// <summary> + /// Gets or sets the maximum, and re-calculated the fall-off accordingly. + /// </summary> + public double Maximum + { + get { return _max; } + set + { + _max = value; + FallOff = _raw; + } + } + + /// <summary> + /// Gets or sets the minimum, and re-calculated the fall-off accordingly. + /// </summary> + public double Minimum + { + get { return _min; } + set + { + _min = value; + FallOff = _raw; + } + } + + #endregion + + #region Methods + + /// <summary> + /// Sets the bounds. + /// </summary> + /// <param name="min">The minimum value.</param> + /// <param name="max">The maximum value.</param> + public void SetBounds(double min, double max) + { + Debug.Assert(min < max); + _min = min; + _max = max; + FallOff = _fallOff; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + Debug.Assert(Modules[2] != null); + var cv = Modules[2].GetValue(x, y, z); + if (_fallOff > 0.0) + { + double a; + if (cv < (_min - _fallOff)) + { + return Modules[0].GetValue(x, y, z); + } + if (cv < (_min + _fallOff)) + { + var lc = (_min - _fallOff); + var uc = (_min + _fallOff); + a = Utils.MapCubicSCurve((cv - lc) / (uc - lc)); + return Utils.InterpolateLinear(Modules[0].GetValue(x, y, z), + Modules[1].GetValue(x, y, z), a); + } + if (cv < (_max - _fallOff)) + { + return Modules[1].GetValue(x, y, z); + } + if (cv < (_max + _fallOff)) + { + var lc = (_max - _fallOff); + var uc = (_max + _fallOff); + a = Utils.MapCubicSCurve((cv - lc) / (uc - lc)); + return Utils.InterpolateLinear(Modules[1].GetValue(x, y, z), + Modules[0].GetValue(x, y, z), a); + } + return Modules[0].GetValue(x, y, z); + } + if (cv < _min || cv > _max) + { + return Modules[0].GetValue(x, y, z); + } + return Modules[1].GetValue(x, y, z); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Select.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Select.cs.meta new file mode 100644 index 00000000..310cc39a --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Select.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 68ae76f31b0c84b0593bf02785ebed7c diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Subtract.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Subtract.cs new file mode 100644 index 00000000..2dbd42ff --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Subtract.cs @@ -0,0 +1,53 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that outputs the difference of the two output values from two + /// source modules. [OPERATOR] + /// </summary> + public class Subtract : ModuleBase + { + #region Constructors + + /// <summary> + /// Initializes a new instance of Subtract. + /// </summary> + public Subtract() + : base(2) + { + } + + /// <summary> + /// Initializes a new instance of Subtract. + /// </summary> + /// <param name="lhs">The left hand input module.</param> + /// <param name="rhs">The right hand input module.</param> + public Subtract(ModuleBase lhs, ModuleBase rhs) + : base(2) + { + Modules[0] = lhs; + Modules[1] = rhs; + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(Modules[1] != null); + return Modules[0].GetValue(x, y, z) - Modules[1].GetValue(x, y, z); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Subtract.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Subtract.cs.meta new file mode 100644 index 00000000..7bb1ccaa --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Subtract.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: babee65c2a2764d2da05db9230dd8a22 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Terrace.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Terrace.cs new file mode 100644 index 00000000..5b80f641 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Terrace.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using Debug = System.Diagnostics.Debug; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that maps the output value from a source module onto a + /// terrace-forming curve. [OPERATOR] + /// </summary> + public class Terrace : ModuleBase + { + #region Fields + + private readonly List<double> _data = new List<double>(); + private bool _inverted; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Terrace. + /// </summary> + public Terrace() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Terrace. + /// </summary> + /// <param name="input">The input module.</param> + public Terrace(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + /// <summary> + /// Initializes a new instance of Terrace. + /// </summary> + /// <param name="inverted">Indicates whether the terrace curve is inverted.</param> + /// <param name="input">The input module.</param> + public Terrace(bool inverted, ModuleBase input) + : base(1) + { + Modules[0] = input; + IsInverted = inverted; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets the number of control points. + /// </summary> + public int ControlPointCount + { + get { return _data.Count; } + } + + /// <summary> + /// Gets the list of control points. + /// </summary> + public List<double> ControlPoints + { + get { return _data; } + } + + /// <summary> + /// Gets or sets a value whether the terrace curve is inverted. + /// </summary> + public bool IsInverted + { + get { return _inverted; } + set { _inverted = value; } + } + + #endregion + + #region Methods + + /// <summary> + /// Adds a control point to the curve. + /// </summary> + /// <param name="input">The curves input value.</param> + public void Add(double input) + { + if (!_data.Contains(input)) + { + _data.Add(input); + } + _data.Sort(delegate(double lhs, double rhs) { return lhs.CompareTo(rhs); }); + } + + /// <summary> + /// Clears the control points. + /// </summary> + public void Clear() + { + _data.Clear(); + } + + /// <summary> + /// Auto-generates a terrace curve. + /// </summary> + /// <param name="steps">The number of steps.</param> + public void Generate(int steps) + { + if (steps < 2) + { + throw new ArgumentException("Need at least two steps"); + } + Clear(); + var ts = 2.0 / (steps - 1.0); + var cv = -1.0; + for (var i = 0; i < steps; i++) + { + Add(cv); + cv += ts; + } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + Debug.Assert(ControlPointCount >= 2); + var smv = Modules[0].GetValue(x, y, z); + int ip; + for (ip = 0; ip < _data.Count; ip++) + { + if (smv < _data[ip]) + { + break; + } + } + var i0 = Mathf.Clamp(ip - 1, 0, _data.Count - 1); + var i1 = Mathf.Clamp(ip, 0, _data.Count - 1); + if (i0 == i1) + { + return _data[i1]; + } + var v0 = _data[i0]; + var v1 = _data[i1]; + var a = (smv - v0) / (v1 - v0); + if (_inverted) + { + a = 1.0 - a; + var t = v0; + v0 = v1; + v1 = t; + } + a *= a; + return Utils.InterpolateLinear(v0, v1, a); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Terrace.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Terrace.cs.meta new file mode 100644 index 00000000..2894f8e4 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Terrace.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: adbad148cd4a64869873cc8d85051249 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Translate.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Translate.cs new file mode 100644 index 00000000..fa6e6790 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Translate.cs @@ -0,0 +1,105 @@ +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that moves the coordinates of the input value before + /// returning the output value from a source module. [OPERATOR] + /// </summary> + public class Translate : ModuleBase + { + #region Fields + + private double _x = 1.0; + private double _y = 1.0; + private double _z = 1.0; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Translate. + /// </summary> + public Translate() + : base(1) + { + } + + /// <summary> + /// Initializes a new instance of Translate. + /// </summary> + /// <param name="input">The input module.</param> + public Translate(ModuleBase input) + : base(1) + { + Modules[0] = input; + } + + /// <summary> + /// Initializes a new instance of Translate. + /// </summary> + /// <param name="x">The translation on the x-axis.</param> + /// <param name="y">The translation on the y-axis.</param> + /// <param name="z">The translation on the z-axis.</param> + /// <param name="input">The input module.</param> + public Translate(double x, double y, double z, ModuleBase input) + : base(1) + { + Modules[0] = input; + X = x; + Y = y; + Z = z; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the translation on the x-axis. + /// </summary> + public double X + { + get { return _x; } + set { _x = value; } + } + + /// <summary> + /// Gets or sets the translation on the y-axis. + /// </summary> + public double Y + { + get { return _y; } + set { _y = value; } + } + + /// <summary> + /// Gets or sets the translation on the z-axis. + /// </summary> + public double Z + { + get { return _z; } + set { _z = value; } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + return Modules[0].GetValue(x + _x, y + _y, z + _z); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Translate.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Translate.cs.meta new file mode 100644 index 00000000..cae50ff8 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Translate.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 584b45e999fb2415295c796d01c406d9 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Turbulence.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Turbulence.cs new file mode 100644 index 00000000..5c25805b --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Turbulence.cs @@ -0,0 +1,164 @@ +using System.Diagnostics; +using LibNoise.Generator; + +namespace LibNoise.Operator +{ + /// <summary> + /// Provides a noise module that that randomly displaces the input value before + /// returning the output value from a source module. [OPERATOR] + /// </summary> + public class Turbulence : ModuleBase + { + #region Constants + + private const double X0 = (12414.0 / 65536.0); + private const double Y0 = (65124.0 / 65536.0); + private const double Z0 = (31337.0 / 65536.0); + private const double X1 = (26519.0 / 65536.0); + private const double Y1 = (18128.0 / 65536.0); + private const double Z1 = (60493.0 / 65536.0); + private const double X2 = (53820.0 / 65536.0); + private const double Y2 = (11213.0 / 65536.0); + private const double Z2 = (44845.0 / 65536.0); + + #endregion + + #region Fields + + private double _power = 1.0; + private readonly Perlin _xDistort; + private readonly Perlin _yDistort; + private readonly Perlin _zDistort; + + #endregion + + #region Constructors + + /// <summary> + /// Initializes a new instance of Turbulence. + /// </summary> + public Turbulence() + : base(1) + { + _xDistort = new Perlin(); + _yDistort = new Perlin(); + _zDistort = new Perlin(); + } + + /// <summary> + /// Initializes a new instance of Turbulence. + /// </summary> + /// <param name="input">The input module.</param> + public Turbulence(ModuleBase input) + : base(1) + { + _xDistort = new Perlin(); + _yDistort = new Perlin(); + _zDistort = new Perlin(); + Modules[0] = input; + } + + /// <summary> + /// Initializes a new instance of Turbulence. + /// </summary> + public Turbulence(double power, ModuleBase input) + : this(new Perlin(), new Perlin(), new Perlin(), power, input) + { + } + + /// <summary> + /// Initializes a new instance of Turbulence. + /// </summary> + /// <param name="x">The perlin noise to apply on the x-axis.</param> + /// <param name="y">The perlin noise to apply on the y-axis.</param> + /// <param name="z">The perlin noise to apply on the z-axis.</param> + /// <param name="power">The power of the turbulence.</param> + /// <param name="input">The input module.</param> + public Turbulence(Perlin x, Perlin y, Perlin z, double power, ModuleBase input) + : base(1) + { + _xDistort = x; + _yDistort = y; + _zDistort = z; + Modules[0] = input; + Power = power; + } + + #endregion + + #region Properties + + /// <summary> + /// Gets or sets the frequency of the turbulence. + /// </summary> + public double Frequency + { + get { return _xDistort.Frequency; } + set + { + _xDistort.Frequency = value; + _yDistort.Frequency = value; + _zDistort.Frequency = value; + } + } + + /// <summary> + /// Gets or sets the power of the turbulence. + /// </summary> + public double Power + { + get { return _power; } + set { _power = value; } + } + + /// <summary> + /// Gets or sets the roughness of the turbulence. + /// </summary> + public int Roughness + { + get { return _xDistort.OctaveCount; } + set + { + _xDistort.OctaveCount = value; + _yDistort.OctaveCount = value; + _zDistort.OctaveCount = value; + } + } + + /// <summary> + /// Gets or sets the seed of the turbulence. + /// </summary> + public int Seed + { + get { return _xDistort.Seed; } + set + { + _xDistort.Seed = value; + _yDistort.Seed = value + 1; + _zDistort.Seed = value + 2; + } + } + + #endregion + + #region ModuleBase Members + + /// <summary> + /// Returns the output value for the given input coordinates. + /// </summary> + /// <param name="x">The input coordinate on the x-axis.</param> + /// <param name="y">The input coordinate on the y-axis.</param> + /// <param name="z">The input coordinate on the z-axis.</param> + /// <returns>The resulting output value.</returns> + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + var xd = x + (_xDistort.GetValue(x + X0, y + Y0, z + Z0) * _power); + var yd = y + (_yDistort.GetValue(x + X1, y + Y1, z + Z1) * _power); + var zd = z + (_zDistort.GetValue(x + X2, y + Y2, z + Z2) * _power); + return Modules[0].GetValue(xd, yd, zd); + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Turbulence.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Turbulence.cs.meta new file mode 100644 index 00000000..8a5c934c --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Operator/Turbulence.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 0fff09f24d7f041909a70459bf281bd6 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties.meta new file mode 100644 index 00000000..7131a566 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 49675d30a4ae9442e91c545a7507cd48 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties/AssemblyInfo.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..5764ea83 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties/AssemblyInfo.cs @@ -0,0 +1,38 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("LibNoise.Unity")] +[assembly: AssemblyProduct("LibNoise.Unity")] +[assembly: + AssemblyDescription("C# Unity Port of LibNoise, Ported from BigBlackBlock Gamestudio port of LibNoise to XNA")] +[assembly: AssemblyCompany("None")] +[assembly: + AssemblyCopyright( + "LibUnity.Xna Copyright © Jason Bevins 2003-2007, 2010 BigBlackBlock Gamestudio, LibNoise.Unity Copyright © 2010 Unity Commons, distributed under the terms on the Lesser GPL" + )] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("aa606d44-f8c3-47aa-a2b5-9156119ff843")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// + +[assembly: AssemblyVersion("1.0.0.0")]
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties/AssemblyInfo.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties/AssemblyInfo.cs.meta new file mode 100644 index 00000000..66652972 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Properties/AssemblyInfo.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 9834969af61da4894b115a330b272bb9 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/README.md b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/README.md new file mode 100644 index 00000000..92211c8b --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/README.md @@ -0,0 +1,25 @@ +# LibNoise.Unity + +The main repository for LibNoise.Unity is currently maintained by +[Ricardo J. Méndez](https://github.com/ricardojmendez). Pull requests +are welcome. + +## License + +LibNoise.Unity is released under the +[LGPL license](https://www.gnu.org/licenses/lgpl.html). See COPYING.txt and +COPYING.LESSER.txt for details. + +## About + +[LibNoise](http://libnoise.sourceforge.net/) was originally created by +Jason Bevins. The library was later ported to Xna by [Marc André Ueberall](http://www.big-black-block.com/#home), and moved to Unity by Tim Speltz. Speltz’s original development forum thread contains a Unity package with +an example scene, which can be found +[here](http://forum.unity3d.com/threads/68764-LibNoise-Ported-to-Unity). Please note that LibNoise.Unity is only a repository for the library code itself and +contains no example files. + +[You can also see the converted tutorials examples on this repository](https://github.com/ricardojmendez/LibNoiseTutorials). + +Other contributors to LibNoise.Unity include +[Teddy Bradford](https://github.com/teddybradford) who reworked much of the +Noise2D class to improve tiling support for noise maps. diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/README.md.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/README.md.meta new file mode 100644 index 00000000..90d585c3 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/README.md.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 68ca633e34cae4d52ace312cfc9c6652 diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Utils.cs b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Utils.cs new file mode 100644 index 00000000..e2d68c4f --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Utils.cs @@ -0,0 +1,286 @@ +using System; + +namespace LibNoise +{ + internal static class Utils + { + #region Constants + + internal const double Sqrt3 = 1.7320508075688772935; + internal const int OctavesMaximum = 30; + +#if NOISE_VERSION_1 + private const int GeneratorNoiseX = 1; + private const int GeneratorNoiseY = 31337; + private const int GeneratorNoiseZ = 263; + private const int GeneratorSeed = 1013; + private const int GeneratorShift = 13; + #else + private const int GeneratorNoiseX = 1619; + private const int GeneratorNoiseY = 31337; + private const int GeneratorNoiseZ = 6971; + private const int GeneratorSeed = 1013; + private const int GeneratorShift = 8; +#endif + + #endregion + + #region Fields + + internal static readonly double[] Randoms = + { + -0.763874, -0.596439, -0.246489, 0.0, 0.396055, 0.904518, -0.158073, 0.0, + -0.499004, -0.8665, -0.0131631, 0.0, 0.468724, -0.824756, 0.316346, 0.0, + 0.829598, 0.43195, 0.353816, 0.0, -0.454473, 0.629497, -0.630228, 0.0, + -0.162349, -0.869962, -0.465628, 0.0, 0.932805, 0.253451, 0.256198, 0.0, + -0.345419, 0.927299, -0.144227, 0.0, -0.715026, -0.293698, -0.634413, 0.0, + -0.245997, 0.717467, -0.651711, 0.0, -0.967409, -0.250435, -0.037451, 0.0, + 0.901729, 0.397108, -0.170852, 0.0, 0.892657, -0.0720622, -0.444938, 0.0, + 0.0260084, -0.0361701, 0.999007, 0.0, 0.949107, -0.19486, 0.247439, 0.0, + 0.471803, -0.807064, -0.355036, 0.0, 0.879737, 0.141845, 0.453809, 0.0, + 0.570747, 0.696415, 0.435033, 0.0, -0.141751, -0.988233, -0.0574584, 0.0, + -0.58219, -0.0303005, 0.812488, 0.0, -0.60922, 0.239482, -0.755975, 0.0, + 0.299394, -0.197066, -0.933557, 0.0, -0.851615, -0.220702, -0.47544, 0.0, + 0.848886, 0.341829, -0.403169, 0.0, -0.156129, -0.687241, 0.709453, 0.0, + -0.665651, 0.626724, 0.405124, 0.0, 0.595914, -0.674582, 0.43569, 0.0, + 0.171025, -0.509292, 0.843428, 0.0, 0.78605, 0.536414, -0.307222, 0.0, + 0.18905, -0.791613, 0.581042, 0.0, -0.294916, 0.844994, 0.446105, 0.0, + 0.342031, -0.58736, -0.7335, 0.0, 0.57155, 0.7869, 0.232635, 0.0, + 0.885026, -0.408223, 0.223791, 0.0, -0.789518, 0.571645, 0.223347, 0.0, + 0.774571, 0.31566, 0.548087, 0.0, -0.79695, -0.0433603, -0.602487, 0.0, + -0.142425, -0.473249, -0.869339, 0.0, -0.0698838, 0.170442, 0.982886, 0.0, + 0.687815, -0.484748, 0.540306, 0.0, 0.543703, -0.534446, -0.647112, 0.0, + 0.97186, 0.184391, -0.146588, 0.0, 0.707084, 0.485713, -0.513921, 0.0, + 0.942302, 0.331945, 0.043348, 0.0, 0.499084, 0.599922, 0.625307, 0.0, + -0.289203, 0.211107, 0.9337, 0.0, 0.412433, -0.71667, -0.56239, 0.0, + 0.87721, -0.082816, 0.47291, 0.0, -0.420685, -0.214278, 0.881538, 0.0, + 0.752558, -0.0391579, 0.657361, 0.0, 0.0765725, -0.996789, 0.0234082, 0.0, + -0.544312, -0.309435, -0.779727, 0.0, -0.455358, -0.415572, 0.787368, 0.0, + -0.874586, 0.483746, 0.0330131, 0.0, 0.245172, -0.0838623, 0.965846, 0.0, + 0.382293, -0.432813, 0.81641, 0.0, -0.287735, -0.905514, 0.311853, 0.0, + -0.667704, 0.704955, -0.239186, 0.0, 0.717885, -0.464002, -0.518983, 0.0, + 0.976342, -0.214895, 0.0240053, 0.0, -0.0733096, -0.921136, 0.382276, 0.0, + -0.986284, 0.151224, -0.0661379, 0.0, -0.899319, -0.429671, 0.0812908, 0.0, + 0.652102, -0.724625, 0.222893, 0.0, 0.203761, 0.458023, -0.865272, 0.0, + -0.030396, 0.698724, -0.714745, 0.0, -0.460232, 0.839138, 0.289887, 0.0, + -0.0898602, 0.837894, 0.538386, 0.0, -0.731595, 0.0793784, 0.677102, 0.0, + -0.447236, -0.788397, 0.422386, 0.0, 0.186481, 0.645855, -0.740335, 0.0, + -0.259006, 0.935463, 0.240467, 0.0, 0.445839, 0.819655, -0.359712, 0.0, + 0.349962, 0.755022, -0.554499, 0.0, -0.997078, -0.0359577, 0.0673977, 0.0, + -0.431163, -0.147516, -0.890133, 0.0, 0.299648, -0.63914, 0.708316, 0.0, + 0.397043, 0.566526, -0.722084, 0.0, -0.502489, 0.438308, -0.745246, 0.0, + 0.0687235, 0.354097, 0.93268, 0.0, -0.0476651, -0.462597, 0.885286, 0.0, + -0.221934, 0.900739, -0.373383, 0.0, -0.956107, -0.225676, 0.186893, 0.0, + -0.187627, 0.391487, -0.900852, 0.0, -0.224209, -0.315405, 0.92209, 0.0, + -0.730807, -0.537068, 0.421283, 0.0, -0.0353135, -0.816748, 0.575913, 0.0, + -0.941391, 0.176991, -0.287153, 0.0, -0.154174, 0.390458, 0.90762, 0.0, + -0.283847, 0.533842, 0.796519, 0.0, -0.482737, -0.850448, 0.209052, 0.0, + -0.649175, 0.477748, 0.591886, 0.0, 0.885373, -0.405387, -0.227543, 0.0, + -0.147261, 0.181623, -0.972279, 0.0, 0.0959236, -0.115847, -0.988624, 0.0, + -0.89724, -0.191348, 0.397928, 0.0, 0.903553, -0.428461, -0.00350461, 0.0, + 0.849072, -0.295807, -0.437693, 0.0, 0.65551, 0.741754, -0.141804, 0.0, + 0.61598, -0.178669, 0.767232, 0.0, 0.0112967, 0.932256, -0.361623, 0.0, + -0.793031, 0.258012, 0.551845, 0.0, 0.421933, 0.454311, 0.784585, 0.0, + -0.319993, 0.0401618, -0.946568, 0.0, -0.81571, 0.551307, -0.175151, 0.0, + -0.377644, 0.00322313, 0.925945, 0.0, 0.129759, -0.666581, -0.734052, 0.0, + 0.601901, -0.654237, -0.457919, 0.0, -0.927463, -0.0343576, -0.372334, 0.0, + -0.438663, -0.868301, -0.231578, 0.0, -0.648845, -0.749138, -0.133387, 0.0, + 0.507393, -0.588294, 0.629653, 0.0, 0.726958, 0.623665, 0.287358, 0.0, + 0.411159, 0.367614, -0.834151, 0.0, 0.806333, 0.585117, -0.0864016, 0.0, + 0.263935, -0.880876, 0.392932, 0.0, 0.421546, -0.201336, 0.884174, 0.0, + -0.683198, -0.569557, -0.456996, 0.0, -0.117116, -0.0406654, -0.992285, 0.0, + -0.643679, -0.109196, -0.757465, 0.0, -0.561559, -0.62989, 0.536554, 0.0, + 0.0628422, 0.104677, -0.992519, 0.0, 0.480759, -0.2867, -0.828658, 0.0, + -0.228559, -0.228965, -0.946222, 0.0, -0.10194, -0.65706, -0.746914, 0.0, + 0.0689193, -0.678236, 0.731605, 0.0, 0.401019, -0.754026, 0.52022, 0.0, + -0.742141, 0.547083, -0.387203, 0.0, -0.00210603, -0.796417, -0.604745, 0.0, + 0.296725, -0.409909, -0.862513, 0.0, -0.260932, -0.798201, 0.542945, 0.0, + -0.641628, 0.742379, 0.192838, 0.0, -0.186009, -0.101514, 0.97729, 0.0, + 0.106711, -0.962067, 0.251079, 0.0, -0.743499, 0.30988, -0.592607, 0.0, + -0.795853, -0.605066, -0.0226607, 0.0, -0.828661, -0.419471, -0.370628, 0.0, + 0.0847218, -0.489815, -0.8677, 0.0, -0.381405, 0.788019, -0.483276, 0.0, + 0.282042, -0.953394, 0.107205, 0.0, 0.530774, 0.847413, 0.0130696, 0.0, + 0.0515397, 0.922524, 0.382484, 0.0, -0.631467, -0.709046, 0.313852, 0.0, + 0.688248, 0.517273, 0.508668, 0.0, 0.646689, -0.333782, -0.685845, 0.0, + -0.932528, -0.247532, -0.262906, 0.0, 0.630609, 0.68757, -0.359973, 0.0, + 0.577805, -0.394189, 0.714673, 0.0, -0.887833, -0.437301, -0.14325, 0.0, + 0.690982, 0.174003, 0.701617, 0.0, -0.866701, 0.0118182, 0.498689, 0.0, + -0.482876, 0.727143, 0.487949, 0.0, -0.577567, 0.682593, -0.447752, 0.0, + 0.373768, 0.0982991, 0.922299, 0.0, 0.170744, 0.964243, -0.202687, 0.0, + 0.993654, -0.035791, -0.106632, 0.0, 0.587065, 0.4143, -0.695493, 0.0, + -0.396509, 0.26509, -0.878924, 0.0, -0.0866853, 0.83553, -0.542563, 0.0, + 0.923193, 0.133398, -0.360443, 0.0, 0.00379108, -0.258618, 0.965972, 0.0, + 0.239144, 0.245154, -0.939526, 0.0, 0.758731, -0.555871, 0.33961, 0.0, + 0.295355, 0.309513, 0.903862, 0.0, 0.0531222, -0.91003, -0.411124, 0.0, + 0.270452, 0.0229439, -0.96246, 0.0, 0.563634, 0.0324352, 0.825387, 0.0, + 0.156326, 0.147392, 0.976646, 0.0, -0.0410141, 0.981824, 0.185309, 0.0, + -0.385562, -0.576343, -0.720535, 0.0, 0.388281, 0.904441, 0.176702, 0.0, + 0.945561, -0.192859, -0.262146, 0.0, 0.844504, 0.520193, 0.127325, 0.0, + 0.0330893, 0.999121, -0.0257505, 0.0, -0.592616, -0.482475, -0.644999, 0.0, + 0.539471, 0.631024, -0.557476, 0.0, 0.655851, -0.027319, -0.754396, 0.0, + 0.274465, 0.887659, 0.369772, 0.0, -0.123419, 0.975177, -0.183842, 0.0, + -0.223429, 0.708045, 0.66989, 0.0, -0.908654, 0.196302, 0.368528, 0.0, + -0.95759, -0.00863708, 0.288005, 0.0, 0.960535, 0.030592, 0.276472, 0.0, + -0.413146, 0.907537, 0.0754161, 0.0, -0.847992, 0.350849, -0.397259, 0.0, + 0.614736, 0.395841, 0.68221, 0.0, -0.503504, -0.666128, -0.550234, 0.0, + -0.268833, -0.738524, -0.618314, 0.0, 0.792737, -0.60001, -0.107502, 0.0, + -0.637582, 0.508144, -0.579032, 0.0, 0.750105, 0.282165, -0.598101, 0.0, + -0.351199, -0.392294, -0.850155, 0.0, 0.250126, -0.960993, -0.118025, 0.0, + -0.732341, 0.680909, -0.0063274, 0.0, -0.760674, -0.141009, 0.633634, 0.0, + 0.222823, -0.304012, 0.926243, 0.0, 0.209178, 0.505671, 0.836984, 0.0, + 0.757914, -0.56629, -0.323857, 0.0, -0.782926, -0.339196, 0.52151, 0.0, + -0.462952, 0.585565, 0.665424, 0.0, 0.61879, 0.194119, -0.761194, 0.0, + 0.741388, -0.276743, 0.611357, 0.0, 0.707571, 0.702621, 0.0752872, 0.0, + 0.156562, 0.819977, 0.550569, 0.0, -0.793606, 0.440216, 0.42, 0.0, + 0.234547, 0.885309, -0.401517, 0.0, 0.132598, 0.80115, -0.58359, 0.0, + -0.377899, -0.639179, 0.669808, 0.0, -0.865993, -0.396465, 0.304748, 0.0, + -0.624815, -0.44283, 0.643046, 0.0, -0.485705, 0.825614, -0.287146, 0.0, + -0.971788, 0.175535, 0.157529, 0.0, -0.456027, 0.392629, 0.798675, 0.0, + -0.0104443, 0.521623, -0.853112, 0.0, -0.660575, -0.74519, 0.091282, 0.0, + -0.0157698, -0.307475, -0.951425, 0.0, -0.603467, -0.250192, 0.757121, 0.0, + 0.506876, 0.25006, 0.824952, 0.0, 0.255404, 0.966794, 0.00884498, 0.0, + 0.466764, -0.874228, -0.133625, 0.0, 0.475077, -0.0682351, -0.877295, 0.0, + -0.224967, -0.938972, -0.260233, 0.0, -0.377929, -0.814757, -0.439705, 0.0, + -0.305847, 0.542333, -0.782517, 0.0, 0.26658, -0.902905, -0.337191, 0.0, + 0.0275773, 0.322158, -0.946284, 0.0, 0.0185422, 0.716349, 0.697496, 0.0, + -0.20483, 0.978416, 0.0273371, 0.0, -0.898276, 0.373969, 0.230752, 0.0, + -0.00909378, 0.546594, 0.837349, 0.0, 0.6602, -0.751089, 0.000959236, 0.0, + 0.855301, -0.303056, 0.420259, 0.0, 0.797138, 0.0623013, -0.600574, 0.0, + 0.48947, -0.866813, 0.0951509, 0.0, 0.251142, 0.674531, 0.694216, 0.0, + -0.578422, -0.737373, -0.348867, 0.0, -0.254689, -0.514807, 0.818601, 0.0, + 0.374972, 0.761612, 0.528529, 0.0, 0.640303, -0.734271, -0.225517, 0.0, + -0.638076, 0.285527, 0.715075, 0.0, 0.772956, -0.15984, -0.613995, 0.0, + 0.798217, -0.590628, 0.118356, 0.0, -0.986276, -0.0578337, -0.154644, 0.0, + -0.312988, -0.94549, 0.0899272, 0.0, -0.497338, 0.178325, 0.849032, 0.0, + -0.101136, -0.981014, 0.165477, 0.0, -0.521688, 0.0553434, -0.851339, 0.0, + -0.786182, -0.583814, 0.202678, 0.0, -0.565191, 0.821858, -0.0714658, 0.0, + 0.437895, 0.152598, -0.885981, 0.0, -0.92394, 0.353436, -0.14635, 0.0, + 0.212189, -0.815162, -0.538969, 0.0, -0.859262, 0.143405, -0.491024, 0.0, + 0.991353, 0.112814, 0.0670273, 0.0, 0.0337884, -0.979891, -0.196654, 0.0 + }; + + #endregion + + #region Methods + + internal static double GradientCoherentNoise3D(double x, double y, double z, long seed, QualityMode quality) + { + var x0 = x > 0.0 ? (int) x : (int) x - 1; + var x1 = x0 + 1; + var y0 = y > 0.0 ? (int) y : (int) y - 1; + var y1 = y0 + 1; + var z0 = z > 0.0 ? (int) z : (int) z - 1; + var z1 = z0 + 1; + double xs = 0, ys = 0, zs = 0; + switch (quality) + { + case QualityMode.Low: + { + xs = (x - x0); + ys = (y - y0); + zs = (z - z0); + break; + } + case QualityMode.Medium: + { + xs = MapCubicSCurve(x - x0); + ys = MapCubicSCurve(y - y0); + zs = MapCubicSCurve(z - z0); + break; + } + case QualityMode.High: + { + xs = MapQuinticSCurve(x - x0); + ys = MapQuinticSCurve(y - y0); + zs = MapQuinticSCurve(z - z0); + break; + } + } + var n0 = GradientNoise3D(x, y, z, x0, y0, z0, seed); + var n1 = GradientNoise3D(x, y, z, x1, y0, z0, seed); + var ix0 = InterpolateLinear(n0, n1, xs); + n0 = GradientNoise3D(x, y, z, x0, y1, z0, seed); + n1 = GradientNoise3D(x, y, z, x1, y1, z0, seed); + var ix1 = InterpolateLinear(n0, n1, xs); + var iy0 = InterpolateLinear(ix0, ix1, ys); + n0 = GradientNoise3D(x, y, z, x0, y0, z1, seed); + n1 = GradientNoise3D(x, y, z, x1, y0, z1, seed); + ix0 = InterpolateLinear(n0, n1, xs); + n0 = GradientNoise3D(x, y, z, x0, y1, z1, seed); + n1 = GradientNoise3D(x, y, z, x1, y1, z1, seed); + ix1 = InterpolateLinear(n0, n1, xs); + var iy1 = InterpolateLinear(ix0, ix1, ys); + return InterpolateLinear(iy0, iy1, zs); + } + + internal static double GradientNoise3D(double fx, double fy, double fz, int ix, int iy, int iz, long seed) + { + var i = (GeneratorNoiseX * ix + GeneratorNoiseY * iy + GeneratorNoiseZ * iz + + GeneratorSeed * seed) & 0xffffffff; + i ^= (i >> GeneratorShift); + i &= 0xff; + var xvg = Randoms[(i << 2)]; + var yvg = Randoms[(i << 2) + 1]; + var zvg = Randoms[(i << 2) + 2]; + var xvp = (fx - ix); + var yvp = (fy - iy); + var zvp = (fz - iz); + return ((xvg * xvp) + (yvg * yvp) + (zvg * zvp)) * 2.12; + } + + internal static double InterpolateCubic(double a, double b, double c, double d, double position) + { + var p = (d - c) - (a - b); + var q = (a - b) - p; + var r = c - a; + var s = b; + return p * position * position * position + q * position * position + r * position + s; + } + + internal static double InterpolateLinear(double a, double b, double position) + { + return ((1.0 - position) * a) + (position * b); + } + + internal static double MakeInt32Range(double value) + { + if (value >= 1073741824.0) + { + return (2.0 * Math.IEEERemainder(value, 1073741824.0)) - 1073741824.0; + } + if (value <= -1073741824.0) + { + return (2.0 * Math.IEEERemainder(value, 1073741824.0)) + 1073741824.0; + } + return value; + } + + internal static double MapCubicSCurve(double value) + { + return (value * value * (3.0 - 2.0 * value)); + } + + internal static double MapQuinticSCurve(double value) + { + var a3 = value * value * value; + var a4 = a3 * value; + var a5 = a4 * value; + return (6.0 * a5) - (15.0 * a4) + (10.0 * a3); + } + + internal static double ValueNoise3D(int x, int y, int z, int seed) + { + return 1.0 - (ValueNoise3DInt(x, y, z, seed) / 1073741824.0); + } + + internal static long ValueNoise3DInt(int x, int y, int z, int seed) + { + long n = (GeneratorNoiseX * x + GeneratorNoiseY * y + GeneratorNoiseZ * z + + GeneratorSeed * seed) & 0x7fffffff; + n = (n >> 13) ^ n; + return (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; + } + + #endregion + } +}
\ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Utils.cs.meta b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Utils.cs.meta new file mode 100644 index 00000000..111818ca --- /dev/null +++ b/Other/NodeEditorExamples/Assets/Examples/LibNoiseEditor/Plugins/LibNoise/Utils.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 1 +guid: 32fa019161d9a4cd3b1a9173943428f3 |