Ogre::SceneNode* ParticleFactory::CreateParticleEntity(Ogre::String object_name, Ogre::String material_name,Ogre::SceneNode* parent, Ogre::Vector3 size){

		/* Create one instance of the torus (one entity) */
		/* The same object can have multiple instances or entities */

		/* Create entity */
		Ogre::String name = parent->getName() + object_name;
        //Ogre::Entity* entity = scene_manager->createEntity(object_name);
		Ogre::Entity* entity = scene_manager->createEntity(object_name);

		Ogre::MaterialPtr mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(material_name));
		//mat = mat->clone(object_name.append("_" +material_name.append("_" + Ogre::StringConverter::toString(materialCounter))));
		mat = mat->clone(name.append("_" +material_name.append("_" + Ogre::StringConverter::toString(materialCounter))));

		//std::cout << "NAME: " << name << std::endl;
		//mat = mat->clone(object_name.append(material_name));
		/* Apply a material to the entity */
		entity->setMaterialName(mat->getName());
		//materialArray[numMaterials] = mat->getName();
		materialArray.push_back(mat->getName());
		

		/* Create a scene node for the entity */
		/* The scene node keeps track of the entity's position */
        Ogre::SceneNode* scene_node = parent->createChildSceneNode(mat->getName());
        scene_node->attachObject(entity);
		//scene_node->translate(0.5,0.5,-1);
		incrementCounter();
		/* Scale the entity */
		scene_node->scale(size);
		return scene_node;
}
예제 #2
0
bool GameState::mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
{
    if(id == OIS::MB_Right)
    {
        OgreFramework::getSingletonPtr()->m_pTrayMgr->hideCursor();
        m_bRMousePressed = true;
    }
    else if(id == OIS::MB_Left)
    {
        if(!util::VPGRAPH->isCreated())
        {
            std::vector<Ogre::Vector3> points;
            for(int i = 1; i <= 42; i++)
            {
                Ogre::String nome = "ViewPoint";
                nome.append(Ogre::StringConverter::toString(i));
                points.push_back(m_pSceneMgr->getSceneNode(nome)->getPosition());
            }
            util::VPGRAPH->createGraph(points);
        }

        m_pHero->getInput(arg, id);
    }
    OgreFramework::getSingletonPtr()->m_pTrayMgr->injectMouseDown(arg, id);
    return true;
}
예제 #3
0
파일: File.cpp 프로젝트: onze/Steel
    Ogre::String File::fileName() const
    {
        Ogre::String s = mBaseName;

        if(mExtension.size() > 0)
            s.append("." + mExtension);

        return s;
    }
예제 #4
0
void GameState::adjustObjectsMasks(const Ogre::String &name, unsigned int num, MaskEnum mask)
{
    for(unsigned int i = 1; i <= num; i++)
    {
        Ogre::String nome = name;
        nome.append(Ogre::StringConverter::toString(i));
        m_pSceneMgr->getEntity(nome)->setQueryFlags(mask);
    }
}
void SoundDetector::_generateEventOutgoingObject(Ogre::String objectName)
{
	if(debug)
	{
		Ogre::RenderWindow* win = ClassPack::getSingleton()->getRenderWindow();
		Ogre::String str = "Outgoing : ";
		str.append( objectName );
		win->setDebugText( str );
	}
	eventMng->createDetectionEvent("outgoingSound_" + mName, objectName);
}
예제 #6
0
CRoad::CRoad(Ogre::SceneNode *pOwnerNode, Ogre::String Name, OperationType opType)
{
	initialize(opType, false);
	setMaterial("BaseWhiteNoLighting");
	mDirty = true;
	
	mTesselation = 1;
	mWidth = 5;

	mSceneManager = pOwnerNode->getCreator();
	mRoadMesh = mSceneManager->createManualObject(Name.append(" internal class"));
	pOwnerNode->attachObject(mRoadMesh);

}
예제 #7
0
int LevelManager::LoadLevel(int levelId)
{
	Ogre::String text = "Level ";

	//convert levelId to string
	std::string levelString;
	std::stringstream out;
	out << levelId;
	levelString = out.str();

	text.append(levelString);
	text.append(" starting");
	GAMEENGINE.GetGUIManager()->AddAlert(text);

	//Variables needed to generate a new level
	Hut* hutTemplate;
	Guardian* guardianTemplate;
	int numHutsToSpawn = DEFAULT_NUM_HUTS_TO_SPAWN; 
	int numMaxEnemies = DEFAULT_MAX_NUM_ENEMIES;
	Ogre::String levelTexture;

	bool levelLoaded = mLevelParser->parseLevel(levelId, &levelTexture, &hutTemplate, &guardianTemplate, &numHutsToSpawn, &numMaxEnemies);
	std::cout<<"Level Loaded: "<<levelLoaded<<std::endl;
	if(levelLoaded)
	{
		mCurrentLevel->Shutdown();
		
		mMaxNumEnemies = numMaxEnemies;
		mCurrentLevel->SetupLevel(hutTemplate, guardianTemplate, levelTexture, numHutsToSpawn);
		mCurrentLevel->SetLevelId(mCurrentLevel->GetLevelId()+1);
		
		mCurrentLevel->Startup();
	}
	else
	{
		std::cout<<"Could not load level."<<std::endl;
		return -1;
	}
	return 1;
}
	Ogre::String ScriptWriter::getSpaces(unsigned int numberOfSpaces)
	{
		Ogre::String s = "";
		s.append(numberOfSpaces, ' ');
		return s;
	}
예제 #9
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();

}
예제 #10
0
void MenuSystem::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
	// Process all the sdk tray managers
	for(std::vector<OgreBites::SdkTrayManager*>::iterator it = mTrays.begin();
		it != mTrays.end();
		++it)
	{
		(*it)->frameRenderingQueued(evt);
	}

	// Update the chat windows
	updateChats();

	// Check for when to change state when we are connected
	if(currentMenu == STARTMENU)
	{
		// Check if the network connects
		if(clientPtr->getIsConnected())
		{
			SetMenu(LISTLOBBYMENU);
		}
	}


	// Update the players that are in the lobby
	if(currentMenu == LOBBYMENU)
	{
		std::vector<RakNet::RakString>* vec = clientPtr->GetLobbyUsers();
		lobbyPlayersTextBox->clearText();

		int index = 1;
		for(std::vector<RakNet::RakString>::iterator it = vec->begin();
			it != vec->end();
			++it)
		{
			Ogre::String str = Ogre::String((*it).C_String());
			if(index % 3 == 0)
			{ 
				str.append("\n");
			}
			else
			{
				str.append(" ");
			}

			lobbyPlayersTextBox->appendText(str);


			++index;
		}
	}


	// Process for when we get the signal to transition into the match menu state
	if(currentMenu == LOBBYMENU)
	{
		// If we are to transition set the flag back to flase
		if(clientPtr->getTransitionMatch())
		{
			clientPtr->setTransitionMatch(false);

			SetMenu(MATCHMENU);
		}
	}
}
예제 #11
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();
}
예제 #12
0
void TerrainManager::terrainInit(Ogre::String file, OgreManager* o)
{
	_OgreManager = o;

	initialiseResources();

	createLight();

	setGlobalOptions();

	_TerrainGroup = OGRE_NEW Ogre::TerrainGroup(_OgreManager->getSceneManager(), Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
	_TerrainGroup->setFilenameConvention(Ogre::String("GameTerrain"), Ogre::String("dat"));
	_TerrainGroup->setOrigin(Ogre::Vector3::ZERO);

	setDefaultImportSettings();

	bool lTerrainsImported = false;
	 for (long x = 0; x <= 0; ++x)
	 {
        for (long y = 0; y <= 0; ++y)
		{
			//Define terrain function
			 Ogre::String filename = _TerrainGroup->generateFilename(x, y);
			if (Ogre::ResourceGroupManager::getSingleton().resourceExists(_TerrainGroup->getResourceGroup(), filename))
			{
				_TerrainGroup->defineTerrain(x, y);
			}
			else
			{
				Ogre::Image img;
				//Get terrain image
				Ogre::String tempFile = Ogre::StringConverter::toString(x * 10 + y);
				tempFile.append(".bmp");
				img.load("terrain.bmp", Ogre::String("TerrainResources"));
					if (x % 2 != 0)
						img.flipAroundY();
					if (y % 2 != 0)
						img.flipAroundX();
				//Get terrain image end
				_TerrainGroup->defineTerrain(x, y, &img);
				lTerrainsImported = true;
			}
			//Define terrain function end
		}
	}
	
	_TerrainGroup->loadAllTerrains(true);

	if (lTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = _TerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            //Init blend maps function start
			Ogre::TerrainLayerBlendMap* blendMap0 = t->getLayerBlendMap(1);
			Ogre::TerrainLayerBlendMap* blendMap1 = t->getLayerBlendMap(2);
			Ogre::Real minHeight0 = -10;
			Ogre::Real fadeDist0 = 0;//40;
			Ogre::Real minHeight1 = -10;
			Ogre::Real fadeDist1 = 0;//15;
			float* pBlend0 = blendMap0->getBlendPointer();
			float* pBlend1 = blendMap1->getBlendPointer();
			for (Ogre::uint16 y = 0; y < t->getLayerBlendMapSize(); ++y)
			{
				for (Ogre::uint16 x = 0; x < t->getLayerBlendMapSize(); ++x)
				{
					Ogre::Real tx, ty;
 
					blendMap0->convertImageToTerrainSpace(x, y, &tx, &ty);
					Ogre::Real height = t->getHeightAtTerrainPosition(tx, ty);
					Ogre::Real val = (height - minHeight0) / fadeDist0;
					val = Ogre::Math::Clamp(val, (Ogre::Real)0, (Ogre::Real)1);
					*pBlend0++ = val;
 
					val = (height - minHeight1) / fadeDist1;
					val = Ogre::Math::Clamp(val, (Ogre::Real)0, (Ogre::Real)1);
					*pBlend1++ = val;
				}
			}
			blendMap0->dirty();
			blendMap1->dirty();
			blendMap0->update();
			blendMap1->update();
			//Init blend maps end
        }
    }

	_TerrainGroup->freeTemporaryResources();

	_OgreManager->getSceneManager()->setSkyBox(true, "Examples/EarlyMorningSkyBox", 5000, true, Ogre::Quaternion::IDENTITY, "GameResources");
}