当前位置: 首页>>代码示例>>C++>>正文


C++ IArchive::Close方法代码示例

本文整理汇总了C++中IArchive::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ IArchive::Close方法的具体用法?C++ IArchive::Close怎么用?C++ IArchive::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IArchive的用法示例。


在下文中一共展示了IArchive::Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadModel

void CModelViewRender::LoadModel()
{
    ASSERT(GetDocument() != NULL);
    CString strPath = GetDocument()->GetPathName();
    LPCTSTR szPath = strPath;
    TCHAR extStr[_MAX_EXT];
    TCHAR fileName[_MAX_FNAME];
    _tsplitpath(szPath, NULL, NULL, fileName, extStr);

    if (strPath.IsEmpty())
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel shouldn't have been called with NULL path\n"), __FILE__, __LINE__);
        return;
    }

    StdString szFilename = fileName;
    szFilename += extStr;
    m_hszModelName = szFilename;

    CFileVersionSetter setter( _T("2.5") );

    if (0 == _tcsicmp(extStr, _T(".cfg")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath, _T("Filepath"));
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("Cal3DRenderObject"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            FillAnimationList();
            pArchive->Close();
        }
    }
    else if (0 == _tcsicmp(extStr, _T(".hrc")))
    {
        IArchive *pArchive = CreateMemoryArchive();
        if (pArchive != NULL)
        {
            pArchive->Write(szPath);
            pArchive->SetIsWriting(false);
            static CHashString hszCal3DRenderObject(_T("CHierarchicalModel"));
            CreateEEObject(&m_hszEntityName, &hszCal3DRenderObject, m_hszModelName, pArchive);
            pArchive->Close();
        }
    }
    else
    {
        m_ToolBox->Log(LOGWARNING, _T("%s(%i):LoadModel was passed %s extension, which is not recognized\n"), __FILE__, __LINE__, extStr);
    }
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:51,代码来源:ModelViewRender.cpp

示例2: DeductCredits

int GameComponent::DeductCredits( int credits )
{
#ifdef _SHELL
	// deduct hardware credits
	return ::DeductCredits( credits );
#else
	// deduct software credits
	IArchive *archive = CreateMemoryArchive();
	if (archive)
	{
		archive->SetIsWriting(true);
		CHashString hsAttribName(_T("Credits"));
		GetGlobalAttribute(&hsAttribName, archive);

		archive->SetIsWriting(false);
		int currCredits = 0;
		archive->Read(currCredits, _T("Credits"));
		
		currCredits -= credits;
        SetGlobalAttribute(&hsAttribName, currCredits);

		archive->Close();
	}

	return 0;
#endif
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:27,代码来源:GameComponent.cpp

示例3: LoadTextFile

bool CGUIStaticText::LoadTextFile(const TCHAR *szFilename)
{
	if (_tcscmp(szFilename, "") != 0)
	{
		CREATEARCHIVE ca;
		ca.mode = 0x00000001;
		static CHashString type = _T("File");
		ca.streamType = &type;
		ca.streamData = (void*) szFilename;
		static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
		DWORD retval = EngineGetToolBox()->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca);
		if ((retval == MSG_NOT_HANDLED) || (retval == MSG_ERROR) || (retval == MSG_WARNING))
		{
			return false;
		}
		
		IArchive *ar = ca.archive;
		StdString szTemp;
		unsigned int numBytes = ar->Read(szTemp);
		ar->Close();
		if (numBytes > 0)
		{
			m_szText = szTemp;
			return true;
		}
		else 
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:35,代码来源:CGUIStaticText.cpp

示例4: CreateScene

void CModelViewRender::CreateScene()
{
    Vec3 v3Zero(0.0f, 0.0f, 0.0f);
    EulerAngle eZero;
    Vec3 v3Scale(1.0f,1.0f,1.0f);
    StdString szEntityType(_T("EditorObject"));

    IArchive *pArchive = CreateMemoryArchive();
    pArchive->Write(_T("EditorObject"), _T("EntityType"));
    pArchive->Write(v3Zero, _T("Position"));
    pArchive->Write(eZero, _T("Rotation"));
    pArchive->Write(v3Scale, _T("Scale"));
    pArchive->SetIsWriting(false);

    // Create Instance of CEntity
    static CHashString hszEntity(_T("CEntity"));
    CreateEEObject(&m_hszSceneName, &hszEntity, m_hszEntityName, pArchive);

    pArchive->Close();

    m_v3Position.Set(0, 0, 0);
    m_v3CameraPos.Set(0.0f, 0.0f, 200.0f);
    m_v3Rotation.Set(0.0f, 0.0f, 0.0f);

    LoadModel();
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:26,代码来源:ModelViewRender.cpp

示例5: GetCreditCount

int GameComponent::GetCreditCount()
{
#ifdef _SHELL
	// get hardware credits
	return ::GetCreditCount();	
#else
	// get software credits
	IArchive *archive = CreateMemoryArchive();
	if (archive)
	{
		archive->SetIsWriting(true);
		CHashString hsAttribName(_T("Credits"));
		GetGlobalAttribute(&hsAttribName, archive);

		archive->SetIsWriting(false);
		int credits = 0;
		archive->Read(credits, _T("Credits"));
		archive->Close();
		return credits;
	}

	return 0;

#endif
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:25,代码来源:GameComponent.cpp

示例6: UpdateLanguageEntryText

void CGUIStaticText::UpdateLanguageEntryText()
{
	CHashString hszLangKey(m_szLangEntryKey);
	CHashString hszLangTextOut(_T(""));

	static DWORD dwZeroString = CHashString(_T("")).GetUniqueID();
	if (hszLangKey.GetUniqueID() != dwZeroString)
	{
		IArchive *ar = CreateAndFillArchive();
		
		GETLANGUAGETEXTPARAMS gltp;
		gltp.arParams = ar;
		gltp.hszKeyString = &hszLangKey;
		gltp.hszTranslatedText = &hszLangTextOut;
		static DWORD msgGetLanguageText = CHashString(_T("GetLanguageText")).GetUniqueID();

		m_ToolBox->SendMessage(msgGetLanguageText, sizeof(GETLANGUAGETEXTPARAMS), &gltp);

		if (m_pStaticText)
		{
			m_pStaticText->SetText(m_szFont, "", hszLangTextOut.GetString(), hszLangTextOut.GetString(), hszLangTextOut.GetString(), 
				hszLangTextOut.GetString(), m_iFontsize);
		}

		if (ar)
		{
			ar->Close();
		}
	}
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:30,代码来源:CGUIStaticText.cpp

示例7: UpdateWorldEventTrigger

void CWorldEventToolPal::UpdateWorldEventTrigger( void )
{
	static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
	static DWORD msgHash_GetComponentType = CHashString(_T("GetComponentType")).GetUniqueID();
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();

	static CHashString Hash_Type = CHashString(_T("CWorldEventTrigger"));

	CString buf;
	m_Name.GetLBText(m_Name.GetCurSel(), buf);
	CHashString hszName((TCHAR*)buf.GetBuffer());
	FINDOBJECTPARAMS param;
	param.hszName = &hszName;
	DWORD result = m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), &param);

	// object exists 
	if( param.bFound == true )
	{
		GETCOMPONENTTYPEPARAMS gctp;
		gctp.name = &hszName;
		m_ToolBox->SendMessage(msgHash_GetComponentType, sizeof(gctp), &gctp);

		// it is a world event, get values from it
		if ( (gctp.componenttype != NULL) && (gctp.componenttype->GetUniqueID() == Hash_Type.GetUniqueID()) )
		{
			CREATEARCHIVE ca;
			CHashString streamType(_T("Memory"));
			ca.streamData = NULL;
			ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ;
			ca.streamType = &streamType;
	 	
			m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca, NULL, NULL);
			IArchive *MemArchive = (ca.archive);

			MemArchive->SetIsWriting(true);
			MemArchive->SeekTo(0);

			SERIALIZEOBJECTPARAMS sop;
			sop.name = &hszName;
			sop.archive = MemArchive;
			m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);

			MemArchive->SetIsWriting(false);
			MemArchive->SeekTo(0);

			StdString tmp;
			MemArchive->Read( tmp );
			m_EntityName.SetWindowText( tmp.c_str() );
			MemArchive->Read( tmp );
			m_EntityType.SetWindowText( tmp.c_str() );
			MemArchive->Read( tmp );
			m_EventName.SetWindowText( tmp.c_str() );
			
			MemArchive->Close();
		}
	}
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:58,代码来源:WorldEventToolPal.cpp

示例8: SetGlobalAttribute

void GameComponent::SetGlobalAttribute( IHashString *attributeName, bool value )
{
	if( attributeName != NULL )
	{
		IArchive *archive = CreateMemoryArchive();
		archive->SetIsWriting( true );
		archive->Write( (bool)value );
		archive->SetIsWriting( false );

		SetGlobalAttribute( attributeName, archive );

		archive->Close();
	}
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:14,代码来源:GameComponent.cpp

示例9: TestCreateNode

bool CNodeSystemTest::TestCreateNode()
{
	bool result = true;
	bool subResult = false;

	CHashString hszNodeName(_T("Node1"));
	CHashString hszNodeType(_T("CNode"));

	m_dialogEditControl->ReplaceSel(_T("  Testing Creation of Node 1 - \n"));
	CreateObject( &hszNodeName, NULL, &hszNodeType );

	InitializeObject( &hszNodeName );

	m_dialogEditControl->ReplaceSel(_T("    Created node found in engine: "));

	subResult = FindObject( &hszNodeName );
	SUBREPORT( subResult );
	result = result && subResult;

	m_dialogEditControl->ReplaceSel(_T("    Verify default values: "));
	IArchive *archive = CreateMemoryArchive();
	SerializeObject( &hszNodeName, archive, true );

	float fVersion;
	float fX;
	float fY;
	float fZ;
	archive->SetIsWriting( false );
	archive->Read( fVersion );
	archive->Read( fX );
	archive->Read( fY );
	archive->Read( fZ );
	archive->Close();

	subResult = fVersion == 1.0f;
	subResult = subResult && fX == 0.0f;
	subResult = subResult && fY == 0.0f;
	subResult = subResult && fZ == 0.0f;
	SUBREPORT( subResult );

	result = result && subResult;

	DeleteObject( &hszNodeName );

	m_dialogEditControl->ReplaceSel(_T("  TestCreateNode overall: "));
	return result;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:47,代码来源:NodeSystemTest.cpp

示例10: streamType

IBaseTextureObject * CTextureManager::LoadCubeDDSTexture( IHashString* name )
{
	//Open the data stream
	DWORD result;

	IArchive *FileArchive;
	CHashString streamType(_T("File"));
	CREATEARCHIVE ca;

	ca.mode = STREAM_MODE_READ | STREAM_MODE_BINARY;
	ca.streamData = (void*)name->GetString();
	ca.streamType = &streamType;
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	result = m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca);
	
	IBaseTextureObject *pTexture = NULL;
	if( result == MSG_HANDLED )
	{
		FileArchive = dynamic_cast<IArchive *>(ca.archive);
		//Check DDS
		UINT fourcc;
		FileArchive->Read( fourcc );
		if( EE_ENDIANSWAP32(fourcc) != MAKEFOURCC( 'D', 'D', 'S', ' ' ) )
		{
			return NULL;
		}
		DDSHeader header;
		char * pheader = (char*)&header;
		//DDS, start loading header
		for( int i = 0; i < sizeof( header ); i++ )
		{
			FileArchive->Read( (*pheader) );
			pheader++;
		}
		//close the file, no longer needed
		FileArchive->Close();
		if( IsDDSCubeMap( header ) )
		{
			static CHashString DX9CubeTexObj(_T("CDX9CubeTextureObject")); 
			pTexture = CreateTextureObject( name, &DX9CubeTexObj);
			pTexture->LoadFromFile( name->GetString() );
		}
	}
	return pTexture;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:45,代码来源:CTextureManager.cpp

示例11: TestCreateNodeConnection

bool CNodeSystemTest::TestCreateNodeConnection()
{
	bool result = true;
	bool subResult = false;

	CHashString hszNodeConnectionName(_T("NodeConnection1"));
	CHashString hszNodeConnectionType(_T("CNodeConnection"));

	m_dialogEditControl->ReplaceSel(_T("  Testing Creation of Node Connection 1 - \n"));
	CreateObject( &hszNodeConnectionName, NULL, &hszNodeConnectionType );

	InitializeObject( &hszNodeConnectionName );

	m_dialogEditControl->ReplaceSel(_T("    Created node found in engine: "));

	subResult = FindObject( &hszNodeConnectionName );
	SUBREPORT( subResult );
	result = result && subResult;

	m_dialogEditControl->ReplaceSel(_T("    Verify default values: "));
	IArchive *archive = CreateMemoryArchive();
	SerializeObject( &hszNodeConnectionName, archive, true );

	float fVersion;
	StdString szNode1;
	StdString szNode2;
	archive->SetIsWriting( false );
	archive->Read( fVersion );
	archive->Read( szNode1 );
	archive->Read( szNode2 );
	archive->Close();

	subResult = fVersion == 1.0f;
	subResult = subResult && szNode1 == "";
	subResult = subResult && szNode2 == "";
	SUBREPORT( subResult );

	result = result && subResult;

	DeleteObject( &hszNodeConnectionName );
	m_dialogEditControl->ReplaceSel(_T("  TestCreateNodeConnection overall: "));
	return result;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:43,代码来源:NodeSystemTest.cpp

示例12: OnSaveParticleFile

/////////////////////////////////////////////////////////////
// SAVE PARTICLE EMITTER
/////////////////////////////////////////////////////////////
DWORD CParticleLoader::OnSaveParticleFile(DWORD size, void *params)
{
	VERIFY_MESSAGE_SIZE(size, sizeof(TCHAR *));
	TCHAR *pFilepath = (TCHAR *)params;

	StdString szFilename = ExtractFileName(pFilepath);
	CHashString hszFilename(szFilename);

	StdString szFilepath(pFilepath);
	CHashString hszFilepath(pFilepath);

	DWORD result;
	
	// Check to see that Emitter Exists
	static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
	FINDOBJECTPARAMS param;
	param.hszName = &hszFilepath;
	result = m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), &param);
	if (param.bFound == false)
	{
		//Object does not exist to save out.
		return MSG_ERROR;
	}

	// Create XMLArchive using IXML
	IXMLArchive *XMLar;
	CHashString streamType(_T("File"));

	CREATEARCHIVE ca;
	ca.mode = STREAM_MODE_WRITE;
	ca.streamData = pFilepath;
	ca.streamType = &streamType;
	static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID();
	result = EngineGetToolBox()->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca);
	if( result == MSG_ERROR )
	{
		return MSG_ERROR;
	}

	XMLar = dynamic_cast<IXMLArchive *>(ca.archive);
	if( !XMLar )
	{
		return MSG_ERROR;
	}

	// Create MemArchive using IAR
	IArchive *MemArchive;
	CHashString memType(_T("Memory"));

	CREATEARCHIVE caOut;
	caOut.mode = STREAM_MODE_READ | STREAM_MODE_WRITE;
	caOut.streamData = NULL;
	caOut.streamSize = 0;
	caOut.streamType = &memType;
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &caOut) != MSG_HANDLED)
	{
		XMLar->Close();
		return MSG_ERROR;
	}
	MemArchive = caOut.archive;

	// Change the Memarchive to write
	MemArchive->SetIsWriting(true);

	// Serialize out Emitter Data
	SERIALIZEOBJECTPARAMS sop;
	sop.archive = MemArchive;
	sop.name = &hszFilepath;
	static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);

	// EMITTER PARSE VALUES
	StdString	szName(_T("ParticleEmitter"));
	StdString	szBrush(_T("Brush"));
	StdString	szKeyframe(_T("Keyframe"));

//	StdString	szDummy;
	float time = 0.0f;
	float value = 0.0f;
	StdString szEmitterName;
	int numBrushes = 0;
	int numKeyframes = 0;
	StdString	szBrushFilepath;
	StdString	szPropertyName;
	
	// Change the Memarchive to read
	MemArchive->SetIsWriting(false);

//	MemArchive->Read( szDummy, _T("filename"));
	MemArchive->Read( szEmitterName, _T("name"));
	MemArchive->Read( numBrushes, _T("brushes"));
	MemArchive->Read( numKeyframes, _T("keyframes"));

	XMLar->StartClass(szName);
		XMLar->Write(szEmitterName, _T("name"));
		XMLar->Write(numBrushes, _T("brushes"));
//.........这里部分代码省略.........
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:101,代码来源:ParticleLoader.cpp

示例13: InitRenderScene

void CModelViewRender::InitRenderScene()
{
    // set active scene to model view scene so objects created here will be placed in the correct scene
    SetActiveScene();

    //Create Cal3DRenderObject from loaded file
    CreateScene();

    // create a new Memory Archive
    IArchive *pArchive = CreateMemoryArchive();
    if (pArchive == NULL)
    {
        return;
    }

    StdString szEntityType(_T("EditorObject"));
    //Vec3 v3Zero(0.0f, 0.0f, 0.0f);
    Vec3 v3EntityLightPosition(0.0f, 200.0f, 200.0f);
    EulerAngle eaZero;
    Vec3 v3Scale(1.0f, 1.0f, 1.0f);
    pArchive->Write(szEntityType, _T("EntityType"));
    pArchive->Write(v3EntityLightPosition, _T("Position"));
    pArchive->Write(eaZero, _T("Rotation"));
    pArchive->Write(v3Scale, _T("Scale"));
    pArchive->SetIsWriting(false);

    CFileVersionSetter setter;
    // Create the CEntity LightObject Parent /////////////////////////////////////////////////////////
    static CHashString hszCEntity(_T("CEntity"));
    if (CreateEEObject(&m_hszSceneName, &hszCEntity, m_hszLightEntityName, pArchive))
    {
        pArchive->SetIsWriting(true);
        pArchive->SeekTo(0);
        int iVersionNumber = 1000;
        Vec3 v3LightPosition( 0.0, 0.0f, 0.0f );
        Vec3 v3LightDirection( 0.0f, 0.0f, 0.0f );
        float fAttenuation = 99999.0f;
        float fColor[] = { 0.75f, 0.75f, 0.75f, 1.0f };
        StdString szLightType(_T("OMNI_POINT_LIGHT"));
        bool bCastShadows = false;
        UINT numKeys = 0;
        pArchive->Write(iVersionNumber, _T("Version"));
        pArchive->Write(v3LightPosition, _T("Position"));
        pArchive->Write(v3LightDirection, _T("Direction"));
        pArchive->Write(fAttenuation, _T("Attenuation"));
        pArchive->Write(fColor[0], _T("ColorRed") );
        pArchive->Write(fColor[1], _T("ColorGreen") );
        pArchive->Write(fColor[2], _T("ColorBlue") );
        pArchive->Write(fColor[3], _T("ColorAlpha") );
        pArchive->Write(szLightType, _T("LightType") );
        pArchive->Write(bCastShadows, _T("CastShadows") );
        pArchive->Write(numKeys, _T("NumKeyframes") );
        pArchive->SetIsWriting(false);

        // Create the Light Object ////////////////////////////////////////////////////////////////
        static CHashString hszCLightObject(_T("CLightObject"));
        CreateEEObject(&m_hszLightEntityName, &hszCLightObject, m_hszLightObjectName, pArchive);
    }

    pArchive->Close();
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:61,代码来源:ModelViewRender.cpp

示例14: OnLoadFile

DWORD CShaderEffectLoader::OnLoadFile(DWORD size, void *params)
{
	VERIFY_MESSAGE_SIZE(size, sizeof(TCHAR *));
	TCHAR *pFileName = (TCHAR *)params;

	if( _tcslen( pFileName ) == 0 )
	{
		m_ToolBox->Log( LOGWARNING, _T("Shader File is empty string") );
		return MSG_ERROR;
	}

	StdString szFileName(pFileName);
	szFileName.MakeSafeFileName();
	CHashString effectname( szFileName );

	// only load an effect file once
	static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
	FINDOBJECTPARAMS param;
	param.hszName = &effectname;
	m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), &param );
	if ( param.bFound == true )
	{
		// effect already loaded
		return MSG_HANDLED_STOP;
	}

	IArchive *MemArchive;
	// hash the file name
	CHashString streamType(_T("File"));
	// create a new archive and load the file
	CREATEARCHIVE ca;
	DWORD retVal;
	ca.streamData = pFileName;
	ca.mode = STREAM_MODE_READ;
	ca.streamType = &streamType;
	// call the Archive factory to create an XML archive
	static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID();
	if (retVal = m_ToolBox->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
	{
		m_ToolBox->Log( LOGWARNING, _T("SHADEREFFECTLOADER: %s\n\tCould not create XML Archive\n"), pFileName );
		return MSG_ERROR;
	}

	MemArchive = dynamic_cast<IXMLArchive *>(ca.archive);

	///create the cal model
	CREATEOBJECTPARAMS cop;
	INITOBJECTPARAMS iop;
	SERIALIZEOBJECTPARAMS sop;
	
	CHashString hszParentName( _T("World") );
	CHashString hszTypeName(_T("CEffect"));	

	cop.parentName = &hszParentName;
	cop.typeName = &hszTypeName;
	cop.name = &effectname;
	static DWORD msgHash_CreateObject = CHashString(_T("CreateObject")).GetUniqueID();
	DWORD retval = m_ToolBox->SendMessage(msgHash_CreateObject, sizeof(CREATEOBJECTPARAMS), &cop, NULL, NULL);

	sop.name = &effectname;
	sop.archive = MemArchive;
	static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);
	

	iop.name = &effectname;
	if( retval == MSG_HANDLED )
	{
		static DWORD msgHash_InitObject = CHashString(_T("InitObject")).GetUniqueID();
		retval = m_ToolBox->SendMessage(msgHash_InitObject, sizeof(INITOBJECTPARAMS), &iop, NULL, NULL);
	}

	MemArchive->Close();

	CREATEEFFECTINTERFACE addmsg;
	addmsg.m_Name = &effectname;
	static DWORD msgHash_AddEffect = CHashString(_T("AddEffect")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_AddEffect, sizeof( CREATEEFFECTINTERFACE ), &addmsg );
	return MSG_HANDLED_STOP;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:80,代码来源:ShaderEffectLoader.cpp

示例15: OnLoadWorldFile

// load a file if we recognize the type.
DWORD CXMLWorldLoader::OnLoadWorldFile(DWORD size, void *params)
{
	CHashString oldVersion = _T("");
	CREATEOBJECTPARAMS cop;
	INITOBJECTPARAMS iop;
	SERIALIZEOBJECTPARAMS sop;
	DWORD retVal;
	IXMLArchive *Archive = NULL;
	DWORD currNode = 0;
	LOADINGUPDATEPARAMS pbp;

	VERIFY_MESSAGE_SIZE(size, sizeof(TCHAR *));
	TCHAR *pFileName = (TCHAR *)params;

	// use both a hashstring and a pointer so that the first iteration of the loop
	// will pass SetParentName a NULL instead of an address of a hashstring
	// hashed to ""
	CHashString hszParentType(_T("CWorld"));
	CHashString hszParentName(_T("World"));
	CHashString hszName(_T(""));
	CHashString hszTypeName(_T(""));
	CHashString streamType(_T("File"));

	// delete previous world root
	DELETEOBJECTPARAMS dop;
	dop.name = &hszParentName;
	static DWORD msgHash_DeleteObject = CHashString(_T("DeleteObject")).GetUniqueID();
	EngineGetToolBox()->SendMessage(msgHash_DeleteObject, sizeof(dop), &dop );
	// delete is ok to fail if no world has been created yet

	// create new world root
	cop.name = &hszParentName;
	cop.parentName = NULL;
	cop.typeName = &hszParentType;
	static DWORD msgHash_CreateObject = CHashString(_T("CreateObject")).GetUniqueID();
	DWORD returnValue = EngineGetToolBox()->SendMessage(msgHash_CreateObject, sizeof(cop), &cop );
	if (returnValue != MSG_HANDLED)
	{
		EngineGetToolBox()->Log(LOGERROR, _T("Failed to create World Root Object\n"));
		return MSG_ERROR;
	}

	CREATEARCHIVE ca;
	ca.streamData = (void *)pFileName;
	ca.mode = STREAM_MODE_READ;
	ca.streamType = &streamType;
#ifdef USEXMLFILESTREAMS
	// call the Archive factory to create an XML archive
	static DWORD msgHash_CreateXMLArchiveStream = CHashString(_T("CreateXMLArchiveStream")).GetUniqueID();
	if (retVal = m_ToolBox->SendMessage(msgHash_CreateXMLArchiveStream, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
#else
	// call the Archive factory to create an XML archive
	static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID();
	if (retVal = m_ToolBox->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
#endif
	{
		return retVal;
	}

	Archive = dynamic_cast<IXMLArchive *>(ca.archive);
	DWORD numNodes = Archive->GetNumberOfNodes();

	// Deteriminte World Version
	int iWorldNumAttrib = Archive->GetNumAttributes();

	StdString szNodeName;
	Archive->GetNode(szNodeName);
	
	pbp.currentPosition = Archive->GetCurrentNodePosition();
	pbp.totalSize = numNodes;
	// update progress bar
	static DWORD msgHash_LoadingUpdate = CHashString(_T("LoadingUpdate")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_LoadingUpdate, sizeof(LOADINGUPDATEPARAMS), &pbp);


	// must start with <World>
	if (szNodeName != _T("CWorld"))
	{
		EngineGetToolBox()->SetErrorValue(WARN_INVALID_FILE);
		EngineGetToolBox()->Log(LOGWARNING, _T("Invalid world file %s\n"), pFileName);
		Archive->Close();
		return MSG_ERROR;
	}

	// Version 1.0
	if( iWorldNumAttrib == 1 )
	{
		// read the name of the world
		StdString szName;
		Archive->Read( szName, _T("Name") );
		m_WorldFileVersion = 1.0f;
		static DWORD msgHash_GetFileVersion = CHashString(_T("GetFileVersion")).GetUniqueID();
		DWORD retval = m_ToolBox->SendMessage(msgHash_GetFileVersion, sizeof(IHashString), &oldVersion);
		if (retval != MSG_HANDLED)
		{
			m_ToolBox->Log(LOGERROR, _T("Could not get world version!"));
			return MSG_ERROR;
		}
		CHashString hszNewVersion = _T("1.0");
//.........这里部分代码省略.........
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:101,代码来源:XMLWorldLoader.cpp


注:本文中的IArchive::Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。