Revision: 297
http://artoolkit.svn.sourceforge.net/artoolkit/?rev=297&view=rev
Author: retrakker
Date: 2008-08-22 02:22:09 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
added back OpenVRML support - added implmentation for OpenVRML 0.15.10 which is working on Ubuntu 8.04.1 with OpenVRML 0.15.10
Modified Paths:
--------------
branches/hartmut-pre-2_8/artoolkit/CMakeLists.txt
branches/hartmut-pre-2_8/artoolkit/examples/CMakeLists.txt
branches/hartmut-pre-2_8/artoolkit/lib/SRC/CMakeLists.txt
Added Paths:
-----------
branches/hartmut-pre-2_8/artoolkit/CMakeModules/FindOpenVRML.cmake
branches/hartmut-pre-2_8/artoolkit/examples/simpleVRML/CMakeLists.txt
branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/CMakeLists.txt
branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewerCapi_openvrml-0.15.10.cpp
branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.cpp
branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.h
Modified: branches/hartmut-pre-2_8/artoolkit/CMakeLists.txt
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/CMakeLists.txt 2008-08-21 21:51:32 UTC (rev 296)
+++ branches/hartmut-pre-2_8/artoolkit/CMakeLists.txt 2008-08-22 02:22:09 UTC (rev 297)
@@ -32,6 +32,8 @@
find_package(OpenGL)
find_package(GLUT)
find_package(GStreamer)
+find_package(OpenVRML)
+find_package(PkgConfig)
#
# Preset some of the output directories
Added: branches/hartmut-pre-2_8/artoolkit/CMakeModules/FindOpenVRML.cmake
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/CMakeModules/FindOpenVRML.cmake (rev 0)
+++ branches/hartmut-pre-2_8/artoolkit/CMakeModules/FindOpenVRML.cmake 2008-08-22 02:22:09 UTC (rev 297)
@@ -0,0 +1,113 @@
+# Locate openvml library
+# This module defines
+# OPENVRML_LIBRARY
+# OPENVRML_FOUND, if false, do not try to link to vrml
+# OPENVRML_INCLUDE_DIR, where to find the headers
+#
+# $OPENVRML_DIR is an environment variable that would
+# correspond to the ./configure --prefix=$OPENVRML_DIR
+#
+# Created by Robert Osfield.
+# Modified for the debug library by Jean-S?stien Guay.
+
+FIND_PATH(OPENVRML_INCLUDE_DIR openvrml/system.h
+ $ENV{OPENVRML_DIR}/include
+ $ENV{OPENVRML_DIR}
+ $ENV{OSGDIR}/include
+ $ENV{OSGDIR}
+ $ENV{OSG_ROOT}/include
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/include
+ /usr/include
+ /sw/include # Fink
+ /opt/local/include # DarwinPorts
+ /opt/csw/include # Blastwave
+ /opt/include
+ [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
+ /usr/freeware/include
+)
+
+FIND_LIBRARY(OPENVRML_openvrml_LIBRARY
+ NAMES openvrml
+ PATHS
+ $ENV{OPENVRML_DIR}/lib
+ $ENV{OPENVRML_DIR}
+ $ENV{OSGDIR}/lib
+ $ENV{OSGDIR}
+ $ENV{OSG_ROOT}/lib
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/lib
+ /usr/lib
+ /sw/lib
+ /opt/local/lib
+ /opt/csw/lib
+ /opt/lib
+ [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
+ /usr/freeware/lib64
+)
+
+FIND_LIBRARY(OPENVRML_gl_LIBRARY
+ NAMES openvrml-gl
+ PATHS
+ $ENV{OPENVRML_DIR}/lib
+ $ENV{OPENVRML_DIR}
+ $ENV{OSGDIR}/lib
+ $ENV{OSGDIR}
+ $ENV{OSG_ROOT}/lib
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/lib
+ /usr/lib
+ /sw/lib
+ /opt/local/lib
+ /opt/csw/lib
+ /opt/lib
+ [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
+ /usr/freeware/lib64
+)
+
+
+
+FIND_LIBRARY(OPENVRML_LIBRARY_DEBUG
+ NAMES openvrmld
+ PATHS
+ $ENV{OPENVRML_DIR}/lib
+ $ENV{OPENVRML_DIR}
+ $ENV{OSGDIR}/lib
+ $ENV{OSGDIR}
+ $ENV{OSG_ROOT}/lib
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/lib
+ /usr/lib
+ /sw/lib
+ /opt/local/lib
+ /opt/csw/lib
+ /opt/lib
+ [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
+ /usr/freeware/lib64
+)
+
+SET(OPENVRML_FOUND "NO")
+IF(OPENVRML_openvrml_LIBRARY AND OPENVRML_INCLUDE_DIR)
+ SET(OPENVRML_FOUND "YES")
+ENDIF(OPENVRML_openvrml_LIBRARY AND OPENVRML_INCLUDE_DIR)
+
+SET(OPENVRML_LIBRARIES ${OPENVRML_openvrml_LIBRARY} ${OPENVRML_gl_LIBRARY})
+
+#-------------- next part --------------
+IF (WIN32)
+ INCLUDE_DIRECTORIES( ${OPENVRML_INCLUDE_DIR} ${OPENVRML_INCLUDE_DIR}/openvrml ${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
+ SET(OPENVRML_ANTLR_LIBRARY antlr.lib)
+ SET(OPENVRML_ANTLR_LIBRARY_DEBUG antlrd.lib)
+ SET(OPENVRML_REGEX_LIBRARY regex.lib)
+ SET(OPENVRML_REGEX_LIBRARY_DEBUG regexd.lib)
+ SET(TARGET_LIBRARIES_VARS OPENVRML_ANTLR_LIBRARY OPENVRML_REGEX_LIBRARY OPENVRML_LIBRARY JPEG_LIBRARY PNG_LIBRARY ZLIB_LIBRARY)
+ SET(TARGET_EXTERNAL_LIBRARIES Ws2_32.lib)
+ELSE(WIN32)
+ INCLUDE_DIRECTORIES( ${OPENVRML_INCLUDE_DIR} ${OPENVRML_INCLUDE_DIR}/openvrml)
+ENDIF(WIN32)
+
+
Modified: branches/hartmut-pre-2_8/artoolkit/examples/CMakeLists.txt
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/examples/CMakeLists.txt 2008-08-21 21:51:32 UTC (rev 296)
+++ branches/hartmut-pre-2_8/artoolkit/examples/CMakeLists.txt 2008-08-22 02:22:09 UTC (rev 297)
@@ -13,3 +13,9 @@
add_subdirectory(simple2)
add_subdirectory(simpleLite)
add_subdirectory(twoView)
+
+
+if(OPENVRML_FOUND)
+ add_subdirectory(simpleVRML)
+endif(OPENVRML_FOUND)
+
Added: branches/hartmut-pre-2_8/artoolkit/examples/simpleVRML/CMakeLists.txt
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/examples/simpleVRML/CMakeLists.txt (rev 0)
+++ branches/hartmut-pre-2_8/artoolkit/examples/simpleVRML/CMakeLists.txt 2008-08-22 02:22:09 UTC (rev 297)
@@ -0,0 +1,53 @@
+
+set(EXE_NAME simpleVRML)
+
+set(SRCS
+ object.h
+ object.c
+ simpleVRML.c
+ )
+
+
+
+if(APPLE)
+
+ set(MACOSX_BUNDLE_BUNDLE_NAME ${EXE_NAME})
+ set(MACOSX_BUNDLE_BUNDLE_VERSION ${ARTOOLKIT_VERSION_SHORT})
+ set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${ARTOOLKIT_VERSION_FULL})
+ set(MACOSX_BUNDLE_LONG_VERSION_STRING "ARToolKit ${EXE_NAME} Version ${ARTOOLKIT_VERSION_FULL}")
+ set(MACOSX_BUNDLE_ICON_FILE ARToolKit.icns)
+ set(MACOSX_BUNDLE_COPYRIGHT "(c) 2008 Human Interface Technology Laboratory New Zealand")
+
+ set_source_files_properties(
+ ${CMAKE_SOURCE_DIR}/share/ARToolKit.icns
+ PROPERTIES
+ MACOSX_PACKAGE_LOCATION "Resources"
+ )
+ set_source_files_properties(
+ ${ARTOOLKIT_FILES_DATA}
+ PROPERTIES
+ HEADER_FILE_ONLY TRUE
+ MACOSX_PACKAGE_LOCATION "Resources/Data"
+ )
+ set_source_files_properties(
+ ${ARTOOLKIT_FILES_DATA_MULTI}
+ PROPERTIES
+ HEADER_FILE_ONLY TRUE
+ MACOSX_PACKAGE_LOCATION "Resources/Data/multi"
+ )
+
+ add_executable(${EXE_NAME} MACOSX_BUNDLE
+ ${SRCS} ${CMAKE_SOURCE_DIR}/share/ARToolKit.icns
+ )
+
+else(APPLE)
+ add_executable(${EXE_NAME} ${SRCS})
+endif(APPLE)
+
+
+target_link_libraries(${EXE_NAME}
+ AR ARgsub ARgsub_lite ARgsubUtil ARvrml ARvideo
+ ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}
+ ${OPENVRML_LIBRARIES})
+
+
Added: branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/CMakeLists.txt
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/CMakeLists.txt (rev 0)
+++ branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/CMakeLists.txt 2008-08-22 02:22:09 UTC (rev 297)
@@ -0,0 +1,64 @@
+#
+# CMake build system for ARToolKit
+#
+# (c) Copyrights 2007-2008 Hartmut Seichter, HIT Lab NZ
+#
+
+set(lib_name ARvrml)
+
+set(OPENVRML_API)
+
+#
+# We have to go through some convoluted hops to
+# determine the correct version.
+# Assumption is: nothing new than 0.16.x
+#
+if(OPENVRML_FOUND AND PKG_CONFIG_FOUND)
+ pkg_search_module(LIBOPENVRML openvrml)
+
+ if (${LIBOPENVRML_VERSION} MATCHES "0.14.")
+ set(OPENVRML_API "_openvrml-0.14.3")
+ endif(${LIBOPENVRML_VERSION} MATCHES "0.14.")
+
+ if (${LIBOPENVRML_VERSION} MATCHES "0.15.")
+ set(OPENVRML_API "_openvrml-0.15.10")
+ endif(${LIBOPENVRML_VERSION} MATCHES "0.15.")
+
+ if (${LIBOPENVRML_VERSION} MATCHES "0.16.")
+ set(OPENVRML_API "")
+ endif(${LIBOPENVRML_VERSION} MATCHES "0.16.")
+
+endif(OPENVRML_FOUND AND PKG_CONFIG_FOUND)
+
+#
+# If we have no pkg-config we only assume 0.16 is supported
+#
+
+set(srcs_openvrml
+ arViewerCapi${OPENVRML_API}.cpp
+ arViewer${OPENVRML_API}.cpp
+ arViewer${OPENVRML_API}.h
+ )
+
+set(srcs_common
+ arViewer.h
+ )
+
+set(hdrs_public
+ ${CMAKE_SOURCE_DIR}/include/AR/arvrml.h
+ )
+
+include_directories(${CMAKE_SOURCE_DIR}/include ${GLUT_INCLUDE_DIR} ${OPENVRML_INCLUDE_DIR})
+
+add_library(${lib_name} ${hdrs_public} ${srcs_openvrml})
+
+target_link_libraries(${lib_name} AR ${OPENGL_LIBRARY} ${GLUT_LIBRARIES})
+
+artoolkit_install(${lib_name})
+
+install(FILES ${hdrs_public}
+ DESTINATION include/AR
+)
+
+
+
Added: branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewerCapi_openvrml-0.15.10.cpp
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewerCapi_openvrml-0.15.10.cpp (rev 0)
+++ branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewerCapi_openvrml-0.15.10.cpp 2008-08-22 02:22:09 UTC (rev 297)
@@ -0,0 +1,193 @@
+/*
+ *
+ * This file is part of ARToolKit.
+ *
+ * ARToolKit is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ARToolKit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with ARToolKit; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <AR/arvrml.h>
+#include "arViewer_openvrml-0.15.10.h"
+#include <iostream>
+#include <vector>
+#include <string>
+#ifdef __APPLE__
+# include <GLUT/glut.h>
+#else
+# include <GL/glut.h>
+#endif
+#include <stdio.h>
+#include <string.h>
+
+//extern "C" {
+
+//}
+
+
+#define AR_VRML_MAX 100
+
+static arVrmlViewer *viewer[AR_VRML_MAX];
+static int init = 1;
+static int vrID = -1;
+
+static char *get_buff( char *buf, int n, FILE *fp );
+
+
+int arVrmlLoadFile(const char *file)
+{
+
+ FILE *fp;
+ openvrml::browser * myBrowser = NULL;
+ char buf[256], buf1[256];
+ char buf2[256];
+ int id;
+ int i;
+
+ if( init ) {
+ for( i = 0; i < AR_VRML_MAX; i++ ) viewer[i] = NULL;
+ init = 0;
+ }
+ for( i = 0; i < AR_VRML_MAX; i++ ) {
+ if( viewer[i] == NULL ) break;
+ }
+ if( i == AR_VRML_MAX ) return -1;
+ id = i;
+
+ if( (fp=fopen(file, "r")) == NULL ) return -1;
+
+ get_buff(buf, 256, fp);
+ if( sscanf(buf, "%s", buf1) != 1 ) {fclose(fp); return -1;}
+ for( i = 0; file[i] != '\0'; i++ ) buf2[i] = file[i];
+ for( ; i >= 0; i-- ) {
+ if( buf2[i] == '/' ) break;
+ }
+ buf2[i+1] = '\0';
+ sprintf(buf, "%s%s", buf2, buf1);
+
+ myBrowser = new arVrmlBrowser;
+ if (!myBrowser) {
+ fclose(fp);
+ return -1;
+ }
+
+ viewer[id] = new arVrmlViewer();
+ if (!viewer[id]) {
+ delete myBrowser;
+ fclose(fp);
+ return -1;
+ }
+ strcpy(viewer[id]->filename, buf); // Save filename in viewer.
+ myBrowser->viewer(viewer[id]);
+
+ std::vector<std::string> uri(1, buf);
+ std::vector<std::string> parameter;
+ myBrowser->load_url(uri, parameter);
+
+
+ get_buff(buf, 256, fp);
+ if( sscanf(buf, "%lf %lf %lf", &viewer[id]->translation[0],
+ &viewer[id]->translation[1], &viewer[id]->translation[2]) != 3 ) {
+ delete viewer[id];
+ viewer[id] = NULL;
+ fclose(fp);
+ return -1;
+ }
+
+ get_buff(buf, 256, fp);
+ if( sscanf(buf, "%lf %lf %lf %lf", &viewer[id]->rotation[0],
+ &viewer[id]->rotation[1], &viewer[id]->rotation[2], &viewer[id]->rotation[3]) != 4 ) {
+ delete viewer[id];
+ viewer[id] = NULL;
+ fclose(fp);
+ return -1;
+ }
+
+ get_buff(buf, 256, fp);
+ if( sscanf(buf, "%lf %lf %lf", &viewer[id]->scale[0], &viewer[id]->scale[1],
+ &viewer[id]->scale[2]) != 3 ) {
+ delete viewer[id];
+ viewer[id] = NULL;
+ fclose(fp);
+ return -1;
+ }
+ fclose(fp);
+
+ return id;
+}
+
+int arVrmlFree( int id )
+{
+ if( viewer[id] == NULL ) return -1;
+
+ delete viewer[id];
+ viewer[id] = NULL;
+
+ if( vrID == id ) {
+ vrID = -1;
+ }
+
+ return 0;
+}
+
+int arVrmlTimerUpdate()
+{
+ int i;
+
+ for( i = 0; i < AR_VRML_MAX; i++ ) {
+ if( viewer[i] == NULL ) continue;
+ viewer[i]->timerUpdate();
+ }
+ return 0;
+}
+
+int arVrmlDraw( int id )
+{
+ if( viewer[id] == NULL ) return -1;
+ viewer[id]->redraw();
+ return 0;
+}
+
+int arVrmlSetInternalLight( int flag )
+{
+ int i;
+
+ if( flag ) {
+ for( i = 0; i < AR_VRML_MAX; i++ ) {
+ if( viewer[i] == NULL ) continue;
+ viewer[i]->setInternalLight(true);
+ }
+ }
+ else {
+ for( i = 0; i < AR_VRML_MAX; i++ ) {
+ if( viewer[i] == NULL ) continue;
+ viewer[i]->setInternalLight(false);
+ }
+ }
+
+ return 0;
+}
+
+static char *get_buff( char *buf, int n, FILE *fp )
+{
+ char *ret, buf1[256];
+
+ for(;;) {
+ ret = fgets( buf, n, fp );
+ if( ret == NULL ) return(NULL);
+ if( sscanf(buf, "%s", buf1) != 1 ) continue;
+
+ if( buf1[0] != '#' ) return(ret);
+ }
+}
Property changes on: branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewerCapi_openvrml-0.15.10.cpp
___________________________________________________________________
Added: svn:executable
+ *
Added: branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.cpp
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.cpp (rev 0)
+++ branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.cpp 2008-08-22 02:22:09 UTC (rev 297)
@@ -0,0 +1,330 @@
+/*
+ Original version for VRML97-0.8.7 by Hirokazu Kato.
+
+ Updated for OpenVRML-0.14.3 by Raphael Grasset.
+ -remove vrmlScene since we use reference now.
+ -remove culling pb
+
+ Updated for OpenVRML-0.16.1 by Philip Lamb. 2006-11-15.
+ - add arVrmlBrowser class and Boost dependencies.
+*/
+/*
+ *
+ * This file is part of ARToolKit.
+ *
+ * ARToolKit is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ARToolKit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with ARToolKit; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <iostream>
+#include <math.h>
+#ifdef __APPLE__
+# include <GLUT/glut.h>
+#else
+# include <GL/glut.h>
+#endif
+#include "arViewer_openvrml-0.15.10.h"
+
+using namespace openvrml;
+
+arVrmlBrowser::arVrmlBrowser(): openvrml::browser(std::cout, std::cerr)
+{
+}
+
+/*
+std::auto_ptr<openvrml::resource_istream>
+arVrmlBrowser::do_get_resource(const std::string & uri)
+{
+ using std::auto_ptr;
+ using std::invalid_argument;
+ using std::string;
+ using openvrml::resource_istream;
+
+ class file_resource_istream : public resource_istream {
+ std::string url_;
+ std::filebuf buf_;
+
+ public:
+ explicit file_resource_istream(const std::string & path): resource_istream(&this->buf_)
+ {
+ if (!this->buf_.open(path.c_str(), ios_base::in | ios_base::binary)) {
+ this->setstate(ios_base::badbit);
+ }
+ }
+
+ void url(const std::string & str) throw (std::bad_alloc)
+ {
+ this->url_ = str;
+ }
+
+ private:
+ virtual const std::string do_url() const throw ()
+ {
+ return this->url_;
+ }
+
+ virtual const std::string do_type() const throw ()
+ {
+ //
+ // A real application should use OS facilities for this. This
+ // is a crude hack because sdl-viewer uses std::filebuf in
+ // order to remain simple and portable.
+ //
+ using std::find;
+ using std::string;
+ using boost::algorithm::iequals;
+ using boost::next;
+ string media_type = "application/octet-stream";
+ const string::const_reverse_iterator dot_pos =
+ find(this->url_.rbegin(), this->url_.rend(), '.');
+ if (dot_pos == this->url_.rend()
+ || next(dot_pos.base()) == this->url_.end()) {
+ return media_type;
+ }
+ const string::const_iterator hash_pos =
+ find(next(dot_pos.base()), this->url_.end(), '#');
+ const string ext(dot_pos.base(), hash_pos);
+ if (iequals(ext, "wrl")) {
+ media_type = openvrml::vrml_media_type;
+ } else if (iequals(ext, "x3dv")) {
+ media_type = openvrml::x3d_vrml_media_type;
+ } else if (iequals(ext, "png")) {
+ media_type = "image/png";
+ } else if (iequals(ext, "jpg") || iequals(ext, "jpeg")) {
+ media_type = "image/jpeg";
+ }
+ return media_type;
+ }
+
+ virtual bool do_data_available() const throw ()
+ {
+ return !!(*this);
+ }
+ }; // class file_resource_istream
+
+ const string scheme = uri.substr(0, uri.find_first_of(':'));
+ if (scheme != "file") {
+ throw invalid_argument('\"' + scheme + "\" URI scheme not supported");
+ }
+ //
+ // file://
+ // ^
+ // 01234567
+ static const string::size_type authority_start_index = 7;
+
+ //
+ // On Windows we want to start at the drive letter, which is after the
+ // first slash in the path.
+ //
+ // We ignore the content of the authority; a smarter implementation
+ // should confirm that it is localhost, the machine name, or zero
+ // length.
+ //
+ string::size_type path_start_index =
+# ifdef _WIN32
+ uri.find_first_of('/', authority_start_index) + 1;
+# else
+ uri.find_first_of('/', authority_start_index);
+# endif
+ string path = uri.substr(path_start_index);
+
+ auto_ptr<resource_istream> in(new file_resource_istream(path));
+ static_cast<file_resource_istream *>(in.get())->url(uri);
+
+ return in;
+}
+*/
+
+arVrmlViewer::arVrmlViewer()
+{
+ internal_light = true;
+
+ translation[0] = 0.0;
+ translation[1] = 0.0;
+ translation[2] = 0.0;
+
+ rotation[0] = 0.0;
+ rotation[1] = 0.0;
+ rotation[2] = 0.0;
+ rotation[3] = 0.0;
+
+ scale[0] = 1.0;
+ scale[1] = 1.0;
+ scale[2] = 1.0;
+}
+
+arVrmlViewer::~arVrmlViewer() throw()
+{
+
+}
+
+void arVrmlViewer::timerUpdate()
+{
+ this->update(0.0);
+}
+
+
+
+void arVrmlViewer::setInternalLight(bool flag)
+{
+ internal_light = flag;
+}
+
+void arVrmlViewer::redraw()
+{
+ //double start = browser::current_time();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glTranslated( translation[0], translation[1], translation[2] );
+ if (rotation[0] != 0.0) {
+ glRotated(rotation[0], rotation[1], rotation[2], rotation[3]);
+ }
+ glScaled(scale[0], scale[1], scale[2]);
+
+#if USE_STENCIL_SHAPE
+ glEnable(GL_STENCIL_TEST);
+ glStencilFunc(GL_ALWAYS, 1, 1);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+#endif
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LEQUAL);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_FOG); // this is a global attribute
+ //glDisable(GL_TEXTURE_2D);
+ glEnable(GL_CULL_FACE);
+ glFrontFace(GL_CCW);
+ glCullFace(GL_BACK);
+
+ if (internal_light) {
+ if (lit) glEnable(GL_LIGHTING);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
+ glEnable(GL_NORMALIZE);
+ glDisable(GL_COLOR_MATERIAL);
+ glDisable(GL_BLEND);
+ glShadeModel(GL_SMOOTH);
+
+ for (int i = 0; i < max_lights; ++i) {
+ light_info_[i].type = light_unused;
+ GLenum light = (GLenum) (GL_LIGHT0 + i);
+ glDisable(light);
+ }
+ }
+
+ objects = 0;
+ nested_objects = 0;
+ sensitive = 0;
+
+ if (browser()) browser()->render();
+
+ if (internal_light) {
+ if (lit) glDisable(GL_LIGHTING);
+ }
+ glDisable(GL_BLEND);
+ glDisable(GL_CULL_FACE);
+ //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+}
+
+void arVrmlViewer::post_redraw()
+{
+
+}
+void arVrmlViewer::set_cursor(cursor_style c)
+{
+
+}
+
+void arVrmlViewer::swap_buffers()
+{
+
+}
+
+void arVrmlViewer::set_timer(double t)
+{
+
+}
+
+
+void arVrmlViewer::set_viewpoint(const openvrml::vec3f & position,
+ const openvrml::rotation & orientation,
+ float fieldOfView,
+ float avatarSize,
+ float visibilityLimit)
+{
+
+}
+
+viewer::object_t arVrmlViewer::insert_background(const std::vector<float> & groundAngle,
+ const std::vector<color> & groundColor,
+ const std::vector<float> & skyAngle,
+ const std::vector<color> & skyColor,
+ const image & front,
+ const image & back,
+ const image & left,
+ const image & right,
+ const image & top,
+ const image & bottom)
+{
+ return 0;
+}
+
+viewer::object_t arVrmlViewer::insert_dir_light(float ambientIntensity,
+ float intensity,
+ const openvrml::color & color,
+ const openvrml::vec3f & direction)
+{
+ if (internal_light) return gl::viewer::insert_dir_light(ambientIntensity, intensity, color, direction);
+ return 0;
+}
+
+viewer::object_t arVrmlViewer::insert_point_light(float ambientIntensity,
+ const openvrml::vec3f & attenuation,
+ const openvrml::color & color,
+ float intensity,
+ const openvrml::vec3f & location,
+ float radius)
+{
+ if (internal_light) return gl::viewer::insert_point_light(ambientIntensity, attenuation, color, intensity, location, radius);
+
+ return 0;
+}
+
+
+viewer::object_t arVrmlViewer::insert_spot_light(float ambientIntensity,
+ const openvrml::vec3f & attenuation,
+ float beamWidth,
+ const openvrml::color & color,
+ float cutOffAngle,
+ const openvrml::vec3f & direction,
+ float intensity,
+ const openvrml::vec3f & location,
+ float radius)
+{
+ if (internal_light) return gl::viewer::insert_spot_light(ambientIntensity, attenuation, beamWidth, color,cutOffAngle, direction, intensity, location, radius);
+ return 0;
+}
+
+ bounding_volume::intersection
+arVrmlViewer::intersect_view_volume(const bounding_volume & bvolume) const
+{
+ // if( d_cull ) {
+ //return openvrml::viewer::intersect_view_volume(bvolume);
+ // }
+ // else {
+ return bounding_volume::inside;
+ //}
+}
Property changes on: branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.cpp
___________________________________________________________________
Added: svn:executable
+ *
Added: branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.h
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.h (rev 0)
+++ branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.h 2008-08-22 02:22:09 UTC (rev 297)
@@ -0,0 +1,112 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*-
+/*
+ *
+ * This file is part of ARToolKit.
+ *
+ * ARToolKit is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ARToolKit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with ARToolKit; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef AR_VRMLINT_H
+#define AR_VRMLINT_H
+
+#include <iostream>
+#include <fstream>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/utility.hpp>
+#include <openvrml/browser.h>
+#include <openvrml/gl/viewer.h>
+#include <openvrml/bounding_volume.h>
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+class arVrmlBrowser : public openvrml::browser {
+public:
+ arVrmlBrowser();
+
+private:
+ /*
+ virtual std::auto_ptr<openvrml::resource_istream>
+ do_get_resource(const std::string & uri);
+ */
+};
+
+class arVrmlViewer : public openvrml::gl::viewer {
+
+public:
+ explicit arVrmlViewer();
+ virtual ~arVrmlViewer() throw ();
+
+ char filename[512];
+ double translation[3];
+ double rotation[4];
+ double scale[3];
+ bool internal_light;
+
+ void timerUpdate();
+ void redraw();
+ void setInternalLight( bool f );
+
+protected:
+ virtual void post_redraw();
+ virtual void set_cursor(openvrml::gl::viewer::cursor_style c);
+ virtual void swap_buffers();
+ virtual void set_timer(double);
+
+
+ virtual void set_viewpoint(const openvrml::vec3f & position,
+ const openvrml::rotation & orientation,
+ float fieldOfView,
+ float avatarSize,
+ float visibilityLimit);
+
+ virtual viewer::object_t insert_background(const std::vector<float> & groundAngle,
+ const std::vector<openvrml::color> & groundColor,
+ const std::vector<float> & skyAngle,
+ const std::vector<openvrml::color> & skyColor,
+ const openvrml::image & front,
+ const openvrml::image & back,
+ const openvrml::image & left,
+ const openvrml::image & right,
+ const openvrml::image & top,
+ const openvrml::image & bottom);
+
+ virtual viewer::object_t insert_dir_light(float ambientIntensity,
+ float intensity,
+ const openvrml::color & color,
+ const openvrml::vec3f & direction);
+
+ virtual viewer::object_t insert_point_light(float ambientIntensity,
+ const openvrml::vec3f & attenuation,
+ const openvrml::color & color,
+ float intensity,
+ const openvrml::vec3f & location,
+ float radius);
+
+ virtual viewer::object_t insert_spot_light(float ambientIntensity,
+ const openvrml::vec3f & attenuation,
+ float beamWidth,
+ const openvrml::color & color,
+ float cutOffAngle,
+ const openvrml::vec3f & direction,
+ float intensity,
+ const openvrml::vec3f & location,
+ float radius);
+ virtual openvrml::bounding_volume::intersection
+ intersect_view_volume(const openvrml::bounding_volume & bvolume) const;
+};
+
+#endif
Property changes on: branches/hartmut-pre-2_8/artoolkit/lib/SRC/ARvrml/arViewer_openvrml-0.15.10.h
___________________________________________________________________
Added: svn:executable
+ *
Modified: branches/hartmut-pre-2_8/artoolkit/lib/SRC/CMakeLists.txt
===================================================================
--- branches/hartmut-pre-2_8/artoolkit/lib/SRC/CMakeLists.txt 2008-08-21 21:51:32 UTC (rev 296)
+++ branches/hartmut-pre-2_8/artoolkit/lib/SRC/CMakeLists.txt 2008-08-22 02:22:09 UTC (rev 297)
@@ -46,3 +46,13 @@
add_subdirectory(VideoGStreamer)
endif(USE_GSTREAMER)
endif(UNIX)
+
+find_package(OpenVRML)
+if(OPENVRML_FOUND)
+ option(ARTOOLKIT_USE_OPENVRML "Create VRML based libraries and examples" ON)
+ if(ARTOOLKIT_USE_OPENVRML)
+ add_subdirectory(ARvrml)
+ endif(ARTOOLKIT_USE_OPENVRML)
+endif(OPENVRML_FOUND)
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|