void EffectsExporter::exportEffects(Scene *sce)
{
	this->scene = sce;

	if (this->export_settings->export_texture_type == BC_TEXTURE_TYPE_MAT) {
		if (hasEffects(sce)) {
				MaterialFunctor mf;
				openLibrary();
				mf.forEachMaterialInExportSet<EffectsExporter>(sce, *this, this->export_settings->export_set);
				closeLibrary();
		}
	}
	else {
		std::set<Object *> uv_textured_obs = bc_getUVTexturedObjects(sce, !this->export_settings->active_uv_only);
		std::set<Image *> uv_images = bc_getUVImages(sce, !this->export_settings->active_uv_only);
		if (uv_images.size() > 0) {
			openLibrary();
			std::set<Image *>::iterator uv_images_iter;
			for (uv_images_iter = uv_images.begin();
			     uv_images_iter != uv_images.end();
			     uv_images_iter++)
			{

				Image *ima = *uv_images_iter;
				std::string key(id_name(ima));
				key = translate_id(key);
				COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
					key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
					key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
				sampler.setImageId(key);

				openEffect(key + "-effect");
				COLLADASW::EffectProfile ep(mSW);
				ep.setProfileType(COLLADASW::EffectProfile::COMMON);
				ep.setShaderType(COLLADASW::EffectProfile::PHONG);
				ep.setDiffuse(createTexture(ima, key, &sampler), false, "diffuse");
				COLLADASW::ColorOrTexture cot = getcol(0, 0, 0, 1.0f);
				ep.setSpecular(cot, false, "specular");
				ep.openProfile();
				ep.addProfileElements();
				ep.addExtraTechniques(mSW);
				ep.closeProfile();
				closeEffect();
			}
			closeLibrary();
		}
	}
}
    //---------------------------------------------------------------
    MaterialMap* MaterialExporter::exportMaterials ( bool writeMaterials )
    {
        mWriteMaterials = writeMaterials;

        // Should we only export the selected elements?
        bool exportSelectedOnly = mDocumentExporter->getExportSelectedOnly ();

        // Should we only export the referenced (used) materials?
        bool exportReferencedOnly = ExportOptions::exportReferencedMaterials ();

        if ( !exportSelectedOnly && !exportReferencedOnly ) 
        {
            // Get all shaders, which are in the default shader list.
            // Unfortunately, you will not get the default initialShadingGroup elements, which are
            // directly connected to an object, if no other material (shader) is connected to the object.
            exportMaterialsByShaderPlug ();
        }

        // Now go through scene graph and find all shaders, connected to the meshes.
        // So you can find the default shaders of an object.
        exportMaterialsBySceneGraph ();

        // Set the flag, that the material std::map is initialised
        materialMapInitialized = true;

        // Close the tags in the collada document
        closeLibrary();

        // Return the material list
        return &mMaterialMap;
    }
Beispiel #3
0
void LibraryWidget::setLibraryManager(LibraryManager *lm)
{
    m_libraryManager = lm;

    connect(lm, SIGNAL(libraryAdded(Library*)), this, SLOT(addLibrary(Library*)));
    connect(lm, SIGNAL(libraryRemoved(QUrl)), this, SLOT(closeLibrary(QUrl)));
}
Beispiel #4
0
void CamerasExporter::exportCameras(Scene *sce)
{
    openLibrary();

    forEachCameraObjectInScene(sce, *this, this->export_settings->selected);

    closeLibrary();
}
Beispiel #5
0
void LightsExporter::exportLights(Scene *sce, bool export_selected)
{
	openLibrary();
	
	forEachLampObjectInScene(sce, *this, export_selected);
	
	closeLibrary();
}
Beispiel #6
0
void LightsExporter::exportLights(Scene *sce)
{
  openLibrary();

  forEachLightObjectInExportSet(sce, *this, this->export_settings.get_export_set());

  closeLibrary();
}
Beispiel #7
0
 LibraryInterception::~LibraryInterception()
 {
     for( auto& kv : m_libraries )
         closeLibrary( kv.second.handle );
     m_libraries.clear();
     m_context = 0;
     m_owner = 0;
 }
void ColladaSerializer::ColladaExporter::ColladaScene::write() {
	if (scene_opened) {
		closeVisualScene();
		closeLibrary();

		COLLADASW::Scene scene (mSW, COLLADASW::URI ("#" + scene_id));
		scene.add();		
	}
}
void SceneExporter::exportScene(Scene *sce)
{
	// <library_visual_scenes> <visual_scene>
	std::string id_naming = id_name(sce);
	openVisualScene(translate_id(id_naming), id_naming);
	exportHierarchy(sce);
	closeVisualScene();
	closeLibrary();
}
void ColladaSerializer::ColladaExporter::ColladaMaterials::write() {
	effects.close();
	for (std::vector<IfcGeom::Material>::const_iterator it = materials.begin(); it != materials.end(); ++it) {
		const std::string& material_name = collada_id((*it).name());
		openMaterial(material_name);
		addInstanceEffect("#" + material_name + "-fx");
		closeMaterial();
	}
	closeLibrary();
}
Beispiel #11
0
void ImagesExporter::exportImages(Scene *sce, bool export_selected)
{
	if(hasImages(sce)) {
		openLibrary();
		MaterialFunctor mf;
		mf.forEachMaterialInScene<ImagesExporter>(sce, *this, export_selected);

		closeLibrary();
	}
}
void GeometryExporter::exportGeom(Scene *sce)
{
	openLibrary();

	mScene = sce;
	GeometryFunctor gf;
	gf.forEachMeshObjectInScene<GeometryExporter>(sce, *this, this->export_settings->selected);

	closeLibrary();
}
Beispiel #13
0
void MaterialsExporter::exportMaterials(Scene *sce)
{
	if (hasMaterials(sce)) {
		openLibrary();

		MaterialFunctor mf;
		mf.forEachMaterialInExportSet<MaterialsExporter>(sce, *this, this->export_settings->export_set);

		closeLibrary();
	}
}
    //---------------------------------------------------------------
    void AnimationClipExporter::exportAnimationClips ( const AnimationClipList* animationClips )
    {
        AnimationClipList::const_iterator clipIter = animationClips->begin();
        for ( ; clipIter!= animationClips->end(); ++clipIter )
        {
            AnimationClip* animationClip = *clipIter;
            addAnimationClip ( *animationClip->colladaClip );
        }

        closeLibrary();
    }
Beispiel #15
0
void ArmatureExporter::export_controllers(Scene *sce, bool export_selected)
{
	scene = sce;

	openLibrary();

	GeometryFunctor gf;
	gf.forEachMeshObjectInScene<ArmatureExporter>(sce, *this, export_selected);

	closeLibrary();
}
void ControllerExporter::export_controllers(Scene *sce)
{
	scene = sce;

	openLibrary();

	GeometryFunctor gf;
	gf.forEachMeshObjectInExportSet<ControllerExporter>(sce, *this, this->export_settings->export_set);

	closeLibrary();
}
void EffectsExporter::exportEffects(Scene *sce)
{
	if (hasEffects(sce)) {
		this->scene = sce;
		openLibrary();
		MaterialFunctor mf;
		mf.forEachMaterialInExportSet<EffectsExporter>(sce, *this, this->export_settings->export_set);

		closeLibrary();
	}
}
void AnimationExporter::exportAnimations(Scene *sce)
{
	if (hasAnimations(sce)) {
		this->scene = sce;

		openLibrary();

		forEachObjectInExportSet(sce, *this, this->export_settings->export_set);

		closeLibrary();
	}
}
Beispiel #19
0
void AnimationExporter::exportAnimations(Scene *sce)
{
	if(hasAnimations(sce)) {
		this->scene = sce;

		openLibrary();

		forEachObjectInScene(sce, *this);

		closeLibrary();
	}
}
    //---------------------------------------------------------------
    void ImageExporter::doExport()
    {
        // export all wire frame color materials

        for ( ExportedImageMap::const_iterator it = mExportedImageMap.begin(); it != mExportedImageMap.end(); ++it )
        {
			const ImageInfo& imageInfo = it->second;
            addImage ( COLLADASW::Image ( imageInfo.fileLocation, imageInfo.imageId ) );
        }

        closeLibrary();
    }
bool AnimationExporter::exportAnimations(Scene *sce)
{
	bool has_animations = hasAnimations(sce);
	if (has_animations) {
		this->scene = sce;

		openLibrary();

		forEachObjectInExportSet(sce, *this, this->export_settings->export_set);

		closeLibrary();
	}
	return has_animations;
}
Beispiel #22
0
void MaterialsExporter::exportMaterials(Scene *sce)
{
	if (this->export_settings->export_texture_type == BC_TEXTURE_TYPE_MAT)
	{
		if (hasMaterials(sce)) {
			openLibrary();

			MaterialFunctor mf;
			mf.forEachMaterialInExportSet<MaterialsExporter>(sce, *this, this->export_settings->export_set);

			closeLibrary();
		}
	}

	else {
		std::set<Image *> uv_images = bc_getUVImages(sce, !this->export_settings->active_uv_only);
		if (uv_images.size() > 0) {
			openLibrary();
			std::set<Image *>::iterator uv_images_iter;
			for (uv_images_iter = uv_images.begin();
				uv_images_iter != uv_images.end();
				uv_images_iter++) {

				Image *ima = *uv_images_iter;
				std::string matid(id_name(ima));

				openMaterial(get_material_id_from_id(matid), translate_id(matid));
				std::string efid = translate_id(matid) + "-effect";
				addInstanceEffect(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, efid));
				closeMaterial();
			}
			closeLibrary();
		}
	}

}
Beispiel #23
0
void ImagesExporter::exportImages(Scene *sce)
{
	openLibrary();

	MaterialFunctor mf;
	if (this->export_settings->include_material_textures) {
		mf.forEachMaterialInExportSet<ImagesExporter>(sce, *this, this->export_settings->export_set);
	}

	if (this->export_settings->include_uv_textures) {
		export_UV_Images();
	}

	closeLibrary();
}
    //---------------------------------------------------------------
    void GeometriesExporter::doExport()
    {
        doExport ( mExportSceneGraph->getRootExportNode() );

		const MorphControllerHelperGeometryList& morphControllerHelperGeometryList = mExportSceneGraph->getMorphControllerHelperGeometryList();

		for ( MorphControllerHelperGeometryList::const_iterator it = morphControllerHelperGeometryList.begin(); it != morphControllerHelperGeometryList.end(); ++it)
		{
			const MorphControllerHelperGeometry& morphControllerHelperGeometry = *it;
			GeometryExporter geometryExporter ( &morphControllerHelperGeometry, this, mDocumentExporter );

			geometryExporter.doExport();
		}

        closeLibrary();
    }
Beispiel #25
0
    void Kernel::launchInitPhase(void)
    {
        LibraryHandle handle = loadLibrary(m_initFilename);

        if( ! handle )
            throw std::system_error(EACCES, std::system_category(), m_initFilename + m_moduleExtension + ", " + libraryError() );


        IKernel::InitFunction fct = (IKernel::InitFunction) searchSymbol(handle, "init");

        if( ! fct )
            throw std::system_error(ENOEXEC, std::system_category(), m_initFilename + m_moduleExtension + ", " + libraryError() );
        fct( *this);

        closeLibrary(handle);
    }
    //---------------------------------------------------------------
    void LightExporter::exportLights ( )
    {
        if ( !ExportOptions::exportLights() ) return;

        // Get the list with the transform nodes.
        SceneGraph* sceneGraph = mDocumentExporter->getSceneGraph();
        SceneElementsList* exportNodesTree = sceneGraph->getExportNodesTree();

        // Export all/selected DAG nodes
        size_t length = exportNodesTree->size();
        for ( uint i = 0; i < length; ++i )
        {
            SceneElement* sceneElement = ( *exportNodesTree ) [i];
            exportLights ( sceneElement );
        }

        closeLibrary();
    }
Beispiel #27
0
void MaterialExporter::add()
{
    char tempStr[1024];

    openLibrary();
    for (int i = 0; i < m_bsp->numShaders; ++i)
    {
        sprintf(tempStr, "material%d", i);
        std::string matId = tempStr;

        sprintf(tempStr, "material%d-fx", i);
        std::string fxId = tempStr;

        openMaterial(matId, matId);
        addInstanceEffect(COLLADASW::URI(EMPTY_STRING, fxId));
        closeMaterial();
    }
    closeLibrary();
}
Beispiel #28
0
void MaterialExporter::doExport()
{
	vgLogDebug("Exporting materials");
	openLibrary();
	
	if( m_exportSettings.getLevel() > GEOMETRY )
	{
		typedef collectedMapType::right_map::const_iterator right_const_iterator;

		for( right_const_iterator right_iter = m_collectedMap.right.begin(), iend = m_collectedMap.right.end();
			 right_iter != iend; ++right_iter )
		{
			vgd::Shp< vge::technique::CollectedMaterial > collectedMaterial = right_iter->first;
			
			if( collectedMaterial->getMaterial() )
			{
				std::string effectName = collectedMaterial->getEffectId();
				std::string materialName = effectName + MATERIAL_ID_SUFFIX;
				collectedMaterial->setMaterialId( materialName );

				openMaterial ( materialName, COLLADABU::Utils::checkNCName(materialName) );
				addInstanceEffect ( "#" + effectName );
				closeMaterial ();
			}
		}
	}
	else
	{
		std::string effectName = "DefaultWhole";
		std::string materialName = effectName + MATERIAL_ID_SUFFIX;

		openMaterial ( materialName, COLLADABU::Utils::checkNCName(materialName) );
		addInstanceEffect ( "#" + effectName );
		closeMaterial ();
	}
	closeLibrary();
}
	//---------------------------------------------------------------
	void LightExporter::doExport()
	{
		exportEnvironmentAmbientLight();
		doExport( mExportSceneGraph->getRootExportNode() );
		closeLibrary();
	}
Beispiel #30
0
 bool LibraryInterception::onIntercept( XeCore::Intuicio::ParallelThreadVM* caller, uint32 code )
 {
     if( !m_context || !m_owner )
         return false;
     if( code == C_LOAD )
     {
         Library lib;
         int64_t id = 0;
         int64_t ptrPath = 0;
         std::string path;
         if( !m_context->stackPop( caller, &id, sizeof( id ) ) )
             return false;
         if( !m_context->stackPop( caller, &ptrPath, sizeof( ptrPath ) ) )
             return false;
         if( m_libraries.count( id ) )
             return false;
         if( !id || !ptrPath )
             return false;
         path = (char*)ptrPath;
         lib.handle = loadLibrary( path );
         if( !lib.handle )
         {
             for( auto p : paths )
             {
                 lib.handle = loadLibrary( (p + "/" + path).c_str() );
                 if( lib.handle )
                     break;
             }
         }
         if( !lib.handle )
         {
             int32_t v = 0;
             m_context->stackPush( caller, &v, sizeof( v ) );
             return true;
         }
         lib.onLoad = (int32_t (*)())getFunction( lib.handle, "onLoad" );
         lib.onUnload = (int32_t (*)())getFunction( lib.handle, "onUnload" );
         lib.onCall = (int32_t (*)( Runtime*, int64_t, int64_t ))getFunction( lib.handle, "onCall" );
         if( !lib.onLoad || !lib.onUnload || !lib.onCall )
         {
             closeLibrary( lib.handle );
             int32_t v = 0;
             m_context->stackPush( caller, &v, sizeof( v ) );
             return true;
         }
         if( !lib.onLoad() )
         {
             closeLibrary( lib.handle );
             int32_t v = 0;
             m_context->stackPush( caller, &v, sizeof( v ) );
             return true;
         }
         m_libraries[ id ] = lib;
         int32_t v = 1;
         m_context->stackPush( caller, &v, sizeof( v ) );
         return true;
     }
     else if( code == C_UNLOAD )
     {
         int64_t id = 0;
         if( !m_context->stackPop( caller, &id, sizeof( id ) ) )
             return false;
         if( !m_libraries.count( id ) )
             return false;
         m_libraries[ id ].onUnload();
         closeLibrary( m_libraries[ id ].handle );
         m_libraries.erase( id );
         int32_t v = 1;
         m_context->stackPush( caller, &v, sizeof( v ) );
         return true;
     }
     else if( code == C_CALL )
     {
         int64_t id = 0;
         int64_t func = 0;
         if( !m_context->stackPop( caller, &id, sizeof( id ) ) )
             return false;
         if( !m_context->stackPop( caller, &func, sizeof( func ) ) )
             return false;
         if( !m_libraries.count( id ) )
             return false;
         int32_t status = m_libraries[ id ].onCall( m_owner, (int64_t)caller, func );
         return status;
     }
     return false;
 }