summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-10-11 20:25:39 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-10-11 20:25:39 (GMT)
commitef551cb937956e2c13570ab3f8f119c48fa5656e (patch)
treefb12268c38f7bbdddd583859d8c615411048d071
parent1924f35d1d21a59939110f7eae238052c37474e2 (diff)
downloaduscxml-ef551cb937956e2c13570ab3f8f119c48fa5656e.zip
uscxml-ef551cb937956e2c13570ab3f8f119c48fa5656e.tar.gz
uscxml-ef551cb937956e2c13570ab3f8f119c48fa5656e.tar.bz2
Reactivated plugin system
-rw-r--r--CMakeLists.txt24
-rw-r--r--apps/samples/put-that-there/put-that-there.scxml29
-rw-r--r--contrib/ctest/hosts/buildslave-opensuse-12-32.ctest6
-rw-r--r--contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest6
-rw-r--r--contrib/ctest/tests/plugins.ctest2
-rw-r--r--src/bindings/swig/java/CMakeLists.txt2
-rw-r--r--src/bindings/swig/php/uscxmlNativePHP.php18
-rw-r--r--src/uscxml/CMakeLists.txt2
-rw-r--r--src/uscxml/interpreter/InterpreterDraft6.cpp5
-rw-r--r--src/uscxml/plugins/datamodel/CMakeLists.txt26
-rw-r--r--src/uscxml/plugins/element/CMakeLists.txt10
-rw-r--r--src/uscxml/plugins/invoker/CMakeLists.txt96
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp365
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h41
-rw-r--r--src/uscxml/plugins/invoker/miles/SpatialAudio.cpp.old (renamed from src/uscxml/plugins/invoker/miles/SpatialAudio.cpp)0
-rw-r--r--src/uscxml/plugins/invoker/miles/SpatialAudio.h.old (renamed from src/uscxml/plugins/invoker/miles/SpatialAudio.h)0
-rw-r--r--src/uscxml/plugins/ioprocessor/CMakeLists.txt15
-rw-r--r--test/CMakeLists.txt8
18 files changed, 535 insertions, 120 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 533106e..4e7cadc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -402,6 +402,12 @@ endforeach()
OPTION(BUILD_AS_PLUGINS "Build invokers, ioprocessors and datamodels as plugins" OFF)
+if (BUILD_AS_PLUGINS)
+ add_definitions("-DBUILD_AS_PLUGINS")
+ include_directories("src/uscxml/plugins")
+# list(APPEND USCXML_FILES "src/uscxml/plugins/Plugins.cpp")
+endif()
+
# this is where the config.h ends up
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(src)
@@ -444,8 +450,10 @@ if (NOT WIN32)
elseif(APPLE)
find_library(APP_SERVICES_LIBRARY ApplicationServices)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
+ find_library(FOUNDATION_LIBRARY Foundation)
list (APPEND USCXML_CORE_LIBS ${APP_SERVICES_LIBRARY})
list (APPEND USCXML_CORE_LIBS ${COREFOUNDATION_LIBRARY})
+ list (APPEND USCXML_CORE_LIBS ${FOUNDATION_LIBRARY})
endif()
elseif(WIN32)
list (APPEND XML_LIBRARIES "Ws2_32")
@@ -653,11 +661,11 @@ endif()
find_package(MILES)
if (MILES_FOUND)
# openal is only needed for miles
- # find_package(OpenAL REQUIRED)
- # find_package(JPEG REQUIRED)
- # list (APPEND MILES_LIBRARIES "iconv")
- # list (APPEND MILES_LIBRARIES ${JPEG_LIBRARIES})
- # list (APPEND USCXML_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR})
+ find_package(OpenAL REQUIRED)
+ find_package(JPEG REQUIRED)
+ list (APPEND MILES_LIBRARIES "iconv")
+ list (APPEND MILES_LIBRARIES ${JPEG_LIBRARIES})
+ list (APPEND USCXML_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR})
include_directories (${MILES_INCLUDE_DIR})
list (APPEND USCXML_OPT_LIBS ${MILES_LIBRARIES})
@@ -757,7 +765,7 @@ endif()
if (NOT CMAKE_CROSSCOMPILING)
set_target_properties(uscxml PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "src/uscxml/pch.h")
set_target_properties(uscxml PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
- cotire(uscxml)
+# cotire(uscxml)
endif()
if (NOT CMAKE_CROSSCOMPILING)
@@ -765,13 +773,13 @@ if (NOT CMAKE_CROSSCOMPILING)
target_link_libraries(uscxml-browser uscxml)
if (NOT CMAKE_CROSSCOMPILING)
set_target_properties(uscxml-browser PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
- cotire(uscxml-browser)
+# cotire(uscxml-browser)
endif()
set_target_properties(uscxml-browser PROPERTIES FOLDER "Apps")
install_executable(TARGETS uscxml-browser COMPONENT tools)
- if (PROTOBUF_FOUND)
+ if (PROTOBUF_FOUND AND OFF)
file(GLOB W3C-MMI-COMMON ${PROJECT_SOURCE_DIR}/apps/w3c-mmi/*.cpp ${PROJECT_SOURCE_DIR}/apps/w3c-mmi/*.h)
file(GLOB_RECURSE W3C-MMI-IM ${PROJECT_SOURCE_DIR}/apps/w3c-mmi/im/*.cpp ${PROJECT_SOURCE_DIR}/apps/w3c-mmi/im/*.h)
diff --git a/apps/samples/put-that-there/put-that-there.scxml b/apps/samples/put-that-there/put-that-there.scxml
new file mode 100644
index 0000000..fee9f39
--- /dev/null
+++ b/apps/samples/put-that-there/put-that-there.scxml
@@ -0,0 +1,29 @@
+<scxml datamodel="ecmascript" initial="start" binding="late"
+ xmlns="http://www.w3.org/2005/07/scxml"
+ xmlns:scenegraph="http://uscxml.tk.informatik.tu-darmstadt.de/scenegraph.xsd">
+ <state id="start">
+ <invoke type="scenegraph">
+ <content>
+ <scenegraph:display x="0" y="0" width="80%" height="80%">
+ <scenegraph:viewport x="0" y="0" width="100%" height="100%" bgcolor="grey" id="scene1">
+ <scenegraph:translation x="0" y="0" z="0">
+ <scenegraph:sphere radius="1" materialcolor="1.0,1.0,0,0.3" />
+ </scenegraph:translation>
+ <scenegraph:translation x="5" y="0" z="0">
+ <scenegraph:box x="1" y="2" z="3" color="red" />
+ </scenegraph:translation>
+ <scenegraph:translation x="0" y="5" z="0">
+ <scenegraph:capsule radius="1" height="2" materialcolor="blue" transparency="0.5"/>
+ </scenegraph:translation>
+ <scenegraph:translation x="0" y="0" z="5">
+ <scenegraph:cone radius="1" height="2" color="lightblue" />
+ </scenegraph:translation>
+ <scenegraph:translation x="0" y="-5" z="0">
+ <scenegraph:cylinder radius="1" height="2" color="orange" />
+ </scenegraph:translation>
+ </scenegraph:viewport>
+ </scenegraph:display>
+ </content>
+ </invoke>
+ </state>
+</scxml> \ No newline at end of file
diff --git a/contrib/ctest/hosts/buildslave-opensuse-12-32.ctest b/contrib/ctest/hosts/buildslave-opensuse-12-32.ctest
index 8b49d1a..e5a0406 100644
--- a/contrib/ctest/hosts/buildslave-opensuse-12-32.ctest
+++ b/contrib/ctest/hosts/buildslave-opensuse-12-32.ctest
@@ -13,3 +13,9 @@ set(REMOVE_PREBUILDS OFF)
set(CTEST_BUILD_NAME "linux-x86 gcc 4.7.2")
include("tests/xpath.ctest")
include("common.ctest.inc")
+
+set(RETAIN_BUILD_DIR OFF)
+set(REMOVE_PREBUILDS OFF)
+set(CTEST_BUILD_NAME "linux-x86 gcc 4.7.2")
+include("tests/plugins.ctest")
+include("common.ctest.inc")
diff --git a/contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest b/contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest
index 8636679..b77b3a7 100644
--- a/contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest
+++ b/contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest
@@ -13,3 +13,9 @@ set(REMOVE_PREBUILDS OFF)
set(CTEST_BUILD_NAME "linux-x86 gcc 4.6.3")
include("tests/xpath.ctest")
include("common.ctest.inc")
+
+set(RETAIN_BUILD_DIR OFF)
+set(REMOVE_PREBUILDS OFF)
+set(CTEST_BUILD_NAME "linux-x86 gcc 4.6.3")
+include("tests/plugins.ctest")
+include("common.ctest.inc")
diff --git a/contrib/ctest/tests/plugins.ctest b/contrib/ctest/tests/plugins.ctest
new file mode 100644
index 0000000..a983bb9
--- /dev/null
+++ b/contrib/ctest/tests/plugins.ctest
@@ -0,0 +1,2 @@
+set(CTEST_BUILD_OPTIONS "-DBUILD_AS_PLUGINS=ON -DENABLE_GCOV:BOOL=ON")
+set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME} - plugins") \ No newline at end of file
diff --git a/src/bindings/swig/java/CMakeLists.txt b/src/bindings/swig/java/CMakeLists.txt
index 2b604f3..fb02b17 100644
--- a/src/bindings/swig/java/CMakeLists.txt
+++ b/src/bindings/swig/java/CMakeLists.txt
@@ -16,7 +16,7 @@ SET(SCXMLPL_JAVA_PACKAGE "org.uscxml")
SET(SCXMLPL_JAVA_DIR "org/uscxml")
# we need ; to produce a space with the package .. weird
-SET_SOURCE_FILES_PROPERTIES(uscxml.i PROPERTIES SWIG_FLAGS "-package;${SCXMLPL_JAVA_PACKAGE}")
+SET_SOURCE_FILES_PROPERTIES(uscxml.i PROPERTIES SWIG_FLAGS "-w473 -package;${SCXMLPL_JAVA_PACKAGE}")
SET_SOURCE_FILES_PROPERTIES(uscxml.i PROPERTIES CPLUSPLUS ON)
SET(CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/${SCXMLPL_JAVA_DIR}")
diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php
index 4a9c37b..a0c8cd2 100644
--- a/src/bindings/swig/php/uscxmlNativePHP.php
+++ b/src/bindings/swig/php/uscxmlNativePHP.php
@@ -260,6 +260,24 @@ class Blob {
default: $this->_cPtr=new_Blob($size_or_data,$size,$adopt);
}
}
+
+ function md5() {
+ return Blob_md5($this->_cPtr);
+ }
+
+ function base64() {
+ return Blob_base64($this->_cPtr);
+ }
+
+ function fromBase64($base64) {
+ $r=Blob_fromBase64($this->_cPtr,$base64);
+ if (is_resource($r)) {
+ $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
+ if (class_exists($c)) return new $c($r);
+ return new Blob($r);
+ }
+ return $r;
+ }
}
class Data {
diff --git a/src/uscxml/CMakeLists.txt b/src/uscxml/CMakeLists.txt
index 20c9010..9582112 100644
--- a/src/uscxml/CMakeLists.txt
+++ b/src/uscxml/CMakeLists.txt
@@ -38,7 +38,7 @@ source_group("Interpreter" FILES ${USCXML_INTERPRETERS})
list (APPEND USCXML_FILES ${USCXML_INTERPRETERS})
if(APPLE OR IOS)
- file(GLOB_RECURSE USCXML_APPLE
+ file(GLOB USCXML_APPLE
*.mm
)
source_group("Interpreter" FILES ${USCXML_APPLE})
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp
index 3480c43..7ea09c2 100644
--- a/src/uscxml/interpreter/InterpreterDraft6.cpp
+++ b/src/uscxml/interpreter/InterpreterDraft6.cpp
@@ -34,6 +34,11 @@ void InterpreterDraft6::interpret() {
datamodelName = ATTR(_scxml, "profile");
if(datamodelName.length() > 0) {
_dataModel = _factory->createDataModel(datamodelName, this);
+ if (!_dataModel) {
+ Event e;
+ e.data.compound["cause"] = Data("Cannot instantiate datamodel");
+ throw e;
+ }
} else {
_dataModel = _factory->createDataModel("null", this);
}
diff --git a/src/uscxml/plugins/datamodel/CMakeLists.txt b/src/uscxml/plugins/datamodel/CMakeLists.txt
index 3b6a852..4811551 100644
--- a/src/uscxml/plugins/datamodel/CMakeLists.txt
+++ b/src/uscxml/plugins/datamodel/CMakeLists.txt
@@ -8,22 +8,21 @@ if (BUILD_DM_ECMA)
ecmascript/*.cpp
ecmascript/*.h
)
- source_group("Datamodel\\jsc" FILES ${JSC_DATAMODEL})
file(GLOB_RECURSE JSC_DOM
ecmascript/JavaScriptCore/dom/*.cpp
ecmascript/JavaScriptCore/dom/*.h
)
- source_group("Datamodel\\DOM" FILES ${JSC_DOM})
if (BUILD_AS_PLUGINS)
+ source_group("JavaScriptCore" FILES ${JSC_DATAMODEL})
+ source_group("dom" FILES ${JSC_DOM})
+
add_library(
datamodel_jsc SHARED
${JSC_DATAMODEL}
${JSC_DOM})
- target_link_libraries(datamodel_jsc
- uscxml
- ${JSC_LIBRARY})
+ target_link_libraries(datamodel_jsc uscxml ${JSC_LIBRARY})
set_target_properties(datamodel_jsc PROPERTIES FOLDER "Plugin DataModel")
- else()
+ else()
list (APPEND USCXML_FILES ${JSC_DATAMODEL})
list (APPEND USCXML_FILES ${JSC_DOM})
list (APPEND USCXML_OPT_LIBS ${JSC_LIBRARY})
@@ -40,21 +39,20 @@ if (BUILD_DM_ECMA)
ecmascript/*.cpp
ecmascript/*.h
)
- source_group("Datamodel\\v8" FILES ${V8_DATAMODEL})
file(GLOB_RECURSE V8_DOM
ecmascript/v8/dom/*.cpp
ecmascript/v8/dom/*.h
)
- source_group("Datamodel\\v8\\DOM" FILES ${V8_DOM})
if (BUILD_AS_PLUGINS)
+ source_group("V8" FILES ${V8_DATAMODEL})
+ source_group("dom" FILES ${V8_DOM})
+
add_library(
datamodel_v8 SHARED
${V8_DATAMODEL}
${V8_DOM})
- target_link_libraries(datamodel_v8
- uscxml
- ${V8_LIBRARY})
+ target_link_libraries(datamodel_v8 uscxml ${V8_LIBRARY})
set_target_properties(datamodel_v8 PROPERTIES FOLDER "Plugin DataModel")
else()
list (APPEND USCXML_FILES ${V8_DATAMODEL})
@@ -72,8 +70,8 @@ file(GLOB NULL_DATAMODEL
null/*.cpp
null/*.h
)
-source_group("Datamodel\\null" FILES ${NULL_DATAMODEL})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${NULL_DATAMODEL})
add_library(datamodel_null SHARED ${NULL_DATAMODEL})
target_link_libraries(datamodel_null uscxml)
set_target_properties(datamodel_null PROPERTIES FOLDER "Plugin DataModel")
@@ -90,8 +88,8 @@ if (BUILD_DM_XPATH)
xpath/*.cpp
xpath/*.h
)
- source_group("Datamodel\\xpath" FILES ${XPATH_DATAMODEL})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${XPATH_DATAMODEL})
add_library(datamodel_xpath SHARED ${XPATH_DATAMODEL})
target_link_libraries(datamodel_xpath uscxml)
set_target_properties(datamodel_xpath PROPERTIES FOLDER "Plugin DataModel")
@@ -116,8 +114,8 @@ if (SWI_FOUND AND BUILD_DM_PROLOG)
prolog/swi/*.cpp
prolog/swi/*.h
)
- source_group("Datamodel\\swi" FILES ${SWI_DATAMODEL})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${SWI_DATAMODEL})
add_library(
datamodel_swi SHARED
${SWI_DATAMODEL})
diff --git a/src/uscxml/plugins/element/CMakeLists.txt b/src/uscxml/plugins/element/CMakeLists.txt
index fd69417..c0a7e15 100644
--- a/src/uscxml/plugins/element/CMakeLists.txt
+++ b/src/uscxml/plugins/element/CMakeLists.txt
@@ -5,8 +5,8 @@ file(GLOB_RECURSE FETCH_ELEMENT
fetch/*.cpp
fetch/*.h
)
-source_group("Element\\fetch" FILES ${FETCH_ELEMENT})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${FETCH_ELEMENT})
add_library(
element_fetch SHARED
${FETCH_ELEMENT})
@@ -22,8 +22,8 @@ endif()
# mmi/*.cpp
# mmi/*.h
# )
-# source_group("Element\\mmi" FILES ${MMI_ELEMENT})
# if (BUILD_AS_PLUGINS)
+# source_group("" FILES ${MMI_ELEMENT})
# add_library(
# element_mmi SHARED
# ${MMI_ELEMENT})
@@ -41,8 +41,8 @@ file(GLOB_RECURSE POSTPONE_ELEMENT
postpone/*.cpp
postpone/*.h
)
-source_group("Element\\postpone" FILES ${POSTPONE_ELEMENT})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${POSTPONE_ELEMENT})
add_library(
element_postpone SHARED
${POSTPONE_ELEMENT})
@@ -60,8 +60,8 @@ file(GLOB_RECURSE FILE_ELEMENT
file/*.cpp
file/*.h
)
-source_group("Element\\file" FILES ${FILE_ELEMENT})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${FILE_ELEMENT})
add_library(
element_file SHARED
${FILE_ELEMENT})
@@ -79,8 +79,8 @@ file(GLOB_RECURSE RESPOND_ELEMENT
respond/*.cpp
respond/*.h
)
-source_group("Element\\respond" FILES ${RESPOND_ELEMENT})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${RESPOND_ELEMENT})
add_library(
element_respond SHARED
${RESPOND_ELEMENT})
diff --git a/src/uscxml/plugins/invoker/CMakeLists.txt b/src/uscxml/plugins/invoker/CMakeLists.txt
index 5f767c9..43dd683 100644
--- a/src/uscxml/plugins/invoker/CMakeLists.txt
+++ b/src/uscxml/plugins/invoker/CMakeLists.txt
@@ -5,8 +5,8 @@ file(GLOB_RECURSE SAMPLE_INVOKER
sample/*.h
)
-source_group("Invoker\\sample" FILES ${SAMPLE_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${SAMPLE_INVOKER})
add_library(
invoker_sample SHARED
${SAMPLE_INVOKER})
@@ -23,8 +23,8 @@ file(GLOB_RECURSE DIRMON_INVOKER
filesystem/dirmon/*.cpp
filesystem/dirmon/*.h
)
-source_group("Invoker\\dirmon" FILES ${DIRMON_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${DIRMON_INVOKER})
add_library(
invoker_dirmon SHARED
${DIRMON_INVOKER})
@@ -37,20 +37,20 @@ endif()
# Location invoker to watch for proximity to GPS coordinates
-file(GLOB_RECURSE LOCATION_INVOKER
- location/*.cpp
- location/*.h
-)
-source_group("Invoker\\location" FILES ${LOCATION_INVOKER})
-if (BUILD_AS_PLUGINS)
- add_library(
- invoker_location SHARED
- ${LOCATION_INVOKER})
- target_link_libraries(invoker_location uscxml)
- set_target_properties(invoker_location PROPERTIES FOLDER "Plugin Invoker")
-else()
- list (APPEND USCXML_FILES ${LOCATION_INVOKER})
-endif()
+# file(GLOB_RECURSE LOCATION_INVOKER
+# location/*.cpp
+# location/*.h
+# )
+# if (BUILD_AS_PLUGINS)
+# source_group("" FILES ${LOCATION_INVOKER})
+# add_library(
+# invoker_location SHARED
+# ${LOCATION_INVOKER})
+# target_link_libraries(invoker_location uscxml)
+# set_target_properties(invoker_location PROPERTIES FOLDER "Plugin Invoker")
+# else()
+# list (APPEND USCXML_FILES ${LOCATION_INVOKER})
+# endif()
# XHTML invoker
@@ -60,8 +60,8 @@ file(GLOB_RECURSE XHTML_INVOKER
xhtml/*.cpp
xhtml/*.h
)
-source_group("Invoker\\xhtml" FILES ${XHTML_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${XHTML_INVOKER})
add_library(
invoker_xhtml SHARED
${XHTML_INVOKER})
@@ -78,8 +78,8 @@ file(GLOB_RECURSE SYSTEM_INVOKER
system/*.cpp
system/*.h
)
-source_group("Invoker\\system" FILES ${SYSTEM_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${SYSTEM_INVOKER})
add_library(
invoker_system SHARED
${SYSTEM_INVOKER})
@@ -97,8 +97,8 @@ if (SQLITE3_FOUND)
sqlite3/*.cpp
sqlite3/*.h
)
- source_group("Invoker\\sqlite" FILES ${SQLITE3_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${SQLITE3_INVOKER})
add_library(
invoker_sqlite3 SHARED
${SQLITE3_INVOKER})
@@ -118,12 +118,12 @@ if (FFMPEG_FOUND)
ffmpeg/*.cpp
ffmpeg/*.h
)
- source_group("Invoker\\ffmpeg" FILES ${FFMPEG_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${FFMPEG_INVOKER})
add_library(
invoker_ffmpeg SHARED
${FFMPEG_INVOKER})
- target_link_libraries(invoker_ffmpeg uscxml)
+ target_link_libraries(invoker_ffmpeg uscxml ${FFMPEG_LIBRARIES})
set_target_properties(invoker_ffmpeg PROPERTIES FOLDER "Plugin Invoker")
else()
list (APPEND USCXML_FILES ${FFMPEG_INVOKER})
@@ -139,12 +139,12 @@ if (LIBPURPLE_FOUND)
im/*.cpp
im/*.h
)
- source_group("Invoker\\im" FILES ${LIBPURPLE_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${LIBPURPLE_INVOKER})
add_library(
invoker_im SHARED
${LIBPURPLE_INVOKER})
- target_link_libraries(invoker_im uscxml)
+ target_link_libraries(invoker_im uscxml ${LIBPURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${ICONV_LIBRARIES})
set_target_properties(invoker_im PROPERTIES FOLDER "Plugin Invoker")
else()
list (APPEND USCXML_FILES ${LIBPURPLE_INVOKER})
@@ -160,12 +160,12 @@ if (LIBICAL_FOUND)
calendar/*.cpp
calendar/*.h
)
- source_group("Invoker\\calendar" FILES ${CALENDAR_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${CALENDAR_INVOKER})
add_library(
invoker_calendar SHARED
${CALENDAR_INVOKER})
- target_link_libraries(invoker_calendar uscxml)
+ target_link_libraries(invoker_calendar uscxml ${LIBICAL_LIBRARIES})
set_target_properties(invoker_calendar PROPERTIES FOLDER "Plugin Invoker")
else()
list (APPEND USCXML_FILES ${CALENDAR_INVOKER})
@@ -182,8 +182,8 @@ if (CORELOCATION_LIBRARY AND OFF)
location/CoreLocation/*.mm
location/CoreLocation/*.h
)
- source_group("Invoker\\location" FILES ${LOCATION_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${LOCATION_INVOKER})
add_library(
invoker_location SHARED
${LOCATION_INVOKER})
@@ -203,14 +203,16 @@ if (UMUNDO_FOUND)
umundo/*.cpp
umundo/*.cc
umundo/*.h)
- source_group("Invoker\\umundo" FILES ${UMUNDO_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${UMUNDO_INVOKER})
+# message(FATAL_ERROR "UMUNDO_LIBRARIES: ${UMUNDO_LIBRARIES}")
add_library(
invoker_umundo SHARED
${UMUNDO_INVOKER})
- target_link_libraries(invoker_umundo
- uscxml
- ${UMUNDO_LIBRARIES})
+ target_link_libraries(invoker_umundo uscxml
+ optimized ${PROTOBUF_LIBRARY}
+ debug ${PROTOBUF_LIBRARY_DEBUG}
+ ${UMUNDO_LIBRARIES})
set_target_properties(invoker_umundo PROPERTIES FOLDER "Plugin Invoker")
else()
list (APPEND USCXML_FILES ${UMUNDO_INVOKER})
@@ -224,8 +226,8 @@ set(USCXML_INVOKERS "scxml ${USCXML_INVOKERS}")
file(GLOB_RECURSE USCXML_INVOKER
scxml/*.cpp
scxml/*.h)
-source_group("Invoker\\uscxml" FILES ${USCXML_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${USCXML_INVOKER})
add_library(
invoker_uscxml SHARED
${USCXML_INVOKER})
@@ -243,8 +245,8 @@ set(USCXML_INVOKERS "httpservlet ${USCXML_INVOKERS}")
file(GLOB_RECURSE HTTPSERVLET_INVOKER
http/*.cpp
http/*.h)
-source_group("Invoker\\httpservlet" FILES ${HTTPSERVLET_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${HTTPSERVLET_INVOKER})
add_library(
invoker_httpserver SHARED
${HTTPSERVLET_INVOKER})
@@ -263,8 +265,8 @@ file(GLOB_RECURSE HEARTBEAT_INVOKER
heartbeat/*.cpp
heartbeat/*.h
)
-source_group("Invoker\\heartbeat" FILES ${HEARTBEAT_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${HEARTBEAT_INVOKER})
add_library(
invoker_heartbeat SHARED
${HEARTBEAT_INVOKER})
@@ -281,9 +283,9 @@ if (OPENSCENEGRAPH_FOUND AND OPENGL_FOUND)
file(GLOB OPENSCENEGRAPH_INVOKER
graphics/openscenegraph/*.cpp
graphics/openscenegraph/*.h)
- source_group("Invoker\\scenegraph" FILES ${OPENSCENEGRAPH_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${OPENSCENEGRAPH_INVOKER})
add_library(
invoker_openscenegraph SHARED
${OPENSCENEGRAPH_INVOKER})
@@ -300,9 +302,9 @@ if (OPENSCENEGRAPH_FOUND AND OPENGL_FOUND)
file(GLOB OPENSCENEGRAPH_CONVERTER_INVOKER
graphics/openscenegraph/converter/*.cpp
graphics/openscenegraph/converter/*.h)
- source_group("Invoker\\scenegraph\\convert" FILES ${OPENSCENEGRAPH_CONVERTER_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${OPENSCENEGRAPH_CONVERTER_INVOKER})
add_library(
invoker_openscenegraph_convert SHARED
${OPENSCENEGRAPH_CONVERTER_INVOKER})
@@ -335,16 +337,24 @@ if (OPENAL_FOUND AND (LIBSNDFILE_FOUND OR AUDIOTOOLBOX_FOUND))
audio/AudioToolbox*.h)
LIST(APPEND OPENAL_INVOKER ${AUDIOTOOLBOX_WRAPPER})
endif()
- source_group("Invoker\\audio" FILES ${OPENAL_INVOKER})
# message("MILES_INVOKER ${MILES_INVOKER}")
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${OPENAL_INVOKER})
add_library(
invoker_openal SHARED
${OPENAL_INVOKER})
- target_link_libraries(invoker_openal
- ${OPENAL_LIBRARY}
- uscxml)
+ if (LIBSNDFILE_FOUND)
+ target_link_libraries(invoker_openal
+ ${OPENAL_LIBRARY}
+ ${LIBSNDFILE_LIBRARY}
+ uscxml)
+ elseif(AUDIOTOOLBOX_FOUND)
+ target_link_libraries(invoker_openal
+ ${OPENAL_LIBRARY}
+ ${AUDIOTOOLBOX}/AudioToolbox
+ uscxml)
+ endif()
set_target_properties(invoker_openal PROPERTIES FOLDER "Plugin Invoker")
else()
list (APPEND USCXML_FILES ${OPENAL_INVOKER})
@@ -359,16 +369,18 @@ if (MILES_FOUND)
file(GLOB_RECURSE MILES_INVOKER
miles/*.cpp
miles/*.h)
- source_group("Invoker\\miles" FILES ${MILES_INVOKER})
# message("MILES_INVOKER ${MILES_INVOKER}")
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${MILES_INVOKER})
add_library(
invoker_miles SHARED
${MILES_INVOKER})
target_link_libraries(invoker_miles
${MILES_LIBRARIES}
${OPENAL_LIBRARY}
+ ${JPEG_LIBRARIES}
+ ${ICONV_LIBRARIES}
uscxml)
set_target_properties(invoker_miles PROPERTIES FOLDER "Plugin Invoker")
else()
@@ -379,14 +391,14 @@ endif()
# VoiceXML modality components
-if (UMUNDO_FOUND)
+if (UMUNDO_FOUND AND OFF)
set(USCXML_INVOKERS "vxml ${USCXML_INVOKERS}")
file(GLOB_RECURSE VXML_INVOKER
vxml/*.cpp
vxml/*.h
)
- source_group("Invoker\\voicexml" FILES ${VXML_INVOKER})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${VXML_INVOKER})
add_library(
invoker_voicexml SHARED
${VXML_INVOKER})
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
index 2b77baf..d732e63 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
@@ -3,10 +3,36 @@
#include "uscxml/UUID.h"
#include <glog/logging.h>
+#include <osg/Shape>
+#include <osg/ShapeDrawable>
+#include <osg/Material>
+#include <osg/Depth>
+
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
#endif
+#define OSG_SET_MATERIAL \
+osg::ref_ptr<osg::Material> mat = getMaterial(element); \
+if (mat) { \
+ osg::ref_ptr<osg::StateSet> nodeSS = geode->getOrCreateStateSet(); \
+\
+ nodeSS->setAttribute(mat.get()); \
+ nodeSS->setMode( GL_BLEND, osg::StateAttribute::ON ); \
+/* nodeSS->setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); \
+ nodeSS->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON ); \
+ osg::Depth* depth = new osg::Depth; \
+ depth->setWriteMask( false ); \
+ nodeSS->setAttributeAndModes( depth, osg::StateAttribute::ON ); \
+ nodeSS->setMode( GL_LIGHTING, osg::StateAttribute::OFF );*/ \
+}
+
+#define OSG_SET_COLOR \
+bool validColor = true; \
+osg::Vec4 color = getColor(element, "color", validColor); \
+if (validColor) \
+drawable->setColor(color);
+
namespace uscxml {
#ifdef BUILD_AS_PLUGINS
@@ -17,6 +43,12 @@ bool connect(pluma::Host& host) {
}
#endif
+#define OSG_TAG_HANDLE(tagName, procFunc) \
+} else if (boost::iequals(LOCALNAME(childs.item(i)), tagName) && \
+ validChildren.find(tagName) != validChildren.end()) { \
+ procFunc(childs.item(i));\
+
+
OSGInvoker::OSGInvoker() {
}
@@ -35,6 +67,9 @@ Data OSGInvoker::getDataModelVariables() {
}
void OSGInvoker::send(const SendRequest& req) {
+ if (boost::iequals(req.name, "intersect")) {
+
+ }
}
void OSGInvoker::cancel(const std::string sendId) {
@@ -43,6 +78,10 @@ void OSGInvoker::cancel(const std::string sendId) {
void OSGInvoker::invoke(const InvokeRequest& req) {
tthread::lock_guard<tthread::recursive_mutex> lock(_mutex);
+ setupColors();
+
+ std::cout << req.dom;
+
// register default event handlers
Arabica::DOM::Events::EventTarget<std::string> evTarget = Arabica::DOM::Events::EventTarget<std::string>(req.dom);
evTarget.addEventListener("DOMSubtreeModified", *this, false);
@@ -52,9 +91,37 @@ void OSGInvoker::invoke(const InvokeRequest& req) {
std::set<std::string> validChilds;
validChilds.insert("display");
- processChildren(validChilds, req.dom);
+
+ // this is somewhat unfortunate, if content contains a single child, we will get that, otherwise its parent (<content>)
+ if (boost::iequals(LOCALNAME(req.dom), "display")) {
+ processChildren(validChilds, req.dom.getParentNode());
+ } else {
+ processChildren(validChilds, req.dom);
+ }
}
+void OSGInvoker::setupColors() {
+ _colors["red"] = osg::Vec4(1.0, 0.0, 0.0, 1.0);
+ _colors["cyan"] = osg::Vec4(0.0, 1.0, 1.0, 1.0);
+ _colors["blue"] = osg::Vec4(0.0, 0.0, 1.0, 1.0);
+ _colors["darkblue"] = osg::Vec4(0.0, 0.0, 0.625, 1.0);
+ _colors["lightblue"] = osg::Vec4(0.675, 0.84375,0.89844,1.0);
+ _colors["purple"] = osg::Vec4(0.5, 0.0, 0.5, 1.0);
+ _colors["yellow"] = osg::Vec4(1.0, 1.0, 0.0, 1.0);
+ _colors["lime"] = osg::Vec4(0.0, 1.0, 0.0, 1.0);
+ _colors["magenta"] = osg::Vec4(1.0, 0.0, 1.0, 1.0);
+ _colors["white"] = osg::Vec4(1.0, 1.0, 1.0, 1.0);
+ _colors["silver"] = osg::Vec4(0.75, 0.75, 0.75, 1.0);
+ _colors["grey"] = osg::Vec4(0.5, 0.5, 0.5, 1.0);
+ _colors["gray"] = osg::Vec4(0.5, 0.5, 0.5, 1.0);
+ _colors["black"] = osg::Vec4(0.0, 0.0, 0.0, 1.0);
+ _colors["orange"] = osg::Vec4(1.0, 0.644, 0.0, 1.0);
+ _colors["brown"] = osg::Vec4(0.644, 0.164, 0.164, 1.0);
+ _colors["maroon"] = osg::Vec4(0.5, 0.0, 0.0, 1.0);
+ _colors["green"] = osg::Vec4(0.0, 0.5, 0.0, 1.0);
+ _colors["olive"] = osg::Vec4(0.5, 0.5, 0.0, 1.0);
+}
+
void OSGInvoker::runOnMainThread() {
_displays_t::iterator dispIter = _displays.begin();
if (_mutex.try_lock()) {
@@ -70,7 +137,7 @@ void OSGInvoker::handleEvent(Arabica::DOM::Events::Event<std::string>& event) {
// std::cout << "Handling Event!" << std::endl;
Arabica::DOM::Node<std::string> node(event.getTarget());
if (_nodes.find(node) != _nodes.end()) {
- osg::Node* osgNode = _nodes[node];
+ osg::ref_ptr<osg::Node> osgNode = _nodes[node];
if (false) {
} else if (boost::iequals(LOCALNAME(node), "rotation")) {
updateRotation(osgNode, event);
@@ -117,26 +184,39 @@ void OSGInvoker::processViewport(const Arabica::DOM::Node<std::string>& element)
unsigned int actualY = 0;
unsigned int actualWidth = 0;
unsigned int actualHeight = 0;
+
getViewport(element, actualX, actualY, actualWidth, actualHeight, compDisp);
-
osg::Viewport* viewPort = new osg::Viewport(actualX, actualY, actualWidth, actualHeight);
compDisp->addView(name, viewPort, sceneView);
+ bool hasBGColor;
+ osg::Vec4 bgColor = getColor(element, "bgcolor", hasBGColor);
+ if (hasBGColor) {
+ sceneView->getCamera()->setClearColor(bgColor);
+ } else {
+ sceneView->getCamera()->setClearColor(_colors["white"]);
+ }
+
std::set<std::string> validChilds;
validChilds.insert("camera");
validChilds.insert("translation");
validChilds.insert("rotation");
validChilds.insert("scale");
validChilds.insert("node");
+ validChilds.insert("sphere");
+ validChilds.insert("box");
+ validChilds.insert("capsule");
+ validChilds.insert("cone");
+ validChilds.insert("cylinder");
processChildren(validChilds, element);
}
void OSGInvoker::processCamera(const Arabica::DOM::Node<std::string>& element) {}
-void OSGInvoker::updateCamera(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event) {}
+void OSGInvoker::updateCamera(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) {}
void OSGInvoker::processTranslation(const Arabica::DOM::Node<std::string>& element) {
assert(_nodes.find(element.getParentNode()) != _nodes.end());
- osg::Node* node = _nodes[element.getParentNode()];
+ osg::ref_ptr<osg::Node> node = _nodes[element.getParentNode()];
double x = 0, y = 0, z = 0;
if (HAS_ATTR(element, "x"))
@@ -159,12 +239,17 @@ void OSGInvoker::processTranslation(const Arabica::DOM::Node<std::string>& eleme
validChilds.insert("rotation");
validChilds.insert("scale");
validChilds.insert("node");
+ validChilds.insert("sphere");
+ validChilds.insert("box");
+ validChilds.insert("capsule");
+ validChilds.insert("cone");
+ validChilds.insert("cylinder");
processChildren(validChilds, element);
}
void OSGInvoker::processRotation(const Arabica::DOM::Node<std::string>& element) {
assert(_nodes.find(element.getParentNode()) != _nodes.end());
- osg::Node* node = _nodes[element.getParentNode()];
+ osg::ref_ptr<osg::Node> node = _nodes[element.getParentNode()];
osg::Matrix rotation = rotationFromElement(element);
osg::MatrixTransform* transform = new osg::MatrixTransform();
@@ -177,11 +262,16 @@ void OSGInvoker::processRotation(const Arabica::DOM::Node<std::string>& element)
validChilds.insert("rotation");
validChilds.insert("scale");
validChilds.insert("node");
+ validChilds.insert("sphere");
+ validChilds.insert("box");
+ validChilds.insert("capsule");
+ validChilds.insert("cone");
+ validChilds.insert("cylinder");
processChildren(validChilds, element);
}
-void OSGInvoker::updateRotation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event) {
- osg::MatrixTransform* transform = static_cast<osg::MatrixTransform*>(node);
+void OSGInvoker::updateRotation(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) {
+ osg::ref_ptr<osg::MatrixTransform> transform = static_cast<osg::MatrixTransform*>(node->asTransform());
if (false) {
} else if (boost::iequals(event.getType(), "DOMAttrModified")) {
osg::Matrix rotation = rotationFromElement(Arabica::DOM::Node<std::string>(event.getTarget()));
@@ -232,7 +322,7 @@ osg::Matrix OSGInvoker::rotationFromElement(const Arabica::DOM::Node<std::string
void OSGInvoker::processScale(const Arabica::DOM::Node<std::string>& element) {
assert(_nodes.find(element.getParentNode()) != _nodes.end());
- osg::Node* node = _nodes[element.getParentNode()];
+ osg::ref_ptr<osg::Node> node = _nodes[element.getParentNode()];
double x = 1, y = 1, z = 1;
if (HAS_ATTR(element, "x"))
@@ -255,6 +345,11 @@ void OSGInvoker::processScale(const Arabica::DOM::Node<std::string>& element) {
validChilds.insert("rotation");
validChilds.insert("scale");
validChilds.insert("node");
+ validChilds.insert("sphere");
+ validChilds.insert("box");
+ validChilds.insert("capsule");
+ validChilds.insert("cone");
+ validChilds.insert("cylinder");
processChildren(validChilds, element);
}
@@ -263,7 +358,7 @@ void OSGInvoker::processNode(const Arabica::DOM::Node<std::string>& element) {
assert(nodeIter != _nodes.end());
assert(_nodes.find(element.getParentNode()) != _nodes.end());
- osg::Node* parent = _nodes[element.getParentNode()];
+ osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()];
std::string filename;
if (HAS_ATTR(element, "src")) {
@@ -290,33 +385,241 @@ void OSGInvoker::processNode(const Arabica::DOM::Node<std::string>& element) {
}
}
+void OSGInvoker::processSphere(const Arabica::DOM::Node<std::string>& element) {
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()];
+
+ float radius = 1;
+ osg::Vec3 center(0,0,0);
+
+ if (HAS_ATTR(element, "radius")) {
+ radius = strTo<float>(ATTR(element, "radius"));
+ }
+
+ osg::ref_ptr<osg::Sphere> sphere = new osg::Sphere(center, radius);
+ osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(sphere);
+ osg::ref_ptr<osg::Geode> geode = new osg::Geode();
+ geode->addDrawable(drawable);
+
+ OSG_SET_COLOR;
+ OSG_SET_MATERIAL;
+
+ _nodes[element] = geode;
+
+ parent->asGroup()->addChild(geode);
+}
+
+void OSGInvoker::updateSphere(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) {
+}
+
+void OSGInvoker::processBox(const Arabica::DOM::Node<std::string>& element) {
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()];
+
+ float x = 1;
+ float y = 1;
+ float z = 1;
+ osg::Vec3 center(0,0,0);
+
+ if (HAS_ATTR(element, "x")) x = strTo<float>(ATTR(element, "x"));
+ if (HAS_ATTR(element, "y")) y = strTo<float>(ATTR(element, "y"));
+ if (HAS_ATTR(element, "z")) z = strTo<float>(ATTR(element, "z"));
+
+ osg::ref_ptr<osg::Box> box = new osg::Box(center, x, y, z);
+ osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(box);
+ osg::ref_ptr<osg::Geode> geode = new osg::Geode();
+ geode->addDrawable(drawable);
+
+ OSG_SET_COLOR;
+ OSG_SET_MATERIAL;
+
+ _nodes[element] = geode;
+
+ parent->asGroup()->addChild(geode);
+
+}
+void OSGInvoker::updateBox(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) {
+}
+void OSGInvoker::processCapsule(const Arabica::DOM::Node<std::string>& element) {
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()];
+
+ float radius = 1;
+ float height = 1;
+ osg::Vec3 center(0,0,0);
+
+ if (HAS_ATTR(element, "radius")) radius = strTo<float>(ATTR(element, "radius"));
+ if (HAS_ATTR(element, "height")) height = strTo<float>(ATTR(element, "height"));
+
+ osg::ref_ptr<osg::Capsule> capsule = new osg::Capsule(center, radius, height);
+ osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(capsule);
+ osg::ref_ptr<osg::Geode> geode = new osg::Geode();
+ geode->addDrawable(drawable);
+
+ OSG_SET_COLOR;
+ OSG_SET_MATERIAL;
+
+ _nodes[element] = geode;
+ parent->asGroup()->addChild(geode);
+}
+void OSGInvoker::updateCapsule(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) {
+}
+
+void OSGInvoker::processCone(const Arabica::DOM::Node<std::string>& element) {
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()];
+
+ float radius = 1;
+ float height = 1;
+ osg::Vec3 center(0,0,0);
+
+ if (HAS_ATTR(element, "radius")) radius = strTo<float>(ATTR(element, "radius"));
+ if (HAS_ATTR(element, "height")) height = strTo<float>(ATTR(element, "height"));
+
+ osg::ref_ptr<osg::Cone> cone = new osg::Cone(center, radius, height);
+ osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(cone);
+ osg::ref_ptr<osg::Geode> geode = new osg::Geode();
+ geode->addDrawable(drawable);
+
+ OSG_SET_COLOR;
+ OSG_SET_MATERIAL;
+
+ _nodes[element] = geode;
+
+ parent->asGroup()->addChild(geode);
+
+}
+void OSGInvoker::updateCone(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) {
+}
+
+void OSGInvoker::processCylinder(const Arabica::DOM::Node<std::string>& element) {
+ assert(_nodes.find(element.getParentNode()) != _nodes.end());
+ osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()];
+
+ float radius = 1;
+ float height = 1;
+ osg::Vec3 center(0,0,0);
+
+ if (HAS_ATTR(element, "radius")) radius = strTo<float>(ATTR(element, "radius"));
+ if (HAS_ATTR(element, "height")) height = strTo<float>(ATTR(element, "height"));
+
+ osg::ref_ptr<osg::Cylinder> cylinder = new osg::Cylinder(center, radius, height);
+ osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(cylinder);
+ osg::ref_ptr<osg::Geode> geode = new osg::Geode();
+ geode->addDrawable(drawable);
+
+ OSG_SET_COLOR;
+ OSG_SET_MATERIAL;
+
+ _nodes[element] = geode;
+
+ parent->asGroup()->addChild(geode);
+
+}
+void OSGInvoker::updateCylinder(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) {
+}
+
+osg::Vec4 OSGInvoker::getColor(const Arabica::DOM::Node<std::string>& element, const std::string& attr, bool& valid) {
+ if (HAS_ATTR(element, attr)) {
+ std::string color = ATTR(element, attr);
+
+ // is this one of the predefined colors?
+ if (_colors.find(color) != _colors.end()) {
+ valid = true;
+ return _colors[color];
+ }
+
+ // otherwise try to parse as rgba values
+ int i;
+ osg::Vec4 colorVec = parseVec4(color, i);
+
+ if (i == 1) {
+ // only a single value was given, interpret as grey value
+ colorVec[1] = colorVec[2] = colorVec[0]; colorVec[3] = 1.0;
+ valid = true;
+ return colorVec;
+ }
+
+ if (i == 3) {
+ // three values were given, set opacity to max
+ colorVec[3] = 1.0;
+ valid = true;
+ return colorVec;
+ }
+ }
+
+ // return empty reference
+ valid = false;
+ return osg::Vec4();
+}
+
+osg::ref_ptr<osg::Material> OSGInvoker::getMaterial(const Arabica::DOM::Node<std::string>& element) {
+
+ osg::ref_ptr<osg::Material> nodeMat;
+
+ // material color
+ bool hasMatColor;
+ osg::Vec4 matColor = getColor(element, "materialcolor", hasMatColor);
+ if (hasMatColor) {
+ if (!nodeMat)
+ nodeMat = new osg::Material;
+ nodeMat->setDiffuse(osg::Material::FRONT, matColor);
+ nodeMat->setDiffuse(osg::Material::BACK, matColor);
+ }
+
+ // translucency
+ if (HAS_ATTR(element, "transparency")) {
+ std::string transparency = ATTR(element, "transparency");
+ float trans = strTo<float>(transparency);
+ if (!nodeMat)
+ nodeMat = new osg::Material;
+ nodeMat->setTransparency(osg::Material::FRONT, trans);
+ nodeMat->setTransparency(osg::Material::BACK, trans);
+ }
+
+ return nodeMat;
+}
+
+osg::Vec4 OSGInvoker::parseVec4(const std::string& coeffs, int& i) {
+
+ // otherwise try to parse as rgba values
+ std::string coeff;
+ std::stringstream coeffSS(coeffs);
+
+ osg::Vec4 vec;
+
+ i = 0;
+ while(std::getline(coeffSS, coeff, ',')) {
+ boost::trim(coeff);
+ if (coeff.length() == 0)
+ continue;
+ if (!isNumeric(coeff.c_str(), 10))
+ continue;
+
+ vec[i] = strTo<float>(coeff);
+ i++;
+ }
+ return vec;
+}
+
void OSGInvoker::processChildren(const std::set<std::string>& validChildren, const Arabica::DOM::Node<std::string>& element) {
Arabica::DOM::NodeList<std::string> childs = element.getChildNodes();
for (int i = 0; i < childs.getLength(); ++i) {
if (childs.item(i).getNodeType() != Arabica::DOM::Node_base::ELEMENT_NODE)
continue;
if (false) {
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "node") &&
- validChildren.find("node") != validChildren.end()) {
- processNode(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "translation") &&
- validChildren.find("translation") != validChildren.end()) {
- processTranslation(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "rotation") &&
- validChildren.find("rotation") != validChildren.end()) {
- processRotation(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "scale") &&
- validChildren.find("scale") != validChildren.end()) {
- processScale(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "viewport") &&
- validChildren.find("viewport") != validChildren.end()) {
- processViewport(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "camera") &&
- validChildren.find("camera") != validChildren.end()) {
- processCamera(childs.item(i));
- } else if (boost::iequals(LOCALNAME(childs.item(i)), "display") &&
- validChildren.find("display") != validChildren.end()) {
- processDisplay(childs.item(i));
+ OSG_TAG_HANDLE("node", processNode);
+ OSG_TAG_HANDLE("translation", processTranslation);
+ OSG_TAG_HANDLE("rotation", processRotation);
+ OSG_TAG_HANDLE("scale", processScale);
+ OSG_TAG_HANDLE("viewport", processViewport);
+ OSG_TAG_HANDLE("camera", processCamera);
+ OSG_TAG_HANDLE("display", processDisplay);
+ OSG_TAG_HANDLE("sphere", processSphere);
+ OSG_TAG_HANDLE("box", processBox);
+ OSG_TAG_HANDLE("cone", processCone);
+ OSG_TAG_HANDLE("capsule", processCapsule);
+ OSG_TAG_HANDLE("cylinder", processCylinder);
} else {
LOG(INFO) << "Unknown XML element " << TAGNAME(childs.item(i));
}
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
index bb46e79..512eecb 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
@@ -5,9 +5,12 @@
#include <DOM/Events/MutationEvent.hpp>
#include <DOM/Events/EventListener.hpp>
#include <DOM/Events/Event.hpp>
+
#include "CompositeDisplay.h"
#include <osg/MatrixTransform>
+#include <osg/Material>
#include <osgDB/ReadFile>
+
#include <set>
#ifdef BUILD_AS_PLUGINS
@@ -40,23 +43,39 @@ public:
protected:
void processDisplay(const Arabica::DOM::Node<std::string>& element);
- void updateDisplay(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void updateDisplay(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
void processViewport(const Arabica::DOM::Node<std::string>& element);
- void updateViewport(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void updateViewport(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
void processCamera(const Arabica::DOM::Node<std::string>& element);
- void updateCamera(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void updateCamera(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
void processTranslation(const Arabica::DOM::Node<std::string>& element);
- void updateTranslation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void updateTranslation(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
void processRotation(const Arabica::DOM::Node<std::string>& element);
- void updateRotation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void updateRotation(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
static osg::Matrix rotationFromElement(const Arabica::DOM::Node<std::string>& element);
void processScale(const Arabica::DOM::Node<std::string>& element);
- void updateScale(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void updateScale(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
+
void processNode(const Arabica::DOM::Node<std::string>& element);
- void updateNode(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
+ void updateNode(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
+
+ void processSphere(const Arabica::DOM::Node<std::string>& element);
+ void updateSphere(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
+ void processBox(const Arabica::DOM::Node<std::string>& element);
+ void updateBox(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
+ void processCapsule(const Arabica::DOM::Node<std::string>& element);
+ void updateCapsule(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
+ void processCone(const Arabica::DOM::Node<std::string>& element);
+ void updateCone(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
+ void processCylinder(const Arabica::DOM::Node<std::string>& element);
+ void updateCylinder(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event);
+
+ osg::Vec4 getColor(const Arabica::DOM::Node<std::string>& element, const std::string& attr, bool& valid);
+ osg::ref_ptr<osg::Material> getMaterial(const Arabica::DOM::Node<std::string>& element);
+ osg::Vec4 parseVec4(const std::string& coeffs, int& number);
void processChildren(const std::set<std::string>& validChildren, const Arabica::DOM::Node<std::string>& element);
@@ -90,9 +109,13 @@ protected:
std::map<Arabica::DOM::Node<std::string>, osgViewer::View*> _views;
typedef std::map<Arabica::DOM::Node<std::string>, osgViewer::View*> _views_t;
- std::map<Arabica::DOM::Node<std::string>, osg::Node*> _nodes;
- typedef std::map<Arabica::DOM::Node<std::string>, osg::Node*> _nodes_t;
+ std::map<Arabica::DOM::Node<std::string>, osg::ref_ptr<osg::Node> > _nodes;
+ typedef std::map<Arabica::DOM::Node<std::string>, osg::ref_ptr<osg::Node> > _nodes_t;
+ void setupColors();
+ std::map<std::string, osg::Vec4> _colors;
+ typedef std::map<std::string, osg::Vec4> _colors_t;
+
tthread::recursive_mutex _mutex;
};
diff --git a/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp b/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp.old
index 9a26960..9a26960 100644
--- a/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp
+++ b/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp.old
diff --git a/src/uscxml/plugins/invoker/miles/SpatialAudio.h b/src/uscxml/plugins/invoker/miles/SpatialAudio.h.old
index e7ab830..e7ab830 100644
--- a/src/uscxml/plugins/invoker/miles/SpatialAudio.h
+++ b/src/uscxml/plugins/invoker/miles/SpatialAudio.h.old
diff --git a/src/uscxml/plugins/ioprocessor/CMakeLists.txt b/src/uscxml/plugins/ioprocessor/CMakeLists.txt
index 8f124ed..bcab37c 100644
--- a/src/uscxml/plugins/ioprocessor/CMakeLists.txt
+++ b/src/uscxml/plugins/ioprocessor/CMakeLists.txt
@@ -3,8 +3,8 @@ file(GLOB_RECURSE SAMPLE_IOPROCESSOR
sample/*.cpp
sample/*.h
)
-source_group("IOProcessor\\sample" FILES ${SAMPLE_IOPROCESSOR})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${SAMPLE_IOPROCESSOR})
add_library(
ioprocessor_sample SHARED
${SAMPLE_IOPROCESSOR})
@@ -19,8 +19,8 @@ file(GLOB_RECURSE COMET_IOPROCESSOR
comet/*.cpp
comet/*.h
)
-source_group("IOProcessor\\comet" FILES ${COMET_IOPROCESSOR})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${COMET_IOPROCESSOR})
add_library(
ioprocessor_comet SHARED
${COMET_IOPROCESSOR})
@@ -38,8 +38,8 @@ file(GLOB_RECURSE BASICHTTP_IOPROCESSOR
basichttp/*.cpp
basichttp/*.h
)
-source_group("IOProcessor\\basichttp" FILES ${BASICHTTP_IOPROCESSOR})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${BASICHTTP_IOPROCESSOR})
add_library(
ioprocessor_basichttp SHARED
${BASICHTTP_IOPROCESSOR})
@@ -57,12 +57,13 @@ file(GLOB_RECURSE SCXML_IOPROCESSOR
scxml/*.cpp
scxml/*.h
)
-source_group("IOProcessor\\scxml" FILES ${SCXML_IOPROCESSOR})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${SCXML_IOPROCESSOR})
add_library(
ioprocessor_scxml SHARED
${SCXML_IOPROCESSOR})
- target_link_libraries(ioprocessor_scxml uscxml)
+ # scxml ioprocessor is a basichttp ioprocessor
+ target_link_libraries(ioprocessor_scxml ioprocessor_basichttp uscxml)
set_target_properties(ioprocessor_scxml PROPERTIES FOLDER "Plugin IOProcessor")
else()
list (APPEND USCXML_FILES ${SCXML_IOPROCESSOR})
@@ -71,7 +72,7 @@ endif()
# mmi ioprocessor
-if (PROTOBUF_FOUND)
+if (PROTOBUF_FOUND AND OFF)
if (NOT PROTOBUF_PROTOC_EXECUTABLE)
message(FATAL_ERROR "protoc binary required for serialization")
@@ -94,8 +95,8 @@ if (PROTOBUF_FOUND)
add_library(mmi_proto STATIC ${PROTO_SRCS})
set_target_properties(mmi_proto PROPERTIES FOLDER "Generated")
- source_group("IOProcessor\\modality" FILES ${MMI_IOPROCESSOR})
if (BUILD_AS_PLUGINS)
+ source_group("" FILES ${MMI_IOPROCESSOR})
add_library(
ioprocessor_mmi SHARED
${MMI_IOPROCESSOR})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4fba8a5..261817b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -64,13 +64,17 @@ if (NOT WIN32)
set_target_properties(test-arabica-parsing PROPERTIES FOLDER "Tests")
add_executable(test-stress src/test-stress.cpp)
- target_link_libraries(test-stress uscxml)
+ if (BUILD_AS_PLUGINS)
+ target_link_libraries(test-stress uscxml invoker_dirmon)
+ else()
+ target_link_libraries(test-stress uscxml)
+ endif()
add_test(test-stress ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-stress ${CMAKE_SOURCE_DIR}/test/samples/w3c)
set_target_properties(test-stress PROPERTIES FOLDER "Tests")
if (LIBPURPLE_FOUND)
add_executable(test-instant-messaging src/test-instant-messaging.cpp)
- target_link_libraries(test-instant-messaging uscxml)
+ target_link_libraries(test-instant-messaging uscxml ${LIBPURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${ICONV_LIBRARIES})
add_test(test-instant-messaging ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-instant-messaging)
set_target_properties(test-instant-messaging PROPERTIES FOLDER "Tests")
endif()