Пример #1
0
void AssimpApp::update()
{
	mAssimpLoader.enableTextures( mEnableTextures );
	mAssimpLoader.enableSkinning( mEnableSkinning );
	mAssimpLoader.enableAnimation( mEnableAnimation );

	double time = fmod( getElapsedSeconds(), mAssimpLoader.getAnimationDuration( 0 ) );
	mAssimpLoader.setTime( time );
	mAssimpLoader.update();

	mFps = getAverageFps();
}
void EpicMonsterApp::update()
{
	static int lastNodeIndex = -1;
    
	if ( mNodeIndex != lastNodeIndex )
	{
		setupParams();
		lastNodeIndex = mNodeIndex;
	}
    
	if ( !mNoBones )
	{
		mAssimpLoader.setNodeOrientation( mNodeNames[ mNodeIndex ],
                                         mNodeOrientations[ mNodeIndex ] );
        
        mAssimpLoader.setNodePosition( mNodeNames[ mNodeIndex ],
                                         mNodePositions[ mNodeIndex ] );
	}
    
	mAssimpLoader.update();
    
	mFps = getAverageFps();
    
    
    computeAttractorPosition();
    
    if (mStep) {
        
        gl::setMatricesWindow( mPPFbo.getSize(), false ); // false to prevent vertical flipping
        gl::setViewport( mPPFbo.getBounds() );
        
        mPPFbo.updateBind();
        
        mParticlesShader.bind();
        mParticlesShader.uniform( "positions", 0 );
        mParticlesShader.uniform( "velocities", 1 );
        mParticlesShader.uniform( "attractorPos", mAttractor);
        mParticlesShader.uniform( "fallDirection", mFallDirection);
        

        gl::drawSolidRect(mPPFbo.getBounds());
        mParticlesShader.unbind();
        
        
        mPPFbo.updateUnbind();
        mPPFbo.swap();
    }
    
    //else {
        flockToBody();
    //}
     
     
    
    while (listener.hasWaitingMessages()) {
		osc::Message message;
		listener.getNextMessage(&message);
		
		console() << "New message received" << std::endl;
		console() << "Address: " << message.getAddress() << std::endl;
        
        if(boneMap.find(message.getAddress()) != boneMap.end()) {
           string bone = boneMap.at(message.getAddress());
            
            Vec3f pos = Vec3f(message.getArgAsFloat(0), message.getArgAsFloat(1), message.getArgAsFloat(2));
            Quatf ori = Quatf(message.getArgAsFloat(3), message.getArgAsFloat(4), message.getArgAsFloat(5), message.getArgAsFloat(6));
            mAssimpLoader.setNodePosition(bone, pos*0.2);
            mAssimpLoader.setNodeOrientation(bone, ori);
        }
		
	}
}