在 Linux 上静态编译 osgconv 并支持 obj 文件
Compiling osgconv on Linux statically with support for obj files
我已经在 Linux(32 位)设置 OFF DYNAMIC_OPENSCENEGRAPH 和 DYNAMIC_OPENTHREADS 标志上编译了 OpenSceneGraph 3.4.0,并在 CMake 上启用了应用程序和示例。
构建成功,我有静态库以及正常工作的示例 osgstaticviewer。
然后我尝试使用从 osgstaticviewer 复制的 CMakeLists.txt 仅使用静态库编译 osgconv 并修改添加 obj 支持和 osgconv 原始源文件。编译有效,生成的可执行文件有效,但我无法将 obj 文件转换为 osg 文件。特别是,如果我尝试命令:
./osgconv myModel.obj myModel.osg
我收到以下警告:
Warning: Could not find plugin to read objects from file "myModel.obj".
Error no data loaded.
静态链接 osg 插件的过程是什么?
下面用于编译osgconv的CMakeLists.txt:
#this file is automatically generated
SET(TARGET_ADDED_LIBRARIES osgdb_obj osgdb_ive osgdb_openflight osgdb_osg osgdb_rgb osgdb_osg )
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES}
osgdb_deprecated_osg osgdb_deprecated_osgparticle osgdb_deprecated_osganimation
osgdb_deprecated_osgfx osgdb_deprecated_osgsim osgdb_deprecated_osgtext
osgdb_deprecated_osgviewer osgdb_deprecated_osgshadow osgdb_deprecated_osgterrain
osgdb_deprecated_osgvolume osgdb_deprecated_osgwidget
)
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES}
osgdb_serializers_osg osgdb_serializers_osgparticle osgdb_serializers_osgtext
osgdb_serializers_osgterrain osgdb_serializers_osganimation osgdb_serializers_osgfx
osgdb_serializers_osgshadow osgdb_serializers_osgmanipulator osgdb_serializers_osgsim
osgdb_serializers_osgvolume
)
IF(FREETYPE_FOUND)
ADD_DEFINITIONS(-DUSE_FREETYPE)
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES} osgdb_freetype)
ENDIF(FREETYPE_FOUND)
SET(TARGET_SRC
OrientationConverter.cpp
osgconv.cpp
)
SET(TARGET_H
OrientationConverter.h
)
SETUP_APPLICATION(osgconv)
您需要修改 osgconv 的源代码才能让 USE_OSGPLUGIN 宏在此处看到对各种插件的绑定支持:
http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/examples/osgstaticviewer/osgstaticviewer.cpp#L40
我已经在 Linux(32 位)设置 OFF DYNAMIC_OPENSCENEGRAPH 和 DYNAMIC_OPENTHREADS 标志上编译了 OpenSceneGraph 3.4.0,并在 CMake 上启用了应用程序和示例。
构建成功,我有静态库以及正常工作的示例 osgstaticviewer。
然后我尝试使用从 osgstaticviewer 复制的 CMakeLists.txt 仅使用静态库编译 osgconv 并修改添加 obj 支持和 osgconv 原始源文件。编译有效,生成的可执行文件有效,但我无法将 obj 文件转换为 osg 文件。特别是,如果我尝试命令:
./osgconv myModel.obj myModel.osg
我收到以下警告:
Warning: Could not find plugin to read objects from file "myModel.obj".
Error no data loaded.
静态链接 osg 插件的过程是什么?
下面用于编译osgconv的CMakeLists.txt:
#this file is automatically generated
SET(TARGET_ADDED_LIBRARIES osgdb_obj osgdb_ive osgdb_openflight osgdb_osg osgdb_rgb osgdb_osg )
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES}
osgdb_deprecated_osg osgdb_deprecated_osgparticle osgdb_deprecated_osganimation
osgdb_deprecated_osgfx osgdb_deprecated_osgsim osgdb_deprecated_osgtext
osgdb_deprecated_osgviewer osgdb_deprecated_osgshadow osgdb_deprecated_osgterrain
osgdb_deprecated_osgvolume osgdb_deprecated_osgwidget
)
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES}
osgdb_serializers_osg osgdb_serializers_osgparticle osgdb_serializers_osgtext
osgdb_serializers_osgterrain osgdb_serializers_osganimation osgdb_serializers_osgfx
osgdb_serializers_osgshadow osgdb_serializers_osgmanipulator osgdb_serializers_osgsim
osgdb_serializers_osgvolume
)
IF(FREETYPE_FOUND)
ADD_DEFINITIONS(-DUSE_FREETYPE)
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES} osgdb_freetype)
ENDIF(FREETYPE_FOUND)
SET(TARGET_SRC
OrientationConverter.cpp
osgconv.cpp
)
SET(TARGET_H
OrientationConverter.h
)
SETUP_APPLICATION(osgconv)
您需要修改 osgconv 的源代码才能让 USE_OSGPLUGIN 宏在此处看到对各种插件的绑定支持: http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/examples/osgstaticviewer/osgstaticviewer.cpp#L40