CBase_AnalysisMethod	*CBase_AnalysisTemplate::CreateNewMethod(CString cStrName, CString cStrNameFrom)
{
	//必须具有名字
	if(cStrName.GetLength()<1) return NULL;

	CBase_AnalysisMethod *pcMethod = NULL;

	if(m_pcCurrentMethod->IsNameExist(cStrName)) {
		AfxMessageBox(_T("该方法名称已经存在!"));
		return NULL;
	}

	pcMethod = new CBase_AnalysisMethod(cStrName, this);


	//判断参照方法是否存在
	if(cStrNameFrom.GetLength()>0) {
		CBase_AnalysisMethod *pcMethodFrom = LoadMethod(cStrNameFrom);
		if(pcMethodFrom) {
			pcMethod->GetDataFrom(*pcMethodFrom);
			delete pcMethodFrom;
		}
	}

	return pcMethod;
}
Exemple #2
0
// Creates a DirectX specific material from an imported material
bool CMesh::CreateMaterialDX
(
	const SMeshMaterial& material,
	SMeshMaterialDX*     materialDX
)
{
	// Load shaders for render method
	materialDX->renderMethod = material.renderMethod;
	if (!LoadMethod( materialDX->renderMethod ))
	{
		return false;
	}

	// Copy colours and shininess from material
	materialDX->diffuseColour = D3DXCOLOR( material.diffuseColour.r, material.diffuseColour.g, 
	                                       material.diffuseColour.b, material.diffuseColour.a );
	materialDX->specularColour = D3DXCOLOR( material.specularColour.r, material.specularColour.g, 
	                                        material.specularColour.b, material.specularColour.a );
	materialDX->specularPower = material.specularPower;

	// Load material textures
	materialDX->numTextures = material.numTextures;
	for (TUInt32 texture = 0; texture < material.numTextures; ++texture)
	{
		string fullFileName = MediaFolder + material.textureFileNames[texture];
		if (FAILED(D3DXCreateTextureFromFile( g_pd3dDevice, fullFileName.c_str(),
											  &materialDX->textures[texture] )))
		{
			string errorMsg = "Error loading texture " + fullFileName;
			SystemMessageBox( errorMsg.c_str(), "CMesh Error" );
			return false;
		}
	}
	return true;
}
Exemple #3
0
    void Action::load(int version, const char* agentType, const properties_t& properties)
    {
        super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "Method") == 0)
            {
                if (p.value[0] != '\0')
                {
                    this->m_method = Action::LoadMethod(p.value);
                }
            }
            else if (strcmp(p.name, "ResultOption") == 0)
            {
                if (strcmp(p.value, "BT_INVALID") == 0)
                {
                    m_resultOption = BT_INVALID;

                }
                else if (strcmp(p.value, "BT_FAILURE") == 0)
                {
                    m_resultOption = BT_FAILURE;

                }
                else if (strcmp(p.value, "BT_RUNNING") == 0)
                {
                    m_resultOption = BT_RUNNING;

                }
                else
                {
                    m_resultOption = BT_SUCCESS;
                }
            }
            else if (strcmp(p.name, "ResultFunctor") == 0)
            {
                if (p.value[0] != '\0')
                {
                    this->m_resultFunctor = LoadMethod(p.value);
                }
            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }
    }
    void SelectorProbability::load(int version, const char* agentType, const properties_t& properties)
    {
		super::load(version, agentType, properties);

        for (propertie_const_iterator_t it = properties.begin(); it != properties.end(); ++it)
        {
            const property_t& p = (*it);

            if (strcmp(p.name, "RandomGenerator") == 0)
            {
				if (p.value[0] != '\0')
				{
					this->m_method = LoadMethod(p.value);
				}//if (p.value[0] != '\0')
            }
            else
            {
                //BEHAVIAC_ASSERT(0, "unrecognised property %s", p.name);
            }
        }
    }
BOOL CBase_AnalysisTemplate::ChangeCurrentMethod(CString cStrMethod, BOOL bSaveOldMethod)
{
	//通过名称调入方法
	if(cStrMethod.GetLength()<1) return FALSE;
	if(m_pcCurrentMethod && m_pcCurrentMethod->GetName()==cStrMethod)
	{
		//如果名称相同,继续使用当前内存中的方法
		return TRUE;//m_pcCurrentMethod->Run();//tiewen 09-06-02 16:05
	}

	//调入方法
	CBase_AnalysisMethod *pcMethod = LoadMethod(cStrMethod);
	if(!pcMethod) return FALSE;
/*
	//将老的方法存盘
	if(bSaveOldMethod) {
		if(!m_pcCurrentMethod->Save()) {
			delete pcMethod;
			return FALSE;
		}
	}
*/
	return ChangeCurrentMethod(pcMethod, bSaveOldMethod);
/*
	if(m_pcCurrentMethod)
		delete m_pcCurrentMethod;

	//将调入方法作为缺省方法
	m_pcCurrentMethod = pcMethod;

	//更新到界面 090608 16:34
	AfxGetMainWnd()->SendMessage(WM_REFRESHCURRENTMETHOD);

	//运行该方法
	return 
		m_pcCurrentMethod->Run();
*/
}