From Stephan Huber and Mathieu Marache, "attached you'll find framework support for os x via cmake. Please credit
Mathieu Marache, he added the last missing piece to this puzzle. I think it is safe to commit these changes to trunk, as the traditional way via dylibs should work as before. Here's some more info how to get frameworks: With these modifications it is possible to compile frameworks on OS X, when you set the Cmake-option OSG_COMPILE_FRAMEWORKS to true. If you want to embed the frameworks in your app-bundle make sure to set OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR accordingly. You'll have to build the install-target of the generated xcode-projects as this sets the install_name_dirs of the frameworks and plugins."
This commit is contained in:
parent
a8332528f4
commit
c091b5c2d1
@ -144,6 +144,8 @@ FIND_PACKAGE(OpenGL)
|
||||
IF(APPLE)
|
||||
FIND_LIBRARY(CARBON_LIBRARY Carbon)
|
||||
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
|
||||
OPTION(OSG_COMPILE_FRAMEWORKS "compile frameworks instead of dylibs (experimental)" OFF)
|
||||
SET(OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR "@executable_path/../Frameworks" CACHE STRING "install name dir for compiled frameworks")
|
||||
ENDIF()
|
||||
|
||||
IF(UNIX)
|
||||
|
@ -29,12 +29,25 @@ INSTALL(
|
||||
TARGETS ${LIB_NAME}
|
||||
RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT libopenscenegraph
|
||||
LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT libopenscenegraph
|
||||
ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR} COMPONENT libopenscenegraph-dev
|
||||
ARCHIVE DESTINATION ${INSTALL_ARCHIVEDIR} COMPONENT libopenscenegraph-dev
|
||||
FRAMEWORK DESTINATION /Library/Frameworks
|
||||
)
|
||||
|
||||
# FIXME: Do not run for OS X framework
|
||||
INSTALL(
|
||||
FILES ${LIB_PUBLIC_HEADERS}
|
||||
DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}
|
||||
COMPONENT libopenscenegraph-dev
|
||||
)
|
||||
IF(NOT OSG_COMPILE_FRAMEWORKS)
|
||||
INSTALL (
|
||||
FILES ${LIB_PUBLIC_HEADERS}
|
||||
DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}
|
||||
COMPONENT libopenscenegraph-dev
|
||||
)
|
||||
ELSE()
|
||||
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
SET(CMAKE_INSTALL_RPATH "${OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR}")
|
||||
|
||||
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${OPENSCENEGRAPH_VERSION}
|
||||
PUBLIC_HEADER "${LIB_PUBLIC_HEADERS}"
|
||||
INSTALL_NAME_DIR "${OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR}"
|
||||
)
|
||||
# MESSAGE("${OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR}")
|
||||
ENDIF()
|
||||
|
@ -127,10 +127,20 @@ INSTALL(
|
||||
LIBRARY DESTINATION lib${LIB_POSTFIX} COMPONENT libopenthreads
|
||||
RUNTIME DESTINATION bin COMPONENT libopenthreads
|
||||
)
|
||||
INSTALL(
|
||||
FILES ${OpenThreads_PUBLIC_HEADERS}
|
||||
DESTINATION include/OpenThreads
|
||||
COMPONENT libopenthreads-dev
|
||||
|
||||
IF(!OSG_COMPILE_FRAMEWORKS)
|
||||
INSTALL(
|
||||
FILES ${OpenThreads_PUBLIC_HEADERS}
|
||||
DESTINATION include/OpenThreads
|
||||
COMPONENT libopenthreads-dev
|
||||
)
|
||||
|
||||
ELSE()
|
||||
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
FRAMEWORK_VERSION ${OPENTHREADS_VERSION}
|
||||
PUBLIC_HEADER "${OpenThreads_PUBLIC_HEADERS}"
|
||||
INSTALL_NAME_DIR "${OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR}"
|
||||
)
|
||||
ENDIF()
|
||||
#commented out# INCLUDE(ModuleInstall OPTIONAL)
|
||||
|
@ -97,6 +97,9 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
|
||||
{
|
||||
SERIALIZER();
|
||||
|
||||
std::istringstream iss(options->getOptionString());
|
||||
std::string opt;
|
||||
|
||||
bool bOwnDAE = false;
|
||||
DAE* pDAE = NULL;
|
||||
|
||||
@ -104,30 +107,48 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
|
||||
if( ! acceptsExtension(ext) ) return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
// Process options
|
||||
bool usePolygon(false); // Use plugin option "polygon" to enable
|
||||
bool GoogleMode(false); // Use plugin option "GoogleMode" to enable
|
||||
bool writeExtras(true); // Use plugin option "NoExtras" to disable
|
||||
bool usePolygon(false); // Use plugin option "polygon" to enable
|
||||
bool googleMode(false); // Use plugin option "GoogleMode" to enable
|
||||
bool writeExtras(true); // Use plugin option "NoExtras" to disable
|
||||
bool earthTex(false); // Use plugin option "DaeEarthTex" to enable
|
||||
bool zUpAxis(false); // Use plugin option "ZUpAxis" to enable
|
||||
bool forceTexture(false); // Use plugin option "ForceTexture" to enable
|
||||
if( options )
|
||||
{
|
||||
pDAE = (DAE*)options->getPluginData("DAE");
|
||||
std::istringstream iss( options->getOptionString() );
|
||||
// Sukender's note: I don't know why DAE seems to accept comma-sparated options instead of space-separated options as other ReaderWriters. However, to avoid breaking compatibility, here's a workaround:
|
||||
std::string optString( options->getOptionString() );
|
||||
for(std::string::iterator it=optString.begin(); it!=optString.end(); ++it) {
|
||||
if (*it == ' ') *it = ',';
|
||||
}
|
||||
std::istringstream iss( optString );
|
||||
std::string opt;
|
||||
|
||||
bool unrecognizedOption = false;
|
||||
//while (iss >> opt)
|
||||
while( std::getline( iss, opt, ',' ) )
|
||||
{
|
||||
if( opt == "polygon") usePolygon = true;
|
||||
else if (opt == "GoogleMode") GoogleMode = true;
|
||||
else if (opt == "GoogleMode") googleMode = true;
|
||||
else if (opt == "NoExtras") writeExtras = false;
|
||||
else if (opt == "DaeEarthTex") earthTex = true;
|
||||
else if (opt == "ZUpAxis") zUpAxis = true;
|
||||
else if (opt == "ForceTexture") forceTexture = true;
|
||||
else
|
||||
{
|
||||
osg::notify(osg::WARN)
|
||||
<< std::endl << "COLLADA dae plugin: unrecognized option \"" << opt << std::endl
|
||||
<< "comma-delimited options:" << std::endl << std::endl
|
||||
<< "\tpolygon = use polygons instead of polylists for element" << std::endl
|
||||
<< "\tGoogleMode = write files suitable for use by Google products" << std::endl
|
||||
<< "example: osgviewer -O polygon bar.dae" << std::endl << std::endl;
|
||||
osg::notify(osg::NOTICE)
|
||||
<< std::endl << "COLLADA dae plugin: unrecognized option \"" << opt << std::endl;
|
||||
unrecognizedOption = true;
|
||||
}
|
||||
}
|
||||
if (unrecognizedOption) {
|
||||
// TODO Remove this or make use of supportedOptions()
|
||||
osg::notify(osg::NOTICE)
|
||||
<< "comma-delimited options:" << std::endl << std::endl
|
||||
<< "\tpolygon = use polygons instead of polylists for element" << std::endl
|
||||
<< "\tGoogleMode = write files suitable for use by Google products" << std::endl
|
||||
<< "example: osgviewer -O polygon bar.dae" << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == pDAE)
|
||||
@ -141,7 +162,7 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
|
||||
|
||||
osg::NodeVisitor::TraversalMode traversalMode = writeExtras ? osg::NodeVisitor::TRAVERSE_ALL_CHILDREN : osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN;
|
||||
|
||||
osgDAE::daeWriter daeWriter(pDAE, fileURI, usePolygon, GoogleMode, traversalMode, writeExtras);
|
||||
osgDAE::daeWriter daeWriter(pDAE, fileURI, usePolygon, googleMode, traversalMode, writeExtras, earthTex, zUpAxis, forceTexture);
|
||||
daeWriter.setRootNode( node );
|
||||
const_cast<osg::Node*>(&node)->accept( daeWriter );
|
||||
|
||||
|
@ -17,6 +17,15 @@ public:
|
||||
supportsExtension("dae","COLLADA 1.4.x DAE format");
|
||||
// Collada zip archive (contains one or more dae files and a manifest.xml)
|
||||
supportsExtension("zae","COLLADA 1.4.x ZAE format");
|
||||
|
||||
supportsOption("polygon", "Use polygons instead of polylists for element (Write option)");
|
||||
supportsOption("GoogleMode", "Write files suitable for use by Google products");
|
||||
supportsOption("NoExtras", "Write option (Undocumented)");
|
||||
supportsOption("DaeEarthTex", "DAE settings for writing earth textures");
|
||||
supportsOption("ZUpAxis", "indicates if the up axis is on Z axis");
|
||||
supportsOption("ForceTexture", "force the use an image for a texture, even if the file is not found");
|
||||
|
||||
supportsOption("StrictTransparency", "Read option (Undocumented)");
|
||||
}
|
||||
|
||||
const char* className() const { return "COLLADA 1.4.x DAE reader/writer"; }
|
||||
|
@ -100,140 +100,148 @@ void daeWriter::processMaterial( osg::StateSet *ss, domBind_material *pDomBindMa
|
||||
|
||||
domImage::domInit_from *imgif = daeSafeCast< domImage::domInit_from >( img->add( COLLADA_ELEMENT_INIT_FROM ) );
|
||||
std::string fileURI = ReaderWriterDAE::ConvertFilePathToColladaCompatibleURI(osgDB::findDataFile(osgimg->getFileName()));
|
||||
if (fileURI=="" && m_ForceTexture)
|
||||
{
|
||||
fileURI = osgimg->getFileName();
|
||||
}
|
||||
|
||||
daeURI dd(*dae, fileURI);
|
||||
imgif->setValue( dd );
|
||||
// The document URI should contain the canonical path it was created with
|
||||
imgif->getValue().makeRelativeTo(doc->getDocumentURI());
|
||||
|
||||
|
||||
#ifndef EARTH_TEX
|
||||
domCommon_newparam_type *np = daeSafeCast< domCommon_newparam_type >( pc->add(COLLADA_ELEMENT_NEWPARAM) );
|
||||
std::string surfName = efName + "-surface";
|
||||
np->setSid( surfName.c_str() );
|
||||
domFx_surface_common *surface = daeSafeCast< domFx_surface_common >( np->add(COLLADA_ELEMENT_SURFACE) );
|
||||
domFx_surface_init_from_common *sif = daeSafeCast< domFx_surface_init_from_common >( surface->add(COLLADA_ELEMENT_INIT_FROM) );
|
||||
sif->setValue( iName.c_str() );
|
||||
surface->setType( FX_SURFACE_TYPE_ENUM_2D );
|
||||
|
||||
np = daeSafeCast< domCommon_newparam_type >( pc->add( COLLADA_ELEMENT_NEWPARAM ) );
|
||||
std::string sampName = efName + "-sampler";
|
||||
np->setSid( sampName.c_str() );
|
||||
domFx_sampler2D_common *sampler = daeSafeCast< domFx_sampler2D_common >( np->add( COLLADA_ELEMENT_SAMPLER2D ) );
|
||||
domFx_sampler2D_common_complexType::domSource *source = daeSafeCast< domFx_sampler2D_common_complexType::domSource >( sampler->add( COLLADA_ELEMENT_SOURCE ) );
|
||||
source->setValue( surfName.c_str() );
|
||||
|
||||
//set sampler state
|
||||
domFx_sampler2D_common_complexType::domWrap_s *wrap_s = daeSafeCast< domFx_sampler2D_common_complexType::domWrap_s >( sampler->add( COLLADA_ELEMENT_WRAP_S ) );
|
||||
osg::Texture::WrapMode wrap = tex->getWrap( osg::Texture::WRAP_S );
|
||||
switch( wrap )
|
||||
if (!m_EarthTex)
|
||||
{
|
||||
case osg::Texture::CLAMP:
|
||||
case osg::Texture::CLAMP_TO_EDGE:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_CLAMP );
|
||||
break;
|
||||
case osg::Texture::CLAMP_TO_BORDER:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_BORDER );
|
||||
break;
|
||||
case osg::Texture::REPEAT:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_WRAP );
|
||||
break;
|
||||
case osg::Texture::MIRROR:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_MIRROR );
|
||||
break;
|
||||
default:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_NONE );
|
||||
break;
|
||||
}
|
||||
domCommon_newparam_type *np = daeSafeCast< domCommon_newparam_type >( pc->add(COLLADA_ELEMENT_NEWPARAM) );
|
||||
std::string surfName = efName + "-surface";
|
||||
np->setSid( surfName.c_str() );
|
||||
domFx_surface_common *surface = daeSafeCast< domFx_surface_common >( np->add(COLLADA_ELEMENT_SURFACE) );
|
||||
domFx_surface_init_from_common *sif = daeSafeCast< domFx_surface_init_from_common >( surface->add(COLLADA_ELEMENT_INIT_FROM) );
|
||||
sif->setValue( iName.c_str() );
|
||||
surface->setType( FX_SURFACE_TYPE_ENUM_2D );
|
||||
|
||||
domFx_sampler2D_common_complexType::domWrap_t *wrap_t = daeSafeCast< domFx_sampler2D_common_complexType::domWrap_t >( sampler->add( COLLADA_ELEMENT_WRAP_T ) );
|
||||
wrap = tex->getWrap( osg::Texture::WRAP_T );
|
||||
switch( wrap )
|
||||
np = daeSafeCast< domCommon_newparam_type >( pc->add( COLLADA_ELEMENT_NEWPARAM ) );
|
||||
std::string sampName = efName + "-sampler";
|
||||
np->setSid( sampName.c_str() );
|
||||
domFx_sampler2D_common *sampler = daeSafeCast< domFx_sampler2D_common >( np->add( COLLADA_ELEMENT_SAMPLER2D ) );
|
||||
domFx_sampler2D_common_complexType::domSource *source = daeSafeCast< domFx_sampler2D_common_complexType::domSource >( sampler->add( COLLADA_ELEMENT_SOURCE ) );
|
||||
source->setValue( surfName.c_str() );
|
||||
|
||||
//set sampler state
|
||||
domFx_sampler2D_common_complexType::domWrap_s *wrap_s = daeSafeCast< domFx_sampler2D_common_complexType::domWrap_s >( sampler->add( COLLADA_ELEMENT_WRAP_S ) );
|
||||
osg::Texture::WrapMode wrap = tex->getWrap( osg::Texture::WRAP_S );
|
||||
switch( wrap )
|
||||
{
|
||||
case osg::Texture::CLAMP:
|
||||
case osg::Texture::CLAMP_TO_EDGE:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_CLAMP );
|
||||
break;
|
||||
case osg::Texture::CLAMP_TO_BORDER:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_BORDER );
|
||||
break;
|
||||
case osg::Texture::REPEAT:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_WRAP );
|
||||
break;
|
||||
case osg::Texture::MIRROR:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_MIRROR );
|
||||
break;
|
||||
default:
|
||||
wrap_s->setValue( FX_SAMPLER_WRAP_COMMON_NONE );
|
||||
break;
|
||||
}
|
||||
|
||||
domFx_sampler2D_common_complexType::domWrap_t *wrap_t = daeSafeCast< domFx_sampler2D_common_complexType::domWrap_t >( sampler->add( COLLADA_ELEMENT_WRAP_T ) );
|
||||
wrap = tex->getWrap( osg::Texture::WRAP_T );
|
||||
switch( wrap )
|
||||
{
|
||||
case osg::Texture::CLAMP:
|
||||
case osg::Texture::CLAMP_TO_EDGE:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_CLAMP );
|
||||
break;
|
||||
case osg::Texture::CLAMP_TO_BORDER:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_BORDER );
|
||||
break;
|
||||
case osg::Texture::REPEAT:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_WRAP );
|
||||
break;
|
||||
case osg::Texture::MIRROR:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_MIRROR );
|
||||
break;
|
||||
default:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_NONE );
|
||||
break;
|
||||
}
|
||||
|
||||
const osg::Vec4 &bcol = tex->getBorderColor();
|
||||
domFx_sampler2D_common_complexType::domBorder_color *dbcol = daeSafeCast< domFx_sampler2D_common_complexType::domBorder_color >( sampler->add( COLLADA_ELEMENT_BORDER_COLOR ) );
|
||||
dbcol->getValue().append( bcol.r() );
|
||||
dbcol->getValue().append( bcol.g() );
|
||||
dbcol->getValue().append( bcol.b() );
|
||||
dbcol->getValue().append( bcol.a() );
|
||||
|
||||
domFx_sampler2D_common_complexType::domMinfilter *minfilter = daeSafeCast< domFx_sampler2D_common_complexType::domMinfilter >( sampler->add( COLLADA_ELEMENT_MINFILTER ) );
|
||||
osg::Texture::FilterMode mode = tex->getFilter( osg::Texture::MIN_FILTER );
|
||||
switch( mode )
|
||||
{
|
||||
case osg::Texture::LINEAR:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR );
|
||||
break;
|
||||
case osg::Texture::LINEAR_MIPMAP_LINEAR:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR_MIPMAP_LINEAR );
|
||||
break;
|
||||
case osg::Texture::LINEAR_MIPMAP_NEAREST:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR_MIPMAP_NEAREST );
|
||||
break;
|
||||
case osg::Texture::NEAREST:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST );
|
||||
break;
|
||||
case osg::Texture::NEAREST_MIPMAP_LINEAR:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST_MIPMAP_LINEAR );
|
||||
break;
|
||||
case osg::Texture::NEAREST_MIPMAP_NEAREST:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST_MIPMAP_NEAREST );
|
||||
break;
|
||||
}
|
||||
|
||||
domFx_sampler2D_common_complexType::domMagfilter *magfilter = daeSafeCast< domFx_sampler2D_common_complexType::domMagfilter >( sampler->add( COLLADA_ELEMENT_MAGFILTER ) );
|
||||
mode = tex->getFilter( osg::Texture::MAG_FILTER );
|
||||
switch( mode )
|
||||
{
|
||||
case osg::Texture::LINEAR:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR );
|
||||
break;
|
||||
case osg::Texture::LINEAR_MIPMAP_LINEAR:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR_MIPMAP_LINEAR );
|
||||
break;
|
||||
case osg::Texture::LINEAR_MIPMAP_NEAREST:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR_MIPMAP_NEAREST );
|
||||
break;
|
||||
case osg::Texture::NEAREST:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST );
|
||||
break;
|
||||
case osg::Texture::NEAREST_MIPMAP_LINEAR:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST_MIPMAP_LINEAR );
|
||||
break;
|
||||
case osg::Texture::NEAREST_MIPMAP_NEAREST:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST_MIPMAP_NEAREST );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
domCommon_color_or_texture_type *cot = daeSafeCast< domCommon_color_or_texture_type >( phong->add( COLLADA_ELEMENT_DIFFUSE ) );
|
||||
domCommon_color_or_texture_type_complexType::domTexture *dtex = daeSafeCast< domCommon_color_or_texture_type_complexType::domTexture >( cot->add( COLLADA_ELEMENT_TEXTURE ) );
|
||||
dtex->setTexture( sampName.c_str() );
|
||||
dtex->setTexcoord( "texcoord0" );
|
||||
}
|
||||
else
|
||||
{
|
||||
case osg::Texture::CLAMP:
|
||||
case osg::Texture::CLAMP_TO_EDGE:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_CLAMP );
|
||||
break;
|
||||
case osg::Texture::CLAMP_TO_BORDER:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_BORDER );
|
||||
break;
|
||||
case osg::Texture::REPEAT:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_WRAP );
|
||||
break;
|
||||
case osg::Texture::MIRROR:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_MIRROR );
|
||||
break;
|
||||
default:
|
||||
wrap_t->setValue( FX_SAMPLER_WRAP_COMMON_NONE );
|
||||
break;
|
||||
// Earth tex
|
||||
domCommon_color_or_texture_type *cot = daeSafeCast< domCommon_color_or_texture_type >( phong->add( COLLADA_ELEMENT_DIFFUSE ) );
|
||||
domCommon_color_or_texture_type_complexType::domTexture *dtex = daeSafeCast< domCommon_color_or_texture_type_complexType::domTexture >( cot->add( COLLADA_ELEMENT_TEXTURE ) );
|
||||
dtex->setTexture( iName.c_str() );
|
||||
dtex->setTexcoord( "texcoord0" );
|
||||
}
|
||||
|
||||
const osg::Vec4 &bcol = tex->getBorderColor();
|
||||
domFx_sampler2D_common_complexType::domBorder_color *dbcol = daeSafeCast< domFx_sampler2D_common_complexType::domBorder_color >( sampler->add( COLLADA_ELEMENT_BORDER_COLOR ) );
|
||||
dbcol->getValue().append( bcol.r() );
|
||||
dbcol->getValue().append( bcol.g() );
|
||||
dbcol->getValue().append( bcol.b() );
|
||||
dbcol->getValue().append( bcol.a() );
|
||||
|
||||
domFx_sampler2D_common_complexType::domMinfilter *minfilter = daeSafeCast< domFx_sampler2D_common_complexType::domMinfilter >( sampler->add( COLLADA_ELEMENT_MINFILTER ) );
|
||||
osg::Texture::FilterMode mode = tex->getFilter( osg::Texture::MIN_FILTER );
|
||||
switch( mode )
|
||||
{
|
||||
case osg::Texture::LINEAR:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR );
|
||||
break;
|
||||
case osg::Texture::LINEAR_MIPMAP_LINEAR:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR_MIPMAP_LINEAR );
|
||||
break;
|
||||
case osg::Texture::LINEAR_MIPMAP_NEAREST:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR_MIPMAP_NEAREST );
|
||||
break;
|
||||
case osg::Texture::NEAREST:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST );
|
||||
break;
|
||||
case osg::Texture::NEAREST_MIPMAP_LINEAR:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST_MIPMAP_LINEAR );
|
||||
break;
|
||||
case osg::Texture::NEAREST_MIPMAP_NEAREST:
|
||||
minfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST_MIPMAP_NEAREST );
|
||||
break;
|
||||
}
|
||||
|
||||
domFx_sampler2D_common_complexType::domMagfilter *magfilter = daeSafeCast< domFx_sampler2D_common_complexType::domMagfilter >( sampler->add( COLLADA_ELEMENT_MAGFILTER ) );
|
||||
mode = tex->getFilter( osg::Texture::MAG_FILTER );
|
||||
switch( mode )
|
||||
{
|
||||
case osg::Texture::LINEAR:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR );
|
||||
break;
|
||||
case osg::Texture::LINEAR_MIPMAP_LINEAR:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR_MIPMAP_LINEAR );
|
||||
break;
|
||||
case osg::Texture::LINEAR_MIPMAP_NEAREST:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_LINEAR_MIPMAP_NEAREST );
|
||||
break;
|
||||
case osg::Texture::NEAREST:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST );
|
||||
break;
|
||||
case osg::Texture::NEAREST_MIPMAP_LINEAR:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST_MIPMAP_LINEAR );
|
||||
break;
|
||||
case osg::Texture::NEAREST_MIPMAP_NEAREST:
|
||||
magfilter->setValue( FX_SAMPLER_FILTER_COMMON_NEAREST_MIPMAP_NEAREST );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
domCommon_color_or_texture_type *cot = daeSafeCast< domCommon_color_or_texture_type >( phong->add( COLLADA_ELEMENT_DIFFUSE ) );
|
||||
domCommon_color_or_texture_type_complexType::domTexture *dtex = daeSafeCast< domCommon_color_or_texture_type_complexType::domTexture >( cot->add( COLLADA_ELEMENT_TEXTURE ) );
|
||||
dtex->setTexture( sampName.c_str() );
|
||||
dtex->setTexcoord( "texcoord0" );
|
||||
#else
|
||||
domCommon_color_or_texture_type *cot = daeSafeCast< domCommon_color_or_texture_type >( phong->add( COLLADA_ELEMENT_DIFFUSE ) );
|
||||
domCommon_color_or_texture_type_complexType::domTexture *dtex = daeSafeCast< domCommon_color_or_texture_type_complexType::domTexture >( cot->add( COLLADA_ELEMENT_TEXTURE ) );
|
||||
dtex->setTexture( iName.c_str() );
|
||||
dtex->setTexcoord( "texcoord0" );
|
||||
#endif
|
||||
|
||||
domInstance_material::domBind_vertex_input *bvi = daeSafeCast< domInstance_material::domBind_vertex_input >( pDomInstanceMaterial->add( COLLADA_ELEMENT_BIND_VERTEX_INPUT ) );
|
||||
bvi->setSemantic( "texcoord0" );
|
||||
bvi->setInput_semantic( COMMON_PROFILE_INPUT_TEXCOORD );
|
||||
@ -370,13 +378,16 @@ void daeWriter::processMaterial( osg::StateSet *ss, domBind_material *pDomBindMa
|
||||
ctt->setOpaque( FX_OPAQUE_ENUM_A_ONE );
|
||||
domCommon_color_or_texture_type_complexType::domTexture * dtex = daeSafeCast< domCommon_color_or_texture_type_complexType::domTexture >( ctt->add(COLLADA_ELEMENT_TEXTURE) );
|
||||
|
||||
#ifndef EARTH_TEX
|
||||
std::string sampName = efName + "-sampler";
|
||||
dtex->setTexture( sampName.c_str() );
|
||||
#else
|
||||
std::string iName = efName + "-image";
|
||||
dtex->setTexture( iName.c_str() );
|
||||
#endif
|
||||
if (!m_EarthTex)
|
||||
{
|
||||
std::string sampName = efName + "-sampler";
|
||||
dtex->setTexture( sampName.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string iName = efName + "-image";
|
||||
dtex->setTexture( iName.c_str() );
|
||||
}
|
||||
dtex->setTexcoord( "texcoord0" );
|
||||
}
|
||||
else
|
||||
|
@ -23,14 +23,21 @@
|
||||
|
||||
namespace osgDAE {
|
||||
|
||||
std::string toString(osg::Vec3 value)
|
||||
std::string toString(const osg::Vec3f& value)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << value.x() << " " << value.y() << " " << value.z();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string toString(osg::Matrix value)
|
||||
std::string toString(const osg::Vec3d& value)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << value.x() << " " << value.y() << " " << value.z();
|
||||
return str.str();
|
||||
}
|
||||
|
||||
std::string toString(const osg::Matrix& value)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << value(0,0) << " " << value(1,0) << " " << value(2,0) << " " << value(3,0) << " "
|
||||
@ -41,13 +48,17 @@ std::string toString(osg::Matrix value)
|
||||
}
|
||||
|
||||
|
||||
daeWriter::daeWriter( DAE *dae_, const std::string &fileURI, bool _usePolygons, bool GoogleMode, TraversalMode tm, bool _writeExtras) : osg::NodeVisitor( tm ),
|
||||
daeWriter::daeWriter( DAE *dae_, const std::string &fileURI, bool _usePolygons, bool googleMode, TraversalMode tm, bool _writeExtras, bool earthTex, bool zUpAxis, bool forceTexture) : osg::NodeVisitor( tm ),
|
||||
dae(dae_),
|
||||
_domLibraryAnimations(NULL),
|
||||
writeExtras(_writeExtras),
|
||||
rootName(*dae_),
|
||||
usePolygons (_usePolygons),
|
||||
m_GoogleMode(GoogleMode)
|
||||
m_GoogleMode(googleMode),
|
||||
m_EarthTex(earthTex),
|
||||
m_ZUpAxis(zUpAxis),
|
||||
m_ForceTexture(forceTexture),
|
||||
m_CurrentRenderingHint(osg::StateSet::DEFAULT_BIN)
|
||||
{
|
||||
success = true;
|
||||
|
||||
@ -68,7 +79,7 @@ daeWriter::daeWriter( DAE *dae_, const std::string &fileURI, bool _usePolygons,
|
||||
currentNode->setId( "sceneRoot" );
|
||||
|
||||
//create Asset
|
||||
createAssetTag();
|
||||
createAssetTag(m_ZUpAxis);
|
||||
|
||||
lib_cameras = NULL;
|
||||
lib_effects = NULL;
|
||||
@ -149,7 +160,7 @@ std::string daeWriter::uniquify( const std::string &name )
|
||||
return "";
|
||||
}
|
||||
|
||||
void daeWriter::createAssetTag()
|
||||
void daeWriter::createAssetTag( bool isZUpAxis )
|
||||
{
|
||||
domAsset *asset = daeSafeCast< domAsset >(dom->add( COLLADA_ELEMENT_ASSET ) );
|
||||
domAsset::domCreated *c = daeSafeCast< domAsset::domCreated >(asset->add(COLLADA_ELEMENT_CREATED));
|
||||
|
@ -135,7 +135,7 @@ class daeWriter : public osg::NodeVisitor
|
||||
protected:
|
||||
class ArrayNIndices;
|
||||
public:
|
||||
daeWriter( DAE *dae_, const std::string &fileURI, bool usePolygons=false, bool GoogleMode = false,TraversalMode tm=TRAVERSE_ALL_CHILDREN, bool writeExtras = true);
|
||||
daeWriter( DAE *dae_, const std::string &fileURI, bool usePolygons=false, bool googleMode = false, TraversalMode tm=TRAVERSE_ALL_CHILDREN, bool writeExtras = true, bool earthTex = false, bool zUpAxis=false, bool forceTexture=false);
|
||||
virtual ~daeWriter();
|
||||
|
||||
void setRootNode( const osg::Node &node );
|
||||
@ -190,7 +190,7 @@ protected: //methods
|
||||
|
||||
void processMaterial( osg::StateSet *ss, domBind_material *pDomBindMaterial, const std::string &geoName );
|
||||
|
||||
void createAssetTag();
|
||||
void createAssetTag(bool isZUpAxis);
|
||||
|
||||
void pushStateSet(osg::StateSet* ss);
|
||||
|
||||
@ -306,9 +306,18 @@ private: //members
|
||||
/** provide an unique name */
|
||||
std::string uniquify( const std::string &name );
|
||||
|
||||
/** work in Google compatibility mode */
|
||||
/** work in Google compatibility mode. In daeWMaterials, change transparency color. And in daeWGeometry, replace tristrip and trifans by triangles*/
|
||||
bool m_GoogleMode;
|
||||
|
||||
/** work in Google compatibility mode for textures*/
|
||||
bool m_EarthTex;
|
||||
|
||||
/** indicates if the up axis is on Z axis*/
|
||||
bool m_ZUpAxis;
|
||||
|
||||
/** force the use an image for a texture, even if the file is not found*/
|
||||
bool m_ForceTexture;
|
||||
|
||||
/** Current RenderingHint */
|
||||
/** This are needed because the stateSet merge code currently does not handle it */
|
||||
int m_CurrentRenderingHint;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# FIXME: For OS X, need flag for Framework or dylib
|
||||
IF(DYNAMIC_OPENSCENEGRAPH)
|
||||
ADD_DEFINITIONS(-DOSGVIEWER_LIBRARY)
|
||||
@ -70,32 +69,59 @@ ELSE()
|
||||
ENDIF()
|
||||
|
||||
IF(${OSG_WINDOWING_SYSTEM} STREQUAL "Cocoa")
|
||||
ADD_DEFINITIONS(-DUSE_DARWIN_COCOA_IMPLEMENTATION)
|
||||
SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
|
||||
${HEADER_PATH}/api/Cocoa/GraphicsHandleCocoa
|
||||
${HEADER_PATH}/api/Cocoa/GraphicsWindowCocoa
|
||||
${HEADER_PATH}/api/Cocoa/PixelBufferCocoa
|
||||
)
|
||||
ADD_DEFINITIONS(-DUSE_DARWIN_COCOA_IMPLEMENTATION)
|
||||
|
||||
IF(OSG_COMPILE_FRAMEWORKS)
|
||||
SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
|
||||
${HEADER_PATH}/api/Cocoa/GraphicsHandleCocoa
|
||||
${HEADER_PATH}/api/Cocoa/GraphicsWindowCocoa
|
||||
${HEADER_PATH}/api/Cocoa/PixelBufferCocoa
|
||||
)
|
||||
SET_PROPERTY(SOURCE ${HEADER_PATH}/api/Cocoa/GraphicsHandleCocoa PROPERTY MACOSX_PACKAGE_LOCATION Headers/api/Cocoa)
|
||||
SET_PROPERTY(SOURCE ${HEADER_PATH}/api/Cocoa/GraphicsWindowCocoa PROPERTY MACOSX_PACKAGE_LOCATION Headers/api/Cocoa)
|
||||
SET_PROPERTY(SOURCE ${HEADER_PATH}/api/Cocoa/PixelBufferCocoa PROPERTY MACOSX_PACKAGE_LOCATION Headers/api/Cocoa)
|
||||
ELSE()
|
||||
SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
|
||||
${HEADER_PATH}/api/Cocoa/GraphicsHandleCocoa
|
||||
${HEADER_PATH}/api/Cocoa/GraphicsWindowCocoa
|
||||
${HEADER_PATH}/api/Cocoa/PixelBufferCocoa
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
|
||||
GraphicsWindowCocoa.mm
|
||||
DarwinUtils.h
|
||||
DarwinUtils.mm
|
||||
PixelBufferCocoa.mm
|
||||
)
|
||||
SET(LIB_EXTRA_LIBS ${COCOA_LIBRARY} ${LIB_EXTRA_LIBS})
|
||||
SET(LIB_EXTRA_LIBS ${COCOA_LIBRARY} ${LIB_EXTRA_LIBS})
|
||||
ELSEIF(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon")
|
||||
ADD_DEFINITIONS(-DUSE_DARWIN_CARBON_IMPLEMENTATION)
|
||||
SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
|
||||
${HEADER_PATH}/api/Carbon/GraphicsHandleCarbon
|
||||
${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon
|
||||
${HEADER_PATH}/api/Carbon/PixelBufferCarbon
|
||||
)
|
||||
ADD_DEFINITIONS(-DUSE_DARWIN_CARBON_IMPLEMENTATION)
|
||||
|
||||
IF(OSG_COMPILE_FRAMEWORKS)
|
||||
SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
|
||||
${HEADER_PATH}/api/Carbon/GraphicsHandleCarbon
|
||||
${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon
|
||||
${HEADER_PATH}/api/Carbon/PixelBufferCarbon
|
||||
)
|
||||
SET_PROPERTY(SOURCE ${HEADER_PATH}/api/Carbon/GraphicsHandleCarbon PROPERTY MACOSX_PACKAGE_LOCATION Headers/api/Carbon)
|
||||
SET_PROPERTY(SOURCE ${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon PROPERTY MACOSX_PACKAGE_LOCATION Headers/api/Carbon)
|
||||
SET_PROPERTY(SOURCE ${HEADER_PATH}/api/Carbon/PixelBufferCarbon PROPERTY MACOSX_PACKAGE_LOCATION Headers/api/Carbon)
|
||||
ELSE()
|
||||
SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS}
|
||||
${HEADER_PATH}/api/Carbon/GraphicsHandleCarbon
|
||||
${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon
|
||||
${HEADER_PATH}/api/Carbon/PixelBufferCarbon
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
|
||||
GraphicsWindowCarbon.cpp
|
||||
DarwinUtils.h
|
||||
DarwinUtils.mm
|
||||
PixelBufferCarbon.cpp
|
||||
)
|
||||
|
||||
SET(LIB_EXTRA_LIBS ${COCOA_LIBRARY} ${LIB_EXTRA_LIBS})
|
||||
ELSE()
|
||||
# X11 for everybody else
|
||||
|
Loading…
Reference in New Issue
Block a user