Exemplo n.º 1
0
void XCCBReader::pause()
{
	CCBAnimationManager* mActionManager = getAnimationManager();
	mActionManager->getRootNode()->pauseSchedulerAndActions();

	CCDictionary* pDic = mActionManager->getNodeSequences();
	CCDictElement* pElement = NULL;
	CCDICT_FOREACH(pDic, pElement)
	{
		CCNode *node = (CCNode*)pElement->getIntKey();
		node->pauseSchedulerAndActions();
	}
Exemplo n.º 2
0
//--------------------------------------------------------------
void Surface::checkActivity(float dt)
{
	float now = ofGetElapsedTimeMillis();
	if (!m_isEnableStandby) return;
	
	
	if (m_stateActivity == EStandby_active)
	{
		if (getVolumePacketsHistoryMean() <= m_volumePacketsHistoryMeanTh_goStandby)
		{
			m_stateActivity = EStandby_pre_standby;
			m_timeStandby = 0.0f;
		}
	}
	else
	if (m_stateActivity == EStandby_pre_standby)
	{

		m_timeStandby+=dt;
		
		if (m_timeStandby >= m_durationPreStandby)
		{
			if (getVolumePacketsHistoryMean() >= m_volumePacketsHistoryMeanTh_goActive)
			{
				m_stateActivity = EStandby_active;
			}
			else
			{
				m_stateActivity = EStandby_standby;

				m_isLaunchPacket = true;
				m_timeLaunchPacket = now;
				m_durationLaunchPacket = ofRandom(0.25f,0.75f);
			}
		}
	}
	else
	if (m_stateActivity == EStandby_standby)
	{

		if (getVolumePacketsHistoryMean() >= m_volumePacketsHistoryMeanTh_goActive)
		{
			m_stateActivity = EStandby_active;
		}
		else
		{
			//printf("m_isLaunchPacket=%s\n", m_isLaunchPacket ? "true":"false");
		
		
			Animation* pAnimCurrent = getAnimationManager().mp_animationCurrent;
			if (pAnimCurrent && m_listDevices.size()>0)
			{
				Device* pDevice = m_listDevices[0];
				
				if (m_isLaunchPacket)
				{

					// Generate pulse (call directly)
					DevicePacket packet;
					packet.m_volume = ofRandom(1.0f)/* * pDevice->getSoundInputVolumeMax()*/;
					if (pAnimCurrent->m_name == "particlesMega2")
					{
						packet.m_volume = 0.2f;
					}
										
										
					pAnimCurrent->onNewPacket(&packet, pDevice->m_id, pDevice->m_pointSurface.x*m_fbo.getWidth(), pDevice->m_pointSurface.y*m_fbo.getHeight());
				
					if (now-m_timeLaunchPacket>=m_durationLaunchPacket*1000.0f){
						m_isLaunchPacket = false;
						m_durationNoLaunchPacket = ofRandom(8.0f,12.0f);
						m_timeLaunchPacket = now;
					}
				}
				else
				{
					// Generate pulse (call directly)
					DevicePacket packet;
					packet.m_volume = 0.0f;
					
					pAnimCurrent->onNewPacket(&packet, pDevice->m_id, pDevice->m_pointSurface.x*m_fbo.getWidth(), pDevice->m_pointSurface.y*m_fbo.getHeight());

					if (now-m_timeLaunchPacket>=m_durationNoLaunchPacket*1000.0f)
					{
						m_isLaunchPacket = true;
						m_durationLaunchPacket = ofRandom(0.25f,0.75f);
						m_timeLaunchPacket = now;
					}
				}
												
				
			}
		}
	}
	
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------------------
TestAnimation::TestAnimation()
{
    // On crée une camera
    m_pCamera = getSceneManager()->createCamera();
    m_pCamera->setEyePosition(QVector3D(2., 1., 2.));
    m_pCamera->setCenter(QVector3D(0., 0., 0.));


#ifdef SOFTWARE_RENDERING
    m_pView = createSoftwareView3D(m_pCamera);
#else
    m_pView = createWidget3D(m_pCamera);
#endif

    m_pCamera->setAspectRatio((real)m_pView->width() / (real)m_pView->height());

    // On charge le modéle
    CSceneNode* pRootNode = m_pSceneManager->getRootNode();

    CSceneNode* pModelNode = pRootNode->createChild("dwarf");

    // anim_test.x
    // rotatingcube.3ds
    // dwarf.x

    if (!CAssimpImporter::mergeScene("://dwarf.x", m_pSceneManager, true, pModelNode).isEmpty())
    {
        // On récupére la bounding box
        CBox3D bbox = pRootNode->getGlobalAxisAlignedBoundingBox();

        real sizeX = bbox.getMaximum().x() - bbox.getMinimum().x();
        real sizeY = bbox.getMaximum().y() - bbox.getMinimum().y();
        real sizeZ = bbox.getMaximum().z() - bbox.getMinimum().z();

        real maxSize = sizeX;
        if (sizeY > maxSize) maxSize = sizeY;
        if (sizeZ > maxSize) maxSize = sizeZ;

        // On redimensionne la scene de façon à ce qu'elle tienne dans une boite de 1x1x1
        pModelNode->scale(1. / maxSize);

        CBox3D scaledBbox = pModelNode->getGlobalAxisAlignedBoundingBox();

        // On la centre
        pModelNode->translate(-scaledBbox.getCenter());

        CSceneNode* pLightNode = pRootNode->createChild("LightNode", QVector3D(8.0, 12.0, 0));

        // On crée une lumiére diffuse blanche
        CLight* pLight = m_pSceneManager->createLight("Light");
        pLight->setDiffuseColor(0.8f, 0.8f, 0.8f);
        pLight->setAmbientColor(0.6f, 0.6f, 0.6f);
        pLight->setSpecularColor(0.4f, 0.4f, 0.4f);
        pLight->setDirection(QVector3D(-1, -1, 0));

        // On l'associe au noeud
        pLightNode->addItem(pLight);

        pRootNode->dumpNodeTree();
        //m_pSceneManager->setSceneGraphVisible(true);

        QList<CAnimation*> anims = m_pSceneManager->getAnimations();

        m_pView->setGeometry(QRect(100, 100, 400, 300));
        m_pView->getRenderer()->run();
        getAnimationManager()->run();

        if (anims.size() > 0)
        {
            QList<CSceneNodeAnimation*> nodeAnimations = anims[0]->getNodeAnimations();

            foreach (CSceneNodeAnimation* pNodeAnim, nodeAnimations)
            {
                pNodeAnim->setAnimationBehavior(eAnimationBehaviourRepeat);
            }