void 
MaterialPreviewDialog::InitPreviewGrids(void)
{

	wxFlexGridSizer *item0 = new wxFlexGridSizer( 6, 0, 0 );

	typedef std::list<Ogre::String> MaterialFileNameList;
	MaterialFileNameList materialFileNameList;

	Ogre::FileInfoListPtr fileInfoList =
		Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
		Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		"*.material");
	for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
	{
		if ( it->archive->getName() == EFFECT_PATH)
		{
			materialFileNameList.push_back(it->filename);
		}
	}

	wxComboBox *matCombo = mParentDialog->mMaterialComboBox;
	assert (matCombo);

	for ( int i=0; i<matCombo->GetCount(); ++i )
	{
		Ogre::String matName = matCombo->GetString(i);

		Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(matName);			

		if (mat.isNull())
		{
		}
		else
		{
			size_t numOfTex = mat->getTechnique(0)->getPass(0)->getNumTextureUnitStates();
			if (numOfTex > 0)
			{
				Ogre::String texName = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getTextureName();
				if (texName.empty() == false)
				{
					wxBoxSizer *item1 = new wxBoxSizer( wxVERTICAL );

					wxStaticBitmap *item2 = new wxStaticBitmap( this, ID_STATICBITMAP, TexturePreview( 0 ), wxDefaultPosition, wxSize(64,64) );
					item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );

					wxStaticText *item3 = new wxStaticText( this, ID_TEXT_MATERIAL_NAME, _("text"), wxDefaultPosition, wxDefaultSize, 0 );
					item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );

					wxButton *item4 = new wxButton( this, ID_BUTTON_USE, _("Use"), wxDefaultPosition, wxDefaultSize, 0 );
					item1->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );

					item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );

					buildPreviewBitmap( texName );
					item2->SetBitmap(mCurrentPreviewImage);
					item3->SetLabel(texName.c_str());
					item4->SetLabel(matName.c_str());
				}
			}
		}
	}

	this->SetSizer( item0 );
	item0->SetSizeHints( this );
}
예제 #2
0
 //---------------------------------------------------------------------
 bool FileSystemLayer::createDirectory(const Ogre::String& path)
 {
     return !_mkdir(path.c_str()) || errno == EEXIST; // Use CRT API rather than CreateDirectoryA to pass Windows Store validation
 }
예제 #3
0
 //---------------------------------------------------------------------
 bool FileSystemLayer::renameFile(const Ogre::String& oldname, const Ogre::String& newname)
 {
     if(fileExists(oldname) && fileExists(newname))
         removeFile(newname);
     return !rename(oldname.c_str(), newname.c_str()); // Use CRT API to pass Windows Store validation
 }
bool NetworkManager::start(bool isServer, Ogre::ushort serverPort, Ogre::String serverIP)	
{
	mServer = isServer; 	
	RakNet::Time waitTime = 10000;
	RakNet::Time prevTime = 0;
	if(isServer)
	{
		Ogre::LogManager::getSingletonPtr()
			->logMessage(RealToys::logMessagePrefix + "Starting network as " 
			+ "server on port " + Ogre::StringConverter::toString(serverPort) );
	}
	else
	{
		Ogre::LogManager::getSingletonPtr()
			->logMessage(RealToys::logMessagePrefix + "Starting network as " 
			+ "client to server " + serverIP + " on port " + 
			Ogre::StringConverter::toString(serverPort) );
	}

	mAirplaneManager = AirplaneManager::getSingletonPtr();

	upAndRunning = false;
	mConnectAtemp = false;
	mWaitForPong = false;

	RakNet::SocketDescriptor sd;
	mRakPeer = RakNet::RakPeerInterface::GetInstance();
	
	if(isServer)
	{
		sd.port = serverPort;
		mReplicaManager = RT_ReplicaManager(mSceneMgr, mWorld);
	}
	else
	{
		sd.port = 0;
		mReplicaManager = RT_ReplicaManager(mSceneMgr);
	}
	mReplicaManager.SetDefaultPacketReliability(UNRELIABLE_SEQUENCED);
	mReplicaManager.SetDefaultPacketPriority(HIGH_PRIORITY);
	

	// The network ID authority is the system that creates the common numerical identifier used to lookup pointers (the server here).
	//mNetworkIdManager.SetIsNetworkIDAuthority(isServer);
	// ObjectMemberRPC, AutoRPC for objects, and ReplicaManager3 require that you call SetNetworkIDManager()
	mReplicaManager.SetNetworkIDManager(&mNetworkIdManager);

	// Setup RPC3 system and classes 
	//mRPCIdManager.SetIsNetworkIDAuthority(true);
	mRPC3Inst.SetNetworkIDManager(&mRPCIdManager);
	
	this->SetNetworkIDManager(&mRPCIdManager);

	RakNet::NetworkID id0 = 0;
	this->SetNetworkID(id0);
	RPC3_REGISTER_FUNCTION(&mRPC3Inst, &NetworkManager::createAirplane);
	RPC3_REGISTER_FUNCTION(&mRPC3Inst, &NetworkManager::processAirplaneInput);
	
		
	// Start RakNet, up to 32 connections if the server
	if(!doStartup(isServer, sd))
	{
		return false;
	}	
	
	mRakPeer->AttachPlugin(&mReplicaManager);
	mRakPeer->AttachPlugin(&mRPC3Inst);

	mNetworkID = mRakPeer->GetGuidFromSystemAddress(RakNet::UNASSIGNED_SYSTEM_ADDRESS);

	// The server should allow systems to connect. Clients do not need to unless we want to transmit messages directly between systems or to use RakVoice
	if (isServer)
	{
//		mRakPeer->SetMaximumIncomingConnections(RealToys::maxClients-1);
		mRakPeer->SetMaximumIncomingConnections(0);		//will not accept connections until setCurrentMap is called
		//mNetworkID = RealToys::serverPlayerID;		
	}
	else
	{
		if(serverIP == "255.255.255.255")
		{
			if(mRakPeer->Ping( serverIP.c_str(), serverPort, true, 0 ) )
			{
				Ogre::LogManager::getSingletonPtr()
					->logMessage(RealToys::logMessagePrefix + "Client will try to search for servers on LAN");
				mWaitForPong = true;
			}
			else
			{
				Ogre::LogManager::getSingletonPtr()
					->logMessage(RealToys::logMessagePrefix + "Client PING failed");
				return false;
			}
		}
		else
		{
			if(!doConnect(serverIP, serverPort))
			{
				return false;
			}
		}		
	}

	mIsStarted = true;
	if(isServer)
	{
		upAndRunning = true;
	}
	else
	{
		Ogre::LogManager::getSingletonPtr()
			->logMessage(RealToys::logMessagePrefix + "Trying to connect to server" );
		//"update" until receives a package saying if it was a successful connection or not
		prevTime = RakNet::GetTime();		
		while(!upAndRunning && (mConnectAtemp || mWaitForPong) && waitTime > 0)
		{
			update();
			waitTime-=(RakNet::GetTime()-prevTime);
			prevTime = RakNet::GetTime();
		}
	}

	
	if(upAndRunning)
	{
		mAirplaneManager->setPlayerID(mNetworkID);
		ScoresManager::getSingletonPtr()->setLocalSysAddress(mNetworkID);

		Ogre::String addrs( mNetworkID.ToString() );
		if(mServer)
			addrs += " (server)";
		Ogre::LogManager::getSingletonPtr()
			->logMessage(RealToys::logMessagePrefix + "Network started " + addrs);
	}
	else
	{
		Ogre::LogManager::getSingletonPtr()
			->logMessage(RealToys::logMessagePrefix + "Network failed to start" );
	}
	return upAndRunning;
}
예제 #5
0
void GameScriptParser::callLuaScriptFunction(const Ogre::String &func) {
    lua_getglobal(lua_state, func.c_str()); // function to be called, without parameters and without return value!
    lua_call(lua_state,0, 0);
}
예제 #6
0
wxPGConstants * WXEffectEditDialog::PopulateConstants(const Ogre::String& type)
{
	size_t id = reinterpret_cast<size_t>(&type);
	wxPGConstants* constants = wxPropertyGrid::GetConstantsArray(id);

	if (constants)
	{
		for (std::list<wxPGConstants*>::iterator it = mConstantList.begin(); it != mConstantList.end(); ++it)
		{
			if (constants == *it)
			{
				if (constants->UnRef())
					delete constants;

				mConstantList.erase(it);

				break;
			}
		}
	}
//	if (!constants)
//	{
		constants = wxPropertyGrid::CreateConstantsArray(id);

		if ( type == "Material" )
		{
			typedef std::list<Ogre::String> MaterialFileNameList;
			MaterialFileNameList materialFileNameList;

			Ogre::FileInfoListPtr fileInfoList =
				Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
				Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
				"*.material");
			for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
			{
				if ( it->archive->getName() == EFFECT_PATH)
				{
					materialFileNameList.push_back(it->filename);
				}
			}
			// 第一个为空,表示设置这个元素的材质是用原mesh的材质
			constants->Add("none");

			Ogre::ResourceManager::ResourceMapIterator resourceMapIterator = Ogre::MaterialManager::getSingleton().getResourceIterator();

			while ( resourceMapIterator.hasMoreElements() )
			{				
				Ogre::String matName = resourceMapIterator.peekNextValue()->getName();

				for ( MaterialFileNameList::iterator i = materialFileNameList.begin();
					i != materialFileNameList.end(); ++i )
				{
					if ( *i == resourceMapIterator.peekNextValue()->getOrigin() )
					{
						constants->Add(matName.c_str());
						break;
					}
				}

				resourceMapIterator.moveNext();
			}
		}
		else if ( type == "MeshName" )
		{			
			constants->Add("none");

			Ogre::FileInfoListPtr fileInfoList =
				Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(
				Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
				"*.mesh");
			for (Ogre::FileInfoList::const_iterator it = fileInfoList->begin(); it != fileInfoList->end(); ++it)
			{
				if ( it->archive->getName() == EFFECT_PATH)
				{
					const Fairy::String& name = it->filename;
					constants->Add(name.c_str());
				}
			}
		}	
		else if ( type == "ParticleSystem" )
		{
			Ogre::ParticleSystemManager::ParticleSystemTemplateIterator iterator = Ogre::ParticleSystemManager::getSingleton().getTemplateIterator();

			while ( iterator.hasMoreElements() )
			{
				// 获取到粒子系统的名称
				Ogre::String parName = iterator.peekNextKey();

				constants->Add(parName.c_str());

				// 使iterator往后移
				iterator.moveNext();
			}
		}

		registerConstants(constants);
//	}

	return constants;
}
예제 #7
0
//-----------------------------------------------------------------------------
int COFSSceneSerializer::Export(bool SaveAs, Ogre::String exportfile)
{
    OgitorsRoot *ogRoot = OgitorsRoot::getSingletonPtr();
    OgitorsSystem *mSystem = OgitorsSystem::getSingletonPtr();
    OFS::OfsPtr& mFile = ogRoot->GetProjectFile();

    PROJECTOPTIONS *pOpt = ogRoot->GetProjectOptions();

    bool forceSave = false;
    Ogre::String fileLocation = ogRoot->GetProjectFile()->getFileSystemName();
    Ogre::String fileName = "";

    if (!exportfile.empty())
    {
        // Save location was passed, so use this filename
        fileLocation = exportfile;
    }

    if (SaveAs)
    {
        // Saving at a different location
        UTFStringVector extlist;

        if( mFile->getFileSystemType() == OFS::OFS_PACKED )
        {
            extlist.push_back(OTR("Ogitor File System File"));
            extlist.push_back("*.ofs");
        }
        else
        {
            extlist.push_back(OTR("Ogitor Scene File"));
            extlist.push_back("*" + Globals::OGSCENE_FORMAT_EXTENSION);
        }

        Ogre::String newfileLocation = mSystem->DisplaySaveDialog(OTR("Save As"), extlist, fileLocation);
        if(newfileLocation == "") 
            return SCF_CANCEL;

        mSystem->SetSetting("system", "oldOpenPath", newfileLocation);

        if(Ogre::StringUtil::match(newfileLocation, fileLocation, false))
        {
            SaveAs = false;
        } 
        else 
        {
            forceSave = true;
            fileLocation = newfileLocation;
        }
    }

    Ogre::String filePath = OgitorsUtils::ExtractFilePath(fileLocation);
    fileName = OgitorsUtils::ExtractFileName(fileLocation);

    // Change the project directory to the new path
    pOpt->ProjectDir = filePath;

    if(fileName.substr(fileName.size() - 4, 4) != ".ofs")
        fileLocation = filePath;

    int dotpos = fileName.find_last_of(".");
    if (dotpos > 0)
    {
        fileName.erase(dotpos, fileName.length() - dotpos);
    }

    if (SaveAs && mFile->moveFileSystemTo(fileLocation.c_str()) != OFS::OFS_OK)
    {
        return SCF_ERRFILE;
    }

    if (SaveAs)
    {
        mFile->deleteFile((pOpt->ProjectName + Globals::OGSCENE_FORMAT_EXTENSION).c_str());
        pOpt->ProjectName = fileName;
    }

    if (_writeFile(fileName + Globals::OGSCENE_FORMAT_EXTENSION, forceSave) != SCF_OK)
    {
        return SCF_ERRFILE;
    }

    return SCF_OK;
}
예제 #8
0
bool FileExists(Ogre::String const & path)
{
	return FileExists(path.c_str());
}
예제 #9
0
bool FolderExists(Ogre::String const & path)
{
	return FolderExists(path.c_str());
}
예제 #10
0
void MilkshapePlugin::doExportAnimations(msModel* pModel, Ogre::SkeletonPtr& ogreskel)
{

    Ogre::LogManager& logMgr = Ogre::LogManager::getSingleton();
    std::vector<SplitAnimationStruct> splitInfo;
    Ogre::String msg;

    int numFrames = msModel_GetTotalFrames(pModel);
    msg = "Number of frames: " + Ogre::StringConverter::toString(numFrames);
    logMgr.logMessage(msg);

    if (splitAnimations)
    {
        // Explain
        msg = "You have chosen to create multiple discrete animations by splitting up the frames in "
            "the animation sequence. In order to do this, you must supply a simple text file "
            "describing the separate animations, which has a single line per animation in the format: \n\n" 
            "startFrame,endFrame,animationName\n\nFor example: \n\n"
            "1,20,Walk\n21,35,Run\n36,40,Shoot\n\n" 
            "..creates 3 separate animations (the frame numbers are inclusive)."
            "You must browse to this file in the next dialog.";
        MessageBox(0,msg.c_str(), "Splitting Animations",MB_ICONINFORMATION | MB_OK);
        // Prompt for a file which contains animation splitting info
        OPENFILENAME ofn;
        memset (&ofn, 0, sizeof (OPENFILENAME));
        
        char szFile[MS_MAX_PATH];
        char szFileTitle[MS_MAX_PATH];
        char szDefExt[32] = "skeleton";
        char szFilter[128] = "All Files (*.*)\0*.*\0\0";
        szFile[0] = '\0';
        szFileTitle[0] = '\0';

        ofn.lStructSize = sizeof (OPENFILENAME);
        ofn.lpstrDefExt = szDefExt;
        ofn.lpstrFilter = szFilter;
        ofn.lpstrFile = szFile;
        ofn.nMaxFile = MS_MAX_PATH;
        ofn.lpstrFileTitle = szFileTitle;
        ofn.nMaxFileTitle = MS_MAX_PATH;
        ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
        ofn.lpstrTitle = "Open animation split configuration file";

        if (!::GetOpenFileName (&ofn))
        {
            msg = "Splitting aborted, generating a single animation called 'Default'";
            MessageBox(0, msg.c_str(), "Info", MB_OK | MB_ICONWARNING);
            SplitAnimationStruct split;
            split.start = 1;
            split.end = numFrames;
            split.name = "Default";
            splitInfo.push_back(split);
        }
        else
        {
            // Read file
            Ogre::String sline;
            char line[256];
            SplitAnimationStruct newSplit;

            std::ifstream istr;
            istr.open(szFile);

            while (!istr.eof())
            {
                istr.getline(line, 256);
                sline = line;

                // Ignore blanks & comments
                if (sline == "" || sline.substr(0,2) == "//")
                    continue;

                // Split on ','
                std::vector<Ogre::String> svec = Ogre::StringUtil::split(line, ",\n");

                // Basic validation on number of elements
                if (svec.size() != 3)
                {
                    MessageBox(0, "Warning: corrupt animation details in file. You should look into this. ",
                        "Corrupt animations file", MB_ICONWARNING | MB_OK);
                    continue;
                }
                // Remove any embedded spaces
                Ogre::StringUtil::trim(svec[0]);
                Ogre::StringUtil::trim(svec[1]);
                Ogre::StringUtil::trim(svec[2]);
                // Create split info
                newSplit.start = atoi(svec[0].c_str());
                newSplit.end = atoi(svec[1].c_str());
                newSplit.name = svec[2];
                splitInfo.push_back(newSplit);

            }


        }

    }
    else
    {
        // No splitting
        SplitAnimationStruct split;
        split.start = 1;
        split.end = numFrames;
        split.name = "Default";
        splitInfo.push_back(split);
    }

    // Get animation length
    // Map frames -> seconds, this can be changed in speed of animation anyway



    int numBones = msModel_GetBoneCount(pModel);
    unsigned int frameTime;
    float realTime;

    std::vector<SplitAnimationStruct>::iterator animsIt;
    for (animsIt = splitInfo.begin(); animsIt != splitInfo.end(); ++animsIt)
    {
        SplitAnimationStruct& currSplit = *animsIt;

        // Create animation
        frameTime = currSplit.end - currSplit.start;
        realTime = frameTime / fps;
        Ogre::LogManager::getSingleton().stream()
            << "Trying to create Animation object for animation "
            <<  currSplit.name << " For Frames " << currSplit.start << " to "
            << currSplit.end << " inclusive. ";

        Ogre::LogManager::getSingleton().stream()
            << "Frame time = "
            << frameTime << ", Seconds = " << realTime;

        Ogre::Animation *ogreanim =
            ogreskel->createAnimation(currSplit.name, realTime);
        logMgr.logMessage("Animation object created.");

        int i;
        // Create all the animation tracks
        for (i = 0; i < numBones; ++i)
        {

            msBone* bone = msModel_GetBoneAt(pModel, i);
            Ogre::Bone* ogrebone = ogreskel->getBone(bone->szName);

            // Create animation tracks
            msg = "Creating AnimationTrack for bone " + Ogre::StringConverter::toString(i);
            logMgr.logMessage(msg);

            Ogre::NodeAnimationTrack *ogretrack = ogreanim->createNodeTrack(i, ogrebone);
            logMgr.logMessage("Animation track created.");

            // OGRE uses keyframes which are both position and rotation
            // Milkshape separates them, but never seems to use the ability to
            // have a different # of pos & rot keys

            int numKeys = msBone_GetRotationKeyCount(bone);

            msg = "Number of keyframes: " + Ogre::StringConverter::toString(numKeys);
            logMgr.logMessage(msg);

            int currKeyIdx;
            msPositionKey* currPosKey;
            msRotationKey* currRotKey;
            for (currKeyIdx = 0; currKeyIdx < numKeys; ++currKeyIdx )
            {
                currPosKey = msBone_GetPositionKeyAt(bone, currKeyIdx);
                currRotKey = msBone_GetRotationKeyAt(bone, currKeyIdx);

                // Make sure keyframe is in current time frame (for splitting)
                if (currRotKey->fTime >= currSplit.start && currRotKey->fTime <= currSplit.end)
                {

                    msg = "Creating KeyFrame #" + Ogre::StringConverter::toString(currKeyIdx)
                        + " for bone #" + Ogre::StringConverter::toString(i);
                    logMgr.logMessage(msg);
                    // Create keyframe
                    // Adjust for start time, and for the fact that frames are numbered from 1
                    frameTime = currRotKey->fTime - currSplit.start;
                    realTime = frameTime / fps;
                    Ogre::TransformKeyFrame *ogrekey = ogretrack->createNodeKeyFrame(realTime);
                    logMgr.logMessage("KeyFrame created");

                    Ogre::Vector3 kfPos;
                    // Imported milkshape animations may not have positions 
                    // for all rotation keys
                    if ( currKeyIdx < bone->nNumPositionKeys ) {
                        kfPos.x = currPosKey->Position[0];
                        kfPos.y = currPosKey->Position[1];
                        kfPos.z = currPosKey->Position[2];
                    }
                    else {
                        kfPos.x = bone->Position[0];
                        kfPos.y = bone->Position[1];
                        kfPos.z = bone->Position[2];
                    }
                    Ogre::Quaternion qx, qy, qz, kfQ;

                    // Milkshape translations are local to own orientation, not parent
                    kfPos = ogrebone->getOrientation() * kfPos;

                    ogrekey->setTranslate(kfPos);
                    qx.FromAngleAxis(Ogre::Radian(currRotKey->Rotation[0]), Ogre::Vector3::UNIT_X);
                    qy.FromAngleAxis(Ogre::Radian(currRotKey->Rotation[1]), Ogre::Vector3::UNIT_Y);
                    qz.FromAngleAxis(Ogre::Radian(currRotKey->Rotation[2]), Ogre::Vector3::UNIT_Z);
                    kfQ = qz * qy * qx;
                    ogrekey->setRotation(kfQ);

                    Ogre::LogManager::getSingleton().stream()
                        << "KeyFrame details: Adjusted Frame Time=" << frameTime
                        << " Seconds: " << realTime << " Position=" << kfPos << " " 
                        << "Ms3d Rotation= {" << currRotKey->Rotation[0] << ", " 
                        << currRotKey->Rotation[1] << ", " << currRotKey->Rotation[2] 
                        << "} " << "Orientation=" << kfQ;
                } // keyframe creation

            } // keys
        } //Bones
    } // Animations




}
예제 #11
0
 void DebugWindow::setMessageText(const Ogre::String& text)
 {
     CeGuiString o(text.c_str());
     mMessageText->setText(o);
 }
예제 #12
0
//---------------------------------------------------------------------
bool FileSystemLayerImpl::createDirectory(const Ogre::String& path)
{
    return CreateDirectory(path.c_str(), NULL) != 0 ||
           GetLastError() == ERROR_ALREADY_EXISTS;
}
예제 #13
0
void SkillObjectEditor::OnSaveSkillObject(wxCommandEvent &e)
{
	if (NULL == mSkill)
	{
		wxMessageBox("您还没有创建技能,请创建后重试!","提示");
		return;
	}

	if(mSaveFileName == "")
	{
		SaveSkillDialog *dlg = new SaveSkillDialog(this, wxID_ANY,
			_("保存技能"), mSkill);

		bool ok = (dlg->ShowModal() == wxID_OK);
		if(ok)
		{
			mSaveFileName = dlg->mComboBox->GetValue().c_str();

			//判断文件名
			Ogre::StringVector strings = Ogre::StringUtil::split( mSaveFileName, "." );

			if (strings.size() != 2 || strings[1] != "skill")
			{
				mSaveFileName.append(".skill");
			}
			dlg->Destroy();
		}
		else
		{
			dlg->Destroy();
			return;

		}

	}
	//if(mbRecoverSave)
	//{
	//	char buf[256];
	//	sprintf(buf,"是否覆盖文件%s中的%s效果数据!",mSaveFileName.c_str(),mSkillTemplateName.c_str());
	//	RecoverSaveDialog* dlg = new RecoverSaveDialog(m_Frame,wxID_ANY,wxT("覆盖文件"));
	//	dlg->SetText(wxString(buf));


	//	if(wxID_OK == dlg->ShowModal())
	//	{
	//		mbRecoverSave = false;
	//		dlg->Destroy();
	//	}
	//	else
	//	{
	//		dlg->Destroy();
	//		return;
	//	}
	//}

	Ogre::StringVector templates;

	const Ogre::String fileName = mSaveFileName;


	Fairy::EffectManager::getSingleton().getSkillTemplatesFromScriptFile(fileName, templates);

	std::ofstream outFile;

	Ogre::String pathFileName = EFFECT_PATH+fileName;
	outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file

	if (!outFile.is_open())
	{
		return;
	}

	bool newTemplate = true;

	// 把所有的模板都写入该文件中
	for ( size_t i=0; i<templates.size(); ++i )
	{
		//	if (templates[i] != mEffect->getTemplateName())
		///{
		Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templates[i]);
		assert (skill);

		if (skill->getSkillName() == mSkillTemplateName)
		{
			saveSkill(mSkill, mSkillTemplateName, outFile );

			*skill = *mSkill;

			newTemplate = false;
		}
		else
			saveSkill(skill, skill->getSkillName(), outFile);

	}


	if (newTemplate)
	{
		saveSkill(mSkill, mSkillTemplateName, outFile );
		mSkill->setSkillName(mSkillTemplateName);
		Fairy::EffectManager::getSingleton().addToSkillTemplateScriptFileMap(mSkillTemplateName, fileName);
	}

	outFile.close();
}
예제 #14
0
void SkillObjectEditor::OnSaveAsSkillObject(wxCommandEvent &e)
{
	if (NULL == mSkill)
	{
		wxMessageBox("您还没有创建技能,请创建后重试!","提示");
		return;
	}

	SaveAsSkillDialog *dlg = new SaveAsSkillDialog(this, wxID_ANY,
		_("另存技能"), mSkill);

	bool ok = (dlg->ShowModal() == wxID_OK);
	if(ok)
	{
		Ogre::StringVector templates;

		Ogre::String fileName = dlg->mComboBox->GetValue().c_str();
		Ogre::String templateName = dlg->mTextCtrl->GetValue().c_str();

		if(templateName.length() == 0)
		{
			dlg->Destroy();
			return;
		}

		//判断文件名
		Ogre::StringVector strings = Ogre::StringUtil::split( fileName, "." );
		if (strings.size() != 2 || strings[1] != "skill")
		{
			fileName.append(".skill");
		}

		Fairy::EffectManager::getSingleton().getSkillTemplatesFromScriptFile(fileName, templates);

		std::ofstream outFile;

		Ogre::String pathFileName = EFFECT_PATH+fileName;
		outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file

		if (!outFile.is_open())
		{
			dlg->Destroy();
			return;
		}

		bool newTemplate = true;


		// 把所有的模板都写入该文件中
		for ( size_t i=0; i<templates.size(); ++i )
		{
			//	if (templates[i] != mEffect->getTemplateName())
			///{
			Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templates[i]);
			assert (skill);

			if (skill->getSkillName() == dlg->mTextCtrl->GetValue().c_str())
			{
				saveSkill(mSkill, dlg->mTextCtrl->GetValue().c_str(), outFile );


				newTemplate = false;
			}
			else
				saveSkill(skill, skill->getSkillName(), outFile);

		}

		if (newTemplate)
		{
			
			// 刷新EffectManager中的模板内容
			Fairy::Skill *skill = Fairy::EffectManager::getSingleton().getSkill(templateName);
			if (NULL == skill)
			{
				skill = Fairy::EffectManager::getSingleton().createSkillTemplate(templateName);
			}

			*skill = *mSkill;

			saveSkill(skill, templateName, outFile );

			Fairy::EffectManager::getSingleton().addToSkillTemplateScriptFileMap(templateName, fileName);

			InitSkillEditor(skill, templateName);
		}

		outFile.close();
	}

	wxBusyInfo* busyInfo = new wxBusyInfo(wxT("更新技能数据 ..."), this);
	m_Frame->GetSkillSelector()->Reload();
	delete busyInfo;

	dlg->Destroy();

}
예제 #15
0
void MenuSystem::processTextEvent(const OIS::KeyEvent& ke)
{
	switch(ke.key)
	{
	case OIS::KC_BACK:
		{
			if(currentText.size() > 0)
			{
				currentText.pop_back();
			}
		}
		break;
	case OIS::KC_RETURN:
		{
			// Send the current text over the network to either lobby or master
			// depending on which we are in.
			switch(currentMenu)
			{
			case LISTLOBBYMENU:
				{
					// Send the chat to the master
					Ogre::String builder = Ogre::String(name + ": " + currentText.c_str()); 
					clientPtr->SendMasterChat(builder.c_str());
					currentText.clear();
				}
				break;
			case LOBBYMENU:
				{
					// Send the chat the lobby
					Ogre::String builder = Ogre::String(name + ": " + currentText.c_str()); 
					clientPtr->SendLobbyChat(builder.c_str());
					currentText.clear();
				}
				break;
			case MATCHMENU:
				{
					// Send the chat to the match
					clientPtr->SendMatchChat(currentText.c_str());
				}
				break;
			}
		}
		break;
	default:
		{
			if(ke.text >= ' ' && ke.text <= 'z')
			{
				currentText.push_back(ke.text);
			}
		}
	}

	// Depending on which tray is active send the text to different text boxes
	switch(currentMenu)
	{
	case STARTMENU:
		{
			ip->setText(currentText);
		}
		break;
	case LISTLOBBYMENU:
		{

		}
		break;
	case CREATELOBBYMENU:
		{
			lobbyName->setText(currentText);
		}
		break;
	case LOBBYMENU:
		{
			lobbyChatTextField->setText(currentText); 
		}
		break;
	case MATCHMENU:
		{

		}
		break;
	case RESULTMENU:		
		{

		}
		break;
	}
}
예제 #16
0
void
BrushSelector::ReloadTextureList(void)
{
	CatalogMap catalogMap;
	mCatalogMap.clear();

    if (!Ogre::ResourceGroupManager::getSingletonPtr())
        return;

    mBrushesTree->Freeze();

    mBrushesTree->DeleteAllItems();

	wxTreeItemId rootId = mBrushesTree->AddRoot(/*_("Brushes")*/wxT("画刷列表"));
 
    // 重新解析定义文件
    GetSceneManipulator()->reloadPaintInfo();

    const Fairy::TerrainPaintInfoContainer *paintInfoContainer = GetSceneManipulator()->getTerrainPaintInfoContainer();

    assert (paintInfoContainer);

    const Fairy::TextureInfoMap &textureInfoMap = paintInfoContainer->getTextureInfoMap();

	OwnerTexs ownerTextures;

	Fairy::TextureInfoMap::const_iterator it = textureInfoMap.begin();	

    // 遍历画刷数组
    while ( it != textureInfoMap.end() )
    {
        const Fairy::TextureInfos &textureInfos = it->second;
        
        // 遍历该画刷下的所有纹理
        for ( size_t i=0; i<textureInfos.size(); ++i )
        {
            // 取出所属的大纹理的名称
            Ogre::String ownerTexName = textureInfos[i].ownerTextureName;

			// 记录大纹理的名称
			ownerTextures.insert(OwnerTexs::value_type(ownerTexName, ownerTexName));

            // 如果该纹理名称中包含了/,说明它是在一个文件夹中的
            size_t pos = ownerTexName.find_last_of('/');

            // 在文件夹中
            if (pos != Ogre::String::npos)
            {
                // 先去除纹理文件名,剩下路径名
                ownerTexName.erase(pos+1);
                // 加上画刷的名称
                ownerTexName.append(textureInfos[i].brushName);
                wxTreeItemId id = mBrushesTree->AppendItem( GetParentId(ownerTexName, catalogMap), wxT(textureInfos[i].textureName) );
				
				mCatalogMap.insert(CatalogMap::value_type( textureInfos[i].textureName, id ));
            }
            else
            {
                Ogre::String brushName = textureInfos[i].brushName;
                // 如果是在根目录下,就直接用画刷名称来作为路径名
                wxTreeItemId id = mBrushesTree->AppendItem( GetParentId(brushName, catalogMap), wxT(textureInfos[i].textureName) );
				mCatalogMap.insert(CatalogMap::value_type( textureInfos[i].textureName, id ));
			}				
        }
        ++it;
    }

	wxString lostTexNames = wxEmptyString;
	for (OwnerTexs::iterator ownerIt = ownerTextures.begin(); ownerIt != ownerTextures.end(); ++ownerIt)
	{
		Ogre::String texName = ownerIt->first;

		Ogre::FileInfoListPtr fileInfoList =
			Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("Brushes",texName);
		
		Ogre::FileInfoList::const_iterator itBegin = fileInfoList->begin();
		Ogre::FileInfoList::const_iterator itEnd = fileInfoList->end(); 
		if (itBegin == itEnd)
		{
			lostTexNames+=wxT("\n");
			lostTexNames+=texName.c_str();
			 continue;
		}

		Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(texName);

		if (!texture.isNull())
		{
			Ogre::TextureManager::getSingleton().remove(texName);
			Ogre::Image image;
			image.load(texName, Fairy::BRUSH_RESOURCE_GROUP_NAME);
			texture = Ogre::TextureManager::getSingleton()
				.loadImage(texName, Fairy::BRUSH_RESOURCE_GROUP_NAME, image);
		}
	}	

	if (!lostTexNames.empty())
	{
		wxMessageBox(wxT("以下贴图无法找到:")+lostTexNames);
	}

    mBrushesTree->Thaw();
}
예제 #17
0
void WXEffectEditDialog::OnSaveAsButtonDown(wxCommandEvent &e)
{
	SaveAsEffectDialog *dlg = new SaveAsEffectDialog(this, wxID_ANY,
		_("保存特效"), mEffect);

	bool ok = (dlg->ShowModal() == wxID_OK);
	if(ok)
	{
	//	bool append = true;
		// 如果模板名称不一样了,说明是要存成一个新的模板
		/*if ( dlg->mTextCtrl->GetValue().c_str() == mEffect->getTemplateName() )
		{
			append = false;
		}*/
		Ogre::StringVector templates;

		const Ogre::String fileName = dlg->mComboBox->GetValue().c_str();
		const Ogre::String templateName = dlg->mTextCtrl->GetValue().c_str();

		Ogre::StringVector strings = Ogre::StringUtil::split( fileName, "." );
		if ( (strings.size() != 2) || (strings[1] != "effect") )
		{
			wxMessageBox ( _("The Script File Name Is Wrong!") );
			return;
		}

		Fairy::EffectManager::getSingleton().getTemplatesFromScriptFile(fileName, templates);

		std::ofstream outFile;

		Ogre::String pathFileName = EFFECT_PATH+fileName;
		outFile.open ( pathFileName.c_str(), std::ios::out | std::ios::trunc ); // append to file

		if (!outFile.is_open())
		{
			return;
		}
		
		bool newTemplate = true;

		// 把所有的模板都写入该文件中
		for ( size_t i=0; i<templates.size(); ++i )
		{
		//	if (templates[i] != mEffect->getTemplateName())
			///{
				Fairy::Effect *effect = Fairy::EffectManager::getSingleton().getTemplate(templates[i]);
				assert (effect);

				if (effect->getTemplateName() == dlg->mTextCtrl->GetValue().c_str())
				{
					saveEffect(mEffect, dlg->mTextCtrl->GetValue().c_str(), outFile );

					*effect = *mEffect;

					newTemplate = false;
				}
				else
					saveEffect(effect, effect->getTemplateName(), outFile);
		
		}


		if (newTemplate)
		{
			saveEffect(mEffect, templateName, outFile );
			mEffect->setTemplateName(templateName);

			// 刷新EffectManager中的模板内容
			Fairy::Effect *effect = Fairy::EffectManager::getSingleton().createEffectTemplate(mEffect->getTemplateName());

			*effect = *mEffect;

			Fairy::EffectManager::getSingleton().addToEffectTemplateScriptFileMap(templateName, fileName);
		}

		outFile.close();
	}

	dlg->Destroy();
}
/** Function used to update the progress bar
@param percentComplete The percentage complete 0 - 100
@param msg The current task message
*/
void QtSpacescapeMainWindow::updateProgressBar(unsigned int percentComplete, const Ogre::String& msg)
{
    ui->mProgressDialog->setValue(percentComplete);
    ui->mProgressDialog->setLabelText(QString(msg.c_str()));
    qApp->processEvents();
}
    //---------------------------------------------------------------------
	const bool FileSystemLayerImpl::fileExists(const Ogre::String& path) const
	{
		return access(path.c_str(), R_OK) == 0;
	}
예제 #20
0
//-----------------------------------------------------------------------------------------
bool CTerrainGroupEditor::load(bool async)
{
    if(mLoaded->get())
        return true;

    if(!getParent()->load())
        return false;

    Ogre::ResourceGroupManager *mngr = Ogre::ResourceGroupManager::getSingletonPtr();
    Ogre::String terrainDir = OgitorsRoot::getSingletonPtr()->GetProjectOptions()->TerrainDirectory;
    terrainDir = mOgitorsRoot->GetProjectFile()->getFileSystemName() + "::/" + terrainDir + "/";

    mngr->addResourceLocation(terrainDir + "textures/normalheight", "Ofs", "TerrainGroupNormalHeight");
    mngr->initialiseResourceGroup("TerrainGroupNormalHeight");

    mngr->addResourceLocation(terrainDir + "textures/diffusespecular", "Ofs", "TerrainGroupDiffuseSpecular");
    mngr->initialiseResourceGroup("TerrainGroupDiffuseSpecular");

    mngr->addResourceLocation(terrainDir + "plants", "Ofs", "TerrainGroupPlants");
    mngr->initialiseResourceGroup("TerrainGroupPlants");

    OgitorsRoot::getSingletonPtr()->PrepareTerrainResources();
    OgitorsRoot::getSingletonPtr()->ReloadUserResources();

    mDecalFrustum = OGRE_NEW Ogre::Frustum();
    mDecalNode = getSceneManager()->getRootSceneNode()->createChildSceneNode("OgitorTerrainDecalNode");
    mDecalNode->setPosition(99999, -99999, 99999);
    mDecalNode->attachObject(mDecalFrustum);
    mDecalFrustum->setProjectionType(Ogre::PT_ORTHOGRAPHIC);
    mDecalNode->setOrientation(Ogre::Quaternion(Ogre::Degree(-90), Ogre::Vector3::UNIT_X));
    mDecalFrustum->setFOVy(Ogre::Degree(45));
    mDecalFrustum->setNearClipDistance(10);
    mDecalFrustum->setOrthoWindow(10, 10);
    mDecalFrustum->setVisible(false);
    mDecalTexture = Ogre::TextureManager::getSingletonPtr()->createManual("OgitorDecalTexture", "TerrainResources", 
        Ogre::TEX_TYPE_2D, 256, 256, 1, 1, Ogre::PF_A8R8G8B8, Ogre::TU_DYNAMIC_WRITE_ONLY, this);

    mBrushData = OGRE_ALLOC_T(float, BRUSH_DATA_SIZE * BRUSH_DATA_SIZE, Ogre::MEMCATEGORY_GEOMETRY);

    mTerrainGlobalOptions->setMaxPixelError(mMaxPixelError->get());
    mTerrainGlobalOptions->setCompositeMapSize(mCompositeMapTextureSize->get());
    mTerrainGlobalOptions->setCompositeMapDistance(mCompositeMapDistance->get());
    mTerrainGlobalOptions->setLightMapSize(mLightMapTextureSize->get());
    mTerrainGlobalOptions->setLayerBlendMapSize(mBlendMapTextureSize->get());
    mTerrainGlobalOptions->setUseVertexCompressionWhenAvailable(false);
    mTerrainGlobalOptions->setSkirtSize(mSkirtSize->get());
    mTerrainGlobalOptions->setUseRayBoxDistanceCalculation(mUseRayBoxDistanceCalculation->get());

    if(mMaterialGeneratorType->get() == 1)
    {
        Ogre::TerrainMaterialGeneratorPtr matGenPtr(OGRE_NEW Ogre::TerrainMaterialGeneratorC(this, mDecalFrustum));
        mTerrainGlobalOptions->setDefaultMaterialGenerator(matGenPtr);
        mMaxLayersAllowed = 10;
    }
    else
    {
        Ogre::TerrainMaterialGeneratorPtr matGenPtr(OGRE_NEW Ogre::TerrainMaterialGeneratorB(this, mDecalFrustum));
        mTerrainGlobalOptions->setDefaultMaterialGenerator(matGenPtr);
        mMaxLayersAllowed = 6;
    }

    CSceneManagerEditor *mSceneMgr = static_cast<CSceneManagerEditor*>(mOgitorsRoot->GetSceneManagerEditor());

    if(mSceneMgr->getShadowsEnabled())
    {
        if(mMaterialGeneratorType->get() == 1)
        {
            Ogre::TerrainMaterialGeneratorC::SM2Profile* matProfile = static_cast<Ogre::TerrainMaterialGeneratorC::SM2Profile*>(mTerrainGlobalOptions->getDefaultMaterialGenerator()->getActiveProfile());
            matProfile->setReceiveDynamicShadowsEnabled(true);
            matProfile->setReceiveDynamicShadowsLowLod(false);
            matProfile->setReceiveDynamicShadowsDepth(true);
            matProfile->setReceiveDynamicShadowsPSSM(static_cast<Ogre::PSSMShadowCameraSetup*>(mSceneMgr->getPSSMSetup().get()));
        }
        else
        {
            Ogre::TerrainMaterialGeneratorB::SM2Profile* matProfile = static_cast<Ogre::TerrainMaterialGeneratorB::SM2Profile*>(mTerrainGlobalOptions->getDefaultMaterialGenerator()->getActiveProfile());
            matProfile->setReceiveDynamicShadowsEnabled(true);
            matProfile->setReceiveDynamicShadowsLowLod(false);
            matProfile->setReceiveDynamicShadowsDepth(true);
            matProfile->setReceiveDynamicShadowsPSSM(static_cast<Ogre::PSSMShadowCameraSetup*>(mSceneMgr->getPSSMSetup().get()));
        }
    }

    CONNECT_PROPERTY_MEMFN(mSceneMgr, "shadows::enabled", CTerrainGroupEditor, onShadowsChange, mShadowsConnection[0]);
    CONNECT_PROPERTY_MEMFN(mSceneMgr, "shadows::technique", CTerrainGroupEditor, onShadowsTechniqueChange, mShadowsConnection[1]);

    mHandle = OGRE_NEW Ogre::TerrainGroup(mOgitorsRoot->GetSceneManager(), Ogre::Terrain::ALIGN_X_Z, mMapSize->get(), mWorldSize->get());
    mHandle->setOrigin(Ogre::Vector3::ZERO);
    mHandle->setResourceGroup("TerrainResources");
    mHandle->setFilenameConvention(mPageNamePrefix->get(), "ogt");
    StaticGroupPtr = mHandle;

    mPGHandle = new PagedGeometry(mOgitorsRoot->GetViewport()->getCameraEditor()->getCamera(), mPGPageSize->get());
    mPGHandle->addDetailLevel<GrassPage>(mPGDetailDistance->get());

    //Create a GrassLoader object
    mGrassLoaderHandle = new GrassLoader(mPGHandle);
    mGrassLoaderHandle->setVisibilityFlags(1 << mLayer->get());

    //Assign the "grassLoader" to be used to load geometry for the PagedGrass instance
    mPGHandle->setPageLoader(mGrassLoaderHandle);

    //Supply a height function to GrassLoader so it can calculate grass Y values
    mGrassLoaderHandle->setHeightFunction(OgitorTerrainGroupHeightFunction);

    Ogre::Vector3 vDir;
    Ogre::ColourValue cDiffuse;
    Ogre::SceneManager::MovableObjectIterator mit = mOgitorsRoot->GetSceneManager()->getMovableObjectIterator("Light");
    while(mit.hasMoreElements())
    {
        Ogre::Light *l = static_cast<Ogre::Light*>(mit.getNext());
        if(l->getType() == Ogre::Light::LT_DIRECTIONAL && l->getCastShadows())
        {
            vDir = l->getDerivedDirection();
            cDiffuse = l->getDiffuseColour();
            break;
        }
    }

    mTerrainGlobalOptions->setLightMapDirection(vDir);
    mTerrainGlobalOptions->setCompositeMapAmbient(mOgitorsRoot->GetSceneManager()->getAmbientLight());
    mTerrainGlobalOptions->setCompositeMapDiffuse(cDiffuse);

    terrainDir = OgitorsRoot::getSingletonPtr()->GetProjectOptions()->TerrainDirectory + "/terrain/";

    OFS::FileList TGAList = mOgitorsRoot->GetProjectFile()->listFiles(terrainDir.c_str(), OFS::OFS_FILE);

    for(unsigned int t = 0; t < TGAList.size(); t++)
    {
        int pos = TGAList[t].name.find("_density.tga");
        if(pos > 0)
        {
            Ogre::Image _img;
            Ogre::String sLoc = terrainDir + TGAList[t].name;

            // Block to ensure streams are freed when exiting the block
            {
                OFS::OFSHANDLE *iHandle = new OFS::OFSHANDLE();
                mOgitorsRoot->GetProjectFile()->openFile( *iHandle, sLoc.c_str() );
                Ogre::DataStreamPtr img_stream = Ogre::DataStreamPtr(OGRE_NEW OfsDataStream(mOgitorsRoot->GetProjectFile(), iHandle));
                _img.load(img_stream);
            }

            Ogre::String nLoc = terrainDir + TGAList[t].name.substr(0, pos);
            nLoc += "_density.png";

            OgitorsUtils::SaveImageOfs( _img, nLoc );
            mOgitorsRoot->GetProjectFile()->deleteFile( sLoc.c_str() );
        }
    }

    registerForUpdates();

    mLoaded->set(true);
    return true;
}
예제 #21
0
int COFSSceneSerializer::Import(Ogre::String importfile)
{
    OgitorsRoot *ogRoot = OgitorsRoot::getSingletonPtr();
    OgitorsSystem *mSystem = OgitorsSystem::getSingletonPtr();
    OFS::OfsPtr& mFile = OgitorsRoot::getSingletonPtr()->GetProjectFile();

    if(importfile == "")
    {
        UTFStringVector extlist;
        extlist.push_back(OTR("Ogitor File System File"));
        extlist.push_back("*.ofs");
        extlist.push_back(OTR("Ogitor Scene File"));
        extlist.push_back("*" + Globals::OGSCENE_FORMAT_EXTENSION);

        importfile = mSystem->GetSetting("system", "oldOpenPath", "");
        importfile = mSystem->DisplayOpenDialog(OTR("Open"), extlist, importfile);
        if(importfile == "") 
            return SCF_CANCEL;

        mSystem->SetSetting("system", "oldOpenPath", importfile);
    }

    importfile = OgitorsUtils::QualifyPath(importfile);

    Ogre::String filePath = OgitorsUtils::ExtractFilePath(importfile);
    Ogre::String fileName = OgitorsUtils::ExtractFileName(importfile);

    bool testpassed = false;
    try
    {
        std::ofstream test((filePath + "test.dat").c_str());
        if(test.is_open())
            testpassed = true;
        test.close();
        mSystem->DeleteFile(filePath + "test.dat");
    }
    catch(...)
    {
        testpassed = false;
    }

    if(!testpassed)
    {
        mSystem->DisplayMessageDialog("The path is read-only. Ogitor can not work with read-only project paths!", DLGTYPE_OK);
        return SCF_CANCEL;
    }

    Ogre::UTFString loadmsg = "";

    int typepos = importfile.find_last_of(".");
    if(typepos != -1 && (importfile.substr(typepos, 4) != ".ofs"))
        importfile = filePath;
    

    OFS::OfsResult oRet;
    if((oRet = mFile.mount(importfile.c_str(), OFS::OFS_MOUNT_OPEN | OFS::OFS_MOUNT_RECOVER)) != OFS::OFS_OK)
    {
        if(oRet == OFS::OFS_PREVIOUS_VERSION)
        {
            mSystem->DisplayMessageDialog("The OFS file is a previous version, please use qtOFS to upgrade it to new file version.", DLGTYPE_OK);
        }

        loadmsg = mSystem->Translate("Please load a Scene File...");
        mSystem->UpdateLoadProgress(-1, loadmsg);
        return SCF_ERRPARSE;
    }

    OFS::FileSystemStats fsStats;

    mFile->getFileSystemStats(fsStats);

    PROJECTOPTIONS *pOpt = ogRoot->GetProjectOptions();
    pOpt->CreatedIn = "";

    pOpt->ProjectDir = filePath;
    typepos = fileName.find_last_of(".");
    if(typepos != -1)
        fileName.erase(typepos, fileName.length() - typepos);
    pOpt->ProjectName = fileName;

    fileName += Globals::OGSCENE_FORMAT_EXTENSION;

    OFS::ofs64 file_size = 0;

    if(mFile->getFileSize(fileName.c_str(), file_size) != OFS::OFS_OK)
	{		
        // OGSCENE file name needs to match OFS container file name. If the later was renamed, we 
        // need to automatically adapt the OGSCENE file name now.
        OFS::FileList files = mFile->listFiles("/", OFS::OFS_FILE);
        unsigned int ogsceneFileExtensionLength = strlen(Globals::OGSCENE_FORMAT_EXTENSION.c_str());

		for(OFS::FileList::iterator iter = files.begin(); iter != files.end(); iter++)
		{
			// Filter out too short names
            if(iter->name.size() <= ogsceneFileExtensionLength) 
                continue;

			if(stricmp(iter->name.c_str() + (iter->name.size() - (ogsceneFileExtensionLength)), Globals::OGSCENE_FORMAT_EXTENSION.c_str()) == 0)
			{
				mFile->renameFile(iter->name.c_str(), fileName.c_str());
				break;
			}
		}

		if(mFile->getFileSize(fileName.c_str(), file_size) != OFS::OFS_OK)
			return SCF_ERRFILE;
	}

    char *file_data = new char[(unsigned int)file_size + 1];

    OFS::OFSHANDLE projHandle;

    if(mFile->openFile(projHandle, fileName.c_str(), OFS::OFS_READ) != OFS::OFS_OK)
    {
        delete [] file_data;
        return SCF_ERRFILE;
    }

    mFile->read(projHandle, file_data, file_size);
    mFile->closeFile(projHandle);

    TiXmlDocument docImport;

    if(!docImport.LoadFromMemory(file_data, file_size))
    {
        delete [] file_data;
        return SCF_ERRFILE;
    }

    delete [] file_data;

    loadmsg = mSystem->Translate("Parsing Scene File");
    mSystem->UpdateLoadProgress(1, loadmsg);

    TiXmlNode* ogitorSceneNode = 0;
    TiXmlNode* projectNode;
    TiXmlElement* element = 0;
    bool upgradeExecuted = false;
    ogitorSceneNode = docImport.FirstChild("OGITORSCENE");

    if(!ogitorSceneNode)
        return SCF_ERRPARSE;

    element = ogitorSceneNode->ToElement();

    // Old OGSCENE version check and attempt to fix/update
    int version = Ogre::StringConverter::parseInt(ValidAttr(element->Attribute("version"), "0"));    
    if(Ogre::StringConverter::toString(version) < Globals::OGSCENE_FORMAT_VERSION)
    {
        mSystem->DisplayMessageDialog(mSystem->Translate("Old OGSCENE file version detected. Ogitor will now attempt to upgrade the format and will also create a backup version of your OFS file."), DLGTYPE_OK);

        loadmsg = mSystem->Translate("Upgrading OGSCENE file.");
        mSystem->UpdateLoadProgress(10, loadmsg);

        if(version == 0)
        {
            mSystem->DisplayMessageDialog(mSystem->Translate("OGSCENE files contains no version number set and therefore cannot be loaded."), DLGTYPE_OK);
            return SCF_ERRPARSE;
        }
        else if(version == 1)
        {
            mSystem->DisplayMessageDialog(mSystem->Translate("OGSCENE files with version 1 cannot be upgraded automatically. Please contact the Ogitor team for further details."), DLGTYPE_OK);
            return SCF_ERRPARSE;
        }

        if(version > 1)
        {
            if((mFile->getFileSystemType() == OFS::OFS_PACKED) && (!mSystem->CopyFile(importfile, importfile + ".backup")))
                mSystem->DisplayMessageDialog(mSystem->Translate("Error while trying to create backup file."), DLGTYPE_OK);
        }
        switch(version)
        {
         case 2:
            _upgradeOgsceneFileFrom2To3(ogitorSceneNode);
            _upgradeOgsceneFileFrom3To4(ogitorSceneNode);
            break;
         case 3:
            _upgradeOgsceneFileFrom3To4(ogitorSceneNode);
            break;
        }

        upgradeExecuted = true;
    }  

    projectNode = ogitorSceneNode->FirstChild("PROJECT");

    if(projectNode)
    {
        loadmsg = mSystem->Translate("Parsing project options");
        mSystem->UpdateLoadProgress(5, loadmsg);
        ogRoot->LoadProjectOptions(projectNode->ToElement());
        ogRoot->PrepareProjectResources();
    }

    element = ogitorSceneNode->FirstChildElement();

    loadmsg = mSystem->Translate("Creating scene objects");
    mSystem->UpdateLoadProgress(10, loadmsg);

    unsigned int obj_count = 0;
    Ogre::String objecttype;
    OgitorsPropertyValueMap params;
    OgitorsPropertyValue tmpPropVal;
    Ogre::String objAttValue;
    Ogre::String elementName;
    TiXmlElement* properties = 0;
    Ogre::String attID;
    Ogre::String attValue;
    CBaseEditor* result = 0;
    TiXmlElement* customprop = 0;
    Ogre::StringVector invalidEditorTypes;

    do
    {
        // Make sure its NON-ZERO
        if(pOpt->ObjectCount)
        {
            ++obj_count;
            mSystem->UpdateLoadProgress(10 + ((obj_count * 70) / pOpt->ObjectCount), loadmsg);
        }

        params.clear();       

        objAttValue = ValidAttr(element->Attribute("object_id"), "");
        if(objAttValue != "")
        {
            tmpPropVal.propType = PROP_UNSIGNED_INT;
            tmpPropVal.val = Ogre::Any(Ogre::StringConverter::parseUnsignedInt(objAttValue));
            params.insert(OgitorsPropertyValueMap::value_type("object_id", tmpPropVal));
        }

        objAttValue = ValidAttr(element->Attribute("parentnode"), "");
        if(objAttValue != "")
        {
            tmpPropVal.propType = PROP_STRING;
            tmpPropVal.val = Ogre::Any(objAttValue);
            params.insert(OgitorsPropertyValueMap::value_type("parentnode", tmpPropVal));
        }

        objAttValue = ValidAttr(element->Attribute("name"), "");
        if(objAttValue != "")
        {
            tmpPropVal.propType = PROP_STRING;
            tmpPropVal.val = Ogre::Any(objAttValue);
            params.insert(OgitorsPropertyValueMap::value_type("name", tmpPropVal));
        }
        else
            continue;

        objAttValue = ValidAttr(element->Attribute("typename"), "");
        if(objAttValue != "")
        {
            tmpPropVal.propType = PROP_STRING;
            tmpPropVal.val = Ogre::Any(objAttValue);
            params.insert(OgitorsPropertyValueMap::value_type("typename", tmpPropVal));
        }
        else
            continue;

        properties = element->FirstChildElement();
        if(properties)
        {            
            do
            {
                elementName = properties->Value();
                if(elementName != "PROPERTY")
                    continue;

                attID = ValidAttr(properties->Attribute("id"), "");
                int attType = Ogre::StringConverter::parseInt(ValidAttr(properties->Attribute("type"), ""));
                attValue = ValidAttr(properties->Attribute("value"), "");

                params.insert(OgitorsPropertyValueMap::value_type(attID, OgitorsPropertyValue::createFromString((OgitorsPropertyType)attType, attValue)));
            } while(properties = properties->NextSiblingElement());
        }

        objecttype = Ogre::any_cast<Ogre::String>(params["typename"].val);
        result = ogRoot->CreateEditorObject(0, objecttype, params, false, false);
        if(result)
        {
            customprop = element->FirstChildElement("CUSTOMPROPERTIES");
            if(customprop) 
            {
                OgitorsUtils::ReadCustomPropertySet(customprop, result->getCustomProperties());
            }
        }
        else
            invalidEditorTypes.push_back(objecttype);

    } while(element = element->NextSiblingElement());

    // Print out invalid/unsupported editor types (= types where no factory could be found)
    if(invalidEditorTypes.size() > 0)
    {
        std::sort(invalidEditorTypes.begin(), invalidEditorTypes.end());
        invalidEditorTypes.erase(std::unique(invalidEditorTypes.begin(), invalidEditorTypes.end()), invalidEditorTypes.end());
        Ogre::String invalidTypesResultString;
        for(unsigned int i = 0; i < invalidEditorTypes.size(); i++)
        {
            invalidTypesResultString += invalidEditorTypes.at(i) + "\n";
        }
        mSystem->DisplayMessageDialog(mSystem->Translate("Could not create objects of types:\n" + invalidTypesResultString), DLGTYPE_OK);
    }

    //// Save directly after upgrade
    //if(upgradeExecuted)
    //    Export(false, importfile);

    ogRoot->AfterLoadScene();

    return SCF_OK;
}
void CSaveSceneView::SceneNodeExplore(Ogre::SceneNode *SceneNode)
{
	Ogre::Entity *Entity = NULL;
	Ogre::Camera *Camera = NULL;
	Ogre::Light *Light = NULL;
	Ogre::ParticleSystem *ParticleSystem = NULL;
	Ogre::ManualObject *ManualObject = NULL;
	Ogre::BillboardSet *BillboardSet = NULL;

	xmlTextWriterStartElement(m_XmlWriter, BAD_CAST "SceneNode");
	
	Ogre::String SceneNodeName = SceneNode->getName();

	xmlTextWriterWriteAttribute(m_XmlWriter, 
										BAD_CAST "SceneNodeName",
										BAD_CAST SceneNodeName.c_str());

	Ogre::SceneNode::ObjectIterator obji = SceneNode->getAttachedObjectIterator();

	while (obji.hasMoreElements())
	{
		Ogre::MovableObject* mobj = obji.getNext();
	
		Ogre::String Type = mobj->getMovableType();
	
		if (Type == "Entity")
		{
			Entity = (Ogre::Entity *)(mobj);
			Ogre::String EntityName = Entity->getName();
			xmlTextWriterStartElement(m_XmlWriter, BAD_CAST "Entity");
			xmlTextWriterWriteAttribute(m_XmlWriter, 
										BAD_CAST "EntityName",
										BAD_CAST EntityName.c_str());

			Ogre::MeshPtr Mesh = Entity->getMesh();
			Ogre::String MeshName = Mesh->getName();
			xmlTextWriterWriteAttribute(m_XmlWriter, 
										BAD_CAST "MeshName",
										BAD_CAST MeshName.c_str());
			xmlTextWriterEndElement(m_XmlWriter); 
		}
		
		if (Type == "Camera")
		{
			Camera = (Ogre::Camera *)(mobj);
			Ogre::String CameraName = Camera->getName();
			xmlTextWriterStartElement(m_XmlWriter, BAD_CAST "Camera");
			
			xmlTextWriterWriteAttribute(m_XmlWriter, 
										BAD_CAST "CameraName",
										BAD_CAST CameraName.c_str());
			
			Ogre::Vector3 CameraPosition = Camera->getPosition();
			
			xmlTextWriterWriteFormatAttribute(m_XmlWriter, 
										BAD_CAST "XPosition",
										"%f",CameraPosition.x);
			xmlTextWriterWriteFormatAttribute(m_XmlWriter, 
										BAD_CAST "YPosition",
										"%f",CameraPosition.y);
			xmlTextWriterWriteFormatAttribute(m_XmlWriter, 
										BAD_CAST "ZPosition",
										"%f",CameraPosition.z);

			Ogre::Vector3 CameraDirection = Camera->getDirection();

			xmlTextWriterWriteFormatAttribute(m_XmlWriter, 
										BAD_CAST "XDirection",
										"%f",CameraDirection.x);
			xmlTextWriterWriteFormatAttribute(m_XmlWriter, 
										BAD_CAST "YDirection",
										"%f",CameraDirection.y);
			xmlTextWriterWriteFormatAttribute(m_XmlWriter, 
										BAD_CAST "ZDirection",
										"%f",CameraDirection.z);

			xmlTextWriterEndElement(m_XmlWriter); 
		}

		if (Type == "Light")
		{
			Light = (Ogre::Light *)(mobj);
		}

		if (Type == "ParticleSystem")
		{
			ParticleSystem = (Ogre::ParticleSystem *)(mobj);
		}

		if (Type == "ManualObject")
		{
			ManualObject = (Ogre::ManualObject *)(mobj);
		}

		if (Type == "BillboardSet")
		{
			BillboardSet = (Ogre::BillboardSet *)(mobj);
		}

	}

	Ogre::Node::ChildNodeIterator nodei = SceneNode->getChildIterator();

	while (nodei.hasMoreElements())
	{
		Ogre::SceneNode* node = (Ogre::SceneNode*)(nodei.getNext());
			// Add this subnode and its children...
		SceneNodeExplore(node);
	}

	xmlTextWriterEndElement(m_XmlWriter); //end SceneNode
}
예제 #23
0
	void CEventAreaEditAction::_writeAreaFromSingleFile(const std::string& fileName, SHOW_RECT_MAP& map)
	{
		SHOW_RECT_MAP::iterator itEventAreaEnd;
		SHOW_RECT_MAP::iterator it;

		// 删除旧的文件。
		::DeleteFile(fileName.c_str());

		char bufInfo[1024];
		memset(bufInfo, 0, sizeof(bufInfo));

		// 存储区域的个数
		int iRectCount = map.size();
		sprintf(bufInfo, "%d", iRectCount);
		WritePrivateProfileString("area_info", "area_count", bufInfo, fileName.c_str());


		// 存储每个区域的信息
		itEventAreaEnd = map.end();
		///////////////////////////////////////////////////////////////////////////////////////////////
		//
		// 保存把场景坐标转换成游戏逻辑坐标.
		//

		float fScale = 0;
		float fTerrainDataPosX = getTerrainData()->mPosition.x;
		float fTerrainDataPosZ = getTerrainData()->mPosition.z;
		if(getSceneManipulator())
		{
			fScale = getSceneManipulator()->getBaseScale();
			if(abs((float)fScale) < 0.00001)
			{
				fScale = 1.0;
			}
		}

		char bufPosInfo[1024];
		int iEventRectIndex = 0;
		CEventAreaInfo* pEventAreaInfo = NULL;

		float x = 0;
		float y = 0;
		for(it = map.begin(); it != itEventAreaEnd; it++)
		{
			pEventAreaInfo = it->second;
			if(pEventAreaInfo)
			{
				memset(bufInfo, 0, sizeof(bufInfo));
				sprintf(bufInfo, "area%d", iEventRectIndex);
				iEventRectIndex++;

				// 事件区域id
				memset(bufPosInfo, 0, sizeof(bufPosInfo));
				sprintf(bufPosInfo, "%d", pEventAreaInfo->m_iEventAreaId);
				WritePrivateProfileString(bufInfo, "guid", bufPosInfo, fileName.c_str());

				// 脚本id
				memset(bufPosInfo, 0, sizeof(bufPosInfo));
				sprintf(bufPosInfo, "%d", pEventAreaInfo->m_iScriptId);
				WritePrivateProfileString(bufInfo, "script_id", bufPosInfo, fileName.c_str());


				// 记录矩形区域位置
				memset(bufPosInfo, 0, sizeof(bufPosInfo));
				x = pEventAreaInfo->m_rect.m_LeftTop.x;
				x = (x - fTerrainDataPosX) / fScale;
				sprintf(bufPosInfo, "%.4f", x);
				WritePrivateProfileString(bufInfo, "left", bufPosInfo, fileName.c_str());

				memset(bufPosInfo, 0, sizeof(bufPosInfo));
				x = pEventAreaInfo->m_rect.m_LeftTop.y;
				x = (x - fTerrainDataPosZ) / fScale;
				sprintf(bufPosInfo, "%.4f",x);
				WritePrivateProfileString(bufInfo, "top", bufPosInfo, fileName.c_str());

				memset(bufPosInfo, 0, sizeof(bufPosInfo));
				x = pEventAreaInfo->m_rect.m_RightBottom.x;
				x = (x - fTerrainDataPosX) / fScale;
				sprintf(bufPosInfo, "%.4f",x);
				WritePrivateProfileString(bufInfo, "right", bufPosInfo, fileName.c_str());

				memset(bufPosInfo, 0, sizeof(bufPosInfo));
				x = pEventAreaInfo->m_rect.m_RightBottom.y;
				x = (x - fTerrainDataPosZ) / fScale;
				sprintf(bufPosInfo, "%.4f",x);
				WritePrivateProfileString(bufInfo, "bottom", bufPosInfo, fileName.c_str());

				// Params
				int count = 0;
				for (int i = 0; i<10; ++i)
				{					
					Ogre::String paramName = pEventAreaInfo->m_paramsName[i];
					Ogre::String paramValue = pEventAreaInfo->m_paramsValue[i];
					if (paramName.empty() || paramValue.empty())
					{
						continue;
					}
					memset(bufPosInfo, 0, sizeof(bufPosInfo));
					
					sprintf(bufPosInfo, "%s %s", paramName.c_str(), paramValue.c_str());
					char temp[24];
					memset(temp, 0, sizeof(temp));
					sprintf(temp, "param_%d", count);
					WritePrivateProfileString(bufInfo, temp, bufPosInfo, fileName.c_str());
					count++;
				}
			}
		}

	}		
    //---------------------------------------------------------------------
	bool FileSystemLayer::createDirectory(const Ogre::String& path)
	{
		return !mkdir(path.c_str(), 0755) || errno == EEXIST;
	}
예제 #25
0
 //---------------------------------------------------------------------
 bool FileSystemLayer::fileExists(const Ogre::String& path)
 {
     return _access(path.c_str(), 04) == 0; // Use CRT API rather than GetFileAttributesExA to pass Windows Store validation
 }
예제 #26
0
void mouseEvent(int evt, int x, int y, int flags, void* param){
	HWND hw= (HWND)cvGetWindowHandle(windowName.c_str());
	windowName="x: "+ StringConverter::toString(x) + " , y: " + StringConverter::toString(y) ;
	SetWindowText(hw,(LPCTSTR)windowName.c_str());
}
예제 #27
0
 //---------------------------------------------------------------------
 bool FileSystemLayer::removeFile(const Ogre::String& path)
 {
     return !_unlink(path.c_str()) || errno == ENOENT; // Use CRT API to pass Windows Store validation
 }
예제 #28
0
void MenuSystem::buttonHit(OgreBites::Button* button)
{
	if(button == startButton)
	{
		ipStr = ip->getText();
		name = pName->getText();


		clientPtr->Initialize(ipStr.c_str(), name.c_str());
		//SetMenu(LISTLOBBYMENU);
	}
	else if(button == exitButton)
	{
		//mMain->setShutdown();
		// Having Main.h included in here caused all matter of problems
		// Might be better to have a bool flag for shutdown in this
		// class and have the main look check to see if we want to quit.
		// frameRenderingQueued can return a false and quit
	}
	else if(button == createLobby)
	{
		// Send the server a lobby creation message.
		// Get the name of the lobby

		Ogre::String str = lobbyName->getText();
		const char* data = str.c_str();

		RakNet::RakString name = data;
		clientPtr->CreateLobby(name);

		MenuSystem::updateLobbies();

		SetMenu(LISTLOBBYMENU);
	}
	else if(button == createLobbyButton)
	{
		// We should transition to the lobby creation menu
		SetMenu(CREATELOBBYMENU);
	}
	else if(button == joinLobby)
	{
		// Send a message to the server to add us to the lobby we selected
		// We will wait until we get the reply from the server to transisition into
		// the lobby screen though
		// Pass the index of the selected item since the clients
		// lobby vector is in the same order.
		clientPtr->JoinLobby(selectLobby->getSelectionIndex());
		SetMenu(LOBBYMENU);
	}
	else if(button == refreshLobbyButton)
	{		
		updateLobbies();

		// Also instruct the Client interface to request a new listing of lobbies
		clientPtr->RefreshLobbies();
	}
	else if(button == lobbyBack)
	{
		SetMenu(STARTMENU);
	}
	else if(button == createLobbyBack)
	{
		// We should transition to the lobby creation menu
		SetMenu(LISTLOBBYMENU);
	}
	else if(button == lobbyReadyButton)
	{
		if(isReady)
		{
			lobbyReadyButton->setCaption("NOT READY");
			isReady = !isReady;
			clientPtr->sendReady();
		}
		else
		{
			lobbyReadyButton->setCaption("READY");
			isReady = !isReady;
			clientPtr->sendReady();
		}
	}
	else if(button == matchUpgrade)
	{
		SetMenu(UPGRADEMENU);
	}
	else if(button == powerupBack)
	{
		SetMenu(MATCHMENU);
	}
	else if(button == powerupOne)
	{
		
	}
	else if(button == powerupTwo)
	{
		
	}
	else if(button == powerupThree)
	{
		
	}

}
예제 #29
0
void SoundEditDialog::LoadSoundInfoFromFile(const Ogre::String& filename)
{
    ClearSoundData();

    mCurrentFileName = filename;

    Fairy::Action* action = mSceneManipulator->_getAction("SoundEditAction");

    DBC::DBCFile excelDBFile(1);
    if(!excelDBFile.OpenFromTXT(filename.c_str()))
    {
        mSoundInfoFileChanged = false;
        return;
    }

    int iRecordCount = excelDBFile.GetRecordsNum(); 
    int iLastColum   = excelDBFile.GetFieldsNum();
    const DBC::DBCFile::FIELD* pInfo = NULL;	

    for(int i = 0; i < iRecordCount; i++)
    {
        SoundItem* soundItem = new SoundItem;
        // 读取ID
        pInfo = excelDBFile.Search_Posistion(i, 0);
        soundItem->mInstanceID = pInfo->iValue;

        // 类型id
        pInfo = excelDBFile.Search_Posistion(i, 1);
        soundItem->mSoundID = pInfo->iValue;

        // 位置x
        pInfo = excelDBFile.Search_Posistion(i, 2);
        soundItem->mXPos = pInfo->iValue;

        // 位置z
        pInfo = excelDBFile.Search_Posistion(i, 3);
        soundItem->mZPos = pInfo->iValue;

        // 有效半径
        pInfo = excelDBFile.Search_Posistion(i, 4);
        soundItem->mRadius = pInfo->iValue;

        // 连播次数
        pInfo = excelDBFile.Search_Posistion(i, 5);
        soundItem->mRepeatTime = pInfo->iValue;

        // 连播间隔时间
        pInfo = excelDBFile.Search_Posistion(i, 6);
        soundItem->mRepeatIntervalTime = pInfo->iValue;

        // 下次播放间隔时间
        pInfo = excelDBFile.Search_Posistion(i, 7);
        soundItem->mNextRepeatTime = pInfo->iValue;

        mSoundItems.push_back(soundItem);


        action->setParameter("CreateSoundEntity", Ogre::StringConverter::toString(soundItem->mXPos)
            + " " + Ogre::StringConverter::toString(soundItem->mZPos));
    }

    _FillSoundListCtrl();
}
//-----------------------------------------------------------------------------------------
bool CTerrainPageEditor::importHeightMap(Ogre::String filename, Ogre::Real fBias, Ogre::Real fScale)
{
    if(!mHandle || !mLoaded->get())
        return false;

    Ogre::StringUtil::trim(filename);

    if(filename.empty())
    {
        UTFStringVector extlist;
        extlist.push_back(OTR("Raw 32bit Float File"));
        extlist.push_back("*.raw;*.ohm;*.f32;*.r32");
        extlist.push_back(OTR("PNG Grayscale"));
        extlist.push_back("*.png");
        filename = mSystem->DisplayOpenDialog(OTR("Import Heightmap"),extlist);
        if(filename == "") 
            return false;
    }

    bool flipV = false;
    float *flipBV = 0;

    if(fBias == 0.0f && fScale == 0.0f)
    {
        Ogre::NameValuePairList params;
        params["check1"] = "true";
        if(!mSystem->DisplayImportHeightMapDialog(params))
            return false;

        fScale = Ogre::StringConverter::parseReal(params["input1"]);
        fBias = Ogre::StringConverter::parseReal(params["input2"]);
        flipV = Ogre::StringConverter::parseBool(params["inputCheckV"]);
    }

    float *mHeightData = mHandle->getHeightData();

    Ogre::String namePart = OgitorsUtils::ExtractFileName(filename);
    namePart.erase(0, namePart.find("."));

    OgitorsUndoManager::getSingletonPtr()->BeginCollection("Import Heightmap");

    Ogre::Rect rect(0,0,mHandle->getSize(), mHandle->getSize());
    _notifyModification(-1, rect);
    _notifyEndModification();


    if(namePart == ".ohm" || namePart == ".raw" || namePart == ".f32" || namePart == ".r32")
    {
        size_t vertexNum = mHandle->getSize() * mHandle->getSize();
        float *data = OGRE_ALLOC_T(float, vertexNum, Ogre::MEMCATEGORY_GEOMETRY);

        try
        {
            FILE *f = fopen(filename.c_str(),"rb");
            fread(data,sizeof(float),vertexNum,f);
            fclose(f);
        }
        catch(...)
        {
            OGRE_FREE(data, Ogre::MEMCATEGORY_GEOMETRY);
            return false;
        }

        if(flipV)
        {
            flipBV = OGRE_ALLOC_T(float, mHandle->getSize(), Ogre::MEMCATEGORY_GEOMETRY);

            int linelength = mHandle->getSize() * sizeof(float);

            for(int fj = 0;fj < mHandle->getSize();fj++)
            {
                memcpy(flipBV, data + (fj * linelength), linelength);
                memcpy(data + (fj * linelength), data + ((mHandle->getSize() - fj - 1) * linelength), linelength);
                memcpy(data + ((mHandle->getSize() - fj - 1) * linelength), flipBV, linelength);
            }

            OGRE_FREE(flipBV, Ogre::MEMCATEGORY_GEOMETRY);
        }
        
        for(unsigned int px = 0;px < vertexNum;px++)
            mHeightData[px] = fBias + (data[px] * fScale);

        OGRE_FREE(data, Ogre::MEMCATEGORY_GEOMETRY);
    }