mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-03 01:59:35 -06:00
Merge branch 'develop' into stars
Conflicts: include/openspace/util/constants.h shaders/pscstandard_fs.glsl shaders/pscstandard_vs.glsl src/interaction/interactionhandler.cpp src/main.cpp src/rendering/renderengine.cpp src/scenegraph/scenegraph.cpp src/scenegraph/scenegraphnode.cpp src/util/factorymanager.cpp
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -4,6 +4,10 @@ ext/SGCT
|
||||
.DS_Store
|
||||
*.swp
|
||||
|
||||
# generated glsl files
|
||||
*.gglsl
|
||||
*.OpenSpaceGenerated.glsl
|
||||
|
||||
# CMake stuff
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
@@ -18,4 +22,3 @@ install_manifest.txt
|
||||
# Doxygen stuff
|
||||
html/
|
||||
latex/
|
||||
Doxyfile
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
project (OpenSpace)
|
||||
|
||||
SET(CMAKE_EXE_LINKER_FLAGS /NODEFAULTLIB:\"LIBCMTD.lib\")
|
||||
if (WIN32)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS /NODEFAULTLIB:\"LIBCMTD.lib\")
|
||||
endif ()
|
||||
|
||||
set(OPENSPACE_BASE_DIR "${PROJECT_SOURCE_DIR}")
|
||||
set(OPENSPACE_EXT_DIR "${OPENSPACE_BASE_DIR}/ext")
|
||||
@@ -55,6 +57,7 @@ endif ()
|
||||
# Ghoul
|
||||
set(GHOUL_ROOT_DIR "${OPENSPACE_EXT_DIR}/ghoul")
|
||||
include_directories("${GHOUL_ROOT_DIR}/include")
|
||||
set(BOOST_ROOT "${GHOUL_ROOT_DIR}/ext/boost")
|
||||
add_subdirectory(${GHOUL_ROOT_DIR})
|
||||
set(DEPENDENT_LIBS ${DEPENDENT_LIBS} Ghoul)
|
||||
|
||||
@@ -72,6 +75,7 @@ set(DEPENDENT_LIBS ${DEPENDENT_LIBS} ${SGCT_LIBRARIES})
|
||||
# GLM
|
||||
set(GLM_ROOT_DIR "${GHOUL_ROOT_DIR}/ext/glm")
|
||||
find_package(GLM REQUIRED)
|
||||
add_definitions(-DGLM_SWIZZLE)
|
||||
include_directories(${GLM_INCLUDE_DIRS})
|
||||
|
||||
# GLEW
|
||||
@@ -99,7 +103,12 @@ endif(OPENCL_FOUND)
|
||||
|
||||
# Kameleon
|
||||
option(KAMELEON_LIBRARY_ONLY "Build with Kameleon as library only" ON)
|
||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" ON)
|
||||
if(WIN32)
|
||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
|
||||
else(WIN32)
|
||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" ON)
|
||||
endif(WIN32)
|
||||
option(KAMELEON_USE_HDF5 "Kameleon use HDF5" OFF)
|
||||
set(KAMELEON_ROOT_DIR ${OPENSPACE_EXT_DIR}/kameleon)
|
||||
set(KAMELEON_INCLUDES ${KAMELEON_ROOT_DIR}/src)
|
||||
add_subdirectory(${KAMELEON_ROOT_DIR})
|
||||
@@ -120,3 +129,5 @@ endif ()
|
||||
#########################################################################################
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
#add_subdirectory(gui)
|
||||
452
Doxyfile
Normal file
452
Doxyfile
Normal file
@@ -0,0 +1,452 @@
|
||||
# Doxyfile 1.7.6.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = OpenSpace
|
||||
PROJECT_NUMBER =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY = doc/
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ALWAYS_DETAILED_SEC = YES
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
QT_AUTOBRIEF = YES
|
||||
|
||||
# This tag can be used to specify a number of aliases that acts
|
||||
# as commands in the documentation. An alias has the form "name=value".
|
||||
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
|
||||
# put the command \sideeffect (or @sideeffect) in the documentation, which
|
||||
# will result in a user-defined paragraph with heading "Side Effects:".
|
||||
# You can put \n's in the value part of an alias to insert newlines.
|
||||
|
||||
ALIASES =
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
|
||||
SUBGROUPING = YES
|
||||
|
||||
# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
|
||||
# unions are shown inside the group in which they are included (e.g. using
|
||||
# @ingroup) instead of on a separate page (for HTML and Man pages) or
|
||||
# section (for LaTeX and RTF).
|
||||
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = YES
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = YES
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
INLINE_INFO = NO
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = YES
|
||||
SORT_MEMBERS_CTORS_1ST = YES
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = NO
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = NO
|
||||
SHOW_FILES = NO
|
||||
SHOW_NAMESPACES = YES
|
||||
LAYOUT_FILE =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
QUIET = YES
|
||||
WARNINGS = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
INPUT = src \
|
||||
include
|
||||
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cpp \
|
||||
*.h \
|
||||
*.inl
|
||||
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS = /ext/* bin/* build/* config/* gui/* kernels/* openspace-data/* scripts/* shaders/*
|
||||
EXCLUDE_SYMBOLS =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
VERBATIM_HEADERS = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 4
|
||||
IGNORE_PREFIX =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER = doxygen/header.html
|
||||
HTML_FOOTER = doxygen/footer.html
|
||||
HTML_STYLESHEET = doxygen/stylesheet.css
|
||||
#HTML_EXTRA_FILES =
|
||||
HTML_COLORSTYLE_HUE = 200
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_TIMESTAMP = NO
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
|
||||
# for more information.
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME =
|
||||
DOCSET_BUNDLE_ID =
|
||||
DOCSET_PUBLISHER_ID =
|
||||
DOCSET_PUBLISHER_NAME =
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
CHM_INDEX_ENCODING =
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = YES
|
||||
GENERATE_TREEVIEW = YES
|
||||
ENUM_VALUES_PER_LINE = 6
|
||||
TREEVIEW_WIDTH = 300
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_RELPATH = http://www.mathjax.org/mathjax
|
||||
MATHJAX_EXTENSIONS =
|
||||
SEARCHENGINE = YES
|
||||
SERVER_BASED_SEARCH = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
LATEX_FOOTER =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_SOURCE_CODE = NO
|
||||
LATEX_BIB_STYLE = plain
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED = YES
|
||||
SKIP_FUNCTION_MACROS = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
|
||||
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
|
||||
# available from the path. This tool is part of Graphviz, a graph visualization
|
||||
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
|
||||
# have no effect if this option is set to NO (the default)
|
||||
|
||||
HAVE_DOT = NO
|
||||
|
||||
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
|
||||
# allowed to run in parallel. When set to 0 (the default) doxygen will
|
||||
# base this on the number of processors available in the system. You can set it
|
||||
# explicitly to a value larger than 0 to get control over the balance
|
||||
# between CPU load and processing speed.
|
||||
|
||||
DOT_NUM_THREADS = 0
|
||||
|
||||
# By default doxygen will use the Helvetica font for all dot files that
|
||||
# doxygen generates. When you want a differently looking font you can specify
|
||||
# the font name using DOT_FONTNAME. You need to make sure dot is able to find
|
||||
# the font, which can be done by putting it in a standard location or by setting
|
||||
# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
|
||||
# directory containing the font.
|
||||
|
||||
DOT_FONTNAME = Helvetica
|
||||
|
||||
# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
|
||||
# The default size is 10pt.
|
||||
|
||||
DOT_FONTSIZE = 10
|
||||
|
||||
# By default doxygen will tell dot to use the Helvetica font.
|
||||
# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
|
||||
# set the path where dot can find it.
|
||||
|
||||
DOT_FONTPATH =
|
||||
|
||||
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
|
||||
# will generate a graph for each documented class showing the direct and
|
||||
# indirect inheritance relations. Setting this tag to YES will force the
|
||||
# CLASS_DIAGRAMS tag to NO.
|
||||
|
||||
CLASS_GRAPH = YES
|
||||
|
||||
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
|
||||
# will generate a graph for each documented class showing the direct and
|
||||
# indirect implementation dependencies (inheritance, containment, and
|
||||
# class references variables) of the class with other documented classes.
|
||||
|
||||
COLLABORATION_GRAPH = YES
|
||||
|
||||
# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
|
||||
# will generate a graph for groups, showing the direct groups dependencies
|
||||
|
||||
GROUP_GRAPHS = YES
|
||||
|
||||
# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
|
||||
# collaboration diagrams in a style similar to the OMG's Unified Modeling
|
||||
# Language.
|
||||
|
||||
UML_LOOK = NO
|
||||
|
||||
# If set to YES, the inheritance and collaboration graphs will show the
|
||||
# relations between templates and their instances.
|
||||
|
||||
TEMPLATE_RELATIONS = NO
|
||||
|
||||
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
|
||||
# tags are set to YES then doxygen will generate a graph for each documented
|
||||
# file showing the direct and indirect include dependencies of the file with
|
||||
# other documented files.
|
||||
|
||||
INCLUDE_GRAPH = YES
|
||||
|
||||
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
|
||||
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
|
||||
# documented header file showing the documented files that directly or
|
||||
# indirectly include this file.
|
||||
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
|
||||
# If the CALL_GRAPH and HAVE_DOT options are set to YES then
|
||||
# doxygen will generate a call dependency graph for every global function
|
||||
# or class method. Note that enabling this option will significantly increase
|
||||
# the time of a run. So in most cases it will be better to enable call graphs
|
||||
# for selected functions only using the \callgraph command.
|
||||
|
||||
CALL_GRAPH = NO
|
||||
|
||||
# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
|
||||
# doxygen will generate a caller dependency graph for every global function
|
||||
# or class method. Note that enabling this option will significantly increase
|
||||
# the time of a run. So in most cases it will be better to enable caller
|
||||
# graphs for selected functions only using the \callergraph command.
|
||||
|
||||
CALLER_GRAPH = NO
|
||||
|
||||
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
|
||||
# will generate a graphical hierarchy of all classes instead of a textual one.
|
||||
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
|
||||
# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
|
||||
# then doxygen will show the dependencies a directory has on other directories
|
||||
# in a graphical way. The dependency relations are determined by the #include
|
||||
# relations between the files in the directories.
|
||||
|
||||
DIRECTORY_GRAPH = YES
|
||||
|
||||
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
|
||||
# generated by dot. Possible values are svg, png, jpg, or gif.
|
||||
# If left blank png will be used. If you choose svg you need to set
|
||||
# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
|
||||
# visible in IE 9+ (other browsers do not have this requirement).
|
||||
|
||||
DOT_IMAGE_FORMAT = png
|
||||
|
||||
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
|
||||
# enable generation of interactive SVG images that allow zooming and panning.
|
||||
# Note that this requires a modern browser other than Internet Explorer.
|
||||
# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
|
||||
# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
|
||||
# visible. Older versions of IE do not have SVG support.
|
||||
|
||||
INTERACTIVE_SVG = NO
|
||||
|
||||
# The tag DOT_PATH can be used to specify the path where the dot tool can be
|
||||
# found. If left blank, it is assumed the dot tool can be found in the path.
|
||||
|
||||
DOT_PATH =
|
||||
|
||||
# The DOTFILE_DIRS tag can be used to specify one or more directories that
|
||||
# contain dot files that are included in the documentation (see the
|
||||
# \dotfile command).
|
||||
|
||||
DOTFILE_DIRS =
|
||||
|
||||
# The MSCFILE_DIRS tag can be used to specify one or more directories that
|
||||
# contain msc files that are included in the documentation (see the
|
||||
# \mscfile command).
|
||||
|
||||
MSCFILE_DIRS =
|
||||
|
||||
# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
|
||||
# nodes that will be shown in the graph. If the number of nodes in a graph
|
||||
# becomes larger than this value, doxygen will truncate the graph, which is
|
||||
# visualized by representing a node as a red box. Note that doxygen if the
|
||||
# number of direct children of the root node in a graph is already larger than
|
||||
# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
|
||||
# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
|
||||
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
|
||||
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
|
||||
# graphs generated by dot. A depth value of 3 means that only nodes reachable
|
||||
# from the root by following a path via at most 3 edges will be shown. Nodes
|
||||
# that lay further from the root node will be omitted. Note that setting this
|
||||
# option to 1 or 2 may greatly reduce the computation time needed for large
|
||||
# code bases. Also note that the size of a graph can be further restricted by
|
||||
# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
|
||||
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
|
||||
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
|
||||
# background. This is disabled by default, because dot on Windows does not
|
||||
# seem to support this out of the box. Warning: Depending on the platform used,
|
||||
# enabling this option may lead to badly anti-aliased labels on the edges of
|
||||
# a graph (i.e. they become hard to read).
|
||||
|
||||
DOT_TRANSPARENT = NO
|
||||
|
||||
# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
|
||||
# files in one run (i.e. multiple -o and -T options on the command line). This
|
||||
# makes dot run faster, but since only newer versions of dot (>1.8.10)
|
||||
# support this, this feature is disabled by default.
|
||||
|
||||
DOT_MULTI_TARGETS = NO
|
||||
|
||||
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
|
||||
# generate a legend page explaining the meaning of the various boxes and
|
||||
# arrows in the dot generated graphs.
|
||||
|
||||
GENERATE_LEGEND = YES
|
||||
|
||||
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
|
||||
# remove the intermediate dot files that are used to generate
|
||||
# the various graphs.
|
||||
|
||||
DOT_CLEANUP = YES
|
||||
65
config/sgct/ccmc_lab_all.xml
Normal file
65
config/sgct/ccmc_lab_all.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<Settings>
|
||||
<Display swapInterval="1" />
|
||||
</Settings>
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="true" monitor="0">
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1920" y="1080" />
|
||||
<!--<Size x="640" y="310" />-->
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Viewplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="-3.556" y="-1.0" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="-3.556" y="1.0" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="-1.778" y="1.0" z="0.0" />
|
||||
</Viewplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
<Window fullScreen="true" monitor="1">
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1920" y="1080" />
|
||||
<!--<Size x="640" y="310" />-->
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Viewplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="-1.778" y="-1.0" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="-1.778" y="1.0" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="1.778" y="1.0" z="0.0" />
|
||||
</Viewplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
<Window fullScreen="true" monitor="2">
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1920" y="1080" />
|
||||
<!--<Size x="640" y="310" />-->
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Viewplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="1.778" y="-1.0" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="1.778" y="1.0" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="3.556" y="1.0" z="0.0" />
|
||||
</Viewplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="4.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
47
config/sgct/ccmc_lab_work.xml
Normal file
47
config/sgct/ccmc_lab_work.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<Settings>
|
||||
<Display swapInterval="1" />
|
||||
</Settings>
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="true" monitor="1">
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1920" y="1080" />
|
||||
<!--<Size x="640" y="310" />-->
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Viewplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="-1.778" y="-1.0" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="-1.778" y="1.0" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="1.778" y="1.0" z="0.0" />
|
||||
</Viewplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
<Window fullScreen="true" monitor="2">
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1920" y="1080" />
|
||||
<!--<Size x="640" y="310" />-->
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<Viewplane>
|
||||
<!-- Lower left -->
|
||||
<Pos x="1.778" y="-1.0" z="0.0" />
|
||||
<!-- Upper left -->
|
||||
<Pos x="1.778" y="1.0" z="0.0" />
|
||||
<!-- Upper right -->
|
||||
<Pos x="3.556" y="1.0" z="0.0" />
|
||||
</Viewplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
</Node>
|
||||
<User eyeSeparation="0.065">
|
||||
<Pos x="0.0" y="0.0" z="4.0" />
|
||||
</User>
|
||||
</Cluster>
|
||||
@@ -1,13 +1,19 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<Cluster masterAddress="localhost" externalControlPort="20500">
|
||||
<Settings>
|
||||
<Display swapInterval="1" />
|
||||
<Display swapInterval="0" />
|
||||
</Settings>
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false">
|
||||
<Window fullScreen="false" fxaa="false">
|
||||
<!-- <Res x="4096" y="2304" /> -->
|
||||
<!-- <Res x="1920" y="1080" /> -->
|
||||
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="640" y="360" />
|
||||
<Pos x="500" y="50.0" />
|
||||
<Size x="1280" y="720" />
|
||||
<!-- <Size x="960" y="540" /> -->
|
||||
<!-- <Size x="640" y="360" /> -->
|
||||
<!--<Size x="640" y="310" />-->
|
||||
<Pos x="640" y="0.0" />
|
||||
<Viewport>
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
|
||||
9
doxygen/footer.html
Normal file
9
doxygen/footer.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<!--BEGIN GENERATE_TREEVIEW-->
|
||||
</ul>
|
||||
</div>
|
||||
<!--END GENERATE_TREEVIEW-->
|
||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||
<hr class="footer"/>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
</body>
|
||||
</html>
|
||||
50
doxygen/header.html
Normal file
50
doxygen/header.html
Normal file
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||
<link href="$relpath$tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
|
||||
$treeview
|
||||
$search
|
||||
$mathjax
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div! -->
|
||||
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="projectlogo">
|
||||
<img alt="Logo" src="$relpath$$projectlogo"/></td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectname">$projectname
|
||||
<!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectbrief">$projectbrief</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<td>$searchbox</td>
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
||||
951
doxygen/stylesheet.css
Normal file
951
doxygen/stylesheet.css
Normal file
@@ -0,0 +1,951 @@
|
||||
/* The standard CSS for doxygen */
|
||||
|
||||
body, table, div, p, dl {
|
||||
font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
/* @group Heading Levels */
|
||||
|
||||
h1 {
|
||||
font-size: 150%;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
margin: 10px 2px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.multicol {
|
||||
-moz-column-gap: 1em;
|
||||
-webkit-column-gap: 1em;
|
||||
-moz-column-count: 3;
|
||||
-webkit-column-count: 3;
|
||||
}
|
||||
|
||||
p.startli, p.startdd, p.starttd {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
p.endli {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
p.enddd {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
p.endtd {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
caption {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.legend {
|
||||
font-size: 70%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h3.version {
|
||||
font-size: 90%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.qindex, div.navtab{
|
||||
background-color: #EBF3F6;
|
||||
border: 1px solid #A3C6D7;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.qindex, div.navpath {
|
||||
width: 100%;
|
||||
line-height: 140%;
|
||||
}
|
||||
|
||||
div.navtab {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
/* @group Link Styling */
|
||||
|
||||
a {
|
||||
color: #3D728C;
|
||||
font-weight: normal;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.contents a:visited {
|
||||
color: #4683A2;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a.qindex {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a.qindexHL {
|
||||
font-weight: bold;
|
||||
background-color: #9CC1D4;
|
||||
color: #ffffff;
|
||||
border: 1px double #86B3CA;
|
||||
}
|
||||
|
||||
.contents a.qindexHL:visited {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
a.el {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a.elRef {
|
||||
}
|
||||
|
||||
a.code, a.code:visited {
|
||||
color: #4665A2;
|
||||
}
|
||||
|
||||
a.codeRef, a.codeRef:visited {
|
||||
color: #4665A2;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
dl.el {
|
||||
margin-left: -1cm;
|
||||
}
|
||||
|
||||
.fragment {
|
||||
font-family: monospace, fixed;
|
||||
font-size: 105%;
|
||||
}
|
||||
|
||||
pre.fragment {
|
||||
border: 1px solid #C4DAE5;
|
||||
background-color: #FBFCFD;
|
||||
padding: 4px 6px;
|
||||
margin: 4px 8px 4px 2px;
|
||||
overflow: auto;
|
||||
word-wrap: break-word;
|
||||
font-size: 9pt;
|
||||
line-height: 125%;
|
||||
}
|
||||
|
||||
div.ah {
|
||||
background-color: black;
|
||||
font-weight: bold;
|
||||
color: #ffffff;
|
||||
margin-bottom: 3px;
|
||||
margin-top: 3px;
|
||||
padding: 0.2em;
|
||||
border: solid thin #333;
|
||||
border-radius: 0.5em;
|
||||
-webkit-border-radius: .5em;
|
||||
-moz-border-radius: .5em;
|
||||
box-shadow: 2px 2px 3px #999;
|
||||
-webkit-box-shadow: 2px 2px 3px #999;
|
||||
-moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444));
|
||||
background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000);
|
||||
}
|
||||
|
||||
div.groupHeader {
|
||||
margin-left: 16px;
|
||||
margin-top: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.groupText {
|
||||
margin-left: 16px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: white;
|
||||
color: black;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.contents {
|
||||
margin-top: 10px;
|
||||
margin-left: 8px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
td.indexkey {
|
||||
background-color: #EBF3F6;
|
||||
font-weight: bold;
|
||||
border: 1px solid #C4DAE5;
|
||||
margin: 2px 0px 2px 0;
|
||||
padding: 2px 10px;
|
||||
white-space: nowrap;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
td.indexvalue {
|
||||
background-color: #EBF3F6;
|
||||
border: 1px solid #C4DAE5;
|
||||
padding: 2px 10px;
|
||||
margin: 2px 0px;
|
||||
}
|
||||
|
||||
tr.memlist {
|
||||
background-color: #EEF4F7;
|
||||
}
|
||||
|
||||
p.formulaDsp {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
img.formulaDsp {
|
||||
|
||||
}
|
||||
|
||||
img.formulaInl {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.center {
|
||||
text-align: center;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
div.center img {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
address.footer {
|
||||
text-align: right;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
img.footer {
|
||||
border: 0px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* @group Code Colorization */
|
||||
|
||||
span.keyword {
|
||||
color: #008000
|
||||
}
|
||||
|
||||
span.keywordtype {
|
||||
color: #604020
|
||||
}
|
||||
|
||||
span.keywordflow {
|
||||
color: #e08000
|
||||
}
|
||||
|
||||
span.comment {
|
||||
color: #800000
|
||||
}
|
||||
|
||||
span.preprocessor {
|
||||
color: #806020
|
||||
}
|
||||
|
||||
span.stringliteral {
|
||||
color: #002080
|
||||
}
|
||||
|
||||
span.charliteral {
|
||||
color: #008080
|
||||
}
|
||||
|
||||
span.vhdldigit {
|
||||
color: #ff00ff
|
||||
}
|
||||
|
||||
span.vhdlchar {
|
||||
color: #000000
|
||||
}
|
||||
|
||||
span.vhdlkeyword {
|
||||
color: #700070
|
||||
}
|
||||
|
||||
span.vhdllogic {
|
||||
color: #ff0000
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/*
|
||||
.search {
|
||||
color: #003399;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
form.search {
|
||||
margin-bottom: 0px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
input.search {
|
||||
font-size: 75%;
|
||||
color: #000080;
|
||||
font-weight: normal;
|
||||
background-color: #e8eef2;
|
||||
}
|
||||
*/
|
||||
|
||||
td.tiny {
|
||||
font-size: 75%;
|
||||
}
|
||||
|
||||
.dirtab {
|
||||
padding: 4px;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid #A3C6D7;
|
||||
}
|
||||
|
||||
th.dirtab {
|
||||
background: #EBF3F6;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
hr {
|
||||
height: 0px;
|
||||
border: none;
|
||||
border-top: 1px solid #4A8AAA;
|
||||
}
|
||||
|
||||
hr.footer {
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
/* @group Member Descriptions */
|
||||
|
||||
table.memberdecls {
|
||||
border-spacing: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.mdescLeft, .mdescRight,
|
||||
.memItemLeft, .memItemRight,
|
||||
.memTemplItemLeft, .memTemplItemRight, .memTemplParams {
|
||||
background-color: #F9FBFC;
|
||||
border: none;
|
||||
margin: 4px;
|
||||
padding: 1px 0 0 8px;
|
||||
}
|
||||
|
||||
.mdescLeft, .mdescRight {
|
||||
padding: 0px 8px 4px 8px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.memItemLeft, .memItemRight, .memTemplParams {
|
||||
border-top: 1px solid #C4DAE5;
|
||||
}
|
||||
|
||||
.memItemLeft, .memTemplItemLeft {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.memItemRight {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.memTemplParams {
|
||||
color: #4683A2;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Member Details */
|
||||
|
||||
/* Styles for detailed member documentation */
|
||||
|
||||
.memtemplate {
|
||||
font-size: 80%;
|
||||
color: #4683A2;
|
||||
font-weight: normal;
|
||||
margin-left: 9px;
|
||||
}
|
||||
|
||||
.memnav {
|
||||
background-color: #EBF3F6;
|
||||
border: 1px solid #A3C6D7;
|
||||
text-align: center;
|
||||
margin: 2px;
|
||||
margin-right: 15px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.mempage {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.memitem {
|
||||
padding: 0;
|
||||
margin-bottom: 10px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.memname {
|
||||
white-space: nowrap;
|
||||
font-weight: bold;
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.memproto, dl.reflist dt {
|
||||
border-top: 1px solid #A8C9D9;
|
||||
border-left: 1px solid #A8C9D9;
|
||||
border-right: 1px solid #A8C9D9;
|
||||
padding: 6px 0px 6px 0px;
|
||||
color: #254555;
|
||||
font-weight: bold;
|
||||
text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9);
|
||||
/* opera specific markup */
|
||||
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
|
||||
border-top-right-radius: 8px;
|
||||
border-top-left-radius: 8px;
|
||||
/* firefox specific markup */
|
||||
-moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px;
|
||||
-moz-border-radius-topright: 8px;
|
||||
-moz-border-radius-topleft: 8px;
|
||||
/* webkit specific markup */
|
||||
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
|
||||
-webkit-border-top-right-radius: 8px;
|
||||
-webkit-border-top-left-radius: 8px;
|
||||
background-image:url('nav_f.png');
|
||||
background-repeat:repeat-x;
|
||||
background-color: #E2EDF2;
|
||||
|
||||
}
|
||||
|
||||
.memdoc, dl.reflist dd {
|
||||
border-bottom: 1px solid #A8C9D9;
|
||||
border-left: 1px solid #A8C9D9;
|
||||
border-right: 1px solid #A8C9D9;
|
||||
padding: 2px 5px;
|
||||
background-color: #FBFCFD;
|
||||
border-top-width: 0;
|
||||
/* opera specific markup */
|
||||
border-bottom-left-radius: 8px;
|
||||
border-bottom-right-radius: 8px;
|
||||
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
|
||||
/* firefox specific markup */
|
||||
-moz-border-radius-bottomleft: 8px;
|
||||
-moz-border-radius-bottomright: 8px;
|
||||
-moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px;
|
||||
background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7FAFB 95%, #EEF4F7);
|
||||
/* webkit specific markup */
|
||||
-webkit-border-bottom-left-radius: 8px;
|
||||
-webkit-border-bottom-right-radius: 8px;
|
||||
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
|
||||
background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7FAFB), to(#EEF4F7));
|
||||
}
|
||||
|
||||
dl.reflist dt {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
dl.reflist dd {
|
||||
margin: 0px 0px 10px 0px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.paramkey {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.paramtype {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.paramname {
|
||||
color: #602020;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.paramname em {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.params, .retval, .exception, .tparams {
|
||||
border-spacing: 6px 2px;
|
||||
}
|
||||
|
||||
.params .paramname, .retval .paramname {
|
||||
font-weight: bold;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.params .paramtype {
|
||||
font-style: italic;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.params .paramdir {
|
||||
font-family: "courier new",courier,monospace;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group Directory (tree) */
|
||||
|
||||
/* for the tree view */
|
||||
|
||||
.ftvtree {
|
||||
font-family: sans-serif;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
/* these are for tree view when used as main index */
|
||||
|
||||
.directory {
|
||||
font-size: 9pt;
|
||||
font-weight: bold;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.directory h3 {
|
||||
margin: 0px;
|
||||
margin-top: 1em;
|
||||
font-size: 11pt;
|
||||
}
|
||||
|
||||
/*
|
||||
The following two styles can be used to replace the root node title
|
||||
with an image of your choice. Simply uncomment the next two styles,
|
||||
specify the name of your image and be sure to set 'height' to the
|
||||
proper pixel height of your image.
|
||||
*/
|
||||
|
||||
/*
|
||||
.directory h3.swap {
|
||||
height: 61px;
|
||||
background-repeat: no-repeat;
|
||||
background-image: url("yourimage.gif");
|
||||
}
|
||||
.directory h3.swap span {
|
||||
display: none;
|
||||
}
|
||||
*/
|
||||
|
||||
.directory > h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.directory p {
|
||||
margin: 0px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory div {
|
||||
display: none;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.directory img {
|
||||
vertical-align: -30%;
|
||||
}
|
||||
|
||||
/* these are for tree view when not used as main index */
|
||||
|
||||
.directory-alt {
|
||||
font-size: 100%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.directory-alt h3 {
|
||||
margin: 0px;
|
||||
margin-top: 1em;
|
||||
font-size: 11pt;
|
||||
}
|
||||
|
||||
.directory-alt > h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.directory-alt p {
|
||||
margin: 0px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.directory-alt div {
|
||||
display: none;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.directory-alt img {
|
||||
vertical-align: -30%;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
div.dynheader {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
address {
|
||||
font-style: normal;
|
||||
color: #2A4F61;
|
||||
}
|
||||
|
||||
table.doxtable {
|
||||
border-collapse:collapse;
|
||||
}
|
||||
|
||||
table.doxtable td, table.doxtable th {
|
||||
border: 1px solid #2D5468;
|
||||
padding: 3px 7px 2px;
|
||||
}
|
||||
|
||||
table.doxtable th {
|
||||
background-color: #37677F;
|
||||
color: #FFFFFF;
|
||||
font-size: 110%;
|
||||
padding-bottom: 4px;
|
||||
padding-top: 5px;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
table.fieldtable {
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid #A8C9D9;
|
||||
border-spacing: 0px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
-moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px;
|
||||
-webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15);
|
||||
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.fieldtable td, .fieldtable th {
|
||||
padding: 3px 7px 2px;
|
||||
}
|
||||
|
||||
.fieldtable td.fieldtype, .fieldtable td.fieldname {
|
||||
white-space: nowrap;
|
||||
border-right: 1px solid #A8C9D9;
|
||||
border-bottom: 1px solid #A8C9D9;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.fieldtable td.fielddoc {
|
||||
border-bottom: 1px solid #A8C9D9;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fieldtable tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.fieldtable th {
|
||||
background-image:url('nav_f.png');
|
||||
background-repeat:repeat-x;
|
||||
background-color: #E2EDF2;
|
||||
font-size: 90%;
|
||||
color: #254555;
|
||||
padding-bottom: 4px;
|
||||
padding-top: 5px;
|
||||
text-align:left;
|
||||
-moz-border-radius-topleft: 4px;
|
||||
-moz-border-radius-topright: 4px;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
border-bottom: 1px solid #A8C9D9;
|
||||
}
|
||||
|
||||
|
||||
.tabsearch {
|
||||
top: 0px;
|
||||
left: 10px;
|
||||
height: 36px;
|
||||
background-image: url('tab_b.png');
|
||||
z-index: 101;
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.navpath ul
|
||||
{
|
||||
font-size: 11px;
|
||||
background-image:url('tab_b.png');
|
||||
background-repeat:repeat-x;
|
||||
height:30px;
|
||||
line-height:30px;
|
||||
color:#8AB6CC;
|
||||
border:solid 1px #C2D9E4;
|
||||
overflow:hidden;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
.navpath li
|
||||
{
|
||||
list-style-type:none;
|
||||
float:left;
|
||||
padding-left:10px;
|
||||
padding-right:15px;
|
||||
background-image:url('bc_s.png');
|
||||
background-repeat:no-repeat;
|
||||
background-position:right;
|
||||
color:#36657C;
|
||||
}
|
||||
|
||||
.navpath li.navelem a
|
||||
{
|
||||
height:32px;
|
||||
display:block;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.navpath li.navelem a:hover
|
||||
{
|
||||
color:#68A1BD;
|
||||
}
|
||||
|
||||
.navpath li.footer
|
||||
{
|
||||
list-style-type:none;
|
||||
float:right;
|
||||
padding-left:10px;
|
||||
padding-right:15px;
|
||||
background-image:none;
|
||||
background-repeat:no-repeat;
|
||||
background-position:right;
|
||||
color:#36657C;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
||||
|
||||
div.summary
|
||||
{
|
||||
float: right;
|
||||
font-size: 8pt;
|
||||
padding-right: 5px;
|
||||
width: 50%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
div.summary a
|
||||
{
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
div.ingroups
|
||||
{
|
||||
margin-left: 5px;
|
||||
font-size: 8pt;
|
||||
padding-left: 5px;
|
||||
width: 50%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.ingroups a
|
||||
{
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
div.header
|
||||
{
|
||||
background-image:url('nav_h.png');
|
||||
background-repeat:repeat-x;
|
||||
background-color: #F9FBFC;
|
||||
margin: 0px;
|
||||
border-bottom: 1px solid #C4DAE5;
|
||||
}
|
||||
|
||||
div.headertitle
|
||||
{
|
||||
padding: 5px 5px 5px 7px;
|
||||
}
|
||||
|
||||
dl
|
||||
{
|
||||
padding: 0 0 0 10px;
|
||||
}
|
||||
|
||||
dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug
|
||||
{
|
||||
border-left:4px solid;
|
||||
padding: 0 0 0 6px;
|
||||
}
|
||||
|
||||
dl.note
|
||||
{
|
||||
border-color: #D0C000;
|
||||
}
|
||||
|
||||
dl.warning, dl.attention
|
||||
{
|
||||
border-color: #FF0000;
|
||||
}
|
||||
|
||||
dl.pre, dl.post, dl.invariant
|
||||
{
|
||||
border-color: #00D000;
|
||||
}
|
||||
|
||||
dl.deprecated
|
||||
{
|
||||
border-color: #505050;
|
||||
}
|
||||
|
||||
dl.todo
|
||||
{
|
||||
border-color: #00C0E0;
|
||||
}
|
||||
|
||||
dl.test
|
||||
{
|
||||
border-color: #3030E0;
|
||||
}
|
||||
|
||||
dl.bug
|
||||
{
|
||||
border-color: #C08050;
|
||||
}
|
||||
|
||||
#projectlogo
|
||||
{
|
||||
text-align: center;
|
||||
vertical-align: center;
|
||||
border-collapse: separate;
|
||||
}
|
||||
|
||||
#projectlogo img
|
||||
{
|
||||
border: 0px none;
|
||||
}
|
||||
|
||||
#projectname
|
||||
{
|
||||
font: 300% Tahoma, Arial,sans-serif;
|
||||
margin: 0px;
|
||||
padding: 2px 0px;
|
||||
}
|
||||
|
||||
#projectbrief
|
||||
{
|
||||
font: 120% Tahoma, Arial,sans-serif;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#projectnumber
|
||||
{
|
||||
font: 50% Tahoma, Arial,sans-serif;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#titlearea
|
||||
{
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #5394B4;
|
||||
background-color: #006599;
|
||||
|
||||
}
|
||||
|
||||
.image
|
||||
{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dotgraph
|
||||
{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mscgraph
|
||||
{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.caption
|
||||
{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.zoom
|
||||
{
|
||||
border: 1px solid #90BACE;
|
||||
}
|
||||
|
||||
dl.citelist {
|
||||
margin-bottom:50px;
|
||||
}
|
||||
|
||||
dl.citelist dt {
|
||||
color:#335F75;
|
||||
float:left;
|
||||
font-weight:bold;
|
||||
margin-right:10px;
|
||||
padding:5px;
|
||||
}
|
||||
|
||||
dl.citelist dd {
|
||||
margin:2px 0;
|
||||
padding:5px 0;
|
||||
}
|
||||
|
||||
@media print
|
||||
{
|
||||
#top { display: none; }
|
||||
#side-nav { display: none; }
|
||||
#nav-path { display: none; }
|
||||
body { overflow:visible; }
|
||||
h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
|
||||
.summary { display: none; }
|
||||
.memitem { page-break-inside: avoid; }
|
||||
#doc-content
|
||||
{
|
||||
margin-left:0 !important;
|
||||
height:auto !important;
|
||||
width:auto !important;
|
||||
overflow:inherit;
|
||||
display:inline;
|
||||
}
|
||||
pre.fragment
|
||||
{
|
||||
overflow: visible;
|
||||
text-wrap: unrestricted;
|
||||
white-space: -moz-pre-wrap; /* Moz */
|
||||
white-space: -pre-wrap; /* Opera 4-6 */
|
||||
white-space: -o-pre-wrap; /* Opera 7 */
|
||||
white-space: pre-wrap; /* CSS3 */
|
||||
word-wrap: break-word; /* IE 5.5+ */
|
||||
}
|
||||
}
|
||||
|
||||
Submodule ext/ghoul updated: 476cf3aece...08152443a9
@@ -1,8 +1,3 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(GUI)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${GUI_SOURCE_DIR}/build-debug)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(luascriptexternalcontrol)
|
||||
10
gui/luascriptexternalcontrol/CMakeLists.txt
Normal file
10
gui/luascriptexternalcontrol/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
project(LuascriptExternalControl)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
find_package(Qt5Widgets)
|
||||
find_package(Qt5Network)
|
||||
add_executable(LuascriptExternalControl WIN32 main.cpp mainwindow.cpp)
|
||||
target_link_libraries(LuascriptExternalControl Qt5::Widgets Qt5::Network)
|
||||
35
gui/luascriptexternalcontrol/main.cpp
Normal file
35
gui/luascriptexternalcontrol/main.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
MainWidget window;
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
103
gui/luascriptexternalcontrol/mainwindow.cpp
Normal file
103
gui/luascriptexternalcontrol/mainwindow.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
|
||||
MainWidget::MainWidget()
|
||||
: _ipAddress(new QLineEdit)
|
||||
, _command(new QLineEdit)
|
||||
, _logWindow(new QTextEdit)
|
||||
, _socket(nullptr)
|
||||
{
|
||||
setWindowTitle("OpenSpace LuaScripting GUI");
|
||||
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
_ipAddress->setMinimumWidth(200);
|
||||
_ipAddress->setText("127.0.0.1");
|
||||
layout->addWidget(_ipAddress, 0, 0);
|
||||
|
||||
QPushButton* connectButton = new QPushButton("Connect");
|
||||
connect(connectButton, SIGNAL(clicked()), this, SLOT(onConnectButton()));
|
||||
connectButton->show();
|
||||
layout->addWidget(connectButton, 0, 1);
|
||||
|
||||
_command->setMinimumWidth(200);
|
||||
layout->addWidget(_command, 1, 0);
|
||||
|
||||
QPushButton* sendButton = new QPushButton("Send");
|
||||
sendButton->setDefault(true);
|
||||
connect(sendButton, SIGNAL(clicked()), this, SLOT(sendCommandButton()));
|
||||
layout->addWidget(sendButton, 1, 1);
|
||||
|
||||
layout->addWidget(_logWindow, 2, 0, 1, 2);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
MainWidget::~MainWidget() {
|
||||
delete _command;
|
||||
delete _socket;
|
||||
}
|
||||
|
||||
void MainWidget::readTcpData() {
|
||||
QByteArray data = _socket->readAll();
|
||||
|
||||
if (_logWindow->toPlainText().isEmpty())
|
||||
_logWindow->setText(data.data());
|
||||
else
|
||||
_logWindow->setText(_logWindow->toPlainText() + "\n" + data.data());
|
||||
}
|
||||
|
||||
void MainWidget::onConnectButton() {
|
||||
delete _socket;
|
||||
|
||||
_socket = new QTcpSocket(this);
|
||||
connect( _socket, SIGNAL(readyRead()), SLOT(readTcpData()) );
|
||||
_socket->connectToHost(_ipAddress->text(), 20500);
|
||||
|
||||
}
|
||||
|
||||
void MainWidget::sendCommandButton() {
|
||||
if (!_socket) {
|
||||
if (_logWindow->toPlainText().isEmpty())
|
||||
_logWindow->setText("No connection found");
|
||||
else
|
||||
_logWindow->setText(_logWindow->toPlainText() + "\n" + "No connection found");
|
||||
return;
|
||||
}
|
||||
|
||||
QString command = _command->text();
|
||||
|
||||
if (_logWindow->toPlainText().isEmpty())
|
||||
_logWindow->setText(command);
|
||||
else
|
||||
_logWindow->setText(_logWindow->toPlainText() + "\n" + command);
|
||||
|
||||
|
||||
_socket->write(("0" + command + "\r\n").toLatin1());
|
||||
}
|
||||
67
gui/luascriptexternalcontrol/mainwindow.h
Normal file
67
gui/luascriptexternalcontrol/mainwindow.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __MAINWINDOW_H__
|
||||
#define __MAINWINDOW_H__
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QTcpSocket>
|
||||
#include <QTextEdit>
|
||||
|
||||
class MainWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWidget();
|
||||
~MainWidget();
|
||||
|
||||
private slots:
|
||||
void onConnectButton();
|
||||
void sendCommandButton();
|
||||
void readTcpData();
|
||||
|
||||
private:
|
||||
QLineEdit* _ipAddress;
|
||||
QLineEdit* _command;
|
||||
QTextEdit* _logWindow;
|
||||
|
||||
QTcpSocket* _socket;
|
||||
|
||||
|
||||
//
|
||||
//private slots:
|
||||
// void on__connectButton_clicked();
|
||||
// void on__statsCheckBox_toggled(bool checked);
|
||||
// void readTcpData();
|
||||
// void on__graphCheckBox_toggled(bool checked);
|
||||
// void on__renderComboBox_currentIndexChanged(const QString &arg1);
|
||||
//
|
||||
//private:
|
||||
// qint64 sendToSGCT(QByteArray data);
|
||||
//
|
||||
// Ui::MainWindow *ui;
|
||||
// QTcpSocket* _sgctSocket;
|
||||
};
|
||||
|
||||
#endif // __MAINWINDOW_H__
|
||||
@@ -1,20 +0,0 @@
|
||||
# FIXME: ugly hack for linking qt5
|
||||
set (CMAKE_PREFIX_PATH "/home/hhellteg/Qt/5.2.1/gcc_64")
|
||||
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
# Find the Qt libraries
|
||||
find_package(Qt5Widgets)
|
||||
find_package(Qt5Network)
|
||||
|
||||
# Create ui_mainwindow.h file
|
||||
qt5_wrap_ui(QT_UI_HEADERS mainwindow.ui)
|
||||
|
||||
# Tell CMake to create the executable
|
||||
add_executable(gui main.cpp mainwindow.cpp ${QT_UI_HEADERS})
|
||||
|
||||
# Use the needed modules from Qt 5.
|
||||
target_link_libraries(gui Qt5::Widgets Qt5::Network)
|
||||
@@ -1,12 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
_sgctSocket(NULL) {
|
||||
ui->setupUi(this);
|
||||
ui->_hostEdit->setText("127.0.0.1");
|
||||
setWindowTitle("OpenSpace Qt GUI");
|
||||
ui->_statsCheckBox->setEnabled(false);
|
||||
ui->_graphCheckBox->setEnabled(false);
|
||||
ui->_renderComboBox->setEnabled(false);
|
||||
|
||||
// TEST JSON
|
||||
// QJsonObject json, jsonObj2;
|
||||
// QJsonArray jsonArr, jsonArr2;
|
||||
// json["Value 1"] = (QString("Herp"));
|
||||
// json["Value 2"] = (QString("Derp"));
|
||||
// jsonArr.push_back(QString("val1"));
|
||||
// jsonArr.push_back(QString("val2"));
|
||||
// jsonArr.push_back(QString("val3"));
|
||||
// jsonArr.push_back(QString("val4"));
|
||||
// jsonArr.push_back(QString("val5"));
|
||||
// jsonArr2.push_back(QString("val21"));
|
||||
// jsonArr2.push_back(QString("val22"));
|
||||
// jsonArr2.push_back(QString("val23"));
|
||||
// jsonArr2.push_back(QString("val24"));
|
||||
// jsonArr2.push_back(QString("val25"));
|
||||
// jsonObj2["ArrayYo2"] = jsonArr2;
|
||||
// jsonArr.push_back(jsonObj2);
|
||||
// json["ArrayYo"] = jsonArr;
|
||||
// QJsonDocument doc;
|
||||
// doc.setObject(json);
|
||||
// std::cout << doc.toJson().data() << std::endl;
|
||||
// quick_exit(0);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::on__connectButton_clicked() {
|
||||
_sgctSocket = new QTcpSocket(this);
|
||||
connect( _sgctSocket, SIGNAL(readyRead()), SLOT(readTcpData()) );
|
||||
_sgctSocket->connectToHost(ui->_hostEdit->text(), 20500);
|
||||
if (_sgctSocket->waitForConnected()) {
|
||||
ui->_statsCheckBox->setEnabled(true);
|
||||
ui->_graphCheckBox->setEnabled(true);
|
||||
ui->_renderComboBox->setEnabled(true);
|
||||
} else {
|
||||
std::cout << "Connection failed" << std::endl;
|
||||
ui->_statsCheckBox->setEnabled(false);
|
||||
ui->_graphCheckBox->setEnabled(false);
|
||||
ui->_renderComboBox->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on__statsCheckBox_toggled(bool checked) {
|
||||
QJsonObject json;
|
||||
QJsonDocument doc;
|
||||
if (checked) {
|
||||
json["stats"] = 1;
|
||||
} else {
|
||||
json["stats"] = 0;
|
||||
}
|
||||
doc.setObject(json);
|
||||
std::cout << "Bytes sent: " << sendToSGCT(doc.toJson()) << " " << std::flush;
|
||||
}
|
||||
|
||||
void MainWindow::on__graphCheckBox_toggled(bool checked) {
|
||||
QJsonObject json;
|
||||
QJsonDocument doc;
|
||||
if (checked) {
|
||||
json["graph"] = 1;
|
||||
} else {
|
||||
json["graph"] = 0;
|
||||
}
|
||||
doc.setObject(json);
|
||||
std::cout << "Bytes sent: " << sendToSGCT(doc.toJson()) << " " << std::flush;
|
||||
}
|
||||
|
||||
void MainWindow::readTcpData() {
|
||||
QByteArray data = _sgctSocket->readAll();
|
||||
std::cout << data.data() << std::flush;
|
||||
}
|
||||
|
||||
void MainWindow::on__renderComboBox_currentIndexChanged(const QString &arg1){
|
||||
QJsonObject json;
|
||||
QJsonDocument doc;
|
||||
if (arg1.compare(QString("VolumeRaycaster")) == 0) {
|
||||
json["renderer"] = QString("volumeraycaster");
|
||||
} else if (arg1.compare(QString("Flare")) == 0) {
|
||||
json["renderer"] = QString("flare");
|
||||
}
|
||||
doc.setObject(json);
|
||||
std::cout << "Bytes sent: " << sendToSGCT(doc.toJson()) << " " << std::flush;
|
||||
}
|
||||
|
||||
qint64 MainWindow::sendToSGCT(QByteArray data) {
|
||||
return _sgctSocket->write(data + "\r\n"); // "\r\n" seperates messages
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTcpSocket>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on__connectButton_clicked();
|
||||
void on__statsCheckBox_toggled(bool checked);
|
||||
void readTcpData();
|
||||
void on__graphCheckBox_toggled(bool checked);
|
||||
void on__renderComboBox_currentIndexChanged(const QString &arg1);
|
||||
|
||||
private:
|
||||
qint64 sendToSGCT(QByteArray data);
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
QTcpSocket* _sgctSocket;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
@@ -1,102 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>303</width>
|
||||
<height>312</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="2">
|
||||
<widget class="QCheckBox" name="_graphCheckBox">
|
||||
<property name="text">
|
||||
<string>Graph</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="_renderComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>VolumeRaycaster</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flare</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="_connectButton">
|
||||
<property name="text">
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="_statsCheckBox">
|
||||
<property name="text">
|
||||
<string>Stats</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="_debugLabel">
|
||||
<property name="text">
|
||||
<string>Debug info</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="_renderLabel">
|
||||
<property name="text">
|
||||
<string>Renderer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="_hostEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="_hostLabel">
|
||||
<property name="text">
|
||||
<string>Host</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>303</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
93
include/openspace/abuffer/abuffer.h
Normal file
93
include/openspace/abuffer/abuffer.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __ABUFFER_H__
|
||||
#define __ABUFFER_H__
|
||||
|
||||
#include <openspace/abuffer/abuffer_i.h>
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/glm.h>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class Texture;
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ABuffer: public ABuffer_I {
|
||||
public:
|
||||
|
||||
ABuffer();
|
||||
virtual ~ABuffer();
|
||||
virtual void resolve();
|
||||
|
||||
void addVolume(const std::string& tag,ghoul::opengl::Texture* volume);
|
||||
void addTransferFunction(const std::string& tag,ghoul::opengl::Texture* transferFunction);
|
||||
int addSamplerfile(const std::string& filename);
|
||||
|
||||
protected:
|
||||
virtual std::string settings() = 0;
|
||||
|
||||
bool initializeABuffer();
|
||||
|
||||
void generateShaderSource();
|
||||
bool updateShader();
|
||||
|
||||
std::string openspaceHeaders();
|
||||
std::string openspaceSamplerCalls();
|
||||
std::string openspaceSamplers();
|
||||
std::string openspaceTransferFunction();
|
||||
|
||||
unsigned int _width, _height, _totalPixels;
|
||||
|
||||
private:
|
||||
GLuint _screenQuad;
|
||||
|
||||
bool _validShader;
|
||||
std::string _fragmentShaderPath;
|
||||
ghoul::filesystem::File* _fragmentShaderFile;
|
||||
ghoul::opengl::ProgramObject* _resolveShader;
|
||||
|
||||
std::vector<std::pair<std::string,ghoul::opengl::Texture*> > _volumes;
|
||||
std::vector<std::pair<std::string,ghoul::opengl::Texture*> > _transferFunctions;
|
||||
std::vector<ghoul::filesystem::File*> _samplerFiles;
|
||||
std::vector<std::string> _samplers;
|
||||
|
||||
// Development functionality to update shader for changes in several files
|
||||
std::vector<ghoul::filesystem::File*> _shaderFiles;
|
||||
|
||||
float _volumeStepFactor;
|
||||
|
||||
|
||||
|
||||
}; // ABuffer
|
||||
} // openspace
|
||||
|
||||
#endif // __ABUFFER_H__
|
||||
60
include/openspace/abuffer/abufferSingleLinked.h
Normal file
60
include/openspace/abuffer/abufferSingleLinked.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __ABUFFERSINGLELINKED_H__
|
||||
#define __ABUFFERSINGLELINKED_H__
|
||||
|
||||
#include <openspace/abuffer/abuffer.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ABufferSingleLinked: public ABuffer {
|
||||
public:
|
||||
|
||||
ABufferSingleLinked();
|
||||
virtual ~ABufferSingleLinked();
|
||||
virtual bool initialize();
|
||||
|
||||
virtual void clear();
|
||||
virtual void preRender();
|
||||
virtual void postRender();
|
||||
|
||||
virtual std::string settings();
|
||||
|
||||
private:
|
||||
|
||||
GLuint *_data;
|
||||
GLuint _anchorPointerTexture;
|
||||
GLuint _anchorPointerTextureInitializer;
|
||||
GLuint _atomicCounterBuffer;
|
||||
GLuint _fragmentBuffer;
|
||||
GLuint _fragmentTexture;
|
||||
|
||||
|
||||
|
||||
|
||||
}; // ABufferSingleLinked
|
||||
} // openspace
|
||||
|
||||
#endif // __ABUFFERSINGLELINKED_H__
|
||||
43
include/openspace/abuffer/abuffer_i.h
Normal file
43
include/openspace/abuffer/abuffer_i.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __ABUFFER_I_H__
|
||||
#define __ABUFFER_I_H__
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ABuffer_I {
|
||||
public:
|
||||
virtual ~ABuffer_I() {};
|
||||
virtual bool initialize() = 0;
|
||||
|
||||
virtual void clear() = 0;
|
||||
virtual void preRender() = 0;
|
||||
virtual void postRender() = 0;
|
||||
virtual void resolve() = 0;
|
||||
|
||||
}; // ABuffer_I
|
||||
} // openspace
|
||||
|
||||
#endif // __ABUFFER_I_H__
|
||||
60
include/openspace/abuffer/abufferdynamic.h
Normal file
60
include/openspace/abuffer/abufferdynamic.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __ABUFFERDYNAMIC_H__
|
||||
#define __ABUFFERDYNAMIC_H__
|
||||
|
||||
#include <openspace/abuffer/abuffer.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ABufferDynamic: public ABuffer {
|
||||
public:
|
||||
|
||||
ABufferDynamic();
|
||||
virtual ~ABufferDynamic();
|
||||
virtual bool initialize();
|
||||
|
||||
virtual void clear();
|
||||
virtual void preRender();
|
||||
virtual void postRender();
|
||||
|
||||
virtual std::string settings();
|
||||
|
||||
private:
|
||||
|
||||
GLuint *_data;
|
||||
GLuint _anchorPointerTexture;
|
||||
GLuint _anchorPointerTextureInitializer;
|
||||
GLuint _atomicCounterBuffer;
|
||||
GLuint _fragmentBuffer;
|
||||
GLuint _fragmentTexture;
|
||||
|
||||
|
||||
|
||||
|
||||
}; // ABufferDynamic
|
||||
} // openspace
|
||||
|
||||
#endif // __ABUFFERDYNAMIC_H__
|
||||
61
include/openspace/abuffer/abufferfixed.h
Normal file
61
include/openspace/abuffer/abufferfixed.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __ABUFFERFIXED_H__
|
||||
#define __ABUFFERFIXED_H__
|
||||
|
||||
#include <openspace/abuffer/abuffer.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ABufferFixed: public ABuffer {
|
||||
public:
|
||||
|
||||
ABufferFixed();
|
||||
virtual ~ABufferFixed();
|
||||
virtual bool initialize();
|
||||
|
||||
virtual void clear();
|
||||
virtual void preRender();
|
||||
virtual void postRender();
|
||||
|
||||
virtual std::string settings();
|
||||
|
||||
private:
|
||||
|
||||
GLuint *_data;
|
||||
GLuint _anchorPointerTexture;
|
||||
GLuint _anchorPointerTextureInitializer;
|
||||
GLuint _atomicCounterBuffer;
|
||||
GLuint _atomicCounterTexture;
|
||||
GLuint _fragmentBuffer;
|
||||
GLuint _fragmentTexture;
|
||||
|
||||
|
||||
|
||||
|
||||
}; // ABufferFixed
|
||||
} // openspace
|
||||
|
||||
#endif // __ABUFFERFIXED_H__
|
||||
@@ -34,17 +34,34 @@
|
||||
#include <ghoul/opencl/clprogram.h>
|
||||
#include <ghoul/opencl/clkernel.h>
|
||||
|
||||
//#define FLARE_ONLY
|
||||
// #define FLARE_ONLY
|
||||
|
||||
#include <openspace/flare/flare.h>
|
||||
#include <openspace/util/shadercreator.h>
|
||||
|
||||
#define ABUFFER_SINGLE_LINKED 1
|
||||
#define ABUFFER_FIXED 2
|
||||
#define ABUFFER_DYNAMIC 3
|
||||
#define ABUFFER_IMPLEMENTATION ABUFFER_SINGLE_LINKED
|
||||
|
||||
// #define OPENSPACE_VIDEO_EXPORT
|
||||
|
||||
namespace ghoul {
|
||||
namespace cmdparser {
|
||||
class CommandlineParser;
|
||||
class CommandlineCommand;
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ScriptEngine;
|
||||
namespace scripting {
|
||||
class ScriptEngine;
|
||||
}
|
||||
|
||||
class OpenSpaceEngine {
|
||||
public:
|
||||
static void create(int argc, char** argv, std::vector<std::string>& sgctArguments);
|
||||
static bool create(int argc, char** argv, std::vector<std::string>& sgctArguments);
|
||||
static void destroy();
|
||||
static OpenSpaceEngine& ref();
|
||||
|
||||
@@ -59,6 +76,8 @@ public:
|
||||
ghoul::opencl::CLContext& clContext();
|
||||
InteractionHandler& interactionHandler();
|
||||
RenderEngine& renderEngine();
|
||||
scripting::ScriptEngine& scriptEngine();
|
||||
ShaderCreator& shaderBuilder();
|
||||
|
||||
// SGCT callbacks
|
||||
bool initializeGL();
|
||||
@@ -70,19 +89,27 @@ public:
|
||||
void mouseButtonCallback(int key, int action);
|
||||
void mousePositionCallback(int x, int y);
|
||||
void mouseScrollWheelCallback(int pos);
|
||||
void externalControlCallback(const char* receivedChars, int size, int clientId);
|
||||
|
||||
void encode();
|
||||
void decode();
|
||||
|
||||
private:
|
||||
OpenSpaceEngine();
|
||||
OpenSpaceEngine(std::string programName);
|
||||
~OpenSpaceEngine();
|
||||
|
||||
bool gatherCommandlineArguments();
|
||||
|
||||
static OpenSpaceEngine* _engine;
|
||||
|
||||
ghoul::Dictionary* _configurationManager;
|
||||
InteractionHandler* _interactionHandler;
|
||||
RenderEngine* _renderEngine;
|
||||
scripting::ScriptEngine* _scriptEngine;
|
||||
ghoul::cmdparser::CommandlineParser* _commandlineParser;
|
||||
#ifdef OPENSPACE_VIDEO_EXPORT
|
||||
bool _doVideoExport;
|
||||
#endif
|
||||
#ifdef FLARE_ONLY
|
||||
Flare* _flare;
|
||||
#endif
|
||||
@@ -90,6 +117,7 @@ private:
|
||||
ghoul::opencl::CLContext _context;
|
||||
|
||||
sgct::SharedVector<char> _synchronizationBuffer;
|
||||
ShaderCreator _shaderBuilder;
|
||||
};
|
||||
|
||||
#define OsEng (openspace::OpenSpaceEngine::ref())
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -56,6 +58,8 @@ public:
|
||||
void mouseButtonCallback(int key, int action);
|
||||
void mousePositionCallback(int x, int y);
|
||||
void mouseScrollWheelCallback(int pos);
|
||||
|
||||
void addKeyCallback(int key, std::function<void(void)> f);
|
||||
|
||||
private:
|
||||
glm::vec3 mapToTrackball(glm::vec2 mousePos);
|
||||
@@ -77,6 +81,8 @@ private:
|
||||
|
||||
// for locking and unlocking
|
||||
std::mutex cameraGuard_;
|
||||
|
||||
std::multimap<int, std::function<void(void)> > _keyCallbacks;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ private:
|
||||
void handleNodes();
|
||||
void loadIntoNodes(const boost::property_tree::ptree& tree, std::string parent = "", const int depth = 0);
|
||||
|
||||
OpenSpaceEngine* _engine;
|
||||
// OpenSpaceEngine* _engine;
|
||||
std::vector<Node> _nodes;
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ public:
|
||||
NumericalProperty(std::string identifier, std::string guiName, T value,
|
||||
T minimumValue, T maximumValue);
|
||||
|
||||
bool getLua(lua_State* state) const override;
|
||||
bool setLua(lua_State* state) override;
|
||||
int typeLua() const override;
|
||||
|
||||
virtual std::string className() const override;
|
||||
|
||||
using TemplateProperty<T>::operator=;
|
||||
|
||||
@@ -22,43 +22,125 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
#define REGISTER_NUMERICALPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef NumericalProperty<TYPE> CLASS_NAME; \
|
||||
template <> std::string PropertyDelegate<NumericalProperty<TYPE>>::className(); \
|
||||
template <> std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>();
|
||||
#define REGISTER_NUMERICALPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef NumericalProperty<TYPE> CLASS_NAME; \
|
||||
template <> \
|
||||
std::string PropertyDelegate<NumericalProperty<TYPE>>::className(); \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue(lua_State* state, \
|
||||
bool& success); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromLuaValue(lua_State* state, \
|
||||
bool& success); \
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue(lua_State* state, \
|
||||
TYPE value); \
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<NumericalProperty<TYPE>>::toLuaValue(lua_State* state, \
|
||||
TYPE value); \
|
||||
template <> \
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
|
||||
template <> \
|
||||
int PropertyDelegate<NumericalProperty<TYPE>>::typeLua();
|
||||
|
||||
|
||||
#define REGISTER_NUMERICALPROPERTY_SOURCE(CLASS_NAME, TYPE, \
|
||||
DEFAULT_VALUE, DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, DEFAULT_STEPPING) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() { \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() { \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() { \
|
||||
return DEFAULT_VALUE; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() { \
|
||||
return DEFAULT_MIN_VALUE; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() { \
|
||||
return DEFAULT_MAX_VALUE; \
|
||||
}
|
||||
#define REGISTER_NUMERICALPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
|
||||
DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, \
|
||||
DEFAULT_STEPPING, FROM_LUA_LAMBDA_EXPRESSION, \
|
||||
TO_LUA_LAMBDA_EXPRESSION, LUA_TYPE) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
|
||||
{ \
|
||||
return #CLASS_NAME; \
|
||||
\
|
||||
} \
|
||||
template <> \
|
||||
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
\
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_VALUE; \
|
||||
\
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_MIN_VALUE; \
|
||||
\
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_MAX_VALUE; \
|
||||
\
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State * state, \
|
||||
bool& success) \
|
||||
{ \
|
||||
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
|
||||
\
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromLuaValue<TYPE>( \
|
||||
lua_State * state, bool& success) \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(state, \
|
||||
success); \
|
||||
\
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(lua_State * state, \
|
||||
TYPE value) \
|
||||
{ \
|
||||
return TO_LUA_LAMBDA_EXPRESSION(state, value); \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<NumericalProperty<TYPE>>::toLuaValue<TYPE>(lua_State * state, \
|
||||
TYPE value) \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(state, value); \
|
||||
} \
|
||||
template <> \
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua() \
|
||||
{ \
|
||||
return LUA_TYPE; \
|
||||
} \
|
||||
template <> \
|
||||
int PropertyDelegate<NumericalProperty<TYPE>>::typeLua() \
|
||||
{ \
|
||||
return PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
|
||||
}
|
||||
|
||||
// Delegating constructors are necessary; automatic template deduction cannot
|
||||
// deduce template argument for 'U' if 'default' methods are used as default values in
|
||||
@@ -95,5 +177,28 @@ std::string NumericalProperty<T>::className() const {
|
||||
return PropertyDelegate<NumericalProperty<T>>::className();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::setLua(lua_State* state)
|
||||
{
|
||||
bool success;
|
||||
T value = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(state, success);
|
||||
if (success)
|
||||
TemplateProperty<T>::setValue(value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::getLua(lua_State* state) const
|
||||
{
|
||||
bool success = PropertyDelegate<NumericalProperty<T>>::template toLuaValue<T>(state, TemplateProperty<T>::_value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int NumericalProperty<T>::typeLua() const {
|
||||
return PropertyDelegate<NumericalProperty<T>>::typeLua();
|
||||
}
|
||||
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -32,43 +32,223 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
struct lua_State;
|
||||
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
class PropertyOwner;
|
||||
|
||||
/**
|
||||
* A property encapsulates a value which should be user-changeable. A property almost
|
||||
* always belongs to a PropertyOwner who has taken ownership (setPropertyOwner) of the
|
||||
* Property. Per PropertyOwner, the <code>identifier</code> needs to be unique and can be
|
||||
* used as a URI. This class is an abstract base class and each subclass (most notable
|
||||
* TemplateProperty) needs to implement the methods Property::className, Property::get,
|
||||
* Property::set, Property::type(), Property::getLua, Property::setLua, and
|
||||
* Property::typeLua to make full use of the infrastructure.
|
||||
* The most common types can be implemented by creating a specialized instantiation of
|
||||
* TemplateProperty, which provides default implementations for these methods.
|
||||
*
|
||||
* The onChange method can be used by the PropertyOwner to listen to changes that happen
|
||||
* to the Property. The parameter is a function object that gets called after new value
|
||||
* has been set.
|
||||
* The metaData allows the developer to specify additional information about the Property
|
||||
* which might be used in GUI representations. One example would be a glm::vec4 property,
|
||||
* (Vec4Property) that can either represent a 4-dimensional position, a powerscaled
|
||||
* coordinate, a light position, or other things, requiring different GUI representations.
|
||||
* \see TemplateProperty
|
||||
* \see PropertyOwner
|
||||
*/
|
||||
class Property {
|
||||
public:
|
||||
/**
|
||||
* The constructor for the property. The <code>identifier</code> needs to be unique
|
||||
* for each PropertyOwner. The <code>guiName</code> will be stored in the metaData
|
||||
* to be accessed by the GUI elements using the <code>guiName</code> key. The default
|
||||
* visibility settings is <code>true</code>, whereas the default read-only state is
|
||||
* <code>false</code>.
|
||||
* \param identifier A unique identifier for this property. It has to be unique to the
|
||||
* PropertyOwner and cannot contain any <code>.</code>s
|
||||
* \param guiName The human-readable GUI name for this Property
|
||||
*/
|
||||
Property(std::string identifier, std::string guiName);
|
||||
|
||||
/**
|
||||
* The destructor taking care of deallocating all unused memory. This method will not
|
||||
* remove the Property from the PropertyOwner.
|
||||
*/
|
||||
virtual ~Property();
|
||||
|
||||
//virtual Property* create() const = 0;
|
||||
/**
|
||||
* This method returns the class name of the Property. The method is used by the
|
||||
* TemplateFactory to create new instances of Propertys. The returned value is almost
|
||||
* always identical to the C++ class name of the derived class.
|
||||
* \return The class name of the Property
|
||||
*/
|
||||
virtual std::string className() const = 0;
|
||||
|
||||
/**
|
||||
* This method returns the encapsulated value of the Property to the caller. The type
|
||||
* that is returned is determined by the type function and is up to the developer of
|
||||
* the derived class. The default implementation returns an empty boost::any object.
|
||||
* \return The value that is encapsulated by this Property, or an empty boost::any
|
||||
* object if the method was not overritten.
|
||||
*/
|
||||
virtual boost::any get() const;
|
||||
virtual void set(boost::any value);
|
||||
virtual const std::type_info& type() const;
|
||||
|
||||
/**
|
||||
* Sets the value encapsulated by this Property to the <code>value</code> passed to
|
||||
* this function. It is the caller's responsibility to ensure that the type contained
|
||||
* in <code>value</code> is compatible with the concrete subclass of the Property. The
|
||||
* method Property::type will return the desired type for the Property. The default
|
||||
* implementation of this method ignores the input.
|
||||
* \param value The new value that should be stored in this Property
|
||||
*/
|
||||
virtual void set(boost::any value);
|
||||
|
||||
/**
|
||||
* This method returns the type that is requested by this Property for the set method.
|
||||
* The default implementation returns the type of <code>void</code>.
|
||||
* \return The type that is requested by this Property's Property::set method
|
||||
*/
|
||||
virtual const std::type_info& type() const;
|
||||
|
||||
/**
|
||||
* This method encodes the encapsulated value of this Property at the top of the Lua
|
||||
* stack. The specific details of this serialization is up to the property developer
|
||||
* as long as the rest of the stack is unchanged. The implementation has to be
|
||||
* synchronized with the Property::setLua method. The default implementation is a
|
||||
* no-op.
|
||||
* \param state The Lua state to which the value will be encoded
|
||||
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool getLua(lua_State* state) const;
|
||||
|
||||
/**
|
||||
* This method sets the value encapsulated by this Property by deserializing the value
|
||||
* on top of the passed Lua stack. The specific details of the deserialization are up
|
||||
* to the Property developer, but they must only depend on the top element of the
|
||||
* stack and must leave all other elements unchanged. The implementation has to be
|
||||
* synchronized with the Property::getLua method. The default implementation is a
|
||||
* no-op.
|
||||
* \param state The Lua state from which the value will be decoded
|
||||
* \return <code>true</code> if the decoding and setting of the value succeeded,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool setLua(lua_State* state);
|
||||
|
||||
/**
|
||||
* Returns the Lua type that will be put onto the stack in the Property::getLua method
|
||||
* and which will be consumed by the Property::setLua method. The returned value
|
||||
* can belong to the set of Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
|
||||
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
|
||||
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
|
||||
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
|
||||
* <code>LUA_TTHREAD</code>. The default implementation will return
|
||||
* <code>LUA_TNONE</code>.
|
||||
* \return The Lua type that will be consumed or produced by the Property::getLua and
|
||||
* Property::setLua methods.
|
||||
*/
|
||||
virtual int typeLua() const;
|
||||
|
||||
/**
|
||||
* This method registers a <code>callback</code> function that will be called every
|
||||
* time if either Property:set or Property::setLua was called with a value that is
|
||||
* different from the previously stored value. The callback can be removed my passing
|
||||
* an empty <code>std::function<void()></code> object.
|
||||
* \param callback The callback function that is called when the encapsulated type has
|
||||
* been successfully changed by either the Property::set or Property::setLua methods.
|
||||
*/
|
||||
virtual void onChange(std::function<void()> callback);
|
||||
|
||||
/**
|
||||
* This method returns the unique identifier of this Property.
|
||||
* \return The unique identifier of this Property
|
||||
*/
|
||||
const std::string& identifier() const;
|
||||
const std::string& guiName() const;
|
||||
|
||||
/**
|
||||
* Returns the PropertyOwner of this Property or <code>nullptr</code>, if it does not
|
||||
* have an owner.
|
||||
*\ return The Property of this Property
|
||||
*/
|
||||
PropertyOwner* owner() const;
|
||||
void setPropertyOwner(PropertyOwner* owner);
|
||||
|
||||
/**
|
||||
* Assigned the Property to a new PropertyOwner. This method does not inform the
|
||||
* PropertyOwner of this action.
|
||||
* \param owner The new PropertyOwner for this Property
|
||||
*/
|
||||
void setPropertyOwner(PropertyOwner* owner);
|
||||
|
||||
/**
|
||||
* Returns the human-readable GUI name for this Property that has been set in the
|
||||
* constructor. This method returns the same value as accessing the metaData object
|
||||
* and requesting the <code>std::string</code> stored for the <code>guiName</code>
|
||||
* key.
|
||||
* \return The human-readable GUI name for this Property
|
||||
*/
|
||||
const std::string& guiName() const;
|
||||
|
||||
/**
|
||||
* Sets the identifier of the group that this Property belongs to. Property groups can
|
||||
* be used, for example, by GUI application to visually group different properties,
|
||||
* but it has no impact on the Property itself. The default value for the groupID is
|
||||
* <code>""</code>.
|
||||
* \param groupId The group id that this property should belong to
|
||||
*/
|
||||
void setGroupIdentifier(std::string groupId);
|
||||
|
||||
/**
|
||||
* Returns the group idenfier that this Property belongs to, or <code>""</code> if it
|
||||
* belongs to no group.
|
||||
* \return The group identifier that this Property belongs to
|
||||
*/
|
||||
std::string groupIdentifier() const;
|
||||
|
||||
/**
|
||||
* Determines a hint if this Property should be visible, or hidden. Each application
|
||||
* accessing the properties is free to ignore this hint. It is stored in the metaData
|
||||
* Dictionary with the key: <code>isVisible</code>. The default value is
|
||||
* <code>true</code>.
|
||||
* \param state <code>true</code> if the Property should be visible,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
void setVisible(bool state);
|
||||
bool isVisible() const;
|
||||
|
||||
void setReadOnly(bool state);
|
||||
bool isReadOnly() const;
|
||||
/**
|
||||
* This method determines if this Property should be read-only in external
|
||||
* applications. This setting is only a hint and does not need to be followed by GUI
|
||||
* applications and does not have any effect on the Property::set or Property::setLua
|
||||
* methods. The value is stored in the metaData Dictionary with the key:
|
||||
* <code>isReadOnly</code>. The default value is <code>false</code>.
|
||||
* \param state <code>true</code> if the Property should be read only,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
void setReadOnly(bool state);
|
||||
|
||||
/**
|
||||
* This method allows the developer to give hints to the GUI about different
|
||||
* representations for the GUI. The same Property (for example Vec4Property) can be
|
||||
* used in different ways, each requiring a different input method. These values are
|
||||
* stored in the metaData object using the <code>views.</code> prefix in front of the
|
||||
* <code>option</code> parameter. See Property::ViewOptions for a default list of
|
||||
* possible options. As these are only hints, the GUI is free to ignore any suggestion
|
||||
* by the developer.
|
||||
* \param option The view option that should be modified
|
||||
* \param value Determines if the view option should be active (<code>true</code>) or
|
||||
* deactivated (<code>false</code>)
|
||||
*/
|
||||
void setViewOption(std::string option, bool value = true);
|
||||
bool viewOption(const std::string& option) const;
|
||||
|
||||
/**
|
||||
* Default view options that can be used in the Property::setViewOption method. The
|
||||
* values are: Property::ViewOptions::Color = <code>color</code>,
|
||||
* Property::ViewOptions::LightPosition = <code>lightPosition</code>,
|
||||
* Property::ViewOptions::PowerScaledScalar = <code>powerScaledScalar</code>, and
|
||||
* Property::ViewOptions::PowerScaledCoordinate = <code>powerScaledCoordinate</code>.
|
||||
*/
|
||||
struct ViewOptions {
|
||||
static const std::string Color;
|
||||
static const std::string LightPosition;
|
||||
@@ -76,16 +256,32 @@ public:
|
||||
static const std::string PowerScaledCoordinate;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the metaData that contains all information for external applications to
|
||||
* correctly display information about the Property. No information that is stored in
|
||||
* this Dictionary is necessary for the programmatic use of the Property.
|
||||
* \return The Dictionary containing all meta data information about this Property
|
||||
*/
|
||||
const ghoul::Dictionary& metaData() const;
|
||||
|
||||
protected:
|
||||
PropertyOwner* _owner;
|
||||
/**
|
||||
* This method must be called by all subclasses whenever the encapsulated value has
|
||||
* changed and a potential listener has to be informed.
|
||||
*/
|
||||
void notifyListener();
|
||||
|
||||
/// The PropetyOwner this Property belongs to, or <code>nullptr</code>
|
||||
PropertyOwner* _owner;
|
||||
|
||||
/// The identifier for this Property
|
||||
std::string _identifier;
|
||||
std::string _guiName;
|
||||
|
||||
/// The Dictionary containing all meta data necessary for external applications
|
||||
ghoul::Dictionary _metaData;
|
||||
|
||||
std::vector<std::function<void()>> _onChangeCallbacks;
|
||||
/// The callback function that will be invoked whenever the encapsulated value changes
|
||||
std::function<void()> _onChangeCallback;
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
|
||||
@@ -27,22 +27,115 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
struct lua_State;
|
||||
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
/**
|
||||
* The PropertyDelegate class is used by (among others) the TemplateProperty and the
|
||||
* NumericalProperty classes to outsource the definitions of class names, default values,
|
||||
* etc. Using the PropertyDelegate, it is possible to create new TemplateProperty types
|
||||
* without subclassing the TemplateProperty, but rather creating a specialized instance
|
||||
* of PropertyDelegate. See (http://openspace.itn.liu.se/trac/wiki/guides/properties) for
|
||||
* more detailed information.
|
||||
* \see TemplateProperty
|
||||
* \see NumericalProperty
|
||||
* \tparam T The full class for which this specialized instance of PropertyDelegate is
|
||||
* responsible. For example <code>T = TemplateProperty<std::string></code>.
|
||||
*/
|
||||
template <typename T>
|
||||
class PropertyDelegate {
|
||||
public:
|
||||
/**
|
||||
* This method returns the class name for the class <code>T</code>. The default
|
||||
* implementation will lead to a compile-time error if the class method is not
|
||||
* specialized.
|
||||
* \return The class name for the class <code>T</code>
|
||||
*/
|
||||
static std::string className();
|
||||
|
||||
/**
|
||||
* This method will return the preferred default value for the class <code>T</code>.
|
||||
* The default implementation will lead to a compile-time error if the class method is
|
||||
* not specialized.
|
||||
* \return The default value that the class <code>T</code> should use
|
||||
* \tparam U The type by which the class T is specialized. If
|
||||
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
|
||||
*/
|
||||
template <typename U>
|
||||
static U defaultValue();
|
||||
|
||||
/**
|
||||
* This method will return the preferred default minimum value for the class
|
||||
* <code>T</code>. The default implementation will lead to a compile-time error if the
|
||||
* class method is not specialized. This method is not used in TemplateProperty, but
|
||||
* only NumericalProperty, so the TemplateProperty does not require this method to be
|
||||
* specialized.
|
||||
* \return The default minimum value that the class <code>T</code> should use
|
||||
* \tparam U The type by which the class T is specialized. If
|
||||
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
|
||||
*/
|
||||
template <typename U>
|
||||
static U defaultMinimumValue();
|
||||
|
||||
/**
|
||||
* This method will return the preferred default maximum value for the class
|
||||
* <code>T</code>. The default implementation will lead to a compile-time error if the
|
||||
* class method is not specialized. This method is not used in TemplateProperty, but
|
||||
* only NumericalProperty, so the TemplateProperty does not require this method to be
|
||||
* specialized.
|
||||
* \return The default maximum value that the class <code>T</code> should use
|
||||
* \tparam U The type by which the class T is specialized. If
|
||||
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
|
||||
*/
|
||||
template <typename U>
|
||||
static U defaultMaximumValue();
|
||||
|
||||
/**
|
||||
* This method converts the top value from the Lua stack into a value of type
|
||||
* <code>U</code> and reports the <code>success</code> back to the caller. The default
|
||||
* implementation will lead to a compile-time error if the class method is not
|
||||
* specialized.
|
||||
* \param state The Lua state from which the value is retrieved
|
||||
* \param success Will be <code>true</code> if the conversion succeeded;
|
||||
* <code>false</code> otherwise
|
||||
* \return The value that was created by converting the top value from the stack
|
||||
* \tparam U The type by which the class T is specialized. If
|
||||
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
|
||||
*/
|
||||
template <typename U>
|
||||
static U fromLuaValue(lua_State* state, bool& success);
|
||||
|
||||
/**
|
||||
* This method converts the passed <code>value</code>, encodes it and places it on the
|
||||
* top value of the Lua stack and returns the success back to the caller. The default
|
||||
* implementation will lead to a compile-time error if the class method is not
|
||||
* specialized.
|
||||
* \param state The Lua state from which the value is retrieved
|
||||
* \param value The value that will be converted into a Lua object
|
||||
* \return <code>true</code> if the conversion succeeded; <code>false</code> otherwise
|
||||
* \tparam U The type by which the class T is specialized. If
|
||||
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
|
||||
*/
|
||||
template <typename U>
|
||||
static bool toLuaValue(lua_State* state, U value);
|
||||
|
||||
/**
|
||||
* Returns the Lua type that will be put onto the stack in the
|
||||
* PropertyDelegate::toLuaValue method and which will be consumed by the
|
||||
* PropertyDelegate::fromLuaValue method. The returned value can belong to the set of
|
||||
* Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
|
||||
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
|
||||
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
|
||||
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
|
||||
* <code>LUA_TTHREAD</code>. The default implementation will return
|
||||
* <code>LUA_TNONE</code>. The default implementation will lead to a compile-time
|
||||
* error if the class method is not specialized.
|
||||
* \return The Lua type that will be consumed or produced by the
|
||||
* PropertyDelegate::toLuaValue and PropertyDelegate::fromLuaValue methods.
|
||||
*/
|
||||
static int typeLua();
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
|
||||
@@ -24,22 +24,20 @@
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
template <typename T>
|
||||
std::string PropertyDelegate<T>::className() {
|
||||
static_assert(sizeof(T) == 0, "Unimplemented PropertyDelegate::className specialization");
|
||||
static_assert(sizeof(T) == 0,
|
||||
"Unimplemented PropertyDelegate::className specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::defaultValue() {
|
||||
static_assert(sizeof(T) == 0, "Unimplemented PropertyDelegate::defaultValue specialization");
|
||||
static_assert(sizeof(T) == 0,
|
||||
"Unimplemented PropertyDelegate::defaultValue specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -49,7 +47,6 @@ U PropertyDelegate<T>::defaultMinimumValue() {
|
||||
"Unimplemented PropertyDelegate::defaultMinimumValue specialization");
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::defaultMaximumValue() {
|
||||
@@ -57,5 +54,25 @@ U PropertyDelegate<T>::defaultMaximumValue() {
|
||||
"Unimplemented PropertyDelegate::defaultMaximumValue specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::fromLuaValue(lua_State* state, bool& success) {
|
||||
static_assert(sizeof(T) == 0,
|
||||
"Unimplemented PropertyDelegate::fromLuaValue specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
bool PropertyDelegate<T>::toLuaValue(lua_State* state, U value) {
|
||||
static_assert(sizeof(T) == 0,
|
||||
"Unimplemented PropertyDelegate::toLuaValue specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int PropertyDelegate<T>::typeLua() {
|
||||
static_assert(sizeof(T) == 0,
|
||||
"Unimplemented PropertyDelegate::luaType specialization");
|
||||
}
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -33,29 +33,178 @@
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
/**
|
||||
* A PropertyOwner can own Propertys or other PropertyOwner and provide access to both in
|
||||
* a unified way. The <code>identifier</code>s and <code>name</code>s of Propertys and
|
||||
* sub-owners must be unique to this PropertyOwner. A Property cannot have the same name
|
||||
* as a PropertyOwner owned by this PropertyOwner.
|
||||
* Propertys can be added using the Property::addProperty methods and be removed by the
|
||||
* Property::removeProperty method. The same holds true for sub-owners
|
||||
* (Property::addPropertySubOwner, Property::removePropertySubOwner). These methods will
|
||||
* inform the passed object about the new ownership automatically.
|
||||
* Stored properties can be accessed using the Property::properties method or the
|
||||
* Property::property method, providing an URI for the location of the property. If the
|
||||
* URI contains separators (<code>.</code>), the first name before the separator will be
|
||||
* used as a subOwner's name and the search will proceed recursively.
|
||||
*/
|
||||
class PropertyOwner {
|
||||
public:
|
||||
/// The separator that is used while accessing the properties and/or sub-owners
|
||||
static const char URISeparator = '.';
|
||||
|
||||
/// The constructor initializing the PropertyOwner's name to <code>""</code>
|
||||
PropertyOwner();
|
||||
|
||||
/**
|
||||
* The destructor will remove all Propertys and PropertyOwners it owns along with
|
||||
* itself.
|
||||
*/
|
||||
virtual ~PropertyOwner();
|
||||
|
||||
/**
|
||||
* Sets the name for this PropertyOwner. If the PropertyOwner does not have an owner
|
||||
* itself, the name must be globally unique. If the PropertyOwner has an owner, the
|
||||
* name must be unique to the owner (including the owner's properties). No uniqueness
|
||||
* check will be preformed here, but rather in the PropertyOwner::addProperty and
|
||||
* PropertyOwner::addPropertySubOwner methods).
|
||||
* \param name The name of this PropertyOwner. It may not contain any <code>.</code>s
|
||||
*/
|
||||
void setName(std::string name);
|
||||
virtual const std::string& name() const;
|
||||
|
||||
/**
|
||||
* Returns the name of this PropertyOwner.
|
||||
* \return The name of this PropertyOwner
|
||||
*/
|
||||
const std::string& name() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all Propertys directly owned by this PropertyOwner. This list not
|
||||
* include Propertys owned by other sub-owners.
|
||||
* \return A list of all Propertys directly owned by this PropertyOwner
|
||||
*/
|
||||
const std::vector<Property*>& properties() const;
|
||||
Property* property(const std::string& id) const;
|
||||
|
||||
/**
|
||||
* Retrieves a Property identified by <code>URI</code> from this PropertyOwner. If
|
||||
* <code>id</code> does not contain a <code>.</code> the identifier must refer to a
|
||||
* Property directly owned by this PropertyOwner. If the identifier contains one or
|
||||
* more <code>.</code>, the first part of the name will be recursively extracted and
|
||||
* used as a name for a sub-owner and only the last part of the identifier is
|
||||
* referring to a Property owned by PropertyOwner named by the second-but-last name.
|
||||
* \param URI The identifier of the Property that should be extracted. If the Property
|
||||
* cannot be found, <code>nullptr</code> is returned
|
||||
*/
|
||||
Property* property(const std::string& URI) const;
|
||||
|
||||
/**
|
||||
* This method checks if a Property with the provided <code>URI</code> exists in this
|
||||
* PropertyOwner (or any sub-owner). If the identifier contains one or more
|
||||
* <code>.</code>, the first part of the name will be recursively extracted and is
|
||||
* used as a name for a sub-owner and only the last part of the identifier is
|
||||
* referring to a Property owned by PropertyOwner named by the second-but-last name.
|
||||
* \return <code>true</code> if the <code>URI</code> refers to a Property;
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
bool hasProperty(const std::string& URI) const;
|
||||
|
||||
/**
|
||||
* Returns a list of all sub-owners this PropertyOwner has. Each name of a sub-owner
|
||||
* has to be unique with respect to other sub-owners as well as Property's owned by
|
||||
* this PropertyOwner.
|
||||
* \return A list of all sub-owners this PropertyOwner has
|
||||
*/
|
||||
const std::vector<PropertyOwner*>& subOwners() const;
|
||||
|
||||
/**
|
||||
* This method returns the direct sub-owner of this PropertyOwner with the provided
|
||||
* <code>name</code>. This means that <code>name</code> cannot contain any
|
||||
* <code>.</code> as this character is not allowed in PropertyOwner names. If the
|
||||
* <code>name</code> does not name a valid sub-owner of this PropertyOwner, a
|
||||
* <code>nullptr</code> will be returned.
|
||||
* \param name The name of the sub-owner that should be returned
|
||||
* \return The PropertyOwner with the given <code>name</code>, or <code>nullptr</code>
|
||||
*/
|
||||
PropertyOwner* subOwner(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this PropertyOwner owns a sub-owner with the provided
|
||||
* <code>name</code>; returns <code>false</code> otherwise.
|
||||
* \param name The name of the sub-owner that should be looked up
|
||||
* \return <code>true</code> if this PropertyOwner owns a sub-owner with the provided
|
||||
* <code>name</code>; returns <code>false</code> otherwise
|
||||
*/
|
||||
bool hasSubOwner(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* This method converts a provided <code>groupID</code>, used by the Propertys, into a
|
||||
* human-readable <code>name</code> which can be used by some external application.
|
||||
* \param groupID The group identifier whose human-readable name should be set
|
||||
* \param name The human-readable name for the group identifier
|
||||
*/
|
||||
void setPropertyGroupName(std::string groupID, std::string name);
|
||||
|
||||
/**
|
||||
* Returns the human-readable name for the <code>groupID</code> for the Propertys of
|
||||
* this PropertyOwner.
|
||||
* \param groupID The group identifier whose human-readable name should be returned
|
||||
* \return The human readable name for the Propertys identified by
|
||||
* <code>groupID</code>
|
||||
*/
|
||||
const std::string& propertyGroupName(const std::string& groupID) const;
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Assigns the Property <code>prop</code> to this PropertyOwner. This method will
|
||||
* check if the name of the Property is unique amongst Propertys and sub-owners in
|
||||
* this PropertyOwner. This method will also inform the Property about the change in
|
||||
* ownership by calling the Property::setPropertyOwner method.
|
||||
* \param prop The Property whose ownership is changed.
|
||||
*/
|
||||
void addProperty(Property* prop);
|
||||
|
||||
/// \see Property::addProperty(Property*)
|
||||
void addProperty(Property& prop);
|
||||
|
||||
/**
|
||||
* Adds the provided PropertyOwner to the list of sub-owners for this PropertyOwner.
|
||||
* This means that the name of the <code>owner</code> has to be unique amonst the
|
||||
* direct Property's as well as other PropertyOwner's that this PropertyOwner owns.
|
||||
* This uniqueness will be tested in this method.
|
||||
* \param owner The owner that should be assigned to this PropertyOwner
|
||||
*/
|
||||
void addPropertySubOwner(PropertyOwner* owner);
|
||||
|
||||
/// \see PropertyOwner::addPropertySubOwner(PropertyOwner*)
|
||||
void addPropertySubOwner(PropertyOwner& owner);
|
||||
|
||||
/**
|
||||
* Removes the Property from this PropertyOwner. Notifies the Property about this
|
||||
* change by calling the Property::setPropertyOwner method with a <code>nullptr</code>
|
||||
* as parameter.
|
||||
* \param prop The Property that should be removed from this PropertyOwner
|
||||
*/
|
||||
void removeProperty(Property* prop);
|
||||
|
||||
/// \see PropertyOwner::removeProperty(Property*)
|
||||
void removeProperty(Property& prop);
|
||||
|
||||
/**
|
||||
* Removes the sub-owner from this PropertyOwner.
|
||||
* \param owner The PropertyOwner that should be removed
|
||||
*/
|
||||
void removePropertySubOwner(PropertyOwner* owner);
|
||||
|
||||
/// \see PropertyOwner::removePropertySubOwner(PropertyOwner*)
|
||||
void removePropertySubOwner(PropertyOwner& owner);
|
||||
|
||||
private:
|
||||
/// The name of this PropertyOwner
|
||||
std::string _name;
|
||||
/// A list of all owned Property's
|
||||
std::vector<Property*> _properties;
|
||||
/// A list of all sub-owners
|
||||
std::vector<PropertyOwner*> _subOwners;
|
||||
/// The associations between group identifiers of Property's and human-readable names
|
||||
std::map<std::string, std::string> _groupNames;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,23 +30,7 @@
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
class StringProperty : public TemplateProperty<std::string> {
|
||||
public:
|
||||
StringProperty(std::string identifier, std::string guiName);
|
||||
StringProperty(std::string identifier, std::string guiName, std::string value);
|
||||
|
||||
using TemplateProperty<std::string>::operator=;
|
||||
};
|
||||
|
||||
template <>
|
||||
std::string PropertyDelegate<TemplateProperty<std::string>>::className();
|
||||
|
||||
template <>
|
||||
template <>
|
||||
std::string PropertyDelegate<TemplateProperty<std::string>>::defaultValue<std::string>();
|
||||
|
||||
//REGISTER_TEMPLATEPROPERTY_HEADER(StringProperty, std::string);
|
||||
|
||||
REGISTER_TEMPLATEPROPERTY_HEADER(StringProperty, std::string);
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -30,24 +30,144 @@
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
/**
|
||||
* This concrete subclass of Property handles a single parameter value that is of type
|
||||
* <code>T</code>. It provides all the necessary methods to automatically access the
|
||||
* value. One notable instantiation of this class is StringProperty, using
|
||||
* <code>T = std::string</code> while NumericalProperty is a templated subclass dealing
|
||||
* with numerical parameter types.
|
||||
* The accessor operator and assignment operators are overloaded, so that the
|
||||
* TemplateProperty can be used just in the same way as a regular member variable. In the
|
||||
* case that these cannot not be used inline, the Property::get method will work.
|
||||
* The default value for the stored value of this TemplateProperty is retrieved via a call
|
||||
* to the PropertyDelegate::defaultValue method, providing the template parameter
|
||||
* <code>T</code> as argument. When a new TemplateProperty is required, that method needs
|
||||
* to be specialized for the new type or a compile-time error will occur
|
||||
* (See http://openspace.itn.liu.se/trac/wiki/guides/properties).
|
||||
* \tparam T The type of value that is stored in this TemplateProperty
|
||||
* \see Property
|
||||
* \see NumericalProperty
|
||||
* \see PropertyDelegate
|
||||
*/
|
||||
template <typename T>
|
||||
class TemplateProperty : public Property {
|
||||
public:
|
||||
/**
|
||||
* The constructor initializing the TemplateProperty with the provided
|
||||
* <code>identifier</code> and human-readable <code>guiName</code>. The default value
|
||||
* for the stored type <code>T</code> is retrieved using the PropertyDelegate's
|
||||
* PropertyDelegate::defaultValue method, which must be specialized for new types or
|
||||
* a compile-error will occur.
|
||||
* \param identifier The identifier that is used for this TemplateProperty
|
||||
* \param guiName The human-readable GUI name for this TemplateProperty
|
||||
*/
|
||||
TemplateProperty(std::string identifier, std::string guiName);
|
||||
|
||||
/**
|
||||
* The constructor initializing the TemplateProperty with the provided
|
||||
* <code>identifier</code>, human-readable <code>guiName</code> and provided
|
||||
* <code>value</code>.
|
||||
*/
|
||||
TemplateProperty(std::string identifier, std::string guiName, T value);
|
||||
|
||||
/**
|
||||
* Returns the class name for this TemplateProperty. The default implementation makes
|
||||
* a call to the PropertyDelegate::className method with the template parameter
|
||||
* <code>T</code> as argument. For this to work, that method needs to be specialized
|
||||
* to return the correct class name for the new template parameter T, or a
|
||||
* compile-time error will occur.
|
||||
* \return The class name for the TemplateProperty
|
||||
*/
|
||||
virtual std::string className() const override;
|
||||
|
||||
/**
|
||||
* Returns the stored value packed into a <code>boost::any</code> object.
|
||||
* \return The stored value packed into a <code>boost::any</code> object
|
||||
*/
|
||||
virtual boost::any get() const override;
|
||||
|
||||
/**
|
||||
* Sets the value fro the provided <code>boost::any</code> object. If the types
|
||||
* between <code>T</code> and <code>value</code> disagree, an error is logged and the
|
||||
* stored value remains unchanged.
|
||||
*/
|
||||
virtual void set(boost::any value) override;
|
||||
|
||||
/**
|
||||
* Returns the <code>std::type_info</code> describing the template parameter
|
||||
* <code>T</code>. It can be used to test against a <code>boost::any</code> value
|
||||
* before trying to assign it.
|
||||
* \return The type info object describing the template parameter <code>T</code>
|
||||
*/
|
||||
virtual const std::type_info& type() const override;
|
||||
|
||||
/**
|
||||
* This method encodes the stored value into a Lua object and pushes that object onto
|
||||
* the stack. The encoding is performed by calling PropertyDelegate::toLuaValue with
|
||||
* the template parameter <code>T</code> as an argument. This method has to be
|
||||
* specialized for each new type, or a compile-time error will occur.
|
||||
* \param state The Lua state onto which the encoded object will be pushed
|
||||
* \return <code>true</code> if the encoding succeeded; <code>false</code> otherwise
|
||||
*/
|
||||
bool getLua(lua_State* state) const override;
|
||||
|
||||
/**
|
||||
* Sets the value of this TemplateProprty by decoding the object at the top of the Lua
|
||||
* stack and, if successful, assigning it using the Property::set method. The decoding
|
||||
* is performed by calling the PropertyDelegate::fromLuaValue with the template
|
||||
* parameter <code>T</code> as argument. If the decoding is successful, the new value
|
||||
* is set, otherwise it remains unchanged.
|
||||
* \param state The Lua state from which the value will be decoded
|
||||
* \return <code>true</code> if the decoding succeeded; <code>false</code> otherwise
|
||||
*/
|
||||
bool setLua(lua_State* state) override;
|
||||
|
||||
/// \see Property::typeLua
|
||||
int typeLua() const override;
|
||||
|
||||
/**
|
||||
* This operator allows the TemplateProperty to be used almost transparently as if it
|
||||
* was of the type <code>T</code>. It makes assignments such as
|
||||
* <code>T v = property;</code> possible by allowing implicit casts (even though,
|
||||
* internally, not casts are performed. This method is next to zero overhead).
|
||||
* \return The internal representation of the Property
|
||||
*/
|
||||
operator T();
|
||||
|
||||
/**
|
||||
* This operator allows the TemplateProperty to be used almost transparently as if it
|
||||
* was of the type <code>T</code>. It makes assignments such as
|
||||
* <code>T v = property;</code> possible by allowing implicit casts (even though,
|
||||
* internally, not casts are performed. This method is next to zero overhead).
|
||||
* \return The internal representation of the Property
|
||||
*/
|
||||
operator T() const;
|
||||
|
||||
/**
|
||||
* The assignment operator allows the TemplateProperty's value to be set without using
|
||||
* the TemplateProperty::set method. It will be done internally by thos method and it
|
||||
* allows assignments such as <code>prop = T(1)</code>.
|
||||
* \param val The value that should be set.
|
||||
*/
|
||||
TemplateProperty<T>& operator=(T val);
|
||||
|
||||
/**
|
||||
* These method sets the stored value to the provided value <code>val</code>,
|
||||
* moving it into place. This move only happens if the provided value <code>val</code>
|
||||
* is different from the stored value, which needs an operator== to exist for the type
|
||||
* <code>T</code>. If the value are different, the listeners are notified.
|
||||
* \param val The new value for this TemplateProperty
|
||||
*/
|
||||
void setValue(T val);
|
||||
|
||||
/**
|
||||
* Returns the currently stored value.
|
||||
* \return The currently stored value
|
||||
*/
|
||||
T value() const;
|
||||
|
||||
protected:
|
||||
/// The value that this TemplateProperty currently stores
|
||||
T _value;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,26 +25,82 @@
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
// The following macros can be used to quickly generate the necessary PropertyDelegate
|
||||
// specializations required by the TemplateProperty class. Use the
|
||||
// REGISTER_TEMPLATEPROPERTY_HEADER macro in the header file and the
|
||||
// REGISTER_TEMPLATEPROPERTY_SOURCE macro in the source file of your new specialization of
|
||||
// a TemplateProperty
|
||||
|
||||
|
||||
// CLASS_NAME = The string that the Property::className() should return as well as the
|
||||
// C++ class name for which a typedef will be created
|
||||
// TYPE = The template parameter T for which the TemplateProperty is specialized
|
||||
#define REGISTER_TEMPLATEPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef TemplateProperty<TYPE> CLASS_NAME; \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>();
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue(lua_State* state, \
|
||||
bool& success); \
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue(lua_State* state, \
|
||||
TYPE value); \
|
||||
template <> \
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua();
|
||||
|
||||
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE) \
|
||||
// CLASS_NAME = The string that the Property::className() should return as well as the
|
||||
// C++ class name for which a typedef will be created
|
||||
// TYPE = The template parameter T for which the TemplateProperty is specialized
|
||||
// DEFAULT_VALUE = The value (as type T) which should be used as a default value
|
||||
// FROM_LUA_LAMBDA_EXPRESSION = A lambda expression receiving a lua_State* as the first
|
||||
// parameter, a bool& as the second parameter and returning
|
||||
// a value T. It is used by the fromLua method of
|
||||
// TemplateProperty. The lambda expression must extract the
|
||||
// stored value from the lua_State, return the value and
|
||||
// report success in the second argument
|
||||
// TO_LUA_LAMBDA_EXPRESSION = A lambda expression receiving a lua_State*, a value T and
|
||||
// returning a bool. The lambda expression must encode the
|
||||
// value T onto the lua_State stack and return the success
|
||||
// LUA_TYPE = The Lua type that will be produced/consumed by the previous
|
||||
// Lambda expressions
|
||||
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
|
||||
FROM_LUA_LAMBDA_EXPRESSION, \
|
||||
TO_LUA_LAMBDA_EXPRESSION, LUA_TYPE) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() { \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
|
||||
{ \
|
||||
return #CLASS_NAME; \
|
||||
\
|
||||
} \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>() { \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>() \
|
||||
{ \
|
||||
return DEFAULT_VALUE; \
|
||||
\
|
||||
}
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State * state, \
|
||||
bool& success) \
|
||||
{ \
|
||||
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(lua_State * state, \
|
||||
TYPE value) \
|
||||
{ \
|
||||
return TO_LUA_LAMBDA_EXPRESSION(state, value); \
|
||||
} \
|
||||
template <> \
|
||||
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua() \
|
||||
{ \
|
||||
return LUA_TYPE; \
|
||||
}
|
||||
|
||||
// Delegating constructors are necessary; automatic template deduction cannot
|
||||
// deduce template argument for 'U' if 'default' methods are used as default values in
|
||||
@@ -52,15 +108,17 @@ namespace properties {
|
||||
|
||||
template <typename T>
|
||||
TemplateProperty<T>::TemplateProperty(std::string identifier, std::string guiName)
|
||||
: TemplateProperty<T>(std::move(identifier), std::move(guiName),
|
||||
PropertyDelegate<TemplateProperty<T>>::template defaultValue<T>()) {
|
||||
: TemplateProperty<T>(
|
||||
std::move(identifier), std::move(guiName),
|
||||
PropertyDelegate<TemplateProperty<T>>::template defaultValue<T>())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
TemplateProperty<T>::TemplateProperty(std::string identifier, std::string guiName,
|
||||
T value)
|
||||
: Property(std::move(identifier), std::move(guiName))
|
||||
, _value(value) {
|
||||
, _value(std::move(value)) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -73,6 +131,11 @@ TemplateProperty<T>::operator T() {
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
TemplateProperty<T>::operator T() const {
|
||||
return _value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
TemplateProperty<T>& TemplateProperty<T>::operator=(T val) {
|
||||
setValue(val);
|
||||
@@ -88,7 +151,11 @@ T openspace::properties::TemplateProperty<T>::value() const
|
||||
template <typename T>
|
||||
void openspace::properties::TemplateProperty<T>::setValue(T val)
|
||||
{
|
||||
_value = val;
|
||||
const bool changed = (val != _value);
|
||||
if (changed) {
|
||||
_value = std::move(val);
|
||||
notifyListener();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,10 +167,15 @@ boost::any TemplateProperty<T>::get() const {
|
||||
template <typename T>
|
||||
void TemplateProperty<T>::set(boost::any value) {
|
||||
try {
|
||||
_value = boost::any_cast<T>(std::move(value));
|
||||
T v = boost::any_cast<T>(std::move(value));
|
||||
if (v != _value) {
|
||||
_value = std::move(v);
|
||||
notifyListener();
|
||||
}
|
||||
}
|
||||
catch (boost::bad_any_cast&) {
|
||||
LERRORC("TemplateProperty", "Illegal cast to '" << typeid(T).name() << "'");
|
||||
LERRORC("TemplateProperty", "Illegal cast from '" << value.type().name()
|
||||
<< "' to '" << typeid(T).name() << "'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,5 +184,27 @@ const std::type_info& TemplateProperty<T>::type() const {
|
||||
return typeid(T);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setLua(lua_State* state)
|
||||
{
|
||||
bool success;
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(state, success);
|
||||
if (success)
|
||||
set(boost::any(thisValue));
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::getLua(lua_State* state) const
|
||||
{
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toLuaValue<T>(state, _value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int TemplateProperty<T>::typeLua() const {
|
||||
return PropertyDelegate<TemplateProperty<T>>::typeLua();
|
||||
}
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
@@ -49,25 +49,6 @@ REGISTER_NUMERICALPROPERTY_HEADER(UVec2Property, glm::uvec2);
|
||||
REGISTER_NUMERICALPROPERTY_HEADER(UVec3Property, glm::uvec3);
|
||||
REGISTER_NUMERICALPROPERTY_HEADER(UVec4Property, glm::uvec4);
|
||||
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(CharProperty, char);
|
||||
////REGISTER_NUMERICALPROPERTY_HEADER(Char16Property, char16_t);
|
||||
////REGISTER_NUMERICALPROPERTY_HEADER(Char32Property, char32_t);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(WCharProperty, wchar_t);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(SignedCharProperty, signed char);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(UCharProperty, unsigned char);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(ShortProperty, short);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(UShortProperty, unsigned short);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(IntProperty, int);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(UIntProperty, unsigned int);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(LongProperty, long);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(ULongProperty, unsigned long);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(LongLongProperty, long long);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(ULongLongProperty, unsigned long long);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(FloatProperty, float);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(DoubleProperty, double);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(LongDoubleProperty, long double);
|
||||
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
@@ -29,12 +29,15 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace properties {
|
||||
class Property;
|
||||
}
|
||||
class SceneGraph;
|
||||
class SceneGraphNode;
|
||||
|
||||
SceneGraph* getSceneGraph();
|
||||
|
||||
SceneGraphNode* getSceneGraphNode(const std::string& name);
|
||||
SceneGraph* sceneGraph();
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name);
|
||||
properties::Property* property(const std::string& uri);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
#ifndef __RENDERABLE_H__
|
||||
#define __RENDERABLE_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
#include <openspace/util/camera.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -51,10 +52,16 @@ public:
|
||||
virtual void render(const Camera* camera, const psc& thisPosition) = 0;
|
||||
virtual void update();
|
||||
|
||||
bool isVisible() const;
|
||||
|
||||
protected:
|
||||
// Renderable();
|
||||
std::string findPath(const std::string& path);
|
||||
|
||||
private:
|
||||
properties::BoolProperty _enabled;
|
||||
|
||||
PowerScaledScalar boundingSphere_;
|
||||
std::string _relativePath;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
71
include/openspace/rendering/renderablefieldlines.h
Normal file
71
include/openspace/rendering/renderablefieldlines.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef RENDERABLEFIELDLINES_H_
|
||||
#define RENDERABLEFIELDLINES_H_
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
|
||||
namespace openspace {
|
||||
struct LinePoint;
|
||||
|
||||
class RenderableFieldlines : public Renderable {
|
||||
public:
|
||||
RenderableFieldlines(const ghoul::Dictionary& dictionary);
|
||||
~RenderableFieldlines();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
|
||||
virtual void render(const Camera *camera, const psc& thisPosition);
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
std::vector<std::vector<LinePoint> > getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary);
|
||||
|
||||
std::vector<ghoul::Dictionary> _hintsDictionaries;
|
||||
std::vector<std::string> _filenames;
|
||||
std::vector<glm::vec3> _seedPoints;
|
||||
|
||||
ghoul::opengl::ProgramObject *_fieldlinesProgram;
|
||||
GLuint _VAO, _seedpointVAO;
|
||||
|
||||
ghoul::filesystem::File* _vertexSourceFile;
|
||||
ghoul::filesystem::File* _fragmentSourceFile;
|
||||
|
||||
std::vector<GLint> _lineStart;
|
||||
std::vector<GLsizei> _lineCount;
|
||||
|
||||
bool _programUpdateOnSave;
|
||||
bool _update;
|
||||
void safeShaderCompilation();
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
#endif // RENDERABLEFIELDLINES_H_
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/io/rawvolumereader.h>
|
||||
|
||||
@@ -37,23 +36,19 @@ namespace openspace {
|
||||
|
||||
class RenderableVolume: public Renderable {
|
||||
public:
|
||||
|
||||
// constructors & destructor
|
||||
RenderableVolume(const ghoul::Dictionary& dictionary);
|
||||
~RenderableVolume();
|
||||
|
||||
protected:
|
||||
std::string findPath(const std::string& path);
|
||||
ghoul::opengl::Texture* loadVolume(const std::string& filepath, const ghoul::Dictionary& hintsDictionary);
|
||||
glm::vec3 getVolumeOffset(const std::string& filepath, const ghoul::Dictionary& hintsDictionary);
|
||||
ghoul::RawVolumeReader::ReadHints readHints(const ghoul::Dictionary& dictionary);
|
||||
ghoul::opengl::Texture* loadTransferFunction(const std::string& filepath);
|
||||
|
||||
private:
|
||||
|
||||
// relative path
|
||||
std::string _relativePath;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,105 +1,106 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __RENDERABLEVOLUMECL_H__
|
||||
#define __RENDERABLEVOLUMECL_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderablevolume.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/framebufferobject.h>
|
||||
#include <ghoul/opencl/clcontext.h>
|
||||
#include <ghoul/opencl/clcommandqueue.h>
|
||||
#include <ghoul/opencl/clprogram.h>
|
||||
#include <ghoul/opencl/clkernel.h>
|
||||
#include <ghoul/opencl/clworksize.h>
|
||||
#include <ghoul/io/rawvolumereader.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
|
||||
#define SGCT_WINDOWS_INCLUDE
|
||||
#include <sgct.h>
|
||||
|
||||
namespace sgct_utils {
|
||||
class SGCTBox;
|
||||
}
|
||||
|
||||
//#include <vector>
|
||||
//#include <string>
|
||||
#ifdef __APPLE__
|
||||
#include <memory>
|
||||
#else
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderableVolumeCL: public RenderableVolume {
|
||||
public:
|
||||
|
||||
// constructors & destructor
|
||||
RenderableVolumeCL(const ghoul::Dictionary& dictionary);
|
||||
~RenderableVolumeCL();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
|
||||
virtual void render(const Camera *camera, const psc& thisPosition);
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
|
||||
void safeKernelCompilation();
|
||||
|
||||
std::string _filename;
|
||||
ghoul::RawVolumeReader::ReadHints _hints;
|
||||
float _stepSize;
|
||||
ghoul::opengl::FramebufferObject* _fbo;
|
||||
ghoul::opengl::Texture* _backTexture;
|
||||
ghoul::opengl::Texture* _frontTexture;
|
||||
ghoul::opengl::Texture* _volume;
|
||||
ghoul::opengl::Texture* _output;
|
||||
ghoul::opengl::ProgramObject *_fboProgram;
|
||||
ghoul::opengl::ProgramObject *_quadProgram;
|
||||
sgct_utils::SGCTBox* _boundingBox;
|
||||
GLuint _screenQuad;
|
||||
|
||||
ghoul::opencl::CLContext _context;
|
||||
ghoul::opencl::CLCommandQueue _commands;
|
||||
ghoul::opencl::CLProgram _program;
|
||||
ghoul::opencl::CLKernel _kernel;
|
||||
ghoul::opencl::CLWorkSize* _ws;
|
||||
cl_mem _clBackTexture, _clFrontTexture, _clVolume, _clOutput;
|
||||
|
||||
ghoul::filesystem::File* _kernelSourceFile;
|
||||
bool _kernelUpdateOnSave;
|
||||
std::mutex* _kernelMutex;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
// This is still in the repository to be cannibalized for a possible rewrite (ab)
|
||||
///*****************************************************************************************
|
||||
// * *
|
||||
// * OpenSpace *
|
||||
// * *
|
||||
// * Copyright (c) 2014 *
|
||||
// * *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
// * software and associated documentation files (the "Software"), to deal in the Software *
|
||||
// * without restriction, including without limitation the rights to use, copy, modify, *
|
||||
// * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
// * permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
// * conditions: *
|
||||
// * *
|
||||
// * The above copyright notice and this permission notice shall be included in all copies *
|
||||
// * or substantial portions of the Software. *
|
||||
// * *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
// * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
// * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
// * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
// * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
// * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
// ****************************************************************************************/
|
||||
//
|
||||
//#ifndef __RENDERABLEVOLUMECL_H__
|
||||
//#define __RENDERABLEVOLUMECL_H__
|
||||
//
|
||||
//// open space includes
|
||||
//#include <openspace/rendering/renderablevolume.h>
|
||||
//
|
||||
//// ghoul includes
|
||||
//#include <ghoul/opengl/programobject.h>
|
||||
//#include <ghoul/opengl/texture.h>
|
||||
//#include <ghoul/opengl/framebufferobject.h>
|
||||
//#include <ghoul/opencl/clcontext.h>
|
||||
//#include <ghoul/opencl/clcommandqueue.h>
|
||||
//#include <ghoul/opencl/clprogram.h>
|
||||
//#include <ghoul/opencl/clkernel.h>
|
||||
//#include <ghoul/opencl/clworksize.h>
|
||||
//#include <ghoul/io/rawvolumereader.h>
|
||||
//#include <ghoul/filesystem/file.h>
|
||||
//
|
||||
//#define SGCT_WINDOWS_INCLUDE
|
||||
//#include <sgct.h>
|
||||
//
|
||||
//namespace sgct_utils {
|
||||
// class SGCTBox;
|
||||
//}
|
||||
//
|
||||
////#include <vector>
|
||||
////#include <string>
|
||||
//#ifdef __APPLE__
|
||||
// #include <memory>
|
||||
//#else
|
||||
// #include <mutex>
|
||||
//#endif
|
||||
//
|
||||
//namespace openspace {
|
||||
//
|
||||
//class RenderableVolumeCL: public RenderableVolume {
|
||||
//public:
|
||||
//
|
||||
// // constructors & destructor
|
||||
// RenderableVolumeCL(const ghoul::Dictionary& dictionary);
|
||||
// ~RenderableVolumeCL();
|
||||
//
|
||||
// bool initialize();
|
||||
// bool deinitialize();
|
||||
//
|
||||
// virtual void render(const Camera *camera, const psc& thisPosition);
|
||||
// virtual void update();
|
||||
//
|
||||
//private:
|
||||
//
|
||||
// void safeKernelCompilation();
|
||||
//
|
||||
// std::string _filename;
|
||||
// ghoul::RawVolumeReader::ReadHints _hints;
|
||||
// float _stepSize;
|
||||
// ghoul::opengl::FramebufferObject* _fbo;
|
||||
// ghoul::opengl::Texture* _backTexture;
|
||||
// ghoul::opengl::Texture* _frontTexture;
|
||||
// ghoul::opengl::Texture* _volume;
|
||||
// ghoul::opengl::Texture* _output;
|
||||
// ghoul::opengl::ProgramObject *_fboProgram;
|
||||
// ghoul::opengl::ProgramObject *_quadProgram;
|
||||
// sgct_utils::SGCTBox* _boundingBox;
|
||||
// GLuint _screenQuad;
|
||||
//
|
||||
// ghoul::opencl::CLContext _context;
|
||||
// ghoul::opencl::CLCommandQueue _commands;
|
||||
// ghoul::opencl::CLProgram _program;
|
||||
// ghoul::opencl::CLKernel _kernel;
|
||||
// ghoul::opencl::CLWorkSize* _ws;
|
||||
// cl_mem _clBackTexture, _clFrontTexture, _clVolume, _clOutput;
|
||||
//
|
||||
// ghoul::filesystem::File* _kernelSourceFile;
|
||||
// bool _kernelUpdateOnSave;
|
||||
// std::mutex* _kernelMutex;
|
||||
//
|
||||
//};
|
||||
//
|
||||
//} // namespace openspace
|
||||
//
|
||||
//#endif
|
||||
@@ -1,118 +1,119 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __RENDERABLEVOLUMEEXPERT_H__
|
||||
#define __RENDERABLEVOLUMEEXPERT_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderablevolume.h>
|
||||
#include <openspace/rendering/volumeraycasterbox.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/framebufferobject.h>
|
||||
#include <ghoul/opencl/clcontext.h>
|
||||
#include <ghoul/opencl/clcommandqueue.h>
|
||||
#include <ghoul/opencl/clprogram.h>
|
||||
#include <ghoul/opencl/clkernel.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <memory>
|
||||
#else
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
namespace ghoul {
|
||||
namespace opencl {
|
||||
class CLWorkSize;
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderableVolumeExpert: public RenderableVolume {
|
||||
public:
|
||||
|
||||
// constructors & destructor
|
||||
RenderableVolumeExpert(const ghoul::Dictionary& dictionary);
|
||||
~RenderableVolumeExpert();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
|
||||
virtual void render(const Camera *camera, const psc& thisPosition);
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
|
||||
// private methods
|
||||
void safeKernelCompilation();
|
||||
void safeUpdateTexture(const ghoul::filesystem::File& file);
|
||||
|
||||
// Volumes
|
||||
std::vector<std::string> _volumePaths;
|
||||
std::vector<ghoul::Dictionary> _volumeHints;
|
||||
|
||||
// Textures
|
||||
ghoul::opengl::Texture* _output;
|
||||
std::vector<ghoul::opengl::Texture*> _volumes;
|
||||
std::vector<ghoul::opengl::Texture*> _transferFunctions;
|
||||
std::vector<ghoul::filesystem::File*> _transferFunctionsFiles;
|
||||
|
||||
// opencl texture memory pointers
|
||||
cl_mem _clBackTexture;
|
||||
cl_mem _clFrontTexture;
|
||||
cl_mem _clOutput;
|
||||
std::vector<cl_mem> _clVolumes;
|
||||
std::vector<cl_mem> _clTransferFunctions;
|
||||
|
||||
// opencl program
|
||||
ghoul::opencl::CLContext _context;
|
||||
ghoul::opencl::CLCommandQueue _commands;
|
||||
ghoul::opencl::CLProgram _program;
|
||||
ghoul::opencl::CLKernel _kernel;
|
||||
ghoul::opencl::CLWorkSize* _ws;
|
||||
ghoul::filesystem::File* _kernelSourceFile;
|
||||
std::vector<std::pair<ghoul::opencl::CLProgram::Option, bool> > _kernelOptions;
|
||||
std::vector<std::string> _kernelIncludes;
|
||||
std::vector<std::pair<std::string,std::string> > _kernelDefinitions;
|
||||
bool _programUpdateOnSave;
|
||||
|
||||
// mutexes to prevent inconsistencies
|
||||
std::mutex* _kernelLock;
|
||||
std::mutex* _textureLock;
|
||||
|
||||
ghoul::opengl::ProgramObject *_quadProgram;
|
||||
GLuint _screenQuad;
|
||||
|
||||
VolumeRaycasterBox* _colorBoxRenderer;
|
||||
glm::vec3 _boxScaling;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
// This is still in the repository to be cannibalized for a possible rewrite (ab)
|
||||
///*****************************************************************************************
|
||||
// * *
|
||||
// * OpenSpace *
|
||||
// * *
|
||||
// * Copyright (c) 2014 *
|
||||
// * *
|
||||
// * Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
// * software and associated documentation files (the "Software"), to deal in the Software *
|
||||
// * without restriction, including without limitation the rights to use, copy, modify, *
|
||||
// * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
// * permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
// * conditions: *
|
||||
// * *
|
||||
// * The above copyright notice and this permission notice shall be included in all copies *
|
||||
// * or substantial portions of the Software. *
|
||||
// * *
|
||||
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
// * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
// * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
// * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
// * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
// * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
// ****************************************************************************************/
|
||||
//
|
||||
//#ifndef __RENDERABLEVOLUMEEXPERT_H__
|
||||
//#define __RENDERABLEVOLUMEEXPERT_H__
|
||||
//
|
||||
//// open space includes
|
||||
//#include <openspace/rendering/renderablevolume.h>
|
||||
//#include <openspace/rendering/volumeraycasterbox.h>
|
||||
//
|
||||
//// ghoul includes
|
||||
//#include <ghoul/opengl/programobject.h>
|
||||
//#include <ghoul/opengl/texture.h>
|
||||
//#include <ghoul/opengl/framebufferobject.h>
|
||||
//#include <ghoul/opencl/clcontext.h>
|
||||
//#include <ghoul/opencl/clcommandqueue.h>
|
||||
//#include <ghoul/opencl/clprogram.h>
|
||||
//#include <ghoul/opencl/clkernel.h>
|
||||
//#include <ghoul/filesystem/file.h>
|
||||
//
|
||||
//#ifdef __APPLE__
|
||||
// #include <memory>
|
||||
//#else
|
||||
// #include <mutex>
|
||||
//#endif
|
||||
//
|
||||
//namespace ghoul {
|
||||
// namespace opencl {
|
||||
// class CLWorkSize;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//namespace openspace {
|
||||
//
|
||||
//class RenderableVolumeExpert: public RenderableVolume {
|
||||
//public:
|
||||
//
|
||||
// // constructors & destructor
|
||||
// RenderableVolumeExpert(const ghoul::Dictionary& dictionary);
|
||||
// ~RenderableVolumeExpert();
|
||||
//
|
||||
// bool initialize();
|
||||
// bool deinitialize();
|
||||
//
|
||||
// virtual void render(const Camera *camera, const psc& thisPosition);
|
||||
// virtual void update();
|
||||
//
|
||||
//private:
|
||||
//
|
||||
// // private methods
|
||||
// void safeKernelCompilation();
|
||||
// void safeUpdateTexture(const ghoul::filesystem::File& file);
|
||||
//
|
||||
// // Volumes
|
||||
// std::vector<std::string> _volumePaths;
|
||||
// std::vector<ghoul::Dictionary> _volumeHints;
|
||||
//
|
||||
// // Textures
|
||||
// ghoul::opengl::Texture* _output;
|
||||
// std::vector<ghoul::opengl::Texture*> _volumes;
|
||||
// std::vector<ghoul::opengl::Texture*> _transferFunctions;
|
||||
// std::vector<ghoul::filesystem::File*> _transferFunctionsFiles;
|
||||
//
|
||||
// // opencl texture memory pointers
|
||||
// cl_mem _clBackTexture;
|
||||
// cl_mem _clFrontTexture;
|
||||
// cl_mem _clOutput;
|
||||
// std::vector<cl_mem> _clVolumes;
|
||||
// std::vector<cl_mem> _clTransferFunctions;
|
||||
//
|
||||
// // opencl program
|
||||
// ghoul::opencl::CLContext _context;
|
||||
// ghoul::opencl::CLCommandQueue _commands;
|
||||
// ghoul::opencl::CLProgram _program;
|
||||
// ghoul::opencl::CLKernel _kernel;
|
||||
// ghoul::opencl::CLWorkSize* _ws;
|
||||
// ghoul::filesystem::File* _kernelSourceFile;
|
||||
// std::vector<std::pair<ghoul::opencl::CLProgram::Option, bool> > _kernelOptions;
|
||||
// std::vector<std::string> _kernelIncludes;
|
||||
// std::vector<std::pair<std::string,std::string> > _kernelDefinitions;
|
||||
// bool _programUpdateOnSave;
|
||||
//
|
||||
// // mutexes to prevent inconsistencies
|
||||
// std::mutex* _kernelLock;
|
||||
// std::mutex* _textureLock;
|
||||
//
|
||||
// ghoul::opengl::ProgramObject *_quadProgram;
|
||||
// GLuint _screenQuad;
|
||||
//
|
||||
// VolumeRaycasterBox* _colorBoxRenderer;
|
||||
// glm::vec3 _boxScaling;
|
||||
//
|
||||
//};
|
||||
//
|
||||
//} // namespace openspace
|
||||
//
|
||||
//#endif
|
||||
@@ -25,7 +25,6 @@
|
||||
#ifndef __RENDERABLEVOLUMEGL_H__
|
||||
#define __RENDERABLEVOLUMEGL_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderablevolume.h>
|
||||
|
||||
// ghoul includes
|
||||
@@ -35,25 +34,10 @@
|
||||
#include <ghoul/io/rawvolumereader.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
|
||||
#define SGCT_WINDOWS_INCLUDE
|
||||
#include <sgct.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <memory>
|
||||
#else
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
namespace sgct_utils {
|
||||
class SGCTBox;
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderableVolumeGL: public RenderableVolume {
|
||||
public:
|
||||
|
||||
// constructors & destructor
|
||||
RenderableVolumeGL(const ghoul::Dictionary& dictionary);
|
||||
~RenderableVolumeGL();
|
||||
|
||||
@@ -64,29 +48,31 @@ public:
|
||||
virtual void update();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
ghoul::Dictionary _hintsDictionary;
|
||||
|
||||
std::string _filename;
|
||||
ghoul::RawVolumeReader::ReadHints _hints;
|
||||
float _stepSize;
|
||||
ghoul::opengl::FramebufferObject* _fbo;
|
||||
ghoul::opengl::Texture* _backTexture;
|
||||
ghoul::opengl::Texture* _frontTexture;
|
||||
|
||||
std::string _transferFunctionName;
|
||||
std::string _volumeName;
|
||||
|
||||
std::string _transferFunctionPath;
|
||||
std::string _samplerFilename;
|
||||
|
||||
ghoul::filesystem::File* _transferFunctionFile;
|
||||
|
||||
ghoul::opengl::Texture* _volume;
|
||||
ghoul::opengl::ProgramObject *_fboProgram, *_twopassProgram;
|
||||
sgct_utils::SGCTBox* _boundingBox;
|
||||
GLuint _screenQuad;
|
||||
|
||||
std::mutex* _shaderMutex;
|
||||
|
||||
ghoul::filesystem::File* _vertexSourceFile;
|
||||
ghoul::filesystem::File* _fragmentSourceFile;
|
||||
bool _programUpdateOnSave;
|
||||
|
||||
void safeShaderCompilation();
|
||||
ghoul::opengl::Texture* _transferFunction;
|
||||
|
||||
GLuint _boxArray;
|
||||
ghoul::opengl::ProgramObject *_boxProgram;
|
||||
glm::vec3 _boxScaling, _boxOffset;
|
||||
float _w;
|
||||
GLint _MVPLocation, _modelTransformLocation, _typeLocation;
|
||||
|
||||
bool _updateTransferfunction;
|
||||
int _id;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <openspace/abuffer/abuffer.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Camera;
|
||||
@@ -45,6 +47,7 @@ public:
|
||||
SceneGraph* sceneGraph();
|
||||
|
||||
Camera* camera() const;
|
||||
ABuffer* abuffer() const;
|
||||
|
||||
// sgct wrapped functions
|
||||
bool initializeGL();
|
||||
@@ -58,6 +61,8 @@ public:
|
||||
private:
|
||||
Camera* _mainCamera;
|
||||
SceneGraph* _sceneGraph;
|
||||
|
||||
ABuffer* _abuffer;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
VolumeRaycasterBox();
|
||||
~VolumeRaycasterBox();
|
||||
bool initialize();
|
||||
void render(const glm::mat4& MVP);
|
||||
void render(const glm::mat4& MVP, const glm::mat4& transform = glm::mat4(1.0), int type = 0);
|
||||
|
||||
ghoul::opengl::Texture* backFace();
|
||||
ghoul::opengl::Texture* frontFace();
|
||||
@@ -56,7 +56,7 @@ private:
|
||||
ghoul::opengl::Texture *_backTexture, *_frontTexture;
|
||||
ghoul::opengl::ProgramObject *_boxProgram;
|
||||
sgct_utils::SGCTBox* _boundingBox;
|
||||
GLint _MVPLocation;
|
||||
GLint _MVPLocation, _modelTransformLocation, _typeLocation;
|
||||
|
||||
glm::size2_t _dimensions;
|
||||
};
|
||||
|
||||
@@ -36,9 +36,9 @@ public:
|
||||
|
||||
Ephemeris(const ghoul::Dictionary& dictionary);
|
||||
virtual ~Ephemeris();
|
||||
virtual bool initialize() = 0;
|
||||
virtual bool initialize();
|
||||
virtual const psc& position() const = 0;
|
||||
virtual void update() = 0;
|
||||
virtual void update();
|
||||
|
||||
protected:
|
||||
Ephemeris();
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef SCENEGRAPH_H
|
||||
#define SCENEGRAPH_H
|
||||
#ifndef __SCENEGRAPH_H__
|
||||
#define __SCENEGRAPH_H__
|
||||
|
||||
// std includes
|
||||
#include <vector>
|
||||
@@ -31,12 +31,15 @@
|
||||
|
||||
#include <openspace/util/camera.h>
|
||||
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
class SceneGraphNode;
|
||||
|
||||
class SceneGraph {
|
||||
@@ -94,6 +97,16 @@ public:
|
||||
*/
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to change the
|
||||
* scene graph. The functions contained are
|
||||
* - openspace::luascriptfunctions::property_setValue
|
||||
* - openspace::luascriptfunctions::property_getValue
|
||||
* \return The Lua library that contains all Lua functions available to change the
|
||||
* scene graph
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
std::string _focus, _position;
|
||||
|
||||
@@ -105,4 +118,4 @@ private:
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif // __SCENEGRAPH_H__
|
||||
@@ -22,12 +22,13 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef SCENEGRAPHNODE_H
|
||||
#define SCENEGRAPHNODE_H
|
||||
#ifndef __SCENEGRAPHNODE_H__
|
||||
#define __SCENEGRAPHNODE_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/scenegraph/ephemeris.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/scenegraph/scenegraph.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
@@ -40,8 +41,10 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SceneGraphNode {
|
||||
class SceneGraphNode : public properties::PropertyOwner {
|
||||
public:
|
||||
static std::string RootNodeName;
|
||||
|
||||
// constructors & destructor
|
||||
SceneGraphNode();
|
||||
~SceneGraphNode();
|
||||
@@ -59,31 +62,30 @@ public:
|
||||
// set & get
|
||||
void addNode(SceneGraphNode* child);
|
||||
|
||||
void setName(const std::string& name);
|
||||
void setParent(SceneGraphNode* parent);
|
||||
const psc& getPosition() const;
|
||||
psc getWorldPosition() const;
|
||||
std::string nodeName() const;
|
||||
const psc& position() const;
|
||||
psc worldPosition() const;
|
||||
|
||||
SceneGraphNode* parent() const;
|
||||
const std::vector<SceneGraphNode*>& children() const;
|
||||
|
||||
// bounding sphere
|
||||
PowerScaledScalar calculateBoundingSphere();
|
||||
PowerScaledScalar boundingSphere() const;
|
||||
|
||||
SceneGraphNode* get(const std::string& name);
|
||||
SceneGraphNode* childNode(const std::string& name);
|
||||
|
||||
void print() const;
|
||||
|
||||
// renderable
|
||||
void setRenderable(Renderable* renderable);
|
||||
const Renderable* getRenderable() const;
|
||||
const Renderable* renderable() const;
|
||||
Renderable* renderable();
|
||||
|
||||
private:
|
||||
// essential
|
||||
std::vector<SceneGraphNode*> _children;
|
||||
SceneGraphNode* _parent;
|
||||
std::string _nodeName;
|
||||
Ephemeris* _ephemeris;
|
||||
|
||||
// renderable
|
||||
@@ -100,4 +102,4 @@ private:
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif // __SCENEGRAPHNODE_H__
|
||||
|
||||
@@ -31,20 +31,20 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SpiceEphemeris: public Ephemeris {
|
||||
class SpiceEphemeris : public Ephemeris {
|
||||
public:
|
||||
SpiceEphemeris(const ghoul::Dictionary& dictionary);
|
||||
virtual ~SpiceEphemeris();
|
||||
virtual bool initialize();
|
||||
virtual const psc& position() const;
|
||||
virtual void update();
|
||||
protected:
|
||||
private:
|
||||
|
||||
std::string _targetName, _originName;
|
||||
int _target, _origin;
|
||||
private:
|
||||
std::string _targetName;
|
||||
std::string _originName;
|
||||
int _target;
|
||||
int _origin;
|
||||
psc _position;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -33,14 +33,11 @@ class StaticEphemeris: public Ephemeris {
|
||||
public:
|
||||
StaticEphemeris(const ghoul::Dictionary& dictionary
|
||||
= ghoul::Dictionary());
|
||||
virtual ~StaticEphemeris();
|
||||
virtual bool initialize();
|
||||
virtual const psc& position() const;
|
||||
virtual void update();
|
||||
protected:
|
||||
~StaticEphemeris();
|
||||
const psc& position() const;
|
||||
|
||||
private:
|
||||
psc _position;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
77
include/openspace/scripting/scriptengine.h
Normal file
77
include/openspace/scripting/scriptengine.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __SCRIPTENGINE_H__
|
||||
#define __SCRIPTENGINE_H__
|
||||
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
#include <set>
|
||||
|
||||
/**
|
||||
* \defgroup LuaScripts Lua Scripts
|
||||
*/
|
||||
|
||||
namespace openspace {
|
||||
namespace scripting {
|
||||
|
||||
class ScriptEngine {
|
||||
public:
|
||||
struct LuaLibrary {
|
||||
struct Function {
|
||||
std::string name;
|
||||
lua_CFunction function;
|
||||
std::string helpText;
|
||||
};
|
||||
std::string name;
|
||||
std::vector<Function> functions;
|
||||
|
||||
bool operator<(const LuaLibrary& rhs) const;
|
||||
};
|
||||
|
||||
ScriptEngine();
|
||||
|
||||
bool initialize();
|
||||
void deinitialize();
|
||||
|
||||
bool addLibrary(const LuaLibrary& library);
|
||||
bool hasLibrary(const std::string& name);
|
||||
|
||||
bool runScript(const std::string& script);
|
||||
bool runScriptFile(const std::string& filename);
|
||||
|
||||
private:
|
||||
bool isLibraryNameAllowed(const std::string& name);
|
||||
void addLibraryFunctions(const LuaLibrary& library, bool replace);
|
||||
|
||||
void addBaseLibrary();
|
||||
void remapPrintFunction();
|
||||
|
||||
lua_State* _state;
|
||||
std::set<LuaLibrary> _registeredLibraries;
|
||||
};
|
||||
|
||||
} // namespace scripting
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __SCRIPTENGINE_H__
|
||||
151
include/openspace/tests/test_luaconversions.inl
Normal file
151
include/openspace/tests/test_luaconversions.inl
Normal file
@@ -0,0 +1,151 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
#include <openspace/properties/propertydelegate.h>
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/properties/matrixproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
|
||||
class LuaConversionTest : public testing::Test {
|
||||
protected:
|
||||
lua_State* state;
|
||||
|
||||
LuaConversionTest() {
|
||||
state = luaL_newstate();
|
||||
luaL_openlibs(state);
|
||||
}
|
||||
|
||||
~LuaConversionTest() {
|
||||
lua_close(state);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
lua_close(state);
|
||||
state = luaL_newstate();
|
||||
luaL_openlibs(state);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(LuaConversionTest, LuaExecution) {
|
||||
int status = luaL_loadstring(state, "");
|
||||
EXPECT_EQ(status, LUA_OK);
|
||||
}
|
||||
|
||||
#define CONVERSION_TEST_TEMPLATE(__NAME__, __TYPE__, __VALUE__) \
|
||||
TEST_F(LuaConversionTest, __NAME__) \
|
||||
{ \
|
||||
using namespace openspace::properties; \
|
||||
bool success \
|
||||
= PropertyDelegate<TemplateProperty<__TYPE__>>::toLuaValue<__TYPE__>( \
|
||||
state, __VALUE__); \
|
||||
EXPECT_TRUE(success) << "toLuaValue"; \
|
||||
__TYPE__ value = (__TYPE__)(0); \
|
||||
value = PropertyDelegate<TemplateProperty<__TYPE__>>::fromLuaValue<__TYPE__>( \
|
||||
state, success); \
|
||||
EXPECT_TRUE(success) << "fromLuaValue"; \
|
||||
EXPECT_EQ(value, __VALUE__) << "fromLuaValue"; \
|
||||
}
|
||||
|
||||
#define CONVERSION_TEST_NUMERICAL(__NAME__, __TYPE__, __VALUE__) \
|
||||
TEST_F(LuaConversionTest, __NAME__) \
|
||||
{ \
|
||||
using namespace openspace::properties; \
|
||||
bool success \
|
||||
= PropertyDelegate<NumericalProperty<__TYPE__>>::toLuaValue<__TYPE__>( \
|
||||
state, __VALUE__); \
|
||||
EXPECT_TRUE(success) << "toLuaValue"; \
|
||||
__TYPE__ value = (__TYPE__)(0); \
|
||||
value = PropertyDelegate<NumericalProperty<__TYPE__>>::fromLuaValue<__TYPE__>( \
|
||||
state, success); \
|
||||
EXPECT_TRUE(success) << "fromLuaValue"; \
|
||||
EXPECT_EQ(value, __VALUE__) << "fromLuaValue"; \
|
||||
}
|
||||
|
||||
CONVERSION_TEST_TEMPLATE(Bool, bool, true);
|
||||
|
||||
CONVERSION_TEST_NUMERICAL(Char, char, 1);
|
||||
CONVERSION_TEST_NUMERICAL(WChar, wchar_t, 1);
|
||||
CONVERSION_TEST_NUMERICAL(SignedChar, signed char, 1);
|
||||
CONVERSION_TEST_NUMERICAL(UnsignedChar, unsigned char, 1);
|
||||
CONVERSION_TEST_NUMERICAL(Short, short, 1);
|
||||
CONVERSION_TEST_NUMERICAL(UnsignedShort, unsigned short, 1);
|
||||
CONVERSION_TEST_NUMERICAL(Int, int, 1);
|
||||
CONVERSION_TEST_NUMERICAL(UnsignedInt, unsigned int, 1);
|
||||
CONVERSION_TEST_NUMERICAL(Long, long, 1);
|
||||
CONVERSION_TEST_NUMERICAL(UnsignedLong, unsigned long, 1);
|
||||
CONVERSION_TEST_NUMERICAL(LongLong, long long, 1);
|
||||
CONVERSION_TEST_NUMERICAL(UnsignedLongLong, unsigned long long, 1);
|
||||
CONVERSION_TEST_NUMERICAL(Float, float, 1.f);
|
||||
CONVERSION_TEST_NUMERICAL(Double, double, 1.0);
|
||||
CONVERSION_TEST_NUMERICAL(LongDouble, long double, 1.0);
|
||||
|
||||
CONVERSION_TEST_NUMERICAL(Vec2, glm::vec2, glm::vec2(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Vec3, glm::vec3, glm::vec3(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Vec4, glm::vec4, glm::vec4(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DVec2, glm::dvec2, glm::dvec2(1.0));
|
||||
CONVERSION_TEST_NUMERICAL(DVec3, glm::dvec3, glm::dvec3(1.0));
|
||||
CONVERSION_TEST_NUMERICAL(DVec4, glm::dvec4, glm::dvec4(1.0));
|
||||
CONVERSION_TEST_NUMERICAL(IVec2, glm::ivec2, glm::ivec2(1));
|
||||
CONVERSION_TEST_NUMERICAL(IVec3, glm::ivec3, glm::ivec3(1));
|
||||
CONVERSION_TEST_NUMERICAL(IVec4, glm::ivec4, glm::ivec4(1));
|
||||
CONVERSION_TEST_NUMERICAL(UVec2, glm::uvec2, glm::uvec2(1));
|
||||
CONVERSION_TEST_NUMERICAL(UVec3, glm::uvec3, glm::uvec3(1));
|
||||
CONVERSION_TEST_NUMERICAL(UVec4, glm::uvec4, glm::uvec4(1));
|
||||
|
||||
CONVERSION_TEST_NUMERICAL(Mat2x2, glm::mat2x2, glm::mat2x2(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Mat2x3, glm::mat2x3, glm::mat2x3(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Mat2x4, glm::mat2x4, glm::mat2x4(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Mat3x2, glm::mat3x2, glm::mat3x2(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Mat3x3, glm::mat3x3, glm::mat3x3(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Mat3x4, glm::mat3x4, glm::mat3x4(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Mat4x2, glm::mat4x2, glm::mat4x2(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Mat4x3, glm::mat4x3, glm::mat4x3(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(Mat4x4, glm::mat4x4, glm::mat4x4(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat2x2, glm::dmat2x2, glm::dmat2x2(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat2x3, glm::dmat2x3, glm::dmat2x3(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat2x4, glm::dmat2x4, glm::dmat2x4(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat3x2, glm::dmat3x2, glm::dmat3x2(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat3x3, glm::dmat3x3, glm::dmat3x3(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat3x4, glm::dmat3x4, glm::dmat3x4(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat4x2, glm::dmat4x2, glm::dmat4x2(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat4x3, glm::dmat4x3, glm::dmat4x3(1.f));
|
||||
CONVERSION_TEST_NUMERICAL(DMat4x4, glm::dmat4x4, glm::dmat4x4(1.f));
|
||||
|
||||
TEST_F(LuaConversionTest, String)
|
||||
{
|
||||
using namespace openspace::properties;
|
||||
bool success
|
||||
= PropertyDelegate<TemplateProperty<std::string>>::toLuaValue<std::string>(
|
||||
state, "value");
|
||||
EXPECT_TRUE(success) << "toLuaValue";
|
||||
std::string value = "";
|
||||
value = PropertyDelegate<TemplateProperty<std::string>>::fromLuaValue<std::string>(
|
||||
state, success);
|
||||
EXPECT_TRUE(success) << "fromLuaValue";
|
||||
EXPECT_EQ(value, "value") << "fromLuaValue";
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* GHOUL *
|
||||
* General Helpful Open Utility Library *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2012-2014 *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
@@ -25,6 +24,8 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <openspace/scenegraph/scenegraph.h>
|
||||
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
|
||||
@@ -45,10 +46,10 @@ protected:
|
||||
|
||||
TEST_F(PowerscaleCoordinatesTest, psc) {
|
||||
|
||||
openspace::psc reference(2.0, 1.0, 1.1, 1.0);
|
||||
openspace::psc reference(2.f, 1.f, 1.1f, 1.f);
|
||||
|
||||
openspace::psc first(1.0,0.0,1.0,0.0);
|
||||
openspace::psc second(1.9,1.0,1.0,1.0);
|
||||
openspace::psc first(1.f, 0.f, 1.f, 0.f);
|
||||
openspace::psc second(1.9f, 1.f, 1.f, 1.f);
|
||||
|
||||
EXPECT_EQ(reference, first + second);
|
||||
EXPECT_TRUE(reference == (first + second));
|
||||
@@ -63,10 +64,10 @@ TEST_F(PowerscaleCoordinatesTest, psc) {
|
||||
|
||||
TEST_F(PowerscaleCoordinatesTest, pss) {
|
||||
|
||||
openspace::pss first(1.0,1.0);
|
||||
openspace::pss second(1.0,-1.0);
|
||||
EXPECT_EQ(openspace::pss(1.01,1.0), first + second);
|
||||
EXPECT_EQ(openspace::pss(1.01,1.0), second + first);
|
||||
openspace::pss first(1.f, 1.f);
|
||||
openspace::pss second(1.f, -1.f);
|
||||
EXPECT_EQ(openspace::pss(1.01f, 1.f), first + second);
|
||||
EXPECT_EQ(openspace::pss(1.01f, 1.f), second + first);
|
||||
/*
|
||||
EXPECT_TRUE(first < (first + second));
|
||||
bool retu =(second < (first + second));
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* GHOUL *
|
||||
* General Helpful Open Utility Library *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2012-2014 *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
@@ -55,8 +54,8 @@ TEST_F(SceneGraphTest, SceneGraphNode) {
|
||||
openspace::SceneGraphNode::createFromDictionary(ghoul::Dictionary());
|
||||
|
||||
// Should not have a renderable and position should be 0,0,0,0 (undefined).
|
||||
EXPECT_EQ(nullptr, node->getRenderable());
|
||||
EXPECT_EQ(openspace::psc(), node->getPosition());
|
||||
EXPECT_EQ(nullptr, node->renderable());
|
||||
EXPECT_EQ(openspace::psc(), node->position());
|
||||
|
||||
delete node;
|
||||
ghoul::Dictionary nodeDictionary;
|
||||
@@ -83,10 +82,10 @@ TEST_F(SceneGraphTest, SceneGraphNode) {
|
||||
openspace::SceneGraphNode::createFromDictionary(nodeDictionary);
|
||||
|
||||
// This node should have a renderable (probably no good values but an existing one)
|
||||
EXPECT_TRUE(node->getRenderable());
|
||||
EXPECT_TRUE(node->renderable());
|
||||
|
||||
// position should be initialized
|
||||
EXPECT_EQ(openspace::psc(1.0,1.0,1.0,1.0), node->getPosition());
|
||||
EXPECT_EQ(openspace::psc(1.0,1.0,1.0,1.0), node->position());
|
||||
|
||||
delete node;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* GHOUL *
|
||||
* General Helpful Open Utility Library *
|
||||
* *
|
||||
* Copyright (c) 2012-2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include "gtest/gtest.h"
|
||||
#include "openspace/util/spicemanager.h"
|
||||
@@ -49,7 +49,6 @@ protected:
|
||||
const int nrMetaKernels = 9;
|
||||
int which, handle, count = 0;
|
||||
char file[FILLEN], filtyp[TYPLEN], source[SRCLEN];
|
||||
int found;
|
||||
double abs_error = 0.00001;
|
||||
|
||||
|
||||
@@ -77,9 +76,10 @@ std::string fileType(char type[]){
|
||||
TEST_F(SpiceManagerTest, loadSingleKernel){
|
||||
loadLSKKernel();
|
||||
//naif0008.tls is a text file, check if loaded.
|
||||
SpiceBoolean found;
|
||||
kdata_c(0, "text", FILLEN, TYPLEN, SRCLEN, file, filtyp, source, &handle, &found);
|
||||
|
||||
ASSERT_TRUE(found) << "Kernel not loaded";
|
||||
ASSERT_TRUE(found == SPICETRUE) << "Kernel not loaded";
|
||||
unload_c(LSK.c_str());
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ TEST_F(SpiceManagerTest, loadMetaKernel){
|
||||
"TEXT", "CK", "TEXT" };
|
||||
// If one of the kernels does not load we expect a mismatch
|
||||
for (int i = 0; i < nrMetaKernels; i++){
|
||||
SpiceBoolean found;
|
||||
kdata_c(i, "all", FILLEN, TYPLEN, SRCLEN, file, filtyp, source, &handle, &found);
|
||||
EXPECT_EQ(fileType(filtyp), typeArr[i]) << "One or more kernels did not load properly";
|
||||
}
|
||||
@@ -102,29 +103,33 @@ TEST_F(SpiceManagerTest, loadMetaKernel){
|
||||
TEST_F(SpiceManagerTest, unloadKernelString){
|
||||
loadLSKKernel();
|
||||
//naif0008.tls is a text file, check if loaded.
|
||||
SpiceBoolean found;
|
||||
kdata_c(0, "text", FILLEN, TYPLEN, SRCLEN, file, filtyp, source, &handle, &found);
|
||||
ASSERT_TRUE(found);
|
||||
ASSERT_TRUE(found == SPICETRUE);
|
||||
|
||||
//unload using string keyword
|
||||
bool unloaded = openspace::SpiceManager::ref().unloadKernel("LEAPSECONDS");
|
||||
EXPECT_TRUE(unloaded);
|
||||
|
||||
found = SPICEFALSE;
|
||||
kdata_c(0, "text", FILLEN, TYPLEN, SRCLEN, file, filtyp, source, &handle, &found);
|
||||
EXPECT_FALSE(found);
|
||||
EXPECT_FALSE(found == SPICETRUE);
|
||||
}
|
||||
// Try unloading kernel using integer as ID
|
||||
TEST_F(SpiceManagerTest, unloadKernelInteger){
|
||||
int kernelID = loadLSKKernel();
|
||||
//naif0008.tls is a text file, check if loaded.
|
||||
SpiceBoolean found;
|
||||
kdata_c(0, "text", FILLEN, TYPLEN, SRCLEN, file, filtyp, source, &handle, &found);
|
||||
ASSERT_TRUE(found);
|
||||
ASSERT_TRUE(found == SPICETRUE);
|
||||
|
||||
//unload using unique int ID
|
||||
bool unloaded = openspace::SpiceManager::ref().unloadKernel(kernelID);
|
||||
EXPECT_TRUE(unloaded) << "Kernel did not unload";
|
||||
|
||||
found = SPICEFALSE;
|
||||
kdata_c(0, "text", FILLEN, TYPLEN, SRCLEN, file, filtyp, source, &handle, &found);
|
||||
EXPECT_FALSE(found) << "One or more kernels still present in kernel-pool";
|
||||
EXPECT_FALSE(found == SPICETRUE) << "One or more kernels still present in kernel-pool";
|
||||
}
|
||||
// Try unloading multiple kernels
|
||||
TEST_F(SpiceManagerTest, unloadMetaKernel){
|
||||
@@ -136,6 +141,7 @@ TEST_F(SpiceManagerTest, unloadMetaKernel){
|
||||
|
||||
for (int i = 0; i < nrMetaKernels; i++){
|
||||
// check kernelpool against typeArr
|
||||
SpiceBoolean found;
|
||||
kdata_c(i, "all", FILLEN, TYPLEN, SRCLEN, file, filtyp, source, &handle, &found);
|
||||
EXPECT_EQ(fileType(filtyp), typeArr[i]) << "One or more kernels did not load properly";
|
||||
}
|
||||
@@ -144,8 +150,9 @@ TEST_F(SpiceManagerTest, unloadMetaKernel){
|
||||
|
||||
for (int i = 0; i < nrMetaKernels; i++){
|
||||
// the values should by now be unloaded
|
||||
SpiceBoolean found;
|
||||
kdata_c(i, "all", FILLEN, TYPLEN, SRCLEN, file, filtyp, source, &handle, &found);
|
||||
EXPECT_FALSE(found) << "Failed unloading kernel";
|
||||
EXPECT_FALSE(found == SPICETRUE) << "Failed unloading kernel";
|
||||
}
|
||||
unload_c(META.c_str());
|
||||
}
|
||||
@@ -153,13 +160,11 @@ TEST_F(SpiceManagerTest, unloadMetaKernel){
|
||||
TEST_F(SpiceManagerTest, hasValue){
|
||||
loadPCKKernel();
|
||||
|
||||
int n;
|
||||
int naifId = 399; //Earth
|
||||
double radii[3];
|
||||
|
||||
std::string kernelPoolValue = "RADII";
|
||||
|
||||
found = openspace::SpiceManager::ref().hasValue(naifId, kernelPoolValue);
|
||||
bool found = openspace::SpiceManager::ref().hasValue(naifId, kernelPoolValue);
|
||||
ASSERT_TRUE(found) << "Could not find value for specified kernel";
|
||||
unload_c(PCK.c_str());
|
||||
}
|
||||
@@ -171,7 +176,7 @@ TEST_F(SpiceManagerTest, getValueFromID_1D){
|
||||
std::string value1D = "MAG_NORTH_POLE_LAT";
|
||||
|
||||
double return1D;
|
||||
found = openspace::SpiceManager::ref().getValueFromID(target, value1D, return1D);
|
||||
bool found = openspace::SpiceManager::ref().getValueFromID(target, value1D, return1D);
|
||||
ASSERT_TRUE(found) << "Could not retrieve value";
|
||||
EXPECT_EQ(return1D, 78.565) << "Value not found / differs from expected return";
|
||||
unload_c(PCK.c_str());
|
||||
@@ -200,14 +205,14 @@ TEST_F(SpiceManagerTest, getValueFromID_ND){
|
||||
|
||||
std::vector<double> returnND;
|
||||
unsigned int nr = 5;
|
||||
found = openspace::SpiceManager::ref().getValueFromID(target, valueND, returnND, nr);
|
||||
bool found = openspace::SpiceManager::ref().getValueFromID(target, valueND, returnND, nr);
|
||||
ASSERT_TRUE(found) << "Could not retrieve value for specified kernel";
|
||||
|
||||
std::vector<double> controlVec{ 189870.0, 256900.0, 9000.0, 9000.0, 0.000003 };
|
||||
|
||||
ASSERT_EQ(controlVec.size(), returnND.size()) << "Vectors differ in size";
|
||||
|
||||
for (int i = 0; i < nr; i++){
|
||||
for (unsigned int i = 0; i < nr; ++i){
|
||||
EXPECT_EQ(controlVec[i], returnND[i]) << "Vector value not equal";
|
||||
}
|
||||
unload_c(PCK.c_str());
|
||||
@@ -218,10 +223,10 @@ TEST_F(SpiceManagerTest, stringToEphemerisTime){
|
||||
|
||||
double ephemerisTime;
|
||||
double control_ephemerisTime;
|
||||
char *date = "Thu Mar 20 12:53:29 PST 1997";
|
||||
char date[SRCLEN] = "Thu Mar 20 12:53:29 PST 1997";
|
||||
str2et_c(date, &control_ephemerisTime);
|
||||
|
||||
ephemerisTime = openspace::SpiceManager::ref().stringToEphemerisTime(date);
|
||||
ephemerisTime = openspace::SpiceManager::ref().convertStringToTdbSeconds(date);
|
||||
|
||||
EXPECT_EQ(ephemerisTime, control_ephemerisTime) << "Ephemeries times differ / not found";
|
||||
unload_c(LSK.c_str());
|
||||
@@ -240,7 +245,7 @@ TEST_F(SpiceManagerTest, getTargetPosition){
|
||||
|
||||
glm::dvec3 targetPosition;
|
||||
double lightTime = 0.0;
|
||||
found = openspace::SpiceManager::ref().getTargetPosition("EARTH", et, "J2000", "LT+S", "CASSINI",
|
||||
bool found = openspace::SpiceManager::ref().getTargetPosition("EARTH", et, "J2000", "LT+S", "CASSINI",
|
||||
targetPosition, lightTime);
|
||||
ASSERT_TRUE(found);
|
||||
EXPECT_DOUBLE_EQ(pos[0], targetPosition[0]) << "Position not found or differs from expected return";
|
||||
@@ -263,7 +268,7 @@ TEST_F(SpiceManagerTest, getTargetState){
|
||||
glm::dvec3 targetPosition;
|
||||
glm::dvec3 targetVelocity;
|
||||
double lightTime = 0.0;
|
||||
found = openspace::SpiceManager::ref().getTargetState("EARTH", et, "J2000", "LT+S", "CASSINI",
|
||||
bool found = openspace::SpiceManager::ref().getTargetState("EARTH", et, "J2000", "LT+S", "CASSINI",
|
||||
targetPosition, targetVelocity, lightTime);
|
||||
ASSERT_TRUE(found);
|
||||
//x,y,z
|
||||
@@ -291,7 +296,7 @@ TEST_F(SpiceManagerTest, getStateTransformMatrix){
|
||||
glm::dvec3 velocity(state[3], state[4], state[5]);
|
||||
|
||||
openspace::transformMatrix stateMatrix(6);
|
||||
found = openspace::SpiceManager::ref().getStateTransformMatrix("J2000",
|
||||
bool found = openspace::SpiceManager::ref().getStateTransformMatrix("J2000",
|
||||
"IAU_PHOEBE",
|
||||
et,
|
||||
stateMatrix);
|
||||
@@ -317,7 +322,6 @@ TEST_F(SpiceManagerTest, getPositionTransformMatrix){
|
||||
loadMetaKernel();
|
||||
|
||||
double et;
|
||||
double lt;
|
||||
double state[3] = { 1.0, 1.0, 1.0 };
|
||||
double state_t[3];
|
||||
double referenceMatrix[3][3];
|
||||
@@ -327,7 +331,7 @@ TEST_F(SpiceManagerTest, getPositionTransformMatrix){
|
||||
|
||||
openspace::transformMatrix positionMatrix(3);
|
||||
glm::dvec3 position(state[0], state[1], state[2]);
|
||||
found = openspace::SpiceManager::ref().getPositionTransformMatrix("CASSINI_HGA",
|
||||
bool found = openspace::SpiceManager::ref().getPositionTransformMatrix("CASSINI_HGA",
|
||||
"J2000",
|
||||
et,
|
||||
positionMatrix);
|
||||
@@ -355,17 +359,16 @@ TEST_F(SpiceManagerTest, getFieldOfView){
|
||||
int n;
|
||||
int cassini_ID;
|
||||
double et;
|
||||
double lt;
|
||||
double boresight[3];
|
||||
double bounds_ref[5][3];
|
||||
char shape_ref[TYPLEN];
|
||||
char name_ref[FILLEN];
|
||||
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
SpiceBoolean found;
|
||||
bodn2c_c("CASSINI_ISS_NAC", &cassini_ID, &found);
|
||||
if (!found){
|
||||
printf("error cannot locate ID for Cassini \n");
|
||||
}
|
||||
ASSERT_TRUE(found == SPICETRUE) << "Cannot locate ID for Cassini";
|
||||
|
||||
getfov_c(cassini_ID, 5, TYPLEN, TYPLEN, shape_ref, name_ref, boresight, &n, bounds_ref);
|
||||
|
||||
std::string shape, name;
|
||||
@@ -379,7 +382,7 @@ TEST_F(SpiceManagerTest, getFieldOfView){
|
||||
boresight,
|
||||
bounds,
|
||||
nrReturned);
|
||||
ASSERT_TRUE(found);
|
||||
ASSERT_TRUE(found == SPICETRUE);
|
||||
//check vectors have correct values
|
||||
for (int i = 0; i < nrReturned; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
@@ -399,14 +402,17 @@ TEST_F(SpiceManagerTest, rectangularToLatitudal){
|
||||
obspos[3], point_ref[3];
|
||||
double dist, et, radius_ref, trgepc;
|
||||
int n, naifId;
|
||||
int found;
|
||||
bool found;
|
||||
SpiceBoolean foundSpice;
|
||||
|
||||
// First, find an intersection point to convert to rectangular coordinates
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
bodn2c_c("CASSINI_ISS_NAC", &naifId, &found);
|
||||
bodn2c_c("CASSINI_ISS_NAC", &naifId, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
getfov_c(naifId, 4, FILLEN, FILLEN, shape, frame, bsight, &n, bounds);
|
||||
srfxpt_c("Ellipsoid", "PHOEBE", et, "LT+S", "CASSINI", frame, bsight,
|
||||
point_ref, &dist, &trgepc, obspos, &found);
|
||||
point_ref, &dist, &trgepc, obspos, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
|
||||
reclat_c(point_ref, &radius_ref, &lon, &lat);
|
||||
glm::dvec3 point(point_ref[0], point_ref[1], point_ref[2]);
|
||||
@@ -429,13 +435,17 @@ TEST_F(SpiceManagerTest, latitudinalToRectangular){
|
||||
obspos[3], point_ref[3];
|
||||
double dist, et, radius_ref, trgepc;
|
||||
int n, naifId;
|
||||
SpiceBoolean foundSpice;
|
||||
|
||||
// First, find an intersection point to convert to latitudinal coordinates //
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
bodn2c_c("CASSINI_ISS_NAC", &naifId, &found);
|
||||
bodn2c_c("CASSINI_ISS_NAC", &naifId, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
getfov_c(naifId, 4, FILLEN, FILLEN, shape, frame, bsight, &n, bounds);
|
||||
foundSpice = SPICEFALSE;
|
||||
srfxpt_c("Ellipsoid", "PHOEBE", et, "LT+S", "CASSINI", frame, bsight,
|
||||
point_ref, &dist, &trgepc, obspos, &found);
|
||||
point_ref, &dist, &trgepc, obspos, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
|
||||
reclat_c(point_ref, &radius_ref, &lon, &lat);
|
||||
|
||||
@@ -449,7 +459,7 @@ TEST_F(SpiceManagerTest, latitudinalToRectangular){
|
||||
latrec_c(radius_ref, lon, lat, rectangular_ref);
|
||||
|
||||
glm::dvec3 coordinates;
|
||||
found = openspace::SpiceManager::ref().latidudinalToRectangular(radius_ref, lon, lat, coordinates);
|
||||
bool found = openspace::SpiceManager::ref().latidudinalToRectangular(radius_ref, lon, lat, coordinates);
|
||||
|
||||
ASSERT_TRUE(found);
|
||||
ASSERT_NEAR(lon_ref, lon, abs_error) << "longitude is not set / has incorrect values";
|
||||
@@ -463,14 +473,16 @@ TEST_F(SpiceManagerTest, planetocentricToRectangular){
|
||||
double lat = -35.0; //initial values
|
||||
double lon = 100.0;
|
||||
double rectangular_ref[3];
|
||||
double radius;
|
||||
int naifId;
|
||||
SpiceBoolean foundSpice;
|
||||
|
||||
bodn2c_c("EARTH", &naifId, &found);
|
||||
bodn2c_c("EARTH", &naifId, &foundSpice);
|
||||
ASSERT_TRUE(foundSpice == SPICETRUE);
|
||||
srfrec_c(naifId, lon*rpd_c(), lat*rpd_c(), rectangular_ref);
|
||||
|
||||
glm::dvec3 rectangular;
|
||||
found = openspace::SpiceManager::ref().planetocentricToRectangular("EARTH", lon, lat, rectangular);
|
||||
bool found = openspace::SpiceManager::ref().planetocentricToRectangular("EARTH", lon, lat, rectangular);
|
||||
ASSERT_TRUE(found);
|
||||
|
||||
for (int i = 0; i < 3; i++){
|
||||
EXPECT_EQ(rectangular[i], rectangular_ref[i]) << "Rectangular coordinates differ from expected output";
|
||||
@@ -481,8 +493,11 @@ TEST_F(SpiceManagerTest, planetocentricToRectangular){
|
||||
TEST_F(SpiceManagerTest, getSubObserverPoint){
|
||||
loadMetaKernel();
|
||||
|
||||
double et, targetEt_ref, targetEt;
|
||||
double radii[3], subObserverPoint_ref[3], vectorToSurfacePoint_ref[3];
|
||||
double et;
|
||||
double targetEt_ref;
|
||||
double targetEt;
|
||||
double subObserverPoint_ref[3];
|
||||
double vectorToSurfacePoint_ref[3];
|
||||
static SpiceChar * method[2] = { "Intercept: ellipsoid", "Near point: ellipsoid" };
|
||||
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
@@ -494,7 +509,7 @@ TEST_F(SpiceManagerTest, getSubObserverPoint){
|
||||
subpnt_c(method[i], "phoebe", et, "iau_phoebe",
|
||||
"lt+s", "earth", subObserverPoint_ref, &targetEt_ref, vectorToSurfacePoint_ref);
|
||||
|
||||
found = openspace::SpiceManager::ref().getSubObserverPoint(method[i], "phoebe", et, "iau_phoebe",
|
||||
bool found = openspace::SpiceManager::ref().getSubObserverPoint(method[i], "phoebe", et, "iau_phoebe",
|
||||
"lt+s", "earth", subObserverPoint,
|
||||
targetEt, vectorToSurfacePoint);
|
||||
ASSERT_TRUE(found);
|
||||
@@ -513,7 +528,8 @@ TEST_F(SpiceManagerTest, getSubSolarPoint){
|
||||
loadMetaKernel();
|
||||
|
||||
double et, targetEt_ref, targetEt;
|
||||
double radii[3], subSolarPoint_ref[3], vectorToSurfacePoint_ref[3];
|
||||
double subSolarPoint_ref[3];
|
||||
double vectorToSurfacePoint_ref[3];
|
||||
static SpiceChar * method[2] = { "Intercept: ellipsoid", "Near point: ellipsoid" };
|
||||
|
||||
str2et_c("2004 jun 11 19:32:00", &et);
|
||||
@@ -525,7 +541,7 @@ TEST_F(SpiceManagerTest, getSubSolarPoint){
|
||||
subslr_c(method[i], "phoebe", et, "iau_phoebe",
|
||||
"lt+s", "earth", subSolarPoint_ref, &targetEt_ref, vectorToSurfacePoint_ref);
|
||||
|
||||
found = openspace::SpiceManager::ref().getSubSolarPoint(method[i], "phoebe", et, "iau_phoebe",
|
||||
bool found = openspace::SpiceManager::ref().getSubSolarPoint(method[i], "phoebe", et, "iau_phoebe",
|
||||
"lt+s", "earth", subSolarPoint,
|
||||
targetEt, vectorToSurfacePoint);
|
||||
ASSERT_TRUE(found);
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace openspaceengine {
|
||||
const std::string keyPathScene = "Paths.SCENEPATH";
|
||||
const std::string keyConfigSgct = "SGCTConfig";
|
||||
const std::string keyConfigScene = "Scene";
|
||||
const std::string keyStartupScript = "StartupScripts";
|
||||
const std::string keyConfigTimekernel = "SpiceTimeKernel";
|
||||
} // namespace openspaceengine
|
||||
|
||||
namespace scenegraph {
|
||||
@@ -64,16 +66,33 @@ namespace renderablestars {
|
||||
const std::string keyPathModule = "ModulePath";
|
||||
} // namespace renderablestars
|
||||
|
||||
namespace renderablevolumegl {
|
||||
const std::string keyVolume = "Volume";
|
||||
const std::string keyHints = "Hints";
|
||||
const std::string keyTransferFunction = "TransferFunction";
|
||||
const std::string keySampler = "Sampler";
|
||||
const std::string keyBoxScaling = "BoxScaling";
|
||||
const std::string keyVolumeName = "VolumeName";
|
||||
const std::string keyTransferFunctionName = "TransferFunctionName";
|
||||
} // namespace renderablevolumegl
|
||||
|
||||
namespace planetgeometry {
|
||||
const std::string keyType = "Type";
|
||||
} // namespace planetgeometry
|
||||
|
||||
|
||||
|
||||
namespace ephemeris {
|
||||
const std::string keyType = "Type";
|
||||
} // namespace ephemeris
|
||||
|
||||
namespace staticephemeris {
|
||||
const std::string keyPosition = "Position";
|
||||
} // namespace staticephemeris
|
||||
|
||||
namespace spiceephemeris {
|
||||
const std::string keyBody = "Body";
|
||||
const std::string keyOrigin = "Observer";
|
||||
} // namespace spiceephemeris
|
||||
|
||||
} // namespace constants
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#ifndef KAMELEONWRAPPER_H_
|
||||
#define KAMELEONWRAPPER_H_
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/std_based_type.hpp>
|
||||
|
||||
namespace ccmc {
|
||||
@@ -35,6 +34,16 @@ namespace ccmc {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct LinePoint {
|
||||
glm::vec3 position;
|
||||
glm::vec4 color;
|
||||
|
||||
LinePoint(glm::vec3 pos, glm::vec4 col) {
|
||||
position = pos;
|
||||
color = col;
|
||||
}
|
||||
};
|
||||
|
||||
class KameleonWrapper {
|
||||
public:
|
||||
|
||||
@@ -43,14 +52,58 @@ public:
|
||||
BATSRUS // Magnetosphere
|
||||
};
|
||||
|
||||
enum class TraceDirection {
|
||||
FORWARD = 1,
|
||||
BACK = -1
|
||||
};
|
||||
|
||||
enum class FieldlineEnd {
|
||||
NORTH,
|
||||
SOUTH,
|
||||
OUT
|
||||
};
|
||||
|
||||
KameleonWrapper(const std::string& filename, Model model);
|
||||
~KameleonWrapper();
|
||||
float* getUniformSampledValues(const std::string& var, glm::size3_t outDimensions);
|
||||
float* getUniformSampledVectorValues(const std::string& xVar, const std::string& yVar,
|
||||
const std::string& zVar, glm::size3_t outDimensions);
|
||||
|
||||
std::vector<std::vector<LinePoint> > getClassifiedFieldLines(const std::string& xVar,
|
||||
const std::string& yVar, const std::string& zVar,
|
||||
std::vector<glm::vec3> seedPoints, float stepSize);
|
||||
|
||||
std::vector<std::vector<LinePoint> > getFieldLines(const std::string& xVar,
|
||||
const std::string& yVar, const std::string& zVar,
|
||||
std::vector<glm::vec3> seedPoints, float stepSize, glm::vec4 color);
|
||||
|
||||
std::vector<std::vector<LinePoint> > getLorentzTrajectories(std::vector<glm::vec3> seedPoints,
|
||||
glm::vec4 color, float stepsize);
|
||||
|
||||
glm::vec3 getModelBarycenterOffset();
|
||||
|
||||
private:
|
||||
std::vector<glm::vec3> traceCartesianFieldline(const std::string& xVar,
|
||||
const std::string& yVar, const std::string& zVar, glm::vec3 seedPoint,
|
||||
float stepSize, TraceDirection direction, FieldlineEnd& end);
|
||||
|
||||
std::vector<glm::vec3> traceLorentzTrajectory(glm::vec3 seedPoint,
|
||||
float stepsize, float eCharge);
|
||||
|
||||
void getGridVariables(std::string& x, std::string& y, std::string& z);
|
||||
void progressBar(int current, int end);
|
||||
glm::vec4 classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEnd);
|
||||
|
||||
ccmc::Model* _model;
|
||||
Model _type;
|
||||
ccmc::Interpolator* _interpolator;
|
||||
|
||||
// Model parameters
|
||||
float _xMin, _xMax, _yMin, _yMax, _zMin, _zMax;
|
||||
std::string _xCoordVar, _yCoordVar, _zCoordVar;
|
||||
|
||||
// For progressbar
|
||||
int _lastiProgress;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
60
include/openspace/util/shadercreator.h
Normal file
60
include/openspace/util/shadercreator.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __SHADERCREATOR_H__
|
||||
#define __SHADERCREATOR_H__
|
||||
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace openspace {
|
||||
class ShaderCreator {
|
||||
|
||||
public:
|
||||
ShaderCreator();
|
||||
~ShaderCreator();
|
||||
|
||||
void createSourceFile(bool b);
|
||||
void sourceFileExtension(const std::string& extension);
|
||||
void sourceFileHeader(const std::string& header);
|
||||
|
||||
ghoul::opengl::ProgramObject* buildShader(const std::string& name, const std::string& vpath, const std::string& fpath, const std::string& gpath = "");
|
||||
|
||||
private:
|
||||
|
||||
void _generateSource(const std::string& filename);
|
||||
std::string _loadSource(const std::string& filename, unsigned int depth = 0);
|
||||
std::string _generateFilename(const std::string& filename);
|
||||
|
||||
bool _createSourceFile;
|
||||
std::string _sourceFileExtension;
|
||||
std::string _sourceFileHeader;
|
||||
unsigned int _maxDepth;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -92,19 +92,19 @@ public:
|
||||
* \param kernelPoolValueName Item for which values are desired. ("RADII", "NUT_PREC_ANGLES", etc. )
|
||||
* \return Whether the function succeeded or not
|
||||
*/
|
||||
bool SpiceManager::getValueFromID(const std::string& bodyname,
|
||||
bool getValueFromID(const std::string& bodyname,
|
||||
const std::string& kernelPoolValueName,
|
||||
double& value) const;
|
||||
/* Overloaded method for 3dim vectors, see above specification.*/
|
||||
bool SpiceManager::getValueFromID(const std::string& bodyname,
|
||||
bool getValueFromID(const std::string& bodyname,
|
||||
const std::string& kernelPoolValueName,
|
||||
glm::dvec3& value) const;
|
||||
/* Overloaded method for 4dim vectors, see above specification.*/
|
||||
bool SpiceManager::getValueFromID(const std::string& bodyname,
|
||||
bool getValueFromID(const std::string& bodyname,
|
||||
const std::string& kernelPoolValueName,
|
||||
glm::dvec4& value) const;
|
||||
/* Overloaded method for Ndim vectors, see above specification.*/
|
||||
bool SpiceManager::getValueFromID(const std::string& bodyname,
|
||||
bool getValueFromID(const std::string& bodyname,
|
||||
const std::string& kernelPoolValueName,
|
||||
std::vector<double>& values, unsigned int num) const;
|
||||
|
||||
@@ -119,7 +119,19 @@ public:
|
||||
* \param epochString, A string representing an epoch.
|
||||
* \return Corresponding ephemeris time, equivalent value in seconds past J2000, TDB.
|
||||
*/
|
||||
double stringToEphemerisTime(const std::string& epochString) const;
|
||||
double convertStringToTdbSeconds(const std::string& epochString) const;
|
||||
|
||||
/**
|
||||
* Convert the number of TDB seconds past the J2000 epoch into a human readable
|
||||
* string representation. Fur further details, please refer to 'timout_c' in SPICE
|
||||
* Documentation
|
||||
*
|
||||
* \param seconds The number of seconds that have passed since the J2000 epoch
|
||||
* \param format The output format of the string
|
||||
* (see ftp://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html)
|
||||
* \return The formatted date string
|
||||
*/
|
||||
std::string convertTdbSecondsToString(double seconds, const std::string& format) const;
|
||||
|
||||
// Computing Positions of Spacecraft and Natural Bodies(SPK) ---------------------------- //
|
||||
|
||||
@@ -337,7 +349,7 @@ private:
|
||||
struct spiceKernel {
|
||||
std::string path;
|
||||
std::string name;
|
||||
int id;
|
||||
unsigned int id;
|
||||
};
|
||||
std::vector<spiceKernel> _loadedKernels;
|
||||
unsigned int _kernelCount = 0;
|
||||
@@ -382,6 +394,21 @@ public:
|
||||
data = new double[N*N];
|
||||
empty = true;
|
||||
}
|
||||
|
||||
void transform(glm::dvec3& position) {
|
||||
assert(!empty); // transformation matrix is empty
|
||||
|
||||
double *state;
|
||||
double *state_t;
|
||||
state = new double[N];
|
||||
state_t = new double[N];
|
||||
|
||||
COPY(state, &position);
|
||||
mxvg_c(data, state, N, N, state_t);
|
||||
|
||||
COPY(&position, state_t);
|
||||
}
|
||||
|
||||
/** As the spice function mxvg_c requires a 6dim vector
|
||||
* the two 3dim state vectors are packed into 'state'.
|
||||
* Transformed values are then copied back from state_t
|
||||
@@ -394,8 +421,8 @@ public:
|
||||
* the method ignores its second argument.
|
||||
*/
|
||||
void transform(glm::dvec3& position,
|
||||
glm::dvec3& velocity = glm::dvec3()){
|
||||
assert(("transformation matrix is empty", !empty));
|
||||
glm::dvec3& velocity) {
|
||||
assert(!empty); // transformation matrix is empty
|
||||
|
||||
double *state;
|
||||
double *state_t;
|
||||
@@ -414,7 +441,7 @@ public:
|
||||
* asserts matrix has been filled
|
||||
*/
|
||||
inline double operator()(int i, int j) const{
|
||||
assert(("transformation matrix is empty", !empty));
|
||||
assert(!empty); // transformation matrix is empty
|
||||
return data[j + i*N];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,31 +1,167 @@
|
||||
#ifndef ENGINETIME_H
|
||||
#define ENGINETIME_H
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
namespace openspace
|
||||
{
|
||||
#ifndef __TIME_H__
|
||||
#define __TIME_H__
|
||||
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <string>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
/**
|
||||
* This singleton class represents the current simulation time in OpenSpace. It
|
||||
* internally stores the time and provides methods to set the time directly
|
||||
* (setTime(double), setTime(std::string)) using a <code>double</code> value using the
|
||||
* number of seconds passed since the J2000 epoch or a <code>string</code> that denotes
|
||||
* a valid date string in accordance to the Spice library
|
||||
* (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html). The time can
|
||||
* be retrieved as the number of seconds since the J2000 epoch with currentTime() or as a
|
||||
* UTC string following ISO 8601 with the method currentTimeUTC().
|
||||
*
|
||||
* In addition to the time itself, it also stores a delta time value. This value denotes
|
||||
* the number of seconds that pass for each real-time second. This value is set with
|
||||
* setDeltaTime(double), retrieved with deltaTime() and solely used in the
|
||||
* advanceTime(double), which takes a <code>tickTime</code> parameter. The value of the
|
||||
* parameter is dependent on the usage of the class and must be equal to the real-world
|
||||
* time that has passed since the last call to the method. For example, if the
|
||||
* advanceTime(double) method is called each frame, the <code>tickTime</code> has to be
|
||||
* equal to the frame time.
|
||||
*/
|
||||
class Time {
|
||||
public:
|
||||
virtual ~Time();
|
||||
/**
|
||||
* Initializes the Time singleton and loads an LSK spice kernel with the provided
|
||||
* name.
|
||||
* \param lskKernel The name of the kernel that should be loaded during the
|
||||
* initialization. If the parameter is empty, no kernel will be loaded
|
||||
* \return <code>true</code> if the initialization succeeded, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
static bool initialize(const std::string& lskKernel = "");
|
||||
|
||||
static void init();
|
||||
static void deinit();
|
||||
/**
|
||||
* Deinitializes the Time singleton. This method will not unload the kernel that was
|
||||
* possibly loaded during the initialize method.
|
||||
*/
|
||||
static void deinitialize();
|
||||
|
||||
/**
|
||||
* Returns the reference to the Time singleton object.
|
||||
* \return The reference to the Time singleton object
|
||||
*/
|
||||
static Time& ref();
|
||||
static bool isInitialized();
|
||||
|
||||
void setTime(const char* stringTime);
|
||||
double getTime();
|
||||
/**
|
||||
* Returns <code>true</code> if the singleton has been successfully initialized,
|
||||
* <code>false</code> otherwise
|
||||
* \return <code>true</code> if the singleton has been successfully initialized,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
static bool isInitialized();
|
||||
|
||||
/**
|
||||
* Sets the current time to the specified value in seconds past the J2000 epoch. This
|
||||
* value can be negative to represent dates before the epoch.
|
||||
* \param The number of seconds after the J2000 epoch
|
||||
*/
|
||||
void setTime(double value);
|
||||
|
||||
/**
|
||||
* Sets the current time to the specified value given as a Spice compliant string as
|
||||
* described in the Spice documentation
|
||||
* (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html)
|
||||
* \param time The time to be set as a date string
|
||||
*/
|
||||
void setTime(std::string time);
|
||||
|
||||
/**
|
||||
* Returns the current time as the number of seconds past the J2000 epoch. If the
|
||||
* current time is a date before that epoch, the returned value will be negative.
|
||||
* \return The current time as the number of seconds past the J2000 epoch
|
||||
*/
|
||||
double currentTime() const;
|
||||
|
||||
/**
|
||||
* Returns the current time as a formatted date string compliant with ISO 8601 and
|
||||
* thus also compliant with the Spice library.
|
||||
* \return The current time as a formatted date string
|
||||
*/
|
||||
std::string currentTimeUTC() const;
|
||||
|
||||
/**
|
||||
* Sets the delta time value that is the number of seconds that should pass for each
|
||||
* real-time second. This value is used in the advanceTime(double) method to easily
|
||||
* advance the simulation time.
|
||||
* \param deltaT The number of seconds that should pass for each real-time second
|
||||
*/
|
||||
void setDeltaTime(double deltaT);
|
||||
|
||||
/**
|
||||
* Returns the delta time, that is the number of seconds that pass in the simulation
|
||||
* for each real-time second
|
||||
* \return The number of seconds that pass for each real-time second
|
||||
*/
|
||||
double deltaTime() const;
|
||||
|
||||
/**
|
||||
* Advances the simulation time using the deltaTime() and the <code>tickTime</code>.
|
||||
* The deltaTime() is the number of simulation seconds that pass for each real-time
|
||||
* second. <code>tickTime</code> is the number of real-time seconds that passed since
|
||||
* the last call to this method. If this method is called in the render loop, the
|
||||
* <code>tickTime</code> should be equivalent to the frame time.
|
||||
* \param tickTime The number of real-time seconds that passed since the last call
|
||||
* to this method
|
||||
* \return The new time value after advancing the time
|
||||
*/
|
||||
double advanceTime(double tickTime);
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to change the
|
||||
* current time, retrieve the current time etc. The functions contained are
|
||||
* - openspace::luascriptfunctions::time_setDeltaTime
|
||||
* - openspace::luascriptfunctions::time_deltaTime
|
||||
* - openspace::luascriptfunctions::time_setTime
|
||||
* - openspace::luascriptfunctions::time_currentTime
|
||||
* - openspace::luascriptfunctions::time_currentTimeUTC
|
||||
* \return The Lua library that contains all Lua functions available to change the
|
||||
* Time singleton
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
static Time* this_;
|
||||
Time(void);
|
||||
Time(const Time& src);
|
||||
Time& operator=(const Time& rhs);
|
||||
/// Creates the time object. Only used in the initialize() method
|
||||
Time();
|
||||
Time(const Time& src) = delete;
|
||||
Time& operator=(const Time& rhs) = delete;
|
||||
|
||||
double time_;
|
||||
static Time* _instance; ///< The singleton instance
|
||||
double _time; ///< The time stored as the number of seconds past the J2000 epoch
|
||||
|
||||
double _deltaTimePerSecond; ///< The delta time that is used to advance the time
|
||||
};
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
#endif // __TIME_H__
|
||||
|
||||
@@ -7,10 +7,15 @@ return {
|
||||
OPENSPACE_DATA = "${BASE_PATH}/openspace-data",
|
||||
TESTDIR = "${BASE_PATH}/src/tests",
|
||||
SCENEPATH = "${OPENSPACE_DATA}/scene",
|
||||
-- SCENEPATH = "${OPENSPACE_DATA}/ABufferVolumes",
|
||||
CONFIG = "${BASE_PATH}/config"
|
||||
},
|
||||
SGCTConfig = "${SGCT}/single.xml",
|
||||
--SGCTConfig = "${SGCT}/two_nodes.xml",
|
||||
--SGCTConfig = "${SGCT}/single_sbs_stereo.xml",
|
||||
Scene = "${SCENEPATH}/default.scene"
|
||||
Scene = "${SCENEPATH}/default.scene",
|
||||
SpiceTimeKernel = "${OPENSPACE_DATA}/spice/naif0010.tls",
|
||||
StartupScripts = {
|
||||
"${SCRIPTS}/default_startup.lua"
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
level1_string = "music1",
|
||||
level1_integer = 2332,
|
||||
level1_dictionary =
|
||||
{
|
||||
level2_string = "stuff",
|
||||
level2_integer = 32,
|
||||
level2_dictionary = {
|
||||
level3_string = "levels",
|
||||
level3_integer = 323232
|
||||
}
|
||||
},
|
||||
level2_double = 3.4,
|
||||
level2_boolean = true
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
musicname = "music2"
|
||||
lyrics = "This is not, the greatest lyrics in the world. This is just a tribute"
|
||||
|
||||
config =
|
||||
{
|
||||
level1_string = musicname,
|
||||
level1_lyrics = lyrics,
|
||||
level1_secrets =
|
||||
{
|
||||
secret_stuff1 = "Password",
|
||||
secret_stuff2 = "123456",
|
||||
},
|
||||
level2_double = 4.3
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
setting1 = 1,
|
||||
setting2 = 2,
|
||||
t = {s = 1, t = 2, u = 3}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
setting2 = 4,
|
||||
setting3 = 1,
|
||||
t = { s = 2, v = 0},
|
||||
tt = { t = { a = "a", b = "b", ff="2" }, u = { a = "a", b = "b" } }
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
BasePathOffset = "../../.."
|
||||
|
||||
}
|
||||
5
scripts/default_startup.lua
Normal file
5
scripts/default_startup.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
--openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png')
|
||||
openspace.time.setTime("2000-01-01T00:00:00")
|
||||
openspace.time.setDeltaTime(0.0)
|
||||
|
||||
print(openspace.time.currentTimeUTC())
|
||||
102
shaders/ABuffer/abufferAddToBuffer.hglsl
Normal file
102
shaders/ABuffer/abufferAddToBuffer.hglsl
Normal file
@@ -0,0 +1,102 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
|
||||
layout (binding = 0, r32ui) uniform uimage2D anchorPointerTexture;
|
||||
layout (binding = 1, rgba32ui) uniform uimageBuffer fragmentTexture;
|
||||
layout (binding = 0, offset = 0) uniform atomic_uint atomicCounterBuffer;
|
||||
#endif
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_FIXED
|
||||
layout (binding = 0, r32ui) uniform uimage2D anchorPointerTexture;
|
||||
layout (binding = 1, rgba32ui) uniform uimageBuffer fragmentTexture;
|
||||
|
||||
#define _MAX_LAYERS_ 16
|
||||
#define _SCREEN_WIDTH_ 1280
|
||||
#define _SCREEN_HEIGHT_ 720
|
||||
#endif
|
||||
|
||||
ABufferStruct_t createGeometryFragment(vec4 fragColor, vec4 position, float z = gl_FragCoord.z) {
|
||||
ABufferStruct_t frag;
|
||||
_col_(frag, fragColor);
|
||||
_z_(frag, z);
|
||||
_type_(frag, 0);
|
||||
_pos_(frag, position);
|
||||
return frag;
|
||||
}
|
||||
|
||||
void addToBuffer(ABufferStruct_t frag) {
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
|
||||
uint index = atomicCounterIncrement(atomicCounterBuffer);
|
||||
index *= 2;
|
||||
uint old_head = imageAtomicExchange(anchorPointerTexture, ivec2(gl_FragCoord.xy), index);
|
||||
_next_(frag,old_head);
|
||||
|
||||
uvec4 p1 = uvec4(frag.z, frag.id, frag.rg, frag.ba);
|
||||
uvec4 p2 = uvec4(floatBitsToUint(frag.position.x),floatBitsToUint(frag.position.y),floatBitsToUint(frag.position.z),floatBitsToUint(frag.position.w));
|
||||
|
||||
imageStore(fragmentTexture, int(index), p1);
|
||||
imageStore(fragmentTexture, int(index+1), p2);
|
||||
#endif
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_FIXED
|
||||
uint index = imageAtomicAdd(anchorPointerTexture, ivec2(gl_FragCoord.xy), 1);
|
||||
if(index < _MAX_LAYERS_) {
|
||||
int offset = (int(gl_FragCoord.y) * _SCREEN_WIDTH_ + int(gl_FragCoord.x))*_MAX_LAYERS_ + int(index)*2;
|
||||
|
||||
uvec4 p1 = uvec4(frag.z, frag.id, frag.rg, frag.ba);
|
||||
uvec4 p2 = uvec4(floatBitsToUint(frag.position.x),floatBitsToUint(frag.position.y),floatBitsToUint(frag.position.z),floatBitsToUint(frag.position.w));
|
||||
|
||||
imageStore(fragmentTexture, int(offset ), p1);
|
||||
imageStore(fragmentTexture, int(offset+1), p2);
|
||||
} else {
|
||||
imageAtomicAdd(anchorPointerTexture, ivec2(gl_FragCoord.xy), -1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
ABufferStruct_t loadFromBuffer(uint id) {
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
|
||||
uvec4 u1 = imageLoad(fragmentTexture, int(id));
|
||||
uvec4 u2 = imageLoad(fragmentTexture, int(id+1));
|
||||
#endif
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_FIXED
|
||||
int offset = (int(gl_FragCoord.y) * _SCREEN_WIDTH_ + int(gl_FragCoord.x))*_MAX_LAYERS_ + int(id)*2;
|
||||
uvec4 u1 = imageLoad(fragmentTexture, int(offset));
|
||||
uvec4 u2 = imageLoad(fragmentTexture, int(offset+1));
|
||||
#endif
|
||||
|
||||
vec4 position = vec4( uintBitsToFloat(u2.x),
|
||||
uintBitsToFloat(u2.y),
|
||||
uintBitsToFloat(u2.z),
|
||||
uintBitsToFloat(u2.w));
|
||||
|
||||
return ABufferStruct_t(u1.x, u1.y, u1.z, u1.w, position);
|
||||
|
||||
}
|
||||
295
shaders/ABuffer/abufferResolveFragment.glsl
Normal file
295
shaders/ABuffer/abufferResolveFragment.glsl
Normal file
@@ -0,0 +1,295 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 430
|
||||
|
||||
// ================================================================================
|
||||
// Settings
|
||||
// ================================================================================
|
||||
#pragma openspace insert SETTINGS
|
||||
|
||||
// Select type of depth calculations
|
||||
#define PSCDEPTH 1
|
||||
#define ZDEPTH 2
|
||||
#define ZTYPE ZDEPTH
|
||||
|
||||
// Maximum number of fragments
|
||||
#define MAX_FRAGMENTS 16 // The size of the local fragment list
|
||||
// #define VISUALIZE_TRANSFERFUNCTIONS //
|
||||
#define USE_JITTERING //
|
||||
// #define USE_COLORNORMALIZATION //
|
||||
|
||||
// If you need to render a volume box but not sample the volume (debug purpose)
|
||||
// #define SKIP_VOLUME_0
|
||||
// #define SKIP_VOLUME_1
|
||||
// #define SKIP_VOLUME_2
|
||||
// #define SKIP_VOLUME_3
|
||||
|
||||
// constants
|
||||
const float stepSize = 0.01;
|
||||
const float samplingRate = 1.0;
|
||||
uniform float ALPHA_LIMIT = 0.99;
|
||||
|
||||
|
||||
// Math defintions
|
||||
#define M_E 2.7182818284590452354
|
||||
#define M_LOG2E 1.4426950408889634074 /* log_2 e */
|
||||
#define M_LOG10E 0.43429448190325182765 /* log_10 e */
|
||||
#define M_LN2 0.69314718055994530942 /* log_e 2 */
|
||||
#define M_LN10 2.30258509299404568402 /* log_e 10 */
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#define M_PI_4 0.78539816339744830962 /* pi/4 */
|
||||
#define M_1_PI 0.31830988618379067154 /* 1/pi */
|
||||
#define M_2_PI 0.63661977236758134308 /* 2/pi */
|
||||
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
|
||||
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
|
||||
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
|
||||
#define M_SQRT1_3 0.57735026919 /* 1/sqrt(3) */
|
||||
|
||||
in vec2 texCoord;
|
||||
out vec4 out_color;
|
||||
|
||||
// ================================================================================
|
||||
// Headers,
|
||||
// volume and transferfunctions uniforms
|
||||
// ================================================================================
|
||||
#pragma openspace insert HEADERS
|
||||
|
||||
// ================================================================================
|
||||
// The ABuffer specific includes and definitions
|
||||
// ================================================================================
|
||||
#include "abufferStruct.hglsl"
|
||||
ABufferStruct_t fragments[MAX_FRAGMENTS];
|
||||
|
||||
#if MAX_VOLUMES > 0
|
||||
vec3 volume_direction[MAX_VOLUMES];
|
||||
float volume_length[MAX_VOLUMES];
|
||||
vec3 volume_position[MAX_VOLUMES];
|
||||
int volumes_in_fragment[MAX_VOLUMES];
|
||||
int volume_count = 0;
|
||||
|
||||
#if ZTYPE == ZDEPTH
|
||||
vec2 volume_zlength[MAX_VOLUMES];
|
||||
#elif ZTYPE == PSCDEPTH
|
||||
float volume_zlength[MAX_VOLUMES];
|
||||
#endif
|
||||
#endif
|
||||
#include "abufferSort.hglsl"
|
||||
|
||||
// ================================================================================
|
||||
// Helper functions functions
|
||||
// ================================================================================
|
||||
vec3 CartesianToSpherical(vec3 _cartesian) {
|
||||
// Put cartesian in [-1..1] range first
|
||||
vec3 cartesian = vec3(-1.0,-1.0,-1.0) + _cartesian * 2.0f;
|
||||
|
||||
float r = length(cartesian);
|
||||
float theta, phi;
|
||||
|
||||
if (r == 0.0) {
|
||||
theta = phi = 0.0;
|
||||
} else {
|
||||
theta = acos(cartesian.z/r) / M_PI;
|
||||
phi = (M_PI + atan(cartesian.y, cartesian.x)) / (2.0*M_PI );
|
||||
}
|
||||
r *= M_SQRT1_3;
|
||||
// r = r / sqrt(3.0f);
|
||||
|
||||
// Sampler ignores w component
|
||||
return vec3(r, theta, phi);
|
||||
}
|
||||
|
||||
vec4 blend(vec4 src, vec4 dst) {
|
||||
vec4 o;
|
||||
o.a = src.a + dst.a * (1.0f - src.a);
|
||||
o.rgb = (src.rgb*src.a + dst.rgb*dst.a* (1.0f - src.a));
|
||||
return o;
|
||||
//return mix(src, dst, dst.a*(1.0f - src.a));
|
||||
}
|
||||
|
||||
void blendStep(inout vec4 dst, in vec4 src, in float stepSize) {
|
||||
src.a = 1.0 - pow(1.0 - src.a, stepSize );
|
||||
// src.a = 1.0 -(1.0 - src.a*stepSize);
|
||||
dst.rgb = dst.rgb + (1.0 - dst.a) * src.a * src.rgb;
|
||||
dst.a = dst.a + (1.0 -dst.a) * src.a;
|
||||
}
|
||||
|
||||
float volumeRaycastingDistance(in int id, in ABufferStruct_t startFrag, in ABufferStruct_t endFrag) {
|
||||
#if MAX_VOLUMES > 0
|
||||
#if ZTYPE == ZDEPTH
|
||||
const float S1 = volume_zlength[id].x;
|
||||
const float S2 = volume_zlength[id].y;
|
||||
const float L = S1 - S2;
|
||||
// const float z1 = globz(_z_(startFrag));
|
||||
// const float z2 = globz(_z_(endFrag));
|
||||
const float z1 = _z_(startFrag);
|
||||
const float z2 = _z_(endFrag);
|
||||
return ((z1 - S1) / L - (z2 - S1) / L) * volume_length[id];
|
||||
#elif ZTYPE == PSCDEPTH
|
||||
const float L = volume_zlength[id];
|
||||
const vec4 p1 = _pos_(startFrag);
|
||||
const vec4 p2 = _pos_(endFrag);
|
||||
const float dist = pscLength(p1, p2);
|
||||
// const float z1 = _z_(startFrag);
|
||||
// const float z2 = _z_(endFrag);
|
||||
return (dist / L) * volume_length[id];
|
||||
#endif
|
||||
#else
|
||||
return 0.f;
|
||||
#endif
|
||||
}
|
||||
|
||||
vec4 calculate_final_color(uint frag_count) {
|
||||
// volumeStepSize[volID] = 0.01;
|
||||
int currentVolumeBitmask = 0;
|
||||
vec4 final_color = vec4(0);
|
||||
|
||||
if(frag_count == 1 && _type_(fragments[0]) == 0) {
|
||||
final_color = blend(final_color, _col_(fragments[0]));
|
||||
return final_color;
|
||||
}
|
||||
|
||||
int frag_count_1 = int(frag_count)-1;
|
||||
for(int i = 0; i < frag_count_1 && final_color.a < ALPHA_LIMIT; i++) {
|
||||
|
||||
ABufferStruct_t startFrag = fragments[i];
|
||||
ABufferStruct_t endFrag = fragments[i+1];
|
||||
int type = int(_type_(startFrag));
|
||||
|
||||
if(type == 0) {
|
||||
//blendStep(final_color, _col_(startFrag), stepSize);
|
||||
final_color = blend(final_color, _col_(startFrag));
|
||||
} else {
|
||||
currentVolumeBitmask = currentVolumeBitmask ^ (1 << (type-1));
|
||||
}
|
||||
|
||||
|
||||
#if MAX_VOLUMES > 0
|
||||
if(currentVolumeBitmask > 0) {
|
||||
|
||||
|
||||
int volID;
|
||||
float myMaxSteps = 0.0000001;
|
||||
if(volume_count > 1) {
|
||||
for(int v = 0; v < volume_count; ++v) {
|
||||
int vol = volumes_in_fragment[v];
|
||||
float l = volumeRaycastingDistance(vol, startFrag, endFrag);
|
||||
myMaxSteps = max(myMaxSteps, l/volumeStepSizeOriginal[vol]);
|
||||
}
|
||||
|
||||
for(int v = 0; v < volume_count; ++v) {
|
||||
int vol = volumes_in_fragment[v];
|
||||
float l = volumeRaycastingDistance(vol, startFrag, endFrag);
|
||||
float aaa = l/myMaxSteps;
|
||||
volumeStepSize[vol] = aaa;
|
||||
volID = vol;
|
||||
}
|
||||
} else {
|
||||
volID = type -1;
|
||||
}
|
||||
|
||||
float l = volumeRaycastingDistance(volID, startFrag, endFrag);
|
||||
int max_iterations = int(l / volumeStepSize[volID]);
|
||||
|
||||
// TransferFunction
|
||||
vec4 color = vec4(0);
|
||||
for(int k = 0; k < max_iterations && final_color.a < ALPHA_LIMIT && k < LOOP_LIMIT; ++k) {
|
||||
|
||||
#pragma openspace insert SAMPLERCALLS
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//blendGeometry(final_color, startFrag);
|
||||
//if(i == maxFrags -1 && _type_(endFrag) == 0)
|
||||
// blendGeometry(final_color, endFrag);
|
||||
|
||||
// final_color = blend(final_color, frag_color);
|
||||
if(i == frag_count_1 -1 && _type_(endFrag) == 0)
|
||||
// if(i == frag_count_1 -1)
|
||||
final_color = blend(final_color, _col_(endFrag));
|
||||
|
||||
}
|
||||
// final_color = vec4(0);
|
||||
// int id =3;
|
||||
// if(id < frag_count)final_color = blend(final_color, _col_(fragments[id]));
|
||||
|
||||
// if(frag_count > 0)
|
||||
// final_color = _col_(fragments[0]);
|
||||
|
||||
// ================================================================================
|
||||
// Transferfunction visualizer
|
||||
// ================================================================================
|
||||
#ifdef VISUALIZE_TRANSFERFUNCTIONS
|
||||
#pragma openspace insert TRANSFERFUNC
|
||||
#endif
|
||||
|
||||
// if(frag_count == 1) {
|
||||
// final_color = vec4(1.0,0.0,0.0,1.0);
|
||||
// } else if(frag_count == 2) {
|
||||
// final_color = vec4(0.0,1.0,0.0,1.0);
|
||||
// // final_color = vec4(volume_direction[0],1.0);
|
||||
// } else if(frag_count == 3) {
|
||||
// final_color = vec4(0.0,0.0,1.0,1.0);
|
||||
// // final_color = vec4(volume_direction[0],1.0);
|
||||
// } else if(frag_count == 4) {
|
||||
// final_color = vec4(1.0,1.0,0.0,1.0);
|
||||
// // final_color = vec4(volume_direction[0],1.0);
|
||||
// } else {
|
||||
// final_color = vec4(1.0,1.0,1.0,1.0);
|
||||
// }
|
||||
|
||||
#ifdef USE_COLORNORMALIZATION
|
||||
final_color.rgb = final_color.rgb * final_color.a;
|
||||
final_color.a = 1.0;
|
||||
#endif
|
||||
|
||||
return final_color;
|
||||
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
// Main function
|
||||
// ================================================================================
|
||||
void main() {
|
||||
out_color = vec4(texCoord,0.0,1.0);
|
||||
int frag_count = build_local_fragments_list();
|
||||
sort_fragments_list(frag_count);
|
||||
out_color = calculate_final_color(frag_count);
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
// The samplers implementations
|
||||
// ================================================================================
|
||||
#pragma openspace insert SAMPLERS
|
||||
|
||||
|
||||
|
||||
33
shaders/ABuffer/abufferResolveVertex.glsl
Normal file
33
shaders/ABuffer/abufferResolveVertex.glsl
Normal file
@@ -0,0 +1,33 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 430
|
||||
|
||||
in vec4 position;
|
||||
out vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = position;
|
||||
texCoord = 0.5 + position.xy / 2.0;
|
||||
}
|
||||
141
shaders/ABuffer/abufferSort.hglsl
Normal file
141
shaders/ABuffer/abufferSort.hglsl
Normal file
@@ -0,0 +1,141 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "abufferAddToBuffer.hglsl"
|
||||
|
||||
uniform float volumeStepFactor = 1.0f;
|
||||
|
||||
int build_local_fragments_list() {
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
|
||||
uint current;
|
||||
int frag_count = 0;
|
||||
|
||||
current = imageLoad(anchorPointerTexture, ivec2(gl_FragCoord.xy)).x;
|
||||
|
||||
while(current != 0 && frag_count < MAX_FRAGMENTS) {
|
||||
ABufferStruct_t item = loadFromBuffer(current);
|
||||
current = _next_(item);
|
||||
|
||||
fragments[frag_count] = item;
|
||||
|
||||
frag_count++;
|
||||
}
|
||||
|
||||
return frag_count;
|
||||
#endif
|
||||
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_FIXED
|
||||
uint frag_count = imageLoad(anchorPointerTexture, ivec2(gl_FragCoord.xy)).x;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < frag_count && i < MAX_FRAGMENTS; ++i) {
|
||||
fragments[i] = loadFromBuffer(i);
|
||||
}
|
||||
|
||||
return int(frag_count);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
float pscLength(vec4 v1, vec4 v2) {
|
||||
const float k = 10.0;
|
||||
float ds = v2.w - v1.w;
|
||||
vec4 vector;
|
||||
if(ds >= 0) {
|
||||
float p = pow(k,-ds);
|
||||
vector = vec4(v1.x*p - v2.x, v1.y*p - v2.y, v1.z*p - v2.z, v2.w);
|
||||
} else {
|
||||
float p = pow(k,ds);
|
||||
vector = vec4(v1.x - v2.x*p, v1.y - v2.y*p, v1.z - v2.z*p, v1.w);
|
||||
}
|
||||
return length(vector.xyz)*pow(k,vector.w);
|
||||
}
|
||||
|
||||
float permute(float i) {
|
||||
return mod((62.0*i*i + i), 961.0); // permutation polynomial; 62=2*31; 961=31*31
|
||||
}
|
||||
|
||||
void sort_fragments_list(uint frag_count) {
|
||||
uint i,j;
|
||||
ABufferStruct_t tmp;
|
||||
|
||||
// INSERTION SORT
|
||||
for(i = 1; i < frag_count; ++i) {
|
||||
tmp = fragments[i];
|
||||
for(j = i; j > 0 && _z_(tmp) < _z_(fragments[j-1]); --j) {
|
||||
fragments[j] = fragments[j-1];
|
||||
}
|
||||
fragments[j] = tmp;
|
||||
}
|
||||
|
||||
#if MAX_VOLUMES > 0
|
||||
int ii, jj;
|
||||
for(ii = 0; ii < MAX_VOLUMES; ++ii) {
|
||||
bool start = true;
|
||||
vec3 startColor;
|
||||
vec4 startPosition;
|
||||
for(jj = 0; jj < frag_count; ++jj) {
|
||||
int type = int(_type_(fragments[jj])) - 1;
|
||||
if(type== ii) {
|
||||
if(start) {
|
||||
startColor = _col_(fragments[jj]).rgb;
|
||||
startPosition = _pos_(fragments[jj]);
|
||||
#if ZTYPE == ZDEPTH
|
||||
volume_zlength[ii].x = _z_(fragments[jj]);
|
||||
#endif
|
||||
start = false;
|
||||
} else {
|
||||
volumes_in_fragment[volume_count++] = ii;
|
||||
vec3 dir = _col_(fragments[jj]).rgb - startColor;
|
||||
volume_position[ii] = startColor;
|
||||
volume_length[ii] = length(dir);
|
||||
volume_direction[ii] = normalize(dir);
|
||||
volumeStepSize[ii] = 1.0/(volumeStepFactor * length(volume_direction[ii]*volume_dim[ii]));
|
||||
volumeStepSizeOriginal[ii] = volumeStepSize[ii];
|
||||
#if ZTYPE == ZDEPTH
|
||||
volume_zlength[ii].y = _z_(fragments[jj]);
|
||||
#elif ZTYPE == PSCDEPTH
|
||||
volume_zlength[ii] = pscLength(_pos_(fragments[jj]), startPosition);
|
||||
#endif
|
||||
#ifdef USE_JITTERING
|
||||
if(volumeStepSize[ii] < volume_length[ii]) {
|
||||
// jittering
|
||||
float x = gl_FragCoord.x;
|
||||
float y = gl_FragCoord.y;
|
||||
float jitterValue = float(permute(x + permute(y))) / 961.0;
|
||||
vec3 frontPosNew = startColor + (jitterValue*volumeStepSize[ii])*volume_direction[ii];
|
||||
volume_position[ii] = frontPosNew;
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//volume_direction[0] = vec3(1.0,0.0,0.0);
|
||||
//volume_direction[0] = _col_(fragments[0]).rgb;
|
||||
}
|
||||
162
shaders/ABuffer/abufferStruct.hglsl
Normal file
162
shaders/ABuffer/abufferStruct.hglsl
Normal file
@@ -0,0 +1,162 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef ABUFFERSTRUCT_H_HGLSL
|
||||
#define ABUFFERSTRUCT_H_HGLSL
|
||||
|
||||
// The different kinds of implementation, set from OpenSpace
|
||||
// #define ABUFFER_SINGLE_LINKED 1
|
||||
// #define ABUFFER_FIXED 2
|
||||
// #define ABUFFER_DYNAMIC 3
|
||||
// #define ABUFFER_IMPLEMENTATION ABUFFER_SINGLE_LINKED
|
||||
|
||||
|
||||
//========================================================================================
|
||||
// ABufferStruct_t declaration
|
||||
//========================================================================================
|
||||
// struct ABufferStruct_t {
|
||||
// uint z; // the depth value
|
||||
// uint id; // bits 0-28 next, bits 29-32 type
|
||||
// vec4 color; // packed rgba
|
||||
// //vec4 position; // packed position
|
||||
// // uint padding1;
|
||||
// // uint padding2;
|
||||
// };
|
||||
struct ABufferStruct_t {
|
||||
uint z; // the depth value
|
||||
uint id; // bits 0-28 next, bits 29-32 type
|
||||
uint rg; // packed red green color
|
||||
uint ba; // packed blue alpha color
|
||||
vec4 position; // position
|
||||
};
|
||||
|
||||
|
||||
//========================================================================================
|
||||
// Bitwise operations
|
||||
//========================================================================================
|
||||
const uint mask_1 = 1;
|
||||
const uint mask_8 = 255;
|
||||
const uint mask_16 = 65535;
|
||||
const uint mask_24 = 16777215;
|
||||
const uint mask_29 = 536870911;
|
||||
const uint mask_30 = 1073741823;
|
||||
const uint mask_31 = 2147483647;
|
||||
const uint mask_32 = 4294967295;
|
||||
const uint mask_id = mask_16;
|
||||
const uint shift_id = 0;
|
||||
const uint mask_type = mask_24 - mask_16;
|
||||
const uint shift_type = 16;
|
||||
/*
|
||||
const uint mask_zid_z = mask_24;
|
||||
const uint shift_zid_z = 0;
|
||||
const uint mask_zid_id = mask_29 - mask_24;
|
||||
const uint shift_zid_id = 24;
|
||||
const uint mask_zid_type = mask_31 - mask_29;
|
||||
const uint shift_zid_type = 29;
|
||||
const uint mask_zid_xxx = mask_32 - mask_31;
|
||||
const uint shift_zid_xxx = 31;
|
||||
*/
|
||||
|
||||
const uint mask_id_next = mask_29;
|
||||
const uint shift_id_next = 0;
|
||||
const uint mask_id_type = mask_32 - mask_29;
|
||||
const uint shift_id_type = 29;
|
||||
|
||||
void bitinsert_u(inout uint pack, uint val, uint mask, uint shift) {
|
||||
pack &= ~mask;
|
||||
pack |= (val << shift) & mask;
|
||||
}
|
||||
uint bitextract_u(in uint pack, uint mask, uint shift) {
|
||||
return (pack >> shift) & (mask >> shift);
|
||||
}
|
||||
void bitinsert_i(inout int pack, int val, uint mask, uint shift) {
|
||||
pack &= int( ~mask );
|
||||
pack |= int( (uint(val) << shift) & mask );
|
||||
}
|
||||
int bitextract_i(in int pack, uint mask, uint shift) {
|
||||
return int( (uint(pack) >> shift) & (mask >> shift) );
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// Access functions
|
||||
//========================================================================================
|
||||
float _z_(ABufferStruct_t frag) {
|
||||
return uintBitsToFloat(frag.z);
|
||||
}
|
||||
void _z_(inout ABufferStruct_t frag, float z) {
|
||||
frag.z = floatBitsToUint(z);
|
||||
}
|
||||
|
||||
vec4 _pos_(ABufferStruct_t frag) {
|
||||
// return vec4(0.0,0.0,0.0,0.0);
|
||||
return frag.position;
|
||||
//return unpackUnorm4x8(frag.position);
|
||||
}
|
||||
void _pos_(inout ABufferStruct_t frag, vec4 position) {
|
||||
frag.position = position;
|
||||
// frag.position = packUnorm4x8(position);
|
||||
}
|
||||
|
||||
vec4 _col_(ABufferStruct_t frag) {
|
||||
return vec4(unpackUnorm2x16(frag.rg),unpackUnorm2x16(frag.ba));
|
||||
//return unpackUnorm4x8(frag.color);
|
||||
}
|
||||
void _col_(inout ABufferStruct_t frag, vec4 color) {
|
||||
frag.rg = packUnorm2x16(color.rg);
|
||||
frag.ba = packUnorm2x16(color.ba);
|
||||
//frag.color = packUnorm4x8(color);
|
||||
}
|
||||
|
||||
uint _type_(ABufferStruct_t frag) {
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
|
||||
return bitextract_u(frag.id, mask_id_type, shift_id_type);
|
||||
#else
|
||||
return frag.id;
|
||||
#endif
|
||||
}
|
||||
void _type_(inout ABufferStruct_t frag, uint type) {
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
|
||||
bitinsert_u(frag.id, type, mask_id_type, shift_id_type);
|
||||
#else
|
||||
frag.id = type;
|
||||
#endif
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// Implementation specific functions
|
||||
//========================================================================================
|
||||
|
||||
// _next_ is only needed for the single linked implementation
|
||||
#if ABUFFER_IMPLEMENTATION == ABUFFER_SINGLE_LINKED
|
||||
uint _next_(ABufferStruct_t frag) {
|
||||
return bitextract_u(frag.id, mask_id_next, shift_id_next);
|
||||
//return frag.id;
|
||||
}
|
||||
void _next_(inout ABufferStruct_t frag, uint id) {
|
||||
bitinsert_u(frag.id, id, mask_id_next, shift_id_next);
|
||||
//frag.id = id;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
90
shaders/PowerScaling/powerScaling_fs.hglsl
Normal file
90
shaders/PowerScaling/powerScaling_fs.hglsl
Normal file
@@ -0,0 +1,90 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef POWERSCALING_FS_H_HGLSL
|
||||
#define POWERSCALING_FS_H_HGLSL
|
||||
|
||||
// Observable universe is 10^27m, setting the far value to extremely high, aka 30!! ERMAHGERD!
|
||||
|
||||
const float k = 10.0;
|
||||
const float s_far = 27.0f; //= gl_DepthRange.far; // 40
|
||||
const float s_farcutoff = 12.0f;
|
||||
const float s_nearcutoff = 7.00f;
|
||||
const float s_near = 0.00f;// gl_DepthRange.near; // 0.1
|
||||
|
||||
vec4 psc_normlization(vec4 invec) {
|
||||
|
||||
float xymax = max(invec.x,invec.y);
|
||||
|
||||
if(invec.z > 0.0f || invec.z < 0.0f) {
|
||||
return invec / abs(invec.z);
|
||||
} else if (xymax != 0.0f) {
|
||||
return invec / xymax;
|
||||
} else {
|
||||
return invec / -.0;
|
||||
}
|
||||
}
|
||||
|
||||
float pscDepth(vec4 position) {
|
||||
float depth = 0.0f;
|
||||
if(position.w <= 0.5) {
|
||||
//depth = abs(position.z * pow(10, position.w)) / pow(k,s_far);
|
||||
depth = (position.w+log(abs(position.z)))/pow(k, position.w);
|
||||
} else if(position.w < 3.0) {
|
||||
depth = position.w+log(abs(position.z))/pow(k, position.w);
|
||||
} else {
|
||||
depth = position.w+log(abs(position.z));
|
||||
}
|
||||
|
||||
|
||||
// DEBUG
|
||||
float depth_orig = depth;
|
||||
float x = 0.0f;
|
||||
float cutoffs = 0.0;
|
||||
float orig_z = position.z;
|
||||
|
||||
// calculate a normalized depth [0.0 1.0]
|
||||
if((depth > s_near && depth <= s_nearcutoff) || (depth > s_farcutoff && depth < s_far)) {
|
||||
|
||||
// completely linear interpolation [s_near .. depth .. s_far]
|
||||
depth = (depth - s_near) / (s_far - s_near);
|
||||
|
||||
} else if(depth > s_nearcutoff && depth < s_farcutoff) {
|
||||
|
||||
// DEBUG
|
||||
cutoffs = 1.0;
|
||||
|
||||
// interpolate [10^s_nearcutoff .. 10^depth .. 10^s_farcutoff]
|
||||
// calculate between 0..1 where the depth is
|
||||
x = (pow(10,depth) - pow(10, s_nearcutoff)) / (pow(10,s_farcutoff) - pow(10, s_nearcutoff));
|
||||
|
||||
// remap the depth to the 0..1 depth buffer
|
||||
depth = s_nearcutoff + x * (s_farcutoff - s_nearcutoff);
|
||||
depth = (depth - s_near) / (s_far - s_near);
|
||||
|
||||
}
|
||||
return depth;
|
||||
}
|
||||
|
||||
#endif
|
||||
80
shaders/PowerScaling/powerScaling_vs.hglsl
Normal file
80
shaders/PowerScaling/powerScaling_vs.hglsl
Normal file
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef POWERSCALING_VS_H_HGLSL
|
||||
#define POWERSCALING_VS_H_HGLSL
|
||||
|
||||
const float k = 10.0;
|
||||
|
||||
vec4 psc_addition(vec4 v1, vec4 v2) {
|
||||
float ds = v2.w - v1.w;
|
||||
if(ds >= 0) {
|
||||
float p = pow(k,-ds);
|
||||
return vec4(v1.x*p + v2.x, v1.y*p + v2.y, v1.z*p + v2.z, v2.w);
|
||||
} else {
|
||||
float p = pow(k,ds);
|
||||
return vec4(v1.x + v2.x*p, v1.y + v2.y*p, v1.z + v2.z*p, v1.w);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 psc_to_meter(vec4 v1, vec2 v2) {
|
||||
float factor = v2.x * pow(k,v2.y + v1.w);
|
||||
return vec4(v1.xyz * factor, 1.0);
|
||||
}
|
||||
|
||||
vec4 psc_scaling(vec4 v1, vec2 v2) {
|
||||
float ds = v2.y - v1.w;
|
||||
if(ds >= 0) {
|
||||
return vec4(v1.xyz * v2.x * pow(k,v1.w), v2.y);
|
||||
} else {
|
||||
return vec4(v1.xyz * v2.x * pow(k,v2.y), v1.w);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 pscTransform(vec4 vertexPosition, vec4 cameraPosition, vec2 scaling, mat4 modelTransform) {
|
||||
vec3 local_vertex_pos = mat3(modelTransform) * vertexPosition.xyz;
|
||||
//vec4 lvp = ModelTransform * vertexPosition;
|
||||
|
||||
// PSC addition; local vertex position and the object power scaled world position
|
||||
vec4 position = psc_addition(vec4(local_vertex_pos,vertexPosition.w),objpos);
|
||||
//position = psc_addition(lvp,objpos);
|
||||
|
||||
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
|
||||
position = psc_addition(position,vec4(-cameraPosition.xyz,cameraPosition.w));
|
||||
|
||||
// rotate the camera
|
||||
local_vertex_pos = mat3(camrot) * position.xyz;
|
||||
position = vec4(local_vertex_pos, position.w);
|
||||
//position = camrot* position;
|
||||
|
||||
// rescales the scene to fit inside the view frustum
|
||||
// is set from the main program, but these are decent values
|
||||
// scaling = vec2(1.0, -8.0);
|
||||
|
||||
// project using the rescaled coordinates,
|
||||
//vec4 vs_position_rescaled = psc_scaling(position, scaling);
|
||||
return psc_to_meter(position, scaling);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
in vec4 color;
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
uniform mat4 projectionMatrix;
|
||||
|
||||
@@ -1,8 +1,52 @@
|
||||
#version 400 core
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 430 core
|
||||
|
||||
uniform int volumeType;
|
||||
|
||||
in vec3 vPosition;
|
||||
out vec4 fragColor;
|
||||
in vec3 worldPosition;
|
||||
in float s;
|
||||
|
||||
#include "ABuffer/abufferStruct.hglsl"
|
||||
#include "ABuffer/abufferAddToBuffer.hglsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
void main() {
|
||||
fragColor = vec4(vPosition+0.5, 1.0);
|
||||
vec4 fragColor = vec4(vPosition+0.5, 1.0);
|
||||
vec4 position = vec4(worldPosition,s);
|
||||
float depth = pscDepth(position);
|
||||
|
||||
gl_FragDepth = depth;
|
||||
|
||||
ABufferStruct_t frag;
|
||||
_col_(frag, fragColor);
|
||||
_z_(frag, depth);
|
||||
_type_(frag, volumeType);
|
||||
_pos_(frag, position);
|
||||
addToBuffer(frag);
|
||||
|
||||
discard;
|
||||
}
|
||||
@@ -1,11 +1,62 @@
|
||||
#version 400 core
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec4 vertPosition;
|
||||
|
||||
layout(location = 2) in vec3 vertPosition;
|
||||
uniform mat4 modelViewProjection;
|
||||
uniform mat4 modelTransform;
|
||||
uniform vec4 campos;
|
||||
uniform mat4 camrot;
|
||||
uniform vec2 scaling;
|
||||
uniform vec4 objpos;
|
||||
|
||||
out vec3 vPosition;
|
||||
out vec3 worldPosition;
|
||||
out float s;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
gl_Position = modelViewProjection * vec4(vertPosition, 1.0);
|
||||
vPosition = vertPosition;
|
||||
|
||||
//vs_st = in_st;
|
||||
//vs_stp = in_position.xyz;
|
||||
|
||||
vPosition = vertPosition.xyz;
|
||||
|
||||
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
|
||||
//vs_normal = normalize(modelTransform * vec4(in_normal,0));
|
||||
|
||||
vec4 position = pscTransform(vertPosition, campos, scaling, modelTransform);
|
||||
worldPosition = position.xyz;
|
||||
s = position.w;
|
||||
|
||||
// project the position to view space
|
||||
gl_Position = modelViewProjection * position;
|
||||
|
||||
// vPosition = vertPosition.xyz;
|
||||
// worldPosition = (modelTransform *vec4(vPosition, 1.0)).xyz;
|
||||
// gl_Position = modelViewProjection *vec4(worldPosition, 1.0);
|
||||
}
|
||||
@@ -1,115 +1,49 @@
|
||||
/**
|
||||
Copyright (C) 2012-2014 Jonas Strandstedt
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
#version 430
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#version 400 core
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
uniform vec4 campos;
|
||||
uniform vec4 objpos;
|
||||
uniform float time;
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D texture2;
|
||||
uniform sampler2D texture3;
|
||||
uniform float TessLevel;
|
||||
uniform bool Wireframe;
|
||||
uniform bool Lightsource;
|
||||
uniform bool UseTexture;
|
||||
|
||||
in vec2 vs_st;
|
||||
//in vec3 vs_stp;
|
||||
in vec4 vs_normal;
|
||||
in vec4 vs_position;
|
||||
in vec3 vs_position;
|
||||
in float s;
|
||||
|
||||
out vec4 diffuse;
|
||||
|
||||
const float k = 10.0;
|
||||
|
||||
vec4 psc_normlization(vec4 invec) {
|
||||
|
||||
float xymax = max(invec.x,invec.y);
|
||||
|
||||
if(invec.z > 0.0f || invec.z < 0.0f) {
|
||||
return invec / abs(invec.z);
|
||||
} else if (xymax != 0.0f) {
|
||||
return invec / xymax;
|
||||
} else {
|
||||
return invec / -.0;
|
||||
}
|
||||
}
|
||||
#include "ABuffer/abufferStruct.hglsl"
|
||||
#include "ABuffer/abufferAddToBuffer.hglsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 position = vec4(vs_position,s);
|
||||
float depth = pscDepth(position);
|
||||
vec4 diffuse = texture(texture1, vs_st);
|
||||
|
||||
// Observable universe is 10^27m, setting the far value to extremely high, aka 30!! ERMAHGERD!
|
||||
float s_far = 40.0; //= gl_DepthRange.far; // 40
|
||||
float s_farcutoff = 12.0;
|
||||
float s_nearcutoff = 7.0;
|
||||
float s_near = 0.0f;// gl_DepthRange.near; // 0.1
|
||||
float depth;
|
||||
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
|
||||
addToBuffer(frag);
|
||||
|
||||
// the value can be normalized to 1
|
||||
|
||||
vec4 p = vs_position;
|
||||
if(vs_position.w <= 0.5) {
|
||||
//depth = abs(vs_position.z * pow(10, vs_position.w)) / pow(k,s_far);
|
||||
depth = (vs_position.w+log(abs(vs_position.z)))/pow(k, vs_position.w);
|
||||
} else if(vs_position.w < 3.0) {
|
||||
depth = vs_position.w+log(abs(vs_position.z))/pow(k, vs_position.w);
|
||||
} else {
|
||||
depth = vs_position.w+log(abs(vs_position.z));
|
||||
}
|
||||
|
||||
|
||||
// DEBUG
|
||||
float depth_orig = depth;
|
||||
float x = 0.0f;
|
||||
float cutoffs = 0.0;
|
||||
float orig_z = vs_position.z;
|
||||
|
||||
// calculate a normalized depth [0.0 1.0]
|
||||
if((depth > s_near && depth <= s_nearcutoff) || (depth > s_farcutoff && depth < s_far)) {
|
||||
|
||||
// completely linear interpolation [s_near .. depth .. s_far]
|
||||
depth = (depth - s_near) / (s_far - s_near);
|
||||
|
||||
} else if(depth > s_nearcutoff && depth < s_farcutoff) {
|
||||
|
||||
// DEBUG
|
||||
cutoffs = 1.0;
|
||||
|
||||
// interpolate [10^s_nearcutoff .. 10^depth .. 10^s_farcutoff]
|
||||
// calculate between 0..1 where the depth is
|
||||
x = (pow(10,depth) - pow(10, s_nearcutoff)) / (pow(10,s_farcutoff) - pow(10, s_nearcutoff));
|
||||
|
||||
// remap the depth to the 0..1 depth buffer
|
||||
depth = s_nearcutoff + x * (s_farcutoff - s_nearcutoff);
|
||||
depth = (depth - s_near) / (s_far - s_near);
|
||||
|
||||
} else {
|
||||
// where am I?
|
||||
// do I need to be discarded?
|
||||
// discard;
|
||||
}
|
||||
|
||||
|
||||
// set the depth
|
||||
gl_FragDepth = depth;
|
||||
//gl_FragDepth = 0.5;
|
||||
|
||||
// color
|
||||
diffuse = texture(texture1, vs_st);
|
||||
//diffuse = vec4(vs_position.z,0.0, 0.0, 1.0);
|
||||
// diffuse = vec4(vs_position.xyz * pow(10, vs_position.w), 1.0);
|
||||
//diffuse = vec4(vs_st, 0.0, 1.0);
|
||||
//diffuse = vec4(1.0,1.0, 0.0, 1.0);
|
||||
//diffuse = vec4(depth*5,0.0, 0.0, 1.0);
|
||||
//diffuse = vec4(vs_position.w,0.0, 0.0, 1.0);
|
||||
//diffuse = vec4(1.0,0.0,0.0,1.0);
|
||||
discard;
|
||||
}
|
||||
@@ -1,25 +1,28 @@
|
||||
/**
|
||||
Copyright (C) 2012-2014 Jonas Strandstedt
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#version 400 core
|
||||
#version 430
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
@@ -28,13 +31,6 @@ uniform mat4 camrot;
|
||||
uniform vec2 scaling;
|
||||
uniform vec4 objpos;
|
||||
uniform float time;
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D texture2;
|
||||
uniform sampler2D texture3;
|
||||
uniform float TessLevel;
|
||||
uniform bool Wireframe;
|
||||
uniform bool Lightsource;
|
||||
uniform bool UseTexture;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
//in vec3 in_position;
|
||||
@@ -44,72 +40,24 @@ layout(location = 2) in vec3 in_normal;
|
||||
out vec2 vs_st;
|
||||
out vec3 vs_stp;
|
||||
out vec4 vs_normal;
|
||||
out vec4 vs_position;
|
||||
out vec3 vs_position;
|
||||
out float s;
|
||||
|
||||
const float k = 10.0;
|
||||
const float dgr_to_rad = 0.0174532925;
|
||||
|
||||
vec4 psc_addition(vec4 v1, vec4 v2) {
|
||||
float ds = v2.w - v1.w;
|
||||
if(ds >= 0) {
|
||||
float p = pow(k,-ds);
|
||||
return vec4(v1.x*p + v2.x, v1.y*p + v2.y, v1.z*p + v2.z, v2.w);
|
||||
} else {
|
||||
float p = pow(k,ds);
|
||||
return vec4(v1.x + v2.x*p, v1.y + v2.y*p, v1.z + v2.z*p, v1.w);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 psc_to_meter(vec4 v1, vec2 v2) {
|
||||
float factor = v2.x * pow(k,v2.y + v1.w);
|
||||
return vec4(v1.xyz * factor, 1.0);
|
||||
}
|
||||
|
||||
vec4 psc_scaling(vec4 v1, vec2 v2) {
|
||||
float ds = v2.y - v1.w;
|
||||
if(ds >= 0) {
|
||||
return vec4(v1.xyz * v2.x * pow(k,v1.w), v2.y);
|
||||
} else {
|
||||
return vec4(v1.xyz * v2.x * pow(k,v2.y), v1.w);
|
||||
}
|
||||
}
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
// set variables
|
||||
vs_st = in_st;
|
||||
//vs_stp = in_position.xyz;
|
||||
|
||||
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
|
||||
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
|
||||
|
||||
// fetch model and view translation
|
||||
//vec4 vertex_translate = ModelTransform[3];
|
||||
|
||||
// rotate and scale vertex with model transform and add the translation
|
||||
vec3 local_vertex_pos = mat3(ModelTransform) * in_position.xyz;
|
||||
//vec4 lvp = ModelTransform * in_position;
|
||||
|
||||
// PSC addition; local vertex position and the object power scaled world position
|
||||
vs_position = psc_addition(vec4(local_vertex_pos,in_position.w),objpos);
|
||||
//vs_position = psc_addition(lvp,objpos);
|
||||
|
||||
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
|
||||
vs_position = psc_addition(vs_position,vec4(-campos.xyz,campos.w));
|
||||
|
||||
// rotate the camera
|
||||
local_vertex_pos = mat3(camrot) * vs_position.xyz;
|
||||
vs_position = vec4(local_vertex_pos, vs_position.w);
|
||||
//vs_position = camrot* vs_position;
|
||||
|
||||
// rescales the scene to fit inside the view frustum
|
||||
// is set from the main program, but these are decent values
|
||||
// scaling = vec2(1.0, -8.0);
|
||||
|
||||
// project using the rescaled coordinates,
|
||||
//vec4 vs_position_rescaled = psc_scaling(vs_position, scaling);
|
||||
vec4 vs_position_rescaled = psc_to_meter(vs_position, scaling);
|
||||
//vs_position = vs_position_rescaled;
|
||||
|
||||
vec4 position = pscTransform(in_position, campos, scaling, ModelTransform);
|
||||
vs_position = position.xyz;
|
||||
s = position.w;
|
||||
|
||||
// project the position to view space
|
||||
gl_Position = ViewProjection * vs_position_rescaled;
|
||||
gl_Position = ViewProjection * position;
|
||||
}
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
uniform sampler2D quadTex;
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
layout(location = 0) in vec2 texCoordinate;
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 330
|
||||
|
||||
in vec4 position;
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 400 core
|
||||
|
||||
// Based on http://prideout.net/blog/?p=64
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 400 core
|
||||
|
||||
// Based on http://prideout.net/blog/?p=64
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 400 core
|
||||
|
||||
// Based on http://prideout.net/blog/?p=64
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 400 core
|
||||
|
||||
uniform sampler2D texBack, texFront;
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 400 core
|
||||
|
||||
layout(location = 0) in vec2 texCoordinate;
|
||||
|
||||
@@ -34,6 +34,12 @@ file(GLOB CONFIGURATION_HEADER ${HEADER_ROOT_DIR}/openspace/configuration/*.h)
|
||||
set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${CONFIGURATION_HEADER})
|
||||
source_group(Configuration FILES ${CONFIGURATION_SOURCE} ${CONFIGURATION_HEADER})
|
||||
|
||||
file(GLOB ABUFFER_SOURCE ${SOURCE_ROOT_DIR}/abuffer/*.cpp)
|
||||
set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${ABUFFER_SOURCE})
|
||||
file(GLOB ABUFFER_HEADER ${HEADER_ROOT_DIR}/openspace/abuffer/*.h)
|
||||
set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${ABUFFER_HEADER})
|
||||
source_group(ABuffer FILES ${ABUFFER_SOURCE} ${ABUFFER_HEADER})
|
||||
|
||||
file(GLOB ENGINE_SOURCE ${SOURCE_ROOT_DIR}/engine/*.cpp)
|
||||
set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${ENGINE_SOURCE})
|
||||
file(GLOB ENGINE_HEADER ${HEADER_ROOT_DIR}/openspace/engine/*.h)
|
||||
@@ -90,6 +96,12 @@ file(GLOB SCENEGRAPH_HEADER ${HEADER_ROOT_DIR}/openspace/scenegraph/*.h ${HEADER
|
||||
set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${SCENEGRAPH_HEADER})
|
||||
source_group(SceneGraph FILES ${SCENEGRAPH_SOURCE} ${SCENEGRAPH_HEADER})
|
||||
|
||||
file(GLOB SCRIPTING_SOURCE ${SOURCE_ROOT_DIR}/scripting/*.cpp)
|
||||
set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${SCRIPTING_SOURCE})
|
||||
file(GLOB SCRIPTING_HEADER ${HEADER_ROOT_DIR}/openspace/scripting/*.h)
|
||||
set(OPENSPACE_HEADER ${OPENSPACE_HEADER} ${SCRIPTING_HEADER})
|
||||
source_group(Scripting FILES ${SCRIPTING_SOURCE} ${SCRIPTING_HEADER})
|
||||
|
||||
file(GLOB UTIL_SOURCE ${SOURCE_ROOT_DIR}/util/*.cpp)
|
||||
set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${UTIL_SOURCE})
|
||||
file(GLOB UTIL_HEADER ${HEADER_ROOT_DIR}/openspace/util/*.h)
|
||||
@@ -136,5 +148,23 @@ include_directories("${HEADER_ROOT_DIR}")
|
||||
add_executable(OpenSpace ${SOURCE_ROOT_DIR}/main.cpp ${OPENSPACE_HEADER} ${OPENSPACE_SOURCE})
|
||||
target_link_libraries(OpenSpace ${DEPENDENT_LIBS})
|
||||
|
||||
if (WIN32)
|
||||
if (CMAKE_CL_64)
|
||||
set(OPENSPACE_DLL_LIBS ${OPENSPACE_DLL_LIBS} ${GHOUL_ROOT_DIR}/ext/il/lib/win64/DevIL.dll)
|
||||
set(OPENSPACE_DLL_LIBS ${OPENSPACE_DLL_LIBS} ${GHOUL_ROOT_DIR}/ext/il/lib/win64/ILU.dll)
|
||||
set(OPENSPACE_DLL_LIBS ${OPENSPACE_DLL_LIBS} ${GHOUL_ROOT_DIR}/ext/il/lib/win64/ILUT.dll)
|
||||
else (CMAKE_CL_64)
|
||||
set(OPENSPACE_DLL_LIBS ${OPENSPACE_DLL_LIBS} ${GHOUL_ROOT_DIR}/ext/il/lib/win32/DevIL.dll)
|
||||
set(OPENSPACE_DLL_LIBS ${OPENSPACE_DLL_LIBS} ${GHOUL_ROOT_DIR}/ext/il/lib/win32/ILU.dll)
|
||||
set(OPENSPACE_DLL_LIBS ${OPENSPACE_DLL_LIBS} ${GHOUL_ROOT_DIR}/ext/il/lib/win32/ILUT.dll)
|
||||
endif (CMAKE_CL_64)
|
||||
foreach( file_i ${OPENSPACE_DLL_LIBS})
|
||||
add_custom_command(TARGET OpenSpace POST_BUILD # Adds a post-build event to MyTest
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
|
||||
"${file_i}" # <--this is in-file
|
||||
$<TARGET_FILE_DIR:OpenSpace>)
|
||||
endforeach( file_i )
|
||||
endif(WIN32)
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
|
||||
379
src/abuffer/abuffer.cpp
Normal file
379
src/abuffer/abuffer.cpp
Normal file
@@ -0,0 +1,379 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/abuffer/abuffer.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <sgct.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
std::string _loggerCat = "ABuffer";
|
||||
|
||||
std::string padGeneratedString(const std::string& content) {
|
||||
std::string _content_ = "// GENERATED CONTENT\n" + content + "\n// END GENERATED CONTENT";
|
||||
return _content_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ABuffer::ABuffer(): _validShader(true) {
|
||||
int x1, xSize, y1, ySize;
|
||||
sgct::Engine::instance()->getActiveWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
|
||||
_width = xSize;
|
||||
_height = ySize;
|
||||
_totalPixels = _width * _height;
|
||||
const std::string fragmentShaderSourcePath = absPath("${SHADERS}/ABuffer/abufferResolveFragment.glsl");
|
||||
_fragmentShaderFile = new ghoul::filesystem::File(fragmentShaderSourcePath, true);
|
||||
_fragmentShaderPath = fragmentShaderSourcePath.substr(0, fragmentShaderSourcePath.length()-4) + "gglsl";
|
||||
}
|
||||
|
||||
ABuffer::~ABuffer() {
|
||||
if(_fragmentShaderFile)
|
||||
delete _fragmentShaderFile;
|
||||
|
||||
if(_resolveShader)
|
||||
delete _resolveShader;
|
||||
|
||||
for(auto file: _samplerFiles) {
|
||||
delete file;
|
||||
}
|
||||
for(auto file: _shaderFiles) {
|
||||
delete file;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ABuffer::initializeABuffer() {
|
||||
// ============================
|
||||
// SHADERS
|
||||
// ============================
|
||||
auto shaderCallback = [this](const ghoul::filesystem::File& file) {
|
||||
_validShader = false;
|
||||
};
|
||||
_fragmentShaderFile->setCallback(shaderCallback);
|
||||
|
||||
// Development functionality to update shader for changes in several files
|
||||
auto addFunc = [this, shaderCallback](const std::string& path) {
|
||||
ghoul::filesystem::File* f = new ghoul::filesystem::File(path, false);
|
||||
f->setCallback(shaderCallback);
|
||||
_shaderFiles.push_back(f);
|
||||
};
|
||||
addFunc("${SHADERS}/ABuffer/abufferSort.hglsl");
|
||||
addFunc("${SHADERS}/ABuffer/abufferAddToBuffer.hglsl");
|
||||
addFunc("${SHADERS}/ABuffer/abufferStruct.hglsl");
|
||||
addFunc("${SHADERS}/PowerScaling/powerScaling_fs.hglsl");
|
||||
addFunc("${SHADERS}/PowerScaling/powerScaling_vs.hglsl");
|
||||
|
||||
_resolveShader = nullptr;
|
||||
generateShaderSource();
|
||||
updateShader();
|
||||
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat size = 1.0f;
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// x y z w s t
|
||||
-size, -size, 0.0f, 1.0f,
|
||||
size, size, 0.0f, 1.0f,
|
||||
-size, size, 0.0f, 1.0f,
|
||||
-size, -size, 0.0f, 1.0f,
|
||||
size, -size, 0.0f, 1.0f,
|
||||
size, size, 0.0f, 1.0f,
|
||||
};
|
||||
GLuint vertexPositionBuffer;
|
||||
glGenVertexArrays(1, &_screenQuad); // generate array
|
||||
glBindVertexArray(_screenQuad); // bind array
|
||||
glGenBuffers(1, &vertexPositionBuffer); // generate buffer
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*4, reinterpret_cast<void*>(0));
|
||||
glEnableVertexAttribArray(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ABuffer::resolve() {
|
||||
if( ! _validShader) {
|
||||
_validShader = true;
|
||||
generateShaderSource();
|
||||
updateShader();
|
||||
|
||||
}
|
||||
|
||||
if(_resolveShader) {
|
||||
_resolveShader->activate();
|
||||
int startAt = 0;
|
||||
for(int i = 0; i < _volumes.size(); ++i) {
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
_volumes.at(i).second->bind();
|
||||
startAt = i + 1;
|
||||
}
|
||||
for(int i = 0; i < _transferFunctions.size(); ++i) {
|
||||
glActiveTexture(GL_TEXTURE0 + startAt + i);
|
||||
_transferFunctions.at(i).second->bind();
|
||||
}
|
||||
|
||||
// Decrease stepsize in volumes if right click is pressed
|
||||
// TODO: Let the interactionhandler handle this
|
||||
int val = sgct::Engine::getMouseButton(0, SGCT_MOUSE_BUTTON_RIGHT);
|
||||
float volumeStepFactor = (val) ? 0.2: 1.0;
|
||||
if(volumeStepFactor != _volumeStepFactor) {
|
||||
_volumeStepFactor = volumeStepFactor;
|
||||
_resolveShader->setUniform("volumeStepFactor", _volumeStepFactor);
|
||||
}
|
||||
|
||||
glBindVertexArray(_screenQuad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
_resolveShader->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void ABuffer::addVolume(const std::string& tag,ghoul::opengl::Texture* volume) {
|
||||
_volumes.push_back(std::make_pair(tag, volume));
|
||||
}
|
||||
|
||||
void ABuffer::addTransferFunction(const std::string& tag,ghoul::opengl::Texture* transferFunction) {
|
||||
_transferFunctions.push_back(std::make_pair(tag, transferFunction));
|
||||
}
|
||||
|
||||
int ABuffer::addSamplerfile(const std::string& filename) {
|
||||
if( ! FileSys.fileExists(filename))
|
||||
return -1;
|
||||
|
||||
auto fileCallback = [this](const ghoul::filesystem::File& file) {
|
||||
_validShader = false;
|
||||
};
|
||||
ghoul::filesystem::File* file = new ghoul::filesystem::File(filename);
|
||||
file->setCallback(fileCallback);
|
||||
_samplerFiles.push_back(file);
|
||||
_samplers.push_back("");
|
||||
|
||||
// ID is one more than "actual" position since ID=0 is considered geometry
|
||||
//return 1 << (_samplers.size()-1);
|
||||
return _samplers.size();
|
||||
}
|
||||
|
||||
bool ABuffer::updateShader() {
|
||||
|
||||
using ghoul::opengl::ShaderObject;
|
||||
using ghoul::opengl::ProgramObject;
|
||||
ShaderCreator sc = OsEng.shaderBuilder();
|
||||
ghoul::opengl::ProgramObject* resolveShader = sc.buildShader("ABuffer resolve", absPath("${SHADERS}/ABuffer/abufferResolveVertex.glsl"), _fragmentShaderPath);
|
||||
if( ! resolveShader) {
|
||||
LERROR("Resolve shader not updated");
|
||||
return false;
|
||||
}
|
||||
|
||||
int startAt = 0;
|
||||
for(int i = 0; i < _volumes.size(); ++i) {
|
||||
resolveShader->setUniform(_volumes.at(i).first, i);
|
||||
startAt = i + 1;
|
||||
}
|
||||
for(int i = 0; i < _transferFunctions.size(); ++i) {
|
||||
resolveShader->setUniform(_transferFunctions.at(i).first, startAt + i);
|
||||
}
|
||||
|
||||
if(_resolveShader)
|
||||
delete _resolveShader;
|
||||
|
||||
_resolveShader = resolveShader;
|
||||
LDEBUG("Successfully updated shader!");
|
||||
return true;
|
||||
}
|
||||
|
||||
void ABuffer::generateShaderSource() {
|
||||
|
||||
for(int i = 0; i < _samplerFiles.size(); ++i) {
|
||||
std::string line, source = "";
|
||||
std::ifstream samplerFile(_samplerFiles.at(i)->path());
|
||||
if(samplerFile.is_open()) {
|
||||
while(std::getline(samplerFile, line)) {
|
||||
source += line + "\n";
|
||||
}
|
||||
}
|
||||
samplerFile.close();
|
||||
_samplers.at(i) = source;
|
||||
}
|
||||
|
||||
std::string line, source = "";
|
||||
std::ifstream fragmentShaderFile(_fragmentShaderFile->path());
|
||||
if(fragmentShaderFile.is_open()) {
|
||||
while(std::getline(fragmentShaderFile, line)) {
|
||||
if(line == "#pragma openspace insert HEADERS") {
|
||||
line = padGeneratedString(openspaceHeaders());
|
||||
} else if(line == "#pragma openspace insert SAMPLERCALLS") {
|
||||
line = padGeneratedString(openspaceSamplerCalls());
|
||||
} else if(line == "#pragma openspace insert SAMPLERS") {
|
||||
line = padGeneratedString(openspaceSamplers());
|
||||
} else if(line == "#pragma openspace insert SETTINGS") {
|
||||
line = padGeneratedString(settings());
|
||||
} else if(line == "#pragma openspace insert TRANSFERFUNC") {
|
||||
line = padGeneratedString(openspaceTransferFunction());
|
||||
}
|
||||
source += line + "\n";
|
||||
}
|
||||
}
|
||||
fragmentShaderFile.close();
|
||||
|
||||
std::ofstream fragmentShaderOut(_fragmentShaderPath);
|
||||
fragmentShaderOut << source;
|
||||
fragmentShaderOut.close();
|
||||
}
|
||||
|
||||
std::string ABuffer::openspaceHeaders() {
|
||||
|
||||
std::string headers;
|
||||
headers += "#define MAX_VOLUMES " + std::to_string(_samplers.size()) + "\n";
|
||||
headers += "#define MAX_TF " + std::to_string(_transferFunctions.size()) + "\n";
|
||||
|
||||
|
||||
for (int i = 0; i < _volumes.size(); ++i) {
|
||||
headers += "uniform sampler3D " + _volumes.at(i).first + ";\n";
|
||||
}
|
||||
for (int i = 0; i < _transferFunctions.size(); ++i) {
|
||||
headers += "uniform sampler1D " + _transferFunctions.at(i).first + ";\n";
|
||||
}
|
||||
|
||||
for (int i = 0; i < _samplers.size(); ++i) {
|
||||
auto found = _samplers.at(i).find_first_of('{');
|
||||
if(found!=std::string::npos) {
|
||||
headers += _samplers.at(i).substr(0, found) + ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(_volumes.size() < 1)
|
||||
return headers;
|
||||
|
||||
size_t maxLoop = 0;
|
||||
headers += "const vec3 volume_dim[] = {\n";
|
||||
for (int i = 0; i < _volumes.size(); ++i) {
|
||||
glm::size3_t size = _volumes.at(i).second->dimensions();
|
||||
for(int k = 0; k < 3; ++k)
|
||||
maxLoop = glm::max(maxLoop, size[k]);
|
||||
headers += " vec3(" + std::to_string(size[0]) + ".0," + std::to_string(size[1]) + ".0,"
|
||||
+ std::to_string(size[2]) + ".0),\n";
|
||||
}
|
||||
headers += "};\n";
|
||||
|
||||
headers += "#define LOOP_LIMIT " + std::to_string(maxLoop) + "\n";
|
||||
|
||||
headers += "float volumeStepSize[] = {\n";
|
||||
for (int i = 0; i < _volumes.size(); ++i) {
|
||||
glm::size3_t size = _volumes.at(i).second->dimensions();
|
||||
headers += " stepSize,\n";
|
||||
}
|
||||
headers += "};\n";
|
||||
|
||||
headers += "float volumeStepSizeOriginal[] = {\n";
|
||||
for (int i = 0; i < _volumes.size(); ++i) {
|
||||
glm::size3_t size = _volumes.at(i).second->dimensions();
|
||||
headers += " stepSize,\n";
|
||||
}
|
||||
headers += "};\n";
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
std::string ABuffer::openspaceSamplerCalls() {
|
||||
std::string samplercalls;
|
||||
for (int i = 0; i < _samplers.size(); ++i) {
|
||||
|
||||
auto found1 = _samplers.at(i).find_first_not_of("vec4 ");
|
||||
auto found2 = _samplers.at(i).find_first_of("(",found1);
|
||||
if(found1 != std::string::npos && found2 != std::string::npos) {
|
||||
std::string functionName = _samplers.at(i).substr(found1, found2 - found1);
|
||||
samplercalls += "#ifndef SKIP_VOLUME_"+std::to_string(i)+"\n";
|
||||
samplercalls += "if((currentVolumeBitmask & (1 << " + std::to_string(i) + ")) == "+std::to_string(1 << i)+") {\n";
|
||||
samplercalls += " vec4 c = " + functionName + "(final_color,volume_position[" + std::to_string(i) + "]);\n";
|
||||
// samplercalls += " if(c.a < 0.1) { \n";
|
||||
// samplercalls += " if( volumeStepSize[" + std::to_string(i) + "] < 16.0*volumeStepSizeOriginal[" + std::to_string(i) + "]) \n";
|
||||
// samplercalls += " volumeStepSize[" + std::to_string(i) + "] *= 2.0; \n";
|
||||
// samplercalls += " } else {\n";
|
||||
// samplercalls += " //volume_position[" + std::to_string(i) + "] -= volume_direction[" + std::to_string(i) + "]*volumeStepSize[" + std::to_string(i) + "];\n";
|
||||
// samplercalls += " volumeStepSize[" + std::to_string(i) + "] = volumeStepSizeOriginal[" + std::to_string(i) + "]; \n";
|
||||
// samplercalls += " //c = " + functionName + "(final_color,volume_position[" + std::to_string(i) + "]);\n";
|
||||
// samplercalls += " } \n";
|
||||
// samplercalls += " if(c.a > EPSILON)\n";
|
||||
samplercalls += " blendStep(final_color, c, volumeStepSize[" + std::to_string(i) + "]);\n";
|
||||
// samplercalls += " blendStep(final_color, c, stepSize);\n";
|
||||
// samplercalls += " float aaa = volume_length[i]/myMaxSteps;\n";
|
||||
samplercalls += " volume_position[" + std::to_string(i) + "] += volume_direction[" + std::to_string(i) + "]*volumeStepSize[" + std::to_string(i) + "];\n";
|
||||
// float aaa = ray[v].w/myMaxSteps;
|
||||
// pos[v] += vec4(ray[v].xyz*vec3(aaa),aaa);
|
||||
// samplercalls += " volume_position[" + std::to_string(i) + "] += volume_direction[" + std::to_string(i) + "]*volumeStepSize[" + std::to_string(i) + "];\n";
|
||||
samplercalls += "}\n";
|
||||
samplercalls += "#endif\n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return samplercalls;
|
||||
}
|
||||
|
||||
std::string ABuffer::openspaceSamplers() {
|
||||
std::string samplers;
|
||||
for (int i = 0; i < _samplers.size(); ++i) {
|
||||
samplers += _samplers.at(i) + "\n";
|
||||
}
|
||||
return samplers;
|
||||
}
|
||||
|
||||
std::string ABuffer::openspaceTransferFunction() {
|
||||
std::string tf;
|
||||
tf += "float showfunc_size = 20.0;\n";
|
||||
tf += "float SCREEN_HEIGHTf = float(SCREEN_HEIGHT);\n";
|
||||
tf += "float SCREEN_WIDTHf = float(SCREEN_WIDTH);\n";
|
||||
for(int i = 0; i < _transferFunctions.size(); ++i) {
|
||||
tf += "if( gl_FragCoord.y > SCREEN_HEIGHTf-showfunc_size*"+std::to_string(i+1)+
|
||||
" && gl_FragCoord.y < SCREEN_HEIGHTf-showfunc_size*"+std::to_string(i)+") {\n";
|
||||
tf += " float normalizedIntensity = gl_FragCoord.x / (SCREEN_WIDTHf-1) ;\n";
|
||||
tf += " vec4 tfc = texture("+ _transferFunctions.at(i).first +", normalizedIntensity);\n";
|
||||
tf += " final_color = tfc;\n";
|
||||
tf += " float cmpf = SCREEN_HEIGHTf-showfunc_size*"+std::to_string(i+1)+" + tfc.a*showfunc_size;\n";
|
||||
tf += " if(gl_FragCoord.y > cmpf) {\n";
|
||||
tf += " final_color = vec4(0,0,0,0);\n";
|
||||
tf += " } else {\n";
|
||||
tf += " final_color.a = 1.0;\n";
|
||||
tf += " }\n";
|
||||
tf += "} else if(ceil(gl_FragCoord.y) == SCREEN_HEIGHTf - showfunc_size*"+std::to_string(i+1)+") {\n";
|
||||
tf += " const float intensity = 0.4;\n";
|
||||
tf += " final_color = vec4(intensity,intensity,intensity,1.0);\n";
|
||||
tf += "}\n";
|
||||
}
|
||||
|
||||
return tf;
|
||||
}
|
||||
|
||||
|
||||
} // openspace
|
||||
124
src/abuffer/abufferSingleLinked.cpp
Normal file
124
src/abuffer/abufferSingleLinked.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/abuffer/abufferSingleLinked.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#define MAX_LAYERS 10
|
||||
|
||||
namespace {
|
||||
std::string _loggerCat = "ABufferSingleLinked";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ABufferSingleLinked::ABufferSingleLinked(): _data(0), _anchorPointerTexture(0),
|
||||
_anchorPointerTextureInitializer(0), _atomicCounterBuffer(0), _fragmentBuffer(0),
|
||||
_fragmentTexture(0)
|
||||
{}
|
||||
|
||||
ABufferSingleLinked::~ABufferSingleLinked() {
|
||||
if(_data != 0)
|
||||
delete _data;
|
||||
|
||||
glDeleteTextures(1,&_anchorPointerTexture);
|
||||
glDeleteTextures(1,&_fragmentTexture);
|
||||
glDeleteBuffers(1,&_anchorPointerTextureInitializer);
|
||||
glDeleteBuffers(1,&_atomicCounterBuffer);
|
||||
glDeleteBuffers(1,&_anchorPointerTextureInitializer);
|
||||
}
|
||||
|
||||
bool ABufferSingleLinked::initialize() {
|
||||
// ============================
|
||||
// BUFFERS
|
||||
// ============================
|
||||
glGenTextures(1, &_anchorPointerTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, _anchorPointerTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _width, _height, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
|
||||
glGenBuffers(1, &_anchorPointerTextureInitializer);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
|
||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, _totalPixels * sizeof(GLuint), NULL, GL_STATIC_DRAW);
|
||||
|
||||
_data = (GLuint*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
||||
memset(_data, 0x00, _totalPixels * sizeof(GLuint));
|
||||
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
glGenBuffers(1, &_atomicCounterBuffer);
|
||||
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, _atomicCounterBuffer);
|
||||
glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), NULL, GL_DYNAMIC_COPY);
|
||||
|
||||
glGenBuffers(1, &_fragmentBuffer);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, _fragmentBuffer);
|
||||
glBufferData(GL_TEXTURE_BUFFER, MAX_LAYERS*_totalPixels*sizeof(GLfloat)*4, NULL, GL_DYNAMIC_COPY);
|
||||
|
||||
glGenTextures(1, &_fragmentTexture);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _fragmentTexture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32UI, _fragmentBuffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
|
||||
glBindImageTexture(1, _fragmentTexture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32UI);
|
||||
|
||||
return initializeABuffer();
|
||||
}
|
||||
|
||||
void ABufferSingleLinked::clear() {
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
|
||||
glBindTexture(GL_TEXTURE_2D, _anchorPointerTexture);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _width, _height, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
static const GLuint zero = 1;
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, _atomicCounterBuffer);
|
||||
glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(zero), &zero);
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, 0);
|
||||
}
|
||||
|
||||
void ABufferSingleLinked::preRender() {
|
||||
|
||||
// Bind head-pointer image for read-write
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, _atomicCounterBuffer);
|
||||
glBindImageTexture(0, _anchorPointerTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R32UI);
|
||||
glBindImageTexture(1, _fragmentTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32UI);
|
||||
}
|
||||
|
||||
void ABufferSingleLinked::postRender() {
|
||||
|
||||
}
|
||||
|
||||
std::string ABufferSingleLinked::settings() {
|
||||
return R"()";
|
||||
}
|
||||
|
||||
|
||||
} // openspace
|
||||
124
src/abuffer/abufferdynamic.cpp
Normal file
124
src/abuffer/abufferdynamic.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/abuffer/abufferdynamic.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#define MAX_LAYERS 10
|
||||
|
||||
namespace {
|
||||
std::string _loggerCat = "ABufferDynamic";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ABufferDynamic::ABufferDynamic(): _data(0), _anchorPointerTexture(0),
|
||||
_anchorPointerTextureInitializer(0), _atomicCounterBuffer(0), _fragmentBuffer(0),
|
||||
_fragmentTexture(0)
|
||||
{}
|
||||
|
||||
ABufferDynamic::~ABufferDynamic() {
|
||||
if(_data != 0)
|
||||
delete _data;
|
||||
|
||||
glDeleteTextures(1,&_anchorPointerTexture);
|
||||
glDeleteTextures(1,&_fragmentTexture);
|
||||
glDeleteBuffers(1,&_anchorPointerTextureInitializer);
|
||||
glDeleteBuffers(1,&_atomicCounterBuffer);
|
||||
glDeleteBuffers(1,&_anchorPointerTextureInitializer);
|
||||
}
|
||||
|
||||
bool ABufferDynamic::initialize() {
|
||||
// ============================
|
||||
// BUFFERS
|
||||
// ============================
|
||||
glGenTextures(1, &_anchorPointerTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, _anchorPointerTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _width, _height, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
|
||||
glGenBuffers(1, &_anchorPointerTextureInitializer);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
|
||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, _totalPixels * sizeof(GLuint), NULL, GL_STATIC_DRAW);
|
||||
|
||||
_data = (GLuint*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
||||
memset(_data, 0x00, _totalPixels * sizeof(GLuint));
|
||||
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
glGenBuffers(1, &_atomicCounterBuffer);
|
||||
glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, _atomicCounterBuffer);
|
||||
glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), NULL, GL_DYNAMIC_COPY);
|
||||
|
||||
glGenBuffers(1, &_fragmentBuffer);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, _fragmentBuffer);
|
||||
glBufferData(GL_TEXTURE_BUFFER, MAX_LAYERS*_totalPixels*sizeof(GLfloat)*4, NULL, GL_DYNAMIC_COPY);
|
||||
|
||||
glGenTextures(1, &_fragmentTexture);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _fragmentTexture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32UI, _fragmentBuffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
|
||||
glBindImageTexture(1, _fragmentTexture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32UI);
|
||||
|
||||
return initializeABuffer();
|
||||
}
|
||||
|
||||
void ABufferDynamic::clear() {
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
|
||||
glBindTexture(GL_TEXTURE_2D, _anchorPointerTexture);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _width, _height, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
static const GLuint zero = 1;
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, _atomicCounterBuffer);
|
||||
glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(zero), &zero);
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, 0);
|
||||
}
|
||||
|
||||
void ABufferDynamic::preRender() {
|
||||
|
||||
// Bind head-pointer image for read-write
|
||||
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, _atomicCounterBuffer);
|
||||
glBindImageTexture(0, _anchorPointerTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R32UI);
|
||||
glBindImageTexture(1, _fragmentTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32UI);
|
||||
}
|
||||
|
||||
void ABufferDynamic::postRender() {
|
||||
|
||||
}
|
||||
|
||||
std::string ABufferDynamic::settings() {
|
||||
return R"(#define ABUFFER_SINGLE_LINKED)";
|
||||
}
|
||||
|
||||
|
||||
} // openspace
|
||||
137
src/abuffer/abufferfixed.cpp
Normal file
137
src/abuffer/abufferfixed.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/abuffer/abufferfixed.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#define MAX_LAYERS 32
|
||||
|
||||
namespace {
|
||||
std::string _loggerCat = "ABufferFixed";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ABufferFixed::ABufferFixed(): _data(0), _anchorPointerTexture(0),
|
||||
_anchorPointerTextureInitializer(0), _atomicCounterBuffer(0), _fragmentBuffer(0),
|
||||
_fragmentTexture(0)
|
||||
{}
|
||||
|
||||
ABufferFixed::~ABufferFixed() {
|
||||
if(_data != 0)
|
||||
delete _data;
|
||||
|
||||
glDeleteTextures(1,&_anchorPointerTexture);
|
||||
glDeleteTextures(1,&_fragmentTexture);
|
||||
// glDeleteTextures(1,&_atomicCounterTexture);
|
||||
glDeleteBuffers(1,&_anchorPointerTextureInitializer);
|
||||
// glDeleteBuffers(1,&_atomicCounterBuffer);
|
||||
glDeleteBuffers(1,&_anchorPointerTextureInitializer);
|
||||
}
|
||||
|
||||
bool ABufferFixed::initialize() {
|
||||
// ============================
|
||||
// BUFFERS
|
||||
// ============================
|
||||
glGenTextures(1, &_anchorPointerTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, _anchorPointerTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _width, _height, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
|
||||
glGenBuffers(1, &_anchorPointerTextureInitializer);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
|
||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, _totalPixels * sizeof(GLuint), NULL, GL_STATIC_DRAW);
|
||||
|
||||
_data = (GLuint*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
||||
memset(_data, 0x00, _totalPixels * sizeof(GLuint));
|
||||
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
|
||||
// glGenBuffers(1, &_atomicCounterBuffer);
|
||||
// glBindBuffer(GL_TEXTURE_BUFFER, _atomicCounterBuffer);
|
||||
// glBufferData(GL_TEXTURE_BUFFER, _totalPixels*sizeof(GLuint), NULL, GL_DYNAMIC_COPY);
|
||||
|
||||
// glGenTextures(1, &_atomicCounterTexture);
|
||||
// glBindTexture(GL_TEXTURE_2D, _atomicCounterTexture);
|
||||
// glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, _atomicCounterBuffer);
|
||||
// glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
|
||||
|
||||
glGenBuffers(1, &_fragmentBuffer);
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, _fragmentBuffer);
|
||||
glBufferData(GL_TEXTURE_BUFFER, MAX_LAYERS*_totalPixels*sizeof(GLfloat)*4, NULL, GL_DYNAMIC_COPY);
|
||||
|
||||
glGenTextures(1, &_fragmentTexture);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, _fragmentTexture);
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32UI, _fragmentBuffer);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, 0);
|
||||
|
||||
glBindImageTexture(1, _fragmentTexture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32UI);
|
||||
|
||||
return initializeABuffer();
|
||||
}
|
||||
|
||||
void ABufferFixed::clear() {
|
||||
|
||||
// Bind texture initializer
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, _anchorPointerTextureInitializer);
|
||||
|
||||
// clear _anchorPointerTexture
|
||||
glBindTexture(GL_TEXTURE_2D, _anchorPointerTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _width, _height, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
|
||||
// // clear _atomicCounterTexture
|
||||
// glBindTexture(GL_TEXTURE_2D, _atomicCounterTexture);
|
||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_R32UI, _width, _height, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL);
|
||||
|
||||
// reset GL_PIXEL_UNPACK_BUFFER
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
|
||||
}
|
||||
|
||||
void ABufferFixed::preRender() {
|
||||
|
||||
// Bind head-pointer image for read-write
|
||||
glBindImageTexture(0, _anchorPointerTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R32UI);
|
||||
glBindImageTexture(1, _fragmentTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32UI);
|
||||
// glBindImageTexture(2, _atomicCounterTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R32UI);
|
||||
}
|
||||
|
||||
void ABufferFixed::postRender() {
|
||||
|
||||
}
|
||||
|
||||
std::string ABufferFixed::settings() {
|
||||
return R"()";
|
||||
}
|
||||
|
||||
|
||||
} // openspace
|
||||
@@ -31,10 +31,12 @@
|
||||
#include <openspace/interaction/deviceidentifier.h>
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spice.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
@@ -43,42 +45,59 @@
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
#include <ghoul/cmdparser/commandlineparser.h>
|
||||
#include <ghoul/cmdparser/commandlinecommand.h>
|
||||
#include <ghoul/cmdparser/singlecommand.h>
|
||||
|
||||
using namespace ghoul::filesystem;
|
||||
using namespace ghoul::logging;
|
||||
|
||||
using namespace openspace::scripting;
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "OpenSpaceEngine";
|
||||
const std::string _configurationFile = "openspace.cfg";
|
||||
const std::string _basePathToken = "${BASE_PATH}";
|
||||
const std::string _sgctDefaultConfigFile = "${SGCT}/single.xml";
|
||||
|
||||
const std::string _sgctConfigArgumentCommand = "-config";
|
||||
|
||||
struct {
|
||||
std::string configurationName;
|
||||
} commandlineArgumentPlaceholders;
|
||||
}
|
||||
|
||||
using namespace ghoul::cmdparser;
|
||||
|
||||
namespace openspace {
|
||||
|
||||
OpenSpaceEngine* OpenSpaceEngine::_engine = nullptr;
|
||||
|
||||
OpenSpaceEngine::OpenSpaceEngine()
|
||||
: _configurationManager(nullptr)
|
||||
, _interactionHandler(nullptr)
|
||||
, _renderEngine(nullptr)
|
||||
//, _scriptEngine(nullptr)
|
||||
OpenSpaceEngine::OpenSpaceEngine(std::string programName)
|
||||
: _configurationManager(new ghoul::Dictionary)
|
||||
, _interactionHandler(new InteractionHandler)
|
||||
, _renderEngine(new RenderEngine)
|
||||
, _scriptEngine(new ScriptEngine)
|
||||
, _commandlineParser(new CommandlineParser(programName, true))
|
||||
{
|
||||
}
|
||||
|
||||
OpenSpaceEngine::~OpenSpaceEngine()
|
||||
{
|
||||
delete _configurationManager;
|
||||
_configurationManager = nullptr;
|
||||
delete _interactionHandler;
|
||||
_interactionHandler = nullptr;
|
||||
delete _renderEngine;
|
||||
_renderEngine = nullptr;
|
||||
delete _scriptEngine;
|
||||
_scriptEngine = nullptr;
|
||||
delete _commandlineParser;
|
||||
_commandlineParser = nullptr;
|
||||
|
||||
// TODO deallocate script engine when starting to use it
|
||||
// delete _scriptEngine;
|
||||
|
||||
SpiceManager::deinitialize();
|
||||
Spice::deinit();
|
||||
Time::deinit();
|
||||
Time::deinitialize();
|
||||
DeviceIdentifier::deinit();
|
||||
FileSystem::deinitialize();
|
||||
LogManager::deinitialize();
|
||||
}
|
||||
|
||||
@@ -87,6 +106,18 @@ OpenSpaceEngine& OpenSpaceEngine::ref()
|
||||
assert(_engine);
|
||||
return *_engine;
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::gatherCommandlineArguments()
|
||||
{
|
||||
// TODO: Get commandline arguments from all modules
|
||||
|
||||
CommandlineCommand* configurationFileCommand = new SingleCommand<std::string>(
|
||||
&commandlineArgumentPlaceholders.configurationName, "-config", "-c",
|
||||
"Provides the path to the OpenSpace configuration file");
|
||||
_commandlineParser->addCommand(configurationFileCommand);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::registerPathsFromDictionary(const ghoul::Dictionary& dictionary)
|
||||
{
|
||||
@@ -97,10 +128,12 @@ void OpenSpaceEngine::registerPathsFromDictionary(const ghoul::Dictionary& dicti
|
||||
const std::string fullKey
|
||||
= ghoul::filesystem::FileSystem::TokenOpeningBraces + key
|
||||
+ ghoul::filesystem::FileSystem::TokenClosingBraces;
|
||||
LDEBUG(fullKey << ": " << p);
|
||||
LDEBUG("Registering path " << fullKey << ": " << p);
|
||||
|
||||
bool override = (_basePathToken == fullKey);
|
||||
|
||||
if (override)
|
||||
LINFO("Overriding base path with '" << p << "'");
|
||||
FileSys.registerPathToken(fullKey, p, override);
|
||||
}
|
||||
}
|
||||
@@ -118,7 +151,6 @@ bool OpenSpaceEngine::registerBasePathFromConfigurationFile(const std::string& f
|
||||
if (last == std::string::npos)
|
||||
return false;
|
||||
|
||||
|
||||
std::string basePath = absolutePath.substr(0, last);
|
||||
|
||||
FileSys.registerPathToken(_basePathToken, basePath);
|
||||
@@ -128,88 +160,117 @@ bool OpenSpaceEngine::registerBasePathFromConfigurationFile(const std::string& f
|
||||
|
||||
bool OpenSpaceEngine::findConfiguration(std::string& filename)
|
||||
{
|
||||
if (!filename.empty())
|
||||
return FileSys.fileExists(filename);
|
||||
else {
|
||||
std::string currentDirectory = FileSys.absolutePath(FileSys.currentDirectory());
|
||||
size_t occurrences = std::count(currentDirectory.begin(), currentDirectory.end(),
|
||||
ghoul::filesystem::FileSystem::PathSeparator);
|
||||
std::string currentDirectory = FileSys.absolutePath(FileSys.currentDirectory());
|
||||
size_t occurrences = std::count(currentDirectory.begin(), currentDirectory.end(),
|
||||
ghoul::filesystem::FileSystem::PathSeparator);
|
||||
|
||||
std::string cfgname = _configurationFile;
|
||||
std::string cfgname = _configurationFile;
|
||||
|
||||
bool cfgFileFound = false;
|
||||
for (size_t i = 0; i < occurrences; ++i) {
|
||||
if (i > 0)
|
||||
cfgname = "../" + cfgname;
|
||||
if (FileSys.fileExists(cfgname)) {
|
||||
cfgFileFound = true;
|
||||
break;
|
||||
}
|
||||
bool cfgFileFound = false;
|
||||
for (size_t i = 0; i < occurrences; ++i) {
|
||||
if (i > 0)
|
||||
cfgname = "../" + cfgname;
|
||||
if (FileSys.fileExists(cfgname)) {
|
||||
cfgFileFound = true;
|
||||
break;
|
||||
}
|
||||
if (!cfgFileFound)
|
||||
return false;
|
||||
|
||||
filename = cfgname;
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!cfgFileFound)
|
||||
return false;
|
||||
|
||||
filename = cfgname;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::create(int argc, char** argv,
|
||||
bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
std::vector<std::string>& sgctArguments)
|
||||
{
|
||||
// TODO custom assert (ticket #5)
|
||||
assert(_engine == nullptr);
|
||||
|
||||
// initialize ghoul logging
|
||||
// initialize Ghoul logging
|
||||
LogManager::initialize(LogManager::LogLevel::Debug, true);
|
||||
LogMgr.addLog(new ConsoleLog);
|
||||
|
||||
// TODO change so initialize is not called in the create function
|
||||
|
||||
// Initialize FileSystem
|
||||
ghoul::filesystem::FileSystem::initialize();
|
||||
|
||||
// TODO parse arguments if filename is specified, if not use default
|
||||
std::string configurationFilePath = "";
|
||||
|
||||
LDEBUG("Finding configuration");
|
||||
if (!OpenSpaceEngine::findConfiguration(configurationFilePath)) {
|
||||
LFATAL("Could not find OpenSpace configuration file!");
|
||||
assert(false);
|
||||
|
||||
|
||||
// Sanity check of values
|
||||
if (argc < 1) {
|
||||
LFATAL("No arguments were passed to the function");
|
||||
return false;
|
||||
}
|
||||
|
||||
// create other objects
|
||||
LDEBUG("Creating OpenSpaceEngine");
|
||||
_engine = new OpenSpaceEngine(std::string(argv[0]));
|
||||
|
||||
|
||||
// Query modules for commandline arguments
|
||||
const bool gatherSuccess = _engine->gatherCommandlineArguments();
|
||||
if (!gatherSuccess)
|
||||
return false;
|
||||
|
||||
|
||||
LINFO(FileSys.absolutePath(configurationFilePath));
|
||||
|
||||
// create objects
|
||||
_engine = new OpenSpaceEngine;
|
||||
_engine->_renderEngine = new RenderEngine;
|
||||
_engine->_interactionHandler = new InteractionHandler;
|
||||
_engine->_configurationManager = new ghoul::Dictionary;
|
||||
// Parse commandline arguments
|
||||
std::vector<std::string> remainingArguments;
|
||||
_engine->_commandlineParser->setCommandLine(argc, argv, &sgctArguments);
|
||||
const bool executeSuccess = _engine->_commandlineParser->execute();
|
||||
if (!executeSuccess)
|
||||
return false;
|
||||
|
||||
|
||||
// Find configuration
|
||||
std::string configurationFilePath = commandlineArgumentPlaceholders.configurationName;
|
||||
if (configurationFilePath.empty()) {
|
||||
LDEBUG("Finding configuration");
|
||||
const bool findConfigurationSuccess = OpenSpaceEngine::findConfiguration(configurationFilePath);
|
||||
if (!findConfigurationSuccess) {
|
||||
LFATAL("Could not find OpenSpace configuration file!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
LINFO("Configuration Path: '" << FileSys.absolutePath(configurationFilePath) << "'");
|
||||
|
||||
|
||||
// Registering base path
|
||||
LDEBUG("Registering base path");
|
||||
if (!OpenSpaceEngine::registerBasePathFromConfigurationFile(configurationFilePath)) {
|
||||
LFATAL("Could not register base path");
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
ghoul::Dictionary& configuration = *(_engine->_configurationManager);
|
||||
|
||||
// Loading configuration from disk
|
||||
LDEBUG("Loading configuration from disk");
|
||||
ghoul::Dictionary& configuration = _engine->configurationManager();
|
||||
ghoul::lua::loadDictionaryFromFile(configurationFilePath, configuration);
|
||||
if (configuration.hasKey(constants::openspaceengine::keyPaths)) {
|
||||
ghoul::Dictionary pathsDictionary;
|
||||
if (configuration.getValue(constants::openspaceengine::keyPaths, pathsDictionary))
|
||||
OpenSpaceEngine::registerPathsFromDictionary(pathsDictionary);
|
||||
ghoul::Dictionary pathsDictionary;
|
||||
const bool success = configuration.getValueSafe(constants::openspaceengine::keyPaths, pathsDictionary);
|
||||
if (success)
|
||||
OpenSpaceEngine::registerPathsFromDictionary(pathsDictionary);
|
||||
else {
|
||||
LFATAL("Configuration file does not contain paths token '" << constants::openspaceengine::keyPaths << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string sgctConfigurationPath = _sgctDefaultConfigFile;
|
||||
if (configuration.hasKey(constants::openspaceengine::keyConfigSgct))
|
||||
configuration.getValue(constants::openspaceengine::keyConfigSgct, sgctConfigurationPath);
|
||||
|
||||
sgctArguments.push_back(argv[0]);
|
||||
sgctArguments.push_back("-config");
|
||||
sgctArguments.push_back(absPath(sgctConfigurationPath));
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
sgctArguments.push_back(argv[i]);
|
||||
|
||||
// Determining SGCT configuration file
|
||||
LDEBUG("Determining SGCT configuration file");
|
||||
std::string sgctConfigurationPath = _sgctDefaultConfigFile;
|
||||
configuration.getValueSafe(constants::openspaceengine::keyConfigSgct,
|
||||
sgctConfigurationPath);
|
||||
|
||||
// Prepend the outgoing sgctArguments with the program name
|
||||
// as well as the configuration file that sgct is supposed to use
|
||||
sgctArguments.insert(sgctArguments.begin(), argv[0]);
|
||||
sgctArguments.insert(sgctArguments.begin() + 1, _sgctConfigArgumentCommand);
|
||||
sgctArguments.insert(sgctArguments.begin() + 2, absPath(sgctConfigurationPath));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::destroy()
|
||||
@@ -230,14 +291,25 @@ bool OpenSpaceEngine::initialize()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
GLFWwindow* win = sgct::Engine::instance()->getActiveWindowPtr()->getWindowHandle();
|
||||
glfwSwapBuffers(win);
|
||||
//int samples = sqrt(sgct::Engine::instance()->getActiveWindowPtr()->getNumberOfAASamples());
|
||||
//LDEBUG("samples: " << samples);
|
||||
|
||||
int x1, xSize, y1, ySize;
|
||||
sgct::Engine::instance()->getActiveWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
|
||||
std::string sourceHeader = "";
|
||||
sourceHeader += "#define SCREEN_WIDTH " + std::to_string(xSize) + "\n";
|
||||
sourceHeader += "#define SCREEN_HEIGHT " + std::to_string(ySize) + "\n";
|
||||
sourceHeader += "#define ABUFFER_SINGLE_LINKED " + std::to_string(ABUFFER_SINGLE_LINKED) + "\n";
|
||||
sourceHeader += "#define ABUFFER_FIXED " + std::to_string(ABUFFER_FIXED) + "\n";
|
||||
sourceHeader += "#define ABUFFER_DYNAMIC " + std::to_string(ABUFFER_DYNAMIC) + "\n";
|
||||
sourceHeader += "#define ABUFFER_IMPLEMENTATION " + std::to_string(ABUFFER_IMPLEMENTATION) + "\n";
|
||||
_shaderBuilder.createSourceFile(true);
|
||||
_shaderBuilder.sourceFileHeader(sourceHeader);
|
||||
|
||||
// Register the filepaths from static function enables easy testing
|
||||
// registerFilePaths();
|
||||
_context.createContextFromGLContext();
|
||||
|
||||
// initialize the configurationmanager with the default configuration
|
||||
//_configurationManager->loadConfiguration(absPath("${SCRIPTS}/DefaultConfig.lua"));
|
||||
|
||||
// Detect and log OpenCL and OpenGL versions and available devices
|
||||
ghoul::systemcapabilities::SystemCapabilities::initialize();
|
||||
SysCap.addComponent(new ghoul::systemcapabilities::CPUCapabilitiesComponent);
|
||||
@@ -246,34 +318,48 @@ bool OpenSpaceEngine::initialize()
|
||||
SysCap.detectCapabilities();
|
||||
SysCap.logCapabilities();
|
||||
|
||||
std::string timeKernel;
|
||||
OsEng.configurationManager().getValueSafe(constants::openspaceengine::keyConfigTimekernel, timeKernel);
|
||||
|
||||
// initialize OpenSpace helpers
|
||||
Time::init();
|
||||
SpiceManager::initialize();
|
||||
Time::initialize(timeKernel);
|
||||
Spice::init();
|
||||
Spice::ref().loadDefaultKernels();
|
||||
FactoryManager::initialize();
|
||||
|
||||
|
||||
scriptEngine().initialize();
|
||||
|
||||
// Register Lua script functions
|
||||
LDEBUG("Registering Lua libraries");
|
||||
scriptEngine().addLibrary(SceneGraph::luaLibrary());
|
||||
scriptEngine().addLibrary(Time::luaLibrary());
|
||||
|
||||
// Load scenegraph
|
||||
SceneGraph* sceneGraph = new SceneGraph;
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
if (!OsEng.configurationManager().hasValue<std::string>(
|
||||
constants::openspaceengine::keyConfigScene)) {
|
||||
LFATAL("Configuration needs to point to the scene file");
|
||||
|
||||
std::string sceneDescriptionPath;
|
||||
bool success = OsEng.configurationManager().getValueSafe(
|
||||
constants::openspaceengine::keyConfigScene, sceneDescriptionPath);
|
||||
if (!success) {
|
||||
LFATAL("The configuration does not contain a scene file under key '" <<
|
||||
constants::openspaceengine::keyConfigScene << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string sceneDescriptionPath;
|
||||
bool success = _configurationManager->getValue(
|
||||
constants::openspaceengine::keyConfigScene, sceneDescriptionPath);
|
||||
|
||||
if (!FileSys.fileExists(sceneDescriptionPath)) {
|
||||
LFATAL("Could not find '" << sceneDescriptionPath << "'");
|
||||
if (!FileSys.fileExists(sceneDescriptionPath)) {
|
||||
LFATAL("Could not find scene description '" << sceneDescriptionPath << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string scenePath;
|
||||
success = _configurationManager->getValue(constants::openspaceengine::keyPathScene, scenePath);
|
||||
success = _configurationManager->getValueSafe(
|
||||
constants::openspaceengine::keyPathScene, scenePath);
|
||||
if (!success) {
|
||||
LFATAL("Could not find SCENEPATH key in configuration file");
|
||||
LFATAL("Could not find key '" << constants::openspaceengine::keyPathScene <<
|
||||
"' in configuration file '" << sceneDescriptionPath << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -281,7 +367,6 @@ bool OpenSpaceEngine::initialize()
|
||||
_renderEngine->initialize();
|
||||
sceneGraph->loadScene(sceneDescriptionPath, scenePath);
|
||||
sceneGraph->initialize();
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
|
||||
#ifdef FLARE_ONLY
|
||||
_flare = new Flare();
|
||||
@@ -293,13 +378,42 @@ bool OpenSpaceEngine::initialize()
|
||||
DeviceIdentifier::ref().scanDevices();
|
||||
_engine->_interactionHandler->connectDevices();
|
||||
|
||||
// Run start up scripts
|
||||
//using ghoul::Dictionary;
|
||||
//using constants::openspaceengine::keyStartupScript;
|
||||
ghoul::Dictionary scripts;
|
||||
success = _engine->configurationManager().getValueSafe(
|
||||
constants::openspaceengine::keyStartupScript, scripts);
|
||||
if (success) {
|
||||
for (size_t i = 0; i < scripts.size(); ++i) {
|
||||
std::stringstream stream;
|
||||
// Dictionary-size is 0-based; script numbers are 1-based
|
||||
stream << (i + 1);
|
||||
const std::string& key = stream.str();
|
||||
const bool hasKey = scripts.hasKeyAndValue<std::string>(key);
|
||||
if (!hasKey) {
|
||||
LERROR("The startup scripts have to be declared in a simple array format");
|
||||
break;
|
||||
}
|
||||
|
||||
std::string scriptPath;
|
||||
scripts.getValue(key, scriptPath);
|
||||
std::string&& absoluteScriptPath = absPath(scriptPath);
|
||||
_engine->scriptEngine().runScriptFile(absoluteScriptPath);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OPENSPACE_VIDEO_EXPORT
|
||||
LINFO("OpenSpace compiled with video export; press Print Screen to start/stop recording");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ghoul::Dictionary& OpenSpaceEngine::configurationManager()
|
||||
{
|
||||
// TODO custom assert (ticket #5)
|
||||
assert(_configurationManager != nullptr);
|
||||
assert(_configurationManager);
|
||||
return *_configurationManager;
|
||||
}
|
||||
|
||||
@@ -311,17 +425,31 @@ ghoul::opencl::CLContext& OpenSpaceEngine::clContext()
|
||||
InteractionHandler& OpenSpaceEngine::interactionHandler()
|
||||
{
|
||||
// TODO custom assert (ticket #5)
|
||||
assert(_configurationManager != nullptr);
|
||||
assert(_interactionHandler);
|
||||
return *_interactionHandler;
|
||||
}
|
||||
|
||||
RenderEngine& OpenSpaceEngine::renderEngine()
|
||||
{
|
||||
// TODO custom assert (ticket #5)
|
||||
assert(_configurationManager != nullptr);
|
||||
assert(_renderEngine);
|
||||
return *_renderEngine;
|
||||
}
|
||||
|
||||
ScriptEngine& OpenSpaceEngine::scriptEngine()
|
||||
{
|
||||
// TODO custom assert (ticket #5)
|
||||
assert(_scriptEngine);
|
||||
return *_scriptEngine;
|
||||
}
|
||||
|
||||
|
||||
ShaderCreator& OpenSpaceEngine::shaderBuilder()
|
||||
{
|
||||
// TODO custom assert (ticket #5)
|
||||
return _shaderBuilder;
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::initializeGL()
|
||||
{
|
||||
return _renderEngine->initializeGL();
|
||||
@@ -338,6 +466,8 @@ void OpenSpaceEngine::preSynchronization()
|
||||
|
||||
_interactionHandler->update(dt);
|
||||
_interactionHandler->lockControls();
|
||||
|
||||
Time::ref().advanceTime(dt);
|
||||
}
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->preSync();
|
||||
@@ -366,6 +496,17 @@ void OpenSpaceEngine::postDraw()
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
_interactionHandler->unlockControls();
|
||||
}
|
||||
#ifdef OPENSPACE_VIDEO_EXPORT
|
||||
float speed = 0.01;
|
||||
glm::vec3 euler(0.0, speed, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
glm::vec3 euler2(0.0, -speed, 0.0);
|
||||
glm::quat rot2 = glm::quat(euler2);
|
||||
_interactionHandler->orbit(rot);
|
||||
_interactionHandler->rotate(rot2);
|
||||
if(_doVideoExport)
|
||||
sgct::Engine::instance()->takeScreenshot();
|
||||
#endif
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->postDraw();
|
||||
#endif
|
||||
@@ -376,6 +517,12 @@ void OpenSpaceEngine::keyboardCallback(int key, int action)
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
_interactionHandler->keyboardCallback(key, action);
|
||||
}
|
||||
#ifdef OPENSPACE_VIDEO_EXPORT
|
||||
// LDEBUG("key: " << key);
|
||||
// LDEBUG("SGCT_KEY_PRINT_SCREEN: " << SGCT_KEY_PRINT_SCREEN);
|
||||
if(action == SGCT_PRESS && key == SGCT_KEY_PRINT_SCREEN)
|
||||
_doVideoExport = !_doVideoExport;
|
||||
#endif
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->keyboard(key, action);
|
||||
#endif
|
||||
@@ -431,4 +578,24 @@ void OpenSpaceEngine::decode()
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::externalControlCallback(const char* receivedChars,
|
||||
int size, int clientId)
|
||||
{
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
// The first byte determines the type of message
|
||||
const char type = receivedChars[0];
|
||||
switch (type) {
|
||||
case '0': // LuaScript
|
||||
{
|
||||
std::string script = std::string(receivedChars + 1);
|
||||
LINFO("Received Lua Script: '" << script << "'");
|
||||
_scriptEngine->runScript(script);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Author: Victor Sand (victor.sand@gmail.com)
|
||||
*
|
||||
*/
|
||||
|
||||
//#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <openspace/flare/CLProgram.h>
|
||||
#include <openspace/flare/CLManager.h>
|
||||
@@ -248,14 +249,13 @@ bool CLProgram::ReleaseBuffer(unsigned int _argNr) {
|
||||
|
||||
bool CLProgram::PrepareProgram() {
|
||||
//ghoulFinishGL();
|
||||
/*
|
||||
#ifdef __APPLE__
|
||||
//#ifdef __APPLE__
|
||||
|
||||
//glFlushRenderAPPLE();
|
||||
glFinish();
|
||||
// glFinish();
|
||||
//glFlush();
|
||||
#else
|
||||
*/
|
||||
//#else
|
||||
|
||||
|
||||
glFinish();
|
||||
// Let OpenCL take control of the shared GL textures
|
||||
@@ -341,15 +341,13 @@ bool CLProgram::FinishProgram() {
|
||||
LERROR("Failed to finish program");
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
#else
|
||||
error_ = clFinish(clManager_->commandQueues_[CLManager::EXECUTE]);
|
||||
if (!clManager_->CheckSuccess(error_, "FinishProgram, clFinish")) {
|
||||
ERROR("Failed to finish program");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
//#else
|
||||
//error_ = clFinish(clManager_->commandQueues_[CLManager::EXECUTE]);
|
||||
//if (!clManager_->CheckSuccess(error_, "FinishProgram, clFinish")) {
|
||||
// ERROR("Failed to finish program");
|
||||
// return false;
|
||||
//}
|
||||
//#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ using namespace osp;
|
||||
|
||||
Flare::Flare()
|
||||
: Renderable(ghoul::Dictionary())
|
||||
, _oldTime(0.f)
|
||||
, _currentTime(0.f)
|
||||
, _leftMouseButton(false)
|
||||
, _currentMouseX(0)
|
||||
, _currentMouseY(0)
|
||||
, _lastMouseX(0)
|
||||
, _lastMouseY(0)
|
||||
, _oldTime(0.f)
|
||||
, _currentTime(0.f)
|
||||
{
|
||||
setBoundingSphere(PowerScaledScalar::CreatePSS(sqrt(3.0f)));
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ Camera * InteractionHandler::getCamera() const {
|
||||
|
||||
const psc InteractionHandler::getOrigin() const {
|
||||
if(node_)
|
||||
return node_->getWorldPosition();
|
||||
return node_->worldPosition();
|
||||
return psc();
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void InteractionHandler::orbit(const glm::quat &rotation) {
|
||||
// should be changed to something more dynamic =)
|
||||
psc origin;
|
||||
if(node_) {
|
||||
origin = node_->getWorldPosition();
|
||||
origin = node_->worldPosition();
|
||||
}
|
||||
|
||||
psc relative_origin_coordinate = relative - origin;
|
||||
@@ -173,19 +173,21 @@ void InteractionHandler::distance(const PowerScaledScalar &distance) {
|
||||
lockControls();
|
||||
|
||||
psc relative = camera_->position();
|
||||
psc origin;
|
||||
if(node_) {
|
||||
origin = node_->getWorldPosition();
|
||||
}
|
||||
const psc origin = (node_) ? node_->worldPosition() : psc();
|
||||
|
||||
psc relative_origin_coordinate = relative - origin;
|
||||
glm::vec3 dir(relative_origin_coordinate.direction());
|
||||
dir = dir * distance[0];
|
||||
relative_origin_coordinate = dir;
|
||||
const glm::vec3 dir(relative_origin_coordinate.direction());
|
||||
glm:: vec3 newdir = dir * distance[0];
|
||||
relative_origin_coordinate = newdir;
|
||||
relative_origin_coordinate[3] = distance[1];
|
||||
relative = relative + relative_origin_coordinate;
|
||||
|
||||
camera_->setPosition(relative);
|
||||
relative_origin_coordinate = relative - origin;
|
||||
newdir = relative_origin_coordinate.direction();
|
||||
|
||||
// update only if on the same side of the origin
|
||||
if(glm::angle(newdir, dir) < 90.0f)
|
||||
camera_->setPosition(relative);
|
||||
|
||||
unlockControls();
|
||||
}
|
||||
@@ -246,7 +248,7 @@ glm::vec3 InteractionHandler::mapToCamera(glm::vec3 trackballPos) {
|
||||
|
||||
//Get x,y,z axis vectors of current camera view
|
||||
glm::vec3 currentViewYaxis = glm::normalize(camera_->lookUpVector());
|
||||
psc viewDir = camera_->position() - node_->getWorldPosition();
|
||||
psc viewDir = camera_->position() - node_->worldPosition();
|
||||
glm::vec3 currentViewZaxis = glm::normalize(viewDir.vec3());
|
||||
glm::vec3 currentViewXaxis = glm::normalize(glm::cross(currentViewYaxis, currentViewZaxis));
|
||||
|
||||
@@ -303,69 +305,63 @@ void InteractionHandler::keyboardCallback(int key, int action) {
|
||||
// TODO package in script
|
||||
const double speed = 2.75;
|
||||
const double dt = getDt();
|
||||
if (key == 'S') {
|
||||
glm::vec3 euler(speed * dt* pow(10, 17), 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
orbit(rot);
|
||||
}
|
||||
if (key == 'W') {
|
||||
glm::vec3 euler(-speed * dt* pow(10, 17), 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
orbit(rot);
|
||||
}
|
||||
if (key == 'A') {
|
||||
glm::vec3 euler(0.0, -speed * dt, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
orbit(rot);
|
||||
}
|
||||
if (key == 'D') {
|
||||
glm::vec3 euler(0.0, speed * dt, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
orbit(rot);
|
||||
}
|
||||
if (key == 262) {
|
||||
glm::vec3 euler(0.0, speed * dt, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == 263) {
|
||||
glm::vec3 euler(0.0, -speed * dt, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == 264) {
|
||||
glm::vec3 euler(speed * dt, 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == 265) {
|
||||
glm::vec3 euler(-speed * dt, 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == 'R') {
|
||||
PowerScaledScalar dist(-speed * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'F') {
|
||||
PowerScaledScalar dist(speed * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'T') {
|
||||
PowerScaledScalar dist(-speed * dt, 8.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'G') {
|
||||
PowerScaledScalar dist(speed * dt, 8.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'Y') {
|
||||
PowerScaledScalar dist(-speed * dt, 18.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == 'H') {
|
||||
PowerScaledScalar dist(speed * dt, 18.0);
|
||||
distance(dist);
|
||||
if(action == SGCT_PRESS || action == SGCT_REPEAT) {
|
||||
if (key == SGCT_KEY_S) {
|
||||
glm::vec3 euler(speed * dt, 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
orbit(rot);
|
||||
}
|
||||
if (key == SGCT_KEY_W) {
|
||||
glm::vec3 euler(-speed * dt, 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
orbit(rot);
|
||||
}
|
||||
if (key == SGCT_KEY_A) {
|
||||
glm::vec3 euler(0.0, -speed * dt, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
orbit(rot);
|
||||
}
|
||||
if (key == SGCT_KEY_D) {
|
||||
glm::vec3 euler(0.0, speed * dt, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
orbit(rot);
|
||||
}
|
||||
if (key == 262) {
|
||||
glm::vec3 euler(0.0, speed * dt, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == 263) {
|
||||
glm::vec3 euler(0.0, -speed * dt, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == 264) {
|
||||
glm::vec3 euler(speed * dt, 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == 265) {
|
||||
glm::vec3 euler(-speed * dt, 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotate(rot);
|
||||
}
|
||||
if (key == SGCT_KEY_R) {
|
||||
PowerScaledScalar dist(-speed * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == SGCT_KEY_F) {
|
||||
PowerScaledScalar dist(speed * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == SGCT_KEY_T) {
|
||||
PowerScaledScalar dist(-speed * 100.0 * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
if (key == SGCT_KEY_G) {
|
||||
PowerScaledScalar dist(speed * 100.0 * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (key == '1') {
|
||||
@@ -393,15 +389,23 @@ void InteractionHandler::keyboardCallback(int key, int action) {
|
||||
getCamera()->setCameraDirection(glm::vec3(0.0, 0.0, -1.0));
|
||||
}
|
||||
*/
|
||||
// std::pair <std::multimap<int,std::function<void(void)> >::iterator, std::multimap<int , std::function<void(void)> >::iterator> ret;
|
||||
if(action == SGCT_PRESS) {
|
||||
auto ret = _keyCallbacks.equal_range(key);
|
||||
for (auto it=ret.first; it!=ret.second; ++it)
|
||||
it->second();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void InteractionHandler::mouseButtonCallback(int key, int action) {
|
||||
//if(mouseControl_ != nullptr) {
|
||||
// mouseControl_->mouseButtonCallback(key,action);
|
||||
//}
|
||||
if (key == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
|
||||
if (key == SGCT_MOUSE_BUTTON_LEFT && action == SGCT_PRESS)
|
||||
_leftMouseButtonDown = true;
|
||||
else if (key == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_RELEASE) {
|
||||
else if (key == SGCT_MOUSE_BUTTON_LEFT && action == SGCT_RELEASE) {
|
||||
_leftMouseButtonDown = false;
|
||||
_isMouseBeingPressedAndHeld = false;
|
||||
}
|
||||
@@ -420,7 +424,21 @@ void InteractionHandler::mouseScrollWheelCallback(int pos) {
|
||||
//if(mouseControl_ != nullptr) {
|
||||
// mouseControl_->mouseScrollCallback(pos);
|
||||
//}
|
||||
const double speed = 4.75;
|
||||
const double dt = getDt();
|
||||
if(pos < 0) {
|
||||
PowerScaledScalar dist(speed * dt, 0.0);
|
||||
distance(dist);
|
||||
} else if(pos > 0) {
|
||||
PowerScaledScalar dist(-speed * dt, 0.0);
|
||||
distance(dist);
|
||||
}
|
||||
}
|
||||
|
||||
void InteractionHandler::addKeyCallback(int key, std::function<void(void)> f) {
|
||||
//std::map<int, std::vector<std::function<void(void)> > > _keyCallbacks;
|
||||
|
||||
_keyCallbacks.insert(std::make_pair(key, f));
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
namespace openspace {
|
||||
|
||||
Interface::Interface(OpenSpaceEngine* engine) : _engine(engine) {}
|
||||
Interface::Interface(OpenSpaceEngine* ) {}
|
||||
Interface::~Interface() {}
|
||||
|
||||
void Interface::callback(const char* receivedChars) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user