示例#1
0
void CAddScript::OnOK()
{
	if( !m_strTriggerEnterScriptName.IsEmpty() )
	{
		m_instanceGeo->m_hasEnterScript = m_instanceGeo->m_updateEnterScript = CTrue;
		Cpy( m_instanceGeo->m_enterScript, m_strTriggerEnterScriptName.GetBuffer( m_strTriggerEnterScriptName.GetLength() ) );
		m_strTriggerEnterScriptName.ReleaseBuffer();
	}
	else
	{
		m_instanceGeo->m_hasEnterScript = m_instanceGeo->m_updateEnterScript = CFalse;
		Cpy( m_instanceGeo->m_enterScript, "\n" );
	}

	if( !m_strTriggerExitScriptName.IsEmpty() )
	{
		m_instanceGeo->m_hasExitScript = m_instanceGeo->m_updateExitScript = CTrue;
		Cpy( m_instanceGeo->m_exitScript, m_strTriggerExitScriptName.GetBuffer( m_strTriggerExitScriptName.GetLength() ) );
		m_strTriggerExitScriptName.ReleaseBuffer();
	}
	else
	{
		m_instanceGeo->m_hasExitScript = m_instanceGeo->m_updateExitScript = CFalse;
		Cpy( m_instanceGeo->m_exitScript, "\n" );
	}
	if( m_changed )
	{
		for(CUInt index = 0; index < g_allVSceneNames.size(); index++ )
		{
			m_instanceGeo->m_node->GetScene()->IsInVSceneList(g_allVSceneNames[index].c_str(), CFalse, CTrue );
		}
	}
	CDialog::OnOK();
}
示例#2
0
void CheckMsg(zn_t *zn1, zn_t *zn2, zn_t *znd)//header_t **d, source_t *who, int start, int end)
{
	header_t *c, *t;

	// compare the message with dest
	for (t = znd->start; t != znd->end; NextMsg(t))
		if (Cmp(zn1->end, t))
			break;

	if (t != znd->end)
	{
		int size = ((byte*)zn1->end - (byte*)zn1->start);

		// make room
		memmove((byte*)t + size, t, (byte*)znd->end - (byte*)t);
		znd->end += size;

		// copy
		for (c = zn1->start; c != zn1->end; NextMsg(c), NextMsg(t))
			Cpy(t, c);

		Mrg(zn1->end, t, t, true);

		NextMsg(zn1->end);
		zn1->start = zn1->end;

		return;
	}

	for (t = zn2->start; t != zn2->end; NextMsg(t))
		if (Cmp(zn1->end, t))
			break;

	if (t != zn2->end)
	{

		for (c = zn2->start; c != t; NextMsg(c), NextMsg(znd->end))
			Cpy(znd->end, c);

		for (c = zn1->start; c != zn1->end; NextMsg(c), NextMsg(znd->end))
			Cpy(znd->end, c);

		Mrg(zn1->end, t, znd->end, false);
		NextMsg(znd->end);

		NextMsg(zn1->end);
		NextMsg(t);

		zn1->start = zn1->end;
		zn2->start = t;
	}
	else
	{
		NextMsg(zn1->end);
	}
}
示例#3
0
BOOL CSetCurrentProject::OnInitDialog()
{
    CDialog::OnInitDialog();

    RECT rect;
    m_listAvailableProjects.GetClientRect(&rect);

    CBitmap cBmp;
    CBitmap* cBmpMask = NULL;
    m_projectListImage.Create(32, 32, ILC_COLOR24, 1, 1);

    cBmp.LoadBitmap(IDB_BITMAP_DEFAULT_PROJECT);
    m_projectListImage.Add(&cBmp, cBmpMask);
    cBmp.DeleteObject();

    m_listAvailableProjects.InsertColumn(0, "Available Projects", LVCFMT_LEFT, rect.right - rect.left, 0 );
    m_listAvailableProjects.SetImageList(&m_projectListImage, LVSIL_SMALL);
    m_listAvailableProjects.SetExtendedStyle(LVS_EX_INFOTIP | LVS_EX_ONECLICKACTIVATE | LVS_EX_LABELTIP);

    for( CUInt i = 0; i < g_projects.size(); i++ )
    {
        CChar projectName[MAX_NAME_SIZE];
        Cpy( projectName, g_projects[i]->m_name );
        InserItemToAvailableProjectsList( projectName, g_projects[i]->m_isActive );
    }

    return TRUE;  // return TRUE unless you set the focus to a control
}
示例#4
0
文件: Sky.cpp 项目: DCubix/1.4.0
CSkyDome::CSkyDome()
{
	Cpy (m_strImage, "\n");
	m_hasImage = CFalse;
	m_image = CNew( CImage );
    m_nameIndex = 0;
}
示例#5
0
bool PIDFlowController::setParams(const PIDFCParams & pin)
{
  mut.lock();
  if (running() && (params.dev_ai != pin.dev_ai || params.dev_ao != pin.dev_ao
                    || params.subdev_ai != pin.subdev_ai
                    || params.subdev_ao != pin.subdev_ao)) {
    mut.unlock();
    return false;
  }
  double flow_actual_backup, v_in_backup, v_out_backup; // don't overwrite our params for these 3 since our notion is more accurate 
  Cpy(flow_actual_backup, params.flow_actual);
  Cpy(v_in_backup, params.last_v_in);
  Cpy(v_out_backup, params.last_v_out);
  params = pin;
  Cpy(params.flow_actual, flow_actual_backup);
  Cpy(params.last_v_in, v_in_backup);
  if (!running()) {
    WriteVFunctor f(const_cast<PIDFlowController *>(this));
    Thread::doFuncInRT(f); // force user-set voltage if PID loop isn't running
  } else { // otherwise if PID loop is running don't tinker with voltage
    Cpy(params.last_v_out, v_out_backup);
  }
  setRate(params.rate_hz);
  setControlParams(params.controlParams);
  mut.unlock();
  return true;
}
示例#6
0
void CpyPrev(source_t *who, header_t **d, int start, int end, int size)
{
	int i;
	sizebuf_t *buf;
	header_t *s, *h;

	for (i = start; i < end; i++)
		if (who->frames[i&UPDATE_MASK].buf.bufsize)
		{
			buf = &who->frames[i&UPDATE_MASK].buf;
			s = (header_t *)buf->data;

			for ( h = s; (byte*)h - (byte*)s < buf->bufsize; NextMsg(h), NextMsg(*d))
				Cpy(*d,h);

			MoveFromDemoBuffer(who, i, buf->bufsize);
		}

	MoveFromDemoBuffer(who, end, size);
}
示例#7
0
文件: Water.cpp 项目: DCubix/1.4.0
CVoid CWater::SetDuDvMap( CChar* fileName ) { 
	Cpy( m_strDuDvMap, fileName );

	CImage* image = GetWaterImage( GetAfterPath( m_strDuDvMap ) );

	if( image == NULL )
	{
		image = CNew (CImage);
		CTexture::LoadDDSTexture( image, m_strDuDvMap, NULL );
		image->SetName( GetAfterPath( m_strDuDvMap ) );
		g_waterImages.push_back( image );
	}
	else
	{
		//CChar temp[MAX_NAME_SIZE];
		//sprintf( temp, "\n%s%s%s", "Image '", GetAfterPath(m_strDuDvMap), "' already exists." );
		//PrintInfo( temp, COLOR_YELLOW );
	}
	m_dudvMapImg = image;
};
示例#8
0
void CPrefabDlg::OnBnClickedRenamePackage()
{
	int nSelected = -1;
	TCHAR szBuffer[1024];

	POSITION p = m_listPrefabPackages.GetFirstSelectedItemPosition();
	while (p)
	{
		nSelected = m_listPrefabPackages.GetNextSelectedItem(p);
	}
	if (nSelected >= 0)
	{
		DWORD cchBuf(1024);
		LVITEM lvi;
		lvi.iItem = nSelected;
		lvi.iSubItem = 0;
		lvi.mask = LVIF_TEXT;
		lvi.pszText = szBuffer;
		lvi.cchTextMax = cchBuf;
		m_listPrefabPackages.GetItem(&lvi);
		m_selectedPackageName = szBuffer;

		if (Cmp(szBuffer, "Vanda_Basics"))
		{
			MessageBox("You cannot rename this package", "Vanda Engine Error", MB_OK | MB_ICONINFORMATION);
			return;
		}

	}
	else
	{
		MessageBox("Please select an item!", "Vanda Engine Error", MB_OK | MB_ICONINFORMATION);
		return;
	}
	CChar currentPackageName[MAX_NAME_SIZE];
	sprintf(currentPackageName, "%s", szBuffer);
	if (Cmp(g_currentPackageName, currentPackageName))
	{
		MessageBox("current open prefab belongs to selected package. Please close current prefab scene and try again.", "Vanda Engine Error", MB_OK | MB_ICONERROR);
		return;
	}

	//then fill it with the VScenes of the selected project
	for (CUInt i = 0; i < g_projects.size(); i++)
	{
		for (CUInt j = 0; j < g_projects[i]->m_sceneNames.size(); j++)
		{
			//find pkg file
			CChar pkgPath[MAX_NAME_SIZE];
			CChar sceneWithoutDot[MAX_NAME_SIZE];
			Cpy(sceneWithoutDot, g_projects[i]->m_sceneNames[j].c_str());
			GetWithoutDot(sceneWithoutDot);
			sprintf(pkgPath, "%s%s%s%s%s", g_projectsPath, g_projects[i]->m_name, "/", sceneWithoutDot, "/packages.pkg");
			//copy package names
			FILE *PackageFilePtr;
			PackageFilePtr = fopen(pkgPath, "rb");
			if (!PackageFilePtr)
			{
				CChar temp[MAX_NAME_SIZE];
				sprintf(temp, "%s%s%s", "Couldn't open the file '", pkgPath, "' to save data");
				MessageBox(temp, "Vanda Engine Error", MB_OK);
				ReleaseCapture();
				PrintInfo("Rename failed.", COLOR_RED);
				return;
			}
			CUInt size = -1;
			fread(&size, sizeof(CUInt), 1, PackageFilePtr);
			for (CUInt k = 0; k < size; k++)
			{
				CChar name[MAX_NAME_SIZE];
				CChar package_name[MAX_NAME_SIZE];
				CChar prefab_name[MAX_NAME_SIZE];
				//write prefab data
				fread(name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);
				fread(package_name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);
				fread(prefab_name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);

				if (Cmp(package_name, m_selectedPackageName.c_str()))
				{
					CChar packageName[MAX_NAME_SIZE];
					sprintf(packageName, "This package is used by %s/%s.\nYou can not rename this package.", g_projects[i]->m_name, g_projects[i]->m_sceneNames[j].c_str());
					MessageBox(packageName, "Vanda Engine Error", MB_OK | MB_ICONERROR);
					fclose(PackageFilePtr);
					return;
				}
			}
			fclose(PackageFilePtr);
		}
	}

	m_prefabNameDlg = CNew(CPrefabNameDlg);
	m_prefabNameDlg->SetInitialData(m_selectedPackageName, "\n", CTrue, CTrue);
	if (IDOK == m_prefabNameDlg->DoModal())
	{
		m_listPrefabPackages.SetItemText(nSelected, 0, m_prefabNameDlg->GetNewName());

		CChar PackagePath[MAX_NAME_SIZE];
		HRESULT doc_result_package = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, PackagePath);
		if (doc_result_package != S_OK)
		{
			PrintInfo("\nCouldn't get the documents folder to write data", COLOR_RED);
			return;
		}
		else
		{
			Append(PackagePath, "/Vanda/Packages/");
		}
		CChar old_path[MAX_NAME_SIZE];
		CChar new_path[MAX_NAME_SIZE];
		sprintf(old_path, "%s%s", PackagePath, szBuffer);
		sprintf(new_path, "%s%s", PackagePath, m_prefabNameDlg->GetNewName());
		rename(old_path, new_path);

		//rename vpf files
		for (CUInt i = 0; i < g_prefabPackagesAndNames.size(); i++)
		{
			if (Cmp(g_prefabPackagesAndNames[i].front().c_str(), m_prefabNameDlg->GetNewName()))
			{
				for (CUInt j = 0; j < g_prefabPackagesAndNames[i].size(); j++)
				{
					if (j == 0)continue;
					CChar vpfOldPath[MAX_NAME_SIZE];
					sprintf(vpfOldPath, "%s%s%s%s%s%s%s%s%s", PackagePath, g_prefabPackagesAndNames[i].front().c_str(), "/", g_prefabPackagesAndNames[i][j].c_str(), "/", szBuffer, "_", g_prefabPackagesAndNames[i][j].c_str(), ".vpf");
					CChar vpfNewPath[MAX_NAME_SIZE];
					sprintf(vpfNewPath, "%s%s%s%s%s%s%s%s%s", PackagePath, g_prefabPackagesAndNames[i].front().c_str(), "/", g_prefabPackagesAndNames[i][j].c_str(), "/", g_prefabPackagesAndNames[i].front().c_str(), "_", g_prefabPackagesAndNames[i][j].c_str(), ".vpf");
					rename(vpfOldPath, vpfNewPath);
				}
				break;
			}
		}
		//rename the contents of PKG folder as well
		CChar PKG_old[MAX_URI_SIZE];
		CChar PKG_new[MAX_URI_SIZE];
		sprintf(PKG_old, "%s%s%s%s", PackagePath, "PKG/", szBuffer, ".pkg");
		sprintf(PKG_new, "%s%s%s%s", PackagePath, "PKG/", m_prefabNameDlg->GetNewName(), ".pkg");
		rename(PKG_old, PKG_new);

	}
	CDelete(m_prefabNameDlg);
}
示例#9
0
文件: Scene.cpp 项目: DCubix/1.4.0
CVoid CScene::UpdateExecuteActionList( CFloat elapsedTime, CBool &updateExecuteActionList )
{
	//Execute Action List
	std::vector <CInt> index;
	if( m_executeActionList.size() == 0 )
	{
		updateExecuteActionList = CFalse;
		return;
	}

	for( CUInt i = 0; i < m_executeActionList.size(); i++ )
	{
		CChar executeActionName[MAX_NAME_SIZE];
		Cpy( executeActionName, m_executeActionList[i].c_str() );
		CInt clipIndex = 0;
		//Find the animation clip 
		for( CInt ac = 0; ac < GetNumClips(); ac++ )
		{
			if( Cmp( m_animationClips[ac]->GetName(), executeActionName ) )
			{
				clipIndex = ac;
				break;
			}
		}

		if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_EXECUTE_ACTION && m_animationClips[clipIndex]->GetCurrentTime() >=  m_animationClips[clipIndex]->GetEnd() && !m_animationClips[clipIndex]->GetLock())
		{
			m_animationClips[clipIndex]->SetAnimationStatus( eANIM_NONE );
			index.push_back(i);
			continue;
		}
		if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_EXECUTE_ACTION && m_animationClips[clipIndex]->GetStart() >= m_animationClips[clipIndex]->GetCurrentTime() && m_animationClips[clipIndex]->GetReverse())
		{
			m_animationClips[clipIndex]->SetAnimationStatus( eANIM_NONE );
			index.push_back(i);
			continue;
		}

		if( !(m_animationClips[clipIndex]->GetCurrentTime() >= m_animationClips[clipIndex]->GetEnd() && m_animationClips[clipIndex]->GetLock() && !m_animationClips[clipIndex]->GetReverse()) )
			updateExecuteActionList = CTrue;

		if( m_animationClips[clipIndex]->GetReverse() )
			elapsedTime = -elapsedTime;

		if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_EXECUTE_ACTION && m_animationClips[clipIndex]->GetCurrentTime() >= ( m_animationClips[clipIndex]->GetStart() + m_animationClips[clipIndex]->GetTargetDelayIn() ) && m_animationClips[clipIndex]->GetCurrentTime() <= (m_animationClips[clipIndex]->GetEnd() - m_animationClips[clipIndex]->GetTargetDelayOut() ) )
		{
			m_animationClips[clipIndex]->SetCurrentWeight( m_animationClips[clipIndex]->GetTargetWeight() );
		}
		else if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_EXECUTE_ACTION && m_animationClips[clipIndex]->GetCurrentTime() < ( m_animationClips[clipIndex]->GetStart() + m_animationClips[clipIndex]->GetTargetDelayIn() ) )
		{
			//compute current delay in or delay out time
			CFloat Dc = 0.0f;
			m_animationClips[clipIndex]->SetCurrentDelayInTime2( elapsedTime );
			Dc = m_animationClips[clipIndex]->GetCurrentDelayInTime();
			//compute M
			CFloat M = 0.0f;
			M = (m_animationClips[clipIndex]->GetTargetWeight() - m_animationClips[clipIndex]->GetStartWeight() ) / m_animationClips[clipIndex]->GetTargetDelayIn();

			//compute current weight
			CFloat Wc = 0.0f;
			Wc = M * Dc + m_animationClips[clipIndex]->GetStartWeight();
			m_animationClips[clipIndex]->SetCurrentWeight( Wc );

			if( m_animationClips[clipIndex]->GetCurrentWeight() >= m_animationClips[clipIndex]->GetTargetWeight() )
				m_animationClips[clipIndex]->SetCurrentWeight( m_animationClips[clipIndex]->GetTargetWeight() );
		}
		else if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_EXECUTE_ACTION && m_animationClips[clipIndex]->GetCurrentTime() > (m_animationClips[clipIndex]->GetEnd() - m_animationClips[clipIndex]->GetTargetDelayOut() ) )
		{
			//compute current delay in or delay out time
			CFloat Dc = 0.0f;
			m_animationClips[clipIndex]->SetCurrentDelayOutTime2( elapsedTime );
			Dc = m_animationClips[clipIndex]->GetCurrentDelayOutTime();
			//compute M
			CFloat M = 0.0f;
			M = (-m_animationClips[clipIndex]->GetTargetWeight() ) / m_animationClips[clipIndex]->GetTargetDelayOut();
			//compute current weight
			CFloat Wc = 0.0f;
			Wc = M * Dc + m_animationClips[clipIndex]->GetTargetWeight();
			m_animationClips[clipIndex]->SetCurrentWeight( Wc );
			if( m_animationClips[clipIndex]->GetCurrentWeight() <= 0.0f )
				m_animationClips[clipIndex]->SetCurrentWeight( 0.0f );
		}

		if( m_animationClips[clipIndex]->GetReverse() )
		{
			m_animationClips[clipIndex]->SetCurrentTime2( elapsedTime );
			//if( m_animationClips[clipIndex]->GetCurrentTime() < m_animationClips[clipIndex]->GetStart() )
			//	m_animationClips[clipIndex]->SetCurrentTime( m_animationClips[clipIndex]->GetStart() );
		}
		else
		{
			m_animationClips[clipIndex]->SetCurrentTime2( elapsedTime );
			//if( m_animationClips[clipIndex]->GetCurrentTime() > m_animationClips[clipIndex]->GetEnd() )
			//	m_animationClips[clipIndex]->SetCurrentTime( m_animationClips[clipIndex]->GetEnd() );
		}
	}
	for( CUInt j = 0; j < index.size(); j++ )
	{
		m_executeActionList.erase(m_executeActionList.begin() + index[j]);
	}
	index.clear();
}
示例#10
0
文件: Scene.cpp 项目: DCubix/1.4.0
CVoid CScene::UpdateBlendCycleList( CFloat elapsedTime )
{
	//Blend Cycle List
	std::vector<CInt> index;
	for( CUInt i = 0; i < m_blendCycleList.size(); i++ )
	{
		CChar blendCycleName[MAX_NAME_SIZE];
		Cpy( blendCycleName, m_blendCycleList[i].c_str() );
		CInt clipIndex = 0;
		//Find the animation clip 
		for( CInt ac = 0; ac < GetNumClips(); ac++ )
		{
			if( Cmp( m_animationClips[ac]->GetName(), blendCycleName ) )
			{
				clipIndex = ac;
				break;
			}
		}
		if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_CLEAR_CYCLE && m_animationClips[clipIndex]->GetCurrentWeight() == 0.0f )
		{
			m_animationClips[clipIndex]->SetAnimationStatus( eANIM_NONE );
			index.push_back(i);
			continue;
		}
		//make sure that current weight is not greater than target weight
		if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_BLEND_CYCLE && m_animationClips[clipIndex]->GetCurrentWeight() >= m_animationClips[clipIndex]->GetTargetWeight() )
		{
			m_animationClips[clipIndex]->SetCurrentWeight( m_animationClips[clipIndex]->GetTargetWeight() );
		}
		else
		{
			//compute current delay in or delay out time
			CFloat Dc = 0.0f;
			if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_BLEND_CYCLE )
			{
				m_animationClips[clipIndex]->SetCurrentDelayInTime2( elapsedTime );
				Dc = m_animationClips[clipIndex]->GetCurrentDelayInTime();
			}
			else if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_CLEAR_CYCLE )
			{
				m_animationClips[clipIndex]->SetCurrentDelayOutTime2( elapsedTime );
				Dc = m_animationClips[clipIndex]->GetCurrentDelayOutTime();
			}
			//compute M
			CFloat M = 0.0f;
			if(  m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_BLEND_CYCLE )
				M = (m_animationClips[clipIndex]->GetTargetWeight() - m_animationClips[clipIndex]->GetStartWeight() ) / m_animationClips[clipIndex]->GetTargetDelayIn();
			else
				M = (m_animationClips[clipIndex]->GetTargetWeight() - m_animationClips[clipIndex]->GetStartWeight() ) / m_animationClips[clipIndex]->GetTargetDelayOut();

			//compute current weight
			CFloat Wc = 0.0f;
			Wc = M * Dc + m_animationClips[clipIndex]->GetStartWeight();
			m_animationClips[clipIndex]->SetCurrentWeight( Wc );

			//make sure that W is not less than or greate than target weight
			if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_BLEND_CYCLE && m_animationClips[clipIndex]->GetCurrentWeight() >= m_animationClips[clipIndex]->GetTargetWeight() )
			{
				m_animationClips[clipIndex]->SetCurrentWeight( m_animationClips[clipIndex]->GetTargetWeight() );
			}
			else if( m_animationClips[clipIndex]->GetAnimationStatus() == eANIM_CLEAR_CYCLE && m_animationClips[clipIndex]->GetCurrentWeight() <= 0.0f )
			{
				m_animationClips[clipIndex]->SetCurrentWeight( 0.0f );
			}
		}

		m_animationClips[clipIndex]->SetCurrentTime2( elapsedTime );
		if( m_animationClips[clipIndex]->GetCurrentTime() > m_animationClips[clipIndex]->GetEnd() )
			m_animationClips[clipIndex]->SetCurrentTime( m_animationClips[clipIndex]->GetCurrentTime() - m_animationClips[clipIndex]->GetEnd() + m_animationClips[clipIndex]->GetStart() );

	}
	for( CUInt i = 0; i < index.size(); i++ )
		m_blendCycleList.erase(m_blendCycleList.begin() + index[i]);
}
示例#11
0
文件: Scene.cpp 项目: DCubix/1.4.0
CVoid CScene::Destroy()
{
	NxScene* tempScene = gPhysXscene/*gPhysicsSDK->getScene(i)*/;
	if(tempScene && !g_clickedNew && !g_clickedOpen)
	{
		for( CUInt i = 0; i < m_instanceGeometries.size(); i++ )
		{
			CInstanceGeometry* m_instanceGeo = m_instanceGeometries[i];
			if( tempScene )
			{
				for( CUInt j = 0; j < tempScene->getNbActors(); j++ )
				{
					CChar actorName[MAX_NAME_SIZE];
					if( !tempScene->getActors()[j]->getName() ) continue;
					Cpy( actorName, tempScene->getActors()[j]->getName() );
					if( !Cmp(m_instanceGeo->m_physXName, "\n" ) && Cmp( actorName, m_instanceGeo->m_physXName ) )
					{
						for(CInt nItem =0 ; nItem <  ex_pVandaEngine1Dlg->m_listBoxPhysXElements.GetItemCount(); nItem++)
						{
							CString strText = ex_pVandaEngine1Dlg->m_listBoxPhysXElements.GetItemText(nItem, 0);
							char charPtr[MAX_NAME_SIZE];
							sprintf(charPtr, "%s", strText);
							if(Cmp( m_instanceGeo->m_physXName, charPtr ) )
							{
								ex_pVandaEngine1Dlg->m_listBoxPhysXElements.DeleteItem(nItem);
								ex_pVandaEngine1Dlg->SortPhysXList();
							}
						}

						tempScene->releaseActor( *tempScene->getActors()[j] );
						g_multipleView->m_nx->gControllers->reportSceneChanged();
						m_instanceGeo->m_hasPhysX = CFalse;
						Cpy( m_instanceGeo->m_physXName, "\n" );
					}
				}
			}
		}
	}
	//while(!m_cfxMaterials.empty())
	//{
		//std::map<std::string, cfxMaterial*>::iterator iter = m_cfxMaterials.begin();
		//CDelete(iter->second);
		//m_cfxMaterials.erase(iter);
	//}
	//m_cfxEffects.clear();

	//while(!m_cfxEffects.empty())
	//{
		//std::map<std::string, cfxEffect*>::iterator iter = m_cfxEffects.begin();
		//CDelete(iter->second);
		//m_cfxEffects.erase(iter);
	//}
	//m_cfxEffects.clear();
	//delete all the geometries
	m_textureList.clear(); //save functions
	m_prefabList.clear(); //save functions

	if (g_editorMode == eMODE_PREFAB)
	{
		while (!m_geometries.empty())
		{
			CDelete(m_geometries[0]);
			m_geometries.erase(m_geometries.begin());
		}
		m_geometries.clear();
	}

	m_instanceGeometries.clear();
	//m_instanceControllers.clear();
	while(!m_lightInstances.empty())
	{
		CDelete(m_lightInstances[0]);
		m_lightInstances.erase(m_lightInstances.begin());
	}
	while(!m_lights.empty())
	{
		CDelete( m_lights[0] ); 
		m_lights.erase(m_lights.begin());
	}
	while(!m_cameraInstances.empty())
	{
		for( CUInt size = 0; size < g_cameraInstances.size(); size++ )
		{
			if( Cmp( m_cameraInstances[0]->m_abstractCamera->GetName(), g_cameraInstances[size]->m_abstractCamera->GetName() ) )
			{
				if( g_render.GetActiveInstanceCamera() == g_cameraInstances[size] )
				{
					if (g_multipleView && g_render.GetDefaultInstanceCamera())
					{
						g_render.SetActiveInstanceCamera(g_render.GetDefaultInstanceCamera());
						g_currentCameraType = eCAMERA_DEFAULT_FREE;
						g_multipleView->m_lockInput = CFalse;
					}
					else
					{
						g_render.SetActiveInstanceCamera(NULL);
					}

				}
				g_cameraInstances.erase( g_cameraInstances.begin() + size );
			}
		}
		CDelete(m_cameraInstances[0]);
		m_cameraInstances.erase(m_cameraInstances.begin());
	}

	while(!m_cameras.empty())
	{
		CDelete( m_cameras[0] ); 
		m_cameras.erase(m_cameras.begin());
	}
	while(!m_controllers.empty())
	{
		CDelete( m_controllers[0] );
		m_controllers.erase(m_controllers.begin());
	}
	//Delete all the nodes
	CDelete( m_sceneRoot );
	m_nodes.clear();

	//Clear all the images
	//for( std::vector<CImage*>::iterator it = m_images.begin(); it != m_images.end(); it++ )
	//{
	//	CDelete( *it );
	//}
	//Clear the vector objects
	m_images.clear();

	//clear all the effects
	for( std::vector<CEffect*>::iterator it = m_effects.begin(); it != m_effects.end(); it++ )
	{
		CDelete( *it );
	}
	//Clear the vector objects
	m_effects.clear();

	for( std::vector<CMaterial*>::iterator it = m_materials.begin(); it != m_materials.end(); it++ )
	{
		CDelete( *it );
	}
	//Clear the vector objects
	m_materials.clear();

	for( std::vector<CAnimation*>::iterator it = m_animations.begin(); it != m_animations.end(); it++ )
	{
		CDelete( *it );
	}
	//Clear the vector objects
	m_animations.clear();

	for( std::vector<CAnimationClip*>::iterator it = m_animationClips.begin(); it != m_animationClips.end(); it++ )
	{
		CDelete( *it );
	}
	//Clear the vector objects
	m_animationClips.clear();
}
示例#12
0
void CPrefabDlg::OnBnClickedDelete()
{
	int nSelected = -1;
	POSITION p = m_listPrefabPackages.GetFirstSelectedItemPosition();
	while (p)
	{
		nSelected = m_listPrefabPackages.GetNextSelectedItem(p);
	}
	TCHAR szBuffer1[1024]; //package
	TCHAR szBuffer2[1024]; //prefab

	if (nSelected >= 0)
	{ 
		DWORD cchBuf(1024);
		LVITEM lvi;
		lvi.iItem = nSelected;
		lvi.iSubItem = 0;
		lvi.mask = LVIF_TEXT;
		lvi.pszText = szBuffer1;
		lvi.cchTextMax = cchBuf;
		m_listPrefabPackages.GetItem(&lvi);
		m_selectedPackageName = szBuffer1;
	}
	else
	{
		MessageBox("Please select a package!", "Vanda Engine Error", MB_OK | MB_ICONINFORMATION);
		return;
	}

	nSelected = -1;
	p = m_listPrefabs.GetFirstSelectedItemPosition();
	while (p)
	{
		nSelected = m_listPrefabs.GetNextSelectedItem(p);
	}
	if (nSelected >= 0)
	{
		CInt packageIndex = -1;
		for (CUInt i = 0; i < g_prefabPackagesAndNames.size(); i++)
		{
			if (Cmp(g_prefabPackagesAndNames[i].front().c_str(), m_selectedPackageName.c_str()))
			{
				packageIndex = i;
				break;
			}
		}

		DWORD cchBuf(1024);
		LVITEM lvi;
		lvi.iItem = nSelected;
		lvi.iSubItem = 0;
		lvi.mask = LVIF_TEXT | LVIF_IMAGE;
		lvi.pszText = szBuffer2;
		lvi.cchTextMax = cchBuf;
		m_listPrefabs.GetItem(&lvi);

		m_selectedPrefabName = szBuffer2;

		CChar currentPackageAndPrefabName[MAX_NAME_SIZE];
		sprintf(currentPackageAndPrefabName, "%s%s%s", szBuffer1, "_", szBuffer2);
		if (Cmp(g_currentPackageAndPrefabName, currentPackageAndPrefabName))
		{
			MessageBox("This prefab is already open. Please close current prefab scene and try again.", "Vanda Engine Error", MB_OK | MB_ICONERROR);
			return;
		}

		for (CUInt i = 0; i < g_projects.size(); i++)
		{
			for (CUInt j = 0; j < g_projects[i]->m_sceneNames.size(); j++)
			{
				//find pkg file
				CChar pkgPath[MAX_NAME_SIZE];
				CChar sceneWithoutDot[MAX_NAME_SIZE];
				Cpy(sceneWithoutDot, g_projects[i]->m_sceneNames[j].c_str());
				GetWithoutDot(sceneWithoutDot);
				sprintf(pkgPath, "%s%s%s%s%s", g_projectsPath, g_projects[i]->m_name, "/", sceneWithoutDot, "/packages.pkg");
				//copy package names
				FILE *PackageFilePtr;
				PackageFilePtr = fopen(pkgPath, "rb");
				if (!PackageFilePtr)
				{
					CChar temp[MAX_NAME_SIZE];
					sprintf(temp, "%s%s%s", "Couldn't open the file '", pkgPath, "' to save data");
					MessageBox(temp, "Vanda Engine Error", MB_OK);
					ReleaseCapture();
					PrintInfo("Delete failed.", COLOR_RED);
					return;
				}
				CUInt size = -1;
				fread(&size, sizeof(CUInt), 1, PackageFilePtr);
				for (CUInt k = 0; k < size; k++)
				{
					CChar name[MAX_NAME_SIZE];
					CChar package_name[MAX_NAME_SIZE];
					CChar prefab_name[MAX_NAME_SIZE];
					//write prefab data
					fread(name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);
					fread(package_name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);
					fread(prefab_name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);

					if (Cmp(prefab_name, m_selectedPrefabName.c_str()))
					{
						CChar preafbName[MAX_NAME_SIZE];
						sprintf(preafbName, "This prefab is used by %s/%s.\nYou can not delete this prefab.", g_projects[i]->m_name, g_projects[i]->m_sceneNames[j].c_str());
						MessageBox(preafbName, "Vanda Engine Error", MB_OK | MB_ICONERROR);
						fclose(PackageFilePtr);
						return;
					}
				}
				fclose(PackageFilePtr);
			}
		}

		if (MessageBox("Are you sure you want to delete this prefab?", "Warning", MB_YESNO) == IDYES)
		{
			//remove prefab directory
			CChar PackagePath[MAX_NAME_SIZE];
			HRESULT doc_result_package = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, PackagePath);
			if (doc_result_package != S_OK)
			{
				PrintInfo("\nCouldn't get the documents folder to write data", COLOR_RED);
				return;
			}
			else
			{
				Append(PackagePath, "/Vanda/Packages/");
			}
			CChar path[MAX_NAME_SIZE];
			sprintf(path, "%s%s%s%s", PackagePath, szBuffer1, "/", szBuffer2);
			RemoveAllFilesAndFoldersInDirectory(path);
			for (CUInt i = 0; i < g_prefabPackagesAndNames[packageIndex].size(); i++)
			{
				if (i == 0) continue;
				if (Cmp(g_prefabPackagesAndNames[packageIndex][i].c_str(), m_selectedPrefabName.c_str()))
				{
					g_prefabPackagesAndNames[packageIndex].erase(g_prefabPackagesAndNames[packageIndex].begin() + i);
				}
			}

			m_prefabIndex = -1;
			//delete all items of prefab list
			for (int nItem = m_listPrefabs.GetItemCount() - 1; nItem >= 0; nItem--)
			{
				m_listPrefabs.DeleteItem(nItem);
			}

			for (CUInt i = 0; i < g_prefabPackagesAndNames[packageIndex].size(); i++)
			{
				if (i == 0) continue;
				CChar str[MAX_NAME_SIZE];
				Cpy(str, g_prefabPackagesAndNames[packageIndex][i].c_str());
				InsertItemToPrefabList(str);
			}
			m_listPrefabs.UpdateWindow();
		}
	}
	else
	{
		MessageBox("Please select a prefab!", "Vanda Engine Error", MB_OK | MB_ICONINFORMATION);
		return;
	}
}
示例#13
0
void CEditShadow::OnOK()
{
	if( g_vandaDemo )
	{
		MessageBox( "This feature is not available in RTI demo Edition", "Vanda Engine Error", MB_OK | MB_ICONINFORMATION );
		return;
	}

	// TODO: Add your specialized code here and/or call the base class
	if(	m_strSplitWeight.IsEmpty() || m_strNearClipPlane.IsEmpty() || m_strFarClipPlane.IsEmpty())
			MessageBox( "Please enter the valid data for all the required fields", "Vanda Engine Error", MB_OK | MB_ICONERROR );
	else
	{
		GetInformation();
		g_shadowProperties.m_shadowSplitWeight = m_splitWeight;
		g_shadowProperties.m_shadowFarClipPlane = m_farClipPlane;
		g_shadowProperties.m_shadowNearClipPlane = m_nearClipPlane;
		g_shadowProperties.m_shadowType = (CShadowType)m_shadowType;
		g_shadowProperties.m_shadowSplits = (CShadowSplits)m_shadowSplits;
		g_shadowProperties.m_shadowResolution = (CShadowResolution)m_shadowResolution;
		g_shadowProperties.m_intensity = m_intensity;

		switch( g_shadowProperties.m_shadowResolution )
		{
		case eSHADOW_1024:
			g_dynamicShadowMap->depth_size = 1024;
				break;
		case eSHADOW_2048:
			g_dynamicShadowMap->depth_size = 2048;
			break;
		case eSHADOW_4096:
			g_dynamicShadowMap->depth_size = 4096;
			break;
		default:
			break;
		}
		g_dynamicShadowMap->RegenerateDepthTex( g_dynamicShadowMap->depth_size );

		switch( g_shadowProperties.m_shadowSplits )
		{
		case eSHADOW_1_SPLIT:
			g_dynamicShadowMap->cur_num_splits = 1;
			break;
		case eSHADOW_2_SPLITS:
			g_dynamicShadowMap->cur_num_splits = 2;
			break;
		case eSHADOW_3_SPLITS:
			g_dynamicShadowMap->cur_num_splits = 3;
			break;
		case eSHADOW_4_SPLITS:
			g_dynamicShadowMap->cur_num_splits = 4;
			break;
		default:
			break;
		}

		g_dynamicShadowMap->split_weight = g_shadowProperties.m_shadowSplitWeight;
		Cpy( g_shadowProperties.m_directionalLightName,(LPCSTR)m_currentLightName);

		CInt checkState;
		checkState = m_checkBoxEnableShadow.GetCheck();
		if( checkState == BST_CHECKED && !g_vandaDemo)
			g_shadowProperties.m_enable = CTrue;
		else
			g_shadowProperties.m_enable = CFalse;

		CDialog::OnOK();
	}
}
示例#14
0
BOOL CVandaEngine1App::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();
	SetRegistryKey(_T("Vanda Engine 1"));
	CVandaEngine1Dlg dlg;
	m_pMainWnd = &dlg;
	ex_pVandaEngine1Dlg = &dlg;
	AfxInitRichEdit2();
	CCommandLineInfo oInfo;
	ParseCommandLine(oInfo);
	// DON'T display a new MDI child window during startup!!!
	//oInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
	//if (!ProcessShellCommand(oInfo))
	//	return FALSE;
	if(!oInfo.m_strFileName.IsEmpty())
	{
		g_openVINFile = CTrue;
		Cpy( g_fileNameInCommandLine, oInfo.m_strFileName.GetBuffer( oInfo.m_strFileName.GetLength() ) );
		oInfo.m_strFileName.ReleaseBuffer();

		std::string fullStr( GetCommandLine()  );
		std::string subStr;
		subStr.append( "''" );
		subStr.append(oInfo.m_strFileName.GetString());
		subStr.append( "''" );
		std::string tempStr = fullStr.substr( 0, fullStr.length() - subStr.length() );
		CChar tempStrChar[MAX_NAME_SIZE];
		Cpy( tempStrChar, tempStr.c_str() );
		CChar* afterPath = GetAfterPath( tempStrChar );
		std::string afterPathStr( afterPath);
		std::string finalStr = tempStr.substr(0, tempStr.length() - afterPathStr.length() - 1);
		finalStr.erase(0, 1);
		SetCurrentDirectory( finalStr.c_str() );
	}

	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}


	return FALSE;
}
示例#15
0
void CPrefabDlg::OnBnClickedDeletePackage()
{
	int nSelected = -1;
	POSITION p = m_listPrefabPackages.GetFirstSelectedItemPosition();
	while (p)
	{
		nSelected = m_listPrefabPackages.GetNextSelectedItem(p);
	}
	if (nSelected >= 0)
	{
		TCHAR szBuffer[1024];
		DWORD cchBuf(1024);
		LVITEM lvi;
		lvi.iItem = nSelected;
		lvi.iSubItem = 0;
		lvi.mask = LVIF_TEXT;
		lvi.pszText = szBuffer;
		lvi.cchTextMax = cchBuf;
		m_listPrefabPackages.GetItem(&lvi);

		m_selectedPackageName = szBuffer;

		if (Cmp(szBuffer, "Vanda_Basics"))
		{
			MessageBox("You cannot delete this package", "Vanda Engine Error", MB_OK | MB_ICONINFORMATION);
			return;
		}

		for (CUInt i = 0; i < g_projects.size(); i++)
		{
			for (CUInt j = 0; j < g_projects[i]->m_sceneNames.size(); j++)
			{
				//find pkg file
				CChar pkgPath[MAX_NAME_SIZE];
				CChar sceneWithoutDot[MAX_NAME_SIZE];
				Cpy(sceneWithoutDot, g_projects[i]->m_sceneNames[j].c_str());
				GetWithoutDot(sceneWithoutDot);
				sprintf(pkgPath, "%s%s%s%s%s", g_projectsPath, g_projects[i]->m_name, "/", sceneWithoutDot, "/packages.pkg");
				//copy package names
				FILE *PackageFilePtr;
				PackageFilePtr = fopen(pkgPath, "rb");
				if (!PackageFilePtr)
				{
					CChar temp[MAX_NAME_SIZE];
					sprintf(temp, "%s%s%s", "Couldn't open the file '", pkgPath, "' to save data");
					MessageBox(temp, "Vanda Engine Error", MB_OK);
					ReleaseCapture();
					PrintInfo("Delete failed.", COLOR_RED);
					return;
				}
				CUInt size = -1;
				fread(&size, sizeof(CUInt), 1, PackageFilePtr);
				for (CUInt k = 0; k < size; k++)
				{
					CChar name[MAX_NAME_SIZE];
					CChar package_name[MAX_NAME_SIZE];
					CChar prefab_name[MAX_NAME_SIZE];
					//write prefab data
					fread(name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);
					fread(package_name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);
					fread(prefab_name, sizeof(CChar), MAX_NAME_SIZE, PackageFilePtr);

					if (Cmp(package_name, m_selectedPackageName.c_str()))
					{
						CChar packageName[MAX_NAME_SIZE];
						sprintf(packageName, "This package is used by %s/%s.\nYou can not delete this package.", g_projects[i]->m_name, g_projects[i]->m_sceneNames[j].c_str());
						MessageBox(packageName, "Vanda Engine Error", MB_OK | MB_ICONERROR);
						fclose(PackageFilePtr);
						return;
					}
				}
				fclose(PackageFilePtr);
			}
		}

		CChar currentPackageName[MAX_NAME_SIZE];
		sprintf(currentPackageName, "%s", szBuffer);
		if (Cmp(g_currentPackageName, currentPackageName))
		{
			MessageBox("current open prefab belongs to selected package. Please close current prefab scene and try again.", "Vanda Engine Error", MB_OK | MB_ICONERROR);
			return;
		}

		if (MessageBox("Are you sure you want to delete this package?", "Warning", MB_YESNO) == IDYES)
		{
			CChar PackagePath[MAX_NAME_SIZE];
			HRESULT doc_result_package = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, PackagePath);
			if (doc_result_package != S_OK)
			{
				PrintInfo("\nCouldn't get the documents folder to write data", COLOR_RED);
				return;
			}
			else
			{
				Append(PackagePath, "/Vanda/Packages/");
			}
			CChar path[MAX_NAME_SIZE];
			sprintf(path, "%s%s", PackagePath, szBuffer);

			RemoveAllFilesAndFoldersInDirectory(path);

			//remove pkg file in PKG folder
			CChar PKG_old[MAX_URI_SIZE];
			sprintf(PKG_old, "%s%s%s%s", PackagePath, "PKG/", szBuffer, ".pkg");
			DeleteFile(PKG_old);

			//delete items from std::vector
			for (CUInt i = 0; i < g_prefabPackagesAndNames.size(); i++)
			{
				if (Cmp(g_prefabPackagesAndNames[i].front().c_str(), m_selectedPackageName.c_str()))
				{
					g_prefabPackagesAndNames[i].clear();
					g_prefabPackagesAndNames.erase(g_prefabPackagesAndNames.begin() + i);
					break;
				}
			}

			m_listPrefabPackages.DeleteItem(nSelected);
			m_listPrefabPackages.UpdateWindow();
			m_packageIndex--;
		}
	}
	else
	{
		MessageBox("Please select an item!", "Vanda Engine Error", MB_OK | MB_ICONINFORMATION);
		return;
	}
}
示例#16
0
void Marge (sizebuf_t *dest, int start, int end)
{
	zn_t zn1, zn2, zn3;
	header_t *d;
	source_t *who;
	sizebuf_t tmp, *m1, *m2, *m3;
	byte	buffer[45*MAX_MSGLEN];
	int num;

	memset(&tmp, 0, sizeof(tmp));
	tmp.data = buffer;
	tmp.maxsize = sizeof(buffer);

	SBCpy(dest,&sources->frames[start&UPDATE_MASK].buf);

	// mark place after this message as free
	//MoveFromDemoBuffer(sources, who->frames[world.lastwritten&UPDATE_MASK].buf.bufsize);

	for (who = sources + 1; who - sources < sworld.fromcount; who++)
	{
		m1 = dest;
		m2 = &who->frames[start&UPDATE_MASK].buf;

		memset(&zn1, 0, sizeof(zn1));
		memset(&zn2, 0, sizeof(zn2));

		zn1.fin = !m1->bufsize;
		zn2.fin = !m2->bufsize;

		(byte*)zn1.start = m1->data;
		(byte*)zn1.end = m1->data;
		(byte*)zn2.start = m2->data;
		(byte*)zn2.end = m2->data;

		(byte*)d = tmp.data;

		while(!zn1.fin || !zn2.fin)
		{
			if (!zn1.fin)
				CheckMsg(&zn1, &zn2, &d, NULL,0,0);

			if (!zn2.fin)
				CheckMsg(&zn2, &zn1, &d, NULL,0,0);

			zn1.fin = ((byte*)zn1.end - m1->data) == m1->bufsize;
			zn2.fin = ((byte*)zn2.end - m2->data) == m2->bufsize;
		}

		// mark place after this message as free
		MoveFromDemoBuffer(who, start, (byte*)zn2.start - m2->data);

		if (who - sources == 1)
		{
			MoveFromDemoBuffer(sources, start, (byte*)zn1.start - m1->data);
			for (num = start + 1; zn2.start != zn2.end && num < end; num++)
			{
				m3 = &sources->frames[num&UPDATE_MASK].buf;
				memset(&zn3, 0, sizeof(zn3));

				(byte*)zn3.start = m3->data;
				(byte*)zn3.end = m3->data;

				while ((byte*)zn3.end - (byte*)zn3.start < m3->bufsize)
					CheckMsg(&zn3, &zn2, &d, sources, start, num);

			}

			if (!sources->frames[start&UPDATE_MASK].buf.bufsize)
				zn1.start = zn1.end;
		}

		MoveFromDemoBuffer(who, start, (byte*)zn2.start - m2->data);

		for (num = start + 1; zn1.start != zn1.end && num < end; num++)
		{
			m3 = &who->frames[num&UPDATE_MASK].buf;
			memset(&zn3, 0, sizeof(zn3));

			(byte*)zn3.start = m3->data;
			(byte*)zn3.end = m3->data;

			while ((byte*)zn3.end - (byte*)zn3.start < m3->bufsize)
				CheckMsg(&zn3, &zn1, &d, who, start, num);

		}

		if (!m2->bufsize)
			zn2.start = zn2.end;

		// copy what's left
		for (; zn1.start != zn1.end; NextMsg(zn1.start), NextMsg(d))
			Cpy(d,zn1.start);
		for (; zn2.start != zn2.end; NextMsg(zn2.start), NextMsg(d))
			Cpy(d,zn2.start);

		MoveFromDemoBuffer(who, start, m2->bufsize);

		tmp.bufsize = (byte*)d - tmp.data;
		SBCpy(dest, &tmp);
	}

	MoveFromDemoBuffer(sources, start, sources->frames[start&UPDATE_MASK].buf.bufsize);

	IntegrateMsgs(dest);
}
示例#17
0
void Marge (sizebuf_t *dest, int start, int end)
{
	zn_t zn1, zn2, znd;
	header_t *d, *t;
	source_t *who;
	sizebuf_t tmp, *m1, *m2;
	byte	buffer[45*MAX_MSGLEN];
	int num, n2, n3, num2;

	if (sworld.fromcount == 1)
	{
		SBCpy(dest,&sources->frames[start&UPDATE_MASK].buf);
		MoveFromDemoBuffer(sources, start, sources->frames[start&UPDATE_MASK].buf.bufsize);
		return;
	}

	desync_frames = desync_source = 0;

	//Sys_Printf("%d %d %d\n", start, end, world.messages.bufsize);
	for (; world.lastmarged < end; world.lastmarged++)
	{
		memset(&tmp, 0, sizeof(tmp));
		tmp.data = buffer;
		tmp.maxsize = sizeof(buffer);

		for (who = sources; who - sources < sworld.fromcount; who++)
		{
			//Sys_Printf("marge: %d, %d\n", world.lastmarged, who - sources);
			m1 = &world.messages;
			m2 = &who->frames[world.lastmarged&UPDATE_MASK].buf;
			//Sys_Printf("%d ", m1->bufsize ? ((header_t*)m1->data)->frame : -1);

			memset(&zn1, 0, sizeof(zn1));
			memset(&zn2, 0, sizeof(zn2));

			zn1.fin = true;//!m1->bufsize;
			zn2.fin = !m2->bufsize;

			zn1.start = (header_t *)m1->data;
			zn1.end = (header_t *)(m1->data + m1->bufsize);
			zn2.start = (header_t *)m2->data;
			zn2.end = (header_t *)m2->data;

			d = (header_t *)tmp.data;
			znd.start = (header_t *)tmp.data;
			znd.end = (header_t *)tmp.data;

			while (!zn2.fin)
			{
				for (t = zn1.start; t != zn1.end; NextMsg(t))
					if (Cmp(zn2.end, t))
						break;

				if (t != zn1.end)
				{
					Mrg(zn2.end, t, t, true);
				}
				else
				{
					Cpy(zn1.end, zn2.end);
					NextMsg(zn1.end);
				}
				NextMsg(zn2.end);

				zn2.fin = ((byte*)zn2.end - m2->data) == m2->bufsize;
			}

			m1->bufsize = (byte*)zn1.end - (byte*)zn1.start;
			MoveFromDemoBuffer(who, world.lastmarged, m2->bufsize);
#if 0
			//Sys_Printf("petla:%d, %d\n", m1->bufsize, m2->bufsize);
			while(!zn1.fin || !zn2.fin)
			{
				//Sys_Printf("petla:%d, %d, %d\n", m1->bufsize, m2->bufsize,(byte*)znd.end - (byte*)znd.start);
				if (!zn1.fin)
					CheckMsg(&zn1, &zn2, &znd);

				if (!zn2.fin)
					CheckMsg(&zn2, &zn1, &znd);


				zn1.fin = ((byte*)zn1.end - m1->data) == m1->bufsize;
				zn2.fin = ((byte*)zn2.end - m2->data) == m2->bufsize;
			}
			//Sys_Printf("koniec\n");

			if (!m2->bufsize)
				zn2.start = zn2.end;

			//Sys_Printf("copy\n");
			// copy what's left
			for (; zn1.start != zn1.end; NextMsg(zn1.start), NextMsg(znd.end))
				Cpy(znd.end,zn1.start);

			for (; zn2.start != zn2.end; NextMsg(zn2.start), NextMsg(znd.end))
				Cpy(znd.end,zn2.start);

			//Sys_Printf("move\n");

			MoveFromDemoBuffer(who, world.lastmarged, m2->bufsize);

			tmp.bufsize = (byte*)znd.end - (byte*)znd.start;
			//Sys_Printf("copy to world %d\n",tmp.bufsize);

			SBCpy(&world.messages, &tmp);
			//Sys_Printf("%d done %d\n", who - sources, world.messages.bufsize);
#endif

		}
		//Sys_Printf("\n");
	}

	// find where messages for current frame ends
	t = d = (header_t*)world.messages.data;
	num = n2 = world.lastwritten;
	n3 = -1;
	//if (world.messages.bufsize)
	//	Sys_Printf ("%d %d:", world.lastwritten, world.lastmarged);
	while ((byte*)t - (byte*)world.messages.data < world.messages.bufsize)
	{
		//Sys_Printf("%d ", t->frame);
		if (t->frame <= world.lastwritten)
		{
			d = t;
			num = n2;
			num2 = n3;
		}

		if (t->frame > n2)
		{
			n2 = t->frame;
			n3 = t->source;
		}

		NextMsg(t);
	}

	if (world.messages.bufsize)
	{
		//Sys_Printf("\n");
		//if (num > world.lastwritten) {
		//	for (num = 0; num < sworld.fromcount; num++)
		//		if (num2
		//	Sys_Printf("%d\n", num - world.lastwritten);
		if (d->frame <= world.lastwritten)
			NextMsg(d);
	}
	//if (desync_frames > 0)
	//	Sys_Printf("%d %d %d\n", world.lastwritten, desync_frames, desync_source);
#if 0
	if (desync_frames > 1)
	{
		//Sys_Printf("%d %d %d\n", world.lastwritten, desync_frames, desync_source);
		for (num = 0; num < sworld.fromcount; num++)
			if (desync_source & (1 << num))
				sources[num].sync -= 0.0005*desync_frames;
	}
#endif

	dest->bufsize = (byte*)d - (byte*)world.messages.data;
	//Sys_Printf("here:%d, %d\n", dest->bufsize, world.messages.bufsize);
	memcpy(dest->data,world.messages.data, dest->bufsize);
	memmove(world.messages.data, &world.messages.data[dest->bufsize],world.messages.bufsize - dest->bufsize);
	world.messages.bufsize -= dest->bufsize;

	//Sys_Printf("out\n");

	IntegrateMsgs(dest);
	//Sys_Printf("integrated\n");
}
示例#18
0
BOOL CPrefabDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	CMenu menu;
	menu.LoadMenu(IDR_MENU2);
	SetMenu(&menu);
	menu.Detach();

	if (g_editorMode == eMODE_PREFAB)
	{
		GetMenu()->EnableMenuItem(ID_PACKAGE_NEW, MF_ENABLED);
		GetMenu()->EnableMenuItem(ID_PACKAGE_RENAMESELECTED, MF_ENABLED);
		GetMenu()->EnableMenuItem(ID_PACKAGE_DELETESELECTED, MF_ENABLED);

		GetMenu()->EnableMenuItem(ID_PREFAB_NEW, MF_ENABLED);
		GetMenu()->EnableMenuItem(ID_PREFAB_OPENSELECTED, MF_ENABLED);
		GetMenu()->EnableMenuItem(ID_PREFAB_RENAMESELECTED, MF_ENABLED);
		GetMenu()->EnableMenuItem(ID_PREFAB_DELETESELECTED, MF_ENABLED);
		m_btnInsertPrefab.SetWindowTextA("Open Prefab");
	}
	else
	{
		GetMenu()->EnableMenuItem(ID_PACKAGE_NEW, MF_DISABLED | MF_GRAYED);
		GetMenu()->EnableMenuItem(ID_PACKAGE_RENAMESELECTED, MF_DISABLED | MF_GRAYED);
		GetMenu()->EnableMenuItem(ID_PACKAGE_DELETESELECTED, MF_DISABLED | MF_GRAYED);

		GetMenu()->EnableMenuItem(ID_PREFAB_NEW, MF_DISABLED | MF_GRAYED);
		GetMenu()->EnableMenuItem(ID_PREFAB_OPENSELECTED, MF_DISABLED | MF_GRAYED);
		GetMenu()->EnableMenuItem(ID_PREFAB_RENAMESELECTED, MF_DISABLED | MF_GRAYED);
		GetMenu()->EnableMenuItem(ID_PREFAB_DELETESELECTED, MF_DISABLED | MF_GRAYED);

		m_btnInsertPrefab.SetWindowTextA("Insert Prefab");

	}
	m_slideLod.SetRange(0, 2);
	CBitmap cBmp;
	CBitmap* cBmpMask = NULL;
	m_packageListImage.Create(36, 36, ILC_COLOR24, 1, 1);

	cBmp.LoadBitmap(IDB_BITMAP_DEFAULT_PACKAGE);
	m_packageListImage.Add(&cBmp, cBmpMask);
	cBmp.DeleteObject();

	RECT tempRect;
	m_listPrefabPackages.GetClientRect(&tempRect);
	m_listPrefabPackages.SetImageList(&m_packageListImage, LVSIL_SMALL);
	m_listPrefabPackages.InsertColumn(0, "Packages", LVCFMT_CENTER | LVS_SHOWSELALWAYS, (tempRect.right - tempRect.left) * 80 / 100);
	m_listPrefabPackages.ShowWindow(SW_SHOW);
	m_listPrefabPackages.UpdateWindow();

	m_prefabListImage.Create(80, 80, ILC_COLOR24, 1, 1);

	cBmp.LoadBitmap(IDB_BITMAP_DEFAULT_VPF);
	m_prefabListImage.Add(&cBmp, cBmpMask);
	cBmp.DeleteObject();

	m_listPrefabs.SetImageList(&m_prefabListImage, LVSIL_NORMAL);

	m_listPrefabs.GetClientRect(&tempRect);
	m_listPrefabs.InsertColumn(0, "Prefabs", LVCFMT_LEFT | LVS_SHOWSELALWAYS, (tempRect.right - tempRect.left) * 80 / 100);
	m_listPrefabs.ShowWindow(SW_SHOW);
	m_listPrefabs.UpdateWindow();

	//insert items
	for (CUInt i = 0; i < g_prefabPackagesAndNames.size(); i++)
	{
		CChar str[MAX_NAME_SIZE];
		Cpy(str, g_prefabPackagesAndNames[i].front().c_str());
		if (!Cmp(str, "Vanda_Basics"))
			InsertItemToPackageList(str);
	}
	RECT rect;
	m_listPrefabProperties.GetClientRect(&rect);
	m_listPrefabProperties.InsertColumn(0, "Parameters", LVCFMT_LEFT, rect.right - rect.left, 1);
	m_listPrefabProperties.SetExtendedStyle(LVS_EX_INFOTIP | LVS_EX_ONECLICKACTIVATE | LVS_EX_LABELTIP);
	InserItemToPropertiesList("Vertices");
	InserItemToPropertiesList("Textures");

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
示例#19
0
void Mrg(header_t *a, header_t *b, header_t *d, qbool update)
{
	if (!update)
		Cpy(d, a);

	if (b->frame - a->frame > desync_frames)
	{
		desync_frames = b->frame - a->frame;
		desync_source = b->source;
	}
	else if (a->frame - b->frame > desync_frames)
	{
		desync_frames = a->frame - b->frame;
		desync_source = a->source;
	}

	d->frame = a->frame < b->frame ? a->frame : b->frame;
	d->source = a->source | b->source;

	switch (a->type)
	{
	case dem_single:
		switch (b->type)
		{
		case dem_all:
			(d)->type = dem_all;
			(d)->to = 0;
			break;
		case dem_single:
			if (a->to != b->to)
			{
				(d)->type = dem_multiple;
				(d)->to = (1 << a->to) | (1 << b->to);
			}
			break;
		case dem_multiple:
			(d)->type = dem_multiple;
			(d)->to = (1 << a->to) | b->to;
			break;
		default: //FIXME ?
			(d)->type = a->type;
			(d)->to = a->to;
		}
		break;
	case dem_multiple:
		switch (b->type)
		{
		case dem_all:
			(d)->type = dem_all;
			(d)->to = 0;
			break;
		case dem_multiple:
			(d)->type = dem_multiple;
			(d)->to = a->to | b->to;
			break;
		case dem_single:
			(d)->type = dem_multiple;
			(d)->to = a->to | (1 << b->to);
			break;
		default:
			(d)->type = a->type;
			(d)->to = a->to;
		}
		break;
	case dem_stats:
		(d)->type = dem_stats;
		(d)->to = a->to;
		break;
	case dem_all:
		(d)->type = dem_all;
		(d)->to = 0;
		break;
	}
}
示例#20
0
文件: Base.cpp 项目: DCubix/1.4.0
 CVoid	CBase::SetName( const CChar * n )
{
	Cpy( m_name, n);
}
示例#21
0
文件: Base.cpp 项目: DCubix/1.4.0
 CVoid CBase::SetDocURI(const CChar * n)
{
	Cpy( m_docURI, n);
} 
示例#22
0
文件: Water.cpp 项目: DCubix/1.4.0
CVoid CWater::SetNormalMapName(CChar* name) { 
	Cpy(m_strNormalMap, name );
}
示例#23
0
CVoid CTransform::SetSid( CChar * sid )
{
	Cpy( m_sid, sid ); 
}
示例#24
0
CVoid COctree::SetName( CChar* name )
{
	Cpy( m_name, name );
}
示例#25
0
void CSetCurrentProject::OnOK()
{
    int nSelected = -1;
    POSITION p = m_listAvailableProjects.GetFirstSelectedItemPosition();
    while(p)
    {
        nSelected = m_listAvailableProjects.GetNextSelectedItem(p);
    }
    if( nSelected >= 0 )
    {
        TCHAR szBuffer[1024];
        DWORD cchBuf(1024);
        LVITEM lvi;
        lvi.iItem = nSelected;
        lvi.iSubItem = 0;
        lvi.mask = LVIF_TEXT;
        lvi.pszText = szBuffer;
        lvi.cchTextMax = cchBuf;
        m_listAvailableProjects.GetItem(&lvi);

        for( CUInt i = 0; i < g_projects.size(); i++ )
        {
            if(g_projects[i]->m_isActive)
            {
                if( Cmp( szBuffer, g_projects[i]->m_name ) )
                {
                    return; // no need to switch projects
                }
            }
        }
        //switch projects
        //close curren open VScene
        if(!ex_pVandaEngine1Dlg->OnMenuClickedNew(CTrue))
            return;

        //fist of all, mark all as inactive
        for( CUInt i = 0; i < g_projects.size(); i++ )
        {
            g_projects[i]->m_isActive = CFalse;
        }
        //then find the selected project and mark it as active
        for( CUInt i = 0; i < g_projects.size(); i++ )
        {
            if( Cmp( szBuffer, g_projects[i]->m_name ) )
            {
                g_projects[i]->m_isActive = CTrue;
                break;
            }
        }


        //change current directory
        Cpy( g_currentProjectPath, g_projectsPath );
        Append( g_currentProjectPath, szBuffer );
        Append( g_currentProjectPath, "/" );

        //clear VScene names
        g_VSceneNamesOfCurrentProject.clear();
        //then fill it with the VScenes of the selected project
        for( CUInt i = 0; i < g_projects.size(); i++ )
        {
            if( g_projects[i]->m_isActive )
            {
                for( CUInt j = 0; j < g_projects[i]->m_sceneNames.size(); j++ )
                {
                    g_VSceneNamesOfCurrentProject.push_back( g_projects[i]->m_sceneNames[j].c_str() );
                }
            }
        }
        CChar m_currentVSceneNameWithoutDot[MAX_NAME_SIZE];
        if (Cmp(g_currentVSceneName, "\n"))
            Cpy(m_currentVSceneNameWithoutDot, "Untitled");
        else
        {
            Cpy(m_currentVSceneNameWithoutDot, g_currentVSceneName);
            GetWithoutDot(m_currentVSceneNameWithoutDot);
        }

        CChar temp[256];
        sprintf(temp, "%s%s%s%s%s", "Vanda Engine 1.4 (", szBuffer, " - ", m_currentVSceneNameWithoutDot, ")");
        ex_pVandaEngine1Dlg->SetWindowTextA(temp);
        //save the changes to projects.dat
        FILE *ProjectsFilePtr;
        CChar DATPath[MAX_NAME_SIZE];
        sprintf( DATPath, "%s%s", g_projectsPath, "projects.dat" );

        DeleteFile( DATPath );
        ProjectsFilePtr =  fopen( DATPath, "wb" );
        if( !ProjectsFilePtr )
        {
            MessageBox( "Couldn't open 'assets/Projects/projects.dat' to save data!", "Vanda Engine Error", MB_OK | MB_ICONERROR);
            //return;
        }

        CInt numProjects = (CInt)g_projects.size();
        fwrite(&numProjects, sizeof(CInt), 1, ProjectsFilePtr);
        fclose(ProjectsFilePtr);

        for (CInt i = 0; i < numProjects; i++)
        {
            CChar filePath[MAX_URI_SIZE];
            sprintf(filePath, "%s%s%s%s", g_projectsPath, "PRJ/", g_projects[i]->m_name, ".prj");
            ProjectsFilePtr = fopen(filePath, "wb");

            fwrite(g_projects[i]->m_name, sizeof(CChar), MAX_NAME_SIZE, ProjectsFilePtr);
            CInt numScenes = (CInt)g_projects[i]->m_sceneNames.size();
            fwrite(&numScenes, sizeof(CInt), 1, ProjectsFilePtr);
            for (CInt j = 0; j < numScenes; j++)
            {
                CChar vsceneName[MAX_NAME_SIZE];
                Cpy(vsceneName, g_projects[i]->m_sceneNames[j].c_str());
                fwrite(vsceneName, sizeof(CChar), MAX_NAME_SIZE, ProjectsFilePtr);
            }
            fwrite(&g_projects[i]->m_isActive, sizeof(CBool), 1, ProjectsFilePtr);

            fclose(ProjectsFilePtr);

        }


        CDialog::OnOK();
    }
    else
    {
        MessageBoxA( "Please select a project" );
    }

}
示例#26
0
void CPrefabDlg::OnLvnItemchangedListPrefabsProjects(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
	//remove the current contents of the prefab list
	for (int nItem = m_listPrefabs.GetItemCount() - 1; nItem >= 0; nItem--)
	{
		m_listPrefabs.DeleteItem(nItem);
	}
	m_listPrefabs.UpdateWindow();
	m_prefabIndex = -1; //reset prefab index

	int nSelected = -1;
	POSITION p = m_listPrefabPackages.GetFirstSelectedItemPosition();
	while (p)
	{
		nSelected = m_listPrefabPackages.GetNextSelectedItem(p);
	}
	if (nSelected >= 0)
	{
		TCHAR szBuffer[1024];
		DWORD cchBuf(1024);
		LVITEM lvi;
		lvi.iItem = nSelected;
		lvi.iSubItem = 0;
		lvi.mask = LVIF_TEXT;
		lvi.pszText = szBuffer;
		lvi.cchTextMax = cchBuf;
		m_listPrefabPackages.GetItem(&lvi);
		m_selectedPackageName = szBuffer;

		if (g_editorMode == eMODE_PREFAB)
		{
			//if (Cmp(szBuffer, "Vanda_Basics"))
			//{
			//	GetMenu()->EnableMenuItem(ID_PREFAB_NEW, MF_DISABLED | MF_GRAYED);
			//	GetMenu()->EnableMenuItem(ID_PREFAB_OPENSELECTED, MF_DISABLED | MF_GRAYED);
			//	GetMenu()->EnableMenuItem(ID_PREFAB_RENAMESELECTED, MF_DISABLED | MF_GRAYED);
			//	GetMenu()->EnableMenuItem(ID_PREFAB_DELETESELECTED, MF_DISABLED | MF_GRAYED);
			//}
			//else
			//{
			//	GetMenu()->EnableMenuItem(ID_PREFAB_NEW, MF_ENABLED);
			//	GetMenu()->EnableMenuItem(ID_PREFAB_OPENSELECTED, MF_ENABLED);
			//	GetMenu()->EnableMenuItem(ID_PREFAB_RENAMESELECTED, MF_ENABLED);
			//	GetMenu()->EnableMenuItem(ID_PREFAB_DELETESELECTED, MF_ENABLED);
			//}
		}
	}
	else
	{
		return;
	}
	CInt index = -1;
	for (CInt i = 0; i < (CInt)g_prefabPackagesAndNames.size(); i++)
	{
		if (Cmp(g_prefabPackagesAndNames[i].front().c_str(), m_selectedPackageName.c_str()))
		{
			index = i;
			break;
		}
	}
	if (index != -1)
	{
		for (CUInt i = 0; i < g_prefabPackagesAndNames[index].size(); i++)
		{
			if (i == 0) continue;
			CChar str[MAX_NAME_SIZE];
			Cpy(str, g_prefabPackagesAndNames[index][i].c_str());
			InsertItemToPrefabList(str);
		}
	}
	*pResult = 0;
}
示例#27
0
文件: Water.cpp 项目: DCubix/1.4.0
CVoid CWater::SetName( CString name  ) { 
	Cpy( m_strWaterName, (char*)name.GetBuffer(name.GetLength()) );
	name.ReleaseBuffer();
}
示例#28
0
文件: Scene.cpp 项目: DCubix/1.4.0
CBool CScene::Load( CChar * fileName, CBool reportWarningsAndErrors, CBool readFromBuffer )
{
	if ( fileName == NULL )
		return CFalse; 
	CChar * nameOnly = GetAfterPath( fileName );
	SetName( nameOnly );

	// Instantiate the reference implementation
	m_collada = new DAE;
	PrintInfo( "\n" );
	PrintInfo( _T("\n========Importing new external scene========"), COLOR_BLUE ); 
	numErrors = numWarnings = 0;
	domCOLLADA *dom;
	if( readFromBuffer )
	{
		/////////////////////////////////////////////////////////////////
		//zip path
		CChar zipPath[MAX_NAME_SIZE];
		Cpy( zipPath, fileName );
		GetWithoutDot( zipPath );
		Append(zipPath, ".zip" );

		//file name inside zip file
		CChar fileNameInZip[MAX_NAME_SIZE];
		Cpy( fileNameInZip, GetAfterPath( fileName ) );
		//Uncompress zip file
		std::string buffer = ReadZipFile( zipPath, fileNameInZip );
		//res = m_collada->load( "", buffer.c_str() );
		dom = m_collada->openFromMemory( "", buffer.c_str() );
		///////////////////////////////////////////////////////////////
	}
	else
	{
		// load with full path 
		//res = m_collada->load( fileName );
		dom = m_collada->open(fileName);
	}

	//if (res != DAE_OK)
	//{
	//	PrintInfo(_T("\nCScene::Load > Error loading the COLLADA file:") + CString(fileName), COLOR_RED );
	//	delete m_collada;
	//	m_collada = NULL;

		//if( reportWarningsAndErrors )
		//{
		//	char tempReport[MAX_NAME_SIZE];;
		//	sprintf( tempReport, "%s - fatal error (s)", nameOnly );
		//	PrintInfo2( tempReport, COLOR_RED ); 
		//}

	//	return CFalse;
	//}
	PrintInfo( _T("\nCOLLADA_DOM Runtime database initialized from" ) );
	PrintInfo( _T("'") +  CString( fileName ), COLOR_RED_GREEN );
	//PrintInfo( _T("nameOnly: '") + (CString)nameOnly + _T( "'\n" ) );

	//domCOLLADA *dom = m_collada->getDom(nameOnly);
	//if ( !dom )
	//	dom = m_collada->getDom( fileName); 
	if ( !dom )
	{
		PrintInfo( _T("\nCScene::Load > COLLADA File loaded to the dom, but query for the dom assets failed "), COLOR_RED );
		PrintInfo( _T("\nCScene::Load > COLLADA Load Aborted! "), COLOR_RED );
		delete m_collada;	
		m_collada = NULL;
		if( reportWarningsAndErrors )
		{
			char tempReport[MAX_NAME_SIZE];;
			sprintf( tempReport, "\n%s - Fatal error (s)", nameOnly );
			PrintInfo( tempReport, COLOR_RED ); 
		}
		return CFalse; 
	}

	CInt ret = 0;
	//PrintInfo("Begin Conditioning\n");
	//ret = kmzcleanup(m_collada, true);
	//if (ret)
	//	PrintInfo("kmzcleanup complete\n");
	ret = Triangulate(m_collada);
	if (ret)
		PrintInfo("\nTriangulate complete");
	//ret = deindexer(m_collada);
	//if (ret)
	//	PrintInfo("deindexer complete\n");

	//PrintInfo("Finish Conditioning\n");

	// Need to now get the asset tag which will determine what vector x y or z is up.  Typically y or z. 
	if ( dom->getAsset()->getUp_axis() )
	{
		domAsset::domUp_axis *up = dom->getAsset()->getUp_axis();
		switch( up->getValue() )
		{
			case UPAXISTYPE_X_UP:
				PrintInfo(_T("\nWarning!X is Up Data and Hiearchies must be converted!") ); 
				PrintInfo(_T("\nConversion to X axis Up isn't currently supported!") ); 
				PrintInfo(_T("\nCOLLADA defaulting to Y Up") ); 
				numWarnings +=1;
				//CRender.SetUpAxis(eCYUp); 
				break; 
			case UPAXISTYPE_Y_UP:
				PrintInfo( _T("\nY Axis is Up for this file...COLLADA set to Y Up ") ); 
				//CRender.SetUpAxis(eCYUp); 
				break;
			case UPAXISTYPE_Z_UP:
				PrintInfo( _T("\nZ Axis is Up for this file ") ); 
				PrintInfo( _T("\nAll Geometries and Hiearchies converted!"), COLOR_YELLOW ) ; 
				numWarnings +=1;
				//CRender.SetUpAxis(eCZUp); 
				break; 
			default:
				break; 
		}
	}
	strcpy( m_fileName, fileName ); 
	strcpy( m_pureFileName, nameOnly ); 

	// Load all the image libraries
	//for ( CUInt i = 0; i < dom->getLibrary_images_array().getCount(); i++)
	//{
	//	ReadImageLibrary( dom->getLibrary_images_array()[i] );			
	//}

	CBool success = CFalse;

	/*
	CChar *cfxBinFilename = ReadCfxBinaryFilename( dom->getExtra_array() );
	
	if ( cfxBinFilename != NULL ) 
	{
		cfxLoader::setBinaryLoadRemotePath( BasePath );
		success = (CBool) cfxLoader::loadMaterialsAndEffectsFromBinFile(cfxBinFilename, cfxMaterials, cfxEffects, cgContext);
		assert(success);
	}
	else
	{
	*/
		//success = ( CBool ) cfxLoader::loadMaterialsAndEffects( m_collada, m_cfxMaterials, m_cfxEffects, m_cgContext );
		//assert(success);
	/*}*/
	
	// Load all the effect libraries
	//for ( CUInt i = 0; i < dom->getLibrary_effects_array().getCount(); i++)
	//{
	//	ReadEffectLibrary( dom->getLibrary_effects_array()[i] );			
	//}

	//// Load all the material libraries
	//for ( CUInt i = 0; i < dom->getLibrary_materials_array().getCount(); i++)
	//{
 //		ReadMaterialLibrary( dom->getLibrary_materials_array()[i] );			
	//}

	// Load all the animation libraries
	for ( CUInt i = 0; i < dom->getLibrary_animations_array().getCount(); i++)
	{
		ReadAnimationLibrary( dom->getLibrary_animations_array()[i] );		
		m_hasAnimation = CTrue;
	}
	//Load all animation clips
	for ( CUInt i = 0; i < dom->getLibrary_animation_clips_array().getCount(); i++)
	{
		ReadAnimationClipLibrary( dom->getLibrary_animation_clips_array()[i] );			
	}

	//If there's no clip in COLLADA file, try to create a default clip
	if( m_numClips == 0 && dom->getLibrary_animations_array().getCount() > 0 )
	{
		//Create a default clip and attach all the animations to this clip
		PrintInfo( "\nAdding default animation clip..." );
		CAnimationClip * newAnimClip = CNew(CAnimationClip); 
		//CAssert("No memory\n", newAnimClip!=NULL);
		newAnimClip->SetName( "defaultClip" );
		newAnimClip->SetIndex(0);
		newAnimClip->SetStart(0.0);
		CFloat endTime = 0.0;
		for(CUInt i=0; i<m_animations.size(); i++)
		{
			CAnimation * anim = m_animations[i];

			PrintInfo( "\nAttaching animation ' ", COLOR_WHITE );PrintInfo( anim->GetName(), COLOR_RED_GREEN );
			PrintInfo( " ' to the default animation clip", COLOR_WHITE  );
			
			anim->SetClipTarget( newAnimClip );
			newAnimClip->m_animations.push_back( anim );
			if( anim->GetEndTime() > endTime )
				endTime = anim->GetEndTime();
		}
		newAnimClip->SetEnd((CDouble)endTime);
		m_numClips = 1;
		m_animationClips.push_back( newAnimClip );
	}

	// Find the scene we want
	daeElement* defaultScene = dom->getScene()->getInstance_visual_scene()->getUrl().getElement();
	domAsset::domUp_axis *up = dom->getAsset()->getUp_axis();

	switch( up->getValue() )
	{
		case UPAXISTYPE_X_UP:
			upAxis = eCXUp;
			break; 
		case UPAXISTYPE_Y_UP:
			upAxis = eCYUp;
			break;
		case UPAXISTYPE_Z_UP:
			upAxis = eCZUp;
			break; 
		default:
			break; 
	}

	if(defaultScene)
		ReadScene( (domVisual_scene *)defaultScene, upAxis );
	
	if (m_collada)
	{
		delete m_collada;
		m_collada = 0;
	}
	if( reportWarningsAndErrors )
	{
		char tempReport[MAX_NAME_SIZE];
		COLORREF color;
		if( numErrors > 0 )
			color = COLOR_RED;
		else if (numWarnings > 0 )
			color = COLOR_YELLOW;
		else
			color = COLOR_GREEN;
		sprintf( tempReport, "\n%s - %i error (s), %i warning (s)", nameOnly, numErrors, numWarnings );

		PrintInfo( tempReport, color );

		totalErrors += numErrors;
		totalWarnings += numWarnings;
	}
	return CTrue;
}
示例#29
0
文件: Water.cpp 项目: DCubix/1.4.0
CVoid CWater::SetDuDvMapName(CChar* name) { 
	Cpy(m_strDuDvMap, name);
}
示例#30
0
文件: Scene.cpp 项目: DCubix/1.4.0
CVoid CScene::Destroy()
{
	NxScene* tempScene = gPhysXscene/*gPhysicsSDK->getScene(i)*/;
	if(tempScene && !g_clickedNew && !g_clickedOpen)
	{
		for( CUInt i = 0; i < m_instanceGeometries.size(); i++ )
		{
			CInstanceGeometry* m_instanceGeo = m_instanceGeometries[i];
			if( tempScene )
			{
				for( CUInt j = 0; j < tempScene->getNbActors(); j++ )
				{
					CChar actorName[MAX_URI_SIZE];
					if( !tempScene->getActors()[j]->getName() ) continue;
					Cpy( actorName, tempScene->getActors()[j]->getName() );
					if( !Cmp(m_instanceGeo->m_physXName, "\n" ) && Cmp( actorName, m_instanceGeo->m_physXName ) )
					{
						tempScene->releaseActor( *tempScene->getActors()[j] );
						g_nx->gControllers->reportSceneChanged();
						m_instanceGeo->m_hasPhysX = CFalse;
						Cpy( m_instanceGeo->m_physXName, "\n" );
					}
				}
			}
		}
	}
	//while(!m_cfxMaterials.empty())
	//{
	//	std::map<std::string, cfxMaterial*>::iterator iter = m_cfxMaterials.begin();
	//	CDelete(iter->second);
	//	m_cfxMaterials.erase(iter);
	//}
	//m_cfxEffects.clear();

	//while(!m_cfxEffects.empty())
	//{
	//	std::map<std::string, cfxEffect*>::iterator iter = m_cfxEffects.begin();
	//	CDelete(iter->second);
	//	m_cfxEffects.erase(iter);
	//}
	//m_cfxEffects.clear();
	//delete all the geometries
	//while(!m_geometries.empty())
	//{
	//	CDelete( m_geometries[0] ); 
	//	m_geometries.erase( m_geometries.begin() );
	//}	
	//m_geometries.clear();
	m_instanceGeometries.clear();

	while(!m_lightInstances.empty())
	{
		CDelete(m_lightInstances[0]);
		m_lightInstances.erase(m_lightInstances.begin());
	}
	while(!m_lights.empty())
	{
		CDelete( m_lights[0] ); 
		m_lights.erase(m_lights.begin());
	}
	while(!m_cameraInstances.empty())
	{
		for( CUInt size = 0; size < g_cameraInstances.size(); size++ )
		{
			if( Cmp( m_cameraInstances[0]->m_abstractCamera->GetName(), g_cameraInstances[size]->m_abstractCamera->GetName() ) )
			{
				if( g_render.GetActiveInstanceCamera() == g_cameraInstances[size] )
				{
					if (g_main && g_render.GetDefaultInstanceCamera())
					{
						g_render.SetActiveInstanceCamera(g_render.GetDefaultInstanceCamera());
						g_currentCameraType = eCAMERA_DEFAULT_FREE;
						g_main->m_lockInput = CFalse;
					}
					else
					{
						g_render.SetActiveInstanceCamera(NULL);
					}
				}
				g_cameraInstances.erase( g_cameraInstances.begin() + size );
			}
		}
		CDelete(m_cameraInstances[0]);
		m_cameraInstances.erase(m_cameraInstances.begin());
	}

	while(!m_cameras.empty())
	{
		CDelete( m_cameras[0] ); 
		m_cameras.erase(m_cameras.begin());
	}
	while(!m_controllers.empty())
	{
		CDelete( m_controllers[0] );
		m_controllers.erase(m_controllers.begin());
	}
	//Delete all the nodes
	CDelete( m_sceneRoot );
	m_nodes.clear();

	//Clear all the images
	//for( std::vector<CImage*>::iterator it = m_images.begin(); it != m_images.end(); it++ )
	//{
	//	CDelete( *it );
	//}
	//Clear the vector objects
	m_images.clear();

	//clear all the effects
	for( std::vector<CEffect*>::iterator it = m_effects.begin(); it != m_effects.end(); it++ )
	{
		CDelete( *it );
	}
	//Clear the vector objects
	m_effects.clear();

	for( std::vector<CMaterial*>::iterator it = m_materials.begin(); it != m_materials.end(); it++ )
	{
		CDelete( *it );
	}
	//Clear the vector objects
	m_materials.clear();

	for( std::vector<CAnimation*>::iterator it = m_animations.begin(); it != m_animations.end(); it++ )
	{
		CDelete( *it );
	}
	//Clear the vector objects
	m_animations.clear();

	for( std::vector<CAnimationClip*>::iterator it = m_animationClips.begin(); it != m_animationClips.end(); it++ )
	{
		CDelete( *it );
	}
	//Clear the vector objects
	m_animationClips.clear();
}