Esempio n. 1
0
    //---------------------------------------------------------------------
    void FileSystemLayer::getConfigPaths()
    {
        // try to determine the application's path:
        // recent systems should provide the executable path via the /proc system
        Ogre::String appPath = resolveSymlink("/proc/self/exe");
        if (appPath.empty())
        {
            // if /proc/self/exe isn't available, try it via the program's pid
            pid_t pid = getpid();
            char proc[64];
            int retval = snprintf(proc, sizeof(proc), "/proc/%llu/exe", (unsigned long long) pid);
            if (retval > 0 && retval < (long)sizeof(proc))
                appPath = resolveSymlink(proc);
        }

        if (!appPath.empty())
        {
            // we need to strip the executable name from the path
            Ogre::String::size_type pos = appPath.rfind('/');
            if (pos != Ogre::String::npos)
                appPath.erase(pos);
        }
        else
        {
            // couldn't find actual executable path, assume current working dir
            appPath = ".";
        }

        // use application path as first config search path
        mConfigPaths.push_back(appPath + '/');
        // then search inside ../share/OGRE
        mConfigPaths.push_back(appPath + "/../share/OGRE/");
        // then try system wide /etc
        mConfigPaths.push_back("/etc/OGRE/");
    }
Esempio n. 2
0
CreateTerrainDialog::CreateTerrainDialog(QWidget *parent, Ogre::String lastUsedDiffuse, Ogre::String lastUsedNormal) :
    QDialog(parent, Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint)
{
    setupUi(this);

    unsigned int i, index = 1;
    Ogitors::PropertyOptionsVector *mapDiffuse = Ogitors::OgitorsRoot::GetTerrainDiffuseTextureNames();
    for(i = 0; i < mapDiffuse->size(); i++)
    {
        if (lastUsedDiffuse == (*mapDiffuse)[i].mKey)
            index = i;
        mDiffuseCombo->addItem((*mapDiffuse)[i].mKey.c_str());
    }

    if (lastUsedDiffuse.empty())
        index = 1;

    if(mapDiffuse->size())
        mDiffuseCombo->setCurrentIndex(index);

    index = 1;
    Ogitors::PropertyOptionsVector *mapNormal = Ogitors::OgitorsRoot::GetTerrainNormalTextureNames();
    for(i = 0; i < mapNormal->size(); i++)
    {
        if (lastUsedNormal == (*mapNormal)[i].mKey)
            index = i;
        mNormalCombo->addItem((*mapNormal)[i].mKey.c_str());
    }

    if (lastUsedNormal.empty())
        index = 1;

    if(mapNormal->size())
        mNormalCombo->setCurrentIndex(index);
}
bool VehicleRenderable::loadEntity(TinyXml::TiXmlElement* ele, Ogre::SceneNode* parent)
{
	Ogre::String name			= getAttrib(ele, "name");
	Ogre::String castShadow		= getAttrib(ele, "castShadows");
	Ogre::String receiveShadow	= getAttrib(ele, "receiveShadows");
	Ogre::String meshFile		= getAttrib(ele, "meshFile");
	Ogre::String materialFile	= getAttrib(ele, "materialFile");

	try
	{
		Ogre::Entity* ent = mSceneMgr->createEntity(name, meshFile);
		mEntities.push_back(ent);

		ent->setCastShadows(Ogre::StringConverter::parseBool(castShadow));

		if (!materialFile.empty())
			ent->setMaterialName(materialFile);

		parent->attachObject(ent);
	}
	catch (...)
	{
		Ogre::LogManager::getSingleton().logMessage("VehicleRenderable Error : parsing <" + name + "> error!");
		return false;
	}

	return true;
}
Esempio n. 4
0
	virtual void setupResources(void)
	{
	GraphicsSystem::setupResources();

	Ogre::ConfigFile cf;
	cf.load(mResourcePath + "resources2.cfg");

	Ogre::String originalDataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

	if (originalDataFolder.empty())
	originalDataFolder = "./";
	else if (*(originalDataFolder.end() - 1) != '/')
	originalDataFolder += "/";

	const char *c_locations[4] =
	{
	"2.0/scripts/materials/Tutorial_Terrain",
	"2.0/scripts/materials/Tutorial_Terrain/GLSL",
	"2.0/scripts/materials/Tutorial_Terrain/HLSL",
	"2.0/scripts/materials/Postprocessing/SceneAssets"
	};

	for (size_t i = 0; i<4; ++i)
	{
	Ogre::String dataFolder = originalDataFolder + c_locations[i];
	addResourceLocation(dataFolder, "FileSystem", "General");
	}
	}
Esempio n. 5
0
void OgreApp::setCommandLine(const Ogre::String &commandLine)
{
	String configFile;
	mCommandLine = commandLine;
	
	if(!commandLine.empty())
	{

		// splits command line in a vector without spliting text between quotes
		StringVector quoteSplit = Ogre::StringUtil::split(commandLine, "\"");

		// if the first char was a quote, split() ignored it.
		if(commandLine[0] == '\"')
			quoteSplit.insert(quoteSplit.begin(), " "); // insert a space in the list to reflect the presence of the first quote
		// insert a space instead of an empty string because the next split() will ingore the space but not the empty string
		// split(" ")->{} / split("")->{""}

		for(unsigned int i = 0; i < quoteSplit.size(); i++)
		{
			if(i&1) // odd elements : between quotes
			{
				mCommandLineArgs.push_back(quoteSplit[i]);
			}
			else // even elements : outside quotes
			{
				StringVector spaceSplit = Ogre::StringUtil::split(quoteSplit[i]);
				mCommandLineArgs.insert(mCommandLineArgs.end(), spaceSplit.begin(), spaceSplit.end());
			}
		}
	}
}
Esempio n. 6
0
//-----------------------------------------------------------------------------------------
bool CEntityEditor::_setMeshFile(OgitorsPropertyBase* property, const Ogre::String& value)
{
    if(value.empty())
        return false;

    bool wasLoaded = mLoaded->get();
    bool showBB = mOBBoxRenderable && mOBBoxRenderable->getVisible();

    unLoad();

    int count = mSubEntityCount->get();
    for(int ix = 0; ix < count; ix++)
    {
        Ogre::String name = "subentity" + Ogre::StringConverter::toString(ix);
        mProperties.removeProperty(name + "::material");
        mProperties.removeProperty(name + "::visible");
    }

    mSubEntityCount->set(-1);

    if(wasLoaded)
        load();

    if(showBB)
        showBoundingBox(true);

    return true;
}
Esempio n. 7
0
/** 解析animation sound */
void VEffectManager::_parseAnimSound(Ogre::DataStreamPtr &stream, VSkill *skill)
{
	assert(skill != VNULL);

	VAnimationSound *sound = skill->addAnimationSound();
	assert(sound != VNULL);

	Ogre::String line;

	while (!stream->eof())
	{
		line = stream->getLine();
		++mParsingLineNumber;

		if (!(line.empty() || line.substr(0, 2) == "//"))
		{
			if (line == "}")
			{
				break;
			}
			else
			{
				_parseAnimSoundAttrib(line, sound);
			}
		}
	}
}
Esempio n. 8
0
/** 解析特效元素 */
void VEffectManager::_parseElement(const VString &type, Ogre::DataStreamPtr &stream, VEffect *effect)
{
	VEffectElement *element = createElement(type);
	assert(element != VNULL);

	effect->addElement(element);

	Ogre::String line;

	while (!stream->eof())
	{
		line = stream->getLine();
		++mParsingLineNumber;

		if (!(line.empty() || line.substr(0, 2) == "//"))
		{
			// 跳过空行和注释行
			if (line == "}")
			{
				break;
			}
			else
			{
				_parseElementAttrib(line, element);
			}
		}
	}
}
//-----------------------------------------------------------------------
static Ogre::String concatenate_path(const Ogre::String& base, const Ogre::String& name)
{
    if (base.empty() || is_absolute_path(name.c_str()))
        return name;
    else
        return base + '/' + name;
}
Esempio n. 10
0
void RoR::SkidmarkConfig::LoadDefaultSkidmarkDefs()
{
    LOG("[RoR] Loading skidmarks.cfg...");
    Ogre::String group = "";
    try
    {
        group = Ogre::ResourceGroupManager::getSingleton().findGroupContainingResource("skidmarks.cfg");
        if (group.empty())
        {
            LOG("[RoR] Failed to load skidmarks.cfg (file not found)");
            return;
        }

        Ogre::DataStreamPtr ds = Ogre::ResourceGroupManager::getSingleton().openResource("skidmarks.cfg", group);
        Ogre::String line = "";
        Ogre::String currentModel = "";

        while (!ds->eof())
        {
            line = RoR::Utils::SanitizeUtf8String(ds->getLine());
            Ogre::StringUtil::trim(line);

            if (line.empty() || line[0] == ';')
                continue;

            Ogre::StringVector args = Ogre::StringUtil::split(line, ",");

            if (args.size() == 1)
            {
                currentModel = line;
                continue;
            }

            // process the line if we got a model
            if (!currentModel.empty())
                this->ProcessSkidmarkConfLine(args, currentModel);
        }
    }
    catch (...)
    {
        LOG("[RoR] Error loading skidmarks.cfg (unknown error)");
        m_models.clear(); // Delete anything we might have loaded
        return;
    }
    LOG("[RoR] skidmarks.cfg loaded OK");
}
Esempio n. 11
0
	virtual void registerHlms(void)
	{
	GraphicsSystem::registerHlms();

	Ogre::ConfigFile cf;
	cf.load(mResourcePath + "resources2.cfg");

	Ogre::String dataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

	if (dataFolder.empty())
	dataFolder = "./";
	else if (*(dataFolder.end() - 1) != '/')
	dataFolder += "/";

	Ogre::RenderSystem *renderSystem = mpRoot->getRenderSystem();

	Ogre::String shaderSyntax = "GLSL";
	if (renderSystem->getName() == "Direct3D11 Rendering Subsystem")
	shaderSyntax = "HLSL";

	Ogre::Archive *archiveLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Common/" + shaderSyntax,
	"FileSystem", true);
	Ogre::Archive *archiveLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Common/Any",
	"FileSystem", true);
	Ogre::Archive *archivePbsLibraryAny = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Pbs/Any",
	"FileSystem", true);
	Ogre::Archive *pbsLibrary = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Pbs/" + shaderSyntax,
	"FileSystem", true);

	Ogre::ArchiveVec library;
	library.push_back(archiveLibrary);
	library.push_back(archiveLibraryAny);
	library.push_back(archivePbsLibraryAny);
	library.push_back(pbsLibrary);

	Ogre::Archive *archiveTerra = Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Terra/" + shaderSyntax,
	"FileSystem", true);
	Ogre::HlmsTerra *hlmsTerra = OGRE_NEW Ogre::HlmsTerra(archiveTerra, &library);
	Ogre::HlmsManager *hlmsManager = mpRoot->getHlmsManager();
	hlmsManager->registerHlms(hlmsTerra);

	//Add Terra's piece files that customize the PBS implementation.
	//These pieces are coded so that they will be activated when
	//we set the HlmsPbsTerraShadows listener and there's an active Terra
	//(see Tutorial_TerrainGameState::createScene01)
	Ogre::Hlms *hlmsPbs = hlmsManager->getHlms(Ogre::HLMS_PBS);
	Ogre::Archive *archivePbs = hlmsPbs->getDataFolder();
	Ogre::ArchiveVec libraryPbs = hlmsPbs->getPiecesLibraryAsArchiveVec();
	libraryPbs.push_back(Ogre::ArchiveManager::getSingletonPtr()->load(
	dataFolder + "Hlms/Terra/" + shaderSyntax + "/PbsTerraShadows",
	"FileSystem", true));
	hlmsPbs->reloadFrom(archivePbs, &libraryPbs);
	}
Esempio n. 12
0
	void FileSystemLayer::getConfigPaths()
	{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
		// try to determine the application's path
		DWORD bufsize = 256;
		char* resolved = 0;
		do
		{
			char* buf = OGRE_ALLOC_T(char, bufsize, Ogre::MEMCATEGORY_GENERAL);
			DWORD retval = GetModuleFileName(NULL, buf, bufsize);
			if (retval == 0)
			{
				// failed
				OGRE_FREE(buf, Ogre::MEMCATEGORY_GENERAL);
				break;
			}

			if (retval < bufsize)
			{
				// operation was successful.
				resolved = buf;
			}
			else
			{
				// buffer was too small, grow buffer and try again
				OGRE_FREE(buf, Ogre::MEMCATEGORY_GENERAL);
				bufsize <<= 1;
			}
		} while (!resolved);

		Ogre::String appPath = resolved;
		if (resolved)
			OGRE_FREE(resolved, Ogre::MEMCATEGORY_GENERAL);
		if (!appPath.empty())
		{
			// need to strip the application filename from the path
			Ogre::String::size_type pos = appPath.rfind('\\');
			if (pos != Ogre::String::npos)
				appPath.erase(pos);
		}
		else
		{
			// fall back to current working dir
			appPath = ".";
		}

#elif OGRE_PLATFORM == OGRE_PLATFORM_WINRT
		Ogre::String appPath;
		if(!widePathToOgreString(appPath, Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data()))
		{
			// fallback to current working dir
			appPath = ".";
		}
#endif

		// use application path as config search path
		mConfigPaths.push_back(appPath + '\\');
	}
Esempio n. 13
0
void MeshObject::setMaterialName(Ogre::String m)
{
    if(m.empty()) return;
    materialName = m;
    if(loaded && ent)
    {
        ent->setMaterialName(materialName);
    }
}
Esempio n. 14
0
//-----------------------------------------------------------------------------------------
bool CTerrainGroupEditor::addPage(const int x, const int y, const Ogre::String diffuse, const Ogre::String normal)
{
    if (diffuse.empty() || normal.empty())
        return false;

    OgitorsPropertyValueMap creationparams;
    OgitorsPropertyValue pvalue;

    Ogre::String pagename = mPageNamePrefix->get();
    pagename += Ogre::StringConverter::toString(x);
    pagename += "x";
    pagename += Ogre::StringConverter::toString(y);

    creationparams["init"] = EMPTY_PROPERTY_VALUE;
    pvalue.propType = PROP_STRING;
    pvalue.val = Ogre::Any(pagename);
    creationparams["name"] = pvalue;

    Ogre::Vector3 position;
    mHandle->convertTerrainSlotToWorldPosition(x, y, &position);

    pvalue.propType = PROP_VECTOR3;
    pvalue.val = Ogre::Any(position);
    creationparams["position"] = pvalue;
    pvalue.propType = PROP_INT;
    pvalue.val = Ogre::Any(x);
    creationparams["pagex"] = pvalue;
    pvalue.propType = PROP_INT;
    pvalue.val = Ogre::Any(y);
    creationparams["pagey"] = pvalue;
    pvalue.propType = PROP_STRING;
    pvalue.val = Ogre::Any(diffuse);
    creationparams["layer0::diffusespecular"] = pvalue;
    pvalue.propType = PROP_STRING;
    pvalue.val = Ogre::Any(normal);
    creationparams["layer0::normalheight"] = pvalue;
    pvalue.propType = PROP_REAL;
    pvalue.val = Ogre::Any((Ogre::Real)10.0f);
    creationparams["layer0::worldsize"] = pvalue;

    CTerrainPageEditor* page = (CTerrainPageEditor*)mOgitorsRoot->CreateEditorObject(this, "Terrain Page", creationparams, true, true);

    return true;
}
Esempio n. 15
0
bool
findCorrelativeResource(String& resourceName,Ogre::String& groupName,
                        const Ogre::String& baseResourceName, const Ogre::String& baseGroupName)
{
    Ogre::ResourceGroupManager& mgr = Ogre::ResourceGroupManager::getSingleton();

   Ogre::String name, path;
    Ogre::StringUtil::splitFilename(resourceName, name, path);
    bool existsPath = !path.empty();
	String grp = baseGroupName;

    // First, find in correlatived group and path if resource name doesn't exists path
    if (!existsPath)
    {
        Ogre::StringUtil::splitFilename(baseResourceName, name, path);
        if (!path.empty())
        {
            name = path + resourceName;
            if (mgr.resourceExists(grp, name))
            {
                resourceName = name;
                groupName = baseGroupName;
                return true;
            }
        }
    }

    // Second, find in correlatived group
    if (mgr.resourceExists(grp, resourceName))
    {
        groupName = baseGroupName;
        return true;
    }

    // Three, find in user given group
    if (!groupName.empty())
    {
        if (mgr.resourceExists(groupName, resourceName))
        {
            return true;
        }
    }

    // Four, find in global default group
    if (groupName != DEFAULT_RESOURCE_GROUP_NAME)
    {
		Ogre::String grp = DEFAULT_RESOURCE_GROUP_NAME;
        if (mgr.resourceExists(grp, resourceName))
        {
            groupName = grp;
            return true;
        }
    }

    return false;
}
void DotSceneLoader::processEntity(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent)
{
	// Process attributes
	Ogre::String name = getAttrib(XMLNode, "name");
	Ogre::String id = getAttrib(XMLNode, "id");
	Ogre::String meshFile = getAttrib(XMLNode, "meshFile");
	Ogre::String materialFile = getAttrib(XMLNode, "materialFile");
	bool isStatic = getAttribBool(XMLNode, "static", false);;
	bool castShadows = getAttribBool(XMLNode, "castShadows", true);

	// TEMP: Maintain a list of static and dynamic objects
	if (isStatic)
		staticObjects.push_back(name);
	else
		dynamicObjects.push_back(name);

	rapidxml::xml_node<>* pElement;

	// Process vertexBuffer (?)
	pElement = XMLNode->first_node("vertexBuffer");
	if (pElement)
		;//processVertexBuffer(pElement);

	// Process indexBuffer (?)
	pElement = XMLNode->first_node("indexBuffer");
	if (pElement)
		;//processIndexBuffer(pElement);

	// Create the entity
	Ogre::Entity *pEntity = 0;
	try
	{
		Ogre::MeshManager::getSingleton().load(meshFile, m_sGroupName);
		pEntity = mSceneMgr->createEntity(name, meshFile);
		pEntity->setCastShadows(castShadows);
		pParent->attachObject(pEntity);

		if (!materialFile.empty())
			pEntity->setMaterialName(materialFile);
	}
	catch (Ogre::Exception &/*e*/)
	{
		Ogre::LogManager::getSingleton().logMessage("[DotSceneLoader] Error loading an entity!");
	}

	// Process userDataReference (?)
	pElement = XMLNode->first_node("userDataReference");
	if (pElement)
		processUserDataReference(pElement, pEntity);


}
Esempio n. 17
0
bool OgreSubsystem::LoadOgrePlugins(Ogre::String const & pluginsfile)
{
	Ogre::StringVector pluginList;
	Ogre::String pluginDir;
	Ogre::ConfigFile cfg;

	try
	{
		cfg.load( pluginsfile );
	}
	catch (Ogre::Exception)
	{
		Ogre::LogManager::getSingleton().logMessage(pluginsfile + " not found, automatic plugin loading disabled.");
		return false;
	}

	pluginDir = cfg.getSetting("PluginFolder"); // Ignored on Mac OS X, uses Resources/ directory
	pluginList = cfg.getMultiSetting("Plugin");

#if OGRE_PLATFORM != OGRE_PLATFORM_APPLE && OGRE_PLATFORM != OGRE_PLATFORM_IPHONE
	if (pluginDir.empty())
	{
		// User didn't specify plugins folder, try current one
		pluginDir = ".";
	}
#endif

	char last_char = pluginDir[pluginDir.length()-1];
	if (last_char != '/' && last_char != '\\')
	{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
		pluginDir += "\\";
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
		pluginDir += "/";
#endif
	}

	for ( Ogre::StringVector::iterator it = pluginList.begin(); it != pluginList.end(); ++it )
	{
		Ogre::String pluginFilename = pluginDir + (*it);
		try
		{
			m_ogre_root->loadPlugin(pluginFilename);
		} 
		catch(Ogre::Exception &e)
		{
			LOG("failed to load plugin: " + pluginFilename + ": " + e.getFullDescription());
		}
	}
	return true;
}
Esempio n. 18
0
/*-----------------------------------------------------------------------------
 | Initialize the RT Shader system.	
 -----------------------------------------------------------------------------*/
bool DemoApp::initializeRTShaderSystem(Ogre::SceneManager* sceneMgr)
{			
    if (Ogre::RTShader::ShaderGenerator::initialize())
    {
        mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
        
        mShaderGenerator->addSceneManager(sceneMgr);
        
        // Setup core libraries and shader cache path.
        Ogre::StringVector groupVector = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
        Ogre::StringVector::iterator itGroup = groupVector.begin();
        Ogre::StringVector::iterator itGroupEnd = groupVector.end();
        Ogre::String shaderCoreLibsPath;
        Ogre::String shaderCachePath;
        
        for (; itGroup != itGroupEnd; ++itGroup)
        {
            Ogre::ResourceGroupManager::LocationList resLocationsList = Ogre::ResourceGroupManager::getSingleton().getResourceLocationList(*itGroup);
            Ogre::ResourceGroupManager::LocationList::iterator it = resLocationsList.begin();
            Ogre::ResourceGroupManager::LocationList::iterator itEnd = resLocationsList.end();
            bool coreLibsFound = false;
            
            // Try to find the location of the core shader lib functions and use it
            // as shader cache path as well - this will reduce the number of generated files
            // when running from different directories.
            for (; it != itEnd; ++it)
            {
                if ((*it)->archive->getName().find("RTShaderLib") != Ogre::String::npos)
                {
                    shaderCoreLibsPath = (*it)->archive->getName() + "/";
                    shaderCachePath = shaderCoreLibsPath;
                    coreLibsFound = true;
                    break;
                }
            }
            // Core libs path found in the current group.
            if (coreLibsFound) 
                break; 
        }
        
        // Core shader libs not found -> shader generating will fail.
        if (shaderCoreLibsPath.empty())			
            return false;			
        
        // Create and register the material manager listener.
        mMaterialMgrListener = new ShaderGeneratorTechniqueResolverListener(mShaderGenerator);				
        Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener);
    }
    
    return true;
}
void ActorAnimationSettingEditor::OnListBoxAnimationDoubleClick( wxCommandEvent &event )
{
	if (mListBoxAnimation->GetSelection() == wxNOT_FOUND)
		return;

	mDObject->delCurrentSkill();

	Ogre::String animName = mListBoxAnimation->GetStringSelection().c_str();

	assert ( !animName.empty() );

	mDObject->createSkill( animName,m_Frame->GetGraphDialog()->GetLoop(), true, mAnimationFadeOutTime);
	m_Frame->GetGraphDialog()->InitAnimTimePosSlider();
}
Esempio n. 20
0
//------------------------------------------
Enemy::Enemy(const Ogre::String& meshName,const Ogre::String& headMesh,const Ogre::Vector3& pos, Ogre::SceneNode* pParent)
:m_pEntity(NULL),m_pNode(NULL),m_pSceneMrg(pParent->getCreator()),m_pAniSate(NULL),m_LifeValue(30),m_State(ES_NORMAL),m_Rotate(0),
m_pHeadEnity(NULL),m_HurtTime(0.0f),m_Trans(0.0f,0.0f,0.0f),m_AniFade(0.0f),m_pMouthEntity(NULL),m_pSwallow(NULL)
{

	m_pEntity=m_pSceneMrg->createEntity("Enemy"+Ogre::StringConverter::toString(m_EntityIndex++),meshName);
	m_pNode=pParent->createChildSceneNode();
	m_pNode->attachObject(m_pEntity);
	m_pNode->setPosition(pos);

	bool b=m_pEntity->hasSkeleton();

	if(headMesh.empty()==false)
	{
		m_pHeadEnity=m_pSceneMrg->createEntity(headMesh);
        assert(m_pHeadEnity);
		m_pNode->attachObject(m_pHeadEnity);
		m_pHeadEnity->shareSkeletonInstanceWith(m_pEntity);


		///加载嘴部模形,用于检查是否击中嘴部

		m_pMouthEntity=m_pSceneMrg->createEntity("mouth.mesh");
		m_pMouthEntity->shareSkeletonInstanceWith(m_pEntity);
		m_pNode->attachObject(m_pMouthEntity);
		m_pMouthEntity->setVisible(false);
		


	}

	m_pEntity->setQueryFlags(EnemyMask);
	m_pAniSate=NULL;
	m_pMaterial=m_pEntity->getSubEntity(0)->getMaterial();



	//m_pMouthEntity=m




	///播放休闲动作
   playAnimation(g_idleAni,true,0);

  



}
Esempio n. 21
0
/**
 * This function is called when the visual item was positioned in the
 * backpack.
 */
void WeaponBackpackItem::updated(void)
{
	if(!mText) return;

	// here we have to put the number of units if we can
	Ogre::String str;
	getAmmoText(str);
	if(str.empty()){
		// hide the text?
		return;
	}
	// set the text
	mText->setCaption(str);
	positionText();
}
Esempio n. 22
0
bool VehicleRenderable::loadSceneNodes(TinyXml::TiXmlElement* ele)
{
	TinyXml::TiXmlElement* nodeEle = ele->FirstChildElement("node");
	while (nodeEle)
	{
		Ogre::String name = getAttrib(nodeEle, "name");
		Ogre::SceneNode* node = NULL;

		if (name.empty())
			node = mAttachNode->createChildSceneNode();
		else
			node = mAttachNode->createChildSceneNode(name);

		mSceneNodes.push_back(node);

		Ogre::LogManager::getSingleton().
			logMessage("VehicleRenderable : parsing <" + name + "> node...");

		//process position
		TinyXml::TiXmlElement* pos = nodeEle->FirstChildElement("position");
		node->setPosition(parseVector3(pos));
		node->setInitialState();

		//process scale
		TinyXml::TiXmlElement* scale = nodeEle->FirstChildElement("scale");
		node->setScale(parseVector3(scale));
		node->setInitialState();

		//process rotate
		TinyXml::TiXmlElement* rotate = nodeEle->FirstChildElement("rotation");
		node->setOrientation(parseQuaternion(rotate));
		node->setInitialState();

		//process entities
		TinyXml::TiXmlElement* entity = nodeEle->FirstChildElement("entity");
		while (entity)
		{
			if (!loadEntity(entity, node))
				return false;

			entity = entity->NextSiblingElement("entity");
		}

		nodeEle = nodeEle->NextSiblingElement("node");
	}

	return true;
}
Esempio n. 23
0
Ogre::ResourcePtr
loadCorrelativeResource(const Ogre::String& resourceName, const Ogre::String& groupName,
                        const Ogre::String& baseResourceName, const Ogre::String& baseGroupName,
                        Ogre::ResourceManager& resourceManager)
{
    Ogre::ResourcePtr res;

   Ogre::String name, path;
    Ogre::StringUtil::splitFilename(resourceName, name, path);
    bool existsPath = !path.empty();

    // First, load in correlatived group and path if resource name doesn't exists path
    if (!existsPath)
    {
        Ogre::StringUtil::splitFilename(baseResourceName, name, path);
        if (!path.empty())
        {
            name = path + resourceName;
            res = tryLoadResource(resourceManager, name, baseGroupName);
            if (!res.isNull())
                return res;
        }
    }

    // Second, load in correlatived group
    res = tryLoadResource(resourceManager, resourceName, baseGroupName);
    if (!res.isNull())
        return res;

    // Three, load in user given group
    if (!groupName.empty())
    {
        res = tryLoadResource(resourceManager, resourceName, groupName);
        if (!res.isNull())
            return res;
    }

    // Four, load in global default group
    if (groupName != DEFAULT_RESOURCE_GROUP_NAME)
    {
        res = tryLoadResource(resourceManager, resourceName, groupName);
        if (!res.isNull())
            return res;
    }

    return res;
}
Esempio n. 24
0
//-----------------------------------------------------------------------------
int COFSSceneSerializer::_writeFile(Ogre::String exportfile, const bool forceSave)
{
    if (exportfile.empty())
        return SCF_ERRUNKNOWN;

    OgitorsRoot *ogRoot = OgitorsRoot::getSingletonPtr();
    // Open a stream to output our XML Content and write the general headercopyFile
    std::stringstream outfile;

    outfile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    outfile << "<OGITORSCENE version=\"" << Globals::OGSCENE_FORMAT_VERSION << "\">\n";

    PROJECTOPTIONS *pOpt = ogRoot->GetProjectOptions();
    pOpt->CameraSpeed = ogRoot->GetViewport()->GetCameraSpeed();

    ogRoot->WriteProjectOptions(outfile, pOpt);

    ObjectVector ObjectList;
    OgitorsPropertyValueMap theList;
    OgitorsPropertyValueMap::iterator ni;

    // Start from 1, since 0 means all objects
    for(unsigned int i = 1; i < LAST_EDITOR; i++)
    {
        ogRoot->GetObjectList(i, ObjectList);
        for(unsigned int ob = 0; ob < ObjectList.size(); ob++)
        {
            /// If Object does not have a parent, then it is not part of the scene
            if(ObjectList[ob]->getParent())
            {
                ObjectList[ob]->onSave(forceSave);
                if(ObjectList[ob]->isSerializable())
                {
                    outfile << OgitorsUtils::GetObjectSaveStringV2(ObjectList[ob], 2, true, true).c_str();
                    outfile << "\n";
                }
            }
        }
    }
    outfile << "</OGITORSCENE>\n";

    if (OgitorsUtils::SaveStreamOfs(outfile, exportfile)) {
        return SCF_OK;
    }

    return SCF_ERRFILE;
}
Esempio n. 25
0
	VBOOL splitResourceName(const Ogre::String& name,Ogre::String& resourceName,Ogre::String& groupName)
	{
		Ogre::String::size_type pos = name.find_first_of(':');
		if (pos ==Ogre::String::npos)
		{
			if (groupName.empty())
				groupName = DEFAULT_RESOURCE_GROUP_NAME;
			resourceName = name;
			return VFALSE;
		}
		else
		{
			groupName = name.substr(0, pos);
			resourceName = name.substr(pos+1,Ogre::String::npos);
			return VTRUE;
		}
	}
void DotSceneLoader::processLookTarget(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent)
{
	//! @todo Is this correct? Cause I don't have a clue actually

	// Process attributes
	Ogre::String nodeName = getAttrib(XMLNode, "nodeName");

	Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_PARENT;
	Ogre::String sValue = getAttrib(XMLNode, "relativeTo");
	if (sValue == "local")
		relativeTo = Ogre::Node::TS_LOCAL;
	else if (sValue == "parent")
		relativeTo = Ogre::Node::TS_PARENT;
	else if (sValue == "world")
		relativeTo = Ogre::Node::TS_WORLD;

	rapidxml::xml_node<>* pElement;

	// Process position (?)
	Ogre::Vector3 position;
	pElement = XMLNode->first_node("position");
	if (pElement)
		position = parseVector3(pElement);

	// Process localDirection (?)
	Ogre::Vector3 localDirection = Ogre::Vector3::NEGATIVE_UNIT_Z;
	pElement = XMLNode->first_node("localDirection");
	if (pElement)
		localDirection = parseVector3(pElement);

	// Setup the look target
	try
	{
		if (!nodeName.empty())
		{
			Ogre::SceneNode *pLookNode = mSceneMgr->getSceneNode(nodeName);
			position = pLookNode->_getDerivedPosition();
		}

		pParent->lookAt(position, relativeTo, localDirection);
	}
	catch (Ogre::Exception &/*e*/)
	{
		Ogre::LogManager::getSingleton().logMessage("[DotSceneLoader] Error processing a look target!");
	}
}
Esempio n. 27
0
//-----------------------------------------------------------------------
void AtlasImageTool::initialise (const Ogre::String& configFileName)
{
	if (!configFileName.empty())
	{
		mConfigFile.load(configFileName);
	}
	else
	{
		mConfigFile.load("atlas.cfg");
	}

	mInputFileNames = Ogre::StringUtil::split(mConfigFile.getSetting("InputImage"), ";, ");
	mInputFrames = Ogre::StringUtil::split(mConfigFile.getSetting("Frame"), ";, ");
	mAlpha = Ogre::StringUtil::split(mConfigFile.getSetting("Alpha"), ";, ");
	mOutputImage = mConfigFile.getSetting("OutputImage");
	mImagePath = mConfigFile.getSetting("ImagePath");
	mAtlasImage.setAlwaysUpdate(false); // Manual compilation to speed things up.
}
Esempio n. 28
0
		virtual void setupResources(void)
		{
			GraphicsSystem::setupResources();

			Ogre::ConfigFile cf;
			cf.load(mResourcePath + "resources2.cfg");

			Ogre::String dataFolder = cf.getSetting("DoNotUseAsResource", "Hlms", "");

			if (dataFolder.empty())
				dataFolder = "./";
			else if (*(dataFolder.end() - 1) != '/')
				dataFolder += "/";

			dataFolder += "2.0/scripts/materials/PbsMaterials";

			addResourceLocation(dataFolder, "FileSystem", "General");
		}
Esempio n. 29
0
	MainSkin::MainSkin(const SubWidgetInfo& _info, const Ogre::String& _material, CroppedRectanglePtr _parent, size_t _id) : 
		CroppedRectangleInterface(_info.coord, _info.align, _parent)
	{

		Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();

		mOverlayContainer = static_cast<SharedPanelAlphaOverlayElement*>( overlayManager.createOverlayElement(
			"SharedPanelAlpha", utility::toString("MainSkin_", this)) );

		// устанавливаем колличество саб оверлеев
		mOverlayContainer->setCountSharedOverlay(1);

		//mOverlayContainer->setMetricsMode(Ogre::GMM_PIXELS);
		mOverlayContainer->setPositionInfo(mParent->getLeft() + mCoord.left, mParent->getTop() + mCoord.top, mCoord.width, mCoord.height, 0);
		if (false == _material.empty() && (_info.coord.width != 0)) mOverlayContainer->setMaterialName(_material);

		mParent->_attachChild(this, false);
	}
void ActorAnimationSettingDialog::OnListBoxAnimationDoubleClick( wxCommandEvent &event )
{
	if (mListBoxAnimation->GetSelection() == wxNOT_FOUND)
		return;

	mDObject->delCurrentSkill();

	Ogre::String animName = mListBoxAnimation->GetStringSelection().c_str();

	assert ( !animName.empty() );

	mDObject->createSkill( animName, mCheckBoxLoop->GetValue(), true, mAnimationFadeOutTime);
	InitAnimTimePosSlider();

	// 关闭skill编辑框
	if (mFairySkillEditDialog)
	{
		mFairySkillEditDialog->Hide();
	}
}