コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_SceneEntity::ResetActorFlexesForScene()
{
	int nActorCount = m_pScene->GetNumActors();
	for( int iActor = 0; iActor < nActorCount; ++iActor )
	{
		CChoreoActor *pChoreoActor = m_pScene->GetActor( iActor );
		if ( !pChoreoActor )
			continue;

		C_BaseFlex *pFlexActor = FindNamedActor( pChoreoActor );
		if ( !pFlexActor )
			continue;

		CStudioHdr *pStudioHdr = pFlexActor->GetModelPtr();
		if ( !pStudioHdr )
			continue;

		if ( pStudioHdr->numflexdesc() == 0 )
			continue;

		// Reset the flex weights to their starting position.
		LocalFlexController_t iController;
		for ( iController = LocalFlexController_t(0); iController < pStudioHdr->numflexcontrollers(); ++iController )
		{
			pFlexActor->SetFlexWeight( iController, 0.0f );
		}

		// Reset the prediction interpolation values.
		pFlexActor->m_iv_flexWeight.Reset();
	}
}
コード例 #2
0
ファイル: LabScaleImpacts.cpp プロジェクト: nmovshov/ARSS_win
void labscale::CreateTiltBoxExperiment()
/* Tilt the box back and forth to smooth regolith layer*/
{
    // Put a box on the floor
    if (gRun.loadSceneFromFile.empty())
        CreateRegolithContainer();
    else
    {
        if(!LoadSceneFromFile(gRun.loadSceneFromFile)) ncc__error("Failed to load partially filed box.\a\n");
        PxActor* theBox = FindNamedActor("the_box");
        if (theBox)
        {
            ColorActor(theBox,ncc::rgb::rRed);
            labscale::VIPs.container = theBox->isRigidDynamic();
        }
    }

    // Adjust camera, grid, display
    gCamera.pos.x = 0.0;
    gCamera.pos.y = labscale::reg_box.fillHeight*1.4;
    gCamera.pos.z = labscale::reg_box.diameter*1.6;
    gDebug.bXYGridOn = true;

    // Start the action, tilt action handled in control function
    labscale::reg_box.bTilt = false;
    gSim.isRunning=true;
    gSim.bPause=false;
    gSim.codeTime = 0.0f;
    RefreshHUD();
}
コード例 #3
0
ファイル: LabScaleImpacts.cpp プロジェクト: nmovshov/ARSS_win
void labscale::CreateFillBoxExperiment()
/* Put a box on the ground ready to be filled with regolith.*/
{
    // Put a box on the floor
    if (gRun.loadSceneFromFile.empty())
        CreateRegolithContainer();
    else
    {
        if(!LoadSceneFromFile(gRun.loadSceneFromFile)) ncc__error("Failed to load partially filed box.\a\n");
        PxActor* theBox = FindNamedActor("the_box");
        if (theBox)
        {
            ColorActor(theBox,ncc::rgb::rRed);
            labscale::VIPs.container = theBox->isRigidDynamic();
        }
    }

    // Adjust camera, grid, display
    gCamera.pos.x = 0.0;
    gCamera.pos.y = labscale::reg_box.fillHeight*1.4;
    gCamera.pos.z = labscale::reg_box.diameter*1.6;
    gDebug.bXYGridOn = true;
    
    // Start the action, regolith poured in runtime
    gSim.isRunning=true;
    gSim.bPause=false;
    gSim.codeTime = 0.0f;
    RefreshHUD();

}
コード例 #4
0
//-----------------------------------------------------------------------------
// Purpose: Called every frame that an event is active (Start/EndEvent as also
//  called)
// Input  : *event - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void C_SceneEntity::ProcessEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event )
{
	// For now we only need to process events if we go back in time.
	if ( currenttime < event->m_flPrevTime )
	{
		//if ( !V_strstr( scene->GetFilename(), "idleloop" ) )
		//{
		//	Msg( "ProcessEvent( %6.4f, %32s %6.4f )    %6.4f\n", currenttime, event->GetName(), event->m_flPrevTime, m_flCurrentTime );
		//}

		C_BaseFlex *pActor = NULL;
		CChoreoActor *actor = event->GetActor();
		if ( actor )
		{
			pActor = FindNamedActor( actor );
			if ( NULL == pActor )
			{
				// TODO: QueueProcessEvent
				// This can occur if we haven't been networked an actor yet... we need to queue it so that we can 
				//  fire off the process event as soon as we have the actor resident on the client.
				return;
			}
		}

		switch ( event->GetType() )
		{
		case CChoreoEvent::GESTURE:
			{
				// Verify data.
				Assert( m_bMultiplayer );
				Assert( scene != NULL );
				Assert( event != NULL );

				if ( pActor )
				{
					DispatchProcessGesture( scene, pActor, event );
				}
			}
			break;
		case CChoreoEvent::SEQUENCE:
			{
				// Verify data.
				Assert( m_bMultiplayer );
				Assert( scene != NULL );
				Assert( event != NULL );

				if ( pActor )
				{
					DispatchProcessSequence( scene, pActor, event );
				}
			}
			break;
		}
	}

	event->m_flPrevTime = currenttime;
}
コード例 #5
0
ファイル: c_sceneentity.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// Purpose: All events are leading edge triggered
// Input  : currenttime - 
//			*event - 
//-----------------------------------------------------------------------------
void C_SceneEntity::StartEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event )
{
	Assert( event );

	if ( !Q_stricmp( event->GetName(), "NULL" ) )
 	{
 		Scene_Printf( "%s : %8.2f:  ignored %s\n", GetSceneFileName(), currenttime, event->GetDescription() );
 		return;
 	}
 

	C_BaseFlex *pActor = NULL;
	CChoreoActor *actor = event->GetActor();
	if ( actor )
	{
		pActor = FindNamedActor( actor );
		if ( NULL == pActor )
		{
			// This can occur if we haven't been networked an actor yet... we need to queue it so that we can 
			//  fire off the start event as soon as we have the actor resident on the client.
			QueueStartEvent( currenttime, scene, event );
			return;
		}
	}

	Scene_Printf( "%s : %8.2f:  start %s\n", GetSceneFileName(), currenttime, event->GetDescription() );

	switch ( event->GetType() )
	{
	case CChoreoEvent::FLEXANIMATION:
		{
			if ( pActor )
			{
				DispatchStartFlexAnimation( scene, pActor, event );
			}
		}
		break;
	case CChoreoEvent::EXPRESSION:
		{
			if ( pActor )
			{
				DispatchStartExpression( scene, pActor, event );
			}
		}
		break;
	default:
		break;
	}
}
コード例 #6
0
ファイル: c_sceneentity.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_SceneEntity::UnloadScene( void )
{
	WipeQueuedEvents();

	if ( m_pScene )
	{
		ClearSceneEvents( m_pScene, false );
		for ( int i = 0 ; i < m_pScene->GetNumActors(); i++ )
		{
			C_BaseFlex *pTestActor = FindNamedActor( m_pScene->GetActor( i ) );

			if ( !pTestActor )
				continue;
		
			pTestActor->RemoveChoreoScene( m_pScene );
		}
	}
	delete m_pScene;
	m_pScene = NULL;
}
コード例 #7
0
ファイル: c_sceneentity.cpp プロジェクト: Bubbasacs/FinalProj
void C_SceneEntity::ClearSceneEvents( CChoreoScene *scene, bool canceled )
{
	if ( !m_pScene )
		return;

	Scene_Printf( "%s : %8.2f:  clearing events\n", GetSceneFileName(), m_flCurrentTime );

	int i;
	for ( i = 0 ; i < m_pScene->GetNumActors(); i++ )
	{
		C_BaseFlex *pActor = FindNamedActor( m_pScene->GetActor( i ) );
		if ( !pActor )
			continue;

		// Clear any existing expressions
		pActor->ClearSceneEvents( scene, canceled );
	}

	WipeQueuedEvents();
}
コード例 #8
0
ファイル: c_sceneentity.cpp プロジェクト: Bubbasacs/FinalProj
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : currenttime - 
//			*event - 
//-----------------------------------------------------------------------------
void C_SceneEntity::EndEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event )
{
	Assert( event );

	if ( !Q_stricmp( event->GetName(), "NULL" ) )
 	{
 		return;
 	}

	C_BaseFlex *pActor = NULL;
	CChoreoActor *actor = event->GetActor();
	if ( actor )
	{
		pActor = FindNamedActor( actor );
	}

	Scene_Printf( "%s : %8.2f:  finish %s\n", GetSceneFileName(), currenttime, event->GetDescription() );

	switch ( event->GetType() )
	{
	case CChoreoEvent::FLEXANIMATION:
		{
			if ( pActor )
			{
				DispatchEndFlexAnimation( scene, pActor, event );
			}
		}
		break;
	case CChoreoEvent::EXPRESSION:
		{
			if ( pActor )
			{
				DispatchEndExpression( scene, pActor, event );
			}
		}
		break;
	default:
		break;
	}
}
コード例 #9
0
//-----------------------------------------------------------------------------
// Purpose: All events are leading edge triggered
// Input  : currenttime - 
//			*event - 
//-----------------------------------------------------------------------------
void C_SceneEntity::StartEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event )
{
	Assert( event );

	if ( !Q_stricmp( event->GetName(), "NULL" ) )
 	{
 		Scene_Printf( "%s : %8.2f:  ignored %s\n", GetSceneFileName(), currenttime, event->GetDescription() );
 		return;
 	}
 

	C_BaseFlex *pActor = NULL;
	CChoreoActor *actor = event->GetActor();
	if ( actor )
	{
		pActor = FindNamedActor( actor );
		if ( NULL == pActor )
		{
			// This can occur if we haven't been networked an actor yet... we need to queue it so that we can 
			//  fire off the start event as soon as we have the actor resident on the client.
			QueueStartEvent( currenttime, scene, event );
			return;
		}
	}

	Scene_Printf( "%s : %8.2f:  start %s\n", GetSceneFileName(), currenttime, event->GetDescription() );

	switch ( event->GetType() )
	{
	case CChoreoEvent::FLEXANIMATION:
		{
			if ( pActor )
			{
				DispatchStartFlexAnimation( scene, pActor, event );
			}
		}
		break;
	case CChoreoEvent::EXPRESSION:
		{
			if ( pActor )
			{
				DispatchStartExpression( scene, pActor, event );
			}
		}
		break;
	case CChoreoEvent::GESTURE:
		{
			// Verify data.
			Assert( m_bMultiplayer );
			Assert( scene != NULL );
			Assert( event != NULL );

			if ( pActor )
			{
				DispatchStartGesture( scene, pActor, event );
			}
		}
		break;
	case CChoreoEvent::SEQUENCE:
		{
			// Verify data.
			Assert( m_bMultiplayer );
			Assert( scene != NULL );
			Assert( event != NULL );

			if ( pActor )
			{
				DispatchStartSequence( scene, pActor, event );
			}
		}
		break;
	case CChoreoEvent::LOOP:
		{
			// Verify data.
			Assert( m_bMultiplayer );
			Assert( scene != NULL );
			Assert( event != NULL );

			DispatchProcessLoop( scene, event );
		}
	case CChoreoEvent::SPEAK:
		{
			if ( IsClientOnly() && pActor )
			{
				// FIXME: dB hack.  soundlevel needs to be moved into inside of wav?
				soundlevel_t iSoundlevel = SNDLVL_TALKING;
				if ( event->GetParameters2() )
				{
					iSoundlevel = (soundlevel_t)atoi( event->GetParameters2() );
					if ( iSoundlevel == SNDLVL_NONE )
					{
						iSoundlevel = SNDLVL_TALKING;
					}
				}

				DispatchStartSpeak( scene, pActor, event, iSoundlevel );
			}
		}
		break;
	default:
		break;
	}

	event->m_flPrevTime = currenttime;
}
コード例 #10
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_SceneEntity::PrefetchAnimBlocks( CChoreoScene *pScene )
{
	if (!CommandLine()->FindParm("-hushasserts"))
	{
		Assert( pScene && m_bMultiplayer );
	}
	if ( !pScene || !m_bMultiplayer )
		return;

	// Build a fast lookup, too
	CUtlMap<CChoreoActor*,CBaseFlex*> actorMap( 0, 0, DefLessFunc( CChoreoActor* ) );

	int nSpew = 0;
	int nResident = 0;
	int nChecked = 0;

	// Iterate events and precache necessary resources
	for ( int i = 0; i < pScene->GetNumEvents(); i++ )
	{
		CChoreoEvent *pEvent = pScene->GetEvent( i );
		if ( !pEvent )
			continue;

		// load any necessary data
		switch ( pEvent->GetType() )
		{
		default:
			break;
		case CChoreoEvent::SEQUENCE:
		case CChoreoEvent::GESTURE:
			{
				CChoreoActor *pActor = pEvent->GetActor();
				if ( pActor )
				{
					CBaseFlex *pFlex = NULL;
					int idx = actorMap.Find( pActor );
					if ( idx == actorMap.InvalidIndex() )
					{
						pFlex = FindNamedActor( pActor );
						idx = actorMap.Insert( pActor, pFlex );
					}
					else
					{
						pFlex = actorMap[ idx ];
					}

					if ( pFlex )
					{
						int iSequence = pFlex->LookupSequence( pEvent->GetParameters() );
						if ( iSequence >= 0 )
						{
							CStudioHdr *pStudioHdr = pFlex->GetModelPtr();
							if ( pStudioHdr )
							{
								// Now look up the animblock
								mstudioseqdesc_t &seqdesc = pStudioHdr->pSeqdesc( iSequence );
								for ( int i = 0 ; i < seqdesc.groupsize[ 0 ] ; ++i )
								{
									for ( int j = 0; j < seqdesc.groupsize[ 1 ]; ++j )
									{
										int iAnimation = seqdesc.anim( i, j );
										int iBaseAnimation = pStudioHdr->iRelativeAnim( iSequence, iAnimation );
										mstudioanimdesc_t &animdesc = pStudioHdr->pAnimdesc( iBaseAnimation );

										++nChecked;

										if ( nSpew != 0 )
										{
											Msg( "%s checking block %d\n", pStudioHdr->pszName(), animdesc.animblock );
										}

										// Async load the animation
										int iFrame = 0;
										const mstudioanim_t *panim = animdesc.pAnim( &iFrame );
										if ( panim )
										{
											++nResident;
											if ( nSpew > 1 )
											{
												Msg( "%s:%s[%i:%i] was resident\n", pStudioHdr->pszName(), animdesc.pszName(), i, j );
											}
										}
										else
										{
											if ( nSpew != 0 )
											{
												Msg( "%s:%s[%i:%i] async load\n", pStudioHdr->pszName(), animdesc.pszName(), i, j );
											}
										}
									}
								}
							}
						}
					}
				}
				break;
			}
		}
	}

	if ( !nSpew || nChecked <= 0 )
		return;

	Msg( "%d of %d animations resident\n", nResident, nChecked );
}
コード例 #11
0
ファイル: LabScaleImpacts.cpp プロジェクト: nmovshov/ARSS_win
// Project namespace functions
void labscale::CreatePenetratorExperiment()
/* Throw a steel ball at glass regolith; measure penetration depth.*/
{
    // Load pre-settled regolith or create empty container
    if (gRun.loadSceneFromFile.empty())
        labscale::CreateRegolithContainer();
    else
    {
        if(!LoadSceneFromFile(gRun.loadSceneFromFile)) ncc__error("Failed to load partially filed box.\a\n");
        PxActor* theBox = FindNamedActor("the_box");
        if (theBox)
        {
            ColorActor(theBox, ncc::rgb::rRed);
            labscale::VIPs.container = theBox->isRigidDynamic();
        }
    }

    // Create impactor material (steel, for now)
    PxMaterial* steel = gPhysX.mPhysics->createMaterial(0.5, 0.5, 0.5);
    if (!steel)
        ncc__error("\aPxPhysics::createMaterial() failed!");
    PxReal rho = labscale::impactor.materialDensity;

    // Ready, aim impactor (will fire manually)
    PxReal radius = labscale::impactor.diameter/2;
    labscale::impactor.iniSurface = getRegolithSurface(); // target surface in global frame
    PxReal hLaunch = labscale::impactor.iniSurface + 4*radius;
    labscale::VIPs.ball1 = CreateRubbleGrain(PxVec3(0,hLaunch,0),eSPHERE_GRAIN,radius,*steel,rho);
    labscale::VIPs.ball1->setName("impactor");
    labscale::VIPs.ball1->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true);
    ColorActor(labscale::VIPs.ball1, ncc::rgb::gDarkOlive);

    // Adjust camera, grid, display
    gCamera.pos.x = 0.0;
    gCamera.pos.y = labscale::reg_box.fillHeight*1.4;
    gCamera.pos.z = labscale::reg_box.diameter*1.6;
    gDebug.bXYGridOn = true;

    // Start a log
    if (gRun.outputFrequency)
    {
        ostringstream header;
        header << "# This is the run log of " << gRun.baseName << endl;
        header << "# Experiment type: HOLSAPPLE1 (" << labscale::eExperimentType << ")" << endl;
        header << "# Time step used = " << gSim.timeStep << endl;
        header << "# Top of regolith surface = " << labscale::impactor.iniSurface << endl;
        header << "# Impactor launch speed = " << labscale::impactor.speed << endl;
        header << "# Columns are (values in code units, d is penetration depth):" << endl;
        header << "# [t]    [v_y]    [d]    [x]    [y]    [z]" << endl;
        ofstream fbuf(gRun.outFile.c_str(),ios::trunc);
        if (!fbuf.is_open())
            ncc__error("Could not start a log. Experiment aborted.\a\n");
        fbuf << header.str() << endl;
    }

    // Start the action
    gSim.isRunning=true;
    gSim.bPause=false;
    gSim.codeTime = 0.0f;
    RefreshHUD();
}