diff --git a/.clang-format b/.clang-format
index 2eb120c..fc66707 100644
--- a/.clang-format
+++ b/.clang-format
@@ -16,7 +16,6 @@ BreakBeforeBinaryOperators: false
BreakBeforeBraces: Allman # brace on new line
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
-ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
@@ -37,7 +36,7 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerBindsToType: true
-SortIncludes: false
+SortIncludes: true
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
diff --git a/.travis.yml b/.travis.yml
index 4264a78..79c1976 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,4 +39,6 @@ script:
- mkdir build
- cd build
- ${DEPS_DIR}/cmake/bin/cmake .. && make
-
\ No newline at end of file
+
+services:
+ - docker
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b0d3bd..df7f728 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,18 @@
+# Copyright (c) 2011-2022, Cyrille Favreau
+#
+# 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 for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
cmake_minimum_required(VERSION 3.5)
set(PROJECT_NAME SolR)
@@ -17,10 +32,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
# Project
# ================================================================================
+option(SOLR_RANDOM_DEVICE_ENABLED "Activate Random Device Generator" OFF)
option(SOLR_KINECT_ENABLED "Activate Kinect" OFF)
option(SOLR_OCULUS_ENABLED "Activate Oculus" OFF)
option(SOLR_SIXENSE_ENABLED "Activate Sixense Controller" OFF)
option(SOLR_LEAPMOTION_ENABLED "Activate Leap Motion Controller" OFF)
+option(SOLR_DEFLECT_ENABLED "Activate Deflect streaming" OFF)
+option(SOLR_BUILD_ANARI_DEVICE "Build Sol-R as ANARI library device" OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
@@ -42,9 +60,7 @@ set_property(CACHE SOLR_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED)
if(MSVC)
add_compile_options(-D_USE_MATH_DEFINES -DNOMINMAX -std=c++11)
else(MSVC)
- # __STRICT_ANSI__ is required by OpenCL in order to access x,y,z.. member of
- # cl_float2/3/.. data types. Took me a little while to find out...
- add_compile_options(-std=c++11 -U__STRICT_ANSI__)
+ add_compile_options(-fPIC -std=c++11)
if(APPLE)
add_compile_options(-Wno-c++11-extensions -Wno-narrowing -Wno-deprecated-declarations
-Wno-macro-redefined -Wno-shift-negative-value -Wno-comment)
@@ -120,6 +136,15 @@ if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif(OPENMP_FOUND)
+# ================================================================================
+# Random Generation device
+# ================================================================================
+if(SOLR_RANDOM_DEVICE_ENABLED)
+ # TODO: Find package of random device library and add includes/libs
+ # include_directories(${ ... _INCLUDE_DIR})
+ # list(APPEND FIND_PACKAGES_DEFINES USE_RANDOM_DEVICE)
+endif(SOLR_RANDOM_DEVICE_ENABLED)
+
# ================================================================================
# KINECT 1.8
# ================================================================================
@@ -195,19 +220,53 @@ if(SOLR_LEAPMOTION_ENABLED)
endif(LEAP_FOUND)
endif(SOLR_LEAPMOTION_ENABLED)
+# ================================================================================
+# Deflect
+# ================================================================================
+if(SOLR_DEFLECT_ENABLED)
+ find_package(Deflect REQUIRED SYSTEM)
+ if (Deflect_FOUND)
+ message(STATUS "Deflect found and selected for build")
+ include_directories(${DEFLECT_INCLUDE_DIR})
+ list(APPEND FIND_PACKAGES_DEFINES USE_DEFLECT)
+ else(Deflect_FOUND)
+ message(ERROR " Deflect not found!")
+ endif(Deflect_FOUND)
+endif(SOLR_DEFLECT_ENABLED)
+
+# ================================================================================
+# ANARI SDK (optional)
+# ================================================================================
+if(SOLR_BUILD_ANARI_DEVICE)
+ find_package(anari 0.15.0 REQUIRED)
+ if(anari_FOUND)
+ message(STATUS "ANARI SDK found and selected for ANARI device build")
+ list(APPEND FIND_PACKAGES_DEFINES USE_ANARI)
+ else()
+ message(ERROR "ANARI SDK not found. Cannot build ANARI device")
+ endif()
+endif()
+
# ================================================================================
# Project
# ================================================================================
add_subdirectory(solr)
add_subdirectory(apps)
+# ================================================================================
+# ANARI Device
+# ================================================================================
+if(SOLR_BUILD_ANARI_DEVICE AND anari_FOUND)
+ add_subdirectory(devices)
+endif()
+
# ================================================================================
# Write defines.h and options.cmake
# ================================================================================
if(NOT OPTIONS_CMAKE)
set(OPTIONS_CMAKE ${CMAKE_CURRENT_BINARY_DIR}/options.cmake)
endif(NOT OPTIONS_CMAKE)
-set(DEFINES_FILE "${PROJECT_SOURCE_DIR}/${PROJECT_INCLUDE_NAME}/generated/defines${SYSTEM}.h")
+set(DEFINES_FILE "${PROJECT_SOURCE_DIR}/${PROJECT_INCLUDE_NAME}/generated/solr_defines.h")
file(WRITE ${DEFINES_FILE}
"// generated by CMake, do not edit.\n\n"
"#ifndef ${PROJECT_NAME}_DEFINES_${SYSTEM}_H\n"
diff --git a/DOCKER.md b/DOCKER.md
new file mode 100644
index 0000000..cae12eb
--- /dev/null
+++ b/DOCKER.md
@@ -0,0 +1,33 @@
+# Sol-R with Docker
+
+> Use [Docker](https://docs.docker.com) to run Sol-R as a service and avoid painful tooling setup.
+
+**NOTE**: This is work in progress.
+
+### Prerequisites
+-----------------
+Head over to [Docker](https://docs.docker.com/engine/installation/#supported-platforms) and install Docker for your own platform.
+
+
+### Setup
+---------
+First build the image (*it's necessary to do this step if you want to run Sol-R*):
+```bash
+docker build . -t Sol-R
+```
+
+
+### Usage
+---------
+By default, the entrypoint when running the image is `Sol-R`, but if you want to ssh into the container use:
+```bash
+docker run -ti --rm --entrypoint bash Sol-R
+```
+
+If you want to run Sol-R:
+```bash
+docker run -ti --rm Sol-R
+```
+
+**NOTE** If you are having trouble exiting the process after you run the container (with the above command), use `docker stop ` to stop the container.
+`docker ps` will give you the current running process.
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..3e80892
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,49 @@
+# Docker container for running Sol-R viewer
+FROM ubuntu:xenial
+
+ENV DIST_PATH /app/dist
+ENV BUILD_TOOLS build-essential cmake git wget freeglut3-dev
+
+# Set working dir and copy Sol-R assets
+ENV SOLR_SRC /app/solr
+WORKDIR /app
+ADD . ${SOLR_SRC}
+
+# CUDA 8
+ENV PATH=/usr/local/cuda/bin:$PATH \
+ LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
+
+# Install Sol-R
+# https://github.com/favreau/Sol-R
+RUN apt-get update && \
+ apt-get -y install ${BUILD_TOOLS} && \
+ mkdir ${SOLR_SRC}/tmp && \
+ cd ${SOLR_SRC}/tmp && \
+ wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run && \
+ chmod +x cuda_*_linux-run && ${SOLR_SRC}/tmp/cuda_*_linux-run -extract=${SOLR_SRC}/tmp && \
+ ${SOLR_SRC}/tmp/cuda-linux64-rel*.run -noprompt | cat > /dev/null && \
+ cd ${SOLR_SRC} && \
+ rm -rf tmp && \
+ mkdir build && \
+ cd build && \
+ cmake .. \
+ -DCMAKE_INSTALL_PREFIX=${DIST_PATH} \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DSOLR_ENGINE=CUDA && \
+ make -j8 install && \
+ cd /app && \
+ rm -rf ${SOLR_SRC}/build && \
+ apt-get -y remove ${BUILD_TOOLS} && \
+ apt-get clean
+
+# Add binaries from dist to the PATH
+ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:${DIST_PATH}/lib
+ENV PATH $PATH:${DIST_PATH}/bin
+
+# When running `docker run -ti --rm sol-r`,
+# this will be the cmd that will be executed (+ the CLI options from CMD).
+# To ssh into the container (or override the default entry) use:
+# `docker run -ti --rm --entrypoint bash sol-r`
+# See https://docs.docker.com/engine/reference/run/#entrypoint-default-command-to-execute-at-runtime
+# for more docs
+ENTRYPOINT ["solrViewer"]
diff --git a/LGPL.txt b/LGPL.txt
deleted file mode 100644
index 65c5ca8..0000000
--- a/LGPL.txt
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/LICENSE.txt b/LICENSE.txt
index 9681161..d159169 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,11 +1,339 @@
-Brayns is a minimalistic visualiser that can perform ray-traced rendering of neurons
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
-Brayns is licensed under the LGPL, unless noted otherwise, e.g., for external dependencies. See file LGPL.txt for the full license. External dependencies are either LGPL or BSD-licensed. See file ACKNOWLEDGEMENTS.txt and AUTHORS.txt for further details.
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
-Copyright (c) 2015-2016, EPFL/Blue Brain Project and AUTHORS.txt.
+ Preamble
-This program 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 3 of the License, or (at your option) any later version.
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
-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 Lesser General Public License for more details.
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
-You should have received a copy of the GNU Lesser General Public License along with this program. If not, see .
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+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 Program or any portion
+of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+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 Program, 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 Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) 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; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, 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 executable. However, as a
+special exception, the source code 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.
+
+If distribution of executable or 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 counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program 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.
+
+ 5. 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 Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program 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 to
+this License.
+
+ 7. 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 Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program 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 Program.
+
+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.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program 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.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies 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 Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, 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
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. 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 PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+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.
+
+
+ Copyright (C)
+
+ 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 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.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/README.md b/README.md
index 66d08ae..d0a0c08 100644
--- a/README.md
+++ b/README.md
@@ -1,38 +1,54 @@
[](https://travis-ci.org/favreau/Sol-R)
-### Introduction
+# Welcome to Sol-R, the Speed Of Light Ray-tracer
+
+## Big news: Sol-R goes Quantum!
+
+Sol-R becomes Quantum of Sol-R, thanks to the use of a Quantum Physics based random generation device. Unfortunately, the API to access the random number generator is not open-source but if you buy the [ID Quantique QRng](https://www.idquantique.com/random-number-generation/overview/) device, you will simply need to modify the *_getFloats* implementation of the [RandomGenerator](./solr/engines/random/RandomGenerator.h) class, and I can tell you that it's pretty straight forward! You will also need to add set the _SOLR_RANDOM_DEVICE_ENABLED_ cmake option to _ON_ before configuring the project.
+
+
+
+
+## Note about the Blue Brain BioExplorer, a Sol-R sequel
+
+If you like Sol-R, but you think it's now getting a bit old, you will love my new open-source, the [Blue Brain BioExplorer](https://github.com/BlueBrain/BioExplorer). Check-it out and star the GitHub Repository to support the project.
+
+## Introduction
Sol-R is a CUDA/OpenCL-based realtime ray-tracer compatible with Oculus Rift DK1, Kinect, Razor Hydra and Leap Motion devices.
-Sol-R was used by the Interactive Molecular Visualiser project (http://www.molecular-visualization.com)
+Sol-R was used by the Interactive Molecular Visualizer project (http://www.molecular-visualization.com)
-A number of videos can be found on my channel: https://www.youtube.com/user/CyrilleOnDrums
+A number of videos can be found on my [Youtube channel](https://www.youtube.com/user/CyrilleOnDrums).
Sol-R was written as a hobby project in order to understand and learn more about CUDA and OpenCL. Most of the code was written at night and during week-ends, meaning that it's probably not the best quality ever ;-)
-The idea was to produce a Ray-Tracer that has its own "personality". Most of the code does not rely on any litterature about ray-tracing, but more on a naive approach of what rays could be used for. The idea was not to produce a physically based ray-tracer, but a simple engine that could produce cool images interactively.
+The idea was to produce a Ray-Tracer that has its own "personality". Most of the code does not rely on any literature about ray-tracing, but more on a naive approach of what rays could be used for. A simple engine that could produce cool images interactively.
Take it for what it is! Sol-R is a lot of fun to play with if you like coding computer generated images.
-May the fun continue with your contributions! :-)
+May the fun continue with your contributions! :)
```
usage: solrViewer
```
-### Prerequeries
+
+
+
+## Prerequeries
-#### Mandatory
+### Mandatory
- CMake 3.5
- Glew 2.x
- Glut 3.7
- Cuda 8.0 or OpenCL 1.2
-#### Optional
+### Optional
- Kinect SDK 1.8
- Oculus Rift DK1 SDK 0.2.5
- Sixense SDK
- Leap SDK 3.2.0
-### Build
+## Build from source
```
mkdir Build
cd Build
@@ -41,7 +57,7 @@ make install
```
Note that the installation process with deploy extra files that are needed by the Sol-R viewer. Typically, textures, environment maps and OpenCL kernels. Therefore, it is required to run the solrViewer application from the installation folder.
-### Run
+## Run
```
/bin/solrViewer
```
@@ -58,21 +74,9 @@ Optional dependencies can be activated using the following cmake options:
cmake .. -DSOLR_KINECT_ENABLED=ON -DSOLR_OCULUS_ENABLED=ON -DSOLR_SIXENSE_ENABLED -DSOLR_LEAPMOTION_ENABLED=ON
```
-### Screenshots
-
-
-
-
-
-
-
-
-
-
-
### Supported platforms
Sol-R has currently been tested on:
- Windows 7 with Visual Studio 2015 Community edition
- Mac OS X Sierra 10.12.15
-- Ubuntu 16.04
+- Ubuntu 20.04
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt
index 65c66e9..6f0036f 100644
--- a/apps/CMakeLists.txt
+++ b/apps/CMakeLists.txt
@@ -62,6 +62,10 @@ ADD_EXECUTABLE(
scenes/science/ColumnScene.h
scenes/science/MoleculeScene.cpp
scenes/science/MoleculeScene.h
+ scenes/science/HypercubeScene.cpp
+ scenes/science/HypercubeScene.h
+ scenes/science/TesseractScene.cpp
+ scenes/science/TesseractScene.h
)
diff --git a/apps/common/Types.h b/apps/common/Types.h
index d59598a..df25884 100644
--- a/apps/common/Types.h
+++ b/apps/common/Types.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/common/Utils.cpp b/apps/common/Utils.cpp
index b9a1a9a..e5d27bd 100644
--- a/apps/common/Utils.cpp
+++ b/apps/common/Utils.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "Utils.h"
@@ -33,7 +30,8 @@ Strings getFilesFromFolder(const std::string& folder, const Strings& extensions)
Strings filenames;
#ifdef WIN32
// Textures
- for (Strings::const_iterator it = extensions.begin(); it != extensions.end(); ++it)
+ for (Strings::const_iterator it = extensions.begin();
+ it != extensions.end(); ++it)
{
std::string fullFilter(folder);
fullFilter += "/*";
@@ -60,7 +58,8 @@ Strings getFilesFromFolder(const std::string& folder, const Strings& extensions)
const std::string path = dirp->d_name;
bool ok = false;
- for (Strings::const_iterator it = extensions.begin(); !ok && it != extensions.end(); ++it)
+ for (Strings::const_iterator it = extensions.begin();
+ !ok && it != extensions.end(); ++it)
if (path.find(*it) != std::string::npos)
ok = true;
diff --git a/apps/common/Utils.h b/apps/common/Utils.h
index 9a24df5..d67fda7 100644
--- a/apps/common/Utils.h
+++ b/apps/common/Utils.h
@@ -1,25 +1,23 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
#include "Types.h"
-Strings getFilesFromFolder(const std::string& folder, const Strings& extensions = Strings());
+Strings getFilesFromFolder(const std::string& folder,
+ const Strings& extensions = Strings());
diff --git a/apps/scenes/Scene.cpp b/apps/scenes/Scene.cpp
index 1639f1e..7ee4096 100644
--- a/apps/scenes/Scene.cpp
+++ b/apps/scenes/Scene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
- *
- * This file is part of Sol-R
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * 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 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
// Project
@@ -58,8 +55,6 @@
#include
#endif // USE_SIXENSE
-using namespace solr;
-
const int gTotalPathTracingIterations = 2000;
#ifdef USE_SIXENSE
@@ -85,20 +80,24 @@ std::string controller_manager_text_string;
// 3) Enables hemisphere tracking by calling the Sixense API call
// sixenseAutoEnableHemisphereTracking. After this is completed full 360 degree
// tracking is possible.
-void controller_manager_setup_callback(sixenseUtils::ControllerManager::setup_step step)
+void controller_manager_setup_callback(
+ sixenseUtils::ControllerManager::setup_step step)
{
if (sixenseUtils::getTheControllerManager()->isMenuVisible())
{
- // Turn on the flag that tells the graphics system to draw the instruction
- // screen instead of the controller information. The game
+ // Turn on the flag that tells the graphics system to draw the
+ // instruction screen instead of the controller information. The game
// should be paused at this time.
controller_manager_screen_visible = true;
- // Ask the controller manager what the next instruction string should be.
- controller_manager_text_string = sixenseUtils::getTheControllerManager()->getStepString();
+ // Ask the controller manager what the next instruction string should
+ // be.
+ controller_manager_text_string =
+ sixenseUtils::getTheControllerManager()->getStepString();
// We could also load the supplied controllermanager textures using the
- // filename: sixenseUtils::getTheControllerManager()->getTextureFileName();
+ // filename:
+ // sixenseUtils::getTheControllerManager()->getTextureFileName();
}
else
{
@@ -186,9 +185,11 @@ ________________________________________________________________________________
________________________________________________________________________________
*/
-void Scene::initialize(solr::GPUKernel *kernel, const int width, const int height)
+void Scene::initialize(GPUKernel *kernel, const int width, const int height)
{
- LOG_INFO(1, "--------------------------------------------------------------------------------");
+ LOG_INFO(1,
+ "-----------------------------------------------------------------"
+ "---------------");
LOG_INFO(1, "Scene...............: " << m_name);
m_gpuKernel = kernel;
@@ -200,7 +201,8 @@ void Scene::initialize(solr::GPUKernel *kernel, const int width, const int heigh
// Scene
sceneInfo.size.x = width;
sceneInfo.size.y = height;
- sceneInfo.graphicsLevel = (sceneInfo.cameraType == ctVolumeRendering) ? glNoShading : glFull;
+ sceneInfo.graphicsLevel =
+ (sceneInfo.cameraType == ctVolumeRendering) ? glNoShading : glFull;
sceneInfo.nbRayIterations = 3;
sceneInfo.transparentColor = 0.f;
sceneInfo.viewDistance = 50000.f;
@@ -224,7 +226,7 @@ void Scene::initialize(solr::GPUKernel *kernel, const int width, const int heigh
sceneInfo.skyboxRadius = static_cast(sceneInfo.viewDistance * 0.9f);
sceneInfo.skyboxMaterialId = SKYBOX_SPHERE_MATERIAL;
sceneInfo.gradientBackground = 0;
- sceneInfo.geometryEpsilon = 0.001f;
+ sceneInfo.geometryEpsilon = 0.05f;
sceneInfo.rayEpsilon = 0.05f;
// HDRI
@@ -237,7 +239,8 @@ void Scene::initialize(solr::GPUKernel *kernel, const int width, const int heigh
// Textures
loadTextures(std::string(DEFAULT_MEDIA_FOLDER) + "/textures", filters);
- LOG_INFO(1, "Material textures..: " << m_gpuKernel->getNbActiveTextures() - m_nbHDRI);
+ LOG_INFO(1, "Material textures..: " << m_gpuKernel->getNbActiveTextures() -
+ m_nbHDRI);
// Materials
createRandomMaterials(false, false);
@@ -271,8 +274,10 @@ void Scene::initialize(solr::GPUKernel *kernel, const int width, const int heigh
// Init the controller manager. This makes sure the controllers are present,
// assigned to left and right hands, and that
// the hemisphere calibration is complete.
- sixenseUtils::getTheControllerManager()->setGameType(sixenseUtils::ControllerManager::ONE_PLAYER_TWO_CONTROLLER);
- sixenseUtils::getTheControllerManager()->registerSetupCallback(controller_manager_setup_callback);
+ sixenseUtils::getTheControllerManager()->setGameType(
+ sixenseUtils::ControllerManager::ONE_PLAYER_TWO_CONTROLLER);
+ sixenseUtils::getTheControllerManager()->registerSetupCallback(
+ controller_manager_setup_callback);
m_modelPosition.x = 0.f;
m_modelPosition.y = 0.f;
@@ -337,21 +342,26 @@ ________________________________________________________________________________
void Scene::loadTextures(const std::string &path, const Strings &filters)
{
const Strings textureFiles = getFilesFromFolder(path, filters);
- for (std::vector::const_iterator it = textureFiles.begin(); it != textureFiles.end(); ++it)
- if (m_gpuKernel->loadTextureFromFile(m_gpuKernel->getNbActiveTextures(), *it))
- LOG_INFO(3, "[Slot " << m_gpuKernel->getNbActiveTextures() - 1 << "] Texture " << *it
+ for (std::vector::const_iterator it = textureFiles.begin();
+ it != textureFiles.end(); ++it)
+ if (m_gpuKernel->loadTextureFromFile(m_gpuKernel->getNbActiveTextures(),
+ *it))
+ LOG_INFO(3, "[Slot " << m_gpuKernel->getNbActiveTextures() - 1
+ << "] Texture " << *it
<< " successfully loaded");
}
/*
-________________________________________________________________________________
+___________________________________
+_____________________________________________
Create Random Materials
________________________________________________________________________________
*/
void Scene::createRandomMaterials(bool update, bool lightsOnly)
{
- int nbMaterialTexturePacks = (m_gpuKernel->getNbActiveTextures() - m_nbHDRI) / 5;
+ int nbMaterialTexturePacks =
+ (m_gpuKernel->getNbActiveTextures() - m_nbHDRI) / 5;
int start(0);
int end(NB_MAX_MATERIALS);
if (update)
@@ -366,10 +376,16 @@ void Scene::createRandomMaterials(bool update, bool lightsOnly)
specular.z = 0.f;
specular.w = 0.f;
+ int refractionPower = 5;
+#if 1
float reflection = 0.f;
float refraction = 0.f;
float transparency = 0.f;
- int refractionPower = 5;
+#else
+ float reflection = 0.1f + rand() % 500 / 1000.f;
+ float refraction = 1.01f + 0.1f * (rand() % refractionPower);
+ float transparency = (i % 10 == 0 ? 0.5f + rand() % 500 / 1000.f : 0.f);
+#endif
int diffuseTextureId = TEXTURE_NONE;
int normalTextureId = TEXTURE_NONE;
@@ -378,16 +394,17 @@ void Scene::createRandomMaterials(bool update, bool lightsOnly)
int reflectionTextureId = TEXTURE_NONE;
int transparencyTextureId = TEXTURE_NONE;
int ambientOcclusionTextureId = TEXTURE_NONE;
- vec4f innerIllumination = make_vec4f(0.f, m_gpuKernel->getSceneInfo().viewDistance * 10,
- m_gpuKernel->getSceneInfo().viewDistance);
+ vec4f innerIllumination =
+ make_vec4f(0.f, m_gpuKernel->getSceneInfo().viewDistance * 10,
+ m_gpuKernel->getSceneInfo().viewDistance);
bool procedural = false;
bool wireframe = false;
int wireframeDepth = 0;
- float r, g, b, noise;
+ float r, g, b, gloss;
r = 0.2f + rand() % 600 / 1000.f;
g = 0.2f + rand() % 600 / 1000.f;
b = 0.2f + rand() % 600 / 1000.f;
- noise = 0.f;
+ gloss = 0.f;
float opacity = 0.f;
switch (i)
@@ -426,14 +443,12 @@ void Scene::createRandomMaterials(bool update, bool lightsOnly)
r = 0.5f;
g = 0.5f;
b = 0.5f;
- noise = 0.f;
reflection = 0.f;
break;
case 1099:
r = 0.5f;
g = 0.5f;
b = 0.5f;
- noise = 0.f;
reflection = 0.1f;
break;
@@ -446,7 +461,8 @@ void Scene::createRandomMaterials(bool update, bool lightsOnly)
reflection = 0.25f;
transparency = 0.f;
refraction = 0.f;
- r = g = b = 0.5f;
+ r = g = b = 0.1f;
+ gloss = 0.2f;
}
break;
@@ -631,6 +647,15 @@ void Scene::createRandomMaterials(bool update, bool lightsOnly)
b = 1.f;
innerIllumination.x = 2.f;
break;
+ case METAL_MATERIAL:
+ r = 0.3f;
+ g = 0.3f;
+ b = 0.3f;
+ reflection = 0.5f;
+ specular.x = 1.f;
+ specular.y = 50.f;
+ gloss = 0.5f;
+ break;
default:
if (i >= RANDOM_MATERIALS_OFFSET)
@@ -657,11 +682,13 @@ void Scene::createRandomMaterials(bool update, bool lightsOnly)
{
if (nbMaterialTexturePacks > 0)
{
- int index = m_nbHDRI + 5 * (rand() % nbMaterialTexturePacks);
+ int index =
+ m_nbHDRI + 5 * (rand() % nbMaterialTexturePacks);
for (int t(0); t < 5; ++t)
{
int idx = index + t;
- TextureInfo ti = m_gpuKernel->getTextureInformation(idx);
+ TextureInfo ti =
+ m_gpuKernel->getTextureInformation(idx);
switch (ti.type)
{
case tex_bump:
@@ -701,11 +728,16 @@ void Scene::createRandomMaterials(bool update, bool lightsOnly)
else
m_nbMaterials = m_gpuKernel->addMaterial();
- m_gpuKernel->setMaterial(m_nbMaterials, r, g, b, noise, reflection, refraction, procedural, wireframe,
- wireframeDepth, transparency, opacity, diffuseTextureId, normalTextureId,
- bumpTextureId, specularTextureId, reflectionTextureId, transparencyTextureId,
- ambientOcclusionTextureId, specular.x, specular.y, specular.w, innerIllumination.x,
- innerIllumination.y, innerIllumination.z, false);
+ m_gpuKernel->setMaterial(m_nbMaterials, r, g, b, gloss, reflection,
+ refraction, procedural, wireframe,
+ wireframeDepth, transparency, opacity,
+ diffuseTextureId, normalTextureId,
+ bumpTextureId, specularTextureId,
+ reflectionTextureId, transparencyTextureId,
+ ambientOcclusionTextureId, specular.x,
+ specular.y, specular.w, innerIllumination.x,
+ innerIllumination.y, innerIllumination.z,
+ false);
}
}
@@ -747,7 +779,7 @@ void Scene::createMoleculeMaterials(bool update)
int transparencyTextureId = TEXTURE_NONE;
int ambientOcclusionTextureId = TEXTURE_NONE;
float r, g, b;
- float noise = 0.f;
+ float gloss = 0.f;
bool procedural = false;
r = 0.5f + rand() % 40 / 100.f;
@@ -809,11 +841,15 @@ void Scene::createMoleculeMaterials(bool update)
break; // V
}
m_nbMaterials = m_gpuKernel->addMaterial();
- m_gpuKernel->setMaterial(m_nbMaterials, r, g, b, noise, reflection, refraction, procedural, false, 0,
- transparency, opacity, diffuseTextureId, normalTextureId, bumpTextureId,
- specularTextureId, reflectionTextureId, transparencyTextureId,
- ambientOcclusionTextureId, specular.x, specular.y, specular.w, innerIllumination.x,
- innerIllumination.y, innerIllumination.z, fastTransparency);
+ m_gpuKernel->setMaterial(m_nbMaterials, r, g, b, gloss, reflection,
+ refraction, procedural, false, 0, transparency,
+ opacity, diffuseTextureId, normalTextureId,
+ bumpTextureId, specularTextureId,
+ reflectionTextureId, transparencyTextureId,
+ ambientOcclusionTextureId, specular.x,
+ specular.y, specular.w, innerIllumination.x,
+ innerIllumination.y, innerIllumination.z,
+ fastTransparency);
}
}
@@ -824,7 +860,7 @@ ________________________________________________________________________________
*/
void Scene::saveToFile()
{
- solr::FileMarshaller fm;
+ FileMarshaller fm;
std::string filename(m_name);
filename += ".irt";
fm.saveToFile(*m_gpuKernel, filename);
@@ -837,7 +873,7 @@ ________________________________________________________________________________
*/
void Scene::loadFromFile(const float scale)
{
- solr::FileMarshaller fm;
+ FileMarshaller fm;
std::string filename(m_name);
filename += ".irt";
fm.loadFromFile(*m_gpuKernel, filename, make_vec4f(), scale);
@@ -848,9 +884,9 @@ void Scene::addCornellBox(int boxType)
LOG_INFO(3, "Adding Cornell Box");
LOG_INFO(3, "Ground height = " << m_groundHeight);
vec4f skyBoxSize = make_vec4f(20000.f, 20000.f, 20000.f);
- const vec2f groundSize = make_vec2f(100000.f, 100000.f);
+ const vec2f groundSize = make_vec2f(10000.f, 10000.f);
float groundHeight = m_groundHeight;
- float repeats = 40.f;
+ float repeats = 10.f;
switch (boxType)
{
@@ -1103,8 +1139,11 @@ void Scene::addCornellBox(int boxType)
for (int i(0); i < 25; ++i)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % 20000 - 10000.f, rand() % 20000 - 10000.f,
- rand() % 20000 - 10000.f, 500.f + rand() % 2000, 0.f, 0.f, 1000 + rand() % 30);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % 20000 - 10000.f,
+ rand() % 20000 - 10000.f,
+ rand() % 20000 - 10000.f,
+ 500.f + rand() % 2000, 0.f, 0.f,
+ 1000 + rand() % 30);
}
break;
}
@@ -1112,43 +1151,55 @@ void Scene::addCornellBox(int boxType)
{
// Ground
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCheckboard);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, groundHeight, 0.f, groundSize.x / 4.f, 0.f, groundSize.y / 4,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, groundHeight, 0.f,
+ groundSize.x / 4.f, 0.f, groundSize.y / 4,
RANDOM_MATERIALS_OFFSET);
// Columns
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -5000.f, groundHeight - 1000.f, 5000.f, -4000.f, 8000.f, 5000.f,
- 2000.f, 0.f, 0.f, RANDOM_MATERIALS_OFFSET + 1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -5000.f,
+ groundHeight - 1000.f, 5000.f, -4000.f,
+ 8000.f, 5000.f, 2000.f, 0.f, 0.f,
+ RANDOM_MATERIALS_OFFSET + 1);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, groundHeight - 1000.f, 5000.f, 4000.f, 8000.f, 5000.f, 2000.f,
- 0.f, 0.f, RANDOM_MATERIALS_OFFSET + 2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, groundHeight - 1000.f,
+ 5000.f, 4000.f, 8000.f, 5000.f, 2000.f, 0.f,
+ 0.f, RANDOM_MATERIALS_OFFSET + 2);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
// Spheres
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -5000.f, groundHeight + 1000.f, -5000.f, 1000.f, 0.f, 0.f,
- RANDOM_MATERIALS_OFFSET + 3);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -5000.f,
+ groundHeight + 1000.f, -5000.f, 1000.f, 0.f,
+ 0.f, RANDOM_MATERIALS_OFFSET + 3);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, groundHeight + 1000.f, -5000.f, 1000.f, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, groundHeight + 1000.f,
+ -5000.f, 1000.f, 0.f, 0.f,
RANDOM_MATERIALS_OFFSET + 4);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
// Walls
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXYPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, groundHeight + groundSize.y, groundSize.x, groundSize.x,
- groundSize.y, 0.f, RANDOM_MATERIALS_OFFSET + 5);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f,
+ groundHeight + groundSize.y, groundSize.x,
+ groundSize.x, groundSize.y, 0.f,
+ RANDOM_MATERIALS_OFFSET + 5);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptYZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -groundSize.x, groundHeight + groundSize.y, 0.f, 0.f, groundSize.x,
- groundSize.y, RANDOM_MATERIALS_OFFSET + 6);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -groundSize.x,
+ groundHeight + groundSize.y, 0.f, 0.f,
+ groundSize.x, groundSize.y,
+ RANDOM_MATERIALS_OFFSET + 6);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptYZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, groundSize.x, groundHeight + groundSize.y, 0.f, 0.f, groundSize.x,
- groundSize.y, RANDOM_MATERIALS_OFFSET + 7);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, groundSize.x,
+ groundHeight + groundSize.y, 0.f, 0.f,
+ groundSize.x, groundSize.y,
+ RANDOM_MATERIALS_OFFSET + 7);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
break;
@@ -1156,11 +1207,13 @@ void Scene::addCornellBox(int boxType)
case 7:
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 0.f, 0.f, skyBoxSize.x, 0.f, 0.f, SKYBOX_SPHERE_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 0.f, 0.f, skyBoxSize.x,
+ 0.f, 0.f, SKYBOX_SPHERE_MATERIAL);
const vec2f vt0 = make_vec2f(0.f, 0.f);
const vec2f vt1 = make_vec2f(1.f, 1.f);
const vec2f vt2 = make_vec2f(0.f, 0.f);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, vt0, vt1, vt2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, vt0, vt1,
+ vt2);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
break;
}
@@ -1172,9 +1225,11 @@ void Scene::addCornellBox(int boxType)
float radius = 700.f + float(rand() % 1000);
int material = BASIC_REFLECTION_MATERIAL_002;
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % int(skyBoxSize.x) - skyBoxSize.x / 2,
- m_groundHeight + radius, rand() % int(skyBoxSize.z) - skyBoxSize.z / 2, radius,
- 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(
+ m_nbPrimitives, rand() % int(skyBoxSize.x) - skyBoxSize.x / 2,
+ m_groundHeight + radius,
+ rand() % int(skyBoxSize.z) - skyBoxSize.z / 2, radius, 0.f, 0.f,
+ material);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
break;
@@ -1190,7 +1245,8 @@ void Scene::addCornellBox(int boxType)
glBegin(GL_TRIANGLES);
glVertex3f(skyBoxSize.x, ratio * groundHeight, skyBoxSize.z);
glVertex3f(-skyBoxSize.x, ratio * groundHeight, skyBoxSize.z);
- glVertex3f(-skyBoxSize.x, skyBoxSize.y * ratio * 2.f + groundHeight, skyBoxSize.z);
+ glVertex3f(-skyBoxSize.x, skyBoxSize.y * ratio * 2.f + groundHeight,
+ skyBoxSize.z);
glNormal3f(0.f, 0.f, -1.f);
glNormal3f(0.f, 0.f, -1.f);
glNormal3f(0.f, 0.f, -1.f);
@@ -1207,8 +1263,10 @@ void Scene::addCornellBox(int boxType)
m_gpuKernel->setPrimitiveMaterial(m_nbPrimitives, material);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
glBegin(GL_TRIANGLES);
- glVertex3f(-skyBoxSize.x, 2.f * ratio * skyBoxSize.y + groundHeight, skyBoxSize.z);
- glVertex3f(skyBoxSize.x, 2.f * ratio * skyBoxSize.y + groundHeight, skyBoxSize.z);
+ glVertex3f(-skyBoxSize.x, 2.f * ratio * skyBoxSize.y + groundHeight,
+ skyBoxSize.z);
+ glVertex3f(skyBoxSize.x, 2.f * ratio * skyBoxSize.y + groundHeight,
+ skyBoxSize.z);
glVertex3f(skyBoxSize.x, groundHeight, skyBoxSize.z);
glNormal3f(0.f, 0.f, -1.f);
glNormal3f(0.f, 0.f, -1.f);
@@ -1230,7 +1288,8 @@ void Scene::addCornellBox(int boxType)
case 10:
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, groundHeight - 1000000, 0.f, 1000000.f, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, groundHeight - 1000000,
+ 0.f, 1000000.f, 0.f, 0.f,
SKYBOX_GROUND_MATERIAL);
}
}
@@ -1241,28 +1300,34 @@ void Scene::addCornellBox(int boxType)
// Ground
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptTriangle);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -groundSize.x, groundHeight, -groundSize.y, groundSize.x,
- groundHeight, -groundSize.y, groundSize.x, groundHeight, groundSize.y, 0.f, 0.f,
- 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -groundSize.x,
+ groundHeight, -groundSize.y, groundSize.x,
+ groundHeight, -groundSize.y, groundSize.x,
+ groundHeight, groundSize.y, 0.f, 0.f, 0.f,
+ material);
const vec3f n = make_vec3f(0.f, 1.f, 0.f);
m_gpuKernel->setPrimitiveNormals(m_nbPrimitives, n, n, n);
const vec2f vt0 = make_vec2f();
const vec2f vt1 = make_vec2f(repeats, 0.f);
const vec2f vt2 = make_vec2f(repeats, repeats);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, vt0, vt1, vt2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, vt0,
+ vt1, vt2);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptTriangle);
- m_gpuKernel->setPrimitive(m_nbPrimitives, groundSize.x, groundHeight, groundSize.y, -groundSize.x,
- groundHeight, groundSize.y, -groundSize.x, groundHeight, -groundSize.y, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, groundSize.x,
+ groundHeight, groundSize.y, -groundSize.x,
+ groundHeight, groundSize.y, -groundSize.x,
+ groundHeight, -groundSize.y, 0.f, 0.f,
0.f, material);
const vec3f n = make_vec3f(0.f, 1.f, 0.f);
m_gpuKernel->setPrimitiveNormals(m_nbPrimitives, n, n, n);
const vec2f vt0 = make_vec2f(repeats, repeats);
const vec2f vt1 = make_vec2f(0.f, repeats);
const vec2f vt2 = make_vec2f(0.f, 0.f);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, vt0, vt1, vt2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, vt0,
+ vt1, vt2);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
}
@@ -1279,51 +1344,63 @@ void Scene::createWorm(const vec3f ¢er, int boxId, int material)
{
// Worm on the right hand side
int m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y, center.z, 800.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y, center.z,
+ 800.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
// Eyes
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 400.f, center.y + 500.f, center.z - 400.f, 150.f, 0.f, 0.f,
- 12);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 400.f,
+ center.y + 500.f, center.z - 400.f, 150.f, 0.f,
+ 0.f, 12);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 400.f, center.y + 500.f, center.z - 400.f, 150.f, 0.f, 0.f,
- 12);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 400.f,
+ center.y + 500.f, center.z - 400.f, 150.f, 0.f,
+ 0.f, 12);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 400.f, center.y + 500.f, center.z - 400.f, 200.f, 0.f, 0.f,
- 13);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 400.f,
+ center.y + 500.f, center.z - 400.f, 200.f, 0.f,
+ 0.f, 13);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 400.f, center.y + 500.f, center.z - 400.f, 200.f, 0.f, 0.f,
- 13);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 400.f,
+ center.y + 500.f, center.z - 400.f, 200.f, 0.f,
+ 0.f, 13);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 700.f, center.z, 600.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 700.f,
+ center.z, 600.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1200.f, center.z + 200.f, 600.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1200.f,
+ center.z + 200.f, 600.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1500.f, center.z + 500.f, 600.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1500.f,
+ center.z + 500.f, 600.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1500.f, center.z + 1000.f, 600.f, 0.f, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1500.f,
+ center.z + 1000.f, 600.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1500.f, center.z + 1500.f, 600.f, 0.f, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1500.f,
+ center.z + 1500.f, 600.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1300.f, center.z + 2000.f, 400.f, 0.f, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 1300.f,
+ center.z + 2000.f, 400.f, 0.f, 0.f, material);
// Arms
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 700.f, center.z, center.x - 500.f, center.y - 1200.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 700.f,
+ center.z, center.x - 500.f, center.y - 1200.f,
center.z - 1000.f, 100.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 500.f, center.y - 1200.f, center.z - 1000.f, 300.f, 0.f, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 500.f,
+ center.y - 1200.f, center.z - 1000.f, 300.f, 0.f,
+ 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 700.f, center.z, center.x + 500.f, center.y - 1200.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x, center.y - 700.f,
+ center.z, center.x + 500.f, center.y - 1200.f,
center.z - 1000.f, 100.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 500.f, center.y - 1200.f, center.z - 1000.f, 300.f, 0.f, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 500.f,
+ center.y - 1200.f, center.z - 1000.f, 300.f, 0.f,
+ 0.f, material);
}
/*
@@ -1336,65 +1413,76 @@ void Scene::createDog(const vec3f ¢er, int material, float size, int boxid)
{
// Body
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1000, center.y, center.z, center.x + 1000, center.y, center.z,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1000, center.y,
+ center.z, center.x + 1000, center.y, center.z,
size, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1000, center.y, center.z, size, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1000, center.y,
+ center.z, size, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1000, center.y, center.z, size, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1000, center.y,
+ center.z, size, 0.f, 0.f, material);
// Legs
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y - 2000, center.z - 1000, center.x - 1000,
- center.y, center.z, size, 0, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y - 2000,
+ center.z - 1000, center.x - 1000, center.y,
+ center.z, size, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y - 2000, center.z + 1000, center.x - 1000,
- center.y, center.z, size, 0, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y - 2000,
+ center.z + 1000, center.x - 1000, center.y,
+ center.z, size, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500, center.y - 2000, center.z - 1000, center.x + 1000,
- center.y, center.z, size, 0, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500, center.y - 2000,
+ center.z - 1000, center.x + 1000, center.y,
+ center.z, size, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500, center.y - 2000, center.z + 1000, center.x + 1000,
- center.y, center.z, size, 0, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500, center.y - 2000,
+ center.z + 1000, center.x + 1000, center.y,
+ center.z, size, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y - 2000, center.z - 1000, size, 0, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y - 2000,
+ center.z - 1000, size, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y - 2000, center.z + 1000, size, 0, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y - 2000,
+ center.z + 1000, size, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500, center.y - 2000, center.z - 1000, size, 0, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500, center.y - 2000,
+ center.z - 1000, size, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500, center.y - 2000, center.z + 1000, size, 0, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500, center.y - 2000,
+ center.z + 1000, size, 0, 0.f, material);
// Tail
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y + 1000, center.z, center.x - 1000, center.y,
- center.z, size * 0.8f, 0, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y + 1000,
+ center.z, center.x - 1000, center.y, center.z,
+ size * 0.8f, 0, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y + 1000, center.z, size * 0.8f, 0, 0.f,
- material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x - 1500, center.y + 1000,
+ center.z, size * 0.8f, 0, 0.f, material);
// Head
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1000.f, center.y, center.z, center.x + 1500.f,
- center.y + 1000.f, center.z, size, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1000.f, center.y,
+ center.z, center.x + 1500.f, center.y + 1000.f,
+ center.z, size, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500.f, center.y + 1500.f, center.z, size * 2.f, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500.f,
+ center.y + 1500.f, center.z, size * 2.f, 0.f, 0.f,
material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500.f, center.y + 1500.f, center.z, center.x + 2500.f,
- center.y + 1000.f, center.z, size * 2.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 1500.f,
+ center.y + 1500.f, center.z, center.x + 2500.f,
+ center.y + 1000.f, center.z, size * 2.f, 0.f, 0.f,
+ material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 2500.f, center.y + 1000.f, center.z, size * 2.f, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, center.x + 2500.f,
+ center.y + 1000.f, center.z, size * 2.f, 0.f, 0.f,
material);
}
-void Scene::renderText()
-{
-}
+void Scene::renderText() {}
SceneInfo &Scene::getSceneInfo()
{
@@ -1412,11 +1500,14 @@ void Scene::createSkeleton()
vec4f skyBoxSize = {1600.f, 1200.f, 0.f};
vec4f skyBoxPosition = {3000.f, m_groundHeight - 450.f, 2500.f};
glBegin(GL_TRIANGLES);
- glVertex3f(skyBoxPosition.x + skyBoxSize.x, skyBoxPosition.y - skyBoxSize.y - m_groundHeight,
+ glVertex3f(skyBoxPosition.x + skyBoxSize.x,
+ skyBoxPosition.y - skyBoxSize.y - m_groundHeight,
skyBoxPosition.z + skyBoxSize.z);
- glVertex3f(skyBoxPosition.x - skyBoxSize.x, skyBoxPosition.y - skyBoxSize.y - m_groundHeight,
+ glVertex3f(skyBoxPosition.x - skyBoxSize.x,
+ skyBoxPosition.y - skyBoxSize.y - m_groundHeight,
skyBoxPosition.z + skyBoxSize.z);
- glVertex3f(skyBoxPosition.x - skyBoxSize.x, skyBoxPosition.y + skyBoxSize.y - m_groundHeight,
+ glVertex3f(skyBoxPosition.x - skyBoxSize.x,
+ skyBoxPosition.y + skyBoxSize.y - m_groundHeight,
skyBoxPosition.z + skyBoxSize.z);
glNormal3f(0.f, 0.f, -1.f);
glNormal3f(0.f, 0.f, -1.f);
@@ -1429,11 +1520,14 @@ void Scene::createSkeleton()
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
glBegin(GL_TRIANGLES);
- glVertex3f(skyBoxPosition.x - skyBoxSize.x, skyBoxPosition.y + skyBoxSize.y - m_groundHeight,
+ glVertex3f(skyBoxPosition.x - skyBoxSize.x,
+ skyBoxPosition.y + skyBoxSize.y - m_groundHeight,
skyBoxPosition.z + skyBoxSize.z);
- glVertex3f(skyBoxPosition.x + skyBoxSize.x, skyBoxPosition.y + skyBoxSize.y - m_groundHeight,
+ glVertex3f(skyBoxPosition.x + skyBoxSize.x,
+ skyBoxPosition.y + skyBoxSize.y - m_groundHeight,
skyBoxPosition.z + skyBoxSize.z);
- glVertex3f(skyBoxPosition.x + skyBoxSize.x, skyBoxPosition.y - skyBoxSize.y - m_groundHeight,
+ glVertex3f(skyBoxPosition.x + skyBoxSize.x,
+ skyBoxPosition.y - skyBoxSize.y - m_groundHeight,
skyBoxPosition.z + skyBoxSize.z);
glNormal3f(0.f, 0.f, -1.f);
glNormal3f(0.f, 0.f, -1.f);
@@ -1448,7 +1542,8 @@ void Scene::createSkeleton()
for (int i(0); i < 20; ++i)
{
int primitive = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(primitive, 0.f, 0.f, 0.f, m_skeletonSize, 0.f, 0.f, 0);
+ m_gpuKernel->setPrimitive(primitive, 0.f, 0.f, 0.f, m_skeletonSize, 0.f,
+ 0.f, 0);
if (i == 0)
m_skeletonPrimitiveIndex = primitive;
}
@@ -1464,26 +1559,34 @@ void Scene::animateSkeleton()
{
#ifdef USE_KINECT
m_skeletonPosition.y = m_groundHeight;
- int hr = m_gpuKernel->updateSkeletons(m_skeletonPrimitiveIndex,
- m_skeletonPosition, // Position
- m_skeletonSize, // Skeleton size
- m_skeletonThickness, 40, // Default material
- m_skeletonThickness * 2.0f, 41, // Head size and material
- m_skeletonThickness * 1.5f, 42, // Hands size and material
- m_skeletonThickness * 1.8f, 43 // Feet size and material
- );
+ int hr = m_gpuKernel->updateSkeletons(
+ m_skeletonPrimitiveIndex,
+ m_skeletonPosition, // Position
+ m_skeletonSize, // Skeleton size
+ m_skeletonThickness, 40, // Default material
+ m_skeletonThickness * 2.0f, 41, // Head size and material
+ m_skeletonThickness * 1.5f, 42, // Hands size and material
+ m_skeletonThickness * 1.8f, 43 // Feet size and material
+ );
m_gpuKernel->getSceneInfo().pathTracingIteration = 0;
if (hr == S_OK)
{
vec3f position;
// Head
- if (m_gpuKernel->getSkeletonPosition(NUI_SKELETON_POSITION_HEAD, position))
+ if (m_gpuKernel->getSkeletonPosition(NUI_SKELETON_POSITION_HEAD,
+ position))
{
vec4f amplitude;
- amplitude.x = (position.x * m_skeletonKinectSize - m_gpuKernel->getViewPos().x) / 2.f;
- amplitude.y = (position.y * m_skeletonKinectSize - m_gpuKernel->getViewPos().y) / 2.f;
- amplitude.z = ((100.f + 200.f - position.z * m_skeletonKinectSize) - m_gpuKernel->getViewPos().z) / 2.f;
+ amplitude.x = (position.x * m_skeletonKinectSize -
+ m_gpuKernel->getViewPos().x) /
+ 2.f;
+ amplitude.y = (position.y * m_skeletonKinectSize -
+ m_gpuKernel->getViewPos().y) /
+ 2.f;
+ amplitude.z = ((100.f + 200.f - position.z * m_skeletonKinectSize) -
+ m_gpuKernel->getViewPos().z) /
+ 2.f;
m_gpuKernel->getViewPos().x += amplitude.x;
m_gpuKernel->getViewPos().y += amplitude.y;
@@ -1528,19 +1631,26 @@ void Scene::animateSkeleton()
// See if it's enabled
if (sixenseIsControllerEnabled(cont))
{
- LOG_INFO(3, "Controller " << cont << ", left=" << left_index << ", right=" << right_index);
+ LOG_INFO(3, "Controller " << cont << ", left=" << left_index
+ << ", right=" << right_index);
if (cont == left_index)
{
// if this is the left controller
vec4f angles;
- angles.x = PI * (m_modelRotationAngle.x - acd.controllers[cont].rot_quat[0]);
- angles.y = PI * (m_modelRotationAngle.y - acd.controllers[cont].rot_quat[1]);
- angles.z = PI * (m_modelRotationAngle.z + acd.controllers[cont].rot_quat[2]);
+ angles.x = PI * (m_modelRotationAngle.x -
+ acd.controllers[cont].rot_quat[0]);
+ angles.y = PI * (m_modelRotationAngle.y -
+ acd.controllers[cont].rot_quat[1]);
+ angles.z = PI * (m_modelRotationAngle.z +
+ acd.controllers[cont].rot_quat[2]);
vec3f translation;
- translation.x = 10.f * (acd.controllers[cont].pos[0] - m_modelTranslation.x);
- translation.y = 10.f * (acd.controllers[cont].pos[1] - m_modelTranslation.y);
- translation.z = 10.f * (m_modelTranslation.z - acd.controllers[cont].pos[2]);
+ translation.x = 10.f * (acd.controllers[cont].pos[0] -
+ m_modelTranslation.x);
+ translation.y = 10.f * (acd.controllers[cont].pos[1] -
+ m_modelTranslation.y);
+ translation.z = 10.f * (m_modelTranslation.z -
+ acd.controllers[cont].pos[2]);
m_gpuKernel->getSceneInfo().pathTracingIteration = 0;
m_gpuKernel->rotatePrimitives(m_modelPosition, angles);
@@ -1565,24 +1675,34 @@ void Scene::animateSkeleton()
createRandomMaterials(true, false);
if (left_states.buttonJustPressed(SIXENSE_BUTTON_3))
m_gpuKernel->getSceneInfo().graphicsLevel =
- static_cast((m_gpuKernel->getSceneInfo().graphicsLevel + 1) % 5);
+ static_cast(
+ (m_gpuKernel->getSceneInfo().graphicsLevel +
+ 1) %
+ 5);
if (left_states.buttonJustPressed(SIXENSE_BUTTON_4))
{
m_gpuKernel->getPostProcessingInfo().type++;
- m_gpuKernel->getPostProcessingInfo().type = m_gpuKernel->getPostProcessingInfo().type % 4;
+ m_gpuKernel->getPostProcessingInfo().type =
+ m_gpuKernel->getPostProcessingInfo().type % 4;
}
// Joystick / Camera
- m_gpuKernel->getViewPos().x += 100.f * acd.controllers[cont].joystick_x;
- m_gpuKernel->getViewDir().x += 100.f * acd.controllers[cont].joystick_x;
- m_gpuKernel->getViewPos().z += 100.f * acd.controllers[cont].joystick_y;
- m_gpuKernel->getViewDir().z += 100.f * acd.controllers[cont].joystick_y;
+ m_gpuKernel->getViewPos().x +=
+ 100.f * acd.controllers[cont].joystick_x;
+ m_gpuKernel->getViewDir().x +=
+ 100.f * acd.controllers[cont].joystick_x;
+ m_gpuKernel->getViewPos().z +=
+ 100.f * acd.controllers[cont].joystick_y;
+ m_gpuKernel->getViewDir().z +=
+ 100.f * acd.controllers[cont].joystick_y;
}
if (cont == right_index)
{
- m_gpuKernel->getSceneInfo().eyeSeparation += 50.f * acd.controllers[cont].joystick_x;
- m_gpuKernel->getViewDir().z += 50.f * acd.controllers[cont].joystick_y;
+ m_gpuKernel->getSceneInfo().eyeSeparation +=
+ 50.f * acd.controllers[cont].joystick_x;
+ m_gpuKernel->getViewDir().z +=
+ 50.f * acd.controllers[cont].joystick_y;
}
}
}
diff --git a/apps/scenes/Scene.h b/apps/scenes/Scene.h
index 27d8006..93e83d2 100644
--- a/apps/scenes/Scene.h
+++ b/apps/scenes/Scene.h
@@ -1,31 +1,31 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
#include
+#include
// Raytracer
#include
#include
+using namespace solr;
+
class Scene
{
public:
@@ -33,7 +33,7 @@ class Scene
virtual ~Scene(void);
public:
- void initialize(solr::GPUKernel* kernel, const int width, const int height);
+ void initialize(GPUKernel* kernel, const int width, const int height);
void animate();
void render(const bool& animate);
@@ -58,7 +58,10 @@ class Scene
std::string& getName();
int getCornellBox() { return m_cornellBoxType; }
- void setCornellBoxType(int cornellBoxType) { m_cornellBoxType = cornellBoxType; }
+ void setCornellBoxType(int cornellBoxType)
+ {
+ m_cornellBoxType = cornellBoxType;
+ }
float getGroundHeight() { return m_groundHeight; }
void setGroundHeight(const float h) { m_groundHeight = h; }
@@ -67,11 +70,14 @@ class Scene
public:
int getNbPrimitives() { return m_gpuKernel->getNbActivePrimitives(); }
- solr::GPUKernel* getKernel() { return m_gpuKernel; }
+ GPUKernel* getKernel() { return m_gpuKernel; }
int getNbHDRI() { return m_nbHDRI; }
public:
- void setCurrentModel(const int& currentModel) { m_currentModel = currentModel; }
+ void setCurrentModel(const int& currentModel)
+ {
+ m_currentModel = currentModel;
+ }
protected:
virtual void doInitialize() = 0;
@@ -85,7 +91,7 @@ class Scene
protected:
std::string m_name;
- solr::GPUKernel* m_gpuKernel;
+ GPUKernel* m_gpuKernel;
// Textures
int m_nbHDRI;
diff --git a/apps/scenes/animation/AnimationScene.cpp b/apps/scenes/animation/AnimationScene.cpp
index 77cd456..57735aa 100644
--- a/apps/scenes/animation/AnimationScene.cpp
+++ b/apps/scenes/animation/AnimationScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "AnimationScene.h"
@@ -48,9 +45,7 @@ AnimationScene::AnimationScene(const std::string& name)
m_forward = true;
}
-AnimationScene::~AnimationScene(void)
-{
-}
+AnimationScene::~AnimationScene(void) {}
void AnimationScene::doInitialize()
{
@@ -82,13 +77,14 @@ void AnimationScene::doInitialize()
m_gpuKernel->resetFrame();
solr::CPUBoundingBox aabb;
solr::CPUBoundingBox inAABB;
- objReader.loadModelFromFile(fileName, *m_gpuKernel, center, false, objectSize, (frame == 0), m,
- false, true, aabb, false, inAABB);
+ objReader.loadModelFromFile(fileName, *m_gpuKernel, center, false,
+ objectSize, (frame == 0), m, false, true,
+ aabb, false, inAABB);
// lights
- m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -10000.f, 10000.f, -10000.f, 100.f, 100.f, 100.f,
- DEFAULT_LIGHT_MATERIAL);
+ m_nbPrimitives = m_gpuKernel->addPrimitive(solr::ptSphere);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -10000.f, 10000.f, -10000.f,
+ 100.f, 100.f, 100.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
addCornellBox(m_cornellBoxType);
@@ -108,6 +104,4 @@ void AnimationScene::doAnimate()
m_currentFrame = m_currentFrame % nbFrames;
}
-void AnimationScene::doAddLights()
-{
-}
+void AnimationScene::doAddLights() {}
diff --git a/apps/scenes/animation/AnimationScene.h b/apps/scenes/animation/AnimationScene.h
index 72b1597..55c5dcb 100644
--- a/apps/scenes/animation/AnimationScene.h
+++ b/apps/scenes/animation/AnimationScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/animation/KinectFaceTrackingScene.cpp b/apps/scenes/animation/KinectFaceTrackingScene.cpp
index 63c8196..9612463 100644
--- a/apps/scenes/animation/KinectFaceTrackingScene.cpp
+++ b/apps/scenes/animation/KinectFaceTrackingScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "KinectFaceTrackingScene.h"
@@ -30,17 +27,13 @@
#pragma comment(lib, "FaceTrackLib.lib")
-using namespace solr;
-
KinectFaceTrackingScene::KinectFaceTrackingScene(const std::string& name)
: Scene(name)
, m_faceTracker(nullptr)
{
}
-KinectFaceTrackingScene::~KinectFaceTrackingScene(void)
-{
-}
+KinectFaceTrackingScene::~KinectFaceTrackingScene(void) {}
void KinectFaceTrackingScene::doInitialize()
{
@@ -53,17 +46,22 @@ void KinectFaceTrackingScene::doAnimate()
if (m_faceTracker)
{
// Video camera config with width, height, focal length in pixels
- // NUI_CAMERA_COLOR_NOMINAL_FOCAL_LENGTH_IN_PIXELS focal length is computed for 640x480 resolution
- // If you use different resolutions, multiply this focal length by the scaling factor
- FT_CAMERA_CONFIG videoCameraConfig = {640, 480, NUI_CAMERA_COLOR_NOMINAL_FOCAL_LENGTH_IN_PIXELS};
+ // NUI_CAMERA_COLOR_NOMINAL_FOCAL_LENGTH_IN_PIXELS focal length is
+ // computed for 640x480 resolution If you use different resolutions,
+ // multiply this focal length by the scaling factor
+ FT_CAMERA_CONFIG videoCameraConfig = {
+ 640, 480, NUI_CAMERA_COLOR_NOMINAL_FOCAL_LENGTH_IN_PIXELS};
// Depth camera config with width, height, focal length in pixels
- // NUI_CAMERA_COLOR_NOMINAL_FOCAL_LENGTH_IN_PIXELS focal length is computed for 320x240 resolution
- // If you use different resolutions, multiply this focal length by the scaling factor
- FT_CAMERA_CONFIG depthCameraConfig = {320, 240, NUI_CAMERA_DEPTH_NOMINAL_FOCAL_LENGTH_IN_PIXELS};
+ // NUI_CAMERA_COLOR_NOMINAL_FOCAL_LENGTH_IN_PIXELS focal length is
+ // computed for 320x240 resolution If you use different resolutions,
+ // multiply this focal length by the scaling factor
+ FT_CAMERA_CONFIG depthCameraConfig = {
+ 320, 240, NUI_CAMERA_DEPTH_NOMINAL_FOCAL_LENGTH_IN_PIXELS};
// Initialize the face tracker
- HRESULT hr = m_faceTracker->Initialize(&videoCameraConfig, &depthCameraConfig, NULL, NULL);
+ HRESULT hr = m_faceTracker->Initialize(&videoCameraConfig,
+ &depthCameraConfig, NULL, NULL);
if (FAILED(hr))
{
// Handle errors
@@ -97,14 +95,16 @@ void KinectFaceTrackingScene::doAnimate()
FLOAT translation[3] = {0.f, 0.f, 0.f};
UINT vertexCount(0);
FT_VECTOR3D* vertices(nullptr);
- hr = model->Get3DShape(shapeUnits, suCount, animationUnits, auCount, scale, rotation, translation,
- vertices, vertexCount);
+ hr = model->Get3DShape(shapeUnits, suCount, animationUnits,
+ auCount, scale, rotation,
+ translation, vertices, vertexCount);
LOG_INFO(1, "Get3DShape: " << vertexCount << " vertices");
FT_TRIANGLE* triangles;
UINT triangleCount;
hr = model->GetTriangles(&triangles, &triangleCount);
- LOG_INFO(1, "GetTriangles: " << triangleCount << " triangles");
+ LOG_INFO(1,
+ "GetTriangles: " << triangleCount << " triangles");
if (FAILED(hr))
{
// Handle errors
@@ -114,11 +114,14 @@ void KinectFaceTrackingScene::doAnimate()
for (UINT i(0); i < triangleCount; ++i)
{
glBegin(GL_TRIANGLES);
- glVertex3f(vertices[triangles[i].i].x, vertices[triangles[i].i].y,
+ glVertex3f(vertices[triangles[i].i].x,
+ vertices[triangles[i].i].y,
vertices[triangles[i].i].z);
- glVertex3f(vertices[triangles[i].j].x, vertices[triangles[i].j].y,
+ glVertex3f(vertices[triangles[i].j].x,
+ vertices[triangles[i].j].y,
vertices[triangles[i].j].z);
- glVertex3f(vertices[triangles[i].k].x, vertices[triangles[i].k].y,
+ glVertex3f(vertices[triangles[i].k].x,
+ vertices[triangles[i].k].y,
vertices[triangles[i].k].z);
glNormal3f(0.f, 0.f, -1.f);
glNormal3f(0.f, 0.f, -1.f);
@@ -147,7 +150,8 @@ void KinectFaceTrackingScene::doAddLights()
{
LOG_INFO(3, "Adding sun light");
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -5000.f, 5000.f, -5000.f, 10.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -5000.f, 5000.f, -5000.f,
+ 10.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
}
diff --git a/apps/scenes/animation/KinectFaceTrackingScene.h b/apps/scenes/animation/KinectFaceTrackingScene.h
index 7a4e6fc..74063fb 100644
--- a/apps/scenes/animation/KinectFaceTrackingScene.h
+++ b/apps/scenes/animation/KinectFaceTrackingScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/animation/MetaballsScene.cpp b/apps/scenes/animation/MetaballsScene.cpp
index f8bb112..9381823 100644
--- a/apps/scenes/animation/MetaballsScene.cpp
+++ b/apps/scenes/animation/MetaballsScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "MetaballsScene.h"
@@ -26,10 +23,8 @@
#include
#endif // USE_LEAPMOTION
-#include
#include
-
-using namespace solr;
+#include
const int minGridSize = 40;
float threshold = 1.0f;
@@ -39,15 +34,19 @@ unsigned int gridSize = 60;
unsigned int numMetaballs = 20;
vec4f size = {numMetaballs * 10.f, numMetaballs * 10.f, numMetaballs * 10.f};
vec4f amplitude = {size.x / 5.f, size.y / 5.f, size.z / 5.f};
-vec4f scale = {2500.f / numMetaballs, 2500.f / numMetaballs, 2500.f / numMetaballs};
+vec4f scale = {2500.f / numMetaballs, 2500.f / numMetaballs,
+ 2500.f / numMetaballs};
#else
unsigned int gridSize = 50;
unsigned int numMetaballs = 50;
const int gridScale = 3.f;
-vec3f size = make_vec3f(static_cast(numMetaballs * gridScale), static_cast(numMetaballs* gridScale),
- static_cast(numMetaballs* gridScale));
-const vec3f amplitude = make_vec3f(size.x / gridScale, size.y / gridScale, size.z / gridScale);
-const vec3f scale = make_vec3f(2000.f / numMetaballs, 2000.f / numMetaballs, 2000.f / numMetaballs);
+vec3f size = make_vec3f(static_cast(numMetaballs * gridScale),
+ static_cast(numMetaballs* gridScale),
+ static_cast(numMetaballs* gridScale));
+const vec3f amplitude =
+ make_vec3f(size.x / gridScale, size.y / gridScale, size.z / gridScale);
+const vec3f scale = make_vec3f(2000.f / numMetaballs, 2000.f / numMetaballs,
+ 2000.f / numMetaballs);
#endif // USE_KINECT
METABALL metaballs[50];
@@ -62,7 +61,8 @@ MetaballsScene::MetaballsScene(const std::string& name)
#endif // USE_LEAPMOTION
{
// initialise the metaBall_ size and positions
- vertices = new CUBE_GRID_VERTEX[(maxGridSize + 1) * (maxGridSize + 1) * (maxGridSize + 1)];
+ vertices = new CUBE_GRID_VERTEX[(maxGridSize + 1) * (maxGridSize + 1) *
+ (maxGridSize + 1)];
cubes = new CUBE_GRID_CUBE[maxGridSize * maxGridSize * maxGridSize];
}
@@ -95,13 +95,20 @@ void MetaballsScene::Init()
{
for (unsigned int k = 0; k < gridSize + 1; k++)
{
- const size_t currentVertex = i * (gridSize + 1) * (gridSize + 1) + j * (gridSize + 1) + k;
- vertices[currentVertex].position.x = (i * size.x) / (gridSize)-size.x / 2.f;
- vertices[currentVertex].position.y = (j * size.y) / (gridSize)-size.y / 2.f;
- vertices[currentVertex].position.z = (k * size.z) / (gridSize)-size.z / 2.f;
-
- vertices[currentVertex].textCoords.x = static_cast(i) / static_cast(gridSize);
- vertices[currentVertex].textCoords.y = static_cast(j) / static_cast(gridSize);
+ const size_t currentVertex =
+ i * (gridSize + 1) * (gridSize + 1) + j * (gridSize + 1) +
+ k;
+ vertices[currentVertex].position.x =
+ (i * size.x) / (gridSize)-size.x / 2.f;
+ vertices[currentVertex].position.y =
+ (j * size.y) / (gridSize)-size.y / 2.f;
+ vertices[currentVertex].position.z =
+ (k * size.z) / (gridSize)-size.z / 2.f;
+
+ vertices[currentVertex].textCoords.x =
+ static_cast(i) / static_cast(gridSize);
+ vertices[currentVertex].textCoords.y =
+ static_cast(j) / static_cast(gridSize);
;
vertices[currentVertex].textCoords.z = 0.f;
}
@@ -118,16 +125,33 @@ void MetaballsScene::Init()
{
for (unsigned int k = 0; k < gridSize; k++)
{
- const size_t currentCube = i * gridSize * gridSize + j * gridSize + k;
- cubes[currentCube].vertices[0] = &vertices[(i * (gridSize + 1) + j) * (gridSize + 1) + k];
- cubes[currentCube].vertices[1] = &vertices[(i * (gridSize + 1) + j) * (gridSize + 1) + k + 1];
- cubes[currentCube].vertices[2] = &vertices[(i * (gridSize + 1) + (j + 1)) * (gridSize + 1) + k + 1];
- cubes[currentCube].vertices[3] = &vertices[(i * (gridSize + 1) + (j + 1)) * (gridSize + 1) + k];
- cubes[currentCube].vertices[4] = &vertices[((i + 1) * (gridSize + 1) + j) * (gridSize + 1) + k];
- cubes[currentCube].vertices[5] = &vertices[((i + 1) * (gridSize + 1) + j) * (gridSize + 1) + k + 1];
+ const size_t currentCube =
+ i * gridSize * gridSize + j * gridSize + k;
+ cubes[currentCube].vertices[0] =
+ &vertices[(i * (gridSize + 1) + j) * (gridSize + 1) + k];
+ cubes[currentCube].vertices[1] =
+ &vertices[(i * (gridSize + 1) + j) * (gridSize + 1) + k +
+ 1];
+ cubes[currentCube].vertices[2] =
+ &vertices[(i * (gridSize + 1) + (j + 1)) * (gridSize + 1) +
+ k + 1];
+ cubes[currentCube].vertices[3] =
+ &vertices[(i * (gridSize + 1) + (j + 1)) * (gridSize + 1) +
+ k];
+ cubes[currentCube].vertices[4] =
+ &vertices[((i + 1) * (gridSize + 1) + j) * (gridSize + 1) +
+ k];
+ cubes[currentCube].vertices[5] =
+ &vertices[((i + 1) * (gridSize + 1) + j) * (gridSize + 1) +
+ k + 1];
cubes[currentCube].vertices[6] =
- &vertices[((i + 1) * (gridSize + 1) + (j + 1)) * (gridSize + 1) + k + 1];
- cubes[currentCube].vertices[7] = &vertices[((i + 1) * (gridSize + 1) + (j + 1)) * (gridSize + 1) + k];
+ &vertices[((i + 1) * (gridSize + 1) + (j + 1)) *
+ (gridSize + 1) +
+ k + 1];
+ cubes[currentCube].vertices[7] =
+ &vertices[((i + 1) * (gridSize + 1) + (j + 1)) *
+ (gridSize + 1) +
+ k];
}
}
}
@@ -181,12 +205,14 @@ void MetaballsScene::doAnimate()
const auto finger = fingers[j];
for (int k = 0; k < 4; ++k)
{
- const auto bone = finger.bone(static_cast(k));
+ const auto bone =
+ finger.bone(static_cast(k));
const auto v = bone.center();
metaballs[i].position.x = v.x / 2;
metaballs[i].position.y = v.y / 2 - 40;
metaballs[i].position.z = -v.z / 2 + 40;
- metaballs[i].squaredRadius = finger.width() * finger.width() / 4;
+ metaballs[i].squaredRadius =
+ finger.width() * finger.width() / 4;
++i;
}
}
@@ -216,28 +242,68 @@ void MetaballsScene::doAnimate()
switch (i % 4)
{
case 0:
- metaballs[i].position.x = center.x - ratio * amplitude.x * (float)cos(timer / (740 + i * numMetaballs)) - c;
- metaballs[i].position.y = center.z + ratio * amplitude.y * (float)sin(timer / (620 + i * numMetaballs)) - c;
- metaballs[i].position.z = center.y + fabs(ratio * amplitude.z * (float)sin(cos(timer / (500 + i))) - c);
+ metaballs[i].position.x =
+ center.x -
+ ratio * amplitude.x *
+ (float)cos(timer / (740 + i * numMetaballs)) -
+ c;
+ metaballs[i].position.y =
+ center.z +
+ ratio * amplitude.y *
+ (float)sin(timer / (620 + i * numMetaballs)) -
+ c;
+ metaballs[i].position.z =
+ center.y + fabs(ratio * amplitude.z *
+ (float)sin(cos(timer / (500 + i))) -
+ c);
break;
case 1:
- metaballs[i].position.x = center.x + ratio * amplitude.x * (float)sin(timer / (420 + i * numMetaballs)) + c;
- metaballs[i].position.y = center.z - ratio * amplitude.y * (float)cos(timer / (340 + i * numMetaballs)) - c;
- metaballs[i].position.z = center.y + fabs(ratio * amplitude.z * (float)sin(cos(timer / (400 + i))) - c);
+ metaballs[i].position.x =
+ center.x +
+ ratio * amplitude.x *
+ (float)sin(timer / (420 + i * numMetaballs)) +
+ c;
+ metaballs[i].position.y =
+ center.z -
+ ratio * amplitude.y *
+ (float)cos(timer / (340 + i * numMetaballs)) -
+ c;
+ metaballs[i].position.z =
+ center.y + fabs(ratio * amplitude.z *
+ (float)sin(cos(timer / (400 + i))) -
+ c);
break;
case 2:
- metaballs[i].position.x = center.x + ratio * amplitude.x * (float)cos(timer / (820 + numMetaballs)) -
- 0.2f * (float)sin(timer / 600);
- metaballs[i].position.y = center.z + ratio * amplitude.y * (float)sin(timer / (512 + numMetaballs)) -
- 0.2f * (float)sin(timer / 400);
- metaballs[i].position.z = center.y + fabs(ratio * amplitude.z * (float)sin(cos(timer / (450 + i))) - c);
+ metaballs[i].position.x =
+ center.x +
+ ratio * amplitude.x *
+ (float)cos(timer / (820 + numMetaballs)) -
+ 0.2f * (float)sin(timer / 600);
+ metaballs[i].position.y =
+ center.z +
+ ratio * amplitude.y *
+ (float)sin(timer / (512 + numMetaballs)) -
+ 0.2f * (float)sin(timer / 400);
+ metaballs[i].position.z =
+ center.y + fabs(ratio * amplitude.z *
+ (float)sin(cos(timer / (450 + i))) -
+ c);
break;
case 3:
- metaballs[i].position.x = center.x + ratio * amplitude.x * (float)cos(timer / (1200 + numMetaballs)) -
- 0.4f * (float)sin(timer / 1250);
- metaballs[i].position.y = center.z + ratio * amplitude.y * (float)sin(timer / (2120 + numMetaballs)) -
- 0.4f * (float)sin(timer / 640);
- metaballs[i].position.z = center.y + fabs(ratio * amplitude.z * (float)sin(cos(timer / (450 + i))) - c);
+ metaballs[i].position.x =
+ center.x +
+ ratio * amplitude.x *
+ (float)cos(timer / (1200 + numMetaballs)) -
+ 0.4f * (float)sin(timer / 1250);
+ metaballs[i].position.y =
+ center.z +
+ ratio * amplitude.y *
+ (float)sin(timer / (2120 + numMetaballs)) -
+ 0.4f * (float)sin(timer / 640);
+ metaballs[i].position.z =
+ center.y + fabs(ratio * amplitude.z *
+ (float)sin(cos(timer / (450 + i))) -
+ c);
break;
}
}
@@ -279,8 +345,9 @@ void MetaballsScene::doAnimate()
// get squared distance from ball to point
// float squaredDistance=ballToPoint.GetSquaredLength();
- float squaredDistance =
- ballToPoint.x * ballToPoint.x + ballToPoint.y * ballToPoint.y + ballToPoint.z * ballToPoint.z;
+ float squaredDistance = ballToPoint.x * ballToPoint.x +
+ ballToPoint.y * ballToPoint.y +
+ ballToPoint.z * ballToPoint.z;
if (squaredDistance == 0.0f)
squaredDistance = 0.0001f;
@@ -323,7 +390,8 @@ void MetaballsScene::doAnimate()
if (cubes[i].vertices[7]->value < threshold)
cubeIndex |= 128;
- // look this value up in the edge table to see which edges to interpolate along
+ // look this value up in the edge table to see which edges to
+ // interpolate along
int usedEdges = edgeTable[cubeIndex];
// if the cube is entirely within/outside surface, no faces
@@ -335,18 +403,32 @@ void MetaballsScene::doAnimate()
{
if (usedEdges & 1 << currentEdge)
{
- CUBE_GRID_VERTEX* v1 = cubes[i].vertices[verticesAtEndsOfEdges[currentEdge * 2]];
- CUBE_GRID_VERTEX* v2 = cubes[i].vertices[verticesAtEndsOfEdges[currentEdge * 2 + 1]];
-
- float delta = (threshold - v1->value) / (v2->value - v1->value);
-
- edgeVertices[currentEdge].position.x = v1->position.x + delta * (v2->position.x - v1->position.x);
- edgeVertices[currentEdge].position.y = v1->position.y + delta * (v2->position.y - v1->position.y);
- edgeVertices[currentEdge].position.z = v1->position.z + delta * (v2->position.z - v1->position.z);
-
- edgeVertices[currentEdge].normal.x = v1->normal.x + delta * (v2->normal.x - v1->normal.x);
- edgeVertices[currentEdge].normal.y = v1->normal.y + delta * (v2->normal.y - v1->normal.y);
- edgeVertices[currentEdge].normal.z = v1->normal.z + delta * (v2->normal.z - v1->normal.z);
+ CUBE_GRID_VERTEX* v1 =
+ cubes[i]
+ .vertices[verticesAtEndsOfEdges[currentEdge * 2]];
+ CUBE_GRID_VERTEX* v2 =
+ cubes[i].vertices
+ [verticesAtEndsOfEdges[currentEdge * 2 + 1]];
+
+ float delta =
+ (threshold - v1->value) / (v2->value - v1->value);
+
+ edgeVertices[currentEdge].position.x =
+ v1->position.x +
+ delta * (v2->position.x - v1->position.x);
+ edgeVertices[currentEdge].position.y =
+ v1->position.y +
+ delta * (v2->position.y - v1->position.y);
+ edgeVertices[currentEdge].position.z =
+ v1->position.z +
+ delta * (v2->position.z - v1->position.z);
+
+ edgeVertices[currentEdge].normal.x =
+ v1->normal.x + delta * (v2->normal.x - v1->normal.x);
+ edgeVertices[currentEdge].normal.y =
+ v1->normal.y + delta * (v2->normal.y - v1->normal.y);
+ edgeVertices[currentEdge].normal.z =
+ v1->normal.z + delta * (v2->normal.z - v1->normal.z);
}
}
@@ -368,9 +450,12 @@ void MetaballsScene::doAnimate()
v = edgeVertices[triTable[cubeIndex][k]].position;
t = edgeVertices[triTable[cubeIndex][k]].texCoords;
glNormal3f(n.x, n.y, n.z);
- glTexCoord2f((v.x / minGridSize) + 1.5f, (v.z / minGridSize) + 1.5f);
+ glTexCoord2f((v.x / minGridSize) + 1.5f,
+ (v.z / minGridSize) + 1.5f);
// glTexCoord2f(t.x,t.y);
- glVertex3f(center.x + scale.x * v.x, center.y + scale.x * v.y, center.z + scale.z * v.z);
+ glVertex3f(center.x + scale.x * v.x,
+ center.y + scale.x * v.y,
+ center.z + scale.z * v.z);
}
{
@@ -378,9 +463,12 @@ void MetaballsScene::doAnimate()
v = edgeVertices[triTable[cubeIndex][k + 1]].position;
t = edgeVertices[triTable[cubeIndex][k + 1]].texCoords;
glNormal3f(n.x, n.y, n.z);
- glTexCoord2f((v.x / minGridSize) + 1.5f, (v.z / minGridSize) + 1.5f);
+ glTexCoord2f((v.x / minGridSize) + 1.5f,
+ (v.z / minGridSize) + 1.5f);
// glTexCoord2f(t.x,t.y);
- glVertex3f(center.x + scale.x * v.x, center.y + scale.x * v.y, center.z + scale.z * v.z);
+ glVertex3f(center.x + scale.x * v.x,
+ center.y + scale.x * v.y,
+ center.z + scale.z * v.z);
}
{
@@ -388,9 +476,12 @@ void MetaballsScene::doAnimate()
v = edgeVertices[triTable[cubeIndex][k + 2]].position;
t = edgeVertices[triTable[cubeIndex][k + 2]].texCoords;
glNormal3f(n.x, n.y, n.z);
- glTexCoord2f((v.x / minGridSize) + 1.5f, (v.z / minGridSize) + 1.5f);
+ glTexCoord2f((v.x / minGridSize) + 1.5f,
+ (v.z / minGridSize) + 1.5f);
// glTexCoord2f(t.x,t.y);
- glVertex3f(center.x + scale.x * v.x, center.y + scale.x * v.y, center.z + scale.z * v.z);
+ glVertex3f(center.x + scale.x * v.x,
+ center.y + scale.x * v.y,
+ center.z + scale.z * v.z);
}
glEnd();
@@ -405,11 +496,13 @@ void MetaballsScene::doAnimate()
// Lamp
#ifdef USE_KINECT
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -8000.f, 8000.f, -8000.f, 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -8000.f, 8000.f, -8000.f, 500.f,
+ 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
#else
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -10000.f, 10000.f, -10000.f, 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -10000.f, 10000.f, -10000.f,
+ 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
#endif // USE_KINECT
@@ -431,11 +524,20 @@ void MetaballsScene::initializeLeapMotion()
m_leapMotionController = new Leap::Controller();
if (m_leapMotionController)
{
- LOG_INFO(1, "--------------------------------------------------------------------------------");
- LOG_INFO(1, " Leap Motion initialized! m(o_o)m");
- LOG_INFO(1, "--------------------------------------------------------------------------------");
- LOG_INFO(1, "Connected: " << (m_leapMotionController->isConnected() ? "Yes" : "No"));
- LOG_INFO(1, "--------------------------------------------------------------------------------");
+ LOG_INFO(1,
+ "---------------------------------------------------------"
+ "-----------------------");
+ LOG_INFO(1,
+ " Leap Motion initialized! m(o_o)m");
+ LOG_INFO(1,
+ "---------------------------------------------------------"
+ "-----------------------");
+ LOG_INFO(1, "Connected: " << (m_leapMotionController->isConnected()
+ ? "Yes"
+ : "No"));
+ LOG_INFO(1,
+ "---------------------------------------------------------"
+ "-----------------------");
}
}
}
diff --git a/apps/scenes/animation/MetaballsScene.h b/apps/scenes/animation/MetaballsScene.h
index 0d0f4ee..59b9318 100644
--- a/apps/scenes/animation/MetaballsScene.h
+++ b/apps/scenes/animation/MetaballsScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
@@ -97,284 +94,294 @@ class CUBE_GRID
};
// gives the vertices at the end of each edge
-const int verticesAtEndsOfEdges[24] = {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7};
+const int verticesAtEndsOfEdges[24] = {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,
+ 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7};
// gives the edges to interpolate along given vertex inside/outside
const int edgeTable[256] = {
- 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
- 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
- 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
- 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
- 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
- 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
- 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
- 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
- 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
- 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
- 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
- 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,
- 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,
- 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,
- 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,
- 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0};
+ 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f,
+ 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f,
+ 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 0x230,
+ 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936,
+ 0xe3a, 0xf33, 0xc39, 0xd30, 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5,
+ 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, 0x460, 0x569,
+ 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a,
+ 0x963, 0xa69, 0xb60, 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,
+ 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 0x650, 0x759, 0x453,
+ 0x55a, 0x256, 0x35f, 0x55, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53,
+ 0x859, 0x950, 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, 0xfcc,
+ 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 0x8c0, 0x9c9, 0xac3, 0xbca,
+ 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9,
+ 0x7c0, 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55,
+ 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6,
+ 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
+ 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f,
+ 0x66, 0x76a, 0x663, 0x569, 0x460, 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af,
+ 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0, 0xd30,
+ 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636,
+ 0x13a, 0x33, 0x339, 0x230, 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895,
+ 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190, 0xf00, 0xe09,
+ 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a,
+ 0x203, 0x109, 0x0};
// gives which vertices to join to form triangles for the surface
-const int triTable[256][16] = {{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
- {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
- {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
- {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
- {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
- {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
- {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
- {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
- {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
- {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
- {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
- {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
- {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
- {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
- {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
- {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
- {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
- {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
- {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
- {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
- {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
- {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
- {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
- {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
- {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
- {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
- {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
- {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
- {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
- {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
- {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
- {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
- {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
- {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
- {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
- {5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
- {11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
- {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
- {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
- {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
- {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
- {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
- {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
- {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
- {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
- {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
- {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
- {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
- {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
- {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
- {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
- {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
- {7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
- {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
- {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
- {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
- {9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
- {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
- {5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
- {0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
- {6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
- {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
- {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
- {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
- {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
- {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
- {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
- {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
- {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
- {6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
- {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
- {8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
- {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
- {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
- {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
- {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
- {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
- {2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
- {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
- {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
- {2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
- {1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
- {11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
- {8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
- {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
- {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
- {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
- {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
- {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
- {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
- {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
- {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
- {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
- {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
- {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
- {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
- {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
- {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
- {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
- {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
- {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
- {10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
- {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
- {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
- {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
- {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
- {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
- {4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
- {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
- {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
- {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
- {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
- {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
- {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
- {3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
- {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
- {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
- {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
- {6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
- {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
- {1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
- {4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
- {7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
- {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
- {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
- {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
- {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
- {0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
- {11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
- {6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
- {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
- {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
- {1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
- {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
- {10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
- {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
- {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
- {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
- {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
- {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
- {7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
- {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
- {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
- {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
- {9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
- {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
- {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
- {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
- {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
- {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
- {10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
- {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
- {0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
- {0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
- {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
- {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
- {3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
- {5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
- {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
- {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
- {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
- {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
- {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
- {3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
- {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
- {9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
- {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
- {11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
- {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
- {9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
- {3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
- {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
- {4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
- {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
- {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
- {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
- {3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
- {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
- {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
- {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
- {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};
+const int triTable[256][16] = {
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
+ {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
+ {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
+ {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
+ {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
+ {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
+ {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
+ {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
+ {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
+ {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
+ {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
+ {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
+ {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
+ {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
+ {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
+ {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
+ {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
+ {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
+ {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
+ {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
+ {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
+ {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
+ {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
+ {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
+ {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
+ {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
+ {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
+ {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
+ {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
+ {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
+ {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
+ {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
+ {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
+ {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
+ {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
+ {5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
+ {11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
+ {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
+ {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
+ {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
+ {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
+ {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
+ {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
+ {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
+ {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
+ {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
+ {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
+ {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
+ {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
+ {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
+ {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
+ {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
+ {7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
+ {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
+ {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
+ {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
+ {9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
+ {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
+ {5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
+ {0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
+ {6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
+ {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
+ {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
+ {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
+ {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
+ {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
+ {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
+ {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
+ {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
+ {6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
+ {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
+ {8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
+ {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
+ {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
+ {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
+ {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
+ {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
+ {2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
+ {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
+ {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
+ {2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
+ {1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
+ {11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
+ {8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
+ {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
+ {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
+ {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
+ {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
+ {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
+ {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
+ {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
+ {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
+ {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
+ {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
+ {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
+ {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
+ {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
+ {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
+ {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
+ {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
+ {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
+ {10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
+ {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
+ {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
+ {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
+ {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
+ {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
+ {4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
+ {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
+ {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
+ {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
+ {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
+ {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
+ {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
+ {3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
+ {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
+ {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
+ {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
+ {6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
+ {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
+ {1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
+ {4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
+ {7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
+ {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
+ {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
+ {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
+ {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
+ {0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
+ {11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
+ {6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
+ {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
+ {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
+ {1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
+ {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
+ {10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
+ {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
+ {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
+ {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
+ {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
+ {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
+ {7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
+ {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
+ {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
+ {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
+ {9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
+ {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
+ {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
+ {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
+ {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
+ {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
+ {10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
+ {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
+ {0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
+ {0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
+ {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
+ {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
+ {3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
+ {5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
+ {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
+ {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
+ {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
+ {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
+ {3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
+ {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
+ {9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
+ {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
+ {11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
+ {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
+ {9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
+ {3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
+ {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
+ {4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
+ {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
+ {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
+ {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
+ {3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
+ {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
+ {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
+ {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};
class MetaballsScene : public Scene
{
diff --git a/apps/scenes/animation/WaterScene.cpp b/apps/scenes/animation/WaterScene.cpp
index edb15ca..790cc92 100644
--- a/apps/scenes/animation/WaterScene.cpp
+++ b/apps/scenes/animation/WaterScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "WaterScene.h"
@@ -33,9 +30,7 @@ WaterScene::WaterScene(const std::string& name)
{
}
-WaterScene::~WaterScene(void)
-{
-}
+WaterScene::~WaterScene(void) {}
vec3f WaterScene::F(float x, float z, float stepX, float stepZ)
{
@@ -79,10 +74,12 @@ void WaterScene::processCurve(bool update)
float tstep = step * 2.f;
int primitiveIndex(m_initialIndex - 1);
float tx = 0.f;
- for (float x = -static_cast(M_PI); x < static_cast(M_PI) - step / 2.f; x += step)
+ for (float x = -static_cast(M_PI);
+ x < static_cast(M_PI) - step / 2.f; x += step)
{
float ty = 0.f;
- for (float z = -static_cast(M_PI); z < static_cast(M_PI) - step / 2.f; z += step)
+ for (float z = -static_cast(M_PI);
+ z < static_cast(M_PI) - step / 2.f; z += step)
{
// Face
int index(0);
@@ -98,8 +95,12 @@ void WaterScene::processCurve(bool update)
// Normal
const vec3f P1p = F(x + X + step, z + Z, X / 2.f, Z / 2.f);
const vec3f P3p = F(x + X, z + Z + step, X / 2.f, Z / 2.f);
- vec3f v1 = make_vec3f(P1p.x - vertices[index].x, P1p.y - vertices[index].y, P1p.z - vertices[index].z);
- vec3f v3 = make_vec3f(P3p.x - vertices[index].x, P3p.y - vertices[index].y, P3p.z - vertices[index].z);
+ vec3f v1 = make_vec3f(P1p.x - vertices[index].x,
+ P1p.y - vertices[index].y,
+ P1p.z - vertices[index].z);
+ vec3f v3 = make_vec3f(P3p.x - vertices[index].x,
+ P3p.y - vertices[index].y,
+ P3p.z - vertices[index].z);
m_gpuKernel->normalizeVector(v1);
m_gpuKernel->normalizeVector(v3);
verticesNormals[index] = m_gpuKernel->crossProduct(v1, v3);
@@ -119,20 +120,25 @@ void WaterScene::processCurve(bool update)
}
m_gpuKernel->setPrimitive(
primitiveIndex, m_objectSize.x * vertices[0].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[0].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[0].y,
m_objectSize.z * vertices[0].z, m_objectSize.x * vertices[2].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[2].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[2].y,
m_objectSize.z * vertices[2].z, m_objectSize.x * vertices[3].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[3].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[3].y,
m_objectSize.z * vertices[3].z, 0.f, 0.f, 0.f, m_material);
- m_gpuKernel->setPrimitiveNormals(primitiveIndex, verticesNormals[0], verticesNormals[2],
+ m_gpuKernel->setPrimitiveNormals(primitiveIndex, verticesNormals[0],
+ verticesNormals[2],
verticesNormals[3]);
{
const vec2f tc0 = make_vec2f(tx, ty);
const vec2f tc1 = make_vec2f(tx + tstep, ty);
const vec2f tc2 = make_vec2f(tx + tstep, ty + tstep);
- m_gpuKernel->setPrimitiveTextureCoordinates(primitiveIndex, tc0, tc1, tc2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(primitiveIndex, tc0,
+ tc1, tc2);
}
if (update)
@@ -144,20 +150,25 @@ void WaterScene::processCurve(bool update)
}
m_gpuKernel->setPrimitive(
primitiveIndex, m_objectSize.x * vertices[3].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[3].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[3].y,
m_objectSize.z * vertices[3].z, m_objectSize.x * vertices[1].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[1].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[1].y,
m_objectSize.z * vertices[1].z, m_objectSize.x * vertices[0].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[0].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[0].y,
m_objectSize.z * vertices[0].z, 0.f, 0.f, 0.f, m_material);
- m_gpuKernel->setPrimitiveNormals(primitiveIndex, verticesNormals[3], verticesNormals[1],
+ m_gpuKernel->setPrimitiveNormals(primitiveIndex, verticesNormals[3],
+ verticesNormals[1],
verticesNormals[0]);
{
const vec2f tc0 = make_vec2f(tx + tstep, ty + tstep);
const vec2f tc1 = make_vec2f(tx, ty + tstep);
const vec2f tc2 = make_vec2f(tx, ty);
- m_gpuKernel->setPrimitiveTextureCoordinates(primitiveIndex, tc0, tc1, tc2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(primitiveIndex, tc0,
+ tc1, tc2);
}
ty += tstep;
}
@@ -187,8 +198,12 @@ void WaterScene::processParametricCurve(bool update)
// Normal
const vec3f P1p = P(t, X / 2.f, Z / 2.f);
const vec3f P3p = P(t, X / 2.f, Z / 2.f);
- vec3f v1 = make_vec3f(P1p.x - vertices[index].x, P1p.y - vertices[index].y, P1p.z - vertices[index].z);
- vec3f v3 = make_vec3f(P3p.x - vertices[index].x, P3p.y - vertices[index].y, P3p.z - vertices[index].z);
+ vec3f v1 = make_vec3f(P1p.x - vertices[index].x,
+ P1p.y - vertices[index].y,
+ P1p.z - vertices[index].z);
+ vec3f v3 = make_vec3f(P3p.x - vertices[index].x,
+ P3p.y - vertices[index].y,
+ P3p.z - vertices[index].z);
m_gpuKernel->normalizeVector(v1);
m_gpuKernel->normalizeVector(v3);
verticesNormals[index] = m_gpuKernel->crossProduct(v1, v3);
@@ -207,13 +222,17 @@ void WaterScene::processParametricCurve(bool update)
}
m_gpuKernel->setPrimitive(
primitiveIndex, m_objectSize.x * vertices[0].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[0].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[0].y,
m_objectSize.z * vertices[0].z, m_objectSize.x * vertices[2].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[2].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[2].y,
m_objectSize.z * vertices[2].z, m_objectSize.x * vertices[3].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[3].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[3].y,
m_objectSize.z * vertices[3].z, 0.f, 0.f, 0.f, m_material);
- m_gpuKernel->setPrimitiveNormals(primitiveIndex, verticesNormals[0], verticesNormals[2],
+ m_gpuKernel->setPrimitiveNormals(primitiveIndex, verticesNormals[0],
+ verticesNormals[2],
verticesNormals[3]);
if (update)
@@ -225,13 +244,17 @@ void WaterScene::processParametricCurve(bool update)
}
m_gpuKernel->setPrimitive(
primitiveIndex, m_objectSize.x * vertices[3].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[3].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[3].y,
m_objectSize.z * vertices[3].z, m_objectSize.x * vertices[1].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[1].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[1].y,
m_objectSize.z * vertices[1].z, m_objectSize.x * vertices[0].x,
- m_groundHeight + 2.f * m_objectSize.y * m_scale.y + m_objectSize.y * vertices[0].y,
+ m_groundHeight + 2.f * m_objectSize.y * m_scale.y +
+ m_objectSize.y * vertices[0].y,
m_objectSize.z * vertices[0].z, 0.f, 0.f, 0.f, m_material);
- m_gpuKernel->setPrimitiveNormals(primitiveIndex, verticesNormals[3], verticesNormals[1],
+ m_gpuKernel->setPrimitiveNormals(primitiveIndex, verticesNormals[3],
+ verticesNormals[1],
verticesNormals[0]);
}
}
@@ -265,7 +288,8 @@ void WaterScene::doAddLights()
if (m_gpuKernel->getNbActiveLamps() == 0)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 8000.f, 8000.f, -8000.f, 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 8000.f, 8000.f, -8000.f,
+ 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
}
diff --git a/apps/scenes/animation/WaterScene.h b/apps/scenes/animation/WaterScene.h
index fc744e9..d2fc098 100644
--- a/apps/scenes/animation/WaterScene.h
+++ b/apps/scenes/animation/WaterScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/experiments/CornellBoxScene.cpp b/apps/scenes/experiments/CornellBoxScene.cpp
index 3754455..d811e9e 100644
--- a/apps/scenes/experiments/CornellBoxScene.cpp
+++ b/apps/scenes/experiments/CornellBoxScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "CornellBoxScene.h"
@@ -31,23 +28,25 @@ CornellBoxScene::CornellBoxScene(const std::string& name)
{
}
-CornellBoxScene::~CornellBoxScene(void)
-{
-}
+CornellBoxScene::~CornellBoxScene(void) {}
void CornellBoxScene::doInitialize()
{
m_groundHeight = -5000.f;
// Spheres
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 2200.f, 0.f, 0.f, 2000.f, 0.f, 0.f, rand() % 50);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 2200.f, 0.f, 0.f, 2000.f, 0.f,
+ 0.f, rand() % 50);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -2200.f, 0.f, 0.f, 2000.f, 0.f, 0.f, rand() % 50);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -2200.f, 0.f, 0.f, 2000.f, 0.f,
+ 0.f, rand() % 50);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 2200.f, 0.f, 2000.f, 0.f, 0.f, rand() % 50);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 2200.f, 0.f, 2000.f, 0.f,
+ 0.f, rand() % 50);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, -2200.f, 0.f, 2000.f, 0.f, 0.f, rand() % 50);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, -2200.f, 0.f, 2000.f, 0.f,
+ 0.f, rand() % 50);
m_gpuKernel->getSceneInfo().nbRayIterations = 20;
}
@@ -67,8 +66,10 @@ void CornellBoxScene::doAddLights()
{
// lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % 20000 - 10000.f, rand() % 5000 - m_groundHeight,
- rand() % 20000 - 10000.f, 10.f, 0.f, 0.f, 120 + i);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % 20000 - 10000.f,
+ rand() % 5000 - m_groundHeight,
+ rand() % 20000 - 10000.f, 10.f, 0.f, 0.f,
+ 120 + i);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
}
diff --git a/apps/scenes/experiments/CornellBoxScene.h b/apps/scenes/experiments/CornellBoxScene.h
index c170515..cf78a7c 100644
--- a/apps/scenes/experiments/CornellBoxScene.h
+++ b/apps/scenes/experiments/CornellBoxScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/experiments/CubesScene.cpp b/apps/scenes/experiments/CubesScene.cpp
index 1a96406..5607362 100644
--- a/apps/scenes/experiments/CubesScene.cpp
+++ b/apps/scenes/experiments/CubesScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "CubesScene.h"
@@ -31,9 +28,7 @@ CubesScene::CubesScene(const std::string& name)
{
}
-CubesScene::~CubesScene(void)
-{
-}
+CubesScene::~CubesScene(void) {}
void CubesScene::doInitialize()
{
@@ -55,9 +50,7 @@ void CubesScene::doInitialize()
m_gpuKernel->getSceneInfo().nbRayIterations = 20;
}
-void CubesScene::doAnimate()
-{
-}
+void CubesScene::doAnimate() {}
void CubesScene::doAddLights()
{
@@ -65,7 +58,8 @@ void CubesScene::doAddLights()
if (m_gpuKernel->getNbActiveLamps() == 0)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 8000.f, 8000.f, -8000.f, 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 8000.f, 8000.f, -8000.f,
+ 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
}
diff --git a/apps/scenes/experiments/CubesScene.h b/apps/scenes/experiments/CubesScene.h
index a53d5f0..6aa7d54 100644
--- a/apps/scenes/experiments/CubesScene.h
+++ b/apps/scenes/experiments/CubesScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/experiments/CylinderScene.cpp b/apps/scenes/experiments/CylinderScene.cpp
index 848027e..16f7670 100644
--- a/apps/scenes/experiments/CylinderScene.cpp
+++ b/apps/scenes/experiments/CylinderScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
- *
- * This file is part of Sol-R
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * 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 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "CylinderScene.h"
@@ -31,9 +28,7 @@ CylinderScene::CylinderScene(const std::string& name)
{
}
-CylinderScene::~CylinderScene(void)
-{
-}
+CylinderScene::~CylinderScene(void) {}
/*
________________________________________________________________________________
@@ -75,26 +70,35 @@ void CylinderScene::doInitialize()
m_gpuKernel->setPrimitive(m_nbPrimitives, 2500, 0, 0, 1000, 0.f, 0.f, 55);
m_vt0 = make_vec2f();
m_vt1 = make_vec2f(10.f, 10.f);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, m_vt0, m_vt1, m_vt2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, m_vt0, m_vt1,
+ m_vt2);
m_mappedSphere = m_nbPrimitives;
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -2500, 0, 0, 1000.f, 0.f, 0.f, 45);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, m_vt0, m_vt1, m_vt2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -2500, 0, 0, 1000.f, 0.f, 0.f,
+ 45);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, m_vt0, m_vt1,
+ m_vt2);
// Cylinders
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -1000, 1000, 0, 1000, -1000, 0, size, size, 0.f, rand() % 100);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -1000, 1000, 0, 1000, -1000, 0,
+ size, size, 0.f, rand() % 100);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -1000, -1000, 0, size, 0.f, 0.f, rand() % 40);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -1000, -1000, 0, size, 0.f, 0.f,
+ rand() % 40);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 1000, 1000, 0, size, 0.f, 0.f, LIGHT_MATERIAL_001 /*rand()%40*/);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 1000, 1000, 0, size, 0.f, 0.f,
+ LIGHT_MATERIAL_001 /*rand()%40*/);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -1000, -1000, 0, 1000, 1000, 0, size, size, 0.f, rand() % 100);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -1000, -1000, 0, 1000, 1000, 0,
+ size, size, 0.f, rand() % 100);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -1000, 1000, 0, size, 0.f, 0.f, rand() % 40);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -1000, 1000, 0, size, 0.f, 0.f,
+ rand() % 40);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 1000, -1000, 0, size, 0.f, 0.f, LIGHT_MATERIAL_002 /*rand()%40*/);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 1000, -1000, 0, size, 0.f, 0.f,
+ LIGHT_MATERIAL_002 /*rand()%40*/);
#endif // 1
m_gpuKernel->getSceneInfo().nbRayIterations = 20;
@@ -106,8 +110,10 @@ void CylinderScene::doAnimate()
m_gpuKernel->rotatePrimitives(m_rotationCenter, m_rotationAngles);
m_vt0.x = -PI / 2.f;
m_vt0.y -= 0.05f;
- m_gpuKernel->setPrimitiveTextureCoordinates(m_mappedSphere, m_vt0, m_vt1, m_vt2);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_mappedSphere + 1, m_vt0, m_vt1, m_vt2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_mappedSphere, m_vt0, m_vt1,
+ m_vt2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_mappedSphere + 1, m_vt0,
+ m_vt1, m_vt2);
m_gpuKernel->compactBoxes(false);
}
@@ -115,6 +121,7 @@ void CylinderScene::doAddLights()
{
// lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 10000.f, -10000.f, 2000.f, 0.f, 0, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 10000.f, -10000.f, 2000.f,
+ 0.f, 0, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
diff --git a/apps/scenes/experiments/CylinderScene.h b/apps/scenes/experiments/CylinderScene.h
index b28a8e0..4f6cf2a 100644
--- a/apps/scenes/experiments/CylinderScene.h
+++ b/apps/scenes/experiments/CylinderScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
@@ -38,5 +35,4 @@ class CylinderScene : public Scene
vec2f m_vt0;
vec2f m_vt1;
vec2f m_vt2;
-
};
diff --git a/apps/scenes/experiments/DoggyStyleScene.cpp b/apps/scenes/experiments/DoggyStyleScene.cpp
index b4a94a0..dde2846 100644
--- a/apps/scenes/experiments/DoggyStyleScene.cpp
+++ b/apps/scenes/experiments/DoggyStyleScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "DoggyStyleScene.h"
@@ -33,9 +30,7 @@ DoggyStyleScene::DoggyStyleScene(const std::string& name)
{
}
-DoggyStyleScene::~DoggyStyleScene(void)
-{
-}
+DoggyStyleScene::~DoggyStyleScene(void) {}
void DoggyStyleScene::doInitialize()
{
@@ -47,19 +42,20 @@ void DoggyStyleScene::doInitialize()
m_gpuKernel->rotatePrimitives(center, angles);
}
-void DoggyStyleScene::doAnimate()
-{
-}
+void DoggyStyleScene::doAnimate() {}
void DoggyStyleScene::doAddLights()
{
// Laser
for (int i = 0; i < 3; ++i)
{
- const vec4f p1 = make_vec4f(rand() % 10000 - 5000.f, 5000.f, rand() % 10000 - 5000.f);
- const vec4f p2 = make_vec4f(-(rand() % 10000 - 5000.f), -5000.f, -(rand() % 10000 - 5000.f));
+ const vec4f p1 = make_vec4f(rand() % 10000 - 5000.f, 5000.f,
+ rand() % 10000 - 5000.f);
+ const vec4f p2 = make_vec4f(-(rand() % 10000 - 5000.f), -5000.f,
+ -(rand() % 10000 - 5000.f));
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, 100.f, 100.f, 100.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, p1.x, p1.y, p1.z, p2.x, p2.y,
+ p2.z, 100.f, 100.f, 100.f,
DEFAULT_LIGHT_MATERIAL - i);
}
}
diff --git a/apps/scenes/experiments/DoggyStyleScene.h b/apps/scenes/experiments/DoggyStyleScene.h
index e6a4fa5..f9d9b03 100644
--- a/apps/scenes/experiments/DoggyStyleScene.h
+++ b/apps/scenes/experiments/DoggyStyleScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/experiments/GalleryScene.cpp b/apps/scenes/experiments/GalleryScene.cpp
index c5eee4a..df7a050 100644
--- a/apps/scenes/experiments/GalleryScene.cpp
+++ b/apps/scenes/experiments/GalleryScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "GalleryScene.h"
@@ -35,9 +32,7 @@ GalleryScene::GalleryScene(const std::string& name)
m_groundHeight = -2500.f;
}
-GalleryScene::~GalleryScene(void)
-{
-}
+GalleryScene::~GalleryScene(void) {}
void GalleryScene::doInitialize()
{
@@ -82,37 +77,53 @@ void GalleryScene::doInitialize()
p3.y = y + step.y - frame.y; // sin(y+step.y);
p3.z = sin(x + frame.x);
- const vec3f normal0 = make_vec3f(position.x - p0.x, position.y - p0.y, position.z - p0.z);
- const vec3f normal1 = make_vec3f(position.x - p1.x, position.y - p1.y, position.z - p1.z);
- const vec3f normal2 = make_vec3f(position.x - p2.x, position.y - p2.y, position.z - p2.z);
- const vec3f normal3 = make_vec3f(position.x - p3.x, position.y - p3.y, position.z - p3.z);
+ const vec3f normal0 =
+ make_vec3f(position.x - p0.x, position.y - p0.y,
+ position.z - p0.z);
+ const vec3f normal1 =
+ make_vec3f(position.x - p1.x, position.y - p1.y,
+ position.z - p1.z);
+ const vec3f normal2 =
+ make_vec3f(position.x - p2.x, position.y - p2.y,
+ position.z - p2.z);
+ const vec3f normal3 =
+ make_vec3f(position.x - p3.x, position.y - p3.y,
+ position.z - p3.z);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptTriangle);
- m_gpuKernel->setPrimitive(m_nbPrimitives, position.x + p0.x * size.x, position.y + p0.y * size.y,
- position.z + p0.z * size.z, position.x + p1.x * size.x,
- position.y + p1.y * size.y, position.z + p1.z * size.z,
- position.x + p2.x * size.x, position.y + p2.y * size.y,
- position.z + p2.z * size.z, 0.f, 0.f, 0.f, m);
- m_gpuKernel->setPrimitiveNormals(m_nbPrimitives, normal0, normal1, normal2);
+ m_gpuKernel->setPrimitive(
+ m_nbPrimitives, position.x + p0.x * size.x,
+ position.y + p0.y * size.y, position.z + p0.z * size.z,
+ position.x + p1.x * size.x, position.y + p1.y * size.y,
+ position.z + p1.z * size.z, position.x + p2.x * size.x,
+ position.y + p2.y * size.y, position.z + p2.z * size.z, 0.f,
+ 0.f, 0.f, m);
+ m_gpuKernel->setPrimitiveNormals(m_nbPrimitives, normal0, normal1,
+ normal2);
{
const vec2f tc0 = make_vec2f(1.f, 1.f);
const vec2f tc1 = make_vec2f(0.f, 1.f);
const vec2f tc2 = make_vec2f(0.f, 0.f);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, tc0, tc1, tc2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, tc0,
+ tc1, tc2);
}
m_nbPrimitives = m_gpuKernel->addPrimitive(ptTriangle);
- m_gpuKernel->setPrimitive(m_nbPrimitives, position.x + p2.x * size.x, position.y + p2.y * size.y,
- position.z + p2.z * size.z, position.x + p3.x * size.x,
- position.y + p3.y * size.y, position.z + p3.z * size.z,
- position.x + p0.x * size.x, position.y + p0.y * size.y,
- position.z + p0.z * size.z, 0.f, 0.f, 0.f, m);
- m_gpuKernel->setPrimitiveNormals(m_nbPrimitives, normal2, normal3, normal0);
+ m_gpuKernel->setPrimitive(
+ m_nbPrimitives, position.x + p2.x * size.x,
+ position.y + p2.y * size.y, position.z + p2.z * size.z,
+ position.x + p3.x * size.x, position.y + p3.y * size.y,
+ position.z + p3.z * size.z, position.x + p0.x * size.x,
+ position.y + p0.y * size.y, position.z + p0.z * size.z, 0.f,
+ 0.f, 0.f, m);
+ m_gpuKernel->setPrimitiveNormals(m_nbPrimitives, normal2, normal3,
+ normal0);
{
const vec2f tc0 = make_vec2f(0.f, 0.f);
const vec2f tc1 = make_vec2f(1.f, 0.f);
const vec2f tc2 = make_vec2f(1.f, 1.f);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, tc0, tc1, tc2);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, tc0,
+ tc1, tc2);
}
++i;
}
@@ -120,8 +131,10 @@ void GalleryScene::doInitialize()
for (int i(0); i < 40; ++i)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % 10000 - 5000.f, rand() % 10000 - 5000.f,
- rand() % 10000 - 5000.f, 200.f + rand() % 200, 0.f, 0.f, 41 + rand() % 2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % 10000 - 5000.f,
+ rand() % 10000 - 5000.f,
+ rand() % 10000 - 5000.f, 200.f + rand() % 200,
+ 0.f, 0.f, 41 + rand() % 2);
}
}
@@ -136,6 +149,7 @@ void GalleryScene::doAddLights()
{
// Lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 5000.f, 0.f, 0, 0, 0, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 5000.f, 0.f, 0, 0, 0,
+ DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
diff --git a/apps/scenes/experiments/GalleryScene.h b/apps/scenes/experiments/GalleryScene.h
index 48d0f33..3077109 100644
--- a/apps/scenes/experiments/GalleryScene.h
+++ b/apps/scenes/experiments/GalleryScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/experiments/GraphScene.cpp b/apps/scenes/experiments/GraphScene.cpp
index 4a66d31..1f24272 100644
--- a/apps/scenes/experiments/GraphScene.cpp
+++ b/apps/scenes/experiments/GraphScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "GraphScene.h"
@@ -30,8 +27,6 @@
#endif
#include
-using namespace solr;
-
GraphScene::GraphScene(const std::string& name)
: Scene(name)
{
@@ -55,14 +50,16 @@ void GraphScene::buildGraph(const bool update)
for (int i = 0; i < m_nbGraphElements; ++i)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -1000.f, -4000.f, 0.f, -1000.f, 1000.f, 0.f, 20.f, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -1000.f, -4000.f, 0.f,
+ -1000.f, 1000.f, 0.f, 20.f, 0.f, 0.f,
material);
if (i == 0)
m_startGraph = m_nbPrimitives;
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -1000.f, 1000.f, 0.f, 20.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -1000.f, 1000.f, 0.f,
+ 20.f, 0.f, 0.f, material);
++material;
}
@@ -72,50 +69,73 @@ void GraphScene::buildGraph(const bool update)
material = m_graphMaterial;
for (int i(0); i < m_nbGraphElements; ++i)
{
- m_graphValues[i] = (cos(m_gpuKernel->getSceneInfo().timestamp * 0.00402f + i * 0.2f) *
- sin(m_gpuKernel->getSceneInfo().timestamp * 0.00208f + i * 0.5f)) *
- 2000.f;
+ m_graphValues[i] =
+ (cos(m_gpuKernel->getSceneInfo().timestamp * 0.00402f + i * 0.2f) *
+ sin(m_gpuKernel->getSceneInfo().timestamp * 0.00208f + i * 0.5f)) *
+ 2000.f;
maxY = (m_graphValues[i] > maxY ? m_graphValues[i] : maxY);
switch (m_currentModel % 3)
{
case 0:
{
- float z = 4.f * m_graphSize.x * (i / (m_nbGraphElements / 2)) - 2.f * m_graphSize.x;
+ float z = 4.f * m_graphSize.x * (i / (m_nbGraphElements / 2)) -
+ 2.f * m_graphSize.x;
int j = (i * 2) % (m_nbGraphElements / 2);
- m_gpuKernel->setPrimitive(m_startGraph + (i * 2), m_graphSpace + j * 2.f * m_graphSpace - x / 2.f, y, z,
- m_graphSpace + j * 2.f * m_graphSpace - x / 2.f, m_graphValues[i], z,
- m_graphSize.x, 0.f, 0.f, material);
-
- m_gpuKernel->setPrimitive(m_startGraph + (i * 2) + 1, m_graphSpace + j * 2.f * m_graphSpace - x / 2.f,
- m_graphValues[i], z, m_graphSize.x, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(
+ m_startGraph + (i * 2),
+ m_graphSpace + j * 2.f * m_graphSpace - x / 2.f, y, z,
+ m_graphSpace + j * 2.f * m_graphSpace - x / 2.f,
+ m_graphValues[i], z, m_graphSize.x, 0.f, 0.f, material);
+
+ m_gpuKernel->setPrimitive(m_startGraph + (i * 2) + 1,
+ m_graphSpace + j * 2.f * m_graphSpace -
+ x / 2.f,
+ m_graphValues[i], z, m_graphSize.x, 0.f,
+ 0.f, material);
break;
}
case 1:
{
if (i > 0)
- m_gpuKernel->setPrimitive(m_startGraph + (i * 2), m_graphSpace / 2.f + (i - 1) * m_graphSpace - x / 2.f,
- m_graphValues[i - 1], 0.f, m_graphSpace / 2.f + i * m_graphSpace - x / 2.f,
- m_graphValues[i], 0.f, m_graphSize.x / 2.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(
+ m_startGraph + (i * 2),
+ m_graphSpace / 2.f + (i - 1) * m_graphSpace - x / 2.f,
+ m_graphValues[i - 1], 0.f,
+ m_graphSpace / 2.f + i * m_graphSpace - x / 2.f,
+ m_graphValues[i], 0.f, m_graphSize.x / 2.f, 0.f, 0.f,
+ material);
else
- m_gpuKernel->setPrimitive(m_startGraph + (i * 2), 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_startGraph + (i * 2), 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
material);
- m_gpuKernel->setPrimitive(m_startGraph + (i * 2) + 1, m_graphSpace / 2.f + i * m_graphSpace - x / 2.f,
- m_graphValues[i], 0.f, m_graphSize.x / 2.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_startGraph + (i * 2) + 1,
+ m_graphSpace / 2.f + i * m_graphSpace -
+ x / 2.f,
+ m_graphValues[i], 0.f,
+ m_graphSize.x / 2.f, 0.f, 0.f, material);
break;
}
case 2:
{
if (i > 0)
- m_gpuKernel->setPrimitive(m_startGraph + (i * 2), m_graphSpace / 2.f + (i - 1) * m_graphSpace - x / 2.f,
- m_graphValues[i - 1], 0.f, m_graphSpace / 2.f + i * m_graphSpace - x / 2.f,
- m_graphValues[i], 0.f, m_graphSize.x / 4.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(
+ m_startGraph + (i * 2),
+ m_graphSpace / 2.f + (i - 1) * m_graphSpace - x / 2.f,
+ m_graphValues[i - 1], 0.f,
+ m_graphSpace / 2.f + i * m_graphSpace - x / 2.f,
+ m_graphValues[i], 0.f, m_graphSize.x / 4.f, 0.f, 0.f,
+ material);
else
- m_gpuKernel->setPrimitive(m_startGraph + (i * 2), 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_startGraph + (i * 2), 0.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
material);
- m_gpuKernel->setPrimitive(m_startGraph + (i * 2) + 1, m_graphSpace / 2.f + i * m_graphSpace - x / 2.f,
- m_graphValues[i], 0.f, m_graphSize.x, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_startGraph + (i * 2) + 1,
+ m_graphSpace / 2.f + i * m_graphSpace -
+ x / 2.f,
+ m_graphValues[i], 0.f, m_graphSize.x, 0.f,
+ 0.f, material);
break;
}
}
@@ -190,18 +210,28 @@ void GraphScene::buildChart(const std::string& filename)
for (int z = 0; z < m_valueSize.x; ++z)
{
glBegin(GL_TRIANGLES);
- glTranslatef(-m_graphScale.x * m_graphCenter.x, m_graphScale.y * m_graphCenter.y,
+ glTranslatef(-m_graphScale.x * m_graphCenter.x,
+ m_graphScale.y * m_graphCenter.y,
-m_graphScale.z * m_graphCenter.z);
m_gpuKernel->setCurrentMaterial(RANDOM_MATERIALS_OFFSET + 4 + m);
for (int x = 0; x < m_valueSize.y; ++x)
{
- glVertex3f(m_graphScale.x * x, m_graphScale.y * m_values[x][z], -m_graphScale.z * z);
- glVertex3f(m_graphScale.x * (x + 1), m_graphScale.y * m_values[x + 1][z], -m_graphScale.z * z);
- glVertex3f(m_graphScale.x * (x + 1), m_graphScale.y * m_values[x + 1][z + 1], -m_graphScale.z * (z + 1));
-
- glVertex3f(m_graphScale.x * (x + 1), m_graphScale.y * m_values[x + 1][z + 1], -m_graphScale.z * (z + 1));
- glVertex3f(m_graphScale.x * x, m_graphScale.y * m_values[x][z + 1], -m_graphScale.z * (z + 1));
- glVertex3f(m_graphScale.x * x, m_graphScale.y * m_values[x][z], -m_graphScale.z * z);
+ glVertex3f(m_graphScale.x * x, m_graphScale.y * m_values[x][z],
+ -m_graphScale.z * z);
+ glVertex3f(m_graphScale.x * (x + 1),
+ m_graphScale.y * m_values[x + 1][z],
+ -m_graphScale.z * z);
+ glVertex3f(m_graphScale.x * (x + 1),
+ m_graphScale.y * m_values[x + 1][z + 1],
+ -m_graphScale.z * (z + 1));
+
+ glVertex3f(m_graphScale.x * (x + 1),
+ m_graphScale.y * m_values[x + 1][z + 1],
+ -m_graphScale.z * (z + 1));
+ glVertex3f(m_graphScale.x * x, m_graphScale.y * m_values[x][z + 1],
+ -m_graphScale.z * (z + 1));
+ glVertex3f(m_graphScale.x * x, m_graphScale.y * m_values[x][z],
+ -m_graphScale.z * z);
}
glEnd();
++m;
@@ -210,10 +240,12 @@ void GraphScene::buildChart(const std::string& filename)
for (int x = 0; x < m_valueSize.y; ++x)
{
int p = m_gpuKernel->addPrimitive(ptXYPlane);
- m_gpuKernel->setPrimitive(p, -m_graphScale.x * m_graphCenter.x + m_graphScale.x * x,
- 500.f + m_graphScale.y * m_graphCenter.y + m_graphScale.y * m_values[x][z],
- m_graphScale.z * m_graphCenter.z - m_graphScale.z * z, 200.f, 100.f, 0.f,
- RANDOM_MATERIALS_OFFSET + 3);
+ m_gpuKernel->setPrimitive(
+ p, -m_graphScale.x * m_graphCenter.x + m_graphScale.x * x,
+ 500.f + m_graphScale.y * m_graphCenter.y +
+ m_graphScale.y * m_values[x][z],
+ m_graphScale.z * m_graphCenter.z - m_graphScale.z * z, 200.f,
+ 100.f, 0.f, RANDOM_MATERIALS_OFFSET + 3);
}
}
@@ -327,13 +359,12 @@ void GraphScene::doInitialize()
buildGraph(false);
}
-void GraphScene::doAnimate()
-{
-}
+void GraphScene::doAnimate() {}
void GraphScene::doAddLights()
{
// Lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 5000.f, 0.f, 50.f, 0, 0, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 5000.f, 0.f, 50.f, 0, 0,
+ DEFAULT_LIGHT_MATERIAL);
}
diff --git a/apps/scenes/experiments/GraphScene.h b/apps/scenes/experiments/GraphScene.h
index 2659546..4aab8c9 100644
--- a/apps/scenes/experiments/GraphScene.h
+++ b/apps/scenes/experiments/GraphScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/experiments/PerpetualMotionScene.cpp b/apps/scenes/experiments/PerpetualMotionScene.cpp
index e368018..c38b63b 100644
--- a/apps/scenes/experiments/PerpetualMotionScene.cpp
+++ b/apps/scenes/experiments/PerpetualMotionScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "PerpetualMotionScene.h"
@@ -31,9 +28,7 @@ PerpetualMotionScene::PerpetualMotionScene(const std::string& name)
{
}
-PerpetualMotionScene::~PerpetualMotionScene(void)
-{
-}
+PerpetualMotionScene::~PerpetualMotionScene(void) {}
void PerpetualMotionScene::doInitialize()
{
@@ -47,56 +42,71 @@ void PerpetualMotionScene::doInitialize()
// Portique
float radius = 200.f;
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -4000, m_groundHeight, -4000, -2500, 4000, 0, radius, 0.f, 0.f,
- material1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -4000, m_groundHeight, -4000,
+ -2500, 4000, 0, radius, 0.f, 0.f, material1);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -4000, m_groundHeight, 4000, -2500, 4000, 0, radius, 0.f, 0.f, material1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -4000, m_groundHeight, 4000,
+ -2500, 4000, 0, radius, 0.f, 0.f, material1);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -2500, 4000, 0, radius, 0, 0, material1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -2500, 4000, 0, radius, 0, 0,
+ material1);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -2500, 4000, 0, 2500, 4000, 0, radius, 0.f, 0.f, material1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -2500, 4000, 0, 2500, 4000, 0,
+ radius, 0.f, 0.f, material1);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 4000, m_groundHeight, -4000, 2500, 4000, 0, radius, 0.f, 0.f, material1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 4000, m_groundHeight, -4000, 2500,
+ 4000, 0, radius, 0.f, 0.f, material1);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 4000, m_groundHeight, 4000, 2500, 4000, 0, radius, 0.f, 0.f, material1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 4000, m_groundHeight, 4000, 2500,
+ 4000, 0, radius, 0.f, 0.f, material1);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 2500, 4000, 0, radius, 0, 0, material1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 2500, 4000, 0, radius, 0, 0,
+ material1);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -2500, 4000, 0, radius, 0, 0, material1);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -2500, 4000, 0, radius, 0, 0,
+ material1);
// Balls
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -2000, -1000.f, 0, -2000, 4000, -200, 10, 0.f, 0.f, material2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -2000, -1000.f, 0, -2000, 4000,
+ -200, 10, 0.f, 0.f, material2);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -2000, -1000.f, 0, -2000, 4000, 200, 10, 0.f, 0.f, material2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -2000, -1000.f, 0, -2000, 4000,
+ 200, 10, 0.f, 0.f, material2);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -2000, -1000.f, 0, 1000, 0, 0, material5);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -2000, -1000.f, 0, 1000, 0, 0,
+ material5);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0, -1000.f, 0, 0, 4000, -200, 10, 0.f, 0.f, material2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0, -1000.f, 0, 0, 4000, -200, 10,
+ 0.f, 0.f, material2);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0, -1000.f, 0, 0, 4000, 200, 10, 0.f, 0.f, material2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0, -1000.f, 0, 0, 4000, 200, 10,
+ 0.f, 0.f, material2);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0, -1000.f, 0, 1000, 0, 0, material3);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0, -1000.f, 0, 1000, 0, 0,
+ material3);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 2000, -1000.f, 0, 2000, 4000, -200, 10, 0.f, 0.f, material2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 2000, -1000.f, 0, 2000, 4000,
+ -200, 10, 0.f, 0.f, material2);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 2000, -1000.f, 0, 2000, 4000, 200, 10, 0.f, 0.f, material2);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 2000, -1000.f, 0, 2000, 4000, 200,
+ 10, 0.f, 0.f, material2);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere, true);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 2000, -1000.f, 0, 1000, 0, 0, material4);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 2000, -1000.f, 0, 1000, 0, 0,
+ material4);
m_gpuKernel->getSceneInfo().nbRayIterations = 20;
}
-void PerpetualMotionScene::doAnimate()
-{
-}
+void PerpetualMotionScene::doAnimate() {}
void PerpetualMotionScene::doAddLights()
{
// lights
float size = 1000.f;
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, 5000.f, -5000.f, size, 0.f, size * 4.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, 5000.f, -5000.f, size,
+ 0.f, size * 4.f, DEFAULT_LIGHT_MATERIAL);
}
diff --git a/apps/scenes/experiments/PerpetualMotionScene.h b/apps/scenes/experiments/PerpetualMotionScene.h
index b2ad914..2b4e49e 100644
--- a/apps/scenes/experiments/PerpetualMotionScene.h
+++ b/apps/scenes/experiments/PerpetualMotionScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/experiments/TransparentScene.cpp b/apps/scenes/experiments/TransparentScene.cpp
index bef937a..2b29914 100644
--- a/apps/scenes/experiments/TransparentScene.cpp
+++ b/apps/scenes/experiments/TransparentScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "TransparentScene.h"
@@ -31,18 +28,19 @@ TransparentScene::TransparentScene(const std::string& name)
{
}
-TransparentScene::~TransparentScene(void)
-{
-}
+TransparentScene::~TransparentScene(void) {}
void TransparentScene::doInitialize()
{
// Caustic material
int caustic = 0;
- m_gpuKernel->setMaterial(caustic, 1.f, 1.f, 0.f, 0.f, 0.f, 1.33f, false, false, 0, 0.8f,
- m_gpuKernel->getSceneInfo().viewDistance, TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
- TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE, 0.f, 100.f, 0.f, 0.f, 10.f,
- 10000.f, false);
+ m_gpuKernel->setMaterial(caustic, 1.f, 1.f, 0.f, 0.f, 0.f, 1.33f, false,
+ false, 0, 0.8f,
+ m_gpuKernel->getSceneInfo().viewDistance,
+ TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
+ TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
+ TEXTURE_NONE, 0.f, 100.f, 0.f, 0.f, 10.f, 10000.f,
+ false);
vec3f center;
center.x = 3000.f;
@@ -80,7 +78,8 @@ void TransparentScene::doAddLights()
if (m_gpuKernel->getNbActiveLamps() == 0)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 8000.f, 8000.f, -8000.f, 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 8000.f, 8000.f, -8000.f,
+ 500.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
}
diff --git a/apps/scenes/experiments/TransparentScene.h b/apps/scenes/experiments/TransparentScene.h
index ba512a9..3703d91 100644
--- a/apps/scenes/experiments/TransparentScene.h
+++ b/apps/scenes/experiments/TransparentScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/experiments/XmasScene.cpp b/apps/scenes/experiments/XmasScene.cpp
index eeadc55..7011f98 100644
--- a/apps/scenes/experiments/XmasScene.cpp
+++ b/apps/scenes/experiments/XmasScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
- *
- * This file is part of Sol-R
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * 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 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "XmasScene.h"
@@ -32,9 +29,7 @@ XmasScene::XmasScene(const std::string& name)
{
}
-XmasScene::~XmasScene(void)
-{
-}
+XmasScene::~XmasScene(void) {}
/*
________________________________________________________________________________
@@ -42,7 +37,8 @@ ________________________________________________________________________________
Create tree
________________________________________________________________________________
*/
-void XmasScene::createTree(int iteration, int boxId, int maxIterations, vec3f center, int material, float interval,
+void XmasScene::createTree(int iteration, int boxId, int maxIterations,
+ vec3f center, int material, float interval,
float radius)
{
if (iteration > 0)
@@ -56,37 +52,46 @@ void XmasScene::createTree(int iteration, int boxId, int maxIterations, vec3f ce
int box = (iteration < maxIterations) ? boxId : i;
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, a.x, a.y, a.z, b.x, b.y, b.z, radius / 2.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, a.x, a.y, a.z, b.x, b.y,
+ b.z, radius / 2.f, 0.f, 0.f, material);
- const vec4f angles = make_vec4f(((i == 0) ? 0.5f : 2.f) * (rand() % 100 / 100.f - 0.5f),
+ const vec4f angles = make_vec4f(
+ ((i == 0) ? 0.5f : 2.f) * (rand() % 100 / 100.f - 0.5f),
((i == 0) ? 0.5f : 2.f) * (rand() % 100 / 100.f - 0.5f),
((i == 0) ? 0.5f : 2.f) * (rand() % 100 / 100.f - 0.5f));
- const vec3f cosAngles = make_vec3f(cosf(angles.x), cosf(angles.y), cosf(angles.z));
- const vec3f sinAngles = make_vec3f(sinf(angles.x), sinf(angles.y), sinf(angles.z));
- solr::CPUPrimitive* p = m_gpuKernel->getPrimitive(m_nbPrimitives);
+ const vec3f cosAngles =
+ make_vec3f(cosf(angles.x), cosf(angles.y), cosf(angles.z));
+ const vec3f sinAngles =
+ make_vec3f(sinf(angles.x), sinf(angles.y), sinf(angles.z));
+ CPUPrimitive* p = m_gpuKernel->getPrimitive(m_nbPrimitives);
m_gpuKernel->rotatePrimitive(*p, a, cosAngles, sinAngles);
b.y += interval;
m_gpuKernel->getPrimitiveOtherCenter(m_nbPrimitives, b);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, b.x, b.y, b.z, radius / 2.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, b.x, b.y, b.z,
+ radius / 2.f, 0.f, 0.f, material);
if (iteration == 1 && rand() % 3 == 0)
{
// Boule de noel
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, a.x, a.y, a.z, a.x, a.y - 300.f, a.z, 5, 0.f, 0.f, 1016);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, a.x, a.y, a.z, a.x,
+ a.y - 300.f, a.z, 5, 0.f, 0.f, 1016);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, a.x, a.y - 400.f, a.z, 200, 0.f, 0.f, 1010 + rand() % 6);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, a.x, a.y - 400.f, a.z,
+ 200, 0.f, 0.f, 1010 + rand() % 6);
}
if (iteration == 1 && rand() % 3 == 0)
{
// Leaves
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, b.x, b.y, b.z, 50.f + rand() % 500, 0.f, 0.f, 1002);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, b.x, b.y, b.z,
+ 50.f + rand() % 500, 0.f, 0.f, 1002);
}
- createTree(iteration - 1, box, maxIterations, b, material, interval * (0.8f + rand() % iteration / 10.f),
+ createTree(iteration - 1, box, maxIterations, b, material,
+ interval * (0.8f + rand() % iteration / 10.f),
radius * (0.4f + rand() % iteration / 10.f));
}
}
@@ -95,45 +100,54 @@ void XmasScene::createTree(int iteration, int boxId, int maxIterations, vec3f ce
void XmasScene::doInitialize()
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptYZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -4200.f, 0.f, 0.f, 0.f, 2000.f, 200.f, 1000);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -4200.f, 0.f, 0.f, 0.f, 2000.f,
+ 200.f, 1000);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXYPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -4100.f, 0.f, 200.f, 100.f, 2000.f, 0.f, 1000);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -4100.f, 0.f, 200.f, 100.f,
+ 2000.f, 0.f, 1000);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXYPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -4100.f, 0.f, -200.f, 100.f, 2000.f, 0.f, 1000);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -4100.f, 0.f, -200.f, 100.f,
+ 2000.f, 0.f, 1000);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -4100.f, 2000.f, 0.f, 100.f, 0.f, 200.f, 1000);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -4100.f, 2000.f, 0.f, 100.f, 0.f,
+ 200.f, 1000);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptYZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 4200.f, 0.f, 0.f, 0.f, 2000.f, 200.f, 1000);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 4200.f, 0.f, 0.f, 0.f, 2000.f,
+ 200.f, 1000);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXYPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 4100.f, 0.f, 200.f, 100.f, 2000.f, 0.f, 1000);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 4100.f, 0.f, 200.f, 100.f, 2000.f,
+ 0.f, 1000);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXYPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 4100.f, 0.f, -200.f, 100.f, 2000.f, 0.f, 1000);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 4100.f, 0.f, -200.f, 100.f,
+ 2000.f, 0.f, 1000);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 4100.f, 2000.f, 0.f, 100.f, 0.f, 200.f, 1000);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 4100.f, 2000.f, 0.f, 100.f, 0.f,
+ 200.f, 1000);
int material = 1001;
// Tree
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, m_groundHeight, 0.f, 0.f, -1000.f, 0.f, 250.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, m_groundHeight, 0.f, 0.f,
+ -1000.f, 0.f, 250.f, 0.f, 0.f, material);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, -1000.f, 0.f, 250.f, 0.f, 0.f, material);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, -1000.f, 0.f, 250.f, 0.f,
+ 0.f, material);
int nbIterations = 2 + rand() % 3;
vec3f center = make_vec3f(0.f, -1000.f, 0.f);
createTree(nbIterations, 10, nbIterations, center, material,
1000.f, //+rand()%800,
200.f //+rand()%300
- );
+ );
}
-void XmasScene::doAnimate()
-{
-}
+void XmasScene::doAnimate() {}
void XmasScene::doAddLights()
{
// lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -4000.f, 0.f, 0.f, 0.f, 2000.f, 200.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -4000.f, 0.f, 0.f, 0.f, 2000.f,
+ 200.f, DEFAULT_LIGHT_MATERIAL);
}
diff --git a/apps/scenes/experiments/XmasScene.h b/apps/scenes/experiments/XmasScene.h
index 0b7e054..09ee7e0 100644
--- a/apps/scenes/experiments/XmasScene.h
+++ b/apps/scenes/experiments/XmasScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
@@ -34,6 +31,6 @@ class XmasScene : public Scene
virtual void doAddLights();
private:
- void createTree(int iteration, int boxId, int maxIterations, vec3f center, int material, float interval,
- float radius);
+ void createTree(int iteration, int boxId, int maxIterations, vec3f center,
+ int material, float interval, float radius);
};
diff --git a/apps/scenes/experiments/Year2013.cpp b/apps/scenes/experiments/Year2013.cpp
index 6b29c97..7e980df 100644
--- a/apps/scenes/experiments/Year2013.cpp
+++ b/apps/scenes/experiments/Year2013.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "Year2013.h"
@@ -31,9 +28,7 @@ Year2013::Year2013(const std::string& name)
{
}
-Year2013::~Year2013(void)
-{
-}
+Year2013::~Year2013(void) {}
void Year2013::doInitialize()
{
@@ -70,16 +65,17 @@ void Year2013::doInitialize()
*/
// CERN
- int g2013[10][23] = {{0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1},
- {1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1},
- {1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1},
- {1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1},
- {1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1},
- {1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1},
- {0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1},
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0},
- {0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0}};
+ int g2013[10][23] = {
+ {0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1},
+ {1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1},
+ {1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1},
+ {1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1},
+ {1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1},
+ {1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1},
+ {0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0},
+ {0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0}};
float size = 250.f;
float X = -(15.f * size);
@@ -95,22 +91,26 @@ void Year2013::doInitialize()
case 1:
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, X + x * S, Y - y * S, 0.f, size * 1.2f, 0.f, 0.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, X + x * S, Y - y * S,
+ 0.f, size * 1.2f, 0.f, 0.f,
1030 + (x / 6) * 5);
break;
}
case 2:
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptEllipsoid);
- m_gpuKernel->setPrimitive(m_nbPrimitives, X + x * S, Y - y * S, 0.f, size * 4.f, size, size * 4.f,
+ m_gpuKernel->setPrimitive(m_nbPrimitives, X + x * S, Y - y * S,
+ 0.f, size * 4.f, size, size * 4.f,
1040);
break;
}
case 3:
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, X + x * S, Y - (y + 3) * S, 0.f, X + x * S, Y - (y - 1) * S,
- 0.f, size * 4.f, 0.f, 0.f, 1040);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, X + x * S,
+ Y - (y + 3) * S, 0.f, X + x * S,
+ Y - (y - 1) * S, 0.f, size * 4.f, 0.f,
+ 0.f, 1040);
break;
}
}
@@ -134,14 +134,13 @@ void Year2013::doInitialize()
m_gpuKernel->getSceneInfo().nbRayIterations = 20;
}
-void Year2013::doAnimate()
-{
-}
+void Year2013::doAnimate() {}
void Year2013::doAddLights()
{
// lights
float size = 50.f;
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, 5000.f, -5000.f, size, size * 2.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, 5000.f, -5000.f, size,
+ size * 2.f, 0.f, DEFAULT_LIGHT_MATERIAL);
}
diff --git a/apps/scenes/experiments/Year2013.h b/apps/scenes/experiments/Year2013.h
index 42d4b64..86dda3f 100644
--- a/apps/scenes/experiments/Year2013.h
+++ b/apps/scenes/experiments/Year2013.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/games/SpindizzyScene.cpp b/apps/scenes/games/SpindizzyScene.cpp
index 2990d38..0e20bc0 100644
--- a/apps/scenes/games/SpindizzyScene.cpp
+++ b/apps/scenes/games/SpindizzyScene.cpp
@@ -1,37 +1,30 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "SpindizzyScene.h"
#include
-using namespace solr;
-
SpindizzyScene::SpindizzyScene(const std::string& name)
: Scene(name)
{
}
-SpindizzyScene::~SpindizzyScene(void)
-{
-}
+SpindizzyScene::~SpindizzyScene(void) {}
void SpindizzyScene::doInitialize()
{
@@ -107,11 +100,14 @@ void SpindizzyScene::doAnimate()
void SpindizzyScene::doAddLights()
{
// lights
- m_gpuKernel->setMaterial(129, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, false, false, 0, 0.f,
- m_gpuKernel->getSceneInfo().viewDistance, TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
- TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE, 1.f, 100.f, 0.f, 1.0f, 50.f,
+ m_gpuKernel->setMaterial(129, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, false, false, 0,
+ 0.f, m_gpuKernel->getSceneInfo().viewDistance,
+ TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
+ TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
+ TEXTURE_NONE, 1.f, 100.f, 0.f, 1.0f, 50.f,
m_gpuKernel->getSceneInfo().viewDistance, false);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -10000.f, 10000.f - m_groundHeight, -10000.f, 500.f, 0.f, 500.f * 4.f,
- DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -10000.f,
+ 10000.f - m_groundHeight, -10000.f, 500.f, 0.f,
+ 500.f * 4.f, DEFAULT_LIGHT_MATERIAL);
}
diff --git a/apps/scenes/games/SpindizzyScene.h b/apps/scenes/games/SpindizzyScene.h
index 36aa555..c5ff946 100644
--- a/apps/scenes/games/SpindizzyScene.h
+++ b/apps/scenes/games/SpindizzyScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/maths/FractalScene.cpp b/apps/scenes/maths/FractalScene.cpp
index c731218..376f6bd 100644
--- a/apps/scenes/maths/FractalScene.cpp
+++ b/apps/scenes/maths/FractalScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
- *
- * This file is part of Sol-R
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * 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 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "FractalScene.h"
@@ -34,9 +31,7 @@ FractalScene::FractalScene(const std::string& name)
{
}
-FractalScene::~FractalScene(void)
-{
-}
+FractalScene::~FractalScene(void) {}
/*
________________________________________________________________________________
@@ -44,59 +39,40 @@ ________________________________________________________________________________
Create simple fractal scene
________________________________________________________________________________
*/
-void FractalScene::createFractals(int iteration, int modelId, int mode, int maxIterations, vec4f center, int material,
+void FractalScene::createFractals(int iteration, int modelId, int mode,
+ int maxIterations, vec4f center, int material,
float interval, float radius)
{
- vec4f positions[NB_MODELS][NB_ELEMENTS] =
- {
- {make_vec4f(-1.f, -1.f, -1.f, 0.f),
- make_vec4f(1.f, -1.f, -1.f, 0.f),
- make_vec4f(0.f, -1.f, 1.f, 0.f),
- make_vec4f(0.f, 1.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, -1.f, 0.f),
- make_vec4f(0.f, -1.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f)},
- {make_vec4f(-1.f, -1.f, 1.f, 0.f),
- make_vec4f(1.f, -1.f, 1.f, 0.f),
- make_vec4f(-1.f, 1.f, 1.f, 0.f),
- make_vec4f(1.f, 1.f, 1.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f)},
+ vec4f positions[NB_MODELS][NB_ELEMENTS] = {
+ {make_vec4f(-1.f, -1.f, -1.f, 0.f), make_vec4f(1.f, -1.f, -1.f, 0.f),
+ make_vec4f(0.f, -1.f, 1.f, 0.f), make_vec4f(0.f, 1.f, 0.f, 0.f),
+ make_vec4f(0.f, 0.f, -1.f, 0.f), make_vec4f(0.f, -1.f, 0.f, 0.f),
+ make_vec4f(0.f, 0.f, 0.f, 0.f), make_vec4f(0.f, 0.f, 0.f, 0.f)},
+ {make_vec4f(-1.f, -1.f, 1.f, 0.f), make_vec4f(1.f, -1.f, 1.f, 0.f),
+ make_vec4f(-1.f, 1.f, 1.f, 0.f), make_vec4f(1.f, 1.f, 1.f, 0.f),
+ make_vec4f(0.f, 0.f, 0.f, 0.f), make_vec4f(0.f, 0.f, 0.f, 0.f),
+ make_vec4f(0.f, 0.f, 0.f, 0.f), make_vec4f(0.f, 0.f, 0.f, 0.f)},
{// Cube
- make_vec4f(-1.f, -1.f, -1.f, 0.f),
- make_vec4f(1.f, -1.f, -1.f, 0.f),
- make_vec4f(-1.f, 1.f, -1.f, 0.f),
- make_vec4f(1.f, 1.f, -1.f, 0.f),
- make_vec4f(-1.f, -1.f, 1.f, 0.f),
- make_vec4f(1.f, -1.f, 1.f, 0.f),
- make_vec4f(-1.f, 1.f, 1.f, 0.f),
- make_vec4f(1.f, 1.f, 1.f, 0.f)},
- {make_vec4f(1.f, 0.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 1.f, 0.f),
- make_vec4f(0.f, 2.f, 0.f, 0.f),
- make_vec4f(-1.f, 0.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, -1.f, 0.f),
- make_vec4f(0.f, -1.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f)},
- {make_vec4f(1.f, 1.f, 0.f, 0.f),
- make_vec4f(-1.f, 1.f, 0.f, 0.f),
- make_vec4f(1.f, -1.f, 0.f, 0.f),
- make_vec4f(-1.f, -1.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, -1.f, 0.f),
- make_vec4f(0.f, 0.f, 1.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f),
- make_vec4f(0.f, 0.f, 0.f, 0.f)}
- };
+ make_vec4f(-1.f, -1.f, -1.f, 0.f), make_vec4f(1.f, -1.f, -1.f, 0.f),
+ make_vec4f(-1.f, 1.f, -1.f, 0.f), make_vec4f(1.f, 1.f, -1.f, 0.f),
+ make_vec4f(-1.f, -1.f, 1.f, 0.f), make_vec4f(1.f, -1.f, 1.f, 0.f),
+ make_vec4f(-1.f, 1.f, 1.f, 0.f), make_vec4f(1.f, 1.f, 1.f, 0.f)},
+ {make_vec4f(1.f, 0.f, 0.f, 0.f), make_vec4f(0.f, 0.f, 1.f, 0.f),
+ make_vec4f(0.f, 2.f, 0.f, 0.f), make_vec4f(-1.f, 0.f, 0.f, 0.f),
+ make_vec4f(0.f, 0.f, -1.f, 0.f), make_vec4f(0.f, -1.f, 0.f, 0.f),
+ make_vec4f(0.f, 0.f, 0.f, 0.f), make_vec4f(0.f, 0.f, 0.f, 0.f)},
+ {make_vec4f(1.f, 1.f, 0.f, 0.f), make_vec4f(-1.f, 1.f, 0.f, 0.f),
+ make_vec4f(1.f, -1.f, 0.f, 0.f), make_vec4f(-1.f, -1.f, 0.f, 0.f),
+ make_vec4f(0.f, 0.f, -1.f, 0.f), make_vec4f(0.f, 0.f, 1.f, 0.f),
+ make_vec4f(0.f, 0.f, 0.f, 0.f), make_vec4f(0.f, 0.f, 0.f, 0.f)}};
if (iteration > 0)
{
for (int i(0); i < NB_ELEMENTS; i++)
{
- if (positions[modelId][i].x != 0.f || positions[modelId][i].y != 0.f || positions[modelId][i].z != 0.f)
+ if (positions[modelId][i].x != 0.f ||
+ positions[modelId][i].y != 0.f ||
+ positions[modelId][i].z != 0.f)
{
vec4f c = make_vec4f(0.f, 0.f, 0.f, 0.f);
c.x = center.x + positions[modelId][i].x * center.w * interval;
@@ -113,17 +89,22 @@ void FractalScene::createFractals(int iteration, int modelId, int mode, int maxI
case 0:
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, c.x, c.y, c.z, (iteration == 1) ? c.w / 2.f : c.w,
- (iteration == 2) ? c.w / 2.f : c.w, (iteration == 3) ? c.w / 2.f : c.w,
- 1000 + iteration);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, vt0, vt1, vt2);
- m_gpuKernel->setPrimitiveBellongsToModel(m_nbPrimitives, true);
+ m_gpuKernel->setPrimitive(
+ m_nbPrimitives, c.x, c.y, c.z,
+ (iteration == 1) ? c.w / 2.f : c.w,
+ (iteration == 2) ? c.w / 2.f : c.w,
+ (iteration == 3) ? c.w / 2.f : c.w, 1000 + iteration);
+ m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives,
+ vt0, vt1, vt2);
+ m_gpuKernel->setPrimitiveBellongsToModel(m_nbPrimitives,
+ true);
}
break;
case 1:
{
- m_gpuKernel->addCube(c.x, c.y, c.z, (iteration == 1) ? c.w / 2.f : c.w,
- 1000 + ((maxIterations - iteration) * 10 /*+i*/) % 50);
+ m_gpuKernel->addCube(
+ c.x, c.y, c.z, (iteration == 1) ? c.w / 2.f : c.w,
+ 1000 + ((maxIterations - iteration) * 10 /*+i*/) % 50);
}
break;
default:
@@ -131,23 +112,31 @@ void FractalScene::createFractals(int iteration, int modelId, int mode, int maxI
if (iteration % 2 == 1)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, c.x, c.y, c.z, (iteration == 1) ? c.w / 2.f : c.w,
- (iteration == 2) ? c.w / 2.f : c.w,
- (iteration == 3) ? c.w / 2.f : c.w,
- 1000 + ((maxIterations - iteration) * 10 /*+i*/) % 50);
- m_gpuKernel->setPrimitiveTextureCoordinates(m_nbPrimitives, vt0, vt1, vt2);
- m_gpuKernel->setPrimitiveBellongsToModel(m_nbPrimitives, true);
+ m_gpuKernel->setPrimitive(
+ m_nbPrimitives, c.x, c.y, c.z,
+ (iteration == 1) ? c.w / 2.f : c.w,
+ (iteration == 2) ? c.w / 2.f : c.w,
+ (iteration == 3) ? c.w / 2.f : c.w,
+ 1000 +
+ ((maxIterations - iteration) * 10 /*+i*/) % 50);
+ m_gpuKernel->setPrimitiveTextureCoordinates(
+ m_nbPrimitives, vt0, vt1, vt2);
+ m_gpuKernel->setPrimitiveBellongsToModel(m_nbPrimitives,
+ true);
}
else
{
- m_gpuKernel->addCube(c.x, c.y, c.z, (iteration == 1) ? c.w / 2.f : c.w,
- 1000 + ((maxIterations - iteration) * 10 /*+i*/) % 50);
+ m_gpuKernel->addCube(
+ c.x, c.y, c.z, (iteration == 1) ? c.w / 2.f : c.w,
+ 1000 +
+ ((maxIterations - iteration) * 10 /*+i*/) % 50);
}
}
break;
}
- createFractals(iteration - 1, modelId, mode, maxIterations, c, material, interval, radius);
+ createFractals(iteration - 1, modelId, mode, maxIterations, c,
+ material, interval, radius);
}
}
}
@@ -158,8 +147,9 @@ void FractalScene::doInitialize()
m_groundHeight = -5000.f;
int nbIterations = 2 + rand() % 3;
vec4f center = make_vec4f(0.f, 0.f, 0.f, 2000.f);
- createFractals(nbIterations, rand() % NB_MODELS, rand() % 1, nbIterations, center, 1000 + rand() % 30,
- 1.0f + rand() % 500 / 1000.f, 0.5f + rand() % 200 / 1000.f);
+ createFractals(nbIterations, rand() % NB_MODELS, rand() % 1, nbIterations,
+ center, 1000 + rand() % 30, 1.0f + rand() % 500 / 1000.f,
+ 0.5f + rand() % 200 / 1000.f);
}
void FractalScene::doAnimate()
@@ -176,10 +166,7 @@ void FractalScene::doAddLights()
{
// lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -15000.f, 15000.f, -15000.f, 10.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -15000.f, 15000.f, -15000.f, 10.f,
+ 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
- // m_nbPrimitives = m_gpuKernel->addPrimitive( ptSphere ); m_gpuKernel->setPrimitive( m_nbPrimitives, 15000.f,
- // 15000.f, 15000.f, 10.f, 0.f, 0.f, 121);
- // m_nbPrimitives = m_gpuKernel->addPrimitive( ptSphere ); m_gpuKernel->setPrimitive( m_nbPrimitives, 0.f, 15000.f,
- // -15000.f, 10.f, 0.f, 0.f, 122);
}
diff --git a/apps/scenes/maths/FractalScene.h b/apps/scenes/maths/FractalScene.h
index ef449bd..f0cc28d 100644
--- a/apps/scenes/maths/FractalScene.h
+++ b/apps/scenes/maths/FractalScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
@@ -34,6 +31,7 @@ class FractalScene : public Scene
virtual void doAddLights();
private:
- void createFractals(int iteration, int modelId, int mode, int maxIterations, vec4f center, int material,
- float interval, float radius);
+ void createFractals(int iteration, int modelId, int mode, int maxIterations,
+ vec4f center, int material, float interval,
+ float radius);
};
diff --git a/apps/scenes/maths/FractalsScene.cpp b/apps/scenes/maths/FractalsScene.cpp
index 11f4087..436c2bc 100644
--- a/apps/scenes/maths/FractalsScene.cpp
+++ b/apps/scenes/maths/FractalsScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
- *
- * This file is part of Sol-R
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * 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 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "FractalsScene.h"
@@ -33,9 +30,7 @@ FractalsScene::FractalsScene(const std::string& name)
{
}
-FractalsScene::~FractalsScene(void)
-{
-}
+FractalsScene::~FractalsScene(void) {}
/*
________________________________________________________________________________
@@ -43,7 +38,8 @@ ________________________________________________________________________________
Create simple fractal scene
________________________________________________________________________________
*/
-void FractalsScene::createFractals(float maxIterations, const vec4f& center, int material)
+void FractalsScene::createFractals(float maxIterations, const vec4f& center,
+ int material)
{
SceneInfo& sceneInfo = m_gpuKernel->getSceneInfo();
float W = (float)sceneInfo.size.x;
@@ -83,24 +79,29 @@ void FractalsScene::createFractals(float maxIterations, const vec4f& center, int
if (n > 5)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptTriangle);
- m_gpuKernel->setPrimitive(m_nbPrimitives, (x - 250.f) * center.w, (y - 250.f) * center.w, 0.f,
- (x + step - 250.f) * center.w, (y - 250.f) * center.w, 0.f,
- (x + step - 250.f) * center.w, (y + step - 250.f) * center.w, 0.f,
- 10.f * center.w, 0.f, 0.f, material + (n % 40));
+ m_gpuKernel->setPrimitive(
+ m_nbPrimitives, (x - 250.f) * center.w,
+ (y - 250.f) * center.w, 0.f, (x + step - 250.f) * center.w,
+ (y - 250.f) * center.w, 0.f, (x + step - 250.f) * center.w,
+ (y + step - 250.f) * center.w, 0.f, 10.f * center.w, 0.f,
+ 0.f, material + (n % 40));
m_gpuKernel->setPrimitiveBellongsToModel(m_nbPrimitives, true);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptTriangle);
- m_gpuKernel->setPrimitive(m_nbPrimitives, (x + step - 250.f) * center.w, (y + step - 250.f) * center.w,
- 0.f, (x - 250.f) * center.w, (y + step - 250.f) * center.w, 0.f,
- (x - 250.f) * center.w, (y - 250.f) * center.w, 0.f, 10.f * center.w, 0.f,
- 0.f, material + (n % 40));
+ m_gpuKernel->setPrimitive(
+ m_nbPrimitives, (x + step - 250.f) * center.w,
+ (y + step - 250.f) * center.w, 0.f, (x - 250.f) * center.w,
+ (y + step - 250.f) * center.w, 0.f, (x - 250.f) * center.w,
+ (y - 250.f) * center.w, 0.f, 10.f * center.w, 0.f, 0.f,
+ material + (n % 40));
m_gpuKernel->setPrimitiveBellongsToModel(m_nbPrimitives, true);
}
}
}
}
-vec4f FractalsScene::MandelBox(vec3f V, const vec3f& Scale, float R, float S, float C)
+vec4f FractalsScene::MandelBox(vec3f V, const vec3f& Scale, float R, float S,
+ float C)
{
V.x /= Scale.x;
V.y /= Scale.y;
@@ -154,7 +155,8 @@ vec4f FractalsScene::MandelBox(vec3f V, const vec3f& Scale, float R, float S, fl
{
int div = maxiter / 5;
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, V.x, V.y, V.z, Scale.x, Scale.y, Scale.z, 1000 + div);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, V.x, V.y, V.z, Scale.x,
+ Scale.y, Scale.z, 1000 + div);
m_gpuKernel->setPrimitiveBellongsToModel(m_nbPrimitives, true);
}
return color;
@@ -201,31 +203,40 @@ float FractalsScene::DE(vec3f pos, const int iterations, const vec2f params)
if (!add)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, pos.x, pos.y, pos.z, 0.01f * log(r) * r / dr, 0.f, 0.f, 40);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, pos.x, pos.y, pos.z,
+ 0.01f * log(r) * r / dr, 0.f, 0.f, 40);
m_gpuKernel->setPrimitiveBellongsToModel(m_nbPrimitives, true);
}
return 0.f;
}
/**
- * Decides if a point at a specific location is filled or not. This works by iteration first checking if
- * the pixel is unfilled in successively larger squares or cannot be in the center of any larger square.
- * @param x is the x coordinate of the point being checked with zero being the first pixel
- * @param y is the y coordinate of the point being checked with zero being the first pixel
+ * Decides if a point at a specific location is filled or not. This works by
+ * iteration first checking if the pixel is unfilled in successively larger
+ * squares or cannot be in the center of any larger square.
+ * @param x is the x coordinate of the point being checked with zero being the
+ * first pixel
+ * @param y is the y coordinate of the point being checked with zero being the
+ * first pixel
* @return 1 if it is to be filled or 0 if it is open
*/
bool FractalsScene::isSierpinskiCarpetPixelFilled(int i, vec3i v)
{
- while (v.x > 0 || v.y > 0 || v.z > 0) // when either of these reaches zero the pixel is determined to be on the edge
+ while (v.x > 0 || v.y > 0 ||
+ v.z > 0) // when either of these reaches zero the pixel is determined
+ // to be on the edge
{
if (v.x % i == 1 && v.y % i == 1 &&
- v.z % i == 1) // checks if the pixel is in the center for the current square level
+ v.z % i == 1) // checks if the pixel is in the center for the
+ // current square level
return false;
- v.x /= i; // x and y are decremented to check the next larger square level
+ v.x /=
+ i; // x and y are decremented to check the next larger square level
v.y /= i;
v.z /= i;
}
- return true; // if all possible square levels are checked and the pixel is not determined
+ return true; // if all possible square levels are checked and the pixel is
+ // not determined
// to be open it must be filled
}
@@ -244,8 +255,11 @@ void FractalsScene::doInitialize()
{
vec3i v = make_vec3i(x, y, z);
if (!isSierpinskiCarpetPixelFilled(nbIterations, v))
- m_nbPrimitives = m_gpuKernel->addCube((x - size / 2.f) * radius, (y - size / 2.f) * radius,
- (z - size / 2.f) * radius, step * radius, 39);
+ m_nbPrimitives =
+ m_gpuKernel->addCube((x - size / 2.f) * radius,
+ (y - size / 2.f) * radius,
+ (z - size / 2.f) * radius,
+ step * radius, 39);
}
}
@@ -260,5 +274,6 @@ void FractalsScene::doAddLights()
{
// lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptXZPlane);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 5000.f, 0.f, 500.f, 0.f, 500.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 5000.f, 0.f, 500.f, 0.f,
+ 500.f, DEFAULT_LIGHT_MATERIAL);
}
diff --git a/apps/scenes/maths/FractalsScene.h b/apps/scenes/maths/FractalsScene.h
index 74ce6f1..2ac47b1 100644
--- a/apps/scenes/maths/FractalsScene.h
+++ b/apps/scenes/maths/FractalsScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/maths/TrefoilKnotScene.cpp b/apps/scenes/maths/TrefoilKnotScene.cpp
index dbb8f53..eb3b5d8 100644
--- a/apps/scenes/maths/TrefoilKnotScene.cpp
+++ b/apps/scenes/maths/TrefoilKnotScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "TrefoilKnotScene.h"
@@ -33,9 +30,7 @@ TrefoilKnotScene::TrefoilKnotScene(const std::string& name)
{
}
-TrefoilKnotScene::~TrefoilKnotScene(void)
-{
-}
+TrefoilKnotScene::~TrefoilKnotScene(void) {}
void TrefoilKnotScene::trefoilKnot(float R, float t, vec4f& p)
{
@@ -68,7 +63,8 @@ void TrefoilKnotScene::spring(float R, float t, vec4f& p)
void TrefoilKnotScene::heart(float R, float u, float v, vec4f& p)
{
p.x = R * 4.f * pow(sin(u), 3.f);
- p.y = R * 0.25f * (13 * cos(u) - 5 * cos(2.f * u) - 2.f * cos(3.f * u) - cos(4.f * u));
+ p.y = R * 0.25f *
+ (13 * cos(u) - 5 * cos(2.f * u) - 2.f * cos(3.f * u) - cos(4.f * u));
p.z = 0.f;
}
@@ -79,7 +75,8 @@ void TrefoilKnotScene::thing(float R, float t, vec4f a, vec4f& p)
p.z = R * (-sin(a.z * t));
}
-void TrefoilKnotScene::moebius(float R, float u, float v, float s, float du, float dv, vec4f& p)
+void TrefoilKnotScene::moebius(float R, float u, float v, float s, float du,
+ float dv, vec4f& p)
{
p.x = 4.f * R * (cos(u) + v * cos(u / 2) * cos(u));
p.y = 4.f * R * (sin(u) + v * cos(u / 2) * sin(u));
@@ -96,7 +93,8 @@ void TrefoilKnotScene::doInitialize()
const float R = 500.f;
const float r = 50.f + rand() % 800;
const int geometry = rand() % 10;
- const vec4f a = make_vec4f(1.f + rand() % 4, 1.f + rand() % 4, 1.f + rand() % 4, 1.f + rand() % 4);
+ const vec4f a = make_vec4f(1.f + rand() % 4, 1.f + rand() % 4,
+ 1.f + rand() % 4, 1.f + rand() % 4);
const float s = 1.f;
vec4f U, V;
@@ -216,17 +214,21 @@ void TrefoilKnotScene::doInitialize()
break;
}
m_nbPrimitives = m_gpuKernel->addPrimitive(ptCylinder);
- m_gpuKernel->setPrimitive(m_nbPrimitives, p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, r, 0.f, 0.f, material + M);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, p0.x, p0.y, p0.z, p1.x,
+ p1.y, p1.z, r, 0.f, 0.f, material + M);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, p1.x, p1.y, p1.z, r, 0.f, 0.f, material + M);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, p1.x, p1.y, p1.z, r, 0.f,
+ 0.f, material + M);
++element;
}
}
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -4000.f, -1000.f, 1000.f, 1500.f, 0.f, 0.f, 114);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -4000.f, -1000.f, 1000.f, 1500.f,
+ 0.f, 0.f, 114);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 4000.f, -1000.f, 1000.f, 1500.f, 0.f, 0.f, 113);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 4000.f, -1000.f, 1000.f, 1500.f,
+ 0.f, 0.f, 113);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
m_gpuKernel->getSceneInfo().nbRayIterations = 20;
}
@@ -241,5 +243,6 @@ void TrefoilKnotScene::doAnimate()
void TrefoilKnotScene::doAddLights()
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 5000.f, 0.f, 50.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 5000.f, 0.f, 50.f, 0.f, 0.f,
+ DEFAULT_LIGHT_MATERIAL);
}
diff --git a/apps/scenes/maths/TrefoilKnotScene.h b/apps/scenes/maths/TrefoilKnotScene.h
index 4274758..cc70604 100644
--- a/apps/scenes/maths/TrefoilKnotScene.h
+++ b/apps/scenes/maths/TrefoilKnotScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
@@ -40,5 +37,6 @@ class TrefoilKnotScene : public Scene
void spring(float R, float t, vec4f& p);
void heart(float R, float u, float v, vec4f& p);
void thing(float R, float t, vec4f a, vec4f& p);
- void moebius(float R, float u, float v, float s, float du, float dv, vec4f& p);
+ void moebius(float R, float u, float v, float s, float du, float dv,
+ vec4f& p);
};
diff --git a/apps/scenes/meshes/ObjScene.cpp b/apps/scenes/meshes/ObjScene.cpp
index c7b936a..747a94c 100644
--- a/apps/scenes/meshes/ObjScene.cpp
+++ b/apps/scenes/meshes/ObjScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "ObjScene.h"
@@ -35,9 +32,7 @@ ObjScene::ObjScene(const std::string& name, const std::string& filename)
m_groundHeight = -2500.f;
}
-ObjScene::~ObjScene(void)
-{
-}
+ObjScene::~ObjScene(void) {}
void ObjScene::doInitialize()
{
@@ -49,7 +44,7 @@ void ObjScene::doInitialize()
// Scene Bounding Box
SceneInfo& sceneInfo = m_gpuKernel->getSceneInfo();
- solr::CPUBoundingBox AABB;
+ CPUBoundingBox AABB;
AABB.parameters[0].x = sceneInfo.viewDistance;
AABB.parameters[0].y = sceneInfo.viewDistance;
AABB.parameters[0].z = sceneInfo.viewDistance;
@@ -60,40 +55,44 @@ void ObjScene::doInitialize()
if (m_filename.length() != 0)
{
LOG_INFO(1, "Loading " << m_filename);
- solr::OBJReader objectReader;
- solr::CPUBoundingBox aabb;
- solr::CPUBoundingBox inAABB;
- memset(&inAABB, 0, sizeof(solr::CPUBoundingBox));
- vec4f size = objectReader.loadModelFromFile(m_filename, *m_gpuKernel, objectPosition, true, m_objectScale, true,
- RANDOM_MATERIALS_OFFSET, false, true, aabb, false, inAABB);
+ OBJReader objectReader;
+ CPUBoundingBox aabb;
+ CPUBoundingBox inAABB;
+ memset(&inAABB, 0, sizeof(CPUBoundingBox));
+ vec4f size =
+ objectReader.loadModelFromFile(m_filename, *m_gpuKernel,
+ objectPosition, true, m_objectScale,
+ true, RANDOM_MATERIALS_OFFSET, false,
+ true, aabb, false, inAABB);
m_groundHeight = -size.y / 2.f - sceneInfo.geometryEpsilon;
}
else
{
Strings extensions;
extensions.push_back(".obj");
- const Strings fileNames = getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/obj", extensions);
+ const Strings fileNames =
+ getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/obj",
+ extensions);
if (!fileNames.empty())
{
m_filename = fileNames[m_currentModel % fileNames.size()];
- solr::OBJReader objectReader;
- solr::CPUBoundingBox aabb;
- solr::CPUBoundingBox inAABB;
- memset(&inAABB, 0, sizeof(solr::CPUBoundingBox));
- vec4f size = objectReader.loadModelFromFile(m_filename, *m_gpuKernel, objectPosition, true, m_objectScale,
- true, 1000, false, true, aabb, false, inAABB);
+ OBJReader objectReader;
+ CPUBoundingBox aabb;
+ CPUBoundingBox inAABB;
+ memset(&inAABB, 0, sizeof(CPUBoundingBox));
+ vec4f size =
+ objectReader.loadModelFromFile(m_filename, *m_gpuKernel,
+ objectPosition, true,
+ m_objectScale, true, 1000, false,
+ true, aabb, false, inAABB);
m_groundHeight = -size.y / 2.f - sceneInfo.geometryEpsilon * 10.f;
}
}
}
-void ObjScene::doPostInitialize()
-{
-}
+void ObjScene::doPostInitialize() {}
-void ObjScene::doAnimate()
-{
-}
+void ObjScene::doAnimate() {}
void ObjScene::doAddLights()
{
@@ -101,6 +100,7 @@ void ObjScene::doAddLights()
if (m_gpuKernel->getNbActiveLamps() == 0)
{
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 8000.f, 8000.f, -8000.f, 10.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 8000.f, 8000.f, -8000.f, 10.f,
+ 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
}
}
diff --git a/apps/scenes/meshes/ObjScene.h b/apps/scenes/meshes/ObjScene.h
index d56c371..c041951 100644
--- a/apps/scenes/meshes/ObjScene.h
+++ b/apps/scenes/meshes/ObjScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/meshes/TrianglesScene.cpp b/apps/scenes/meshes/TrianglesScene.cpp
index 5ea4341..7c48983 100644
--- a/apps/scenes/meshes/TrianglesScene.cpp
+++ b/apps/scenes/meshes/TrianglesScene.cpp
@@ -1,30 +1,27 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "TrianglesScene.h"
#include
-#include
#include
#include
#include
+#include
TrianglesScene::TrianglesScene(const std::string& name)
: Scene(name)
@@ -34,22 +31,23 @@ TrianglesScene::TrianglesScene(const std::string& name)
m_groundHeight = -2500.f;
}
-TrianglesScene::~TrianglesScene(void)
-{
-}
+TrianglesScene::~TrianglesScene(void) {}
void TrianglesScene::doInitialize()
{
Strings extensions;
extensions.push_back(".irt");
- const Strings fileNames = getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/irt", extensions);
+ const Strings fileNames =
+ getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/irt",
+ extensions);
if (fileNames.size() != 0)
{
const vec4f center = make_vec4f();
const float objectScale = 1.f;
m_currentModel = m_currentModel % fileNames.size();
- solr::FileMarshaller fm;
- fm.loadFromFile(*m_gpuKernel, fileNames[m_currentModel], center, objectScale * 5000.f);
+ FileMarshaller fm;
+ fm.loadFromFile(*m_gpuKernel, fileNames[m_currentModel], center,
+ objectScale * 5000.f);
m_groundHeight = -2500.f;
}
}
@@ -69,7 +67,8 @@ void TrianglesScene::doAddLights()
{
LOG_INFO(3, "Adding sun light");
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, 5000.f, -5000.f, 10.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 5000.f, 5000.f, -5000.f, 10.f,
+ 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
}
diff --git a/apps/scenes/meshes/TrianglesScene.h b/apps/scenes/meshes/TrianglesScene.h
index 250875a..f738125 100644
--- a/apps/scenes/meshes/TrianglesScene.h
+++ b/apps/scenes/meshes/TrianglesScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/science/ColumnScene.cpp b/apps/scenes/science/ColumnScene.cpp
index 5abed39..7c42c27 100644
--- a/apps/scenes/science/ColumnScene.cpp
+++ b/apps/scenes/science/ColumnScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
- *
- * This file is part of Sol-R
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * 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 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "ColumnScene.h"
@@ -40,9 +37,7 @@ ColumnScene::ColumnScene(const std::string& name)
{
}
-ColumnScene::~ColumnScene(void)
-{
-}
+ColumnScene::~ColumnScene(void) {}
/*
________________________________________________________________________________
@@ -64,7 +59,7 @@ void ColumnScene::doInitialize()
// Scene Bounding Box
SceneInfo& sceneInfo = m_gpuKernel->getSceneInfo();
- solr::CPUBoundingBox AABB;
+ CPUBoundingBox AABB;
AABB.parameters[0].x = sceneInfo.viewDistance;
AABB.parameters[0].y = sceneInfo.viewDistance;
AABB.parameters[0].z = sceneInfo.viewDistance;
@@ -75,24 +70,29 @@ void ColumnScene::doInitialize()
Strings extensions;
extensions.push_back(".obj");
extensions.push_back(".mtl");
- const Strings fileNames = getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/obj", extensions);
+ const Strings fileNames =
+ getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/obj",
+ extensions);
const std::string star("neuron_12558.obj");
- solr::OBJReader objectReader;
- solr::CPUBoundingBox inAABB;
- memset(&inAABB, 0, sizeof(solr::CPUBoundingBox));
- const vec4f size =
- objectReader.loadModelFromFile(path + "\\" + star, *m_gpuKernel, objectPosition, false, m_objectScale,
- false, 10, false, false, AABB, false, inAABB);
-
- const vec4f halfSize = make_vec4f(
- (AABB.parameters[1].x - AABB.parameters[0].x) / 2.f,
- (AABB.parameters[1].y - AABB.parameters[0].y) / 2.f,
- (AABB.parameters[1].z - AABB.parameters[0].z) / 2.f);
-
- const vec4f boxCenter = make_vec4f((AABB.parameters[0].x + AABB.parameters[1].x) / 2.f,
- (AABB.parameters[0].y + AABB.parameters[1].y) / 2.f,
- (AABB.parameters[0].z + AABB.parameters[1].z) / 2.f);
+ OBJReader objectReader;
+ CPUBoundingBox inAABB;
+ memset(&inAABB, 0, sizeof(CPUBoundingBox));
+ const vec4f size =
+ objectReader.loadModelFromFile(path + "\\" + star, *m_gpuKernel,
+ objectPosition, false, m_objectScale,
+ false, 10, false, false, AABB, false,
+ inAABB);
+
+ const vec4f halfSize =
+ make_vec4f((AABB.parameters[1].x - AABB.parameters[0].x) / 2.f,
+ (AABB.parameters[1].y - AABB.parameters[0].y) / 2.f,
+ (AABB.parameters[1].z - AABB.parameters[0].z) / 2.f);
+
+ const vec4f boxCenter =
+ make_vec4f((AABB.parameters[0].x + AABB.parameters[1].x) / 2.f,
+ (AABB.parameters[0].y + AABB.parameters[1].y) / 2.f,
+ (AABB.parameters[0].z + AABB.parameters[1].z) / 2.f);
inAABB.parameters[0].x = (boxCenter.x - halfSize.x * boxScale);
inAABB.parameters[0].y = (boxCenter.y - halfSize.y * boxScale);
@@ -102,7 +102,9 @@ void ColumnScene::doInitialize()
inAABB.parameters[1].z = (boxCenter.z + halfSize.z * boxScale);
m_actorPosition = boxCenter;
- LOG_INFO(1, "Actor Position: " << m_actorPosition.x << "," << m_actorPosition.y << "," << m_actorPosition.z << ")");
+ LOG_INFO(1, "Actor Position: " << m_actorPosition.x << ","
+ << m_actorPosition.y << ","
+ << m_actorPosition.z << ")");
for (int i(0); i < fileNames.size(); ++i)
{
@@ -111,9 +113,10 @@ void ColumnScene::doInitialize()
LOG_INFO(1, "--- Loading " << m_name << " ---");
if (m_name.find(star) == -1)
{
- solr::CPUBoundingBox aabb;
- objectReader.loadModelFromFile(m_name, *m_gpuKernel, objectPosition, false, m_objectScale, false, 11, false,
- false, aabb, true, inAABB);
+ CPUBoundingBox aabb;
+ objectReader.loadModelFromFile(m_name, *m_gpuKernel, objectPosition,
+ false, m_objectScale, false, 11,
+ false, false, aabb, true, inAABB);
m_groundHeight = -size.y / 2.f - sceneInfo.geometryEpsilon;
@@ -134,7 +137,7 @@ void ColumnScene::doInitialize()
}
// Save to binary format
- solr::FileMarshaller fm;
+ FileMarshaller fm;
fm.saveToFile(*m_gpuKernel, "column.irt");
}
@@ -153,8 +156,10 @@ void ColumnScene::doAddLights()
{
// lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % 20000 - 10000.f, rand() % 5000 - m_groundHeight,
- rand() % 20000 - 10000.f, 10.f, 0.f, 0.f, 120 + i);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, rand() % 20000 - 10000.f,
+ rand() % 5000 - m_groundHeight,
+ rand() % 20000 - 10000.f, 10.f, 0.f, 0.f,
+ 120 + i);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
}
diff --git a/apps/scenes/science/ColumnScene.h b/apps/scenes/science/ColumnScene.h
index 11cebc4..9f8d5ee 100644
--- a/apps/scenes/science/ColumnScene.h
+++ b/apps/scenes/science/ColumnScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/science/HypercubeScene.cpp b/apps/scenes/science/HypercubeScene.cpp
new file mode 100644
index 0000000..fb1a649
--- /dev/null
+++ b/apps/scenes/science/HypercubeScene.cpp
@@ -0,0 +1,327 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/*
+IMPORTANT: This code is based on the Hypercube dephi code by cs_Forman
+http://codes-sources.commentcamarche.net/source/33735-hypercubes
+*/
+
+#include "HypercubeScene.h"
+
+#include
+
+#ifdef WIN32
+#include
+#else
+#include
+#endif
+
+float animationAngles[MaxDimensions];
+
+HypercubeScene::HypercubeScene(const std::string& name)
+ : Scene(name)
+ , _primitiveIndex(0)
+ , _scale(1000.f)
+ , _transparency((rand() % 100 > 50) ? 0.5f : 0.f)
+ , _reflection((rand() % 100 > 50) ? 1.f : 0.f)
+ , _explosionFactor(1.f + rand() % 50 / 50.f)
+{
+ srand(static_cast(time(0)));
+ _dimension = 4 + rand() % (MaxDimensions - 5);
+ LOG_INFO(1, "Number of dimensions: " << _dimension);
+ for (size_t i = 0; i < MaxDimensions; ++i)
+ if (rand() % 4 != 0)
+ animationAngles[i] = (rand() % 1000 - 500) / 200.f;
+ else
+ animationAngles[i] = 0.f;
+}
+
+HypercubeScene::~HypercubeScene(void) {}
+
+float HypercubeScene::powerOfTwo(const size_t n)
+{
+ return round(exp(log(2.f) * n));
+}
+
+void HypercubeScene::makeMatrix()
+{
+ const float ratio = static_cast(M_PI) / 360.f;
+ _matrix = identityMatrix();
+ _matrix = multiplyMatrices(
+ _matrix, makeRotationMatrix(0, 1, _angles[2] * ratio)); // Rotate
+ // YZ
+ _matrix = multiplyMatrices(
+ _matrix, makeRotationMatrix(1, 2, _angles[0] * ratio)); // Rotate
+ // XZ
+ _matrix = multiplyMatrices(
+ _matrix, makeRotationMatrix(2, 0, _angles[1] * ratio)); // Rotate
+ // XY
+ for (size_t a = 0; a < 3 * (_dimension - 3); ++a)
+ {
+ auto i = a % 3;
+ auto j = (a / 3) + 3;
+ if (a == 0)
+ {
+ auto t = i;
+ i = j;
+ j = t;
+ }
+ _matrix =
+ multiplyMatrices(_matrix,
+ makeRotationMatrix(i, j, _angles[a + 3] * ratio));
+ }
+}
+
+Matrix HypercubeScene::makeRotationMatrix(const size_t i, const size_t j,
+ const float angle)
+{
+ Matrix matrix = identityMatrix();
+ const auto c = cos(angle);
+ const auto s = sin(angle);
+ matrix.values[i][i] = c;
+ matrix.values[j][j] = c;
+ matrix.values[j][i] = s;
+ matrix.values[i][j] = -s;
+ return matrix;
+}
+
+Matrix HypercubeScene::identityMatrix()
+{
+ Matrix matrix;
+ memset(&matrix, 0, sizeof(Matrix));
+ for (size_t a = 0; a < MaxDimensions; ++a)
+ matrix.values[a][a] = 1.f;
+ return matrix;
+}
+
+Matrix HypercubeScene::multiplyMatrices(const Matrix& matrix1,
+ const Matrix& matrix2)
+{
+ Matrix matrix;
+ for (size_t a = 0; a < MaxDimensions; ++a)
+ for (size_t b = 0; b < MaxDimensions; ++b)
+ {
+ float s = 0.f;
+ for (size_t c = 0; c < MaxDimensions; ++c)
+ s += matrix1.values[a][c] * matrix2.values[c][b];
+ matrix.values[a][b] = s;
+ }
+ return matrix;
+}
+
+Vector HypercubeScene::cross(const Vector& u, const Vector& v)
+{
+ Vector vector(3, 0);
+ vector[0] = u[1] * v[2] - u[2] * v[1];
+ vector[1] = u[2] * v[0] - u[0] * v[2];
+ vector[2] = u[0] * v[1] - u[1] * v[0];
+ return vector;
+}
+
+void HypercubeScene::makeSubFaces(const size_t a, const size_t b, size_t& c,
+ const size_t n)
+{
+ const float s = _scale * _explosionFactor;
+ for (size_t i = 0; i < n; ++i)
+ {
+ const size_t index = c + 4 * i;
+ _vertices[index + 0].resize(MaxDimensions, 0.f);
+ _vertices[index + 1].resize(MaxDimensions, 0.f);
+ _vertices[index + 2].resize(MaxDimensions, 0.f);
+ _vertices[index + 3].resize(MaxDimensions, 0.f);
+ float v;
+ size_t u = 1;
+ for (size_t j = 0; j < _dimension; ++j)
+ {
+ if ((j == a) || (j == b))
+ continue;
+ if ((u & i) == u)
+ v = s;
+ else
+ v = -s;
+ _vertices[index + 0][j] = v;
+ _vertices[index + 1][j] = v;
+ _vertices[index + 2][j] = v;
+ _vertices[index + 3][j] = v;
+ u *= 2;
+ }
+ _vertices[index + 0][a] = s;
+ _vertices[index + 1][a] = s;
+ _vertices[index + 2][a] = -s;
+ _vertices[index + 3][a] = -s;
+ _vertices[index + 0][b] = s;
+ _vertices[index + 1][b] = -s;
+ _vertices[index + 2][b] = -s;
+ _vertices[index + 3][b] = s;
+ }
+
+ c += 4 * n;
+}
+
+void HypercubeScene::createGeometry()
+{
+ const size_t nbVertices =
+ (_dimension - 1) * _dimension * powerOfTwo(_dimension - 1);
+
+ const float refraction = 1.f;
+ for (unsigned int i = 0; i < (nbVertices + 4); ++i)
+ m_gpuKernel->setMaterial(i, 0.5f + 0.5f * cos(i), 0.5f,
+ 0.5f + 0.5f * cos(i) * sin(i), 0.f,
+ _reflection, refraction, false, false, 0,
+ _transparency, 0.f, TEXTURE_NONE, TEXTURE_NONE,
+ TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
+ TEXTURE_NONE, TEXTURE_NONE, 0.f, 100.f, 0.f,
+ 0.f, 10.f, 10000.f, false);
+
+ _vertices.clear();
+ size_t c = 0;
+ const size_t n = powerOfTwo(_dimension - 2);
+ for (size_t a = 0; a < _dimension - 1; ++a)
+ for (size_t b = a + 1; b < _dimension; ++b)
+ makeSubFaces(a, b, c, n);
+ makeMatrix();
+}
+
+Vector HypercubeScene::multiplyVector(const Matrix& m, const Vector& v)
+{
+ Vector vector(_dimension, 0.f);
+ for (size_t a = 0; a < _dimension; ++a)
+ {
+ float s = 0.f;
+ for (size_t b = 0; b < _dimension; ++b)
+ s += m.values[a][b] * v[b];
+ vector[a] = s;
+ }
+ return vector;
+}
+
+Vector HypercubeScene::subtractVector(const Vector& u, const Vector& v)
+{
+ Vector vector(_dimension, 0.f);
+ for (size_t a = 0; a < _dimension; ++a)
+ vector[a] = u[a] - v[a];
+ return vector;
+}
+
+void HypercubeScene::drawFace(const size_t Id)
+{
+ Vector t = multiplyVector(_matrix, _vertices[Id + 0]);
+ Vector u = multiplyVector(_matrix, _vertices[Id + 1]);
+ Vector v = multiplyVector(_matrix, _vertices[Id + 2]);
+ Vector w = multiplyVector(_matrix, _vertices[Id + 3]);
+
+ const Vector n = cross(subtractVector(t, v), subtractVector(u, w));
+ vec3f normal = make_vec3f(n[0], n[1], n[2]);
+
+ const size_t index = 0;
+ if (m_currentModel % 2 == 0)
+ {
+ m_gpuKernel->setCurrentMaterial(static_cast(Id));
+ glBegin(GL_TRIANGLES);
+ glVertex3f(t[index], t[index + 1], t[index + 2]);
+ glNormal3f(normal.x, normal.y, normal.z);
+ glVertex3f(u[index], u[index + 1], u[index + 2]);
+ glNormal3f(normal.x, normal.y, normal.z);
+ glVertex3f(v[index], v[index + 1], v[index + 2]);
+ glNormal3f(normal.x, normal.y, normal.z);
+ glEnd();
+
+ glBegin(GL_TRIANGLES);
+ glVertex3f(v[index], v[index + 1], v[index + 2]);
+ glNormal3f(normal.x, normal.y, normal.z);
+ glVertex3f(w[index], w[index + 1], w[index + 2]);
+ glNormal3f(normal.x, normal.y, normal.z);
+ glVertex3f(t[index], t[index + 1], t[index + 2]);
+ glNormal3f(normal.x, normal.y, normal.z);
+ glEnd();
+ }
+
+ if (m_currentModel % 10 != 0)
+ {
+ const float radius = _scale / 50.f;
+ _primitiveIndex = m_gpuKernel->addPrimitive(ptCylinder);
+ m_gpuKernel->setPrimitive(_primitiveIndex, t[index], t[index + 1],
+ t[index + 2], u[index], u[index + 1],
+ u[index + 2], radius, 0.f, 0.f,
+ METAL_MATERIAL);
+ _primitiveIndex = m_gpuKernel->addPrimitive(ptCylinder);
+ m_gpuKernel->setPrimitive(_primitiveIndex, u[index], u[index + 1],
+ u[index + 2], v[index], v[index + 1],
+ v[index + 2], radius, 0.f, 0.f,
+ METAL_MATERIAL);
+ _primitiveIndex = m_gpuKernel->addPrimitive(ptCylinder);
+ m_gpuKernel->setPrimitive(_primitiveIndex, v[index], v[index + 1],
+ v[index + 2], w[index], w[index + 1],
+ w[index + 2], radius, 0.f, 0.f,
+ METAL_MATERIAL);
+ _primitiveIndex = m_gpuKernel->addPrimitive(ptCylinder);
+ m_gpuKernel->setPrimitive(_primitiveIndex, w[index], w[index + 1],
+ w[index + 2], t[index], t[index + 1],
+ t[index + 2], radius, 0.f, 0.f,
+ METAL_MATERIAL);
+ }
+}
+
+void HypercubeScene::drawFaces()
+{
+ for (size_t a = 0; a < (_vertices.size() + 1) / 4; ++a)
+ drawFace(4 * a);
+
+ if (m_currentModel % 3 == 0)
+ for (size_t a = 0; a < _vertices.size(); ++a)
+ {
+ const size_t index = 0;
+ const float radius = _scale / 10.f;
+ Vector t = multiplyVector(_matrix, _vertices[a]);
+ _primitiveIndex = m_gpuKernel->addPrimitive(ptSphere);
+ m_gpuKernel->setPrimitive(_primitiveIndex, t[index], t[index + 1],
+ t[index + 2], radius, 0.f, 0.f,
+ METAL_MATERIAL);
+ }
+}
+
+void HypercubeScene::doInitialize()
+{
+ _angles.resize(MaxDimensions, 0.f);
+ for (size_t i = 0; i < MaxDimensions; ++i)
+ _angles[i] = animationAngles[i];
+ createGeometry();
+ drawFaces();
+}
+
+void HypercubeScene::doAnimate()
+{
+ for (size_t i = 0; i < MaxDimensions; ++i)
+ _angles[i] += animationAngles[i];
+
+ _primitiveIndex = 0;
+ m_gpuKernel->resetFrame();
+ createGeometry();
+ drawFaces();
+ doAddLights();
+ addCornellBox(m_cornellBoxType);
+ m_gpuKernel->compactBoxes(true);
+}
+
+void HypercubeScene::doAddLights()
+{
+ // lights
+ m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 10000.f, -10000.f, 1000.f,
+ 0.f, 0, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
+}
diff --git a/apps/scenes/science/HypercubeScene.h b/apps/scenes/science/HypercubeScene.h
new file mode 100644
index 0000000..dae83fd
--- /dev/null
+++ b/apps/scenes/science/HypercubeScene.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+#include
+
+const size_t MaxDimensions = 7;
+
+struct Matrix
+{
+ float values[MaxDimensions][MaxDimensions];
+};
+
+typedef std::vector Vector;
+
+class HypercubeScene : public Scene
+{
+public:
+ HypercubeScene(const std::string& name);
+ ~HypercubeScene(void);
+
+protected:
+ virtual void doInitialize();
+ virtual void doAnimate();
+ virtual void doAddLights();
+
+private:
+ float powerOfTwo(const size_t n);
+ void createGeometry();
+ void makeSubFaces(const size_t a, const size_t b, size_t& c,
+ const size_t n);
+ void makeMatrix();
+ Matrix identityMatrix();
+ Matrix multiplyMatrices(const Matrix&, const Matrix&);
+ Matrix makeRotationMatrix(const size_t ID, const size_t IDD,
+ const float angle);
+
+ Vector cross(const Vector& u, const Vector& v);
+ Vector multiplyVector(const Matrix& m, const Vector& v);
+ Vector subtractVector(const Vector& u, const Vector& v);
+
+ void drawFace(size_t Id);
+ void drawFaces();
+
+private:
+ size_t _dimension;
+ std::map _vertices;
+ Matrix _matrix;
+ std::vector _angles;
+ int _primitiveIndex;
+ float _scale;
+ float _transparency;
+ float _reflection;
+ float _explosionFactor;
+};
diff --git a/apps/scenes/science/MoleculeScene.cpp b/apps/scenes/science/MoleculeScene.cpp
index 8c16414..d789684 100644
--- a/apps/scenes/science/MoleculeScene.cpp
+++ b/apps/scenes/science/MoleculeScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "MoleculeScene.h"
@@ -41,9 +38,7 @@ MoleculeScene::MoleculeScene(const std::string& name)
m_groundHeight = -5000.f;
}
-MoleculeScene::~MoleculeScene(void)
-{
-}
+MoleculeScene::~MoleculeScene(void) {}
void MoleculeScene::doInitialize()
{
@@ -56,7 +51,9 @@ void MoleculeScene::doInitialize()
Strings extensions;
extensions.push_back(".pdb");
- const Strings fileNames = getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/pdb", extensions);
+ const Strings fileNames =
+ getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/pdb",
+ extensions);
if (fileNames.size() != 0)
{
m_currentModel = m_currentModel % fileNames.size();
@@ -66,9 +63,11 @@ void MoleculeScene::doInitialize()
m_name = fileNames[m_currentModel];
// PDB
- solr::PDBReader pdbReader;
- pdbReader.loadAtomsFromFile(m_name, *m_gpuKernel, static_cast(geometryType),
- defaultAtomSize, defaultStickSize, atomMaterialType, scale, loadModels);
+ PDBReader pdbReader;
+ pdbReader.loadAtomsFromFile(m_name, *m_gpuKernel,
+ static_cast(geometryType),
+ defaultAtomSize, defaultStickSize,
+ atomMaterialType, scale, loadModels);
}
}
@@ -84,6 +83,7 @@ void MoleculeScene::doAddLights()
{
// Lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -5000.f, 5000.f, -15000.f, 1.f, 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -5000.f, 5000.f, -15000.f, 1.f,
+ 0.f, 0.f, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
diff --git a/apps/scenes/science/MoleculeScene.h b/apps/scenes/science/MoleculeScene.h
index afd7dfa..e74ef4f 100644
--- a/apps/scenes/science/MoleculeScene.h
+++ b/apps/scenes/science/MoleculeScene.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
diff --git a/apps/scenes/science/SwcScene.cpp b/apps/scenes/science/SwcScene.cpp
index 3a9dd6e..cde98f5 100644
--- a/apps/scenes/science/SwcScene.cpp
+++ b/apps/scenes/science/SwcScene.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
- *
- * This file is part of Sol-R
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * 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 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.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#include "SwcScene.h"
@@ -29,14 +26,12 @@ SwcScene::SwcScene(const std::string &name)
{
}
-SwcScene::~SwcScene()
-{
-}
+SwcScene::~SwcScene() {}
/*
________________________________________________________________________________
-Create simple scene for box validation
+Create simple scene for box validation
________________________________________________________________________________
*/
void SwcScene::doInitialize()
@@ -44,7 +39,9 @@ void SwcScene::doInitialize()
// initialization
Strings extensions;
extensions.push_back(".swc");
- const Strings fileNames = getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/swc", extensions);
+ const Strings fileNames =
+ getFilesFromFolder(std::string(DEFAULT_MEDIA_FOLDER) + "/swc",
+ extensions);
if (fileNames.size() != 0)
{
m_currentModel = m_currentModel % fileNames.size();
@@ -54,8 +51,9 @@ void SwcScene::doInitialize()
const vec4f position = make_vec4f(0.f, 0.f, 0.f);
for (int i(0); i < fileNames.size(); ++i)
{
- solr::SWCReader swcReader;
- swcReader.loadMorphologyFromFile(fileNames[i], *m_gpuKernel, position, scale, 1001);
+ SWCReader swcReader;
+ swcReader.loadMorphologyFromFile(fileNames[i], *m_gpuKernel,
+ position, scale, 1001);
if (i == 0)
m_morphologies = swcReader.getMorphologies();
@@ -66,9 +64,10 @@ void SwcScene::doInitialize()
void SwcScene::doAnimate()
{
const int index = m_counter % m_morphologies.size();
- solr::Morphology &m = m_morphologies[index];
+ Morphology &m = m_morphologies[index];
if (m_counter > 0)
- m_gpuKernel->setPrimitiveMaterial(m_previousPrimitiveId, m_previousMaterial);
+ m_gpuKernel->setPrimitiveMaterial(m_previousPrimitiveId,
+ m_previousMaterial);
m_previousMaterial = m_gpuKernel->getPrimitiveMaterial(m.primitiveId);
m_gpuKernel->setPrimitiveMaterial(m.primitiveId, DEFAULT_LIGHT_MATERIAL);
@@ -77,7 +76,7 @@ void SwcScene::doAnimate()
const int light = m_gpuKernel->getLight(0);
if (light != -1)
{
- solr::CPUPrimitive *lamp = m_gpuKernel->getPrimitive(light);
+ CPUPrimitive *lamp = m_gpuKernel->getPrimitive(light);
lamp->p0.x = m.x;
lamp->p0.y = m.y;
lamp->p0.z = m.z - 50.f;
@@ -92,6 +91,7 @@ void SwcScene::doAddLights()
{
// lights
m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
- m_gpuKernel->setPrimitive(m_nbPrimitives, -10000.f, 10000.f, -10000.f, 20.f, 0.f, 0, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, -10000.f, 10000.f, -10000.f, 20.f,
+ 0.f, 0, DEFAULT_LIGHT_MATERIAL);
m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
}
diff --git a/apps/scenes/science/SwcScene.h b/apps/scenes/science/SwcScene.h
index fd31c17..9cfdc96 100644
--- a/apps/scenes/science/SwcScene.h
+++ b/apps/scenes/science/SwcScene.h
@@ -1,27 +1,24 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
-#include
#include
+#include
class SwcScene : public Scene
{
@@ -35,7 +32,7 @@ class SwcScene : public Scene
virtual void doAddLights();
private:
- solr::Morphologies m_morphologies;
+ Morphologies m_morphologies;
int m_counter;
int m_previousMaterial;
int m_previousPrimitiveId;
diff --git a/apps/scenes/science/TesseractScene.cpp b/apps/scenes/science/TesseractScene.cpp
new file mode 100644
index 0000000..be08604
--- /dev/null
+++ b/apps/scenes/science/TesseractScene.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "TesseractScene.h"
+
+#include
+
+TesseractScene::TesseractScene(const std::string& name)
+ : Scene(name)
+ , _timestamp(0.f)
+{
+}
+
+TesseractScene::~TesseractScene() {}
+
+vec3f TesseractScene::computeCoordinates(const vec3f& p1, const vec3f& p2,
+ const vec3f& p3, const vec3f& p4)
+{
+ vec3f newVec;
+
+ if (_timestamp >= 0.f && _timestamp < 0.25f)
+ {
+ newVec.x = p4.x + (p1.x - p4.x) * _timestamp * 4.f;
+ newVec.y = p4.y + (p1.y - p4.y) * _timestamp * 4.f;
+ newVec.z = p4.z + (p1.z - p4.z) * _timestamp * 4.f;
+ }
+ else if (_timestamp >= 0.25f && _timestamp < 0.5f)
+ {
+ newVec.x = p1.x + (p2.x - p1.x) * (_timestamp - 0.25f) * 4.f;
+ newVec.y = p1.y + (p2.y - p1.y) * (_timestamp - 0.25f) * 4.f;
+ newVec.z = p1.z + (p2.z - p1.z) * (_timestamp - 0.25f) * 4.f;
+ }
+ else if (_timestamp >= 0.5f && _timestamp < 0.75f)
+ {
+ newVec.x = p2.x + (p3.x - p2.x) * (_timestamp - 0.5f) * 4.f;
+ newVec.y = p2.y + (p3.y - p2.y) * (_timestamp - 0.5f) * 4.f;
+ newVec.z = p2.z + (p3.z - p2.z) * (_timestamp - 0.5f) * 4.f;
+ }
+ else if (_timestamp >= 0.75f && _timestamp < 1.f)
+ {
+ newVec.x = p3.x + (p4.x - p3.x) * (_timestamp - 0.75f) * 4.f;
+ newVec.y = p3.y + (p4.y - p3.y) * (_timestamp - 0.75f) * 4.f;
+ newVec.z = p3.z + (p4.z - p3.z) * (_timestamp - 0.75f) * 4.f;
+ }
+
+ return newVec;
+}
+
+void TesseractScene::createGeometry()
+{
+ vec3f tesseract[16] = {
+ {-0.5, -0.5, -0.5}, {0.5, -0.5, -0.5}, {0.5, 0.5, -0.5},
+ {-0.5, 0.5, -0.5}, {-0.5, -0.5, 0.5}, {0.5, -0.5, 0.5},
+ {0.5, 0.5, 0.5}, {-0.5, 0.5, 0.5}, {-1, -1, -1},
+ {1, -1, -1}, {1, 1, -1}, {-1, 1, -1},
+ {-1, -1, 1}, {1, -1, 1}, {1, 1, 1},
+ {-1, 1, 1},
+ };
+
+ vec3f vertices[16] = {computeCoordinates(tesseract[8], tesseract[9],
+ tesseract[1], tesseract[0]),
+ computeCoordinates(tesseract[0], tesseract[8],
+ tesseract[9], tesseract[1]),
+ computeCoordinates(tesseract[3], tesseract[11],
+ tesseract[10], tesseract[2]),
+ computeCoordinates(tesseract[11], tesseract[10],
+ tesseract[2], tesseract[3]),
+ computeCoordinates(tesseract[12], tesseract[13],
+ tesseract[5], tesseract[4]),
+ computeCoordinates(tesseract[4], tesseract[12],
+ tesseract[13], tesseract[5]),
+ computeCoordinates(tesseract[7], tesseract[15],
+ tesseract[14], tesseract[6]),
+ computeCoordinates(tesseract[15], tesseract[14],
+ tesseract[6], tesseract[7]),
+ computeCoordinates(tesseract[9], tesseract[1],
+ tesseract[0], tesseract[8]),
+ computeCoordinates(tesseract[1], tesseract[0],
+ tesseract[8], tesseract[9]),
+ computeCoordinates(tesseract[2], tesseract[3],
+ tesseract[11], tesseract[10]),
+ computeCoordinates(tesseract[10], tesseract[2],
+ tesseract[3], tesseract[11]),
+ computeCoordinates(tesseract[13], tesseract[5],
+ tesseract[4], tesseract[12]),
+ computeCoordinates(tesseract[5], tesseract[4],
+ tesseract[12], tesseract[13]),
+ computeCoordinates(tesseract[6], tesseract[7],
+ tesseract[15], tesseract[14]),
+ computeCoordinates(tesseract[14], tesseract[6],
+ tesseract[7], tesseract[15])};
+
+ const float s = 2000.f;
+ float radius = s / 10.f;
+ for (size_t i = 0; i < 16; ++i)
+ {
+ vec3f t = vertices[i];
+ size_t primitiveIndex = m_gpuKernel->addPrimitive(ptSphere);
+ m_gpuKernel->setPrimitive(primitiveIndex, s * t.x, s * t.y, s * t.z,
+ radius, 0.f, 0.f, METAL_MATERIAL);
+ }
+
+ const size_t joints[32][2] = {
+ {0, 1}, {1, 2}, {2, 3}, {3, 0}, {0, 4}, {1, 5}, {2, 6},
+ {3, 7}, {4, 5}, {5, 6}, {6, 7}, {7, 4}, {0, 8}, {1, 9},
+ {2, 10}, {3, 11}, {4, 12}, {5, 13}, {6, 14}, {7, 15}, {8, 9},
+ {9, 10}, {10, 11}, {11, 8}, {8, 12}, {9, 13}, {10, 14}, {11, 15},
+ {12, 13}, {13, 14}, {14, 15}, {15, 12},
+ };
+
+ radius = s / 20.f;
+ for (size_t i = 0; i < 32; ++i)
+ {
+ vec3f t = vertices[joints[i][0]];
+ vec3f u = vertices[joints[i][1]];
+
+ size_t primitiveIndex = m_gpuKernel->addPrimitive(ptCylinder);
+ m_gpuKernel->setPrimitive(primitiveIndex, s * t.x, s * t.y, s * t.z,
+ s * u.x, s * u.y, s * u.z, radius, 0.f, 0.f,
+ METAL_MATERIAL);
+ }
+
+ size_t material = BASIC_REFLECTION_MATERIAL_002;
+ for (size_t i = 0; i < 32; i += 4)
+ {
+ vec3f t = vertices[joints[i][0]];
+ vec3f u = vertices[joints[i + 1][0]];
+ vec3f v = vertices[joints[i + 2][0]];
+ vec3f w = vertices[joints[i + 3][0]];
+
+ m_gpuKernel->setCurrentMaterial(material);
+ glBegin(GL_TRIANGLES);
+ glVertex3f(s * t.x, s * t.y, s * t.z);
+ glVertex3f(s * u.x, s * u.y, s * u.z);
+ glVertex3f(s * v.x, s * v.y, s * v.z);
+ glEnd();
+
+ glBegin(GL_TRIANGLES);
+ glVertex3f(s * v.x, s * v.y, s * v.z);
+ glVertex3f(s * w.x, s * w.y, s * w.z);
+ glVertex3f(s * t.x, s * t.y, s * t.z);
+ glEnd();
+ }
+}
+
+void TesseractScene::doInitialize()
+{
+ createGeometry();
+ doAddLights();
+}
+
+void TesseractScene::doAnimate()
+{
+ m_gpuKernel->resetFrame();
+ createGeometry();
+ doAddLights();
+ addCornellBox(m_cornellBoxType);
+ m_gpuKernel->compactBoxes(true);
+ _timestamp += 0.005f;
+ if (_timestamp > 1.f)
+ _timestamp = 0.f;
+}
+
+void TesseractScene::doAddLights()
+{
+ // lights
+ m_nbPrimitives = m_gpuKernel->addPrimitive(ptSphere);
+ m_gpuKernel->setPrimitive(m_nbPrimitives, 0.f, 10000.f, -10000.f, 1000.f,
+ 0.f, 0, DEFAULT_LIGHT_MATERIAL);
+ m_gpuKernel->setPrimitiveIsMovable(m_nbPrimitives, false);
+}
diff --git a/apps/scenes/science/TesseractScene.h b/apps/scenes/science/TesseractScene.h
new file mode 100644
index 0000000..e13be64
--- /dev/null
+++ b/apps/scenes/science/TesseractScene.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+#include
+
+class TesseractScene : public Scene
+{
+public:
+ TesseractScene(const std::string& name);
+ ~TesseractScene();
+
+protected:
+ virtual void doInitialize();
+ virtual void doAnimate();
+ virtual void doAddLights();
+
+private:
+ vec3f computeCoordinates(const vec3f& p1, const vec3f& p2, const vec3f& p3,
+ const vec3f& p4);
+ void createGeometry();
+ float _timestamp;
+};
diff --git a/apps/solrViewer.cpp b/apps/solrViewer.cpp
index 290a552..915e9b4 100644
--- a/apps/solrViewer.cpp
+++ b/apps/solrViewer.cpp
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
// OpenGL Graphics Includes
@@ -45,26 +42,28 @@
#include
#include
#include
-#include
-#include
#include
#include
#include
#include
+#include
+#include
#include
#include
#include
#include
#include
#include
+#include
#include
#include
+#include
+
+#include
// Ray-tracing Kernel
solr::GPUKernel *gKernel = solr::SingletonKernel::kernel();
-using namespace solr;
-
// General Settings
const int TARGET_FPS = 60;
const int REFRESH_DELAY = 1000 / TARGET_FPS; // ms
@@ -110,8 +109,8 @@ std::string gFilename;
unsigned int gWindowWidth = 1280 / 2;
unsigned int gWindowHeight = 800 / 2;
#else
-unsigned int gWindowWidth = 800;
-unsigned int gWindowHeight = static_cast(gWindowWidth * 9.f / 16.f);
+unsigned int gWindowWidth = 960;
+unsigned int gWindowHeight = 540;
#endif // USE_OCULUS
unsigned int gWindowDepth = 4;
@@ -125,28 +124,29 @@ struct MenuItem
char key;
};
const int NB_MENU_ITEMS = 22;
-MenuItem menuItems[NB_MENU_ITEMS] = {{"a: Black background and no image noise", 'a'},
- {"b: Randomly set background color and image noise", 'b'},
- {"f: Auto-focus", 'f'},
- {"h: Help", 'h'},
- {"i: Show/hide Bounding boxes", 'i'},
- {"m: Animate scene", 'm'},
- {"n: Load next 3D model (in folder medias/obj)", 'n'},
- {"o: Switch to VR mode", 'o'},
- {"p: Post processing (Depth of field, ambient occlusion, bloom, etc)", 'p'},
- {"r: Reset current scene", 'r'},
- {"t: Next scene", 't'},
- {"s: Change graphics level", 's'},
- {"v: Random materials", 'i'},
- {"x: Next environment (CornellBox, SkyBox, etc.)", 'x'},
- {"*: View modes (Standard, Anaglyth 3D, Oculus Rift", '*'},
- {"1: Camera mouse control", '1'},
- {"2: Light mouse control", '2'},
- {"3: 3D model mouse control", '3'},
- {"4: Depth of field mouse control", '3'},
- {"5: Field of view mouse control", '3'},
- {"9: Shadow strength", '9'},
- {"Esc: Exit application", '\033'}};
+MenuItem menuItems[NB_MENU_ITEMS] = {
+ {"A: Black background and no image noise", 'A'},
+ {"b: Randomly set background color and image noise", 'b'},
+ {"f: Auto-focus", 'f'},
+ {"h: Help", 'h'},
+ {"i: Show/hide Bounding boxes", 'i'},
+ {"m: Animate scene", 'm'},
+ {"n: Load next 3D model (in folder medias/obj)", 'n'},
+ {"o: Switch to VR mode", 'o'},
+ {"p: Post processing (Depth of field, ambient occlusion, bloom, etc)", 'p'},
+ {"r: Reset current scene", 'r'},
+ {"t: Next scene", 't'},
+ {"s: Change graphics level", 's'},
+ {"v: Random materials", 'i'},
+ {"x: Next environment (CornellBox, SkyBox, etc.)", 'x'},
+ {"*: View modes (Standard, Anaglyth 3D, Oculus Rift", '*'},
+ {"1: Camera mouse control", '1'},
+ {"2: Light mouse control", '2'},
+ {"3: 3D model mouse control", '3'},
+ {"4: Depth of field mouse control", '3'},
+ {"5: Field of view mouse control", '3'},
+ {"9: Shadow strength", '9'},
+ {"Esc: Exit application", '\033'}};
// controlType
enum ControlType
@@ -168,7 +168,7 @@ int gMaterials[2];
int gWallTexture = 3;
// Scene description and behavior
-int gCornellBoxType = 1;
+int gCornellBoxType = 0;
int gNbBoxes = 0;
int m_nbPrimitives = 0;
int gLampId = 0;
@@ -191,7 +191,6 @@ float gSpecValue = 1.f;
float gSpecPower = 100.f;
float gSpecCoef = 1.f;
float gInnerIllumination = 0.f;
-bool gNoise(false);
// OpenGL
int gTimebase(0);
@@ -209,7 +208,8 @@ void reshape(int x, int y);
void createScene();
#ifdef WIN32
-void RenderString(float x, float y, float z, void *font, const std::string &string, const vec4f &rgb);
+void RenderString(float x, float y, float z, void *font,
+ const std::string &string, const vec4f &rgb);
#endif
// Helpers
@@ -271,7 +271,7 @@ void initgl(int argc, char **argv)
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowPosition(glutGet(GLUT_SCREEN_WIDTH) / 2 - gWindowWidth / 2,
glutGet(GLUT_SCREEN_HEIGHT) / 2 - gWindowHeight / 2);
- std::string caption("SoL-R tech demo v00.02.00");
+ std::string caption("Quantum of SoL-R tech demo v00.02.00");
#ifdef USE_CUDA
caption += " (Powered by CUDA)";
glutInitWindowSize(gWindowWidth, gWindowHeight);
@@ -290,11 +290,13 @@ void initgl(int argc, char **argv)
}
#ifdef WIN32
-void RenderString(float x, float y, float z, void *font, const std::string &string, const vec4f &rgb)
+void RenderString(float x, float y, float z, void *font,
+ const std::string &string, const vec4f &rgb)
{
// glColor3f(rgb.x, rgb.y, rgb.z);
glRasterPos3f(x, y, z);
- glutBitmapString(font, reinterpret_cast(string.c_str()));
+ glutBitmapString(font,
+ reinterpret_cast(string.c_str()));
}
#endif
@@ -357,15 +359,20 @@ void display()
tmpMenuItems += "\n";
}
vec4f textColor = {1.f, 1.f, 1.f};
- sprintf(tmp,
- "%sSelected primitive: %d\nFPS: %d on %s (%dx%d)\nScene "
- "%d: %s\nMouse control: %s\nPrimitives/Boxes: "
- "%d/%d\nhttp://cudaopencl.blogspot.com [%d]",
- tmpMenuItems.c_str(), gSelectedPrimitive, gFPS, gKernel->getGPUDescription().c_str(),
- gScene->getSceneInfo().size.x, gScene->getSceneInfo().size.y, gSceneId,
- gScene->getName().c_str(), gHint.c_str(), gKernel->getNbActivePrimitives(),
- gKernel->getNbActiveBoxes(), si.pathTracingIteration);
- RenderString(-0.9f, 0.9f, 0.f, GLUT_BITMAP_HELVETICA_10, tmp, textColor);
+ sprintf(
+ tmp,
+ "%sSelected primitive: %d\nFPS: %d on %s (%dx%d)\nScene "
+ "%d: %s\nMouse control: %s\nPrimitives/Boxes: "
+ "%d/%d\nhttp://cudaopencl.blogspot.com [%d]",
+ tmpMenuItems.c_str(), gSelectedPrimitive, gFPS,
+ gKernel->getGPUDescription().c_str(),
+ gScene->getSceneInfo().size.x,
+ gScene->getSceneInfo().size.y, gSceneId,
+ gScene->getName().c_str(), gHint.c_str(),
+ gKernel->getNbActivePrimitives(),
+ gKernel->getNbActiveBoxes(), si.pathTracingIteration);
+ RenderString(-0.9f, 0.9f, 0.f, GLUT_BITMAP_HELVETICA_10, tmp,
+ textColor);
}
#endif // WIN32
}
@@ -387,18 +394,22 @@ void display()
text << gRenderingTime << " ms\n";
text << gKernel->getGPUDescription();
text << "\n"
- << gKernel->getNbActivePrimitives() << " triangles, " << si.size.x << "x" << si.size.y << ", "
+ << gKernel->getNbActivePrimitives() << " triangles, "
+ << si.size.x << "x" << si.size.y << ", "
<< si.maxPathTracingIterations << " samples/pixel";
- RenderString(-0.95f, -0.8f, 0.f, GLUT_BITMAP_HELVETICA_10, text.str().c_str(), make_vec4f(1.f,1.f,1.f));
+ RenderString(-0.95f, -0.8f, 0.f, GLUT_BITMAP_HELVETICA_10,
+ text.str().c_str(), make_vec4f(1.f, 1.f, 1.f));
gScene->renderText();
#endif
if (!gSavedToDisk)
{
int margin = 32;
- size_t size = (si.size.x - margin) * (si.size.y - margin) * gColorDepth;
+ size_t size =
+ (si.size.x - margin) * (si.size.y - margin) * gColorDepth;
GLubyte *buffer = new GLubyte[size];
- glReadPixels(0, 0, si.size.x - margin, si.size.y - margin, GL_RGB, GL_UNSIGNED_BYTE, buffer);
+ glReadPixels(0, 0, si.size.x - margin, si.size.y - margin,
+ GL_RGB, GL_UNSIGNED_BYTE, buffer);
GLubyte *dst = new GLubyte[size];
int X = (si.size.x - margin) * gColorDepth;
@@ -412,8 +423,10 @@ void display()
// Save to disc
std::string filename("./SolR");
filename += ".jpg";
- jpge::compress_image_to_jpeg_file(filename.c_str(), si.size.x - margin, si.size.y - margin, gColorDepth,
- dst);
+ jpge::compress_image_to_jpeg_file(filename.c_str(),
+ si.size.x - margin,
+ si.size.y - margin,
+ gColorDepth, dst);
delete[] buffer;
delete[] dst;
gSavedToDisk = true;
@@ -427,7 +440,8 @@ void display()
// Copyright
const char *copyright = "http://cudaopencl.blogspot.com";
float p = strlen(copyright) * 20.f / si.size.x;
- RenderString(-p / 2.f, -0.9f, 0.f, GLUT_BITMAP_HELVETICA_18, copyright, make_vec4f(1.f,1.f,1.f));
+ RenderString(-p / 2.f, -0.9f, 0.f, GLUT_BITMAP_HELVETICA_18,
+ copyright, make_vec4f(1.f, 1.f, 1.f));
gScene->renderText();
}
@@ -454,7 +468,8 @@ case 10: // Kinect
{
for (int x(0); x < KINECT_DEPTH_WIDTH; x += gKinectStep)
{
- int index = KINECT_DEPTH_SIZE - (y * KINECT_DEPTH_WIDTH + x) * KINECT_DEPTH_DEPTH;
+ int index = KINECT_DEPTH_SIZE -
+ (y * KINECT_DEPTH_WIDTH + x) * KINECT_DEPTH_DEPTH;
char a = depthBitmap[index];
char b = depthBitmap[index + 1];
int s = b * 256 + a;
@@ -463,8 +478,10 @@ case 10: // Kinect
if (s < 1 || s > 15000)
s = 50000;
- kernel.setPrimitive(p, 5 + p / gKinectNbSpherePerBox, -(x - 160) * gKinectSpace,
- (y - 120) * gKinectSpace, s / 3.f - 5000.f, gKinectSize, 0.f, 0.f, 7, 1, 1);
+ kernel.setPrimitive(p, 5 + p / gKinectNbSpherePerBox,
+ -(x - 160) * gKinectSpace,
+ (y - 120) * gKinectSpace, s / 3.f - 5000.f,
+ gKinectSize, 0.f, 0.f, 7, 1, 1);
++b;
++p;
@@ -485,7 +502,6 @@ void reshape(int x, int y)
x += 32 - (x % 32);
if (y % 32 != 0)
y += 32 - (y % 32);
- // y = x*9/16;
SceneInfo &sceneInfo = gScene->getSceneInfo();
sceneInfo.size.x = x;
sceneInfo.size.y = y;
@@ -531,17 +547,21 @@ void keyboard(unsigned char key, int x, int y)
}
case 'B':
{
- gScene->getSceneInfo().backgroundColor.x = 1.f;
- gScene->getSceneInfo().backgroundColor.y = 1.f;
- gScene->getSceneInfo().backgroundColor.z = 1.f;
+ gScene->getSceneInfo().backgroundColor.x = 0.1f;
+ gScene->getSceneInfo().backgroundColor.y = 0.1f;
+ gScene->getSceneInfo().backgroundColor.z = 0.1f;
gScene->getSceneInfo().backgroundColor.w = 0.5f;
gScene->getSceneInfo().skyboxMaterialId =
- (gScene->getSceneInfo().skyboxMaterialId == MATERIAL_NONE) ? SKYBOX_SPHERE_MATERIAL : MATERIAL_NONE;
+ (gScene->getSceneInfo().skyboxMaterialId == MATERIAL_NONE)
+ ? SKYBOX_SPHERE_MATERIAL
+ : MATERIAL_NONE;
break;
}
case 'b':
{
- gScene->getSceneInfo().backgroundColor = make_vec4f(rand() % 255 / 255.f, rand() % 255 / 255.f, rand() % 255 / 255.f, 0.5f);
+ gScene->getSceneInfo().backgroundColor =
+ make_vec4f(rand() % 255 / 255.f, rand() % 255 / 255.f,
+ rand() % 255 / 255.f, 0.5f);
break;
}
case 'D':
@@ -560,7 +580,8 @@ void keyboard(unsigned char key, int x, int y)
case 'E':
{
// Extended geometry
- gScene->getSceneInfo().extendedGeometry = !gScene->getSceneInfo().extendedGeometry;
+ gScene->getSceneInfo().extendedGeometry =
+ !gScene->getSceneInfo().extendedGeometry;
break;
}
case 'e':
@@ -571,11 +592,16 @@ void keyboard(unsigned char key, int x, int y)
{
Material *m = kernel->getMaterial(SKYBOX_SPHERE_MATERIAL);
gSphereMaterial = (gSphereMaterial + 1) % nbHDRI;
- kernel->setMaterial(SKYBOX_SPHERE_MATERIAL, m->color.x, m->color.y, m->color.z, m->color.w, 0.f, 0.f,
- (m->attributes.y == 1), (m->attributes.z == 1), m->attributes.w, 0.f, m->opacity,
- gSphereMaterial, TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
- TEXTURE_NONE, m->specular.x, m->specular.y, m->specular.z, m->innerIllumination.x,
- m->innerIllumination.y, m->innerIllumination.z, (m->attributes.x == 1));
+ kernel->setMaterial(SKYBOX_SPHERE_MATERIAL, m->color.x, m->color.y,
+ m->color.z, m->color.w, 0.f, 0.f,
+ (m->attributes.y == 1), (m->attributes.z == 1),
+ m->attributes.w, 0.f, m->opacity,
+ gSphereMaterial, TEXTURE_NONE, TEXTURE_NONE,
+ TEXTURE_NONE, TEXTURE_NONE, TEXTURE_NONE,
+ TEXTURE_NONE, m->specular.x, m->specular.y,
+ m->specular.z, m->innerIllumination.x,
+ m->innerIllumination.y, m->innerIllumination.z,
+ (m->attributes.x == 1));
}
break;
}
@@ -597,7 +623,8 @@ void keyboard(unsigned char key, int x, int y)
}
case 'g':
{
- int nbTextures = (kernel->getNbActiveTextures() - gScene->getNbHDRI()) / 5;
+ int nbTextures =
+ (kernel->getNbActiveTextures() - gScene->getNbHDRI()) / 5;
if (nbTextures > 0)
{
gGroundMaterial = (gGroundMaterial + 1) % nbTextures;
@@ -648,12 +675,17 @@ void keyboard(unsigned char key, int x, int y)
m->transparency = 1.f;
m->refraction = 1.1f;
}
- kernel->setMaterial(SKYBOX_GROUND_MATERIAL, m->color.x, m->color.y, m->color.z, m->color.w, 1.f,
- m->refraction, (m->attributes.y == 1), (m->attributes.z == 1), m->attributes.w,
- m->transparency, m->opacity, diffuseTextureId, normalTextureId, bumpTextureId,
- specularTextureId, reflectionTextureId, transparencyTextureId, TEXTURE_NONE,
- m->specular.x, m->specular.y, m->specular.z, m->innerIllumination.x,
- m->innerIllumination.y, m->innerIllumination.z, (m->attributes.x == 1));
+ kernel->setMaterial(SKYBOX_GROUND_MATERIAL, m->color.x, m->color.y,
+ m->color.z, m->color.w, 1.f, m->refraction,
+ (m->attributes.y == 1), (m->attributes.z == 1),
+ m->attributes.w, m->transparency, m->opacity,
+ diffuseTextureId, normalTextureId,
+ bumpTextureId, specularTextureId,
+ reflectionTextureId, transparencyTextureId,
+ TEXTURE_NONE, m->specular.x, m->specular.y,
+ m->specular.z, m->innerIllumination.x,
+ m->innerIllumination.y, m->innerIllumination.z,
+ (m->attributes.x == 1));
}
break;
}
@@ -665,7 +697,8 @@ void keyboard(unsigned char key, int x, int y)
case 'I':
{
gScene->getSceneInfo().advancedIllumination =
- static_cast((gScene->getSceneInfo().advancedIllumination + 1) % 3);
+ static_cast(
+ (gScene->getSceneInfo().advancedIllumination + 1) % 3);
break;
}
case 'i':
@@ -678,7 +711,8 @@ void keyboard(unsigned char key, int x, int y)
}
case 'k':
{
- gScene->getSceneInfo().gradientBackground = !gScene->getSceneInfo().gradientBackground;
+ gScene->getSceneInfo().gradientBackground =
+ !gScene->getSceneInfo().gradientBackground;
break;
}
case 'K':
@@ -716,11 +750,16 @@ void keyboard(unsigned char key, int x, int y)
case 'o':
{
gScene->getSceneInfo().cameraType =
- (gScene->getSceneInfo().cameraType == ctVolumeRendering) ? ctPerspective : ctVolumeRendering;
+ (gScene->getSceneInfo().cameraType == ctVolumeRendering)
+ ? ctPerspective
+ : ctVolumeRendering;
gScene->getSceneInfo().graphicsLevel =
- (gScene->getSceneInfo().cameraType == ctVolumeRendering) ? glNoShading : glReflectionsAndRefractions;
+ (gScene->getSceneInfo().cameraType == ctVolumeRendering)
+ ? glNoShading
+ : glReflectionsAndRefractions;
gScene->getSceneInfo().backgroundColor.w =
- (gScene->getSceneInfo().cameraType == ctVolumeRendering) ? 0.01f : 0.5f;
+ (gScene->getSceneInfo().cameraType == ctVolumeRendering) ? 0.01f
+ : 0.5f;
break;
}
case 'p':
@@ -741,26 +780,27 @@ void keyboard(unsigned char key, int x, int y)
if (key == 'q')
{
#ifdef WIN32
- std::string filename("E:/Cloud/Dropbox/Samsung Link/Photos/1K/CudaSolR_");
+ std::string filename(
+ "E:/Cloud/Dropbox/Samsung Link/Photos/1K/CudaSolR_");
#else
- std::string filename("~/Pictures/1K/CudaSolR_");
+ std::string filename("/tmp/CudaSolR_1k_");
#endif
filename += buffer;
if (kernel)
- kernel->generateScreenshot(filename, 2100, 2970, gScene->getSceneInfo().maxPathTracingIterations);
+ kernel->generateScreenshot(filename, 960, 960, 256);
}
else
{
#ifdef WIN32
- std::string filename("E:/Cloud/Dropbox/Samsung Link/Photos/4K/CudaSolR_");
+ std::string filename(
+ "E:/Cloud/Dropbox/Samsung Link/Photos/4K/CudaSolR_");
#else
- std::string filename("~/Pictures/4K/CudaSolR_");
+ std::string filename("/tmp/CudaSolR_4k_");
#endif
filename += buffer;
if (kernel)
- kernel->generateScreenshot(filename, 2 * 2970, 2 * 2100,
- gScene->getSceneInfo().maxPathTracingIterations);
+ kernel->generateScreenshot(filename, 3840, 3840, 256);
}
break;
}
@@ -780,7 +820,8 @@ void keyboard(unsigned char key, int x, int y)
}
case 'S':
{
- gScene->getSceneInfo().graphicsLevel = static_cast(gScene->getSceneInfo().graphicsLevel + 1);
+ gScene->getSceneInfo().graphicsLevel = static_cast(
+ gScene->getSceneInfo().graphicsLevel + 1);
if (gScene->getSceneInfo().graphicsLevel > glFull)
gScene->getSceneInfo().graphicsLevel = glNoShading;
break;
@@ -795,7 +836,8 @@ void keyboard(unsigned char key, int x, int y)
case 'T':
{
// Double sided triangles
- gScene->getSceneInfo().doubleSidedTriangles = !gScene->getSceneInfo().doubleSidedTriangles;
+ gScene->getSceneInfo().doubleSidedTriangles =
+ !gScene->getSceneInfo().doubleSidedTriangles;
break;
}
case 't':
@@ -804,7 +846,7 @@ void keyboard(unsigned char key, int x, int y)
delete gScene;
gScene = 0;
gAnimate = false;
- gSceneId = ((gSceneId + 1) % 16);
+ gSceneId = ((gSceneId + 1) % 17);
createScene();
break;
}
@@ -824,7 +866,9 @@ void keyboard(unsigned char key, int x, int y)
{
gScene->getSceneInfo().backgroundColor.w += 0.1f;
gScene->getSceneInfo().backgroundColor.w =
- (gScene->getSceneInfo().backgroundColor.w > 1.f) ? 0.f : gScene->getSceneInfo().backgroundColor.w;
+ (gScene->getSceneInfo().backgroundColor.w > 1.f)
+ ? 0.f
+ : gScene->getSceneInfo().backgroundColor.w;
break;
}
case 'x':
@@ -862,7 +906,8 @@ void keyboard(unsigned char key, int x, int y)
}
case '*':
{
- gScene->getSceneInfo().cameraType = static_cast((gScene->getSceneInfo().cameraType + 1) % 7);
+ gScene->getSceneInfo().cameraType = static_cast(
+ (gScene->getSceneInfo().cameraType + 1) % 7);
LOG_INFO(1, "Camera type: " << gScene->getSceneInfo().cameraType);
break;
}
@@ -927,7 +972,9 @@ void keyboard(unsigned char key, int x, int y)
{
gScene->getSceneInfo().shadowIntensity += 0.05f;
gScene->getSceneInfo().shadowIntensity =
- (gScene->getSceneInfo().shadowIntensity > 1.f) ? 0.f : gScene->getSceneInfo().shadowIntensity;
+ (gScene->getSceneInfo().shadowIntensity > 1.f)
+ ? 0.f
+ : gScene->getSceneInfo().shadowIntensity;
break;
}
case '+':
@@ -1138,9 +1185,12 @@ void motion(int x, int y)
// Changing camera angle
gViewPos.z -= 50 * (mouse_old_y - y);
gViewAngles.w -= 50 * (mouse_old_x - x);
- LOG_INFO(1, "ViewPos = " << gViewPos.x << "," << gViewPos.y << "," << gViewPos.z);
- LOG_INFO(1, "ViewDir = " << gViewDir.x << "," << gViewDir.y << "," << gViewDir.z);
- LOG_INFO(1, "Eye Separation = " << gScene->getSceneInfo().eyeSeparation);
+ LOG_INFO(1, "ViewPos = " << gViewPos.x << "," << gViewPos.y
+ << "," << gViewPos.z);
+ LOG_INFO(1, "ViewDir = " << gViewDir.x << "," << gViewDir.y
+ << "," << gViewDir.z);
+ LOG_INFO(1, "Eye Separation = "
+ << gScene->getSceneInfo().eyeSeparation);
break;
}
case ctGroundHeight:
@@ -1166,7 +1216,8 @@ void motion(int x, int y)
if (gAutoFocus)
{
// Autofocus
- int index = gKernel->getPrimitiveAt(gKernel->getSceneInfo().size.x / 2, gKernel->getSceneInfo().size.y / 2);
+ int index = gKernel->getPrimitiveAt(gKernel->getSceneInfo().size.x / 2,
+ gKernel->getSceneInfo().size.y / 2);
if (index != -1)
{
solr::CPUPrimitive *p = gKernel->getPrimitive(index);
@@ -1179,6 +1230,7 @@ void motion(int x, int y)
void Cleanup(int iExitCode)
{
+ RandomGenerator::getInstance().close();
#ifdef WIN32
gTickCount = GetTickCount() - gTickCount;
LOG_INFO(1, "Benchmark: " << gTickCount << " tick counts");
@@ -1220,41 +1272,49 @@ void createKinectScene(int platform, int device)
USHORT RealDepth = (s & 0xfff8) >> 3;
// Masque pour retrouver si un player a �t� detect�
USHORT Player = s & 7;
- // Transforme les informations de profondeur sur 13-Bit en une intensit�
- // cod� sur 8 Bits
+ // Transforme les informations de profondeur sur 13-Bit en une
+ // intensit� cod� sur 8 Bits
// afin d'afficher une couleur en fonction de la profondeur
BYTE l = 255 - (BYTE)(256 * RealDepth / 0x0fff);
int p = kernel.addPrimitive(ptSphere);
- kernel.setPrimitive(p, 5 + p / gKinectNbSpherePerBox, (x - 160) * 100.f, (y - 120) * 100.f, 0.f,
- gKinectStep * 10.f, 0.f, 0.f, 20 + x % 20, 1, 1);
+ kernel.setPrimitive(p, 5 + p / gKinectNbSpherePerBox,
+ (x - 160) * 100.f, (y - 120) * 100.f, 0.f,
+ gKinectStep * 10.f, 0.f, 0.f, 20 + x % 20,
+ 1, 1);
}
}
}
// Sol
int s0 = kernel.addPrimitive(ptXZPlane);
- kernel.setPrimitive(s0, 0, 0.f, -5000.f, 0.f, 10000.f, 0.f, 10000.f, 100, 1, 1);
+ kernel.setPrimitive(s0, 0, 0.f, -5000.f, 0.f, 10000.f, 0.f, 10000.f, 100, 1,
+ 1);
// Wall
int m_nbPrimitives = kernel.addPrimitive(ptXYPlane);
- kernel.setPrimitive(m_nbPrimitives, 0, 0.f, 0.f, 5000.f, 5000.f, 5000.f, 0.f, 110, 1, 1);
+ kernel.setPrimitive(m_nbPrimitives, 0, 0.f, 0.f, 5000.f, 5000.f, 5000.f,
+ 0.f, 110, 1, 1);
m_nbPrimitives = kernel.addPrimitive(ptYZPlane);
- kernel.setPrimitive(m_nbPrimitives, 1, -5000.f, 0.f, 0.f, 0.f, 5000.f, 5000.f, 107, 1, 1);
+ kernel.setPrimitive(m_nbPrimitives, 1, -5000.f, 0.f, 0.f, 0.f, 5000.f,
+ 5000.f, 107, 1, 1);
m_nbPrimitives = kernel.addPrimitive(ptYZPlane);
- kernel.setPrimitive(m_nbPrimitives, 2, 5000.f, 0.f, 0.f, 0.f, 5000.f, 5000.f, 108, 1, 1);
+ kernel.setPrimitive(m_nbPrimitives, 2, 5000.f, 0.f, 0.f, 0.f, 5000.f,
+ 5000.f, 108, 1, 1);
m_nbPrimitives = kernel.addPrimitive(ptXZPlane);
- kernel.setPrimitive(m_nbPrimitives, 3, 0.f, 5000.f, 0.f, 5000.f, 0.f, 5000.f, 110, 1, 1);
+ kernel.setPrimitive(m_nbPrimitives, 3, 0.f, 5000.f, 0.f, 5000.f, 0.f,
+ 5000.f, 110, 1, 1);
// Camera
m_nbPrimitives = kernel.addPrimitive(ptCamera);
- kernel.setPrimitive(m_nbPrimitives, 0, -2500.f, -4000.f, -5000.f, 1500.f, 1500.f, 0.f, DEFAULT_LIGHT_MATERIAL, 1,
- 1);
+ kernel.setPrimitive(m_nbPrimitives, 0, -2500.f, -4000.f, -5000.f, 1500.f,
+ 1500.f, 0.f, DEFAULT_LIGHT_MATERIAL, 1, 1);
// Lights
gLampIndex = kernel.addPrimitive(ptSphere);
- kernel.setPrimitive(gLampIndex, 4, -5000.f, 2000.f, -20000.f, 500, 0, 50, 128, 1, 1);
+ kernel.setPrimitive(gLampIndex, 4, -5000.f, 2000.f, -20000.f, 500, 0, 50,
+ 128, 1, 1);
gNbBoxes = kernel.compactBoxes();
}
@@ -1262,6 +1322,7 @@ void createKinectScene(int platform, int device)
void createScene()
{
+ RandomGenerator::getInstance().pause();
gAnimate = false;
gHint = "Camera";
switch (gSceneId)
@@ -1276,7 +1337,7 @@ void createScene()
gScene = new MoleculeScene("Molecules");
break;
case 4:
- gScene = new FractalScene("Fractals");
+ gScene = new HypercubeScene("Hypercubes");
break;
case 5:
gScene = new CylinderScene("Cylinders");
@@ -1312,12 +1373,16 @@ void createScene()
case 15:
gScene = new SwcScene("Neuroscience");
break;
+ case 16:
+ gScene = new FractalScene("Fractals");
+ break;
default:
#ifdef _USE_KINECT
gScene = new KinectFaceTrackingScene("Kinect Face Tracking");
break;
#else
- gScene = new PerpetualMotionScene("Perpetual Motion");
+ gScene = new TesseractScene("Tesseract");
+ // gScene = new PerpetualMotionScene("Perpetual Motion");
break;
#endif
}
@@ -1326,6 +1391,7 @@ void createScene()
gScene->setCurrentModel(m_counter);
gScene->initialize(gKernel, gWindowWidth, gWindowHeight);
gKernel->setCamera(gViewPos, gViewDir, gViewAngles);
+ RandomGenerator::getInstance().resume();
}
int main(int argc, char *argv[])
@@ -1346,6 +1412,9 @@ int main(int argc, char *argv[])
createScene();
LOG_INFO(1, "Sol-R is happily running... (^_^)y");
+ for (const auto &menuItem : menuItems)
+ LOG_INFO(3, menuItem.description);
+
glutMainLoop();
Cleanup(EXIT_SUCCESS);
diff --git a/debug_tsdviewer.sh b/debug_tsdviewer.sh
new file mode 100755
index 0000000..6466d2e
--- /dev/null
+++ b/debug_tsdviewer.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Debug script for tsdViewer with Sol-R ANARI device
+
+export LD_LIBRARY_PATH=/home/cfavreau/code/favreau/VisRTX/build/Debug:/home/cfavreau/code/favreau/Sol-R/build/Debug/devices/solr:$LD_LIBRARY_PATH
+export TSD_ANARI_LIBRARIES=solr
+export ANARI_LIBRARY_solr=/home/cfavreau/code/favreau/Sol-R/build/Debug/devices/solr/libanari_library_solr.so
+
+echo "Environment variables set:"
+echo " LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+echo " TSD_ANARI_LIBRARIES=$TSD_ANARI_LIBRARIES"
+echo " ANARI_LIBRARY_solr=$ANARI_LIBRARY_solr"
+echo ""
+echo "Starting GDB..."
+
+gdb -ex "set environment LD_LIBRARY_PATH $LD_LIBRARY_PATH" \
+ -ex "set environment TSD_ANARI_LIBRARIES solr" \
+ -ex "set environment ANARI_LIBRARY_solr $ANARI_LIBRARY_solr" \
+ /home/cfavreau/code/favreau/VisRTX/build/Debug/tsdViewer
+
diff --git a/devices/CMakeLists.txt b/devices/CMakeLists.txt
new file mode 100644
index 0000000..f0e5904
--- /dev/null
+++ b/devices/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Copyright (c) 2011-2022, Cyrille Favreau
+#
+# 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 for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+option(SOLR_BUILD_ANARI_DEVICE "Build Sol-R ANARI device" ON)
+if (SOLR_BUILD_ANARI_DEVICE)
+ add_subdirectory(solr)
+endif()
\ No newline at end of file
diff --git a/devices/README.md b/devices/README.md
new file mode 100644
index 0000000..ed5acf2
--- /dev/null
+++ b/devices/README.md
@@ -0,0 +1,61 @@
+# Sol-R ANARI Device
+
+This directory contains the ANARI device implementation for Sol-R, allowing Sol-R to be used as an ANARI-compliant ray tracing library.
+
+## Building with ANARI Support
+
+To build Sol-R with ANARI device support:
+
+1. Install the ANARI SDK:
+ ```bash
+ git clone https://github.com/KhronosGroup/ANARI-SDK.git
+ cd ANARI-SDK
+ mkdir build && cd build
+ cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/anari-install
+ make -j && make install
+ ```
+
+2. Configure Sol-R with ANARI enabled:
+ ```bash
+ cd Sol-R
+ mkdir build && cd build
+ cmake .. -DSOLR_BUILD_ANARI_DEVICE=ON -Danari_DIR=/path/to/anari-install/lib/cmake/anari
+ make -j
+ ```
+
+## Using the Sol-R ANARI Device
+
+The Sol-R ANARI device can be used with any ANARI-compatible application:
+
+```cpp
+#include
+
+// Load the Sol-R device library
+ANARILibrary lib = anariLoadLibrary("solr", nullptr, nullptr);
+ANARIDevice device = anariNewDevice(lib, "default");
+
+// Use standard ANARI calls
+ANARICamera camera = anariNewCamera(device, "perspective");
+ANARIRenderer renderer = anariNewRenderer(device, "pathtracer");
+// ... etc
+```
+
+## Supported Features
+
+The Sol-R ANARI device currently supports:
+
+- **Cameras**: perspective, orthographic
+- **Geometries**: triangle, sphere, cylinder, cone
+- **Materials**: matte, physically-based
+- **Lights**: directional, point, spot
+- **Renderers**: raycast, pathtracer
+
+## Device Parameters
+
+- `solr.engine`: Rendering engine to use ("cuda", "opencl", "cpu")
+- `solr.samples`: Number of samples per pixel (1-1024)
+- `solr.maxDepth`: Maximum ray depth (1-32)
+
+## Status
+
+This is an initial implementation providing basic ANARI device functionality. The implementation currently provides placeholder objects and will need to be extended to fully integrate with Sol-R's existing ray tracing pipeline.
\ No newline at end of file
diff --git a/devices/solr/CMakeLists.txt b/devices/solr/CMakeLists.txt
new file mode 100644
index 0000000..4fa90e8
--- /dev/null
+++ b/devices/solr/CMakeLists.txt
@@ -0,0 +1,122 @@
+# Copyright (c) 2011-2022, Cyrille Favreau
+#
+# 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 for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+include(GenerateExportHeader)
+include(GNUInstallDirs)
+
+# Set policy for file(GENERATE) behavior
+cmake_policy(SET CMP0070 NEW)
+
+## Establish project ##
+
+project(anari_library_solr VERSION ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH} LANGUAGES CXX)
+
+## Compilation setup ##
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
+
+## Find dependencies ##
+
+# We already have the solr library target available
+
+## Build library target ##
+
+set(SOURCES
+ Object.cpp
+ SolRDevice.cpp
+ SolRLibrary.cpp
+ Extensions.cpp
+ SimpleQueries.cpp
+)
+
+add_library(${PROJECT_NAME} SHARED ${SOURCES})
+
+# Ensure C++17 is properly enabled
+target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
+
+generate_export_header(${PROJECT_NAME}
+ EXPORT_MACRO_NAME "SOLR_DEVICE_INTERFACE"
+)
+
+target_include_directories(${PROJECT_NAME}
+PUBLIC
+ $
+ $
+PRIVATE
+ ${PROJECT_SOURCE_DIR}/solr
+ ${PROJECT_SOURCE_DIR}/generated
+)
+
+target_link_libraries(${PROJECT_NAME}
+PUBLIC
+ anari::anari
+PRIVATE
+ anari::helium
+ # solr # TODO: Re-enable after fixing Sol-R CUDA compilation issues
+)
+
+target_compile_definitions(${PROJECT_NAME}
+PRIVATE
+ SOLR_VERSION_MAJOR=${SolR_VERSION_MAJOR}
+ SOLR_VERSION_MINOR=${SolR_VERSION_MINOR}
+ SOLR_VERSION_PATCH=${SolR_VERSION_PATCH}
+ solr_EXPORTS
+)
+
+# Force C++17 to override Sol-R's C++11 setting
+target_compile_options(${PROJECT_NAME} PRIVATE -std=c++17)
+
+## Query code generation ##
+# Temporarily disable automatic generation due to C++ compatibility issues
+# file(GLOB DEVICE_JSONS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.json")
+# foreach(file ${DEVICE_JSONS})
+# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${file} ${CMAKE_CURRENT_BINARY_DIR}/${file} COPYONLY)
+# endforeach()
+
+# anari_generate_queries(
+# DEVICE_TARGET ${PROJECT_NAME}
+# CPP_NAMESPACE solr
+# JSON_ROOT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}
+# JSON_DEFINITIONS_FILE ${CMAKE_CURRENT_BINARY_DIR}/solr_device.json
+# JSON_EXTENSION_FILES ${DEVICE_JSONS}
+# )
+
+## Install library + headers ##
+
+install(TARGETS ${PROJECT_NAME}
+ EXPORT SolR_Exports
+ LIBRARY DESTINATION lib
+ # on Windows put the dlls into bin
+ RUNTIME DESTINATION bin
+ # ... and the import lib into the devel package
+ ARCHIVE DESTINATION lib
+)
+
+install(
+FILES
+ ${PROJECT_BINARY_DIR}/${PROJECT_NAME}_export.h
+DESTINATION
+ include/anari/ext/solr
+)
+
+install(EXPORT SolR_Exports
+ DESTINATION lib/cmake/SolR
+ NAMESPACE SolR::
+)
\ No newline at end of file
diff --git a/devices/solr/Extensions.cpp b/devices/solr/Extensions.cpp
new file mode 100644
index 0000000..67efffa
--- /dev/null
+++ b/devices/solr/Extensions.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+namespace solr
+{
+
+const char **query_extensions()
+{
+ static const char *extensions[] = {"KHR_CAMERA_ORTHOGRAPHIC",
+ "KHR_CAMERA_PERSPECTIVE",
+ "KHR_DEVICE_SYNCHRONIZATION",
+ "KHR_FRAME_ACCUMULATION",
+ "KHR_FRAME_COMPLETION_CALLBACK",
+ "KHR_GEOMETRY_TRIANGLE",
+ "KHR_GEOMETRY_SPHERE",
+ "KHR_GEOMETRY_CYLINDER",
+ "KHR_GEOMETRY_CONE",
+ "KHR_INSTANCE_TRANSFORM",
+ "KHR_LIGHT_DIRECTIONAL",
+ "KHR_LIGHT_POINT",
+ "KHR_LIGHT_SPOT",
+ "KHR_MATERIAL_MATTE",
+ "KHR_MATERIAL_PHYSICALLY_BASED",
+ "KHR_RENDERER_AMBIENT_LIGHT",
+ "KHR_RENDERER_BACKGROUND_COLOR",
+ "KHR_SAMPLER_IMAGE2D",
+ "KHR_SAMPLER_PRIMITIVE",
+ nullptr};
+ return extensions;
+}
+
+} // namespace solr
\ No newline at end of file
diff --git a/devices/solr/Object.cpp b/devices/solr/Object.cpp
new file mode 100644
index 0000000..40a2d83
--- /dev/null
+++ b/devices/solr/Object.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "Object.h"
+#include "helium/BaseDevice.h"
+
+namespace solr
+{
+
+Object::Object(ANARIDataType type, ANARIDevice device)
+ : helium::BaseObject(type, nullptr) // Pass nullptr when building ANARI
+ // device standalone
+ , m_device(device)
+{
+}
+
+} // namespace solr
\ No newline at end of file
diff --git a/devices/solr/Object.h b/devices/solr/Object.h
new file mode 100644
index 0000000..3e22e97
--- /dev/null
+++ b/devices/solr/Object.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+// helium
+#include "helium/BaseObject.h"
+
+namespace solr
+{
+
+struct Object : public helium::BaseObject
+{
+ Object(ANARIDataType type, ANARIDevice device);
+ virtual ~Object() = default;
+
+ virtual void commit() {}
+
+ ANARIDevice deviceHandle() const;
+
+private:
+ ANARIDevice m_device{nullptr};
+};
+
+// Inlined definitions ////////////////////////////////////////////////////////
+
+inline ANARIDevice Object::deviceHandle() const
+{
+ return m_device;
+}
+
+} // namespace solr
\ No newline at end of file
diff --git a/devices/solr/SimpleQueries.cpp b/devices/solr/SimpleQueries.cpp
new file mode 100644
index 0000000..d825e13
--- /dev/null
+++ b/devices/solr/SimpleQueries.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "anari/anari.h"
+
+namespace solr
+{
+
+const char **query_object_types(ANARIDataType type)
+{
+ static const char *cameras[] = {"perspective", "orthographic", nullptr};
+ static const char *geometries[] = {"triangle", "sphere", nullptr};
+ static const char *lights[] = {"directional", "point", nullptr};
+ static const char *materials[] = {"matte", nullptr};
+ static const char *renderers[] = {"raycast", "pathtracer", nullptr};
+ static const char *empty[] = {nullptr};
+
+ switch (type)
+ {
+ case ANARI_CAMERA:
+ return cameras;
+ case ANARI_GEOMETRY:
+ return geometries;
+ case ANARI_LIGHT:
+ return lights;
+ case ANARI_MATERIAL:
+ return materials;
+ case ANARI_RENDERER:
+ return renderers;
+ default:
+ return empty;
+ }
+}
+
+const void *query_object_info(ANARIDataType type, const char *name,
+ ANARIDataType infoType)
+{
+ // Simple implementation - just return nullptr for now
+ return nullptr;
+}
+
+const void *query_param_info(ANARIDataType type, const char *name,
+ ANARIDataType paramType, const char *infoType)
+{
+ // Simple implementation - just return nullptr for now
+ return nullptr;
+}
+
+} // namespace solr
\ No newline at end of file
diff --git a/devices/solr/SolRDevice.cpp b/devices/solr/SolRDevice.cpp
new file mode 100644
index 0000000..e233481
--- /dev/null
+++ b/devices/solr/SolRDevice.cpp
@@ -0,0 +1,451 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "SolRDevice.h"
+// std
+#include
+
+// Disable verbose debug messages to avoid initialization issues
+#define SOLR_VERBOSE_DEBUG 0
+
+namespace solr
+{
+
+const char **query_extensions();
+
+///////////////////////////////////////////////////////////////////////////////
+// Generated function declarations ////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+const char **query_object_types(ANARIDataType type);
+const void *query_object_info(ANARIDataType type, const char *name,
+ ANARIDataType infoType);
+const void *query_param_info(ANARIDataType type, const char *name,
+ ANARIDataType paramType, const char *infoType);
+
+///////////////////////////////////////////////////////////////////////////////
+// SolRDevice definitions /////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+// Data Arrays ////////////////////////////////////////////////////////////////
+
+void *SolRDevice::mapArray(ANARIArray a)
+{
+#if SOLR_VERBOSE_DEBUG
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::mapArray called");
+
+#endif
+#endif
+ // For now, return a placeholder - implement based on Sol-R's memory
+ // management
+ return nullptr;
+}
+
+void SolRDevice::unmapArray(ANARIArray a)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::unmapArray called");
+
+#endif
+ // Implement based on Sol-R's memory management
+}
+
+ANARIArray1D SolRDevice::newArray1D(const void *appMemory,
+ ANARIMemoryDeleter deleter,
+ const void *deleterPtr, ANARIDataType type,
+ uint64_t numItems1)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::newArray1D called");
+
+#endif
+ // Return a placeholder array object - implement proper array handling
+ return (ANARIArray1D)this;
+}
+
+ANARIArray2D SolRDevice::newArray2D(const void *appMemory,
+ ANARIMemoryDeleter deleter,
+ const void *deleterPtr, ANARIDataType type,
+ uint64_t numItems1, uint64_t numItems2)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::newArray2D called");
+
+#endif
+ return (ANARIArray2D)this;
+}
+
+ANARIArray3D SolRDevice::newArray3D(const void *appMemory,
+ ANARIMemoryDeleter deleter,
+ const void *deleterPtr, ANARIDataType type,
+ uint64_t numItems1, uint64_t numItems2,
+ uint64_t numItems3)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::newArray3D called");
+
+#endif
+ return (ANARIArray3D)this;
+}
+
+// Renderable Objects /////////////////////////////////////////////////////////
+
+ANARICamera SolRDevice::newCamera(const char *type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newCamera called with type: %s",
+ type ? type : "NULL");
+
+#endif
+ return (ANARICamera)this;
+}
+
+ANARIFrame SolRDevice::newFrame()
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::newFrame called");
+
+#endif
+ return (ANARIFrame)this;
+}
+
+ANARIGeometry SolRDevice::newGeometry(const char *type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newGeometry called with type: %s",
+ type ? type : "NULL");
+
+#endif
+ return (ANARIGeometry)this;
+}
+
+ANARIGroup SolRDevice::newGroup()
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::newGroup called");
+
+#endif
+ return (ANARIGroup)this;
+}
+
+ANARIInstance SolRDevice::newInstance(const char *type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newInstance called with type: %s",
+ type ? type : "NULL");
+
+#endif
+ return (ANARIInstance)this;
+}
+
+ANARILight SolRDevice::newLight(const char *type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newLight called with type: %s",
+ type ? type : "NULL");
+
+#endif
+ return (ANARILight)this;
+}
+
+ANARIMaterial SolRDevice::newMaterial(const char *material_type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newMaterial called with type: %s",
+ material_type ? material_type : "NULL");
+
+#endif
+ return (ANARIMaterial)this;
+}
+
+ANARIRenderer SolRDevice::newRenderer(const char *type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newRenderer called with type: %s",
+ type ? type : "NULL");
+
+#endif
+ return (ANARIRenderer)this;
+}
+
+ANARISampler SolRDevice::newSampler(const char *type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newSampler called with type: %s",
+ type ? type : "NULL");
+
+#endif
+ return (ANARISampler)this;
+}
+
+ANARISpatialField SolRDevice::newSpatialField(const char *type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newSpatialField called with type: %s",
+ type ? type : "NULL");
+
+#endif
+ return (ANARISpatialField)this;
+}
+
+ANARISurface SolRDevice::newSurface()
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::newSurface called");
+
+#endif
+ return (ANARISurface)this;
+}
+
+ANARIVolume SolRDevice::newVolume(const char *type)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG,
+ "SolRDevice::newVolume called with type: %s",
+ type ? type : "NULL");
+
+#endif
+ return (ANARIVolume)this;
+}
+
+ANARIWorld SolRDevice::newWorld()
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::newWorld called");
+
+#endif
+ return (ANARIWorld)this;
+}
+
+// Object + Parameter Introspection ///////////////////////////////////////////
+
+void SolRDevice::commitParameters(ANARIObject object)
+{
+ if (this == (SolRDevice *)object)
+ {
+ deviceCommit();
+ }
+}
+
+void SolRDevice::release(ANARIObject _obj)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::release called");
+
+#endif
+ // For now, don't actually release anything since we're using placeholders
+}
+
+int SolRDevice::getProperty(ANARIObject object, const char *name,
+ ANARIDataType type, void *mem, uint64_t size,
+ uint32_t mask)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::getProperty called");
+
+#endif
+ if (object == (ANARIObject)this)
+ {
+ return deviceGetProperty(name, type, mem, size, mask);
+ }
+ return 0;
+}
+
+// Frame Operations ////////////////////////////////////////////////////////////
+
+void SolRDevice::renderFrame(ANARIFrame frame)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::renderFrame called");
+
+#endif
+ // Implement actual rendering using Sol-R
+ // SolRStub disabled when building ANARI device standalone
+ // This would integrate with Sol-R's rendering pipeline
+ // For now, just increment frame counter
+ m_frameCounter++;
+}
+
+int SolRDevice::frameReady(ANARIFrame frame, ANARIWaitMask m)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::frameReady called");
+
+#endif
+ // For now, always return ready
+ return 1;
+}
+
+void SolRDevice::discardFrame(ANARIFrame frame)
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice::discardFrame called");
+
+#endif
+ // Implement frame discard logic
+}
+
+// Other SolRDevice definitions ///////////////////////////////////////////////
+
+SolRDevice::SolRDevice(ANARIStatusCallback defaultCallback, const void *userPtr)
+ : helium::BaseDevice(defaultCallback, userPtr)
+{
+ // SolRStub disabled when building ANARI device standalone
+ // m_solrStub = std::make_unique();
+ // Note: deviceCommit() is called automatically by helium framework
+}
+
+SolRDevice::SolRDevice(ANARILibrary library)
+ : helium::BaseDevice(library)
+{
+ // SolRStub disabled when building ANARI device standalone
+ // m_solrStub = std::make_unique();
+ // Note: deviceCommit() is called automatically by helium framework
+}
+
+SolRDevice::~SolRDevice()
+{
+#if SOLR_VERBOSE_DEBUG
+
+ reportMessage(ANARI_SEVERITY_DEBUG, "SolRDevice destroyed");
+
+#endif
+}
+
+void SolRDevice::initDevice()
+{
+ if (m_initStatus != DeviceInitStatus::UNINITIALIZED)
+ return;
+
+ try
+ {
+ // SolRStub disabled when building ANARI device standalone
+ m_initStatus = DeviceInitStatus::SUCCESS;
+ }
+ catch (const std::exception &e)
+ {
+ m_initStatus = DeviceInitStatus::FAILURE;
+ }
+}
+
+void SolRDevice::deviceCommit()
+{
+ initDevice();
+
+ // Note: Initialization status checking moved to after device is fully
+ // initialized
+}
+
+int SolRDevice::deviceGetProperty(const char *name, ANARIDataType type,
+ void *mem, uint64_t size, uint32_t mask)
+{
+ if (!name || !mem)
+ return 0;
+
+ std::string prop = name;
+ if (prop == "feature" && type == ANARI_STRING_LIST)
+ {
+ *(const char ***)mem = query_extensions();
+ return 1;
+ }
+ else if (prop == "solr" && type == ANARI_BOOL)
+ {
+ *(bool *)mem = true;
+ return 1;
+ }
+ else if (prop == "version" && type == ANARI_STRING)
+ {
+ *(const char **)mem = "0.1.0";
+ return 1;
+ }
+ else if (type == ANARI_STRING_LIST)
+ {
+ // Return empty list for unknown string list properties
+ static const char *empty_list[] = {nullptr};
+ *(const char ***)mem = empty_list;
+ return 1;
+ }
+
+ return 0;
+}
+
+void SolRDevice::flushCommitBuffer()
+{
+ // This method can be used to batch commits if needed
+}
+
+// SolRStub *SolRDevice::getSolRStub() const
+// {
+// return m_solrStub.get();
+// }
+
+const char **SolRDevice::getObjectSubtypes(ANARIDataType objectType)
+{
+ return query_object_types(objectType);
+}
+
+const void *SolRDevice::getObjectInfo(ANARIDataType objectType,
+ const char *objectSubtype,
+ const char *infoName,
+ ANARIDataType infoType)
+{
+ return query_object_info(objectType, objectSubtype, infoType);
+}
+
+const void *SolRDevice::getParameterInfo(ANARIDataType objectType,
+ const char *objectSubtype,
+ const char *parameterName,
+ ANARIDataType parameterType,
+ const char *infoName,
+ ANARIDataType infoType)
+{
+ return query_param_info(objectType, objectSubtype, parameterType, infoName);
+}
+
+} // namespace solr
\ No newline at end of file
diff --git a/devices/solr/SolRDevice.h b/devices/solr/SolRDevice.h
new file mode 100644
index 0000000..6b48154
--- /dev/null
+++ b/devices/solr/SolRDevice.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+// helium
+#include "helium/BaseDevice.h"
+// solr
+// #include "SolRStub.h" // Disabled when building ANARI device standalone
+// std
+#include
+#include
+
+namespace solr
+{
+
+enum class DeviceInitStatus
+{
+ UNINITIALIZED,
+ SUCCESS,
+ FAILURE
+};
+
+struct SolRDevice : public helium::BaseDevice
+{
+ /////////////////////////////////////////////////////////////////////////////
+ // Main interface to accepting API calls
+ /////////////////////////////////////////////////////////////////////////////
+
+ void *mapArray(ANARIArray) override;
+ void unmapArray(ANARIArray) override;
+
+ ANARIArray1D newArray1D(const void *appMemory, ANARIMemoryDeleter deleter,
+ const void *deleterPtr, ANARIDataType,
+ uint64_t numItems1) override;
+
+ ANARIArray2D newArray2D(const void *appMemory, ANARIMemoryDeleter deleter,
+ const void *deleterPtr, ANARIDataType,
+ uint64_t numItems1, uint64_t numItems2) override;
+
+ ANARIArray3D newArray3D(const void *appMemory, ANARIMemoryDeleter deleter,
+ const void *deleterPtr, ANARIDataType,
+ uint64_t numItems1, uint64_t numItems2,
+ uint64_t numItems3) override;
+
+ ANARICamera newCamera(const char *type) override;
+ ANARIFrame newFrame() override;
+ ANARIGeometry newGeometry(const char *type) override;
+ ANARIGroup newGroup() override;
+ ANARIInstance newInstance(const char *type) override;
+ ANARILight newLight(const char *type) override;
+ ANARIMaterial newMaterial(const char *material_type) override;
+ ANARIRenderer newRenderer(const char *type) override;
+ ANARISampler newSampler(const char *type) override;
+ ANARISpatialField newSpatialField(const char *type) override;
+ ANARISurface newSurface() override;
+ ANARIVolume newVolume(const char *type) override;
+ ANARIWorld newWorld() override;
+
+ // Commit and release
+ void commitParameters(ANARIObject object) override;
+ void release(ANARIObject _obj) override;
+
+ // Object + Parameter Introspection
+ int getProperty(ANARIObject object, const char *name, ANARIDataType type,
+ void *mem, uint64_t size, uint32_t mask) override;
+
+ // Frame operations
+ void renderFrame(ANARIFrame) override;
+ int frameReady(ANARIFrame, ANARIWaitMask) override;
+ void discardFrame(ANARIFrame) override;
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Helper/other functions and data members
+ /////////////////////////////////////////////////////////////////////////////
+
+ SolRDevice(ANARIStatusCallback defaultCallback, const void *userPtr);
+ SolRDevice(ANARILibrary library);
+
+ ~SolRDevice() override;
+
+ void initDevice();
+
+ int deviceGetProperty(const char *name, ANARIDataType type, void *mem,
+ uint64_t size, uint32_t mask) override;
+
+ void deviceCommit();
+
+ void flushCommitBuffer();
+
+ // ANARI interface requirements
+ const char **getObjectSubtypes(ANARIDataType objectType) override;
+ const void *getObjectInfo(ANARIDataType objectType,
+ const char *objectSubtype, const char *infoName,
+ ANARIDataType infoType) override;
+ const void *getParameterInfo(ANARIDataType objectType,
+ const char *objectSubtype,
+ const char *parameterName,
+ ANARIDataType parameterType,
+ const char *infoName,
+ ANARIDataType infoType) override;
+
+ // SolRStub *getSolRStub() const; // Disabled when building ANARI device
+ // standalone
+
+private:
+ DeviceInitStatus m_initStatus{DeviceInitStatus::UNINITIALIZED};
+ // std::unique_ptr m_solrStub; // Disabled when building ANARI
+ // device standalone
+
+ // Device state
+ std::atomic m_frameCounter{0};
+};
+
+} // namespace solr
\ No newline at end of file
diff --git a/devices/solr/SolRLibrary.cpp b/devices/solr/SolRLibrary.cpp
new file mode 100644
index 0000000..71b019c
--- /dev/null
+++ b/devices/solr/SolRLibrary.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
+ *
+ * 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 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include "SolRDevice.h"
+#include "anari/backend/LibraryImpl.h"
+#include "anari_library_solr_export.h"
+
+namespace solr
+{
+
+const char **query_extensions();
+
+struct SolRLibrary : public anari::LibraryImpl
+{
+ SolRLibrary(void *lib, ANARIStatusCallback defaultStatusCB,
+ const void *statusCBPtr);
+
+ ANARIDevice newDevice(const char *subtype) override;
+ const char **getDeviceExtensions(const char *deviceType) override;
+};
+
+// Definitions ////////////////////////////////////////////////////////////////
+
+SolRLibrary::SolRLibrary(void *lib, ANARIStatusCallback defaultStatusCB,
+ const void *statusCBPtr)
+ : anari::LibraryImpl(lib, defaultStatusCB, statusCBPtr)
+{
+}
+
+ANARIDevice SolRLibrary::newDevice(const char * /*subtype*/)
+{
+ return (ANARIDevice) new SolRDevice(this_library());
+}
+
+const char **SolRLibrary::getDeviceExtensions(const char * /*deviceType*/)
+{
+ return query_extensions();
+}
+
+} // namespace solr
+
+// Define library entrypoint //////////////////////////////////////////////////
+
+extern "C" SOLR_DEVICE_INTERFACE ANARI_DEFINE_LIBRARY_ENTRYPOINT(solr, handle,
+ scb, scbPtr)
+{
+ return (ANARILibrary) new solr::SolRLibrary(handle, scb, scbPtr);
+}
+
+extern "C" SOLR_DEVICE_INTERFACE ANARIDevice
+ makeSolRDevice(ANARIStatusCallback defaultCallback, const void *userPtr)
+{
+ return (ANARIDevice) new solr::SolRDevice(defaultCallback, userPtr);
+}
\ No newline at end of file
diff --git a/devices/solr/solr_device.json b/devices/solr/solr_device.json
new file mode 100644
index 0000000..6c25785
--- /dev/null
+++ b/devices/solr/solr_device.json
@@ -0,0 +1,380 @@
+{
+ "info": {
+ "name": "SOLR_DEVICE",
+ "type": "device",
+ "dependencies": [
+ "anari_core_1_0",
+ "anari_core_objects_base_1_0",
+ "khr_camera_orthographic",
+ "khr_camera_perspective",
+ "khr_device_synchronization",
+ "khr_frame_accumulation",
+ "khr_frame_completion_callback",
+ "khr_geometry_triangle",
+ "khr_geometry_sphere",
+ "khr_geometry_cylinder",
+ "khr_geometry_cone",
+ "khr_instance_transform",
+ "khr_light_directional",
+ "khr_light_point",
+ "khr_light_spot",
+ "khr_material_matte",
+ "khr_material_physically_based",
+ "khr_renderer_ambient_light",
+ "khr_renderer_background_color",
+ "khr_sampler_image2d",
+ "khr_sampler_primitive"
+ ]
+ },
+ "parameters": [
+ {
+ "name": "solr.engine",
+ "types": [
+ "ANARI_STRING"
+ ],
+ "tags": [],
+ "default": "cuda",
+ "description": "Specify the Sol-R rendering engine to use"
+ },
+ {
+ "name": "solr.samples",
+ "types": [
+ "ANARI_INT32"
+ ],
+ "tags": [],
+ "default": 1,
+ "minimum": 1,
+ "maximum": 1024,
+ "description": "Number of samples per pixel"
+ },
+ {
+ "name": "solr.maxDepth",
+ "types": [
+ "ANARI_INT32"
+ ],
+ "tags": [],
+ "default": 5,
+ "minimum": 1,
+ "maximum": 32,
+ "description": "Maximum ray depth"
+ }
+ ],
+ "objects": [
+ {
+ "type": "ANARI_CAMERA",
+ "name": "perspective",
+ "parameters": [
+ {
+ "name": "aspect",
+ "types": [
+ "ANARI_FLOAT32"
+ ],
+ "tags": [],
+ "default": 1.0
+ },
+ {
+ "name": "fovy",
+ "types": [
+ "ANARI_FLOAT32"
+ ],
+ "tags": [],
+ "default": 1.0472
+ },
+ {
+ "name": "position",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 0.0,
+ 0.0
+ ]
+ },
+ {
+ "name": "direction",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 0.0,
+ -1.0
+ ]
+ },
+ {
+ "name": "up",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 1.0,
+ 0.0
+ ]
+ }
+ ]
+ },
+ {
+ "type": "ANARI_CAMERA",
+ "name": "orthographic",
+ "parameters": [
+ {
+ "name": "aspect",
+ "types": [
+ "ANARI_FLOAT32"
+ ],
+ "tags": [],
+ "default": 1.0
+ },
+ {
+ "name": "height",
+ "types": [
+ "ANARI_FLOAT32"
+ ],
+ "tags": [],
+ "default": 1.0
+ },
+ {
+ "name": "position",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 0.0,
+ 0.0
+ ]
+ },
+ {
+ "name": "direction",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 0.0,
+ -1.0
+ ]
+ },
+ {
+ "name": "up",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 1.0,
+ 0.0
+ ]
+ }
+ ]
+ },
+ {
+ "type": "ANARI_GEOMETRY",
+ "name": "triangle",
+ "parameters": [
+ {
+ "name": "vertex.position",
+ "types": [
+ "ANARI_ARRAY1D"
+ ],
+ "elementType": "ANARI_FLOAT32_VEC3",
+ "tags": []
+ },
+ {
+ "name": "vertex.normal",
+ "types": [
+ "ANARI_ARRAY1D"
+ ],
+ "elementType": "ANARI_FLOAT32_VEC3",
+ "tags": []
+ },
+ {
+ "name": "vertex.color",
+ "types": [
+ "ANARI_ARRAY1D"
+ ],
+ "elementType": "ANARI_FLOAT32_VEC4",
+ "tags": []
+ },
+ {
+ "name": "primitive.index",
+ "types": [
+ "ANARI_ARRAY1D"
+ ],
+ "elementType": "ANARI_UINT32_VEC3",
+ "tags": []
+ }
+ ]
+ },
+ {
+ "type": "ANARI_GEOMETRY",
+ "name": "sphere",
+ "parameters": [
+ {
+ "name": "vertex.position",
+ "types": [
+ "ANARI_ARRAY1D"
+ ],
+ "elementType": "ANARI_FLOAT32_VEC3",
+ "tags": []
+ },
+ {
+ "name": "vertex.radius",
+ "types": [
+ "ANARI_ARRAY1D"
+ ],
+ "elementType": "ANARI_FLOAT32",
+ "tags": []
+ }
+ ]
+ },
+ {
+ "type": "ANARI_LIGHT",
+ "name": "directional",
+ "parameters": [
+ {
+ "name": "direction",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 0.0,
+ -1.0
+ ]
+ },
+ {
+ "name": "color",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 1.0,
+ 1.0,
+ 1.0
+ ]
+ },
+ {
+ "name": "intensity",
+ "types": [
+ "ANARI_FLOAT32"
+ ],
+ "tags": [],
+ "default": 1.0
+ }
+ ]
+ },
+ {
+ "type": "ANARI_LIGHT",
+ "name": "point",
+ "parameters": [
+ {
+ "name": "position",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 0.0,
+ 0.0
+ ]
+ },
+ {
+ "name": "color",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 1.0,
+ 1.0,
+ 1.0
+ ]
+ },
+ {
+ "name": "intensity",
+ "types": [
+ "ANARI_FLOAT32"
+ ],
+ "tags": [],
+ "default": 1.0
+ }
+ ]
+ },
+ {
+ "type": "ANARI_MATERIAL",
+ "name": "matte",
+ "parameters": [
+ {
+ "name": "color",
+ "types": [
+ "ANARI_FLOAT32_VEC3"
+ ],
+ "tags": [],
+ "default": [
+ 0.8,
+ 0.8,
+ 0.8
+ ]
+ }
+ ]
+ },
+ {
+ "type": "ANARI_RENDERER",
+ "name": "raycast",
+ "parameters": [
+ {
+ "name": "background",
+ "types": [
+ "ANARI_FLOAT32_VEC4"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0
+ ]
+ }
+ ]
+ },
+ {
+ "type": "ANARI_RENDERER",
+ "name": "pathtracer",
+ "parameters": [
+ {
+ "name": "background",
+ "types": [
+ "ANARI_FLOAT32_VEC4"
+ ],
+ "tags": [],
+ "default": [
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0
+ ]
+ },
+ {
+ "name": "samples",
+ "types": [
+ "ANARI_INT32"
+ ],
+ "tags": [],
+ "default": 1
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/doc/images/Sol-R_001.png b/doc/images/Sol-R_001.png
index bb57eb1..4f7fd88 100644
Binary files a/doc/images/Sol-R_001.png and b/doc/images/Sol-R_001.png differ
diff --git a/doc/images/Sol-R_002.png b/doc/images/Sol-R_002.png
index eea8f57..cde09bf 100644
Binary files a/doc/images/Sol-R_002.png and b/doc/images/Sol-R_002.png differ
diff --git a/doc/images/Sol-R_003.png b/doc/images/Sol-R_003.png
deleted file mode 100644
index 7fb7989..0000000
Binary files a/doc/images/Sol-R_003.png and /dev/null differ
diff --git a/doc/images/Sol-R_004.png b/doc/images/Sol-R_004.png
deleted file mode 100644
index 10bb38c..0000000
Binary files a/doc/images/Sol-R_004.png and /dev/null differ
diff --git a/doc/images/Sol-R_005.png b/doc/images/Sol-R_005.png
deleted file mode 100644
index 949a135..0000000
Binary files a/doc/images/Sol-R_005.png and /dev/null differ
diff --git a/doc/images/Sol-R_006.png b/doc/images/Sol-R_006.png
deleted file mode 100644
index 7649ffe..0000000
Binary files a/doc/images/Sol-R_006.png and /dev/null differ
diff --git a/doc/images/Sol-R_007.png b/doc/images/Sol-R_007.png
deleted file mode 100644
index 22ad114..0000000
Binary files a/doc/images/Sol-R_007.png and /dev/null differ
diff --git a/doc/images/Sol-R_008.png b/doc/images/Sol-R_008.png
deleted file mode 100644
index 839b2a4..0000000
Binary files a/doc/images/Sol-R_008.png and /dev/null differ
diff --git a/doc/images/Sol-R_009.png b/doc/images/Sol-R_009.png
deleted file mode 100644
index 6fb0817..0000000
Binary files a/doc/images/Sol-R_009.png and /dev/null differ
diff --git a/doc/images/Sol-R_010.png b/doc/images/Sol-R_010.png
deleted file mode 100644
index b14ed37..0000000
Binary files a/doc/images/Sol-R_010.png and /dev/null differ
diff --git a/medias/hdri/0000.jpg b/medias/hdri/0000.jpg
index 5e086b7..47fc4c0 100644
Binary files a/medias/hdri/0000.jpg and b/medias/hdri/0000.jpg differ
diff --git a/medias/hdri/0001.jpg b/medias/hdri/0001.jpg
index 12cfbb9..ec2e9a7 100644
Binary files a/medias/hdri/0001.jpg and b/medias/hdri/0001.jpg differ
diff --git a/medias/hdri/0002.jpg b/medias/hdri/0002.jpg
index a1534cc..6ddcb0e 100644
Binary files a/medias/hdri/0002.jpg and b/medias/hdri/0002.jpg differ
diff --git a/medias/hdri/1000.jpg b/medias/hdri/1000.jpg
new file mode 100644
index 0000000..5e086b7
Binary files /dev/null and b/medias/hdri/1000.jpg differ
diff --git a/medias/hdri/1001.jpg b/medias/hdri/1001.jpg
new file mode 100644
index 0000000..12cfbb9
Binary files /dev/null and b/medias/hdri/1001.jpg differ
diff --git a/medias/hdri/1002.jpg b/medias/hdri/1002.jpg
new file mode 100644
index 0000000..a1534cc
Binary files /dev/null and b/medias/hdri/1002.jpg differ
diff --git a/run_tsdviewer.sh b/run_tsdviewer.sh
new file mode 100755
index 0000000..3583c98
--- /dev/null
+++ b/run_tsdviewer.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Run script for tsdViewer with Sol-R ANARI device
+
+export LD_LIBRARY_PATH=/home/cfavreau/code/favreau/VisRTX/build/Debug:/home/cfavreau/code/favreau/Sol-R/build/Debug/devices/solr:$LD_LIBRARY_PATH
+export TSD_ANARI_LIBRARIES=solr
+export ANARI_LIBRARY_solr=/home/cfavreau/code/favreau/Sol-R/build/Debug/devices/solr/libanari_library_solr.so
+
+echo "Environment variables set:"
+echo " LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+echo " TSD_ANARI_LIBRARIES=$TSD_ANARI_LIBRARIES"
+echo " ANARI_LIBRARY_solr=$ANARI_LIBRARY_solr"
+echo ""
+echo "Starting tsdViewer..."
+echo ""
+
+/home/cfavreau/code/favreau/VisRTX/build/Debug/tsdViewer "$@"
+
diff --git a/solr/CMakeLists.txt b/solr/CMakeLists.txt
index 797d5cc..a819100 100644
--- a/solr/CMakeLists.txt
+++ b/solr/CMakeLists.txt
@@ -1,52 +1,89 @@
+# Copyright (c) 2011-2022, Cyrille Favreau
+#
+# 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 for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
include_directories(${PROJECT_SOURCE_DIR}/solr ${PROJECT_SOURCE_DIR}/generated)
SET(SOLR_SOURCES
- DLL_API.h
- Logging.h
- types.h
- Consts.h
SolRStub.cpp
- SolRStub.h
+ engines/random/RandomGenerator.cpp
engines/GPUKernel.cpp
- engines/GPUKernel.h
#engines/cpu/CPUKernel.cpp
- #engines/cpu/CPUKernel.h
io/PDBReader.cpp
- io/PDBReader.h
io/OBJReader.cpp
- io/OBJReader.h
- io/FileMarshaller.cpp
io/SWCReader.cpp
- io/SWCReader.h
io/FileMarshaller.cpp
- io/FileMarshaller.h
images/ImageLoader.cpp
- images/ImageLoader.h
images/jpge.cpp
- images/jpge.h
images/jpgd.cpp
- images/jpgd.h
images/tgad.cpp
- images/tgad.h
opengl/rtgl.cpp
- opengl/rtgl.h
games/MapReader.cpp
+)
+
+SET(SOLR_HEADERS
+ Logging.h
+ SolRStub.h
+ engines/random/RandomGenerator.h
+ engines/GPUKernel.h
+ #engines/cpu/CPUKernel.h
+ io/PDBReader.h
+ io/OBJReader.h
+ io/SWCReader.h
+ io/FileMarshaller.h
+ images/ImageLoader.h
+ images/jpge.h
+ images/jpgd.h
+ images/tgad.h
+ opengl/rtgl.h
games/MapReader.h
)
+SET(SOLR_PUBLIC_HEADERS
+ ../generated/solr_defines.h
+ engines/GPUKernel.h
+ api.h
+ solr.h
+ consts.h
+)
+
+SET(SOLR_ENGINE_PUBLIC_HEADERS
+ engines/GPUKernel.h
+)
+
+unset(SOLR_ENGINE_LIBRARIES)
+
+# TODO: Include random number device library
+#if( ... _FOUND)
+# SET(SOLR_ENGINE_LIBRARIES ${ ... _LIBRARY})
+#endif( ... _FOUND)
+
if (CUDA_FOUND)
if(UNIX)
set(CUDA_NVCC_USER_ARGS
+ -std=c++11
-D_FORCE_INLINES
+ --compiler-options "-fPIC"
--maxrregcount=32
--use_fast_math
- -gencode=arch=compute_30,code=sm_30
- -gencode=arch=compute_35,code=sm_35
- -gencode=arch=compute_50,code=sm_50
-gencode=arch=compute_52,code=sm_52
+ -gencode=arch=compute_60,code=sm_60
+ -gencode=arch=compute_70,code=sm_70
+ -gencode=arch=compute_80,code=sm_80
)
else(UNIX)
- CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5 5.0 5.2 6.0 6.1)
+ CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5 5.0 5.2 6.0 6.1 7.0 8.0 8.9)
set(CUDA_NVCC_USER_ARGS -D_FORCE_INLINES --maxrregcount=32 --use_fast_math)
endif(UNIX)
@@ -78,7 +115,9 @@ if (CUDA_FOUND)
${KINECT_LIBRARIES}
${OCULUS_SDK_LIBRARIES}
${SIXENSESDK_LIBRARIES}
- )
+ ${SOLR_ENGINE_LIBRARIES}
+ )
+ list(APPEND SOLR_ENGINE_PUBLIC_HEADERS engines/cuda/CudaKernel.h)
endif()
if(OPENCL_FOUND)
@@ -88,6 +127,9 @@ if(OPENCL_FOUND)
engines/opencl/RayTracer.cl
${SOLR_SOURCES})
+ # __STRICT_ANSI__ needs to be undefined for OpenCL to access x,y,z members of cl_float2/3/.. types
+ target_compile_options(solr PRIVATE -U__STRICT_ANSI__)
+
TARGET_LINK_LIBRARIES(
solr
${OPENCL_LIBRARIES}
@@ -97,11 +139,15 @@ if(OPENCL_FOUND)
${KINECT_LIBRARIES}
${OCULUS_SDK_LIBRARIES}
${SIXENSESDK_LIBRARIES}
- )
+ ${SOLR_ENGINE_LIBRARIES}
+ )
+
# ================================================================================
# Install kernels
# ================================================================================
INSTALL( FILES engines/opencl/RayTracer.cl DESTINATION bin/kernels )
+
+ list(APPEND SOLR_ENGINE_PUBLIC_HEADERS engines/opencl/OpenCLKernel.h)
endif()
# ================================================================================
@@ -111,3 +157,6 @@ INSTALL(TARGETS solr
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
+# Install headers
+INSTALL( FILES ${SOLR_PUBLIC_HEADERS} DESTINATION include/solr )
+INSTALL( FILES ${SOLR_ENGINE_PUBLIC_HEADERS} DESTINATION include/solr/engines )
diff --git a/solr/DLL_API.h b/solr/DLL_API.h
deleted file mode 100644
index 3a3d25c..0000000
--- a/solr/DLL_API.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
- *
- * This file is part of Sol-R
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
- *
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#pragma once
-
-#pragma warning(disable : 4251)
-#pragma warning(disable : 4996)
-#pragma warning(disable : 4244) // Oculus DK1 SDK
-
-#ifdef WIN32
-#define SOLR_API __declspec(dllexport)
-#else
-#define SOLR_API
-#endif
diff --git a/solr/Logging.h b/solr/Logging.h
index 4caf5ce..9d819a0 100644
--- a/solr/Logging.h
+++ b/solr/Logging.h
@@ -1,21 +1,18 @@
-/* Copyright (c) 2011-2014, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma once
@@ -51,30 +48,34 @@ inline std::string getTimestamp()
#ifdef WIN32
#if 0
-#define LOG_INFO(__level, __msg) \
- { \
- if (__level == 1) \
- std::cout << getTimestamp() << " INFO [" << __level << "] " << __msg << std::endl; \
+#define LOG_INFO(__level, __msg) \
+ { \
+ if (__level == 1) \
+ std::cout << getTimestamp() << " INFO [" << __level << "] " \
+ << __msg << std::endl; \
}
-#define LOG_ERROR(__msg) std::cout << getTimestamp() << " ERROR [1] " << __msg << std::endl;
+#define LOG_ERROR(__msg) \
+ std::cout << getTimestamp() << " ERROR [1] " << __msg << std::endl;
#else
-#define LOG_INFO(__level, __msg) \
- { \
- if (__level == 1) \
- { \
- std::stringstream __s; \
- __s << getTimestamp() << " [" << GetCurrentThreadId() << "] [INFO] " << __msg; \
- OutputDebugString(__s.str().c_str()); \
- std::cout << "[INFO ] " << __s.str() << std::endl; \
- } \
+#define LOG_INFO(__level, __msg) \
+ { \
+ if (__level == 1) \
+ { \
+ std::stringstream __s; \
+ __s << getTimestamp() << " [" << GetCurrentThreadId() \
+ << "] [INFO] " << __msg; \
+ OutputDebugString(__s.str().c_str()); \
+ std::cout << "[INFO ] " << __s.str() << std::endl; \
+ } \
}
-#define LOG_ERROR(__msg) \
- { \
- std::stringstream __s; \
- __s << getTimestamp() << " [" << GetCurrentThreadId() << "] [ERROR] " << __msg; \
- OutputDebugString(__s.str().c_str()); \
- std::cerr << "[ERROR] " << __s.str() << std::endl; \
+#define LOG_ERROR(__msg) \
+ { \
+ std::stringstream __s; \
+ __s << getTimestamp() << " [" << GetCurrentThreadId() << "] [ERROR] " \
+ << __msg; \
+ OutputDebugString(__s.str().c_str()); \
+ std::cerr << "[ERROR] " << __s.str() << std::endl; \
}
#endif // 0
#else
diff --git a/solr/SolRStub.cpp b/solr/SolRStub.cpp
index 2c75255..78ff265 100644
--- a/solr/SolRStub.cpp
+++ b/solr/SolRStub.cpp
@@ -1,32 +1,29 @@
-/* Copyright (c) 2011-2017, Cyrille Favreau
- * All rights reserved. Do not distribute without permission.
- * Responsible Author: Cyrille Favreau
+/*
+ * Copyright (c) 2011-2022, Cyrille Favreau
*
- * This file is part of Sol-R
+ * 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 library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3.0 as published
- * by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
#pragma warning(disable : 4996)
-#include "types.h"
-#include "Logging.h"
#include "SolRStub.h"
+#include "Logging.h"
#include "engines/GPUKernel.h"
#include "io/FileMarshaller.h"
#include "io/OBJReader.h"
#include "io/PDBReader.h"
+#include "solr.h"
#include
@@ -34,6 +31,8 @@
#include
#endif
+using namespace solr;
+
SceneInfo gSceneInfoStub;
PostProcessingInfo gPostProcessingInfoStub;
@@ -45,22 +44,27 @@ int SolR_SetSceneInfo1()
return 0;
}
-extern "C" SOLR_API int SolR_SetSceneInfo(int width, int height, int graphicsLevel, int nbRayIterations,
- double transparentColor, double viewDistance, double shadowIntensity,
- double eyeSeparation, double bgColorR, double bgColorG, double bgColorB,
- double bgColorA, int renderBoxes, int pathTracingIteration,
- int maxPathTracingIterations, int frameBufferType, int timestamp,
- int atmosphericEffect, int cameraType, int doubleSidedTriangles,
- int extendedGeometry, int advancedIllumination, int skyboxSize,
- int skyboxMaterialId, double geometryEpsilon, double rayEpsilon)
-{
- LOG_INFO(3, "SolR_SetSceneInfo (" << width << "," << height << "," << graphicsLevel << "," << nbRayIterations << ","
- << transparentColor << "," << viewDistance << "," << shadowIntensity << ","
- << eyeSeparation << "," << bgColorR << "," << bgColorG << "," << bgColorB << ","
- << bgColorA << "," << cameraType << "," << renderBoxes << ","
- << pathTracingIteration << "," << maxPathTracingIterations << ","
- << frameBufferType << "," << timestamp << "," << atmosphericEffect << ","
- << cameraType << "," << geometryEpsilon << "," << rayEpsilon);
+extern "C" SOLR_API int SolR_SetSceneInfo(
+ int width, int height, int graphicsLevel, int nbRayIterations,
+ double transparentColor, double viewDistance, double shadowIntensity,
+ double eyeSeparation, double bgColorR, double bgColorG, double bgColorB,
+ double bgColorA, int renderBoxes, int pathTracingIteration,
+ int maxPathTracingIterations, int frameBufferType, int timestamp,
+ int atmosphericEffect, int cameraType, int doubleSidedTriangles,
+ int extendedGeometry, int advancedIllumination, int skyboxSize,
+ int skyboxMaterialId, double geometryEpsilon, double rayEpsilon)
+{
+ LOG_INFO(3, "SolR_SetSceneInfo ("
+ << width << "," << height << "," << graphicsLevel << ","
+ << nbRayIterations << "," << transparentColor << ","
+ << viewDistance << "," << shadowIntensity << ","
+ << eyeSeparation << "," << bgColorR << "," << bgColorG
+ << "," << bgColorB << "," << bgColorA << "," << cameraType
+ << "," << renderBoxes << "," << pathTracingIteration << ","
+ << maxPathTracingIterations << "," << frameBufferType << ","
+ << timestamp << "," << atmosphericEffect << ","
+ << cameraType << "," << geometryEpsilon << ","
+ << rayEpsilon);
gSceneInfoStub.size.x = width;
gSceneInfoStub.size.y = height;
@@ -77,13 +81,16 @@ extern "C" SOLR_API int SolR_SetSceneInfo(int width, int height, int graphicsLev
gSceneInfoStub.renderBoxes = static_cast(renderBoxes);
gSceneInfoStub.pathTracingIteration = pathTracingIteration;
gSceneInfoStub.maxPathTracingIterations = maxPathTracingIterations;
- gSceneInfoStub.frameBufferType = static_cast(frameBufferType);
+ gSceneInfoStub.frameBufferType =
+ static_cast(frameBufferType);
gSceneInfoStub.timestamp = timestamp;
- gSceneInfoStub.atmosphericEffect = static_cast(atmosphericEffect);
+ gSceneInfoStub.atmosphericEffect =
+ static_cast(atmosphericEffect);
gSceneInfoStub.cameraType = static_cast(cameraType);
gSceneInfoStub.doubleSidedTriangles = doubleSidedTriangles;
gSceneInfoStub.extendedGeometry = extendedGeometry;
- gSceneInfoStub.advancedIllumination = static_cast(advancedIllumination);
+ gSceneInfoStub.advancedIllumination =
+ static_cast(advancedIllumination);
gSceneInfoStub.skyboxRadius = skyboxSize;
gSceneInfoStub.skyboxMaterialId = skyboxMaterialId;
@@ -92,7 +99,8 @@ extern "C" SOLR_API int SolR_SetSceneInfo(int width, int height, int graphicsLev
return 0;
}
-int SolR_SetPostProcessingInfo(int type, double param1, double param2, int param3)
+int SolR_SetPostProcessingInfo(int type, double param1, double param2,
+ int param3)
{
LOG_INFO(3, "SolR_SetPostProcessingInfo");
gPostProcessingInfoStub.type = type;
@@ -139,14 +147,20 @@ int SolR_ResetKernel()
}
// --------------------------------------------------------------------------------
-void SolR_SetCamera(double eye_x, double eye_y, double eye_z, double dir_x, double dir_y, double dir_z, double angle_x,
- double angle_y, double angle_z)
+void SolR_SetCamera(double eye_x, double eye_y, double eye_z, double dir_x,
+ double dir_y, double dir_z, double angle_x, double angle_y,
+ double angle_z)
{
LOG_INFO(3, "SolR_SetCamera");
- const vec3f eye = make_vec3f(static_cast(eye_x), static_cast(eye_y), static_cast(eye_z));
- const vec3f dir = make_vec3f(static_cast(dir_x), static_cast(dir_y), static_cast(dir_z));
- const vec4f angles = make_vec4f(static_cast(angle_x), static_cast(angle_y), static_cast(angle_z),
- 6400.f);
+ const vec3f eye =
+ make_vec3f(static_cast(eye_x), static_cast(eye_y),
+ static_cast(eye_z));
+ const vec3f dir =
+ make_vec3f(static_cast(dir_x), static_cast(dir_y),
+ static_cast(dir_z));
+ const vec4f angles =
+ make_vec4f(static_cast(angle_x), static_cast(angle_y),
+ static_cast(angle_z), 6400.f);
solr::SingletonKernel::kernel()->setCamera(eye, dir, angles);
}
@@ -155,7 +169,8 @@ int SolR_RunKernel(double timer, BitmapBuffer *image)
{
LOG_INFO(3, "SolR_RunKernel");
solr::SingletonKernel::kernel()->setSceneInfo(gSceneInfoStub);
- solr::SingletonKernel::kernel()->setPostProcessingInfo(gPostProcessingInfoStub);
+ solr::SingletonKernel::kernel()->setPostProcessingInfo(
+ gPostProcessingInfoStub);
solr::SingletonKernel::kernel()->render_begin(static_cast(timer));
solr::SingletonKernel::kernel()->render_end();
memcpy(image, solr::SingletonKernel::kernel()->getBitmap(),
@@ -167,32 +182,37 @@ int SolR_RunKernel(double timer, BitmapBuffer *image)
int SolR_AddPrimitive(int type, int movable)
{
LOG_INFO(3, "SolR_AddPrimitive");
- int id = solr::SingletonKernel::kernel()->addPrimitive(static_cast(type));
+ int id = solr::SingletonKernel::kernel()->addPrimitive(
+ static_cast(type));
solr::SingletonKernel::kernel()->setPrimitiveIsMovable(id, (movable == 1));
return id;
}
// --------------------------------------------------------------------------------
-int SolR_SetPrimitive(int index, double p0_x, double p0_y, double p0_z, double p1_x, double p1_y, double p1_z,
- double p2_x, double p2_y, double p2_z, double size_x, double size_y, double size_z,
- int materialId)
+int SolR_SetPrimitive(int index, double p0_x, double p0_y, double p0_z,
+ double p1_x, double p1_y, double p1_z, double p2_x,
+ double p2_y, double p2_z, double size_x, double size_y,
+ double size_z, int materialId)
{
LOG_INFO(3, "SolR_SetPrimitive");
- solr::SingletonKernel::kernel()->setPrimitive(index, static_cast(p0_x), static_cast(p0_y),
- static_cast(p0_z), static_cast