コード例 #1
0
ファイル: VLogicModel.cpp プロジェクト: asnwerear/VEngine
void VLogicModel::_createEntities()
{
    VEntityMap::iterator itr;
    for (itr = mEntities.begin(); itr != mEntities.end(); ++itr)
    {
        Ogre::Entity *entity = VNULL;
        VEntityValue &entValue = itr->second;

        VString meshName = entValue.mMeshName;
        VString materialName = entValue.mMaterialName;

        try
        {
            Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(meshName);
        }
        catch (const Ogre::Exception &e)
        {
            Ogre::LogManager::getSingleton().logMessage(e.getDescription());
            continue;
        }

        if (!meshName.empty())
        {
            entValue.mEntity = _createEntity(meshName);
            if (entValue.mEntity && !materialName.empty())
            {
                _setEntityMaterial(itr->first, entValue.mMaterialName);
            }
        }
    }
}
コード例 #2
0
ファイル: VDirAdapter.cpp プロジェクト: asnwerear/Demo
	bool VDirAdapter::remove(const VString &strFileName)
	{
		if (strFileName.empty() || strFileName == "")
			return false;

		return (remove(strFileName.c_str()) == 0);
	}
コード例 #3
0
ファイル: VDirAdapter.cpp プロジェクト: asnwerear/Demo
	bool VDirAdapter::removeDir(const VString &strDir)
	{
		if (strDir.empty() || strDir == "")
			return false;

		return (rmdir(strDir.c_str()) == 0);
	}
コード例 #4
0
ファイル: VLogicModel.cpp プロジェクト: asnwerear/VEngine
VBOOL VLogicModel::changeEntity(const VString &name, const VString &value)
{
    VEntityMap::iterator itr = mEntities.find(name);

    if (itr == mEntities.end())
    {
        Ogre::LogManager::getSingleton().logMessage("Logic Model Entity with name '" + name + "' dosen't exists! " +
                "LogicModel::changeEntity " + mName);
        return VFALSE;
    }

    VEntityValue &tempValue = itr->second;

    if (tempValue.mEntity)
    {
        //

        //
        _destroyEntity(tempValue.mEntity);
        tempValue.mEntity = VNULL;
    }

    if (!value.empty())
    {
        tempValue.mEntity = _createEntity(value);
    }

    //
    if (VNULL == mExternalBoundingBox)
    {
        _updateBoundingBox();
    }

    return VTRUE;
}
コード例 #5
0
ファイル: VLogicModel.cpp プロジェクト: asnwerear/VEngine
VBOOL VLogicModel::changeSlotAttrib(const VString &name, const VString &value)
{
    for (VLocatorMap::iterator itr = mLocators.begin(); itr != mLocators.end(); ++itr)
    {
        VLocatorValue &locator = itr->second;
        VSlotMap::iterator i = locator.mSlots.find(name);

        if (i != locator.mSlots.end())
        {
            VSlotValue &slot = i->second;

            if (value.empty())
            {
                if (slot.mModel != VNULL)
                {
                    VLOGIC_MODEL_MANAGER.destroyLogicModel(slot.mModel);
                }

                slot.mModel = VNULL;
                slot.mModelName = value;
                return VTRUE;
            }
            else
            {
                slot.mModelName = value;
                return _createModelInSlot(slot, locator);
            }
        }
    }

    return VFALSE;
}
コード例 #6
0
ファイル: VDirAdapter_Unix.cpp プロジェクト: asnwerear/Demo
	bool VDirAdapter_Unix::makeDir(const VString &strDir)
	{
        if (strDir.empty() || strDir == "")
            return false;
        
		return (mkdir(strDir.c_str(), S_IRWXU) == 0);
	}
コード例 #7
0
ファイル: VLogicModel.cpp プロジェクト: asnwerear/VEngine
VBOOL VLogicModel::_changeAnimation(const VString &animName, const Real &delay)
{
    VBOOL result = VFALSE;

    if (animName.empty())
    {
        mCurrentAnimationName = "";
        mCurrentAnimationState = VNULL;
        result = VTRUE;
    }
    else
    {
        try
        {
            if (mSkeletonEntity != VNULL)
            {
                mCurrentAnimationState = _getAnimationState(animName);
                mSkeleton->getAnimation(animName)->setInterpolationMode(VLOGIC_MODEL_MANAGER.getAnimationInterpolationMode());
            }
            else
            {
                Ogre::LogManager::getSingleton().logMessage( "Logic Model : " + mName +
                        " Skeleton Entity is NULL, Maybe the skeleton file is lost!" +
                        "LogicModel::_changeAnimation");
            }
        }
        catch (const Ogre::Exception &e)
        {
            Ogre::LogManager::getSingleton().logMessage("Model : " + mName + '\n' + "_getAnimationState Failed!");
            mCurrentAnimationState = NULL;

            OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED,
                        "Resource was incorrectness due incaution producer. "
                        "Full error description: " + e.getFullDescription(),
                        "LogicModel::_changeAnimation");
        }

        if (mCurrentAnimationState != VNULL)
        {
            mCurrentAnimationState->setEnabled(VTRUE);
            mCurrentAnimationState->setTimePosition(0.0f);
            mCurrentAnimationState->setWeight(1);
            mCurrentAnimationName = animName;
            result = VTRUE;
        }
        else
        {
            mCurrentAnimationName = "";
            result = VFALSE;
        }
    }

    return result;
}
コード例 #8
0
ファイル: VDirAdapter_Unix.cpp プロジェクト: asnwerear/Demo
    bool VDirAdapter_Unix::findFile(const VString &strPath)
	{
        if (strPath.empty() || strPath == "")
        {
            return false;
        }
        
        extractRoot(strPath, m_strRoot);
        extractExt(strPath, m_strExt);
        m_pDir = opendir(m_strRoot.c_str());
        m_bExtractName = false;
        
		return (m_pDir != NULL);
	}
コード例 #9
0
ファイル: VDirAdapter.cpp プロジェクト: asnwerear/Demo
	bool VDirAdapter::findFile(const VString &strPath)
	{
		if (strPath.empty() || strPath == "")
			return false;

#ifdef UNICODE
		WCHAR wszPath[512] = {0};
		::MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), strPath.length(), wszPath, sizeof(wszPath));
		m_hFindFile = ::FindFirstFile(wszPath, &m_FindFileData);
#else
		m_hFindFile = ::FindFirstFile(strPath.c_str(), &m_FindFileData);
#endif
		
		extractRoot(strPath, m_strRoot);

		m_bExtractName = false;

		return (m_hFindFile != INVALID_HANDLE_VALUE);
	}
コード例 #10
0
ファイル: VLogicModel.cpp プロジェクト: asnwerear/VEngine
VBOOL VLogicModel::_setEntityMaterial(const VString &entityName, const VString &matName)
{
    if (matName.empty())
    {
        return VTRUE;
    }
    else
    {
        VEntityMap::iterator itr = mEntities.find(entityName);

        if (itr == mEntities.end())
        {
            Ogre::LogManager::getSingleton().logMessage( "Logic Model Entity with name '" + entityName + "' dosen't exists! " +
                    "LogicModel::_setEntityMaterial " + mName );
            return VFALSE;
        }

        VEntityValue &entValue = itr->second;
        Ogre::Entity *entity = entValue.mEntity;
        assert(entity);

        if (matName.find(";") != VString::npos)
        {
            Ogre::StringVector matNames = Ogre::StringUtil::split(matName, ";");
            assert(matName.size() > 1);

            for (VUINT32 i = 0; i < entity->getNumSubEntities(); ++i)
            {
                Ogre::SubEntity *subEntity = entity->getSubEntity(i);
                assert(subEntity);

                VString subMatName;

                if (i < matNames.size())
                {
                    subMatName = matNames[i];
                }
                else
                {
                    subMatName = matNames[0];
                }

                const Ogre::MaterialPtr subMat = Ogre::MaterialManager::getSingleton().getByName(subMatName);
                if (!subMat.isNull())
                {
                    subEntity->setMaterialName(subMatName);
                }
            }
        }
        else
        {
            const Ogre::MaterialPtr entityMat = Ogre::MaterialManager::getSingleton().getByName(matName);
            if (!entityMat.isNull())
            {
                entity->setMaterialName(matName);
            }
        }
    }

    return VTRUE;
}