add noise generation module to nodes!
@@ -194,6 +194,7 @@ add_subdirectory (src/external/framelesshelper)
|
||||
add_subdirectory (src/external/qtimgui)
|
||||
add_subdirectory (src/external/QtAdvancedDockingSystem)
|
||||
add_subdirectory (src/external/NodeEditor)
|
||||
add_subdirectory (src/external/libnoise)
|
||||
|
||||
# Add the found include directories to our include list.
|
||||
include_directories (SYSTEM "${CMAKE_SOURCE_DIR}/include/")
|
||||
@@ -229,6 +230,7 @@ INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/PNG2BLP/pngpp" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/PNG2BLP/zlib" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/imguizmo" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/imguipiemenu" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/external/libnoise/src" )
|
||||
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||
|
||||
COLLECT_FILES(false noggit_root_sources src/noggit .cpp)
|
||||
@@ -338,6 +340,8 @@ TARGET_LINK_LIBRARIES (noggit
|
||||
qt_imgui_widgets
|
||||
qtadvanceddocking
|
||||
nodes
|
||||
noise-static
|
||||
noiseutils-static
|
||||
)
|
||||
|
||||
set (_noggit_revision_output_dir "${CMAKE_BINARY_DIR}/revision_output")
|
||||
|
||||
24
src/external/libnoise/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Binaries
|
||||
build/
|
||||
|
||||
# Generated cmake files
|
||||
CMakeFiles/
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
doc/CMakeFiles/
|
||||
doc/Makefile
|
||||
doc/cmake_install.cmake
|
||||
src/CMakeFiles/
|
||||
src/Makefile
|
||||
src/cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
install_manifest.txt
|
||||
|
||||
# Output files
|
||||
src/libnoise.a
|
||||
src/libnoise.dylib
|
||||
|
||||
# Output Documentation
|
||||
doc/Doxyfile
|
||||
doc/html
|
||||
|
||||
5
src/external/libnoise/AUTHORS.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
Authors:
|
||||
* Jason Bevins <jlbezigvins@gmzigail.com> (for great email, take off every 'zig'.)
|
||||
|
||||
contributor:
|
||||
* Joachim Schiele <js@lastlog.de>, wrote the cmake system
|
||||
27
src/external/libnoise/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# http://www.linux-magazin.de/Heft-Abo/Ausgaben/2007/02/Mal-ausspannen
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
set ( LIBNOISE_VERSION "1.0.0-cmake" )
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries for libnoise" OFF)
|
||||
option(BUILD_LIBNOISE_DOCUMENTATION "Create doxygen documentation for developers" OFF)
|
||||
option(BUILD_LIBNOISE_UTILS "Build utility functions for use with libnoise" ON)
|
||||
option(BUILD_LIBNOISE_EXAMPLES "Build libnoise examples" ON)
|
||||
|
||||
message(STATUS "CMAKE_INSTALL_BINDIR : " ${CMAKE_INSTALL_BINDIR})
|
||||
message(STATUS "CMAKE_INSTALL_LIBDIR : " ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if (BUILD_LIBNOISE_UTILS)
|
||||
add_subdirectory(noiseutils)
|
||||
endif()
|
||||
|
||||
if (BUILD_LIBNOISE_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
add_subdirectory(doc)
|
||||
|
||||
#add_subdirectory(samples)
|
||||
17
src/external/libnoise/HISTORY.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
2010-11-29
|
||||
* fixed some doxygen specific issue, thanks to Max Bolingbroke. now libnoise compiles in:
|
||||
- gentoo linux (according to me: 32 and 64 bit runtimes)
|
||||
- mac os x, using macports (according to Max Bolingbroke)
|
||||
|
||||
2009-11-29
|
||||
* there is some license problem: the library uses the LGPL 2.1 and the examples (on the download page use GPL v2)
|
||||
but the zip file with example sources included uses also LGPL 2.1 license?!
|
||||
* basic doxygen support is there
|
||||
* wrote 'make install' step using cmake
|
||||
* WARNING: src/win32/ is not used at all, maybe someone has to test this with win32 ...
|
||||
and i removed thse win32 files from the distribution, maybe someone want's to have them back?
|
||||
* changed the library #include "noise.h" instead of "noise/noise.h"
|
||||
there is no /include directory anymore since one must use src/ as include path now
|
||||
which will the be searched for "noise.h" now
|
||||
* cmake: created a CMakeList.txt which builds the .so and .a file
|
||||
* removed static Makefiles and libtool but keep compatibility to existing projects working
|
||||
504
src/external/libnoise/LICENSE.md
vendored
Normal file
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
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 this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. 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 not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the 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
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY 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
|
||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey 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 library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
72
src/external/libnoise/README.md
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
> My personal fork was to use this alongside a native plugin for the Unity game engine. It is still licensed under the LGPL as before. Primarily, I made some modifications to allow compiling to a Windows x64 DLL.
|
||||
|
||||
libnoise
|
||||
========
|
||||
|
||||
This is a fork of libnoise which includes noiseutils in the building and installing process.
|
||||
It also contains FindLibNoise.cmake
|
||||
|
||||
> This is a fork of libnoise which changes the build system from static Makefiles to cmake.
|
||||
|
||||
A portable, open-source, coherent noise-generating library for C++
|
||||
|
||||
libnoise is a portable C++ library that is used to generate coherent noise, a type of smoothly-changing noise.
|
||||
libnoise can generate Perlin noise, ridged multifractal noise, and other types of coherent-noise.
|
||||
|
||||
Coherent noise is often used by graphics programmers to generate natural-looking textures, planetary terrain,
|
||||
and other things. The mountain scene shown above was rendered in Terragen with a terrain file generated by libnoise.
|
||||
You can also view some other examples of what libnoise can do.
|
||||
|
||||
In libnoise, coherent-noise generators are encapsulated in classes called noise modules.
|
||||
There are many different types of noise modules. Some noise modules can combine or modify the outputs
|
||||
of other noise modules in various ways; you can join these modules together to generate very complex coherent noise.
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
cmake supports 'out of source' builds by default, to use it do this:
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
this should create everything into the `build/` directory
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
this is covered by cmake:
|
||||
|
||||
```shell
|
||||
make install
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
see examples for details but in general:
|
||||
|
||||
1. you need to supply the library `-lnoise` to the linker
|
||||
2. the includes to the compile with `-I /usr/include/noise`
|
||||
|
||||
OR
|
||||
|
||||
Use provided FindLibNoise.cmake
|
||||
|
||||
A comment on performance
|
||||
------------------------
|
||||
|
||||
Using compiler optimizations for libnoise is *strongly recommended*. Using the
|
||||
unoptimized library is roughly a fifth as fast as using -O3 on my test
|
||||
computer.
|
||||
|
||||
this cmake build by default (if not in developer mode) will build with `-O3`
|
||||
|
||||
|
||||
see:
|
||||
CMAKE_BUILD_TYPE
|
||||
|
||||
Type of build (Debug, Release, ...)
|
||||
69
src/external/libnoise/cmake/Modules/FindLibNoise.cmake
vendored
Executable file
@@ -0,0 +1,69 @@
|
||||
# Locate libnoise.
|
||||
# This module defines
|
||||
# LIBNOISE_LIBRARIES
|
||||
# LIBNOISE_FOUND, if false, do not try to link to libnoise
|
||||
# LIBNOISE_INCLUDE_DIR, where to find the headers
|
||||
|
||||
FIND_PATH(LIBNOISE_INCLUDE_DIR noise.h
|
||||
$ENV{LIBNOISE_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
FIND_PATH(LIBNOISE_INCLUDE_DIR "noise.h"
|
||||
PATHS
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
~/Library/Frameworks/noise/Headers
|
||||
/Library/Frameworks/noise/Headers
|
||||
/usr/local/include/noise
|
||||
/usr/local/include/noise
|
||||
/usr/local/include
|
||||
/usr/include/noise
|
||||
/usr/include/noise
|
||||
/usr/include
|
||||
/sw/include/noise
|
||||
/sw/include/noise
|
||||
/sw/include # Fink
|
||||
/opt/local/include/noise
|
||||
/opt/local/include/noise
|
||||
/opt/local/include # DarwinPorts
|
||||
/opt/csw/include/noise
|
||||
/opt/csw/include/noise
|
||||
/opt/csw/include # Blastwave
|
||||
/opt/include/noise
|
||||
/opt/include/noise
|
||||
/opt/include
|
||||
PATH_SUFFIXES noise
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LIBNOISE_LIBRARIES
|
||||
NAMES libnoise noise libnoiseutils noiseutils
|
||||
PATHS
|
||||
$ENV{LIBNOISE_DIR}
|
||||
NO_DEFAULT_PATH
|
||||
PATH_SUFFIXES lib64 lib so
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LIBNOISE_LIBRARIES
|
||||
NAMES libnoise noise libnoiseutils noiseutils
|
||||
PATHS
|
||||
${CMAKE_SOURCE_DIR}/lib
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
/usr/freeware
|
||||
PATH_SUFFIXES lib64 lib so
|
||||
)
|
||||
|
||||
message("LIBNOISE_INCLUDE_DIR: ${LIBNOISE_INCLUDE_DIR}")
|
||||
|
||||
SET(LIBNOISE_FOUND "NO")
|
||||
IF(LIBNOISE_LIBRARY AND LIBNOISE_INCLUDE_DIR)
|
||||
SET(LIBNOISE_FOUND "YES")
|
||||
ENDIF(LIBNOISE_LIBRARY AND LIBNOISE_INCLUDE_DIR)
|
||||
|
||||
55
src/external/libnoise/doc/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# many thanks go to Philippe Poilbarbe for writing the code this file is based on
|
||||
# http://www.cmake.org/pipermail/cmake/2006-August/010794.html
|
||||
#
|
||||
# much later i also found this:
|
||||
# http://tobias.rautenkranz.ch/cmake/doxygen/
|
||||
# but it is hard to understand...
|
||||
|
||||
IF (BUILD_LIBNOISE_DOCUMENTATION)
|
||||
|
||||
FIND_PACKAGE(Doxygen)
|
||||
|
||||
IF(DOXYGEN_FOUND)
|
||||
SET(DOXYGEN_LANGUAGE "English" CACHE STRING "Language used by doxygen")
|
||||
MARK_AS_ADVANCED(DOXYGEN_LANGUAGE)
|
||||
|
||||
# you could also set the version with this, see Doxygen.in
|
||||
# there you will find a line like this:
|
||||
# PROJECT_NUMBER = @LIBNOISE_VERSION@
|
||||
# @LIBNOISE_VERSION@ is then replaced by our global LIBNOISE_VERSION
|
||||
#
|
||||
# for instance you could uncomment the next 3 lines and change the version for testing
|
||||
# SET(LIBNOISE_VERSION
|
||||
# "1.2.3-foo500"
|
||||
# )
|
||||
|
||||
# doxygen can reference external images with IMAGE_PATH, this is how we set it dynamically
|
||||
SET( CMAKE_DOXYGEN_IMAGE_PATH
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/img"
|
||||
)
|
||||
|
||||
# doxygen searches for source code (defined in FILE_PATTERNS, for example: *.cpp *.h)
|
||||
# with DOXYGEN_SOURCE_DIR we fill a list of directories and later we write it into
|
||||
# the Doxyfile with a REGEX REPLACE (see below)
|
||||
SET( DOXYGEN_SOURCE_DIR
|
||||
"${CMAKE_SOURCE_DIR}/src"
|
||||
)
|
||||
|
||||
SET(DOXYGEN_OUTPUT_DIR html)
|
||||
STRING(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${DOXYGEN_SOURCE_DIR}")
|
||||
|
||||
CONFIGURE_FILE(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||
SET(HTML_TARGET "html" )
|
||||
|
||||
ADD_CUSTOM_TARGET(${HTML_TARGET} ALL
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||
|
||||
INSTALL( DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/" DESTINATION "/usr/share/doc/libnoise-${LIBNOISE_VERSION}" )
|
||||
|
||||
ELSE(DOXYGEN_FOUND)
|
||||
MESSAGE (FATAL_ERROR "doxygen binary couldn't be found")
|
||||
ENDIF(DOXYGEN_FOUND)
|
||||
|
||||
ENDIF (BUILD_LIBNOISE_DOCUMENTATION)
|
||||
|
||||
216
src/external/libnoise/doc/Doxyfile.in
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
# Doxyfile 1.3.9.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = libnoise
|
||||
PROJECT_NUMBER = @LIBNOISE_VERSION@
|
||||
OUTPUT_DIRECTORY = .
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = YES
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 2
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = NO
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = @CMAKE_DOXYGEN_INPUT_LIST@
|
||||
FILE_PATTERNS = *.cpp *.h
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH = @CMAKE_DOXYGEN_IMAGE_PATH@
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
# this code is needed if you want to build this doxygen docu for a static wep page as http://libnoise.sourceforge.net/
|
||||
#HTML_HEADER = htmldata/templateheader.html
|
||||
#HTML_FOOTER = htmldata/templatefooter.html
|
||||
#HTML_STYLESHEET = htmldata/doxygen.css
|
||||
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 8
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = NO
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
16
src/external/libnoise/doc/README.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
Building doco
|
||||
-------------
|
||||
|
||||
Run doxygen from this directory.
|
||||
|
||||
Copy the following files from the htmldata into the html subdirectory:
|
||||
|
||||
* background.png
|
||||
* doxygen.css
|
||||
* libnoise.png
|
||||
|
||||
The HTML documentation contains custom headers and footers that require
|
||||
certain image files to exist in the html subdirectory. I don't know how to
|
||||
get doxygen to copy these files automagically.
|
||||
|
||||
-- jas
|
||||
BIN
src/external/libnoise/doc/htmldata/background.png
vendored
Normal file
|
After Width: | Height: | Size: 187 B |
249
src/external/libnoise/doc/htmldata/doxygen.css
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
body
|
||||
{
|
||||
background-color: #99cccc;
|
||||
background-image: url(background.png);
|
||||
display: block;
|
||||
font-family: verdana,helvetica,sans-serif;
|
||||
font-size: 10pt;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: 70em;
|
||||
}
|
||||
|
||||
img
|
||||
{
|
||||
background-color: white;
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
span.header
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
table.layout
|
||||
{
|
||||
border-collapse: collapse;
|
||||
border-style: none;
|
||||
border-width: 0px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td.header
|
||||
{
|
||||
background-color: white;
|
||||
background-repeat: no-repeat;
|
||||
padding: 6pt;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
td.sidebar
|
||||
{
|
||||
background-color: #99cccc;
|
||||
border-color: #669999;
|
||||
border-style: none;
|
||||
border-width: 0px;
|
||||
padding: 3pt;
|
||||
vertical-align: top;
|
||||
width: 18em;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
td.sidebar a:hover
|
||||
{
|
||||
color: red;
|
||||
}
|
||||
|
||||
td.content
|
||||
{
|
||||
background-color: white;
|
||||
vertical-align: top;
|
||||
padding: 6pt;
|
||||
}
|
||||
|
||||
td.footer
|
||||
{
|
||||
background-color: white;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
ul.toc
|
||||
{
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
td.content img
|
||||
{
|
||||
padding: 4pt;
|
||||
}
|
||||
|
||||
div.fragment
|
||||
{
|
||||
background-color: #ddeeee;
|
||||
border-color: #996666;
|
||||
border-style: dashed;
|
||||
border-width: 1px;
|
||||
font-family: monospace;
|
||||
padding: 8pt;
|
||||
margin: 8pt;
|
||||
margin-left: 24pt;
|
||||
}
|
||||
|
||||
td {
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
caption
|
||||
{
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
a.qindex
|
||||
{
|
||||
}
|
||||
|
||||
a.qindexRef
|
||||
{
|
||||
}
|
||||
|
||||
a.el
|
||||
{
|
||||
text-decoration: none;
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
a.elRef
|
||||
{
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
a.code
|
||||
{
|
||||
text-decoration: none;
|
||||
font-weight: normal;
|
||||
color: #4444ee
|
||||
}
|
||||
|
||||
a.codeRef
|
||||
{
|
||||
font-weight: normal;
|
||||
color: #4444ee
|
||||
}
|
||||
|
||||
dl.el
|
||||
{
|
||||
margin-left: -1cm
|
||||
}
|
||||
|
||||
div.ah
|
||||
{
|
||||
background-color: black;
|
||||
font-weight: bold;
|
||||
color: #ffffff;
|
||||
margin-bottom: 3px;
|
||||
margin-top: 3px
|
||||
}
|
||||
|
||||
div.groupHeader
|
||||
{
|
||||
margin-left: 16px;
|
||||
margin-top: 12px;
|
||||
margin-bottom: 6px;
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
div.groupText
|
||||
{
|
||||
margin-left: 16px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
td.indexkey
|
||||
{
|
||||
background-color: #ddeeee;
|
||||
font-weight: bold;
|
||||
padding-right: 10px;
|
||||
padding-top: 2px;
|
||||
padding-left: 10px;
|
||||
padding-bottom: 2px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 2px
|
||||
}
|
||||
|
||||
td.indexvalue
|
||||
{
|
||||
background-color: #ddeeee;
|
||||
font-style: italic;
|
||||
padding-right: 10px;
|
||||
padding-top: 2px;
|
||||
padding-left: 10px;
|
||||
padding-bottom: 2px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
margin-top: 2px;
|
||||
margin-bottom: 2px
|
||||
}
|
||||
|
||||
td.md
|
||||
{
|
||||
background-color: #ddeeee;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td.mdname1
|
||||
{
|
||||
background-color: #ddeeee;
|
||||
font-weight: bold;
|
||||
color: #602020;
|
||||
}
|
||||
|
||||
td.mdname
|
||||
{
|
||||
background-color: #ddeeee;
|
||||
font-weight: bold;
|
||||
color: #602020;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
span.keyword
|
||||
{
|
||||
color: #008000
|
||||
}
|
||||
|
||||
span.keywordtype
|
||||
{
|
||||
color: #604020
|
||||
}
|
||||
|
||||
span.keywordflow
|
||||
{
|
||||
color: #e08000
|
||||
}
|
||||
|
||||
span.comment
|
||||
{
|
||||
color: #800000
|
||||
}
|
||||
|
||||
span.preprocessor
|
||||
{
|
||||
color: #806020
|
||||
}
|
||||
|
||||
span.stringliteral
|
||||
{
|
||||
color: #002080
|
||||
}
|
||||
|
||||
span.charliteral
|
||||
{
|
||||
color: #008080
|
||||
}
|
||||
BIN
src/external/libnoise/doc/htmldata/libnoise.png
vendored
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
19
src/external/libnoise/doc/htmldata/templatefooter.html
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<!-- end rich gooey content -->
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='footer' colspan='2'>
|
||||
<p>
|
||||
© 2003-2005 Jason Bevins
|
||||
</p>
|
||||
<p>
|
||||
<a href='http://www.doxygen.org/'><img src='doxygen.png' alt='Doxygen logo'></a>
|
||||
<br>
|
||||
The libnoise source documentation was generated by <a href='http://www.doxygen.org/'>doxygen</a> 1.3.9.1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
99
src/external/libnoise/doc/htmldata/templateheader.html
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>libnoise: Documentation</title>
|
||||
<link rel='stylesheet' type='text/css' href='doxygen.css'>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>
|
||||
</head>
|
||||
<body>
|
||||
<table class='layout'>
|
||||
<tr>
|
||||
<td class='sidebar' rowspan='2'>
|
||||
<p>
|
||||
Navigation menu
|
||||
</p>
|
||||
<ul class='toc'>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/index.html'>Main</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/downloads/index.html'>Downloads</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/coherentnoise/index.html'>What is coherent noise?</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/noisegen/index.html'>Generating coherent noise</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/glossary/index.html'>Glossary</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/examples/index.html'>Examples</a>
|
||||
<ul class='toc'>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/examples/textures/index.html'>Procedural textures</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/examples/complexplanet/index.html'>Complex planetary surface</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/examples/worms/index.html'>Perlin worms</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<strong>Docs</strong>
|
||||
</li>
|
||||
<li>
|
||||
<a href='tutorials/index.html'>Tutorials</a>
|
||||
<ul class='toc'>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/tutorials/tutorial1.html'>Tutorial 1</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/tutorials/tutorial2.html'>Tutorial 2</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/tutorials/tutorial3.html'>Tutorial 3</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/tutorials/tutorial4.html'>Tutorial 4</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/tutorials/tutorial5.html'>Tutorial 5</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/tutorials/tutorial6.html'>Tutorial 6</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/tutorials/tutorial7.html'>Tutorial 7</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/tutorials/tutorial8.html'>Tutorial 8</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/cvs/index.html'>CVS</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='http://libnoise.sourceforge.net/links/index.html'>Links</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td class='header'>
|
||||
<p>
|
||||
<img src='libnoise.png' alt='libnoise logo'>
|
||||
</p>
|
||||
<p>
|
||||
A portable, open-source, coherent noise-generating library for C++
|
||||
</p>
|
||||
<hr>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='content'>
|
||||
|
||||
<!-- start rich gooey content -->
|
||||
BIN
src/external/libnoise/doc/img/curve.png
vendored
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
src/external/libnoise/doc/img/gradientcolor.png
vendored
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/external/libnoise/doc/img/modelcylinder.png
vendored
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
src/external/libnoise/doc/img/modelsphere.png
vendored
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
src/external/libnoise/doc/img/moduleabs.png
vendored
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
src/external/libnoise/doc/img/moduleadd.png
vendored
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
src/external/libnoise/doc/img/modulebillow.png
vendored
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
src/external/libnoise/doc/img/moduleblend.png
vendored
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
src/external/libnoise/doc/img/modulecheckerboard.png
vendored
Normal file
|
After Width: | Height: | Size: 767 B |
BIN
src/external/libnoise/doc/img/moduleclamp.png
vendored
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/external/libnoise/doc/img/moduleconst.png
vendored
Normal file
|
After Width: | Height: | Size: 741 B |
BIN
src/external/libnoise/doc/img/modulecurve.png
vendored
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
src/external/libnoise/doc/img/modulecylinders.png
vendored
Normal file
|
After Width: | Height: | Size: 854 B |
BIN
src/external/libnoise/doc/img/moduledisplace.png
vendored
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
src/external/libnoise/doc/img/moduleexponent.png
vendored
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
src/external/libnoise/doc/img/moduleinvert.png
vendored
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
src/external/libnoise/doc/img/modulemax.png
vendored
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
src/external/libnoise/doc/img/modulemin.png
vendored
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
src/external/libnoise/doc/img/modulemultiply.png
vendored
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
src/external/libnoise/doc/img/moduleperlin.png
vendored
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
src/external/libnoise/doc/img/modulepower.png
vendored
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
src/external/libnoise/doc/img/moduleridgedmulti.png
vendored
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
src/external/libnoise/doc/img/modulerotatepoint.png
vendored
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
src/external/libnoise/doc/img/modulescalebias.png
vendored
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
src/external/libnoise/doc/img/modulescalepoint.png
vendored
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
src/external/libnoise/doc/img/moduleselect.png
vendored
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
src/external/libnoise/doc/img/modulespheres.png
vendored
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
src/external/libnoise/doc/img/moduleterrace.png
vendored
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
src/external/libnoise/doc/img/moduletranslatepoint.png
vendored
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
src/external/libnoise/doc/img/moduleturbulence.png
vendored
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
src/external/libnoise/doc/img/modulevoronoi.png
vendored
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/external/libnoise/doc/img/terrace.png
vendored
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
6
src/external/libnoise/examples/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
SET(PROJECT_NAME examples)
|
||||
|
||||
add_executable(complexplanet complexplanet.cpp)
|
||||
ADD_DEFINITIONS( "-I${PROJECT_SOURCE_DIR}/src" )
|
||||
ADD_DEFINITIONS( "-I${PROJECT_SOURCE_DIR}/noiseutils" )
|
||||
target_link_libraries(complexplanet noiseutils-static noise-static)
|
||||
504
src/external/libnoise/examples/COPYING.txt
vendored
Normal file
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
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 this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. 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 not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the 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
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY 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
|
||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey 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 library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
1996
src/external/libnoise/examples/complexplanet.cpp
vendored
Normal file
4
src/external/libnoise/examples/readme.txt
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
libnoise examples - differences between 0.9.0 and 0.9.0.1
|
||||
|
||||
- Since the noiseutils library is part of the noise namespace, these
|
||||
examples now use that namespace.
|
||||
181
src/external/libnoise/examples/texturegranite.cpp
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
// texturegranite.cpp
|
||||
//
|
||||
// This program uses the libnoise library to generate texture maps consisting
|
||||
// of granite.
|
||||
//
|
||||
// Copyright (C) 2004 Jason Bevins
|
||||
//
|
||||
// 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 2 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
|
||||
// (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
// Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include <noise/noise.h>
|
||||
|
||||
#include "noiseutils.h"
|
||||
|
||||
using namespace noise;
|
||||
|
||||
// Height of the texture.
|
||||
const int TEXTURE_HEIGHT = 256;
|
||||
|
||||
// Creates the color gradients for the texture.
|
||||
void CreateTextureColor (utils::RendererImage& renderer);
|
||||
|
||||
// Given a noise module, this function renders a flat square texture map and
|
||||
// writes it to a Windows bitmap (*.bmp) file. Because the texture map is
|
||||
// square, its width is equal to its height. The texture map can be seamless
|
||||
// (tileable) or non-seamless.
|
||||
void CreatePlanarTexture (const module::Module& noiseModule, bool seamless,
|
||||
int height, const char* filename);
|
||||
|
||||
// Given a noise module, this function renders a spherical texture map and
|
||||
// writes it to a Windows bitmap (*.bmp) file. The texture map's width is
|
||||
// double its height.
|
||||
void CreateSphericalTexture (const module::Module& noiseModule, int height,
|
||||
const char* filename);
|
||||
|
||||
// Given a noise map, this function renders a texture map and writes it to a
|
||||
// Windows bitmap (*.bmp) file.
|
||||
void RenderTexture (const utils::NoiseMap& noiseMap,
|
||||
const char* filename);
|
||||
|
||||
int main ()
|
||||
{
|
||||
// Primary granite texture. This generates the "roughness" of the texture
|
||||
// when lit by a light source.
|
||||
module::Billow primaryGranite;
|
||||
primaryGranite.SetSeed (0);
|
||||
primaryGranite.SetFrequency (8.0);
|
||||
primaryGranite.SetPersistence (0.625);
|
||||
primaryGranite.SetLacunarity (2.18359375);
|
||||
primaryGranite.SetOctaveCount (6);
|
||||
primaryGranite.SetNoiseQuality (QUALITY_STD);
|
||||
|
||||
// Use Voronoi polygons to produce the small grains for the granite texture.
|
||||
module::Voronoi baseGrains;
|
||||
baseGrains.SetSeed (1);
|
||||
baseGrains.SetFrequency (16.0);
|
||||
baseGrains.EnableDistance (true);
|
||||
|
||||
// Scale the small grain values so that they may be added to the base
|
||||
// granite texture. Voronoi polygons normally generate pits, so apply a
|
||||
// negative scaling factor to produce bumps instead.
|
||||
module::ScaleBias scaledGrains;
|
||||
scaledGrains.SetSourceModule (0, baseGrains);
|
||||
scaledGrains.SetScale (-0.5);
|
||||
scaledGrains.SetBias (0.0);
|
||||
|
||||
// Combine the primary granite texture with the small grain texture.
|
||||
module::Add combinedGranite;
|
||||
combinedGranite.SetSourceModule (0, primaryGranite);
|
||||
combinedGranite.SetSourceModule (1, scaledGrains);
|
||||
|
||||
// Finally, perturb the granite texture to add realism.
|
||||
module::Turbulence finalGranite;
|
||||
finalGranite.SetSourceModule (0, combinedGranite);
|
||||
finalGranite.SetSeed (2);
|
||||
finalGranite.SetFrequency (4.0);
|
||||
finalGranite.SetPower (1.0 / 8.0);
|
||||
finalGranite.SetRoughness (6);
|
||||
|
||||
// Given the granite noise module, create a non-seamless texture map, a
|
||||
// seamless texture map, and a spherical texture map.
|
||||
CreatePlanarTexture (finalGranite, false, TEXTURE_HEIGHT,
|
||||
"textureplane.bmp");
|
||||
CreatePlanarTexture (finalGranite, true, TEXTURE_HEIGHT,
|
||||
"textureseamless.bmp");
|
||||
CreateSphericalTexture (finalGranite, TEXTURE_HEIGHT,
|
||||
"texturesphere.bmp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CreateTextureColor (utils::RendererImage& renderer)
|
||||
{
|
||||
// Create a gray granite palette. Black and pink appear at either ends of
|
||||
// the palette; those colors provide the charactistic black and pink flecks
|
||||
// in granite.
|
||||
renderer.ClearGradient ();
|
||||
renderer.AddGradientPoint (-1.0000, utils::Color ( 0, 0, 0, 255));
|
||||
renderer.AddGradientPoint (-0.9375, utils::Color ( 0, 0, 0, 255));
|
||||
renderer.AddGradientPoint (-0.8750, utils::Color (216, 216, 242, 255));
|
||||
renderer.AddGradientPoint ( 0.0000, utils::Color (191, 191, 191, 255));
|
||||
renderer.AddGradientPoint ( 0.5000, utils::Color (210, 116, 125, 255));
|
||||
renderer.AddGradientPoint ( 0.7500, utils::Color (210, 113, 98, 255));
|
||||
renderer.AddGradientPoint ( 1.0000, utils::Color (255, 176, 192, 255));
|
||||
}
|
||||
|
||||
void CreatePlanarTexture (const module::Module& noiseModule, bool seamless,
|
||||
int height, const char* filename)
|
||||
{
|
||||
// Map the output values from the noise module onto a plane. This will
|
||||
// create a two-dimensional noise map which can be rendered as a flat
|
||||
// texture map.
|
||||
utils::NoiseMapBuilderPlane plane;
|
||||
utils::NoiseMap noiseMap;
|
||||
plane.SetBounds (-1.0, 1.0, -1.0, 1.0);
|
||||
plane.SetDestSize (height, height);
|
||||
plane.SetSourceModule (noiseModule);
|
||||
plane.SetDestNoiseMap (noiseMap);
|
||||
plane.EnableSeamless (seamless);
|
||||
plane.Build ();
|
||||
|
||||
RenderTexture (noiseMap, filename);
|
||||
}
|
||||
|
||||
void CreateSphericalTexture (const module::Module& noiseModule, int height,
|
||||
const char* filename)
|
||||
{
|
||||
// Map the output values from the noise module onto a sphere. This will
|
||||
// create a two-dimensional noise map which can be rendered as a spherical
|
||||
// texture map.
|
||||
utils::NoiseMapBuilderSphere sphere;
|
||||
utils::NoiseMap noiseMap;
|
||||
sphere.SetBounds (-90.0, 90.0, -180.0, 180.0); // degrees
|
||||
sphere.SetDestSize (height * 2, height);
|
||||
sphere.SetSourceModule (noiseModule);
|
||||
sphere.SetDestNoiseMap (noiseMap);
|
||||
sphere.Build ();
|
||||
|
||||
RenderTexture (noiseMap, filename);
|
||||
}
|
||||
|
||||
void RenderTexture (const utils::NoiseMap& noiseMap, const char* filename)
|
||||
{
|
||||
// Create the color gradients for the texture.
|
||||
utils::RendererImage textureRenderer;
|
||||
CreateTextureColor (textureRenderer);
|
||||
|
||||
// Set up us the texture renderer and pass the noise map to it.
|
||||
utils::Image destTexture;
|
||||
textureRenderer.SetSourceNoiseMap (noiseMap);
|
||||
textureRenderer.SetDestImage (destTexture);
|
||||
textureRenderer.EnableLight (true);
|
||||
textureRenderer.SetLightAzimuth (135.0);
|
||||
textureRenderer.SetLightElev (60.0);
|
||||
textureRenderer.SetLightContrast (2.0);
|
||||
textureRenderer.SetLightColor (utils::Color (255, 255, 255, 0));
|
||||
|
||||
// Render the texture.
|
||||
textureRenderer.Render ();
|
||||
|
||||
// Write the texture as a Windows bitmap file (*.bmp).
|
||||
utils::WriterBMP textureWriter;
|
||||
textureWriter.SetSourceImage (destTexture);
|
||||
textureWriter.SetDestFilename (filename);
|
||||
textureWriter.WriteDestFile ();
|
||||
}
|
||||
187
src/external/libnoise/examples/texturejade.cpp
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
// texturejade.cpp
|
||||
//
|
||||
// This program uses the libnoise library to generate texture maps consisting
|
||||
// of African jade.
|
||||
//
|
||||
// Copyright (C) 2004 Jason Bevins
|
||||
//
|
||||
// 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 2 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
|
||||
// (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
// Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include <noise/noise.h>
|
||||
|
||||
#include "noiseutils.h"
|
||||
|
||||
using namespace noise;
|
||||
|
||||
// Height of the texture.
|
||||
const int TEXTURE_HEIGHT = 256;
|
||||
|
||||
// Creates the color gradients for the texture.
|
||||
void CreateTextureColor (utils::RendererImage& renderer);
|
||||
|
||||
// Given a noise module, this function renders a flat square texture map and
|
||||
// writes it to a Windows bitmap (*.bmp) file. Because the texture map is
|
||||
// square, its width is equal to its height. The texture map can be seamless
|
||||
// (tileable) or non-seamless.
|
||||
void CreatePlanarTexture (const module::Module& noiseModule, bool seamless,
|
||||
int height, const char* filename);
|
||||
|
||||
// Given a noise module, this function renders a spherical texture map and
|
||||
// writes it to a Windows bitmap (*.bmp) file. The texture map's width is
|
||||
// double its height.
|
||||
void CreateSphericalTexture (const module::Module& noiseModule, int height,
|
||||
const char* filename);
|
||||
|
||||
// Given a noise map, this function renders a texture map and writes it to a
|
||||
// Windows bitmap (*.bmp) file.
|
||||
void RenderTexture (const utils::NoiseMap& noiseMap, const char* filename);
|
||||
|
||||
int main ()
|
||||
{
|
||||
// Primary jade texture. The ridges from the ridged-multifractal module
|
||||
// produces the veins.
|
||||
module::RidgedMulti primaryJade;
|
||||
primaryJade.SetSeed (0);
|
||||
primaryJade.SetFrequency (2.0);
|
||||
primaryJade.SetLacunarity (2.20703125);
|
||||
primaryJade.SetOctaveCount (6);
|
||||
primaryJade.SetNoiseQuality (QUALITY_STD);
|
||||
|
||||
// Base of the secondary jade texture. The base texture uses concentric
|
||||
// cylinders aligned on the z axis, which will eventually be perturbed.
|
||||
module::Cylinders baseSecondaryJade;
|
||||
baseSecondaryJade.SetFrequency (2.0);
|
||||
|
||||
// Rotate the base secondary jade texture so that the cylinders are not
|
||||
// aligned with any axis. This produces more variation in the secondary
|
||||
// jade texture since the texture is parallel to the y-axis.
|
||||
module::RotatePoint rotatedBaseSecondaryJade;
|
||||
rotatedBaseSecondaryJade.SetSourceModule (0, baseSecondaryJade);
|
||||
rotatedBaseSecondaryJade.SetAngles (90.0, 25.0, 5.0);
|
||||
|
||||
// Slightly perturb the secondary jade texture for more realism.
|
||||
module::Turbulence perturbedBaseSecondaryJade;
|
||||
perturbedBaseSecondaryJade.SetSourceModule (0, rotatedBaseSecondaryJade);
|
||||
perturbedBaseSecondaryJade.SetSeed (1);
|
||||
perturbedBaseSecondaryJade.SetFrequency (4.0);
|
||||
perturbedBaseSecondaryJade.SetPower (1.0 / 4.0);
|
||||
perturbedBaseSecondaryJade.SetRoughness (4);
|
||||
|
||||
// Scale the secondary jade texture so it contributes a small part to the
|
||||
// final jade texture.
|
||||
module::ScaleBias secondaryJade;
|
||||
secondaryJade.SetSourceModule (0, perturbedBaseSecondaryJade);
|
||||
secondaryJade.SetScale (0.25);
|
||||
secondaryJade.SetBias (0.0);
|
||||
|
||||
// Add the two jade textures together. These two textures were produced
|
||||
// using different combinations of coherent noise, so the final texture will
|
||||
// have a lot of variation.
|
||||
module::Add combinedJade;
|
||||
combinedJade.SetSourceModule (0, primaryJade);
|
||||
combinedJade.SetSourceModule (1, secondaryJade);
|
||||
|
||||
// Finally, perturb the combined jade textures to produce the final jade
|
||||
// texture. A low roughness produces nice veins.
|
||||
module::Turbulence finalJade;
|
||||
finalJade.SetSourceModule (0, combinedJade);
|
||||
finalJade.SetSeed (2);
|
||||
finalJade.SetFrequency (4.0);
|
||||
finalJade.SetPower (1.0 / 16.0);
|
||||
finalJade.SetRoughness (2);
|
||||
|
||||
// Given the jade noise module, create a non-seamless texture map, a
|
||||
// seamless texture map, and a spherical texture map.
|
||||
CreatePlanarTexture (finalJade, false, TEXTURE_HEIGHT,
|
||||
"textureplane.bmp");
|
||||
CreatePlanarTexture (finalJade, true, TEXTURE_HEIGHT,
|
||||
"textureseamless.bmp");
|
||||
CreateSphericalTexture (finalJade, TEXTURE_HEIGHT,
|
||||
"texturesphere.bmp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CreateTextureColor (utils::RendererImage& renderer)
|
||||
{
|
||||
// Create a nice jade palette.
|
||||
renderer.ClearGradient ();
|
||||
renderer.AddGradientPoint (-1.000, utils::Color ( 24, 146, 102, 255));
|
||||
renderer.AddGradientPoint ( 0.000, utils::Color ( 78, 154, 115, 255));
|
||||
renderer.AddGradientPoint ( 0.250, utils::Color (128, 204, 165, 255));
|
||||
renderer.AddGradientPoint ( 0.375, utils::Color ( 78, 154, 115, 255));
|
||||
renderer.AddGradientPoint ( 1.000, utils::Color ( 29, 135, 102, 255));
|
||||
}
|
||||
|
||||
void CreatePlanarTexture (const module::Module& noiseModule, bool seamless,
|
||||
int height, const char* filename)
|
||||
{
|
||||
// Map the output values from the noise module onto a plane. This will
|
||||
// create a two-dimensional noise map which can be rendered as a flat
|
||||
// texture map.
|
||||
utils::NoiseMapBuilderPlane plane;
|
||||
utils::NoiseMap noiseMap;
|
||||
plane.SetBounds (-1.0, 1.0, -1.0, 1.0);
|
||||
plane.SetDestSize (height, height);
|
||||
plane.SetSourceModule (noiseModule);
|
||||
plane.SetDestNoiseMap (noiseMap);
|
||||
plane.EnableSeamless (seamless);
|
||||
plane.Build ();
|
||||
|
||||
RenderTexture (noiseMap, filename);
|
||||
}
|
||||
|
||||
void CreateSphericalTexture (const module::Module& noiseModule, int height,
|
||||
const char* filename)
|
||||
{
|
||||
// Map the output values from the noise module onto a sphere. This will
|
||||
// create a two-dimensional noise map which can be rendered as a spherical
|
||||
// texture map.
|
||||
utils::NoiseMapBuilderSphere sphere;
|
||||
utils::NoiseMap noiseMap;
|
||||
sphere.SetBounds (-90.0, 90.0, -180.0, 180.0); // degrees
|
||||
sphere.SetDestSize (height * 2, height);
|
||||
sphere.SetSourceModule (noiseModule);
|
||||
sphere.SetDestNoiseMap (noiseMap);
|
||||
sphere.Build ();
|
||||
|
||||
RenderTexture (noiseMap, filename);
|
||||
}
|
||||
|
||||
void RenderTexture (const utils::NoiseMap& noiseMap, const char* filename)
|
||||
{
|
||||
// Create the color gradients for the texture.
|
||||
utils::RendererImage textureRenderer;
|
||||
CreateTextureColor (textureRenderer);
|
||||
|
||||
// Set up us the texture renderer and pass the noise map to it.
|
||||
utils::Image destTexture;
|
||||
textureRenderer.SetSourceNoiseMap (noiseMap);
|
||||
textureRenderer.SetDestImage (destTexture);
|
||||
textureRenderer.EnableLight (false);
|
||||
|
||||
// Render the texture.
|
||||
textureRenderer.Render ();
|
||||
|
||||
// Write the texture as a Windows bitmap file (*.bmp).
|
||||
utils::WriterBMP textureWriter;
|
||||
textureWriter.SetSourceImage (destTexture);
|
||||
textureWriter.SetDestFilename (filename);
|
||||
textureWriter.WriteDestFile ();
|
||||
}
|
||||
240
src/external/libnoise/examples/texturesky.cpp
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
// texturesky.cpp
|
||||
//
|
||||
// This program uses the libnoise library to generate texture maps consisting
|
||||
// of water overlayed with clouds of varying density.
|
||||
//
|
||||
// Copyright (C) 2004 Jason Bevins
|
||||
//
|
||||
// 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 2 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
|
||||
// (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
// Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include <noise/noise.h>
|
||||
|
||||
#include "noiseutils.h"
|
||||
|
||||
using namespace noise;
|
||||
|
||||
// Height of the texture.
|
||||
const int TEXTURE_HEIGHT = 256;
|
||||
|
||||
// Creates the color gradients for the texture.
|
||||
void CreateTextureColor (utils::RendererImage& renderer);
|
||||
|
||||
// Given two noise modules, this function renders two flat square texture maps
|
||||
// and combines them to form a Windows bitmap (*.bmp) file. Because the
|
||||
// texture map is square, its width is equal to its height. The final texture
|
||||
// map can be seamless (tileable) or non-seamless.
|
||||
void CreatePlanarTexture (const module::Module& lowerNoiseModule,
|
||||
const module::Module& upperNoiseModule, bool seamless, int height,
|
||||
const char* filename);
|
||||
|
||||
// Given two noise modules, this function renders two spherical texture maps
|
||||
// and combines them to form a Windows bitmap (*.bmp) file. The texture map's
|
||||
// width is double its height.
|
||||
void CreateSphericalTexture (const module::Module& lowerNoiseModule,
|
||||
const module::Module& upperNoiseModule, int height, const char* filename);
|
||||
|
||||
// Given two noise maps, this function renders two texture maps and combines
|
||||
// them to form a Windows bitmap (*.bmp) file.
|
||||
void RenderTexture (const utils::NoiseMap& lowerNoiseMap,
|
||||
const utils::NoiseMap& upperNoiseMap, const char* filename);
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main ()
|
||||
{
|
||||
// This texture map is made up two layers. The bottom layer is a wavy water
|
||||
// texture. The top layer is a cloud texture. These two layers are
|
||||
// combined together to create the final texture map.
|
||||
|
||||
// Lower layer: water texture
|
||||
// --------------------------
|
||||
|
||||
// Base of the water texture. The Voronoi polygons generate the waves. At
|
||||
// the center of the polygons, the values are at their lowest. At the edges
|
||||
// of the polygons, the values are at their highest. The values smoothly
|
||||
// change between the center and the edges of the polygons, producing a
|
||||
// wave-like effect.
|
||||
module::Voronoi baseWater;
|
||||
baseWater.SetSeed (0);
|
||||
baseWater.SetFrequency (8.0);
|
||||
baseWater.EnableDistance (true);
|
||||
baseWater.SetDisplacement (0.0);
|
||||
|
||||
// Stretch the waves along the z axis.
|
||||
module::ScalePoint baseStretchedWater;
|
||||
baseStretchedWater.SetSourceModule (0, baseWater);
|
||||
baseStretchedWater.SetScale (1.0, 1.0, 3.0);
|
||||
|
||||
// Smoothly perturb the water texture for more realism.
|
||||
module::Turbulence finalWater;
|
||||
finalWater.SetSourceModule (0, baseStretchedWater);
|
||||
finalWater.SetSeed (1);
|
||||
finalWater.SetFrequency (8.0);
|
||||
finalWater.SetPower (1.0 / 32.0);
|
||||
finalWater.SetRoughness (1);
|
||||
|
||||
// Upper layer: cloud texture
|
||||
// --------------------------
|
||||
|
||||
// Base of the cloud texture. The billowy noise produces the basic shape
|
||||
// of soft, fluffy clouds.
|
||||
module::Billow cloudBase;
|
||||
cloudBase.SetSeed (2);
|
||||
cloudBase.SetFrequency (2.0);
|
||||
cloudBase.SetPersistence (0.375);
|
||||
cloudBase.SetLacunarity (2.12109375);
|
||||
cloudBase.SetOctaveCount (4);
|
||||
cloudBase.SetNoiseQuality (QUALITY_BEST);
|
||||
|
||||
// Perturb the cloud texture for more realism.
|
||||
module::Turbulence finalClouds;
|
||||
finalClouds.SetSourceModule (0, cloudBase);
|
||||
finalClouds.SetSeed (3);
|
||||
finalClouds.SetFrequency (16.0);
|
||||
finalClouds.SetPower (1.0 / 64.0);
|
||||
finalClouds.SetRoughness (2);
|
||||
|
||||
// Given the water and cloud noise modules, create a non-seamless texture
|
||||
// map, a seamless texture map, and a spherical texture map.
|
||||
CreatePlanarTexture (finalWater, finalClouds, false, TEXTURE_HEIGHT,
|
||||
"textureplane.bmp");
|
||||
CreatePlanarTexture (finalWater, finalClouds, true, TEXTURE_HEIGHT,
|
||||
"textureseamless.bmp");
|
||||
CreateSphericalTexture (finalWater, finalClouds, TEXTURE_HEIGHT,
|
||||
"texturesphere.bmp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CreateTextureColorLayer1 (utils::RendererImage& renderer)
|
||||
{
|
||||
// Create a water palette with varying shades of blue.
|
||||
renderer.ClearGradient ();
|
||||
renderer.AddGradientPoint (-1.00, utils::Color ( 48, 64, 192, 255));
|
||||
renderer.AddGradientPoint ( 0.50, utils::Color ( 96, 192, 255, 255));
|
||||
renderer.AddGradientPoint ( 1.00, utils::Color (255, 255, 255, 255));
|
||||
}
|
||||
|
||||
void CreateTextureColorLayer2 (utils::RendererImage& renderer)
|
||||
{
|
||||
// Create an entirely white palette with varying alpha (transparency) values
|
||||
// for the clouds. These transparent values allows the water to show
|
||||
// through.
|
||||
renderer.ClearGradient ();
|
||||
renderer.AddGradientPoint (-1.00, utils::Color (255, 255, 255, 0));
|
||||
renderer.AddGradientPoint (-0.50, utils::Color (255, 255, 255, 0));
|
||||
renderer.AddGradientPoint ( 1.00, utils::Color (255, 255, 255, 255));
|
||||
}
|
||||
|
||||
void CreatePlanarTexture (const module::Module& lowerNoiseModule,
|
||||
const module::Module& upperNoiseModule, bool seamless, int height,
|
||||
const char* filename)
|
||||
{
|
||||
// Map the output values from both noise module onto two planes. This will
|
||||
// create two two-dimensional noise maps which can be rendered as two flat
|
||||
// texture maps.
|
||||
utils::NoiseMapBuilderPlane plane;
|
||||
utils::NoiseMap lowerNoiseMap;
|
||||
utils::NoiseMap upperNoiseMap;
|
||||
plane.SetBounds (-1.0, 1.0, -1.0, 1.0);
|
||||
plane.SetDestSize (height, height);
|
||||
plane.EnableSeamless (seamless);
|
||||
|
||||
// Generate the lower noise map.
|
||||
plane.SetSourceModule (lowerNoiseModule);
|
||||
plane.SetDestNoiseMap (lowerNoiseMap);
|
||||
plane.Build ();
|
||||
|
||||
// Generate the upper noise map.
|
||||
plane.SetSourceModule (upperNoiseModule);
|
||||
plane.SetDestNoiseMap (upperNoiseMap);
|
||||
plane.Build ();
|
||||
|
||||
// Given these two noise maps, render the lower texture map, then render the
|
||||
// upper texture map on top of the lower texture map.
|
||||
RenderTexture (lowerNoiseMap, upperNoiseMap, filename);
|
||||
}
|
||||
|
||||
void CreateSphericalTexture (const module::Module& lowerNoiseModule,
|
||||
const module::Module& upperNoiseModule, int height, const char* filename)
|
||||
{
|
||||
// Map the output values from both noise module onto two spheres. This will
|
||||
// create two two-dimensional noise maps which can be rendered as two
|
||||
// spherical texture maps.
|
||||
utils::NoiseMapBuilderSphere sphere;
|
||||
utils::NoiseMap lowerNoiseMap;
|
||||
utils::NoiseMap upperNoiseMap;
|
||||
sphere.SetBounds (-90.0, 90.0, -180.0, 180.0); // degrees
|
||||
sphere.SetDestSize (height * 2, height);
|
||||
|
||||
// Generate the lower noise map.
|
||||
sphere.SetSourceModule (lowerNoiseModule);
|
||||
sphere.SetDestNoiseMap (lowerNoiseMap);
|
||||
sphere.Build ();
|
||||
|
||||
// Generate the upper noise map.
|
||||
sphere.SetSourceModule (upperNoiseModule);
|
||||
sphere.SetDestNoiseMap (upperNoiseMap);
|
||||
sphere.Build ();
|
||||
|
||||
// Given these two noise maps, render the lower texture map, then render the
|
||||
// upper texture map on top of the lower texture map.
|
||||
RenderTexture (lowerNoiseMap, upperNoiseMap, filename);
|
||||
}
|
||||
|
||||
void RenderTexture (const utils::NoiseMap& lowerNoiseMap,
|
||||
const utils::NoiseMap& upperNoiseMap, const char* filename)
|
||||
{
|
||||
// Create the color gradients for the lower texture.
|
||||
utils::RendererImage textureRenderer;
|
||||
CreateTextureColorLayer1 (textureRenderer);
|
||||
|
||||
// Set up us the texture renderer and pass the lower noise map to it.
|
||||
utils::Image destTexture;
|
||||
textureRenderer.SetSourceNoiseMap (lowerNoiseMap);
|
||||
textureRenderer.SetDestImage (destTexture);
|
||||
textureRenderer.EnableLight (true);
|
||||
textureRenderer.SetLightAzimuth (135.0);
|
||||
textureRenderer.SetLightElev (60.0);
|
||||
textureRenderer.SetLightContrast (2.0);
|
||||
textureRenderer.SetLightColor (utils::Color (255, 255, 255, 0));
|
||||
|
||||
// Render the texture.
|
||||
textureRenderer.Render ();
|
||||
|
||||
// Create the color gradients for the upper texture.
|
||||
CreateTextureColorLayer2 (textureRenderer);
|
||||
|
||||
// Set up us the texture renderer and pass the upper noise map to it. Also
|
||||
// use the lower texture map as a background so that the upper texture map
|
||||
// can be rendered on top of the lower texture map.
|
||||
textureRenderer.SetSourceNoiseMap (upperNoiseMap);
|
||||
textureRenderer.SetBackgroundImage (destTexture);
|
||||
textureRenderer.SetDestImage (destTexture);
|
||||
textureRenderer.EnableLight (false);
|
||||
|
||||
// Render the texture.
|
||||
textureRenderer.Render ();
|
||||
|
||||
// Write the texture as a Windows bitmap file (*.bmp).
|
||||
utils::WriterBMP textureWriter;
|
||||
textureWriter.SetSourceImage (destTexture);
|
||||
textureWriter.SetDestFilename (filename);
|
||||
textureWriter.WriteDestFile ();
|
||||
}
|
||||
190
src/external/libnoise/examples/textureslime.cpp
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
// textureslime.cpp
|
||||
//
|
||||
// This program uses the libnoise library to generate texture maps consisting
|
||||
// of shiny green slime.
|
||||
//
|
||||
// Copyright (C) 2004 Jason Bevins
|
||||
//
|
||||
// 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 2 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
|
||||
// (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
// Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include <noise/noise.h>
|
||||
|
||||
#include "noiseutils.h"
|
||||
|
||||
using namespace noise;
|
||||
|
||||
// Height of the texture.
|
||||
const int TEXTURE_HEIGHT = 256;
|
||||
|
||||
// Creates the color gradients for the texture.
|
||||
void CreateTextureColor (utils::RendererImage& renderer);
|
||||
|
||||
// Given a noise module, this function renders a flat square texture map and
|
||||
// writes it to a Windows bitmap (*.bmp) file. Because the texture map is
|
||||
// square, its width is equal to its height. The texture map can be seamless
|
||||
// (tileable) or non-seamless.
|
||||
void CreatePlanarTexture (const module::Module& noiseModule, bool seamless,
|
||||
int height, const char* filename);
|
||||
|
||||
// Given a noise module, this function renders a spherical texture map and
|
||||
// writes it to a Windows bitmap (*.bmp) file. The texture map's width is
|
||||
// double its height.
|
||||
void CreateSphericalTexture (const module::Module& noiseModule, int height,
|
||||
const char* filename);
|
||||
|
||||
// Given a noise map, this function renders a texture map and writes it to a
|
||||
// Windows bitmap (*.bmp) file.
|
||||
void RenderTexture (const utils::NoiseMap& noiseMap, const char* filename);
|
||||
|
||||
int main ()
|
||||
{
|
||||
// Large slime bubble texture.
|
||||
module::Billow largeSlime;
|
||||
largeSlime.SetSeed (0);
|
||||
largeSlime.SetFrequency (4.0);
|
||||
largeSlime.SetLacunarity (2.12109375);
|
||||
largeSlime.SetOctaveCount (1);
|
||||
largeSlime.SetNoiseQuality (QUALITY_BEST);
|
||||
|
||||
// Base of the small slime bubble texture. This texture will eventually
|
||||
// appear inside cracks in the large slime bubble texture.
|
||||
module::Billow smallSlimeBase;
|
||||
smallSlimeBase.SetSeed (1);
|
||||
smallSlimeBase.SetFrequency (24.0);
|
||||
smallSlimeBase.SetLacunarity (2.14453125);
|
||||
smallSlimeBase.SetOctaveCount (1);
|
||||
smallSlimeBase.SetNoiseQuality (QUALITY_BEST);
|
||||
|
||||
// Scale and lower the small slime bubble values.
|
||||
module::ScaleBias smallSlime;
|
||||
smallSlime.SetSourceModule (0, smallSlimeBase);
|
||||
smallSlime.SetScale (0.5);
|
||||
smallSlime.SetBias (-0.5);
|
||||
|
||||
// Create a map that specifies where the large and small slime bubble
|
||||
// textures will appear in the final texture map.
|
||||
module::RidgedMulti slimeMap;
|
||||
slimeMap.SetSeed (0);
|
||||
slimeMap.SetFrequency (2.0);
|
||||
slimeMap.SetLacunarity (2.20703125);
|
||||
slimeMap.SetOctaveCount (3);
|
||||
slimeMap.SetNoiseQuality (QUALITY_STD);
|
||||
|
||||
// Choose between the large or small slime bubble textures depending on the
|
||||
// corresponding value from the slime map. Choose the small slime bubble
|
||||
// texture if the slime map value is within a narrow range of values,
|
||||
// otherwise choose the large slime bubble texture. The edge falloff is
|
||||
// non-zero so that there is a smooth transition between the two textures.
|
||||
module::Select slimeChooser;
|
||||
slimeChooser.SetSourceModule (0, largeSlime);
|
||||
slimeChooser.SetSourceModule (1, smallSlime);
|
||||
slimeChooser.SetControlModule (slimeMap);
|
||||
slimeChooser.SetBounds (-0.375, 0.375);
|
||||
slimeChooser.SetEdgeFalloff (0.5);
|
||||
|
||||
// Finally, perturb the slime texture to add realism.
|
||||
module::Turbulence finalSlime;
|
||||
finalSlime.SetSourceModule (0, slimeChooser);
|
||||
finalSlime.SetSeed (2);
|
||||
finalSlime.SetFrequency (8.0);
|
||||
finalSlime.SetPower (1.0 / 32.0);
|
||||
finalSlime.SetRoughness (2);
|
||||
|
||||
// Given the slime noise module, create a non-seamless texture map, a
|
||||
// seamless texture map, and a spherical texture map.
|
||||
CreatePlanarTexture (finalSlime, false, TEXTURE_HEIGHT,
|
||||
"textureplane.bmp");
|
||||
CreatePlanarTexture (finalSlime, true, TEXTURE_HEIGHT,
|
||||
"textureseamless.bmp");
|
||||
CreateSphericalTexture (finalSlime, TEXTURE_HEIGHT,
|
||||
"texturesphere.bmp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CreateTextureColor (utils::RendererImage& renderer)
|
||||
{
|
||||
// Create a green slime palette. A dirt brown color is used for very low
|
||||
// values while green is used for the rest of the values.
|
||||
renderer.ClearGradient ();
|
||||
renderer.AddGradientPoint (-1.0000, utils::Color (160, 64, 42, 255));
|
||||
renderer.AddGradientPoint ( 0.0000, utils::Color ( 64, 192, 64, 255));
|
||||
renderer.AddGradientPoint ( 1.0000, utils::Color (128, 255, 128, 255));
|
||||
}
|
||||
|
||||
void CreatePlanarTexture (const module::Module& noiseModule, bool seamless,
|
||||
int height, const char* filename)
|
||||
{
|
||||
// Map the output values from the noise module onto a plane. This will
|
||||
// create a two-dimensional noise map which can be rendered as a flat
|
||||
// texture map.
|
||||
utils::NoiseMapBuilderPlane plane;
|
||||
utils::NoiseMap noiseMap;
|
||||
plane.SetBounds (-1.0, 1.0, -1.0, 1.0);
|
||||
plane.SetDestSize (height, height);
|
||||
plane.SetSourceModule (noiseModule);
|
||||
plane.SetDestNoiseMap (noiseMap);
|
||||
plane.EnableSeamless (seamless);
|
||||
plane.Build ();
|
||||
|
||||
RenderTexture (noiseMap, filename);
|
||||
}
|
||||
|
||||
void CreateSphericalTexture (const module::Module& noiseModule, int height,
|
||||
const char* filename)
|
||||
{
|
||||
// Map the output values from the noise module onto a sphere. This will
|
||||
// create a two-dimensional noise map which can be rendered as a spherical
|
||||
// texture map.
|
||||
utils::NoiseMapBuilderSphere sphere;
|
||||
utils::NoiseMap noiseMap;
|
||||
sphere.SetBounds (-90.0, 90.0, -180.0, 180.0); // degrees
|
||||
sphere.SetDestSize (height * 2, height);
|
||||
sphere.SetSourceModule (noiseModule);
|
||||
sphere.SetDestNoiseMap (noiseMap);
|
||||
sphere.Build ();
|
||||
|
||||
RenderTexture (noiseMap, filename);
|
||||
}
|
||||
|
||||
void RenderTexture (const utils::NoiseMap& noiseMap, const char* filename)
|
||||
{
|
||||
// Create the color gradients for the texture.
|
||||
utils::RendererImage textureRenderer;
|
||||
CreateTextureColor (textureRenderer);
|
||||
|
||||
// Set up us the texture renderer and pass the noise map to it.
|
||||
utils::Image destTexture;
|
||||
textureRenderer.SetSourceNoiseMap (noiseMap);
|
||||
textureRenderer.SetDestImage (destTexture);
|
||||
textureRenderer.EnableLight (true);
|
||||
textureRenderer.SetLightAzimuth (135.0);
|
||||
textureRenderer.SetLightElev (60.0);
|
||||
textureRenderer.SetLightContrast (2.0);
|
||||
textureRenderer.SetLightColor (utils::Color (255, 255, 255, 0));
|
||||
|
||||
// Render the texture.
|
||||
textureRenderer.Render ();
|
||||
|
||||
// Write the texture as a Windows bitmap file (*.bmp).
|
||||
utils::WriterBMP textureWriter;
|
||||
textureWriter.SetSourceImage (destTexture);
|
||||
textureWriter.SetDestFilename (filename);
|
||||
textureWriter.WriteDestFile ();
|
||||
}
|
||||
192
src/external/libnoise/examples/texturewood.cpp
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
// texturewood.cpp
|
||||
//
|
||||
// This program uses the libnoise library to generate texture maps consisting
|
||||
// of stained oak-like wood.
|
||||
//
|
||||
// Copyright (C) 2004 Jason Bevins
|
||||
//
|
||||
// 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 2 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
|
||||
// (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
// Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include <noise/noise.h>
|
||||
|
||||
#include "noiseutils.h"
|
||||
|
||||
using namespace noise;
|
||||
|
||||
// Height of the texture.
|
||||
const int TEXTURE_HEIGHT = 256;
|
||||
|
||||
// Creates the color gradients for the texture.
|
||||
void CreateTextureColor (utils::RendererImage& renderer);
|
||||
|
||||
// Given a noise module, this function renders a flat square texture map and
|
||||
// writes it to a Windows bitmap (*.bmp) file. Because the texture map is
|
||||
// square, its width is equal to its height. The texture map can be seamless
|
||||
// (tileable) or non-seamless.
|
||||
void CreatePlanarTexture (const module::Module& noiseModule, bool seamless,
|
||||
int height, const char* filename);
|
||||
|
||||
// Given a noise module, this function renders a spherical texture map and
|
||||
// writes it to a Windows bitmap (*.bmp) file. The texture map's width is
|
||||
// double its height.
|
||||
void CreateSphericalTexture (const module::Module& noiseModule, int height,
|
||||
const char* filename);
|
||||
|
||||
// Given a noise map, this function renders a texture map and writes it to a
|
||||
// Windows bitmap (*.bmp) file.
|
||||
void RenderTexture (const utils::NoiseMap& noiseMap, const char* filename);
|
||||
|
||||
int main ()
|
||||
{
|
||||
// Base wood texture. The base texture uses concentric cylinders aligned
|
||||
// on the z axis, like a log.
|
||||
module::Cylinders baseWood;
|
||||
baseWood.SetFrequency (16.0);
|
||||
|
||||
// Perlin noise to use for the wood grain.
|
||||
module::Perlin woodGrainNoise;
|
||||
woodGrainNoise.SetSeed (0);
|
||||
woodGrainNoise.SetFrequency (48.0);
|
||||
woodGrainNoise.SetPersistence (0.5);
|
||||
woodGrainNoise.SetLacunarity (2.20703125);
|
||||
woodGrainNoise.SetOctaveCount (3);
|
||||
woodGrainNoise.SetNoiseQuality (QUALITY_STD);
|
||||
|
||||
// Stretch the Perlin noise in the same direction as the center of the
|
||||
// log. This produces a nice wood-grain texture.
|
||||
module::ScalePoint scaledBaseWoodGrain;
|
||||
scaledBaseWoodGrain.SetSourceModule (0, woodGrainNoise);
|
||||
scaledBaseWoodGrain.SetYScale (0.25);
|
||||
|
||||
// Scale the wood-grain values so that they may be added to the base wood
|
||||
// texture.
|
||||
module::ScaleBias woodGrain;
|
||||
woodGrain.SetSourceModule (0, scaledBaseWoodGrain);
|
||||
woodGrain.SetScale (0.25);
|
||||
woodGrain.SetBias (0.125);
|
||||
|
||||
// Add the wood grain texture to the base wood texture.
|
||||
module::Add combinedWood;
|
||||
combinedWood.SetSourceModule (0, baseWood);
|
||||
combinedWood.SetSourceModule (1, woodGrain);
|
||||
|
||||
// Slightly perturb the wood texture for more realism.
|
||||
module::Turbulence perturbedWood;
|
||||
perturbedWood.SetSourceModule (0, combinedWood);
|
||||
perturbedWood.SetSeed (1);
|
||||
perturbedWood.SetFrequency (4.0);
|
||||
perturbedWood.SetPower (1.0 / 256.0);
|
||||
perturbedWood.SetRoughness (4);
|
||||
|
||||
// Cut the wood texture a small distance from the center of the "log".
|
||||
module::TranslatePoint translatedWood;
|
||||
translatedWood.SetSourceModule (0, perturbedWood);
|
||||
translatedWood.SetZTranslation (1.48);
|
||||
|
||||
// Cut the wood texture on an angle to produce a more interesting wood
|
||||
// texture.
|
||||
module::RotatePoint rotatedWood;
|
||||
rotatedWood.SetSourceModule (0, translatedWood);
|
||||
rotatedWood.SetAngles (84.0, 0.0, 0.0);
|
||||
|
||||
// Finally, perturb the wood texture to produce the final texture.
|
||||
module::Turbulence finalWood;
|
||||
finalWood.SetSourceModule (0, rotatedWood);
|
||||
finalWood.SetSeed (2);
|
||||
finalWood.SetFrequency (2.0);
|
||||
finalWood.SetPower (1.0 / 64.0);
|
||||
finalWood.SetRoughness (4);
|
||||
|
||||
// Given the wood noise module, create a non-seamless texture map, a
|
||||
// seamless texture map, and a spherical texture map.
|
||||
CreatePlanarTexture (finalWood, false, TEXTURE_HEIGHT,
|
||||
"textureplane.bmp");
|
||||
CreatePlanarTexture (finalWood, true, TEXTURE_HEIGHT,
|
||||
"textureseamless.bmp");
|
||||
CreateSphericalTexture (finalWood, TEXTURE_HEIGHT,
|
||||
"texturesphere.bmp");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CreateTextureColor (utils::RendererImage& renderer)
|
||||
{
|
||||
// Create a dark-stained wood palette (oak?)
|
||||
renderer.ClearGradient ();
|
||||
renderer.AddGradientPoint (-1.00, utils::Color (189, 94, 4, 255));
|
||||
renderer.AddGradientPoint ( 0.50, utils::Color (144, 48, 6, 255));
|
||||
renderer.AddGradientPoint ( 1.00, utils::Color ( 60, 10, 8, 255));
|
||||
}
|
||||
|
||||
void CreatePlanarTexture (const module::Module& noiseModule, bool seamless,
|
||||
int height, const char* filename)
|
||||
{
|
||||
// Map the output values from the noise module onto a plane. This will
|
||||
// create a two-dimensional noise map which can be rendered as a flat
|
||||
// texture map.
|
||||
utils::NoiseMapBuilderPlane plane;
|
||||
utils::NoiseMap noiseMap;
|
||||
plane.SetBounds (-1.0, 1.0, -1.0, 1.0);
|
||||
plane.SetDestSize (height, height);
|
||||
plane.SetSourceModule (noiseModule);
|
||||
plane.SetDestNoiseMap (noiseMap);
|
||||
plane.EnableSeamless (seamless);
|
||||
plane.Build ();
|
||||
|
||||
RenderTexture (noiseMap, filename);
|
||||
}
|
||||
|
||||
void CreateSphericalTexture (const module::Module& noiseModule, int height,
|
||||
const char* filename)
|
||||
{
|
||||
// Map the output values from the noise module onto a sphere. This will
|
||||
// create a two-dimensional noise map which can be rendered as a spherical
|
||||
// texture map.
|
||||
utils::NoiseMapBuilderSphere sphere;
|
||||
utils::NoiseMap noiseMap;
|
||||
sphere.SetBounds (-90.0, 90.0, -180.0, 180.0); // degrees
|
||||
sphere.SetDestSize (height * 2, height);
|
||||
sphere.SetSourceModule (noiseModule);
|
||||
sphere.SetDestNoiseMap (noiseMap);
|
||||
sphere.Build ();
|
||||
|
||||
RenderTexture (noiseMap, filename);
|
||||
}
|
||||
|
||||
void RenderTexture (const utils::NoiseMap& noiseMap, const char* filename)
|
||||
{
|
||||
// Create the color gradients for the texture.
|
||||
utils::RendererImage textureRenderer;
|
||||
CreateTextureColor (textureRenderer);
|
||||
|
||||
// Set up us the texture renderer and pass the noise map to it.
|
||||
utils::Image destTexture;
|
||||
textureRenderer.SetSourceNoiseMap (noiseMap);
|
||||
textureRenderer.SetDestImage (destTexture);
|
||||
textureRenderer.EnableLight (false);
|
||||
|
||||
// Render the texture.
|
||||
textureRenderer.Render ();
|
||||
|
||||
// Write the texture as a Windows bitmap file (*.bmp).
|
||||
utils::WriterBMP textureWriter;
|
||||
textureWriter.SetSourceImage (destTexture);
|
||||
textureWriter.SetDestFilename (filename);
|
||||
textureWriter.WriteDestFile ();
|
||||
}
|
||||
667
src/external/libnoise/examples/worms.cpp
vendored
Normal file
@@ -0,0 +1,667 @@
|
||||
// worms.cpp
|
||||
//
|
||||
// This program uses the libnoise library to draw and animate worm-like
|
||||
// creatures. On a fast computer (P4/AMD Athlon-class), hundreds of worms
|
||||
// can be drawn and animated at very high frame rates.
|
||||
//
|
||||
// The worms do not interact with each other because that would use way too
|
||||
// much CPU resources.
|
||||
//
|
||||
// See the documentation for the Worm class for information on how
|
||||
// coherent-noise values are used to draw and animate a worm.
|
||||
//
|
||||
// Requires OpenGL 1.1+ and GLUT (a windowing toolkit for OpenGL.) The GLUT
|
||||
// webpage is http://www.opengl.org/resources/libraries/glut.html
|
||||
//
|
||||
// Keyboard controls:
|
||||
//
|
||||
// Esc: Exits the program.
|
||||
//
|
||||
// Q: Increase the number of worms by one.
|
||||
// A: Decrease the number of worms by one.
|
||||
//
|
||||
// W: Increase the number of worm segments by one.
|
||||
// S: Increase the number of worm segments by one.
|
||||
//
|
||||
// E: Increase the worms' speed.
|
||||
// D: Decrease the worms' speed.
|
||||
//
|
||||
// R: Increase the lateral (thrashing) speed of the worms.
|
||||
// F: Decrease the lateral (thrashing) speed of the worms.
|
||||
//
|
||||
// T: Increase the worms' thickness.
|
||||
// G: Decrease the worms' thickness.
|
||||
//
|
||||
// Y: Increase the worms' "twistiness".
|
||||
// H: Decrease the worms' "twistiness".
|
||||
//
|
||||
// Copyright (C) 2004, 2005 Jason Bevins
|
||||
//
|
||||
// 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 2 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
|
||||
// (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
// Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <gl/gl.h>
|
||||
#include <glut.h>
|
||||
|
||||
#include <noise/noise.h>
|
||||
#include <noise/mathconsts.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace noise;
|
||||
|
||||
// Width of the worm texture.
|
||||
const int g_textureWidth = 16;
|
||||
|
||||
// Height of the worm texture.
|
||||
const int g_textureHeight = 16;
|
||||
|
||||
// 16x16 RGB texture for the worms. Generated by The GIMP.
|
||||
static char* g_pTextureData =
|
||||
"?VE`8U)K13Y:1C];2$%:5DQA>'&!@WB*:UQR9EET9%ES8UAP9UMZ>&%[A6Z$>6-Z"
|
||||
"S[6XR[*PIH2\"IXN0HY2>DWR#VL;+TL3,LYZ<QZVNUL\"_L)..NJJXN:>[V<#)R;\"Y"
|
||||
"W\\G,Y-/4P9^3SZ^KZ-K>RJN?S:VMY=/4U[NPW<+![-GCV<\"UX,C&Y-7BZ=K>V\\2^"
|
||||
"W\\F^XL[!R*.6UK:PYM7/RZB:U[R^V;^POY:)SZ^:Y]#/Y=')SZ^:Y]#/Y=')UKBH"
|
||||
"OY*%O9*%K()WPYF+Q)Z+JGUVU[RUO9.\"HW=MN9)\\R)N)MXQVM9!WRIN+QIJ+L8-W"
|
||||
"GG9FJGYNIGMMJ'YMK()PHWIKN9J+HX)GGGI?L8YQL8US@653F7EBJGYJJGUIEVU@"
|
||||
"GGY:F7E9E'18G'I9G'M:E'1;CW->C')6AVE3E'==F7ED<UQ5@6M4EWE5F7Y6DG92"
|
||||
"C'!6AVI5@613AVQ5B6U5@6=6?FA8?F96>V)5@6E6AVY<:UE6:UM1>V90@6E0@6A0"
|
||||
"<U]7=E]7<UE6<%M7=F!7<%M5:5=4:5M7;EI6:UM2;EY29%138E53:UA1:5A0<%]2"
|
||||
"9%E6<%U:;EE;;EA::UE79E548E%39%15:5957U)29E=58E-69EA6<%Y6<%Y6:5E5"
|
||||
"6U)3:UY<=F5A<U]?=F1>:UI:9EA7:5E78E158E-6;EQ89E=69%54:5M6<V189%E6"
|
||||
"4$I/7556;F->;F!?;EY>:UI=;EY=<&%=9%588E-59%55<&!;:5A96TY25DY/5D]0"
|
||||
"/SQ*03],1D-/2$523$)44$-65DI76TY86TQ674Y674Y49EA::5E;64Y2/SQ(/CQ("
|
||||
",#%'+C!',#))-#-,-S--.3-./#9//#9./#1-0SM02D%013U,/SA*-S-(+BY%,3!&"
|
||||
"(R-%&Q]$&A]%'B)'(R1()\"5((B-(*2=(*\"9)+\"E)+2M))21%(\"%#'!Y#(\"%$(B)%"
|
||||
"\"A)\"\"A)\"\"1-\"\"A-\"\"A1\"\"A-\"\"Q-\"#!5\"#A5\"#A5\"#Q9\"$AA"
|
||||
"\"&QU$%QM#\"Q-\"\"A-\""
|
||||
"";
|
||||
|
||||
// This macro, provided by The GIMP, extracts the pixel values from the
|
||||
// texture defined above.
|
||||
#define HEADER_PIXEL(data,pixel) { \
|
||||
pixel[0] = (((data[0] - 33) << 2) | ((data[1] - 33) >> 4)); \
|
||||
pixel[1] = ((((data[1] - 33) & 0xF) << 4) | ((data[2] - 33) >> 2)); \
|
||||
pixel[2] = ((((data[2] - 33) & 0x3) << 6) | ((data[3] - 33))); \
|
||||
data += 4; \
|
||||
}
|
||||
|
||||
// Default worm lateral speed.
|
||||
const double WORM_LATERAL_SPEED = (2.0 / 8192.0);
|
||||
|
||||
// Default length of a worm segment, in screen units.
|
||||
const double WORM_SEGMENT_LENGTH = (1.0 / 64.0);
|
||||
|
||||
// Default segment count for each worm.
|
||||
const int WORM_SEGMENT_COUNT = 112;
|
||||
|
||||
// Default worm speed.
|
||||
const double WORM_SPEED = (3.0 / 2048.0);
|
||||
|
||||
// Default worm thickness.
|
||||
const double WORM_THICKNESS = (4.0 / 256.0);
|
||||
|
||||
// Default "twistiness" of the worms.
|
||||
const double WORM_TWISTINESS = (4.0 / 256.0);
|
||||
|
||||
// Default worm lateral speed.
|
||||
double g_wormLateralSpeed = WORM_LATERAL_SPEED;
|
||||
|
||||
// Default length of a worm segment, in screen units.
|
||||
double g_wormSegmentLength = WORM_SEGMENT_LENGTH;
|
||||
|
||||
// Default segment count for each worm.
|
||||
int g_wormSegmentCount = WORM_SEGMENT_COUNT;
|
||||
|
||||
// Default worm speed.
|
||||
double g_wormSpeed = WORM_SPEED;
|
||||
|
||||
// Default worm thickness.
|
||||
double g_wormThickness = WORM_THICKNESS;
|
||||
|
||||
// Default "twistiness" of the worms.
|
||||
double g_wormTwistiness = WORM_TWISTINESS;
|
||||
|
||||
// Number of worms rendered on the screen.
|
||||
int g_curWormCount = 32;
|
||||
|
||||
// This template function clamps the specified value to the specified bounds.
|
||||
template<class T>
|
||||
void Clamp (T& value, T lowerBound, T upperBound)
|
||||
{
|
||||
if (value < lowerBound) {
|
||||
value = lowerBound;
|
||||
} else if (value > upperBound) {
|
||||
value = upperBound;
|
||||
}
|
||||
}
|
||||
|
||||
// A standard 2-component vector.
|
||||
class Vector2
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
double x, y;
|
||||
|
||||
};
|
||||
|
||||
// A standard 3-component vector.
|
||||
class Vector3
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
double x, y, z;
|
||||
|
||||
};
|
||||
|
||||
// Worm class
|
||||
//
|
||||
// This class uses three-dimensional coherent noise to draw and animate a
|
||||
// single worm-like creature.
|
||||
//
|
||||
// A worm is made up of a chain of "segments". The first segment is known as
|
||||
// the "head" segment. This class draws the worm starting from the head
|
||||
// segment.
|
||||
//
|
||||
// A worm object contains a three-octave Perlin-noise module, which is used to
|
||||
// specify the angles of each worm segment, in radians. Three octaves is a
|
||||
// good compromise between realism and speed.
|
||||
//
|
||||
// The coherent-noise values that specify the segment angles are generated by
|
||||
// the input values that occur along a horizontal line in "noise space". By
|
||||
// shifting the (x, y, z) coordinates of the input value by a small constant
|
||||
// amount each frame, the worm will slightly move.
|
||||
//
|
||||
// To draw the worm, call the Draw() method.
|
||||
//
|
||||
// To move the worm, call the Update() method. That method moves the position
|
||||
// of the head segment a small distance in the direction opposite its angle.
|
||||
// Also, the x coordinate of the input value is shifted in a negative
|
||||
// direction, which propagates the previous coherent-noise values over to
|
||||
// subsequent segments. This will produce a "slithering" effect.
|
||||
//
|
||||
// Each worm should have its own seed value because worms with the same seed
|
||||
// value will act identically.
|
||||
class Worm
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Worm ()
|
||||
{
|
||||
// The coordinates of the input value for the head segment must not
|
||||
// start at an integer boundary (for example, (0, 0, 0)). At integer
|
||||
// boundaries, the coherent-noise values are always zero (blame gradient
|
||||
// noise for that), which would cause the worm to unrealistically
|
||||
// straighten those boundaries.
|
||||
m_headNoisePos.x = 7.0 / 2048.0;
|
||||
m_headNoisePos.y = 1163.0 / 2048.0;
|
||||
m_headNoisePos.z = 409.0 / 2048.0;
|
||||
|
||||
// Set up us the Perlin-noise module.
|
||||
m_noise.SetSeed (0);
|
||||
m_noise.SetFrequency (1.0);
|
||||
m_noise.SetLacunarity (2.375);
|
||||
m_noise.SetOctaveCount (3);
|
||||
m_noise.SetPersistence (0.5);
|
||||
m_noise.SetNoiseQuality (noise::QUALITY_STD);
|
||||
|
||||
// Set the worm parameters with their default values.
|
||||
m_headScreenPos.x = 0.0;
|
||||
m_headScreenPos.y = 0.0;
|
||||
m_lateralSpeed = WORM_LATERAL_SPEED;
|
||||
m_segmentCount = WORM_SEGMENT_COUNT;
|
||||
m_segmentLength = WORM_SEGMENT_LENGTH;
|
||||
m_speed = WORM_SPEED;
|
||||
m_thickness = WORM_THICKNESS;
|
||||
m_twistiness = WORM_TWISTINESS;
|
||||
}
|
||||
|
||||
// Draw the worm using OpenGL.
|
||||
void Draw () const;
|
||||
|
||||
// Returns the taper amount for a specified segment. A taper value of 0.0
|
||||
// indicates full tapering, while a taper value of 1.0 indicates no
|
||||
// tapering. Taper values are at a minimum at both ends of the worm and
|
||||
// are at a maximum at the middle of the worm.
|
||||
double GetTaperAmount (int segment) const
|
||||
{
|
||||
double curSegment = (double)segment;
|
||||
double segmentCount = (double)m_segmentCount;
|
||||
double halfSegmentCount = segmentCount / 2.0;
|
||||
double baseTaperAmount
|
||||
= 1.0 - fabs ((curSegment / halfSegmentCount) - 1.0);
|
||||
return sqrt (baseTaperAmount); // sqrt better defines the tapering.
|
||||
}
|
||||
|
||||
// Sets the position of the worm's head segment in screen space.
|
||||
void SetHeadScreenPos (const Vector2& pos)
|
||||
{
|
||||
m_headScreenPos = pos;
|
||||
}
|
||||
|
||||
// Sets the worm's lateral speed. This is the amount the worm "thrashes
|
||||
// around" between frames. Higher values increases the thrashing amount.
|
||||
void SetLateralSpeed (double lateralSpeed)
|
||||
{
|
||||
m_lateralSpeed = lateralSpeed;
|
||||
}
|
||||
|
||||
// Sets the seed of the Perlin-noise module.
|
||||
void SetSeed (int seed)
|
||||
{
|
||||
m_noise.SetSeed (seed);
|
||||
}
|
||||
|
||||
// Sets the number of segments that make up the worm.
|
||||
void SetSegmentCount (double segmentCount)
|
||||
{
|
||||
m_segmentCount = segmentCount;
|
||||
}
|
||||
|
||||
// Sets the length of a worm segment, in screen units.
|
||||
void SetSegmentLength (double segmentLength)
|
||||
{
|
||||
m_segmentLength = segmentLength;
|
||||
}
|
||||
|
||||
// Sets the worm's speed. Higher values increase the speed.
|
||||
void SetSpeed (double speed)
|
||||
{
|
||||
m_speed = speed;
|
||||
}
|
||||
|
||||
// Sets the worm's thickness, in screen units.
|
||||
void SetThickness (double thickness)
|
||||
{
|
||||
m_thickness = thickness;
|
||||
}
|
||||
|
||||
// Defines the "twistiness" of the worms. Higher values produce more
|
||||
// contorted worms.
|
||||
void SetTwistiness (double twistiness)
|
||||
{
|
||||
m_twistiness = twistiness;
|
||||
}
|
||||
|
||||
// Updates the worm's segment positions. This must be called after each
|
||||
// frame.
|
||||
void Update ();
|
||||
|
||||
private:
|
||||
|
||||
// Coordinates of the input value that generates the Perlin noise in
|
||||
// "noise space". This is used to specify the angles of the worm's
|
||||
// segments.
|
||||
Vector3 m_headNoisePos;
|
||||
|
||||
// Position of the worm's head segment, in screen space.
|
||||
Vector2 m_headScreenPos;
|
||||
|
||||
// Worm's lateral speed.
|
||||
double m_lateralSpeed;
|
||||
|
||||
// Noise module used to draw the worm.
|
||||
module::Perlin m_noise;
|
||||
|
||||
// Number of segments that make up the worm.
|
||||
int m_segmentCount;
|
||||
|
||||
// Length of a worm segment.
|
||||
double m_segmentLength;
|
||||
|
||||
// Worm speed.
|
||||
double m_speed;
|
||||
|
||||
// Worm thickness.
|
||||
double m_thickness;
|
||||
|
||||
// "Twistiness" of the worm.
|
||||
double m_twistiness;
|
||||
|
||||
};
|
||||
|
||||
void Worm::Draw () const
|
||||
{
|
||||
// The worm is drawn using a triangle strip.
|
||||
glBegin (GL_TRIANGLE_STRIP);
|
||||
|
||||
// Position of the current segment being drawn, in screen space.
|
||||
Vector2 curSegmentScreenPos = m_headScreenPos;
|
||||
|
||||
// The width of the worm's body at the current segment being drawn.
|
||||
Vector2 offsetPos;
|
||||
|
||||
// Coordinates of the input value, in "noise space", that specifies the
|
||||
// current segment's angle.
|
||||
Vector3 curNoisePos;
|
||||
|
||||
// The vector that is perpindicular to the center of the segment; used to
|
||||
// determine the position of the edges of the worm's body.
|
||||
Vector2 curNormalPos;
|
||||
|
||||
for (int curSegment = 0; curSegment < m_segmentCount; curSegment++) {
|
||||
|
||||
// Get the Perlin-noise value for this segment based on the segment
|
||||
// number. This value is interpreted as an angle, in radians.
|
||||
curNoisePos.x = m_headNoisePos.x + (curSegment * m_twistiness);
|
||||
curNoisePos.y = m_headNoisePos.y;
|
||||
curNoisePos.z = m_headNoisePos.z;
|
||||
double noiseValue = m_noise.GetValue (
|
||||
curNoisePos.x,
|
||||
curNoisePos.y,
|
||||
curNoisePos.z);
|
||||
|
||||
// Determine the width of the worm's body at this segment.
|
||||
double taperAmount = GetTaperAmount (curSegment) * m_thickness;
|
||||
|
||||
// Determine the offset of this segment from the previous segment by
|
||||
// converting the angle from the Perlin-noise module to an (x, y)
|
||||
// coordinate.
|
||||
offsetPos.x = cos (noiseValue * 2.0 * noise::PI);
|
||||
offsetPos.y = sin (noiseValue * 2.0 * noise::PI);
|
||||
|
||||
// Determine the coordinates of each corner of the segment.
|
||||
curNormalPos.x = (-offsetPos.y) * taperAmount;
|
||||
curNormalPos.y = ( offsetPos.x) * taperAmount;
|
||||
offsetPos.x *= m_segmentLength;
|
||||
offsetPos.y *= m_segmentLength;
|
||||
GLdouble x0 = (GLdouble)(curSegmentScreenPos.x + curNormalPos.x);
|
||||
GLdouble y0 = (GLdouble)(curSegmentScreenPos.y + curNormalPos.y);
|
||||
GLdouble x1 = (GLdouble)(curSegmentScreenPos.x - curNormalPos.x);
|
||||
GLdouble y1 = (GLdouble)(curSegmentScreenPos.y - curNormalPos.y);
|
||||
|
||||
// Draw the segment using OpenGL.
|
||||
glTexCoord2f ((GLfloat)curSegment, 0.0f);
|
||||
glVertex2d (x0, y0);
|
||||
glTexCoord2f ((GLfloat)curSegment, 1.0f);
|
||||
glVertex2d (x1, y1);
|
||||
|
||||
// Prepare the next segment.
|
||||
++curSegment;
|
||||
curSegmentScreenPos.x += offsetPos.x;
|
||||
curSegmentScreenPos.y += offsetPos.y;
|
||||
}
|
||||
|
||||
// Finish drawing the worm.
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
void Worm::Update ()
|
||||
{
|
||||
// The angle of the head segment is used to determine the direction the worm
|
||||
// moves. The worm moves in the opposite direction.
|
||||
double noiseValue = m_noise.GetValue (
|
||||
m_headNoisePos.x,
|
||||
m_headNoisePos.y,
|
||||
m_headNoisePos.z);
|
||||
m_headScreenPos.x -= (cos (noiseValue * 2.0 * noise::PI) * m_speed);
|
||||
m_headScreenPos.y -= (sin (noiseValue * 2.0 * noise::PI) * m_speed);
|
||||
|
||||
// Slightly update the coordinates of the input value, in "noise space".
|
||||
// This causes the worm's shape to be slightly different in the next frame.
|
||||
// The x coordinate of the input value is shifted in a negative direction,
|
||||
// which propagates the previous Perlin-noise values over to subsequent
|
||||
// segments. This produces a "slithering" effect.
|
||||
m_headNoisePos.x -= m_speed * 2.0;
|
||||
m_headNoisePos.y += m_lateralSpeed;
|
||||
m_headNoisePos.z += m_lateralSpeed;
|
||||
|
||||
// Make sure the worm's head is within the window, otherwise the worm may
|
||||
// escape. Horrible, horrible freedom!
|
||||
Clamp (m_headScreenPos.x, -1.0, 1.0);
|
||||
Clamp (m_headScreenPos.y, -1.0, 1.0);
|
||||
}
|
||||
|
||||
// Array used to store a bunch of worms.
|
||||
const int MAX_WORM_COUNT = 1024;
|
||||
Worm g_wormArray[MAX_WORM_COUNT];
|
||||
|
||||
// This function is called by GLUT when the program is idle.
|
||||
void IdleGLUT ()
|
||||
{
|
||||
glutPostRedisplay ();
|
||||
}
|
||||
|
||||
// This function is called by GLUT when the program window is resized.
|
||||
void ReshapeGLUT (int w, int h)
|
||||
{
|
||||
glViewport (0, 0, (GLsizei)w, (GLsizei)h);
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
|
||||
// No need for perspective since the worms are rendered in 2D.
|
||||
double aspect = (double)h / (double)w;
|
||||
glOrtho (-1.0f, 1.0f, -1.0f * aspect, 1.0f * aspect, 0.0f, 1.0f);
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
}
|
||||
|
||||
// This function is called by GLUT when a key is pressed.
|
||||
void KeyboardGLUT (unsigned char key, int x, int y)
|
||||
{
|
||||
switch (key) {
|
||||
case 'Q':
|
||||
case 'q':
|
||||
++g_curWormCount;
|
||||
break;
|
||||
case 'A':
|
||||
case 'a':
|
||||
--g_curWormCount;
|
||||
break;
|
||||
case 'W':
|
||||
case 'w':
|
||||
++g_wormSegmentCount;
|
||||
break;
|
||||
case 'S':
|
||||
case 's':
|
||||
--g_wormSegmentCount;
|
||||
break;
|
||||
case 'E':
|
||||
case 'e':
|
||||
g_wormSpeed += (1.0 / 2048.0);
|
||||
break;
|
||||
case 'D':
|
||||
case 'd':
|
||||
g_wormSpeed -= (1.0 / 2048.0);
|
||||
break;
|
||||
case 'R':
|
||||
case 'r':
|
||||
g_wormLateralSpeed += (1.0 / 8192.0);
|
||||
break;
|
||||
case 'F':
|
||||
case 'f':
|
||||
g_wormLateralSpeed -= (1.0 / 8192.0);
|
||||
break;
|
||||
case 'T':
|
||||
case 't':
|
||||
g_wormThickness += (1.0 / 256.0);
|
||||
break;
|
||||
case 'G':
|
||||
case 'g':
|
||||
g_wormThickness -= (1.0 / 256.0);
|
||||
break;
|
||||
case 'Y':
|
||||
case 'y':
|
||||
g_wormTwistiness += (1.0 / 256.0);
|
||||
break;
|
||||
case 'H':
|
||||
case 'h':
|
||||
g_wormTwistiness -= (1.0 / 256.0);
|
||||
break;
|
||||
case 27:
|
||||
exit (0);
|
||||
}
|
||||
|
||||
// Make sure the worm parameters are legal. If they are not, set them to
|
||||
// the nearest legal value.
|
||||
Clamp (g_curWormCount, 1, 1024);
|
||||
Clamp (g_wormSegmentCount, 1, 256);
|
||||
Clamp (g_wormSpeed, (1.0 / 2048.0), (1024.0 / 2048.0));
|
||||
Clamp (g_wormLateralSpeed, (1.0 / 8192.0), (64.0 / 8192.0));
|
||||
Clamp (g_wormThickness, (1.0 / 256.0), (16.0 / 256.0));
|
||||
Clamp (g_wormTwistiness, (1.0 / 256.0), (16.0 / 256.0));
|
||||
|
||||
// Set the parameters for each worm.
|
||||
for (int i = 0; i < g_curWormCount; i++) {
|
||||
g_wormArray[i].SetSegmentCount (g_wormSegmentCount);
|
||||
g_wormArray[i].SetSpeed (g_wormSpeed);
|
||||
g_wormArray[i].SetLateralSpeed (g_wormLateralSpeed);
|
||||
g_wormArray[i].SetThickness (g_wormThickness);
|
||||
g_wormArray[i].SetTwistiness (g_wormTwistiness);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called by GLUT when the user moves the mouse or presses
|
||||
// any of its buttons.
|
||||
void MouseGLUT (int button, int state, int x, int y)
|
||||
{
|
||||
static int xMouseCenter = 0;
|
||||
static int yMouseCenter = 0;
|
||||
|
||||
if (state == GLUT_DOWN) {
|
||||
switch (button) {
|
||||
case GLUT_LEFT_BUTTON:
|
||||
break;
|
||||
case GLUT_RIGHT_BUTTON:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (state == GLUT_UP) {
|
||||
switch (button) {
|
||||
case GLUT_LEFT_BUTTON:
|
||||
break;
|
||||
case GLUT_RIGHT_BUTTON:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called by GLUT when the window needs to be redrawn.
|
||||
void DisplayGLUT ()
|
||||
{
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glPushMatrix ();
|
||||
glLoadIdentity ();
|
||||
|
||||
// Draw all the worms.
|
||||
for (int i = 0; i < g_curWormCount; i++) {
|
||||
g_wormArray[i].Draw ();
|
||||
g_wormArray[i].Update ();
|
||||
}
|
||||
|
||||
// Show the frame count in the console window.
|
||||
static int frame = 0;
|
||||
frame++;
|
||||
if ((frame % 10) == 0) {
|
||||
std::cout << frame << std::endl;
|
||||
}
|
||||
|
||||
glPopMatrix ();
|
||||
glFlush ();
|
||||
glutSwapBuffers ();
|
||||
}
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
for (int i = 0; i < MAX_WORM_COUNT; i++) {
|
||||
Vector2 pos;
|
||||
pos.x = noise::ValueNoise3D (i + 1000, i + 2000, i + 3000);
|
||||
pos.y = noise::ValueNoise3D (i + 1001, i + 2001, i + 3001);
|
||||
g_wormArray[i].SetSeed (i);
|
||||
g_wormArray[i].SetHeadScreenPos (pos);
|
||||
}
|
||||
|
||||
// Set up us the GLUT (OpenGL windowing toolkit).
|
||||
glutInit (&argc, argv);
|
||||
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
|
||||
glutInitWindowSize (640, 640);
|
||||
glutInitWindowPosition (0, 0);
|
||||
glutCreateWindow ("libnoise demonstration - Perlin worms");
|
||||
|
||||
// Set up us the GLUT function callbacks.
|
||||
glutDisplayFunc (DisplayGLUT);
|
||||
glutReshapeFunc (ReshapeGLUT);
|
||||
glutMouseFunc (MouseGLUT);
|
||||
glutKeyboardFunc (KeyboardGLUT);
|
||||
glutIdleFunc (IdleGLUT);
|
||||
|
||||
// Set the OpenGL texture mapping and blending parameters for this program.
|
||||
glClearColor (0.1f, 0.15f, 0.3f, 1.0f);
|
||||
glShadeModel (GL_SMOOTH);
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glDisable (GL_CULL_FACE);
|
||||
glEnable (GL_BLEND);
|
||||
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// Build the texture map to use for the worms.
|
||||
unsigned char pTexture[g_textureWidth * g_textureHeight * 4];
|
||||
unsigned char* pSource = (unsigned char*)g_pTextureData;
|
||||
for (int y = 0; y < g_textureHeight; y++) {
|
||||
unsigned char* pDest = &(pTexture[g_textureWidth * 4 * y]);
|
||||
for (int x = 0; x < g_textureWidth; x++) {
|
||||
HEADER_PIXEL (pSource, pDest); // Decode the pixel value.
|
||||
// Set the value of the alpha channel for this pixel. The top and
|
||||
// bottom rows are somewhat transparent. Combined with mipmapping,
|
||||
// it's almost like getting antialiasing for free.
|
||||
if (y == 0 || y == g_textureHeight - 1) {
|
||||
pDest[3] = 0x40;
|
||||
} else {
|
||||
pDest[3] = 0xff;
|
||||
}
|
||||
pDest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Upload the texture to the video card and build mipmaps.
|
||||
GLuint textureID = gluBuild2DMipmaps (GL_TEXTURE_2D,
|
||||
4, // bits per channel
|
||||
(GLint)g_textureWidth, (GLint)g_textureHeight, // dimensions
|
||||
GL_RGBA, // texture format
|
||||
GL_UNSIGNED_BYTE,
|
||||
pTexture);
|
||||
glBindTexture (GL_TEXTURE_2D, textureID);
|
||||
|
||||
// Go farkers go!
|
||||
glutMainLoop ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
36
src/external/libnoise/noiseutils/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
set(PROJECT_NAME libnoiseutils)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS YES CACHE BOOL "Export all symbols")
|
||||
set(libSrcs ${libSrcs}
|
||||
noiseutils.cpp
|
||||
)
|
||||
add_library(noiseutils SHARED ${libSrcs})
|
||||
add_library(noiseutils-static STATIC ${libSrcs})
|
||||
|
||||
set_target_properties(noiseutils PROPERTIES LIBNOISE_VERSION ${LIBNOISE_VERSION})
|
||||
set_target_properties(noiseutils-static PROPERTIES LIBNOISE_VERSION ${LIBNOISE_VERSION})
|
||||
|
||||
target_link_libraries(noiseutils noise)
|
||||
target_link_libraries(noiseutils-static noise-static)
|
||||
|
||||
# I would like to see more projects using these defaults
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
message(STATUS "noiseutils - using optimized compile settings with all warnings enabled")
|
||||
add_compile_options(-Wall -ansi -pedantic -O3)
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
message(STATUS "noiseutils - using optimized compile settings with all warnings enabled")
|
||||
add_compile_options(/Wall /Ox)
|
||||
endif()
|
||||
|
||||
# Where to look for noise headers
|
||||
target_include_directories( noiseutils PRIVATE ../src )
|
||||
target_include_directories( noiseutils-static PRIVATE ../src )
|
||||
|
||||
# install include files into /include
|
||||
install( FILES "${PROJECT_SOURCE_DIR}/noiseutils/noiseutils.h"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/include/noise" )
|
||||
|
||||
# install dynamic libraries (.dll or .so) into /bin
|
||||
install( TARGETS noiseutils DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" )
|
||||
|
||||
# install static libraries (.lib) into /lib
|
||||
install( TARGETS noiseutils-static DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
|
||||
504
src/external/libnoise/noiseutils/COPYING.txt
vendored
Normal file
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
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 this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. 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 not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the 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
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY 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
|
||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey 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 library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
1299
src/external/libnoise/noiseutils/noiseutils.cpp
vendored
Normal file
2540
src/external/libnoise/noiseutils/noiseutils.h
vendored
Normal file
4
src/external/libnoise/noiseutils/readme.txt
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
noiseutils library - differences between 0.9.0 and 0.9.0.1
|
||||
|
||||
- Added the noiseutils classes to the noise::utils namespace.
|
||||
|
||||
80
src/external/libnoise/src/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
# http://www.linux-magazin.de/Heft-Abo/Ausgaben/2007/02/Mal-ausspannen
|
||||
|
||||
set(PROJECT_NAME libnoise)
|
||||
|
||||
include_directories (noise)
|
||||
|
||||
set(libSrcs ${libSrcs}
|
||||
noisegen.cpp
|
||||
latlon.cpp
|
||||
|
||||
model/line.cpp
|
||||
model/plane.cpp
|
||||
model/sphere.cpp
|
||||
model/cylinder.cpp
|
||||
|
||||
module/abs.cpp
|
||||
module/add.cpp
|
||||
module/billow.cpp
|
||||
module/blend.cpp
|
||||
module/cache.cpp
|
||||
module/checkerboard.cpp
|
||||
module/clamp.cpp
|
||||
module/const.cpp
|
||||
module/curve.cpp
|
||||
module/cylinders.cpp
|
||||
module/displace.cpp
|
||||
module/exponent.cpp
|
||||
module/invert.cpp
|
||||
module/max.cpp
|
||||
module/min.cpp
|
||||
module/modulebase.cpp
|
||||
module/multiply.cpp
|
||||
module/perlin.cpp
|
||||
module/power.cpp
|
||||
module/ridgedmulti.cpp
|
||||
module/rotatepoint.cpp
|
||||
module/scalebias.cpp
|
||||
module/scalepoint.cpp
|
||||
module/select.cpp
|
||||
module/spheres.cpp
|
||||
module/terrace.cpp
|
||||
module/translatepoint.cpp
|
||||
module/turbulence.cpp
|
||||
module/voronoi.cpp
|
||||
)
|
||||
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
IF (WIN32)
|
||||
message(STATUS "build - shared for win32 (x86)")
|
||||
add_library( noise SHARED ${libSrcs} win32/dllmain.cpp)
|
||||
ELSE()
|
||||
message(STATUS "build - shared for others")
|
||||
add_library( noise SHARED ${libSrcs} )
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
add_library( noise-static STATIC ${libSrcs} )
|
||||
|
||||
# this value is set in the root CMakeLists.txt
|
||||
set_target_properties( noise-static PROPERTIES LIBNOISE_VERSION ${LIBNOISE_VERSION} )
|
||||
|
||||
target_compile_definitions( noise-static PUBLIC NOISE_STATIC)
|
||||
|
||||
set_target_properties( noise-static PROPERTIES OUTPUT_NAME "noise" )
|
||||
|
||||
# I would like to see more projects using these defaults
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
message(STATUS "noiseutils - using optimized compile settings with all warnings enabled")
|
||||
add_compile_options(-Wall -ansi -pedantic -O3)
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
message(STATUS "noiseutils - using optimized compile settings with all warnings enabled")
|
||||
add_compile_options(/Wall /Ox)
|
||||
endif()
|
||||
|
||||
# install include files into /include
|
||||
install( DIRECTORY "${PROJECT_SOURCE_DIR}/src/noise"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/include" )
|
||||
|
||||
# install static libraries (.lib) into /lib
|
||||
install( TARGETS noise-static DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" )
|
||||
34
src/external/libnoise/src/latlon.cpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// latlon.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "noise/latlon.h"
|
||||
|
||||
using namespace noise;
|
||||
|
||||
void noise::LatLonToXYZ (double lat, double lon, double& x, double& y,
|
||||
double& z)
|
||||
{
|
||||
double r = cos (DEG_TO_RAD * lat);
|
||||
x = r * cos (DEG_TO_RAD * lon);
|
||||
y = sin (DEG_TO_RAD * lat);
|
||||
z = r * sin (DEG_TO_RAD * lon);
|
||||
}
|
||||
47
src/external/libnoise/src/model/cylinder.cpp
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// cylinder.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "mathconsts.h"
|
||||
#include "model/cylinder.h"
|
||||
|
||||
using namespace noise;
|
||||
using namespace noise::model;
|
||||
|
||||
Cylinder::Cylinder (): m_pModule (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Cylinder::Cylinder (const module::Module& module):
|
||||
m_pModule (&module)
|
||||
{
|
||||
}
|
||||
|
||||
double Cylinder::GetValue (double angle, double height) const
|
||||
{
|
||||
assert (m_pModule != NULL);
|
||||
|
||||
double x, y, z;
|
||||
x = cos (angle * DEG_TO_RAD);
|
||||
y = height;
|
||||
z = sin (angle * DEG_TO_RAD);
|
||||
return m_pModule->GetValue (x, y, z);
|
||||
}
|
||||
65
src/external/libnoise/src/model/line.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// line.cpp
|
||||
//
|
||||
// Copyright (C) 2004 Keith Davies
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
|
||||
#include "model/line.h"
|
||||
|
||||
using namespace noise;
|
||||
using namespace noise::model;
|
||||
|
||||
Line::Line ():
|
||||
|
||||
m_attenuate (true),
|
||||
m_pModule (NULL),
|
||||
m_x0 (0.0),
|
||||
m_x1 (1.0),
|
||||
m_y0 (0.0),
|
||||
m_y1 (1.0),
|
||||
m_z0 (0.0),
|
||||
m_z1 (1.0)
|
||||
{
|
||||
}
|
||||
|
||||
Line::Line (const module::Module& module):
|
||||
|
||||
m_attenuate (true),
|
||||
m_pModule (&module),
|
||||
m_x0 (0.0),
|
||||
m_x1 (1.0),
|
||||
m_y0 (0.0),
|
||||
m_y1 (1.0),
|
||||
m_z0 (0.0),
|
||||
m_z1 (1.0)
|
||||
{
|
||||
}
|
||||
|
||||
double Line::GetValue (double p) const
|
||||
{
|
||||
assert (m_pModule != NULL);
|
||||
|
||||
double x = (m_x1 - m_x0) * p + m_x0;
|
||||
double y = (m_y1 - m_y0) * p + m_y0;
|
||||
double z = (m_z1 - m_z0) * p + m_z0;
|
||||
double value = m_pModule->GetValue (x, y, z);
|
||||
|
||||
if (m_attenuate) {
|
||||
return p * (1.0 - p) * 4 * value;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
43
src/external/libnoise/src/model/plane.cpp
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// plane.cpp
|
||||
//
|
||||
// Copyright (C) 2004 Owen Jacobson
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is ojacobson@lionsanctuary.net
|
||||
//
|
||||
|
||||
#include "model/plane.h"
|
||||
|
||||
using namespace noise;
|
||||
using namespace noise::model;
|
||||
|
||||
Plane::Plane ():
|
||||
m_pModule (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Plane::Plane (const module::Module& module) :
|
||||
m_pModule( &module)
|
||||
{
|
||||
}
|
||||
|
||||
// Told you this was trivial.
|
||||
double Plane::GetValue (double x, double z) const
|
||||
{
|
||||
assert (m_pModule != NULL);
|
||||
|
||||
return m_pModule->GetValue (x, 0, z);
|
||||
}
|
||||
45
src/external/libnoise/src/model/sphere.cpp
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// sphere.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "latlon.h"
|
||||
#include "model/sphere.h"
|
||||
using namespace noise;
|
||||
using namespace noise::model;
|
||||
|
||||
Sphere::Sphere ():
|
||||
m_pModule (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Sphere::Sphere (const module::Module& module):
|
||||
m_pModule (&module)
|
||||
{
|
||||
}
|
||||
|
||||
double Sphere::GetValue (double lat, double lon) const
|
||||
{
|
||||
assert (m_pModule != NULL);
|
||||
|
||||
double x, y, z;
|
||||
LatLonToXYZ (lat, lon, x, y, z);
|
||||
return m_pModule->GetValue (x, y, z);
|
||||
}
|
||||
37
src/external/libnoise/src/module/abs.cpp
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// abs.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/abs.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Abs::Abs ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Abs::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
return fabs (m_pSourceModule[0]->GetValue (x, y, z));
|
||||
}
|
||||
39
src/external/libnoise/src/module/add.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// add.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/add.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Add::Add ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Add::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_pSourceModule[1] != NULL);
|
||||
|
||||
return m_pSourceModule[0]->GetValue (x, y, z)
|
||||
+ m_pSourceModule[1]->GetValue (x, y, z);
|
||||
}
|
||||
74
src/external/libnoise/src/module/billow.cpp
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
// billow.cpp
|
||||
//
|
||||
// Copyright (C) 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/billow.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Billow::Billow ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_frequency (DEFAULT_BILLOW_FREQUENCY ),
|
||||
m_lacunarity (DEFAULT_BILLOW_LACUNARITY ),
|
||||
m_noiseQuality (DEFAULT_BILLOW_QUALITY ),
|
||||
m_octaveCount (DEFAULT_BILLOW_OCTAVE_COUNT),
|
||||
m_persistence (DEFAULT_BILLOW_PERSISTENCE ),
|
||||
m_seed (DEFAULT_BILLOW_SEED)
|
||||
{
|
||||
}
|
||||
|
||||
double Billow::GetValue (double x, double y, double z) const
|
||||
{
|
||||
double value = 0.0;
|
||||
double signal = 0.0;
|
||||
double curPersistence = 1.0;
|
||||
double nx, ny, nz;
|
||||
int seed;
|
||||
|
||||
x *= m_frequency;
|
||||
y *= m_frequency;
|
||||
z *= m_frequency;
|
||||
|
||||
for (int curOctave = 0; curOctave < m_octaveCount; curOctave++) {
|
||||
|
||||
// Make sure that these floating-point values have the same range as a 32-
|
||||
// bit integer so that we can pass them to the coherent-noise functions.
|
||||
nx = MakeInt32Range (x);
|
||||
ny = MakeInt32Range (y);
|
||||
nz = MakeInt32Range (z);
|
||||
|
||||
// Get the coherent-noise value from the input value and add it to the
|
||||
// final result.
|
||||
seed = (m_seed + curOctave) & 0xffffffff;
|
||||
signal = GradientCoherentNoise3D (nx, ny, nz, seed, m_noiseQuality);
|
||||
signal = 2.0 * fabs (signal) - 1.0;
|
||||
value += signal * curPersistence;
|
||||
|
||||
// Prepare the next octave.
|
||||
x *= m_lacunarity;
|
||||
y *= m_lacunarity;
|
||||
z *= m_lacunarity;
|
||||
curPersistence *= m_persistence;
|
||||
}
|
||||
value += 0.5;
|
||||
|
||||
return value;
|
||||
}
|
||||
43
src/external/libnoise/src/module/blend.cpp
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// blend.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/blend.h"
|
||||
#include "interp.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Blend::Blend ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Blend::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_pSourceModule[1] != NULL);
|
||||
assert (m_pSourceModule[2] != NULL);
|
||||
|
||||
double v0 = m_pSourceModule[0]->GetValue (x, y, z);
|
||||
double v1 = m_pSourceModule[1]->GetValue (x, y, z);
|
||||
double alpha = (m_pSourceModule[2]->GetValue (x, y, z) + 1.0) / 2.0;
|
||||
return LinearInterp (v0, v1, alpha);
|
||||
}
|
||||
45
src/external/libnoise/src/module/cache.cpp
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// cache.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/cache.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Cache::Cache ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_isCached (false)
|
||||
{
|
||||
}
|
||||
|
||||
double Cache::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
if (!(m_isCached && x == m_xCache && y == m_yCache && z == m_zCache)) {
|
||||
m_cachedValue = m_pSourceModule[0]->GetValue (x, y, z);
|
||||
m_xCache = x;
|
||||
m_yCache = y;
|
||||
m_zCache = z;
|
||||
}
|
||||
m_isCached = true;
|
||||
return m_cachedValue;
|
||||
}
|
||||
38
src/external/libnoise/src/module/checkerboard.cpp
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
// checkerboard.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/checkerboard.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Checkerboard::Checkerboard ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Checkerboard::GetValue (double x, double y, double z) const
|
||||
{
|
||||
int ix = (int)(floor (MakeInt32Range (x)));
|
||||
int iy = (int)(floor (MakeInt32Range (y)));
|
||||
int iz = (int)(floor (MakeInt32Range (z)));
|
||||
return (ix & 1 ^ iy & 1 ^ iz & 1)? -1.0: 1.0;
|
||||
}
|
||||
54
src/external/libnoise/src/module/clamp.cpp
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
// clamp.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/clamp.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Clamp::Clamp ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_lowerBound (DEFAULT_CLAMP_LOWER_BOUND),
|
||||
m_upperBound (DEFAULT_CLAMP_UPPER_BOUND)
|
||||
{
|
||||
}
|
||||
|
||||
double Clamp::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
double value = m_pSourceModule[0]->GetValue (x, y, z);
|
||||
if (value < m_lowerBound) {
|
||||
return m_lowerBound;
|
||||
} else if (value > m_upperBound) {
|
||||
return m_upperBound;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
void Clamp::SetBounds (double lowerBound, double upperBound)
|
||||
{
|
||||
assert (lowerBound < upperBound);
|
||||
|
||||
m_lowerBound = lowerBound;
|
||||
m_upperBound = upperBound;
|
||||
}
|
||||
31
src/external/libnoise/src/module/const.cpp
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// const.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/const.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Const::Const ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_constValue (DEFAULT_CONST_VALUE)
|
||||
{
|
||||
}
|
||||
143
src/external/libnoise/src/module/curve.cpp
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
// curve.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "interp.h"
|
||||
#include "misc.h"
|
||||
#include "module/curve.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Curve::Curve ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_pControlPoints (NULL)
|
||||
{
|
||||
m_controlPointCount = 0;
|
||||
}
|
||||
|
||||
Curve::~Curve ()
|
||||
{
|
||||
delete[] m_pControlPoints;
|
||||
}
|
||||
|
||||
void Curve::AddControlPoint (double inputValue, double outputValue)
|
||||
{
|
||||
// Find the insertion point for the new control point and insert the new
|
||||
// point at that position. The control point array will remain sorted by
|
||||
// input value.
|
||||
int insertionPos = FindInsertionPos (inputValue);
|
||||
InsertAtPos (insertionPos, inputValue, outputValue);
|
||||
}
|
||||
|
||||
void Curve::ClearAllControlPoints ()
|
||||
{
|
||||
delete[] m_pControlPoints;
|
||||
m_pControlPoints = NULL;
|
||||
m_controlPointCount = 0;
|
||||
}
|
||||
|
||||
int Curve::FindInsertionPos (double inputValue)
|
||||
{
|
||||
int insertionPos;
|
||||
for (insertionPos = 0; insertionPos < m_controlPointCount; insertionPos++) {
|
||||
if (inputValue < m_pControlPoints[insertionPos].inputValue) {
|
||||
// We found the array index in which to insert the new control point.
|
||||
// Exit now.
|
||||
break;
|
||||
} else if (inputValue == m_pControlPoints[insertionPos].inputValue) {
|
||||
// Each control point is required to contain a unique input value, so
|
||||
// throw an exception.
|
||||
throw noise::ExceptionInvalidParam ();
|
||||
}
|
||||
}
|
||||
return insertionPos;
|
||||
}
|
||||
|
||||
double Curve::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_controlPointCount >= 4);
|
||||
|
||||
// Get the output value from the source module.
|
||||
double sourceModuleValue = m_pSourceModule[0]->GetValue (x, y, z);
|
||||
|
||||
// Find the first element in the control point array that has an input value
|
||||
// larger than the output value from the source module.
|
||||
int indexPos;
|
||||
for (indexPos = 0; indexPos < m_controlPointCount; indexPos++) {
|
||||
if (sourceModuleValue < m_pControlPoints[indexPos].inputValue) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the four nearest control points so that we can perform cubic
|
||||
// interpolation.
|
||||
int index0 = ClampValue (indexPos - 2, 0, m_controlPointCount - 1);
|
||||
int index1 = ClampValue (indexPos - 1, 0, m_controlPointCount - 1);
|
||||
int index2 = ClampValue (indexPos , 0, m_controlPointCount - 1);
|
||||
int index3 = ClampValue (indexPos + 1, 0, m_controlPointCount - 1);
|
||||
|
||||
// If some control points are missing (which occurs if the value from the
|
||||
// source module is greater than the largest input value or less than the
|
||||
// smallest input value of the control point array), get the corresponding
|
||||
// output value of the nearest control point and exit now.
|
||||
if (index1 == index2) {
|
||||
return m_pControlPoints[index1].outputValue;
|
||||
}
|
||||
|
||||
// Compute the alpha value used for cubic interpolation.
|
||||
double input0 = m_pControlPoints[index1].inputValue;
|
||||
double input1 = m_pControlPoints[index2].inputValue;
|
||||
double alpha = (sourceModuleValue - input0) / (input1 - input0);
|
||||
|
||||
// Now perform the cubic interpolation given the alpha value.
|
||||
return CubicInterp (
|
||||
m_pControlPoints[index0].outputValue,
|
||||
m_pControlPoints[index1].outputValue,
|
||||
m_pControlPoints[index2].outputValue,
|
||||
m_pControlPoints[index3].outputValue,
|
||||
alpha);
|
||||
}
|
||||
|
||||
void Curve::InsertAtPos (int insertionPos, double inputValue,
|
||||
double outputValue)
|
||||
{
|
||||
// Make room for the new control point at the specified position within the
|
||||
// control point array. The position is determined by the input value of
|
||||
// the control point; the control points must be sorted by input value
|
||||
// within that array.
|
||||
ControlPoint* newControlPoints = new ControlPoint[m_controlPointCount + 1];
|
||||
for (int i = 0; i < m_controlPointCount; i++) {
|
||||
if (i < insertionPos) {
|
||||
newControlPoints[i] = m_pControlPoints[i];
|
||||
} else {
|
||||
newControlPoints[i + 1] = m_pControlPoints[i];
|
||||
}
|
||||
}
|
||||
delete[] m_pControlPoints;
|
||||
m_pControlPoints = newControlPoints;
|
||||
++m_controlPointCount;
|
||||
|
||||
// Now that we've made room for the new control point within the array, add
|
||||
// the new control point.
|
||||
m_pControlPoints[insertionPos].inputValue = inputValue ;
|
||||
m_pControlPoints[insertionPos].outputValue = outputValue;
|
||||
}
|
||||
44
src/external/libnoise/src/module/cylinders.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// cylinders.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "misc.h"
|
||||
#include "module/cylinders.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Cylinders::Cylinders ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_frequency (DEFAULT_CYLINDERS_FREQUENCY)
|
||||
{
|
||||
}
|
||||
|
||||
double Cylinders::GetValue (double x, double y, double z) const
|
||||
{
|
||||
x *= m_frequency;
|
||||
z *= m_frequency;
|
||||
|
||||
double distFromCenter = sqrt (x * x + z * z);
|
||||
double distFromSmallerSphere = distFromCenter - floor (distFromCenter);
|
||||
double distFromLargerSphere = 1.0 - distFromSmallerSphere;
|
||||
double nearestDist = GetMin (distFromSmallerSphere, distFromLargerSphere);
|
||||
return 1.0 - (nearestDist * 4.0); // Puts it in the -1.0 to +1.0 range.
|
||||
}
|
||||
48
src/external/libnoise/src/module/displace.cpp
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// displace.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/displace.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Displace::Displace ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Displace::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_pSourceModule[1] != NULL);
|
||||
assert (m_pSourceModule[2] != NULL);
|
||||
assert (m_pSourceModule[3] != NULL);
|
||||
|
||||
// Get the output values from the three displacement modules. Add each
|
||||
// value to the corresponding coordinate in the input value.
|
||||
double xDisplace = x + (m_pSourceModule[1]->GetValue (x, y, z));
|
||||
double yDisplace = y + (m_pSourceModule[2]->GetValue (x, y, z));
|
||||
double zDisplace = z + (m_pSourceModule[3]->GetValue (x, y, z));
|
||||
|
||||
// Retrieve the output value using the offsetted input value instead of
|
||||
// the original input value.
|
||||
return m_pSourceModule[0]->GetValue (xDisplace, yDisplace, zDisplace);
|
||||
}
|
||||
39
src/external/libnoise/src/module/exponent.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// exponent.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/exponent.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Exponent::Exponent ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_exponent (DEFAULT_EXPONENT)
|
||||
{
|
||||
}
|
||||
|
||||
double Exponent::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
double value = m_pSourceModule[0]->GetValue (x, y, z);
|
||||
return (pow (fabs ((value + 1.0) / 2.0), m_exponent) * 2.0 - 1.0);
|
||||
}
|
||||
37
src/external/libnoise/src/module/invert.cpp
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// invert.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/invert.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Invert::Invert ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Invert::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
return -(m_pSourceModule[0]->GetValue (x, y, z));
|
||||
}
|
||||
41
src/external/libnoise/src/module/max.cpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// max.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "misc.h"
|
||||
#include "module/max.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Max::Max ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Max::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_pSourceModule[1] != NULL);
|
||||
|
||||
double v0 = m_pSourceModule[0]->GetValue (x, y, z);
|
||||
double v1 = m_pSourceModule[1]->GetValue (x, y, z);
|
||||
return GetMax (v0, v1);
|
||||
}
|
||||
41
src/external/libnoise/src/module/min.cpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// min.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "misc.h"
|
||||
#include "module/min.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Min::Min ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Min::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_pSourceModule[1] != NULL);
|
||||
|
||||
double v0 = m_pSourceModule[0]->GetValue (x, y, z);
|
||||
double v1 = m_pSourceModule[1]->GetValue (x, y, z);
|
||||
return GetMin (v0, v1);
|
||||
}
|
||||
46
src/external/libnoise/src/module/modulebase.cpp
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// modulebase.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/modulebase.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Module::Module (int sourceModuleCount)
|
||||
{
|
||||
m_pSourceModule = NULL;
|
||||
|
||||
// Create an array of pointers to all source modules required by this
|
||||
// noise module. Set these pointers to NULL.
|
||||
if (sourceModuleCount > 0) {
|
||||
m_pSourceModule = new const Module*[sourceModuleCount];
|
||||
for (int i = 0; i < sourceModuleCount; i++) {
|
||||
m_pSourceModule[i] = NULL;
|
||||
}
|
||||
} else {
|
||||
m_pSourceModule = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Module::~Module ()
|
||||
{
|
||||
delete[] m_pSourceModule;
|
||||
}
|
||||
39
src/external/libnoise/src/module/multiply.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// multiply.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/multiply.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Multiply::Multiply ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Multiply::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_pSourceModule[1] != NULL);
|
||||
|
||||
return m_pSourceModule[0]->GetValue (x, y, z)
|
||||
* m_pSourceModule[1]->GetValue (x, y, z);
|
||||
}
|
||||
72
src/external/libnoise/src/module/perlin.cpp
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
// perlin.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/perlin.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Perlin::Perlin ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_frequency (DEFAULT_PERLIN_FREQUENCY ),
|
||||
m_lacunarity (DEFAULT_PERLIN_LACUNARITY ),
|
||||
m_noiseQuality (DEFAULT_PERLIN_QUALITY ),
|
||||
m_octaveCount (DEFAULT_PERLIN_OCTAVE_COUNT),
|
||||
m_persistence (DEFAULT_PERLIN_PERSISTENCE ),
|
||||
m_seed (DEFAULT_PERLIN_SEED)
|
||||
{
|
||||
}
|
||||
|
||||
double Perlin::GetValue (double x, double y, double z) const
|
||||
{
|
||||
double value = 0.0;
|
||||
double signal = 0.0;
|
||||
double curPersistence = 1.0;
|
||||
double nx, ny, nz;
|
||||
int seed;
|
||||
|
||||
x *= m_frequency;
|
||||
y *= m_frequency;
|
||||
z *= m_frequency;
|
||||
|
||||
for (int curOctave = 0; curOctave < m_octaveCount; curOctave++) {
|
||||
|
||||
// Make sure that these floating-point values have the same range as a 32-
|
||||
// bit integer so that we can pass them to the coherent-noise functions.
|
||||
nx = MakeInt32Range (x);
|
||||
ny = MakeInt32Range (y);
|
||||
nz = MakeInt32Range (z);
|
||||
|
||||
// Get the coherent-noise value from the input value and add it to the
|
||||
// final result.
|
||||
seed = (m_seed + curOctave) & 0xffffffff;
|
||||
signal = GradientCoherentNoise3D (nx, ny, nz, seed, m_noiseQuality);
|
||||
value += signal * curPersistence;
|
||||
|
||||
// Prepare the next octave.
|
||||
x *= m_lacunarity;
|
||||
y *= m_lacunarity;
|
||||
z *= m_lacunarity;
|
||||
curPersistence *= m_persistence;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
38
src/external/libnoise/src/module/power.cpp
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
// power.cpp
|
||||
//
|
||||
// Copyright (C) 2004 Owen Jacobson
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is angstrom@lionsanctuary.net
|
||||
//
|
||||
|
||||
#include "module/power.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Power::Power ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
}
|
||||
|
||||
double Power::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_pSourceModule[1] != NULL);
|
||||
|
||||
return pow (m_pSourceModule[0]->GetValue (x, y, z),
|
||||
m_pSourceModule[1]->GetValue (x, y, z));
|
||||
}
|
||||
114
src/external/libnoise/src/module/ridgedmulti.cpp
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
// ridgedmulti.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/ridgedmulti.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
RidgedMulti::RidgedMulti ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_frequency (DEFAULT_RIDGED_FREQUENCY ),
|
||||
m_lacunarity (DEFAULT_RIDGED_LACUNARITY ),
|
||||
m_noiseQuality (DEFAULT_RIDGED_QUALITY ),
|
||||
m_octaveCount (DEFAULT_RIDGED_OCTAVE_COUNT),
|
||||
m_seed (DEFAULT_RIDGED_SEED)
|
||||
{
|
||||
CalcSpectralWeights ();
|
||||
}
|
||||
|
||||
// Calculates the spectral weights for each octave.
|
||||
void RidgedMulti::CalcSpectralWeights ()
|
||||
{
|
||||
// This exponent parameter should be user-defined; it may be exposed in a
|
||||
// future version of libnoise.
|
||||
double h = 1.0;
|
||||
|
||||
double frequency = 1.0;
|
||||
for (int i = 0; i < RIDGED_MAX_OCTAVE; i++) {
|
||||
// Compute weight for each frequency.
|
||||
m_pSpectralWeights[i] = pow (frequency, -h);
|
||||
frequency *= m_lacunarity;
|
||||
}
|
||||
}
|
||||
|
||||
// Multifractal code originally written by F. Kenton "Doc Mojo" Musgrave,
|
||||
// 1998. Modified by jas for use with libnoise.
|
||||
double RidgedMulti::GetValue (double x, double y, double z) const
|
||||
{
|
||||
x *= m_frequency;
|
||||
y *= m_frequency;
|
||||
z *= m_frequency;
|
||||
|
||||
double signal = 0.0;
|
||||
double value = 0.0;
|
||||
double weight = 1.0;
|
||||
|
||||
// These parameters should be user-defined; they may be exposed in a
|
||||
// future version of libnoise.
|
||||
double offset = 1.0;
|
||||
double gain = 2.0;
|
||||
|
||||
for (int curOctave = 0; curOctave < m_octaveCount; curOctave++) {
|
||||
|
||||
// Make sure that these floating-point values have the same range as a 32-
|
||||
// bit integer so that we can pass them to the coherent-noise functions.
|
||||
double nx, ny, nz;
|
||||
nx = MakeInt32Range (x);
|
||||
ny = MakeInt32Range (y);
|
||||
nz = MakeInt32Range (z);
|
||||
|
||||
// Get the coherent-noise value.
|
||||
int seed = (m_seed + curOctave) & 0x7fffffff;
|
||||
signal = GradientCoherentNoise3D (nx, ny, nz, seed, m_noiseQuality);
|
||||
|
||||
// Make the ridges.
|
||||
signal = fabs (signal);
|
||||
signal = offset - signal;
|
||||
|
||||
// Square the signal to increase the sharpness of the ridges.
|
||||
signal *= signal;
|
||||
|
||||
// The weighting from the previous octave is applied to the signal.
|
||||
// Larger values have higher weights, producing sharp points along the
|
||||
// ridges.
|
||||
signal *= weight;
|
||||
|
||||
// Weight successive contributions by the previous signal.
|
||||
weight = signal * gain;
|
||||
if (weight > 1.0) {
|
||||
weight = 1.0;
|
||||
}
|
||||
if (weight < 0.0) {
|
||||
weight = 0.0;
|
||||
}
|
||||
|
||||
// Add the signal to the output value.
|
||||
value += (signal * m_pSpectralWeights[curOctave]);
|
||||
|
||||
// Go to the next octave.
|
||||
x *= m_lacunarity;
|
||||
y *= m_lacunarity;
|
||||
z *= m_lacunarity;
|
||||
}
|
||||
|
||||
return (value * 1.25) - 1.0;
|
||||
}
|
||||
68
src/external/libnoise/src/module/rotatepoint.cpp
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
// rotatepoint.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "mathconsts.h"
|
||||
#include "module/rotatepoint.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
RotatePoint::RotatePoint ():
|
||||
Module (GetSourceModuleCount ())
|
||||
{
|
||||
SetAngles (DEFAULT_ROTATE_X, DEFAULT_ROTATE_Y, DEFAULT_ROTATE_Z);
|
||||
}
|
||||
|
||||
double RotatePoint::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
double nx = (m_x1Matrix * x) + (m_y1Matrix * y) + (m_z1Matrix * z);
|
||||
double ny = (m_x2Matrix * x) + (m_y2Matrix * y) + (m_z2Matrix * z);
|
||||
double nz = (m_x3Matrix * x) + (m_y3Matrix * y) + (m_z3Matrix * z);
|
||||
return m_pSourceModule[0]->GetValue (nx, ny, nz);
|
||||
}
|
||||
|
||||
void RotatePoint::SetAngles (double xAngle, double yAngle,
|
||||
double zAngle)
|
||||
{
|
||||
double xCos, yCos, zCos, xSin, ySin, zSin;
|
||||
xCos = cos (xAngle * DEG_TO_RAD);
|
||||
yCos = cos (yAngle * DEG_TO_RAD);
|
||||
zCos = cos (zAngle * DEG_TO_RAD);
|
||||
xSin = sin (xAngle * DEG_TO_RAD);
|
||||
ySin = sin (yAngle * DEG_TO_RAD);
|
||||
zSin = sin (zAngle * DEG_TO_RAD);
|
||||
|
||||
m_x1Matrix = ySin * xSin * zSin + yCos * zCos;
|
||||
m_y1Matrix = xCos * zSin;
|
||||
m_z1Matrix = ySin * zCos - yCos * xSin * zSin;
|
||||
m_x2Matrix = ySin * xSin * zCos - yCos * zSin;
|
||||
m_y2Matrix = xCos * zCos;
|
||||
m_z2Matrix = -yCos * xSin * zCos - ySin * zSin;
|
||||
m_x3Matrix = -ySin * xCos;
|
||||
m_y3Matrix = xSin;
|
||||
m_z3Matrix = yCos * xCos;
|
||||
|
||||
m_xAngle = xAngle;
|
||||
m_yAngle = yAngle;
|
||||
m_zAngle = zAngle;
|
||||
}
|
||||
39
src/external/libnoise/src/module/scalebias.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// scalebias.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/scalebias.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
ScaleBias::ScaleBias ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_bias (DEFAULT_BIAS ),
|
||||
m_scale (DEFAULT_SCALE)
|
||||
{
|
||||
}
|
||||
|
||||
double ScaleBias::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
return m_pSourceModule[0]->GetValue (x, y, z) * m_scale + m_bias;
|
||||
}
|
||||
41
src/external/libnoise/src/module/scalepoint.cpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// scalepoint.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/scalepoint.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
ScalePoint::ScalePoint ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_xScale (DEFAULT_SCALE_POINT_X),
|
||||
m_yScale (DEFAULT_SCALE_POINT_Y),
|
||||
m_zScale (DEFAULT_SCALE_POINT_Z)
|
||||
{
|
||||
}
|
||||
|
||||
double ScalePoint::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
return m_pSourceModule[0]->GetValue (x * m_xScale, y * m_yScale,
|
||||
z * m_zScale);
|
||||
}
|
||||
109
src/external/libnoise/src/module/select.cpp
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
// select.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "interp.h"
|
||||
#include "module/select.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Select::Select ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_edgeFalloff (DEFAULT_SELECT_EDGE_FALLOFF),
|
||||
m_lowerBound (DEFAULT_SELECT_LOWER_BOUND),
|
||||
m_upperBound (DEFAULT_SELECT_UPPER_BOUND)
|
||||
{
|
||||
}
|
||||
|
||||
double Select::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_pSourceModule[1] != NULL);
|
||||
assert (m_pSourceModule[2] != NULL);
|
||||
|
||||
double controlValue = m_pSourceModule[2]->GetValue (x, y, z);
|
||||
double alpha;
|
||||
if (m_edgeFalloff > 0.0) {
|
||||
if (controlValue < (m_lowerBound - m_edgeFalloff)) {
|
||||
// The output value from the control module is below the selector
|
||||
// threshold; return the output value from the first source module.
|
||||
return m_pSourceModule[0]->GetValue (x, y, z);
|
||||
|
||||
} else if (controlValue < (m_lowerBound + m_edgeFalloff)) {
|
||||
// The output value from the control module is near the lower end of the
|
||||
// selector threshold and within the smooth curve. Interpolate between
|
||||
// the output values from the first and second source modules.
|
||||
double lowerCurve = (m_lowerBound - m_edgeFalloff);
|
||||
double upperCurve = (m_lowerBound + m_edgeFalloff);
|
||||
alpha = SCurve3 (
|
||||
(controlValue - lowerCurve) / (upperCurve - lowerCurve));
|
||||
return LinearInterp (m_pSourceModule[0]->GetValue (x, y, z),
|
||||
m_pSourceModule[1]->GetValue (x, y, z),
|
||||
alpha);
|
||||
|
||||
} else if (controlValue < (m_upperBound - m_edgeFalloff)) {
|
||||
// The output value from the control module is within the selector
|
||||
// threshold; return the output value from the second source module.
|
||||
return m_pSourceModule[1]->GetValue (x, y, z);
|
||||
|
||||
} else if (controlValue < (m_upperBound + m_edgeFalloff)) {
|
||||
// The output value from the control module is near the upper end of the
|
||||
// selector threshold and within the smooth curve. Interpolate between
|
||||
// the output values from the first and second source modules.
|
||||
double lowerCurve = (m_upperBound - m_edgeFalloff);
|
||||
double upperCurve = (m_upperBound + m_edgeFalloff);
|
||||
alpha = SCurve3 (
|
||||
(controlValue - lowerCurve) / (upperCurve - lowerCurve));
|
||||
return LinearInterp (m_pSourceModule[1]->GetValue (x, y, z),
|
||||
m_pSourceModule[0]->GetValue (x, y, z),
|
||||
alpha);
|
||||
|
||||
} else {
|
||||
// Output value from the control module is above the selector threshold;
|
||||
// return the output value from the first source module.
|
||||
return m_pSourceModule[0]->GetValue (x, y, z);
|
||||
}
|
||||
} else {
|
||||
if (controlValue < m_lowerBound || controlValue > m_upperBound) {
|
||||
return m_pSourceModule[0]->GetValue (x, y, z);
|
||||
} else {
|
||||
return m_pSourceModule[1]->GetValue (x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Select::SetBounds (double lowerBound, double upperBound)
|
||||
{
|
||||
assert (lowerBound < upperBound);
|
||||
|
||||
m_lowerBound = lowerBound;
|
||||
m_upperBound = upperBound;
|
||||
|
||||
// Make sure that the edge falloff curves do not overlap.
|
||||
SetEdgeFalloff (m_edgeFalloff);
|
||||
}
|
||||
|
||||
void Select::SetEdgeFalloff (double edgeFalloff)
|
||||
{
|
||||
// Make sure that the edge falloff curves do not overlap.
|
||||
double boundSize = m_upperBound - m_lowerBound;
|
||||
m_edgeFalloff = (edgeFalloff > boundSize / 2)? boundSize / 2: edgeFalloff;
|
||||
}
|
||||
45
src/external/libnoise/src/module/spheres.cpp
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// spheres.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "misc.h"
|
||||
#include "module/spheres.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Spheres::Spheres ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_frequency (DEFAULT_SPHERES_FREQUENCY)
|
||||
{
|
||||
}
|
||||
|
||||
double Spheres::GetValue (double x, double y, double z) const
|
||||
{
|
||||
x *= m_frequency;
|
||||
y *= m_frequency;
|
||||
z *= m_frequency;
|
||||
|
||||
double distFromCenter = sqrt (x * x + y * y + z * z);
|
||||
double distFromSmallerSphere = distFromCenter - floor (distFromCenter);
|
||||
double distFromLargerSphere = 1.0 - distFromSmallerSphere;
|
||||
double nearestDist = GetMin (distFromSmallerSphere, distFromLargerSphere);
|
||||
return 1.0 - (nearestDist * 4.0); // Puts it in the -1.0 to +1.0 range.
|
||||
}
|
||||
160
src/external/libnoise/src/module/terrace.cpp
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
// terrace.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "interp.h"
|
||||
#include "misc.h"
|
||||
#include "module/terrace.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
using namespace noise;
|
||||
|
||||
Terrace::Terrace ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_controlPointCount (0),
|
||||
m_invertTerraces (false),
|
||||
m_pControlPoints (NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Terrace::~Terrace ()
|
||||
{
|
||||
delete[] m_pControlPoints;
|
||||
}
|
||||
|
||||
void Terrace::AddControlPoint (double value)
|
||||
{
|
||||
// Find the insertion point for the new control point and insert the new
|
||||
// point at that position. The control point array will remain sorted by
|
||||
// value.
|
||||
int insertionPos = FindInsertionPos (value);
|
||||
InsertAtPos (insertionPos, value);
|
||||
}
|
||||
|
||||
void Terrace::ClearAllControlPoints ()
|
||||
{
|
||||
delete[] m_pControlPoints;
|
||||
m_pControlPoints = NULL;
|
||||
m_controlPointCount = 0;
|
||||
}
|
||||
|
||||
int Terrace::FindInsertionPos (double value)
|
||||
{
|
||||
int insertionPos;
|
||||
for (insertionPos = 0; insertionPos < m_controlPointCount; insertionPos++) {
|
||||
if (value < m_pControlPoints[insertionPos]) {
|
||||
// We found the array index in which to insert the new control point.
|
||||
// Exit now.
|
||||
break;
|
||||
} else if (value == m_pControlPoints[insertionPos]) {
|
||||
// Each control point is required to contain a unique value, so throw
|
||||
// an exception.
|
||||
throw noise::ExceptionInvalidParam ();
|
||||
}
|
||||
}
|
||||
return insertionPos;
|
||||
}
|
||||
|
||||
double Terrace::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
assert (m_controlPointCount >= 2);
|
||||
|
||||
// Get the output value from the source module.
|
||||
double sourceModuleValue = m_pSourceModule[0]->GetValue (x, y, z);
|
||||
|
||||
// Find the first element in the control point array that has a value
|
||||
// larger than the output value from the source module.
|
||||
int indexPos;
|
||||
for (indexPos = 0; indexPos < m_controlPointCount; indexPos++) {
|
||||
if (sourceModuleValue < m_pControlPoints[indexPos]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the two nearest control points so that we can map their values
|
||||
// onto a quadratic curve.
|
||||
int index0 = ClampValue (indexPos - 1, 0, m_controlPointCount - 1);
|
||||
int index1 = ClampValue (indexPos , 0, m_controlPointCount - 1);
|
||||
|
||||
// If some control points are missing (which occurs if the output value from
|
||||
// the source module is greater than the largest value or less than the
|
||||
// smallest value of the control point array), get the value of the nearest
|
||||
// control point and exit now.
|
||||
if (index0 == index1) {
|
||||
return m_pControlPoints[index1];
|
||||
}
|
||||
|
||||
// Compute the alpha value used for linear interpolation.
|
||||
double value0 = m_pControlPoints[index0];
|
||||
double value1 = m_pControlPoints[index1];
|
||||
double alpha = (sourceModuleValue - value0) / (value1 - value0);
|
||||
if (m_invertTerraces) {
|
||||
alpha = 1.0 - alpha;
|
||||
SwapValues (value0, value1);
|
||||
}
|
||||
|
||||
// Squaring the alpha produces the terrace effect.
|
||||
alpha *= alpha;
|
||||
|
||||
// Now perform the linear interpolation given the alpha value.
|
||||
return LinearInterp (value0, value1, alpha);
|
||||
}
|
||||
|
||||
void Terrace::InsertAtPos (int insertionPos, double value)
|
||||
{
|
||||
// Make room for the new control point at the specified position within
|
||||
// the control point array. The position is determined by the value of
|
||||
// the control point; the control points must be sorted by value within
|
||||
// that array.
|
||||
double* newControlPoints = new double[m_controlPointCount + 1];
|
||||
for (int i = 0; i < m_controlPointCount; i++) {
|
||||
if (i < insertionPos) {
|
||||
newControlPoints[i] = m_pControlPoints[i];
|
||||
} else {
|
||||
newControlPoints[i + 1] = m_pControlPoints[i];
|
||||
}
|
||||
}
|
||||
delete[] m_pControlPoints;
|
||||
m_pControlPoints = newControlPoints;
|
||||
++m_controlPointCount;
|
||||
|
||||
// Now that we've made room for the new control point within the array,
|
||||
// add the new control point.
|
||||
m_pControlPoints[insertionPos] = value;
|
||||
}
|
||||
|
||||
void Terrace::MakeControlPoints (int controlPointCount)
|
||||
{
|
||||
if (controlPointCount < 2) {
|
||||
throw noise::ExceptionInvalidParam ();
|
||||
}
|
||||
|
||||
ClearAllControlPoints ();
|
||||
|
||||
double terraceStep = 2.0 / ((double)controlPointCount - 1.0);
|
||||
double curValue = -1.0;
|
||||
for (int i = 0; i < (int)controlPointCount; i++) {
|
||||
AddControlPoint (curValue);
|
||||
curValue += terraceStep;
|
||||
}
|
||||
}
|
||||
41
src/external/libnoise/src/module/translatepoint.cpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// translatepoint.cpp
|
||||
//
|
||||
// Copyright (C) 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/translatepoint.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
TranslatePoint::TranslatePoint ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_xTranslation (DEFAULT_TRANSLATE_POINT_X),
|
||||
m_yTranslation (DEFAULT_TRANSLATE_POINT_Y),
|
||||
m_zTranslation (DEFAULT_TRANSLATE_POINT_Z)
|
||||
{
|
||||
}
|
||||
|
||||
double TranslatePoint::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
return m_pSourceModule[0]->GetValue (x + m_xTranslation, y + m_yTranslation,
|
||||
z + m_zTranslation);
|
||||
}
|
||||
91
src/external/libnoise/src/module/turbulence.cpp
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
// turbulence.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "module/turbulence.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Turbulence::Turbulence ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_power (DEFAULT_TURBULENCE_POWER)
|
||||
{
|
||||
SetSeed (DEFAULT_TURBULENCE_SEED);
|
||||
SetFrequency (DEFAULT_TURBULENCE_FREQUENCY);
|
||||
SetRoughness (DEFAULT_TURBULENCE_ROUGHNESS);
|
||||
}
|
||||
|
||||
double Turbulence::GetFrequency () const
|
||||
{
|
||||
// Since each noise::module::Perlin noise module has the same frequency, it
|
||||
// does not matter which module we use to retrieve the frequency.
|
||||
return m_xDistortModule.GetFrequency ();
|
||||
}
|
||||
|
||||
int Turbulence::GetSeed () const
|
||||
{
|
||||
return m_xDistortModule.GetSeed ();
|
||||
}
|
||||
|
||||
double Turbulence::GetValue (double x, double y, double z) const
|
||||
{
|
||||
assert (m_pSourceModule[0] != NULL);
|
||||
|
||||
// Get the values from the three noise::module::Perlin noise modules and
|
||||
// add each value to each coordinate of the input value. There are also
|
||||
// some offsets added to the coordinates of the input values. This prevents
|
||||
// the distortion modules from returning zero if the (x, y, z) coordinates,
|
||||
// when multiplied by the frequency, are near an integer boundary. This is
|
||||
// due to a property of gradient coherent noise, which returns zero at
|
||||
// integer boundaries.
|
||||
double x0, y0, z0;
|
||||
double x1, y1, z1;
|
||||
double x2, y2, z2;
|
||||
x0 = x + (12414.0 / 65536.0);
|
||||
y0 = y + (65124.0 / 65536.0);
|
||||
z0 = z + (31337.0 / 65536.0);
|
||||
x1 = x + (26519.0 / 65536.0);
|
||||
y1 = y + (18128.0 / 65536.0);
|
||||
z1 = z + (60493.0 / 65536.0);
|
||||
x2 = x + (53820.0 / 65536.0);
|
||||
y2 = y + (11213.0 / 65536.0);
|
||||
z2 = z + (44845.0 / 65536.0);
|
||||
double xDistort = x + (m_xDistortModule.GetValue (x0, y0, z0)
|
||||
* m_power);
|
||||
double yDistort = y + (m_yDistortModule.GetValue (x1, y1, z1)
|
||||
* m_power);
|
||||
double zDistort = z + (m_zDistortModule.GetValue (x2, y2, z2)
|
||||
* m_power);
|
||||
|
||||
// Retrieve the output value at the offsetted input value instead of the
|
||||
// original input value.
|
||||
return m_pSourceModule[0]->GetValue (xDistort, yDistort, zDistort);
|
||||
}
|
||||
|
||||
void Turbulence::SetSeed (int seed)
|
||||
{
|
||||
// Set the seed of each noise::module::Perlin noise modules. To prevent any
|
||||
// sort of weird artifacting, use a slightly different seed for each noise
|
||||
// module.
|
||||
m_xDistortModule.SetSeed (seed );
|
||||
m_yDistortModule.SetSeed (seed + 1);
|
||||
m_zDistortModule.SetSeed (seed + 2);
|
||||
}
|
||||
101
src/external/libnoise/src/module/voronoi.cpp
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
// voronoi.cpp
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#include "mathconsts.h"
|
||||
#include "module/voronoi.h"
|
||||
|
||||
using namespace noise::module;
|
||||
|
||||
Voronoi::Voronoi ():
|
||||
Module (GetSourceModuleCount ()),
|
||||
m_displacement (DEFAULT_VORONOI_DISPLACEMENT),
|
||||
m_enableDistance (false ),
|
||||
m_frequency (DEFAULT_VORONOI_FREQUENCY ),
|
||||
m_seed (DEFAULT_VORONOI_SEED )
|
||||
{
|
||||
}
|
||||
|
||||
double Voronoi::GetValue (double x, double y, double z) const
|
||||
{
|
||||
// This method could be more efficient by caching the seed values. Fix
|
||||
// later.
|
||||
|
||||
x *= m_frequency;
|
||||
y *= m_frequency;
|
||||
z *= m_frequency;
|
||||
|
||||
int xInt = (x > 0.0? (int)x: (int)x - 1);
|
||||
int yInt = (y > 0.0? (int)y: (int)y - 1);
|
||||
int zInt = (z > 0.0? (int)z: (int)z - 1);
|
||||
|
||||
double minDist = 2147483647.0;
|
||||
double xCandidate = 0;
|
||||
double yCandidate = 0;
|
||||
double zCandidate = 0;
|
||||
|
||||
// Inside each unit cube, there is a seed point at a random position. Go
|
||||
// through each of the nearby cubes until we find a cube with a seed point
|
||||
// that is closest to the specified position.
|
||||
for (int zCur = zInt - 2; zCur <= zInt + 2; zCur++) {
|
||||
for (int yCur = yInt - 2; yCur <= yInt + 2; yCur++) {
|
||||
for (int xCur = xInt - 2; xCur <= xInt + 2; xCur++) {
|
||||
|
||||
// Calculate the position and distance to the seed point inside of
|
||||
// this unit cube.
|
||||
double xPos = xCur + ValueNoise3D (xCur, yCur, zCur, m_seed );
|
||||
double yPos = yCur + ValueNoise3D (xCur, yCur, zCur, m_seed + 1);
|
||||
double zPos = zCur + ValueNoise3D (xCur, yCur, zCur, m_seed + 2);
|
||||
double xDist = xPos - x;
|
||||
double yDist = yPos - y;
|
||||
double zDist = zPos - z;
|
||||
double dist = xDist * xDist + yDist * yDist + zDist * zDist;
|
||||
|
||||
if (dist < minDist) {
|
||||
// This seed point is closer to any others found so far, so record
|
||||
// this seed point.
|
||||
minDist = dist;
|
||||
xCandidate = xPos;
|
||||
yCandidate = yPos;
|
||||
zCandidate = zPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double value;
|
||||
if (m_enableDistance) {
|
||||
// Determine the distance to the nearest seed point.
|
||||
double xDist = xCandidate - x;
|
||||
double yDist = yCandidate - y;
|
||||
double zDist = zCandidate - z;
|
||||
value = (sqrt (xDist * xDist + yDist * yDist + zDist * zDist)
|
||||
) * SQRT_3 - 1.0;
|
||||
} else {
|
||||
value = 0.0;
|
||||
}
|
||||
|
||||
// Return the calculated distance with the displacement value applied.
|
||||
return value + (m_displacement * (double)ValueNoise3D (
|
||||
(int)(floor (xCandidate)),
|
||||
(int)(floor (yCandidate)),
|
||||
(int)(floor (zCandidate))));
|
||||
}
|
||||
60
src/external/libnoise/src/noise/basictypes.h
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
// basictypes.h
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#ifndef NOISE_BASICTYPES_H
|
||||
#define NOISE_BASICTYPES_H
|
||||
|
||||
// You may need to modify these constants for your compiler or platform.
|
||||
|
||||
namespace noise
|
||||
{
|
||||
|
||||
/// @defgroup libnoise libnoise
|
||||
/// @addtogroup libnoise
|
||||
/// @{
|
||||
|
||||
/// Unsigned integer type.
|
||||
typedef unsigned int uint;
|
||||
|
||||
/// 32-bit unsigned integer type.
|
||||
typedef unsigned int uint32;
|
||||
|
||||
/// 16-bit unsigned integer type.
|
||||
typedef unsigned short uint16;
|
||||
|
||||
/// 8-bit unsigned integer type.
|
||||
typedef unsigned char uint8;
|
||||
|
||||
/// 32-bit signed integer type.
|
||||
typedef int int32;
|
||||
|
||||
/// 16-bit signed integer type.
|
||||
typedef short int16;
|
||||
|
||||
/// 8-bit signed integer type.
|
||||
typedef char int8;
|
||||
|
||||
/// @}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
74
src/external/libnoise/src/noise/exception.h
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
// exception.h
|
||||
//
|
||||
// Copyright (C) 2003, 2004 Jason Bevins
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
// your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public
|
||||
// License (COPYING.txt) for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this library; if not, write to the Free Software Foundation,
|
||||
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// The developer's email is jlbezigvins@gmzigail.com (for great email, take
|
||||
// off every 'zig'.)
|
||||
//
|
||||
|
||||
#ifndef NOISE_EXCEPTION_H
|
||||
#define NOISE_EXCEPTION_H
|
||||
|
||||
namespace noise
|
||||
{
|
||||
|
||||
/// @addtogroup libnoise
|
||||
/// @{
|
||||
|
||||
/// Abstract base class for libnoise exceptions
|
||||
class Exception
|
||||
{
|
||||
};
|
||||
|
||||
/// Invalid parameter exception
|
||||
///
|
||||
/// An invalid parameter was passed to a libnoise function or method.
|
||||
class ExceptionInvalidParam: public Exception
|
||||
{
|
||||
};
|
||||
|
||||
/// No module exception
|
||||
///
|
||||
/// Could not retrieve a source module from a noise module.
|
||||
///
|
||||
/// @note If one or more required source modules were not connected to a
|
||||
/// specific noise module, and its GetValue() method was called, that
|
||||
/// method will raise a debug assertion instead of this exception. This
|
||||
/// is done for performance reasons.
|
||||
class ExceptionNoModule: public Exception
|
||||
{
|
||||
};
|
||||
|
||||
/// Out of memory exception
|
||||
///
|
||||
/// There was not enough memory to perform an action.
|
||||
class ExceptionOutOfMemory: public Exception
|
||||
{
|
||||
};
|
||||
|
||||
/// Unknown exception
|
||||
///
|
||||
/// libnoise raised an unknown exception.
|
||||
class ExceptionUnknown: public Exception
|
||||
{
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||