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


C++ CObj::GetComponent方法代码示例

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


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

示例1: OnObjLoad

void CObjectTool::OnObjLoad()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.

	if (m_StaticList.GetCount() == 0)
	{
		AfxMessageBox(L"Load Static Mesh First!");
		return;
	}

	/*if (m_DynamicList.GetCount() == 0)
	{
		AfxMessageBox(L"Load Dynamic Mesh First!");
		return;
	}*/

	CFileDialog Dlg(TRUE, L"dat", NULL,//화일명 없음 
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		NULL, NULL);

	//옵션 선택 부분.
	if (Dlg.DoModal() == IDOK)
	{
		CString strPathName = Dlg.GetPathName();//path를 돌려줌
		wstring wstrPath = strPathName;
	}

	HANDLE	hFile = CreateFile(Dlg.GetPathName(), GENERIC_READ,
		0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

	DWORD	dwByte;

	int iObjSize = 0;
	ReadFile(hFile, &iObjSize, sizeof(int), &dwByte, NULL);

	for (int i = 0; i < iObjSize; ++i)
	{
		//TCHAR* tcFilePath = new TCHAR[128];
		TCHAR* pObjectKey = new TCHAR[50];
		//ZeroMemory(pObjectKey, sizeof(TCHAR) * 50);

		ReadFile(hFile, pObjectKey, sizeof(TCHAR) * 50, &dwByte, NULL);
		//const_cast<Engine::CLayer*>(pLayer)->DeleteByKey(pObjectKey);

		int iNum;
		ReadFile(hFile, &iNum, sizeof(int), &dwByte, NULL);
		if (0 == iNum)
			continue;

		CObj*	pGameObject = NULL;

		for (int j = 0; j < iNum; ++j)
		{
			
			pGameObject = CStaticObject::Create(pObjectKey,D3DXVECTOR3(0.f,0.f,0.f));
			CObjMgr::GetInstance()->AddObject(pObjectKey,pGameObject);
			CRenderMgr::GetInstance()->AddRenderGroup(TYPE_NONEALPHA, pGameObject);


			const CComponent* pComponent = pGameObject->GetComponent(L"Transform");

			ReadFile(hFile, ((CInfo*)pComponent)->m_fAngle, sizeof(float) * ANGLE_END, &dwByte, NULL);
			ReadFile(hFile, ((CInfo*)pComponent)->m_vScale, sizeof(D3DXVECTOR3), &dwByte, NULL);
			ReadFile(hFile, ((CInfo*)pComponent)->m_vPos, sizeof(D3DXVECTOR3), &dwByte, NULL);
			ReadFile(hFile, ((CInfo*)pComponent)->m_vDir, sizeof(D3DXVECTOR3), &dwByte, NULL);
			ReadFile(hFile, ((CInfo*)pComponent)->m_matWorld, sizeof(D3DXMATRIX), &dwByte, NULL);

			((CBack*)CSceneMgr::GetInstance()->GetScene())->m_ToolObjList.push_back(pGameObject);
		}
	}

	//int iDynamicSize = 0;
	//ReadFile(hFile, &iDynamicSize, sizeof(int), &dwByte, NULL);

	//for (int i = 0; i < iDynamicSize; ++i)
	//{
	//	TCHAR* pObjectKey = new TCHAR[50];

	//	ReadFile(hFile, pObjectKey, sizeof(TCHAR) * 50, &dwByte, NULL);
	//	//const_cast<Engine::CLayer*>(pLayer)->DeleteByKey(pObjectKey);

	//	int iNum;
	//	ReadFile(hFile, &iNum, sizeof(int), &dwByte, NULL);
	//	if (0 == iNum)
	//		continue;

	//	Engine::CGameObject*	pGameObject = NULL;

	//	for (int i = 0; i < iNum; ++i)
	//	{
	//		pGameObject = CDynamicObject::Create(Engine::Get_GraphicDev(), pObjectKey, D3DXVECTOR3(0.f, 0.f, 0.f));
	//		const_cast<Engine::CLayer*>(pLayer)->AddObject(pObjectKey, pGameObject);

	//		const Engine::CComponent* pComponent = pGameObject->GetComponent(L"Transform");
	//		ReadFile(hFile, ((Engine::CTransform*)pComponent)->m_fAngle, sizeof(float) * Engine::ANGLE_END, &dwByte, NULL);
	//		ReadFile(hFile, ((Engine::CTransform*)pComponent)->m_vScale, sizeof(D3DXVECTOR3), &dwByte, NULL);
	//		ReadFile(hFile, ((Engine::CTransform*)pComponent)->m_vPos, sizeof(D3DXVECTOR3), &dwByte, NULL);
	//		ReadFile(hFile, ((Engine::CTransform*)pComponent)->m_vDir, sizeof(D3DXVECTOR3), &dwByte, NULL);
	//		ReadFile(hFile, ((Engine::CTransform*)pComponent)->m_matWorld, sizeof(D3DXMATRIX), &dwByte, NULL);

//.........这里部分代码省略.........
开发者ID:korleinster,项目名称:gamebusdriver,代码行数:101,代码来源:ObjectTool.cpp


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