virtual void update(const UpdateEventPtr e)
    {
		if(!animationPaused)
		{
			osg::ElapsedTimeAnimationAdvancer::Ptr::dcast(TheAnimationAdvancer)->update(e->getElapsedTime());

			TheSkeletonAnimation->update(TheAnimationAdvancer);
		}	
    }
Esempio n. 2
0
    virtual void update(const UpdateEventPtr e)
    {
        Real32 RotateRate(1.0f);

        Matrix RotMat;
        RotMat.setRotate(Quaternion(Vec3f(0.0,1.0,0.0),RotateRate*e->getElapsedTime()));

        Matrix NewMat(RootTransformCore->getMatrix());
        NewMat.multLeft(RotMat);

        beginEditCP(RootTransformCore, Transform::MatrixFieldMask);
            RootTransformCore->setMatrix(NewMat);
        endEditCP(RootTransformCore, Transform::MatrixFieldMask);
    }
    virtual void update(const UpdateEventPtr e)
	{
		RubberCamera->update(e->getElapsedTime());


	   float TranslateAmount(1.0f);
	   float RotateAmount(1.0f);

		WindowEventProducerPtr TheEventProducer(WindowEventProducerPtr::dcast(e->getSource()));
		if(TheEventProducer->getKeyState(KeyEvent::KEY_LEFT) == KeyEvent::KEY_STATE_DOWN)
		{
		   Matrix TranslateTransform;
		   TranslateTransform.setTranslate(-TranslateAmount*e->getElapsedTime(),0.0f,0.0f);
		   Matrix NewTransform(BoxTransform->getMatrix());

		   NewTransform.mult(TranslateTransform);

		   beginEditCP(BoxTransform, Transform::MatrixFieldMask);
			   BoxTransform->setMatrix(NewTransform);
		   endEditCP(BoxTransform, Transform::MatrixFieldMask);
		}
		if(TheEventProducer->getKeyState(KeyEvent::KEY_RIGHT) == KeyEvent::KEY_STATE_DOWN)
	   {
		   Matrix TranslateTransform;
		   TranslateTransform.setTranslate(TranslateAmount*e->getElapsedTime(),0.0f,0.0f);
		   Matrix NewTransform(BoxTransform->getMatrix());

		   NewTransform.mult(TranslateTransform);

		   beginEditCP(BoxTransform, Transform::MatrixFieldMask);
			   BoxTransform->setMatrix(NewTransform);
		   endEditCP(BoxTransform, Transform::MatrixFieldMask);
	   }
		if(TheEventProducer->getKeyState(KeyEvent::KEY_UP) == KeyEvent::KEY_STATE_DOWN)
	   {
		   Matrix TranslateTransform;
		   TranslateTransform.setTranslate(0.0f,0.0f,-TranslateAmount*e->getElapsedTime());
		   Matrix NewTransform(BoxTransform->getMatrix());

		   NewTransform.mult(TranslateTransform);

		   beginEditCP(BoxTransform, Transform::MatrixFieldMask);
			   BoxTransform->setMatrix(NewTransform);
		   endEditCP(BoxTransform, Transform::MatrixFieldMask);
	   }
		if(TheEventProducer->getKeyState(KeyEvent::KEY_DOWN) == KeyEvent::KEY_STATE_DOWN)
	   {
		   Matrix TranslateTransform;
		   TranslateTransform.setTranslate(0.0f,0.0f,TranslateAmount*e->getElapsedTime());
		   Matrix NewTransform(BoxTransform->getMatrix());

		   NewTransform.mult(TranslateTransform);

		   beginEditCP(BoxTransform, Transform::MatrixFieldMask);
			   BoxTransform->setMatrix(NewTransform);
		   endEditCP(BoxTransform, Transform::MatrixFieldMask);
	   }
		if(TheEventProducer->getKeyState(KeyEvent::KEY_A) == KeyEvent::KEY_STATE_DOWN)
	   {
		   Matrix TranslateTransform;
		   //TranslateTransform.setTranslate(-TranslateAmount,0.0f,0.0f);
		   TranslateTransform.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), -RotateAmount*e->getElapsedTime()));
		   Matrix NewTransform(BoxTransform->getMatrix());

		   NewTransform.mult(TranslateTransform);

		   beginEditCP(BoxTransform, Transform::MatrixFieldMask);
			   BoxTransform->setMatrix(NewTransform);
		   endEditCP(BoxTransform, Transform::MatrixFieldMask);
	   }
		if(TheEventProducer->getKeyState(KeyEvent::KEY_D) == KeyEvent::KEY_STATE_DOWN)
	   {
		   Matrix TranslateTransform;
		   //TranslateTransform.setTranslate(TranslateAmount,0.0f,0.0f);
		   TranslateTransform.setRotate(Quaternion(Vec3f(0.0f,1.0f,0.0f), RotateAmount*e->getElapsedTime()));
		   Matrix NewTransform(BoxTransform->getMatrix());

		   NewTransform.mult(TranslateTransform);

		   beginEditCP(BoxTransform, Transform::MatrixFieldMask);
			   BoxTransform->setMatrix(NewTransform);
		   endEditCP(BoxTransform, Transform::MatrixFieldMask);
	   }
	}
    virtual void update(const UpdateEventPtr e)
    {
		ElapsedTimeAnimationAdvancer::Ptr::dcast(TheAnimationAdvancer)->update(e->getElapsedTime());
		//if (animated)
		 TheAnimation->update(TheAnimationAdvancer);
    }