コード例 #1
0
ファイル: CCEChannel.cpp プロジェクト: Ratel13/cocoseditor
cocos2d::FiniteTimeAction* cce::CCEChannel::getNormalActions(){
		
		int frameCount = this->keyframes.size();

		Vector<FiniteTimeAction *> cSequenceArray;

        for (int i = 0; i < frameCount; i++) {
            auto frame = this->keyframes.at(i);
            if (i == 0) {
                float duration = (frame->getFrameIndex()) * getUnitTime();
                FiniteTimeAction *cAction = frame->getAction(type,duration,NULL);
				if (cAction != nullptr){
                    cSequenceArray.pushBack((cAction));
				}else{
					log("Invalid key from %s ",type.c_str());
				}
            }
            else {
                auto srcFrame = this->keyframes.at(i - 1);
                float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime();
                FiniteTimeAction *cAction = frame->getAction(type,duration,srcFrame);
				if (cAction != nullptr){
                    cSequenceArray.pushBack((cAction));
				}else{
					log("Invalid key from %s ",type.c_str());
				}
            }
        }

		cSequenceArray.pushBack(ChannelEndAction::create(this));
		log("cSequenceArray action size %d",cSequenceArray.size());
        return  Sequence::create(cSequenceArray);
}
コード例 #2
0
ファイル: CCActionNode.cpp プロジェクト: RyunosukeOno/rayjack
Spawn * ActionNode::refreshActionProperty()
{
    if ( _object == nullptr )
    {
        return nullptr;
    }
    Vector<FiniteTimeAction*> cSpawnArray;

    for (int n = 0; n < _frameArrayNum; n++)
    {
        auto cArray = _frameArray.at(n);
        if (cArray->size() <= 0)
        {
            continue;
        }

        Vector<FiniteTimeAction*> cSequenceArray;
        auto frameCount = cArray->size();
        for (int i = 0; i < frameCount; i++)
        {
            auto frame = cArray->at(i);
            if (i == 0)
            {
            }
            else
            {
                auto srcFrame = cArray->at(i-1);
                float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime();
                Action* cAction = frame->getAction(duration);
                if(cAction != nullptr)
                cSequenceArray.pushBack(static_cast<FiniteTimeAction*>(cAction));
            }
        }
        Sequence* cSequence = Sequence::create(cSequenceArray);
        if (cSequence != nullptr)
        {
            cSpawnArray.pushBack(cSequence);
        }
    }

    if (_action == nullptr)
    {
    CC_SAFE_RELEASE_NULL(_actionSpawn);
    }
    else
    {
    CC_SAFE_RELEASE_NULL(_action);
    CC_SAFE_RELEASE_NULL(_actionSpawn);
    }

    _actionSpawn = Spawn::create(cSpawnArray);
    CC_SAFE_RETAIN(_actionSpawn);
    return _actionSpawn;
}
コード例 #3
0
Transform DynamicsComputations::getRelativeTransform(const std::string& refFrameName,
                                                     const std::string& frameName)
{
    int refFrameIndex = getFrameIndex(refFrameName);
    int frameIndex = getFrameIndex(frameName);
    if( frameIndex < 0 || refFrameIndex < 0)
    {
        return Transform::Identity();
    }
    else
    {
        return this->getRelativeTransform(refFrameIndex,frameIndex);
    }
}
コード例 #4
0
ファイル: CCActionNode.cpp プロジェクト: 6520874/pipiGame
bool ActionNode::updateActionToTimeLine(float fTime)
{
	bool bFindFrame = false;

	ActionFrame* srcFrame = nullptr;
	//	ActionFrame* destFrame = nullptr;

	for (int n = 0; n < _frameArrayNum; n++)
	{
		auto cArray = _frameArray.at(n);
		if (cArray->empty())
		{
			continue;
		}
		ssize_t frameCount = cArray->size();
		for (int i = 0; i < frameCount; i++)
		{
			auto frame = cArray->at(i);

			if (frame->getFrameIndex()*getUnitTime() == fTime)
			{
				this->easingToFrame(1.0f,1.0f,nullptr,frame);
				bFindFrame = true;
				break;
			}
			else if (frame->getFrameIndex()*getUnitTime() > fTime)
			{
				if (i == 0)
				{
					this->easingToFrame(1.0f,1.0f,nullptr,frame);
					bFindFrame = false;
				}
				else
				{
					srcFrame = cArray->at(i-1);
					float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex())*getUnitTime();
					float delaytime = fTime - srcFrame->getFrameIndex()*getUnitTime();
					this->easingToFrame(duration,1.0f,nullptr,srcFrame);
					//float easingTime = ActionFrameEasing::bounceTime(delaytime);
					this->easingToFrame(duration,delaytime/duration,srcFrame,frame);
					bFindFrame = true;
				}
				break;
			}
		}
	}
	return bFindFrame;
}
コード例 #5
0
int ActionNode::getLastFrameIndex()
{
    int frameindex = -1;
    bool bFindFrame = false;
    for (int n = 0; n < _frameArrayNum; n++)
    {
        auto cArray = _frameArray.at(n);
        if (cArray->empty())
        {
            continue;
        }
        bFindFrame = true;
        ssize_t lastInex = cArray->size() - 1;
        auto frame = cArray->at(lastInex);
        int iFrameIndex = frame->getFrameIndex();

        if (frameindex < iFrameIndex)
        {
            frameindex = iFrameIndex;
        }
    }
    if (!bFindFrame)
    {
        frameindex = 0;
    }
    return frameindex;
}
コード例 #6
0
int ActionNode::getFirstFrameIndex()
{
    int frameindex = 99999;
    bool bFindFrame = false;
    for (int n = 0; n < _frameArrayNum; n++)
    {
        auto cArray = _frameArray.at(n);
        if (cArray->empty())
        {
            continue;
        }
        bFindFrame = true;
        auto frame = cArray->at(0);
        int iFrameIndex = frame->getFrameIndex();

        if (frameindex > iFrameIndex)
        {
            frameindex = iFrameIndex;
        }
    }
    if (!bFindFrame)
    {
        frameindex = 0;
    }
    return frameindex;
}
コード例 #7
0
ファイル: videoIO.cpp プロジェクト: if1live/gotoamc
VideoIO::~VideoIO()
{
	//close output video
	if(outSize != -1)
	{
		//get the delayed frames
		for(int i = getFrameIndex() ; outSize ; i++)
		{
			fflush(stdout);
			outSize = avcodec_encode_video(pOutputCodecCtx, pOutBuffer, outBufferSize, NULL);
			printf("[VideoIO] write frame : %3d (size=%5d)\n", i, outSize);
			fwrite(pOutBuffer, 1, outSize, pOutputFile);
		}
		
		//add sequence end code to have a real mpeg file
		pOutBuffer[0] = 0x00;
		pOutBuffer[1] = 0x00;
		pOutBuffer[2] = 0x01;
		pOutBuffer[3] = 0xb7;
		fwrite(pOutBuffer, 1, 4, pOutputFile);
	}

	//free the rgb image
	if(pInputFrame != NULL)
		av_free(pInputFrame);

	if(pOutputFrame != NULL)
	{
		free(pOutputFrame->data[0]);
		av_free(pOutputFrame);
	}

	//close the codec
	if(pOutputCodecCtx != NULL)
	{
		avcodec_close(pOutputCodecCtx);
		av_free(pOutputCodecCtx);
		fclose(pOutputFile);		//output video
	}

	if(pInputCodecCtx != NULL)
	{
		avcodec_close(pInputCodecCtx);
	}
	
	//close input video
	if(pFormatCtx != NULL)
	{
		av_close_input_file(pFormatCtx);
	}
	
	if(pOutBuffer != NULL)
		free(pOutBuffer);
}
コード例 #8
0
Transform DynamicsComputations::getWorldTransform(std::string frameName)
{
    int frameIndex = getFrameIndex(frameName);
    if( frameIndex < 0 )
    {
        return Transform::Identity();
    }
    else
    {
        return getWorldTransform(frameIndex);
    }
}
コード例 #9
0
uint32 KmScene2101::hmHitByDoor(int messageNum, const MessageParam &param, Entity *sender) {
	uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
	int16 speedUpFrameIndex;
	switch (messageNum) {
	case 0x1008:
		speedUpFrameIndex = getFrameIndex(kKlaymenSpeedUpHash);
		if (_currFrameIndex < speedUpFrameIndex) {
			startAnimation(0x35AA8059, speedUpFrameIndex, -1);
			_y = 438;
		}
		messageResult = 0;
		break;
	case NM_ANIMATION_START:
		if (param.asInteger() == 0x1A1A0785) {
			playSound(0, 0x40F0A342);
		} else if (param.asInteger() == 0x60428026) {
			playSound(0, 0x40608A59);
		}
		break;
	}
	return messageResult;
}
コード例 #10
0
ファイル: Video.cpp プロジェクト: bmagyar/hog3d
bool Video::seek(FrameIndex frame)
{
	if (frame - getFrameIndex() == 1)
		return nextFrame();
	return seek(frame * _invFrameRate);
}
コード例 #11
0
ファイル: CCActionNode.cpp プロジェクト: hugohuang1111/Bird
Spawn * ActionNode::refreshActionProperty()
{
    if ( _object == nullptr )
    {
        return nullptr;
    }
    Vector<FiniteTimeAction*> cSpawnArray;

    for (int n = 0; n < _frameArrayNum; n++)
    {
        auto cArray = _frameArray.at(n);
        if (cArray->size() <= 0)
        {
            continue;
        }

        Vector<FiniteTimeAction*> cSequenceArray;
        auto frameCount = cArray->size();
		if(frameCount > 1)
 		{ 
 			for (int i = 0; i < frameCount; i++)
 			{
 				auto frame = cArray->at(i);
 				if (i == 0)
 				{
// #11173 Fixed every node of UI animation(json) is starting at frame 0.                     
//                  if (frame->getFrameIndex() > 0)
//				    {
//					    DelayTime* cDelayTime = DelayTime::create(frame->getFrameIndex() * getUnitTime());
//					    if (cDelayTime != nullptr)
//						    cSequenceArray.pushBack(static_cast<FiniteTimeAction*>(cDelayTime));
//				    }
 				}
 				else
 				{
 					auto srcFrame = cArray->at(i-1);
 					float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime();
 					Action* cAction = frame->getAction(duration);
 					if(cAction != nullptr)
 					cSequenceArray.pushBack(static_cast<FiniteTimeAction*>(cAction));
 				}
 			}
 		}
 		else if (frameCount == 1)
 		{
 			auto frame = cArray->at(0);
 			float duration = 0.0f;
 			Action* cAction = frame->getAction(duration);
 			if (cAction != nullptr)
 				cSequenceArray.pushBack(static_cast<FiniteTimeAction*>(cAction));
 		}
 		Sequence* cSequence = Sequence::create(cSequenceArray);
 		if (cSequence != nullptr)
 		{
 			cSpawnArray.pushBack(cSequence);
 		}
    }

    if (_action == nullptr)
    {
    CC_SAFE_RELEASE_NULL(_actionSpawn);
    }
    else
    {
    CC_SAFE_RELEASE_NULL(_action);
    CC_SAFE_RELEASE_NULL(_actionSpawn);
    }

    _actionSpawn = Spawn::create(cSpawnArray);
    CC_SAFE_RETAIN(_actionSpawn);
    return _actionSpawn;
}
コード例 #12
0
ファイル: Model.cpp プロジェクト: PerryZh/idyntree
bool Model::isFrameNameUsed(const std::string frameName)
{
    return (FRAME_INVALID_INDEX != getFrameIndex(frameName));
}