예제 #1
0
	//! initializes this resource
	void MeshResource::ResourceInit()
	{
		auto meshResourcePath = GetTemplatePath();
		m_MeshPath = Utils::GetFilePathNoExt(meshResourcePath) + ".fbx";

		if (!m_sMeshReload)
			m_SubMeshInfos.clear();

#ifndef SHOOT_EDITOR
		LoadFS(m_MeshPath.c_str());
#else
		auto binPath = Utils::GetBinPath(m_MeshPath);
		bool dirty = true;
		if (File::Exists(binPath.c_str()))
			dirty = Utils::IsFileMoreRecent(m_MeshPath, binPath)
				 || Utils::IsFileMoreRecent(meshResourcePath, binPath);

		if (dirty)
		{
			Log.Print("Converting FBX '%s'\n", m_MeshPath.c_str());
			auto binFile = Utils::CreateBinFile(binPath);
			FBXMeshLoader(this).Load(m_MeshPath.c_str(), binFile);
			binFile->Close();
			sdelete(binFile);
		}
		else
			LoadFS(binPath.c_str());
#endif

		for (auto& submesh : m_SubMeshInfos)
			submesh.m_VertexBuffer->SetDynamic(m_bDynamic);		
	}
예제 #2
0
SchedViz::SchedViz( const std::string &abstractModel, const std::string &vizFilename, const bool &debug ) :
	_debug(debug), _hyperperiodSec(0.0), _traceViz(NULL) {
	// Start UDM using the ESMoL_Abstract (Semantics) paradigm
	Udm::SmartDataNetwork abstractSDN( Semantics::diagram );
	try {
		// Try to open the model file
		abstractSDN.OpenExisting( abstractModel );
	} catch (udm_exception &ex) {
		std::cout << "Exception occured trying to open " << abstractModel << " in udm:" << std::endl;
		std::cout << ex.what() << std::endl;
		throw SchedVizException( std::string( ex.what() ) );
	}

	// Get the template file name
	std::string templateName = GetTemplatePath() + "\\sched_viz.tpl";
	// Start up the TraceViz
	this->_traceViz = new TraceViz( abstractModel, vizFilename, templateName );

	//Get the root folder of the project
	Semantics::RootFolder rootFolder = Semantics::RootFolder::Cast( abstractSDN.GetRootObject() );
	// Visit the root folder
	this->Visit_RootFolder( rootFolder );

	// Render the trace to file
	this->_traceViz->Render();
	// Delete the traceViz
	delete this->_traceViz;
}
예제 #3
0
	//! ResourceInit
	void Texture::ResourceInit()
	{
		if (m_pData)
		{
			SHOOT_LOG_WARNING(false, "Texture '%s' disk data already loaded", GetTemplatePath().c_str());
			return;
		}

		int channels;
		auto texResourcePath = GetTemplatePath();
		auto pngPath = Utils::GetFilePathNoExt(texResourcePath) + ".png";

#ifndef SHOOT_EDITOR
		LoadFromBinPng(pngPath, channels, m_bpp);
#else
		auto binPath = Utils::GetBinPath(pngPath);
		bool dirty = true;
		if (File::Exists(binPath.c_str()))
		{
			dirty = Utils::IsFileMoreRecent(pngPath, binPath);
			dirty = dirty || (!m_IgnoreResourceFileOnInit && Utils::IsFileMoreRecent(texResourcePath, binPath));
		}			

		if (dirty)
		{
			Log.Print("Converting PNG '%s'\n", pngPath.c_str());
			auto binFile = Utils::CreateBinFile(binPath);

			int width, height;
			m_pData = PNGLoader::LoadFromRawPng(pngPath, width, height, channels, m_bpp, binFile, m_32Bits);
			m_vSize.Set(float(width), float(height));

			binFile->Close();
			sdelete(binFile);
		}
		else
			LoadFromBinPng(binPath, channels, m_bpp);
#endif

		if (!m_pData)
			return;

		m_pImpl->InitHardwareSize();

		// Emulate non-pow 2
		{
			Size size((int)m_vSize.X, (int)m_vSize.Y);
			Size hwSize((int)m_vHardwareSize.X, (int)m_vHardwareSize.Y);
			if ((size != hwSize))
			{
				uchar* pOldData = static_cast<uchar*>(m_pData);
				uchar* pNewData = snew uchar[hwSize.Width * hwSize.Height * m_bpp];
				memset(pNewData, 0, hwSize.Width * hwSize.Height * m_bpp);

				for (int row = 0; row < size.Height; ++row)
					memcpy(pNewData + row*hwSize.Width*m_bpp, pOldData + row*size.Width*m_bpp, size.Width*m_bpp);

				if (m_bOwnData)
				{
					sdelete_array(pOldData);
				}
				m_pData = pNewData;
				m_bOwnData = true;
			}
		}

		switch (channels)
		{
		case 3:	m_eFormat = TF_RGB;	break;
		case 4:	m_eFormat = TF_RGBA; break;
		default: SHOOT_ASSERT(0, "Texture '%s' has unsupported format", pngPath.c_str());
		}
	}