xml::XMLElement* RenderMaterial::loadXMLSettings(xml::XMLElement* elem){

	IResource::loadFromXML(elem);

	xml::XMLElement*e=elem->getSubElement(mT("Technique"));
	while(e)
	{
		core::string name=e->getValueString("Name");
		video::RenderTechnique* t= GetTechniqueByName(name);
		bool loaded=false;
		if(!t)
			t=new RenderTechnique(this);
		else loaded=true;
		t->loadXMLSettings(e);
		if(!loaded)
			AddTechnique(t);
		e=e->nextSiblingElement(mT("Technique"));
	}
	m_activeTechnique=0;
	for(int i=0;i<m_techniques.size();++i)
	{
		if(m_techniques[i]->IsSupported())
		{
			m_activeTechnique=m_techniques[i];
			break;
		}
	}
	return elem;
}
SceneManager::SceneManager(video::IVideoDevice*dev):
ISceneManager(dev),m_activeCamera(0)
{
	m_rootNode = new ISceneNode("Root Scene Node", 0, this);
	m_rootNode->setCullingType(SCT_NONE);

	m_benchmarkItem=new BenchmarkItem(mT("SceneManager"));

	m_nodesMutex=OS::IThreadManager::getInstance().createMutex();

	m_nameIDGenerator=0;

	m_jobsThreadsManager=new ThreadJobManager();
	m_renderManager=new RenderManager(this);

	m_renderBI=m_benchmarkItem->addSubItem(mT("render"));
	m_updateBI=m_benchmarkItem->addSubItem(mT("update"));

	//by default,there is one normal render pass
	//m_normalRP=new NormalRenderPass();
	//addRenderPass(m_normalRP);

	m_activeViewnode=0;

	m_debugDrawManager=0;
}
void CSkyBoxDlg::OnBnClickedLoadskybox()
{
	// TODO: Add your control notification handler code here
	CString str;
	NameTxt.GetWindowTextA(str);
	if(str==mT(""))
	{
		MessageBox(mT("Set SkyBox Name first"),mT("Skybox"),0);
		return;
	}
	CFileDialog fd(true,0,0,OFN_EXPLORER,mT("Image Files |*.*||"));
	if(fd.DoModal()==IDOK)
	{
		core::string path=fd.GetPathName().GetString();
		int i=path.findlast('\\');
		if(i!=-1){
			path=path.substr(0,i+1);
		}
		core::string ext=fd.GetFileExt().GetString();
		scene::SkyBoxManager::getInstance().loadSkyFromFolder(path,ext,str.GetString());
		SkyInfo ifo;
		ifo.name=str.GetString();
		ifo.path=path;
		ifo.ext=ext;
		m_skiesInfo[ifo.name]=ifo;
		RefreshList();
	}
}
//! constructor
SplashScreen::SplashScreen(bool internalRes){

	if(internalRes)
	{
#ifndef MRAY_WinApp_DLL
		m_hInstance=GetModuleHandle(0);
#else 
#	ifdef _DEBUG
		m_hInstance=GetModuleHandle(mT("mrayEngine_d.dll"));
#	else
		m_hInstance=GetModuleHandle(mT("mrayEngine.dll"));
#	endif
#endif
	}else
	{
		m_hInstance=GetModuleHandle(0);
	}

	// Var Init
	m_iTimerNo=0;
	m_hWindow=0;
	m_hBitmap=0;
	m_iXBitmapSize=0;
	m_iYBitmapSize=0;


	//  =======================================================================
	//  Keep the function pointer for the SetLayeredWindowAttributes function
	//  in User32.dll ready
	//  =======================================================================
	HMODULE hUser32 = GetModuleHandle(TEXT("USER32.DLL"));

	g_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes)
		GetProcAddress(hUser32, "SetLayeredWindowAttributes");
}
void SceneManager::addSceneNode(const ISceneNodePtr& node, ISceneNode* parent)
{
	if(!node)
		return;

	SceneNodeMap::iterator it= m_Children.find(node->getNodeName());
	if(it!=m_Children.end())
	{
		gSceneLoggerSystem.log(mT("AddSceneNode: SceneNode with name:")+node->getNodeName()+mT(" is already exists in the scene manager"),ELL_WARNING,EVL_Heavy);
		node->setNodeName(node->getNodeName()+mT("#")+core::StringConverter::toString(++m_nameIDGenerator)+mT("_"));
		addSceneNode(node);
		return;
	}
	node->SetSceneManager(this);

	{
		OS::ScopedLock lock(m_nodesMutex);
		m_Children[node->getNodeName()]=node;
		uint id=m_objectsID.AddObject(node,node->getID());
		node->setID(id);
	}

	node->_OnAddedToSceneManager(this);
	if (parent)
		parent->addChild(node);
	else if (m_rootNode)
		m_rootNode->addChild(node);
	else gSceneLoggerSystem.log("AddSceneNode: parent node is null, and there is no root node set!", ELL_WARNING);
}
xml::XMLElement* DecisionTree::loadXMLSettings(xml::XMLElement* elem)
{
	xml::XMLElement*e;
	e=elem->getSubElement(mT("scheme"));
	if(e)
	{
		if(m_scheme)
			delete m_scheme;
		m_scheme=new AttributesScheme();
		m_scheme->loadXMLSettings(e);
	}
	e=elem->getSubElement(mT("training"));
	if(e)
	{
		xml::XMLAttribute*attr=e->getAttribute(mT("Target"));
		if(!attr)
			return elem;
		TrainingDataSet ds(m_scheme);
		ds.loadExamplesFromXML(e);
		Train(&ds,attr->value);

		//test
		
		xml::XMLElement e(mT("DT"));
		exportXMLSettings(&e);
		GCPtr<OS::IStream> stream=gFileSystem.openFile(mT("IDT.xml"),OS::TXT_WRITE);
		xml::XMLWriter w;
		w.addElement(&e);
		OS::StreamWriter ww(stream);
		ww.writeString(w.flush());
		stream->close();

	}
	return elem;
}
void GameLevelManager::LoadLevelsFile(const core::string& path)
{
	GCPtr<OS::IStream> stream=gFileSystem.openFile(path,OS::TXT_READ);
	if(!stream)
		return;

	xml::XMLTree tree;
	if(!tree.load(stream))
	{
		stream->close();
		return;
	}
	xml::XMLElement*e=tree.getSubElement(mT("Levels"));
	if(!e){
		stream->close();
		return;
	}
	xml::xmlSubElementsMapIT it= e->getElementsBegin();
	for (;it!=e->getElementsEnd();++it)
	{
		if((*it)->GetType()!=xml::ENT_Element)continue;
		xml::XMLElement* elem=dynamic_cast<xml::XMLElement*>(*it);
		xml::XMLAttribute*attr;
		attr=elem->getAttribute(mT("Path"));
		if(attr)
		{
			LoadInfo(attr->value);
		}
	}

	stream->close();
}
ISceneNode* SceneManager::createSceneNode(const core::string&name, ISceneNode* parent)
{
	core::string strName=name;
	if(strName==mT(""))
	{
		strName=mT("SceneNode#")+core::StringConverter::toString(++m_nameIDGenerator);
	}
	/*
	SceneNodeMap::iterator it= m_Children.find(strName);
	if(it!=m_Children.end())
	{
		gSceneLoggerSystem.log(mT("CreateSceneNode: SceneNode with name:")+strName+mT(" is already exists in the scene manager"),ELL_WARNING,EVL_Heavy);
		//pick new name
		strName+=core::StringConverter::toString(++m_nameIDGenerator);
	}*/

	ISceneNode* node=new ISceneNode(strName,m_objectsID.GetNextID(),this);
	addSceneNode(node, parent);
	/*
	m_objectsID.AddObject(node,node->getID());
	m_Children[strName]=node;
	node->_OnAddedToSceneManager(this);

	if (parent)
		parent->addChild(node);
	else
		m_rootNode->addChild(node);*/
	return node;
}
const mchar* getZzipError(zzip_error_t zzipError) 
{
	static core::string errorMsg;
    switch (zzipError)
    {
    case ZZIP_NO_ERROR:
        break;
    case ZZIP_OUTOFMEM:
        errorMsg = mT("Out of memory.");
        break;            
    case ZZIP_DIR_OPEN:
    case ZZIP_DIR_STAT: 
    case ZZIP_DIR_SEEK:
    case ZZIP_DIR_READ:
        errorMsg = mT("Unable to read zip file.");
        break;            
    case ZZIP_UNSUPP_COMPR:
        errorMsg = mT("Unsupported compression format.");
        break;            
    case ZZIP_CORRUPTED:
        errorMsg = mT("Corrupted archive.");
        break;            
    default:
        errorMsg = mT("Unknown error.");
        break;            
    };

    return errorMsg.c_str();
}
void CSettingsFile::writeSettings(OS::IStream* file){

	OS::StreamWriter writer(file);

	TagMap::iterator itag=m_Tags.begin();
	for(;itag!=m_Tags.end();++itag)
	{
		writer.writeString(itag->second->tagName.c_str());
		writer.writeString(mT("{\n"));
		SConfigTag::AttributesIT it=itag->second->m_attrSet.begin();
		for(;it!=itag->second->m_attrSet.end();++it){
// 			SConfigTag::MultiValuesIT itv=it->second.begin();
 			core::string s;
//			for(;itv!=it->second.end();itv++){
				s=mT("\t")+it->first+mT("\t\"")+it->second+mT("\"\n");
				writer.writeString(s);
//			}
		}
		writer.writeString(mT("}\n"));
	}


	file->close();

}
stackDump::stackDump(){

	if( hDbgHelpDll == 0 )
	{
		// If you do not get symbols in the stack trace, it could be because the version of dbghelp.dll
		// in your path is too old. You can download a new one from
		// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/dbghelp_versions.asp
		// And set an explicit path for the dll to load
		// extern const char* hkStackTracerDbghelpPath;
		// hkStackTracerDbghelpPath = "C:\\Program Files\\Debugging Tools for Windows\\dbghelp.dll";
		hDbgHelpDll = LoadLibrary(hkStackTracerDbghelpPath);
		FATAL_ERROR(!hDbgHelpDll, mT("Unable to load dbghelp.dll"));

		s_DllReferences = 1;
		LOAD_FUNCTION(SymInitialize);
		LOAD_FUNCTION(SymGetOptions);
		LOAD_FUNCTION(SymSetOptions);
		LOAD_FUNCTION(SymGetSymFromAddr);
		LOAD_FUNCTION(StackWalk64);
		LOAD_FUNCTION(SymFunctionTableAccess64);
		LOAD_FUNCTION(SymGetModuleBase64);
		LOAD_FUNCTION(SymGetLineFromAddr64);

		DWORD symOptions = pSymGetOptions();
		symOptions |= SYMOPT_LOAD_LINES | SYMOPT_DEBUG;
		pSymSetOptions( symOptions );

		BOOL initsymbols = pSymInitialize( GetCurrentProcess(), 0, TRUE);
		FATAL_ERROR(!initsymbols,mT(""));
	}
	else
	{
		s_DllReferences += 1;
	}
}
core::string DateTime::ToString(const DateTime& dt)
{
	std::ostringstream stream;
	stream << dt.GetDate().GetDay() << mT("/") << dt.GetDate().GetMonth() << mT("/") << dt.GetDate().GetYear();
	stream << "-";
	stream << dt.GetTime().GetHour() << mT(":") << dt.GetTime().GetMinute() << mT(":") << dt.GetTime().GetSecond();
	return stream.str();
}
IResource::IResource()
:m_manager(0),m_name(mT("")),m_group(mT("")),m_loadRequest(0)
{
	m_lastAccess=time(0);
	m_size=0;
	m_loadState=LoadState_Unloaded;
	m_usedCounter=0;
}
xml::XMLElement* FuzzyVeryHedge::exportXML(xml::XMLElement*elem)
{
	xml::XMLElement*e=new xml::XMLElement(mT("Term"));
	elem->addSubElement(e);
	e->addAttribute(mT("Type"),mT("very"));
	m_term->exportXML(e);
	return e;
}
xml::XMLElement* FuzzyNotOpt::exportXML(xml::XMLElement*elem)
{
	xml::XMLElement*e=new xml::XMLElement(mT("Term"));
	elem->addSubElement(e);
	e->addAttribute(mT("Type"),mT("not"));
	m_term->exportXML(e);
	return e;
}
ToonPP::ToonPP(IVideoDevice*dev,const math::vector2d &size){
	m_device=dev;

	m_toonShader=gShaderResourceManager.getResource(mT("Toon/Outline"));

	m_toonTex=dev->createTexture2D(size,video::EPixel_X8R8G8B8);

	m_toonRT=dev->createRenderTarget(mT("ToonPP_FinalRT"),m_toonTex,0,0,0);
}
Exemple #17
0
FGForce::FGForce(FGFDMExec *FDMExec) :
                 fdmex(FDMExec),
                 ttype(tNone)
{
  mT(1,1) = 1; //identity matrix
  mT(2,2) = 1;
  mT(3,3) = 1;

  Debug(0);
}
IGameComponent* GameComponentCreator::CreateObject(const core::string&name,GameEntityManager*mngr)
{
	IGameComponentFactory* f= GetFactory(name);
	if(!f)
	{
		gLogManager.log(mT("Game Component Factory with type: '")+name+mT("' was not found"),ELL_WARNING,EVL_Normal);
		return 0;
	}
	return f->CreateComponent(mngr);
}
Exemple #19
0
void FGForce::UpdateCustomTransformMatrix(void)
{
  double cp,sp,cr,sr,cy,sy;
  double srsp, crcy, crsy;

  cp=cos(vOrient(ePitch)); sp=sin(vOrient(ePitch));
  cr=cos(vOrient(eRoll));  sr=sin(vOrient(eRoll));
  cy=cos(vOrient(eYaw));   sy=sin(vOrient(eYaw));

  srsp = sr*sp;
  crcy = cr*cy;
  crsy = cr*sy;

  mT(1,1) =  cp*cy;
  mT(2,1) =  cp*sy;
  mT(3,1) = -sp;

  mT(1,2) = srsp*cy - crsy;
  mT(2,2) = srsp*sy + crcy;
  mT(3,2) = sr*cp;

  mT(1,3) = crcy*sp + sr*sy;
  mT(2,3) = crsy*sp - sr*cy;
  mT(3,3) = cr*cp;
}
CameraNode* SceneManager::createCamera(const core::string&name, ISceneNode* parent)
{
	core::string strName=name;
	if(strName==mT(""))
	{
		strName=mT("CameraNode#")+core::StringConverter::toString(++m_nameIDGenerator);
	}
	CameraNode* node=new CameraNode(strName,m_objectsID.GetNextID(),this);
	addSceneNode(node, parent);
	return node;
}
WinErrorDialog::WinErrorDialog(){
#ifndef MRAY_WinApp_DLL_EXPORT
	m_hInstance=GetModuleHandle(0);
#else 
#	ifdef _DEBUG
	m_hInstance=GetModuleHandle(mT("mrayWinApp_d.dll"));
#	else
	m_hInstance=GetModuleHandle(mT("mrayWinApp.dll"));
#	endif
#endif
}
bool CZipArchive::checkForError(int err,const mchar*desc){
	if(err==ZZIP_NO_ERROR)return false;
	core::string error_str=mT("CZipArchive- [");
	error_str+=desc;
	error_str+=mT("] :");
	error_str+= getZzipError((zzip_error_t)err);
	gLogManager.log(error_str.c_str(),ELL_WARNING);

	return true;

}
core::string CTime::ToString(const CTime& time, bool _24Format, bool seconds)
{
	std::stringstream stream;
	stream << std::setfill('0') << std::setw(2) << time.GetHour(_24Format);
	stream << mT(":") << std::setfill('0') << std::setw(2) << time.GetMinute();
	if(seconds)
		stream << mT(":") << std::setfill('0') << std::setw(2) << time.GetSecond();
	if (!_24Format)
		stream << "-" <<  (time.IsAM() ? "AM" : "PM");
	return stream.str();
}
BloomPP::BloomPP(video::IVideoDevice*dev,const math::vector2d &size):IPostProcessing(dev)
{
	m_finalRT=dev->createRenderTarget(mT("BloomPP_FinalRT"),size,video::EPixelFormat::EPixel_Float16_RGB,0);
	m_blurRT=dev->createRenderTarget(mT("BloomPP_BlurRT"),size/4,video::EPixelFormat::EPixel_Float16_RGB,0);

	m_callback=new PostprocessingShaderConstants();

	m_uBlur=gShaderResourceManager.loadShader("HBlur.cg","HBlur.cg",mT("cg"));
	m_vBlur=gShaderResourceManager.loadShader("VBlur.cg","VBlur.cg",mT("cg"));
	m_final=gShaderResourceManager.loadShader("BFinal.cg","BFinal.cg",mT("cg"));
}
FreeImageLoader::FreeImageLoader(const core::string& ext,FREE_IMAGE_FORMAT ftType):
	m_ext(ext),m_FTType(ftType)
{
	m_isDummy=false;

	FreeImageCodec::IncreaseRef();
	if(FreeImageCodec::GetRefCount()==1){
		initialize();
	}

	m_extDesc= mT("FreeImage Loader '")+m_ext+mT("'");
}
ToneMappingPP::ToneMappingPP(IVideoDevice*dev,const math::vector2d &size){

	exposure=0.6;

	device=dev;

	m_toneMapping=gShaderResourceManager.getResource(mT("PostProcess/ToneMapping"));

	m_tu=new video::TextureUnit();
	m_tu->SetTexture(device->createTexture2D(size,video::EPixel_Float16_RGB));
	m_rt=device->createRenderTarget(mT("ToneMappingPP_RT"),m_tu->GetTexture(),0,0,0);

}
BrightFilterPP::BrightFilterPP(IVideoDevice*dev,const math::vector2d &size){

	exposure=0.6;
	threshold=0.7;

	device=dev;

	m_brightFilter=gShaderResourceManager.getResource(mT("PostProcess/BrightFilter"));

	m_tu=new video::TextureUnit();
	m_tu->SetTexture(device->createTexture2D(size,video::EPixel_Float16_RGB));
	m_rt=device->createRenderTarget(mT("BrightFilterPP_RT"),m_tu->GetTexture(),0,0,0);

}
Exemple #28
0
// Compute the derived values if required ...
void FGQuaternion::ComputeDerivedUnconditional(void) const
{
  mCacheValid = true;

  double q0 = data[0]; // use some aliases/shorthand for the quat elements.
  double q1 = data[1];
  double q2 = data[2];
  double q3 = data[3];

  // Now compute the transformation matrix.
  double q0q0 = q0*q0;
  double q1q1 = q1*q1;
  double q2q2 = q2*q2;
  double q3q3 = q3*q3;
  double q0q1 = q0*q1;
  double q0q2 = q0*q2;
  double q0q3 = q0*q3;
  double q1q2 = q1*q2;
  double q1q3 = q1*q3;
  double q2q3 = q2*q3;
  
  mT(1,1) = q0q0 + q1q1 - q2q2 - q3q3; // This is found from Eqn. 1.3-32 in
  mT(1,2) = 2.0*(q1q2 + q0q3);         // Stevens and Lewis
  mT(1,3) = 2.0*(q1q3 - q0q2);
  mT(2,1) = 2.0*(q1q2 - q0q3);
  mT(2,2) = q0q0 - q1q1 + q2q2 - q3q3;
  mT(2,3) = 2.0*(q2q3 + q0q1);
  mT(3,1) = 2.0*(q1q3 + q0q2);
  mT(3,2) = 2.0*(q2q3 - q0q1);
  mT(3,3) = q0q0 - q1q1 - q2q2 + q3q3;

  // Since this is an orthogonal matrix, the inverse is simply the transpose.

  mTInv = mT;
  mTInv.T();
  
  // Compute the Euler-angles

  mEulerAngles = mT.GetEuler();
  
  // FIXME: may be one can compute those values easier ???
  mEulerSines(ePhi) = sin(mEulerAngles(ePhi));
  // mEulerSines(eTht) = sin(mEulerAngles(eTht));
  mEulerSines(eTht) = -mT(1,3);
  mEulerSines(ePsi) = sin(mEulerAngles(ePsi));
  mEulerCosines(ePhi) = cos(mEulerAngles(ePhi));
  mEulerCosines(eTht) = cos(mEulerAngles(eTht));
  mEulerCosines(ePsi) = cos(mEulerAngles(ePsi));
}
void CSkyBoxDlg::OnExportLevelXML(xml::XMLElement*e)
{
	xml::XMLElement*elem=new xml::XMLElement(mT("Skies"));
	e->addSubElement(elem);
	std::map<core::string,SkyInfo>::iterator it=m_skiesInfo.begin();
	for(;it!=m_skiesInfo.end();++it)
	{
		xml::XMLElement* info=new xml::XMLElement(mT("SkyInfo"));
		SkyInfo&ifo=it->second;
		elem->addSubElement(info);
		elem->addAttribute(mT("Name"),ifo.name);
		elem->addAttribute(mT("Path"),ifo.path);
		elem->addAttribute(mT("Ext"),ifo.ext);
	}
}
void JFMainMenuState::_initLayout()
{
	GUI::IGUIPanelElement* root=new GUI::IGUIPanelElement(mray::GUID(""),m_guiManager);
	root->SetSize(JFEnvData::App->GetRenderWindow()->GetSize());

	GUI::IGUIButton* btn=(GUI::IGUIButton*)m_guiManager->CreateElement(GUID(mT("Button")));
	btn->SetPosition(math::vector2d(100,100));
	btn->SetSize(math::vector2d(200,50));

	btn->SetText(core::UTFString(mT("Start Game")));
	btn->OnClick+=newClassDelegate2(mT("StartGame"),this,&JFMainMenuState::OnStartGameBtn);

	root->AddElement(btn);
	m_guiManager->SetRootElement(root);
}