Beispiel #1
0
int GetMatrix(struct AnimationList *al, char* name, float time,
   float m[4][4])
{
   int x, y;
   void* a = FindAnimation(name, al);
   Animation* anim = (Animation*) a;

   if(a)
   {
      _GetMatrix(anim, time, m);
      return TRUE;
   }
   
   /* Otherwise, return identity matrix. */
   for(x = 0; x < 4; x++)
   {
      for(y = 0; y < 4; y++)
      {
         if(x == y)
         {
            m[x][y] = 1.0;
         }
         else
         {
            m[x][y] = 0.0;
         }
      }
   }
   return FALSE;
}
void CTestContainer::ShowAnimationL(TAnimationFlag aAnimationType)
	{
	TInt index = FindAnimation(aAnimationType);
	if (index == KErrNotFound)
		return;
	else
		StartAnimationL(index);
	}
bool ExportScene::AddAnimation( ExportAnimation* pAnimation )
{
    if( !pAnimation )
        return false;
    if( FindAnimation( pAnimation->GetName() ) )
        return false;
    m_vAnimations.push_back( pAnimation );
    return true;
}
Beispiel #4
0
bool Animator::SwitchAnimation(std::string const& name)
{
	auto animation = FindAnimation(name);
	if (animation != nullptr)
	{
		SwitchAnimation(animation);
		return true;
	}

	return false;
}
Beispiel #5
0
/*----------------------------------------------------------------------
  GetScale()
  Purpose: gets the scale of an animated object with a certain name
  In parameters:
    al   - the linked list of Animations
    name - the name of the Animation
    time - the time of the wanted scale
  Out parameters:
    Sout  - the scale in the x-, y-, and z-directions at time 
  Returns:
    TRUE if there was a scale with "name", else FALSE (and the
    scale is then (1,1,1)
  Note: this routine does not check if the object is visible or not.
----------------------------------------------------------------------*/
int GetScale(Stack<Animation*> *al,char* name, double time, double Sout[3])
{
   Animation* a = FindAnimation(name,al);
   if(a) 
   {
      _GetScale(a, time, Sout);
      return TRUE;
   }
   Sout[0]=Sout[1]=Sout[2]=1.0;
   return FALSE;
}
Beispiel #6
0
/*----------------------------------------------------------------------
  GetTranslation()
  Purpose: gets the translation of an animated object with a certain name
  In parameters:
    al   - the linked list of Animations
    name - the name of the Animation
    time - the time of the wanted translation
  Out parameters:
    Tout  - the translation at time 
  Returns:
    TRUE if there was a translation with "name", else FALSE (and the
    translation is (0,0,0)
  Note: this routine does not check if the object is visible or not.
----------------------------------------------------------------------*/
int GetTranslation(Stack<Animation*> *al,char* name, double time, double Tout[3])
{
   Animation * a = FindAnimation(name,al);
   if(a)
   {
      _GetTranslation(a, time, Tout);
      return TRUE;
   }
   Tout[0]=Tout[1]=Tout[2]=0.0;
   return FALSE;
}
Beispiel #7
0
/*----------------------------------------------------------------------
  GetRotation()
  Purpose: gets the rotation of an animated object with a certain name
  In parameters:
    al   - the linked list of Animations
    name - the name of the Animation
    time - the time of the wanted rotation
  Out parameters:
    Rout  - the rotation at time. (Rout[0],Rout[1],Rout[2]) is the 
            rotation axis, and Rout[3] is the rotation angle (in radians)
            about that axis
  Returns:
    TRUE if there was a rotation with "name", else FALSE (and the
    axis is (1,0,0) and the angle is 0.0
  Note: this routine does not check if the object is visible or not.
----------------------------------------------------------------------*/
int GetRotation(Stack<Animation*> *al,char* name, double time, double Rout[4])
{
  Animation* a = FindAnimation(name,al);
  if(a)
  {
     _GetRotation(a, time, Rout);
     return TRUE;
  }
  Rout[0]=1.0; Rout[1]=0.0; Rout[2]=0.0; Rout[3]=0.0;
  return FALSE;
}
// Remove animation resource
bool ResourceManager::RemoveAnimation(const GTString& name)
{
	GTString keyName = name;
	keyName.ToLower();
	GSpriteAnimationCocos2dx* pAnimation = FindAnimation(keyName);
	if(pAnimation)
	{
		m_ResAnimationList.Remove(keyName.ToCharString());
		return true;
	}
	return false;
}
Beispiel #9
0
int GetVisibility(struct AnimationList *al, char *name, double time)
{
   void* a = FindAnimation(name, al);
   Animation* anim = (Animation*) a;
   
   if(a)
   {
      return _GetVisibility(anim, time);
   }
   
   return 1;
}
//-----------------------------------------------------------------------------
CPUTAnimation * CPUTAssetLibrary::GetAnimation( const cString &name, bool nameIsFullPathAndFilename )
{
	cString animationFileName;

	CPUTFileSystem::ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name + _L(".anm") : (mAnimationSetDirectoryName + name + _L(".anm")), &animationFileName);

	// If we already have one by this name, then return it
	CPUTAnimation *pAnimation = FindAnimation(animationFileName,true);
	if(pAnimation == NULL)
	{
		return CPUTAnimation::CreateAnimation(animationFileName);
	}
	pAnimation->AddRef();
	return pAnimation;
}
Beispiel #11
0
int GetScale(struct AnimationList *al, char* name, double time,
   double Sout[3])
{
   void* a = FindAnimation(name, al);
   Animation* anim = (Animation*) a;

   if(a) 
   {
      _GetScale(anim, time, Sout);
      return TRUE;
   }

   Sout[0] = Sout[1] = Sout[2] = 1.0;

   return FALSE;
}
Beispiel #12
0
int GetTranslation(struct AnimationList *al, char* name, double time,
   double Tout[3])
{
   void* a = FindAnimation(name, al);
   Animation* anim = (Animation*) a;

   if(a)
   {
      _GetTranslation(anim, time, Tout);
      return TRUE;
   }

   Tout[0] = Tout[1] = Tout[2] = 0.0;

   return FALSE;
}
Beispiel #13
0
/*----------------------------------------------------------------------
  GetCamera()
  Purpose: to get the position, the view direction and the up vector
     of the camera if it is animated. The name of the animation for
     the camera is "camera".
  In parameters:
    al   - the linked list of Animations
    time - the time of the wanted transformation
  Out parameters:
    gotPosition - by the end of the call, this will be 1 if there was a
                  position for the camera, else 0
    viewPos - the camera position (only set if gotPosition returns 1) 
    gotDirection - by the end of the call, this will be 1 if there was a
                  view direction and up vector for the camera, else 0
    viewDir - the camera direction (only set if gotDirection returns 1) 
    viewUp - the camera up vector (only set if gotDirection returns 1) 
  Returns:
    void
----------------------------------------------------------------------*/
void GetCamera(Stack<Animation*> *al,double time,
	       int *gotPosition,double viewPos[3],
	       int *gotDirection, double viewDir[3], double viewUp[3])
{
   Animation *a;
   /* is there an animation called "camera", then use it to animate the camera */
   a=FindAnimation("camera",al);
   if(a)
   {
      double m[4][4];
      
      /* get position of the camera, if any */
      if(a->translations)
      {
	 _GetTranslation(a,time,viewPos);
	 *gotPosition=1;
      }
      else *gotPosition=0;

      /* get view direction and up vector, if any */
      if(a->rotations)
      {
	 /* get matrix (we use only the upper 3x3 matrix to extract dir, and up */
	 _GetMatrix(a,time,m);
	 
	 /* the viewer looks along the negative z-axis, with the y-axis up */
	 viewDir[0]=-m[0][2];
	 viewDir[1]=-m[1][2];
	 viewDir[2]=-m[2][2];
	 
         /* the y-axis is up */
	 viewUp[0]=m[0][1];
	 viewUp[1]=m[1][1];
	 viewUp[2]=m[2][1];
	 
	 *gotDirection=1;
      }  
      else *gotDirection=0;
   }
   else
   {
      /* we did not find any position nor a direction */
      *gotPosition=0;
      *gotDirection=0;
   }
   
}
//-----------------------------------------------------------------------------
CPUTAnimation * CPUTAssetLibrary::GetAnimation( const std::string &name, bool nameIsFullPathAndFilename )
{
	std::string animationFileName;

	CPUTFileSystem::ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name + ".anm" : (mAnimationSetDirectoryName + name + ".anm"), &animationFileName);

	// If we already have one by this name, then return it
	CPUTAnimation *pAnimation = FindAnimation(animationFileName,true);
	if(pAnimation == NULL)
	{
        CPUTAnimation *pAnimation = CPUTAnimation::Create(animationFileName);
        LIBRARY_ASSERT(pAnimation, "Could not create animation " + animationFileName);
        if (pAnimation != NULL)
        AddAnimationSet(animationFileName, "", "", pAnimation);
		return pAnimation;
	}
	pAnimation->AddRef();
	return pAnimation;
}
Beispiel #15
0
int GetRotation(struct AnimationList *al, char* name, double time,
   double Rout[4])
{
   void* a = FindAnimation(name, al);
   Animation* anim = (Animation*) a;

   if(a)
   {
     _GetRotation(anim, time, Rout);
     return TRUE;
   }

   Rout[0] = 1.0;
   Rout[1] = 0.0;
   Rout[2] = 0.0;
   Rout[3] = 0.0;

   return FALSE;
}
Beispiel #16
0
/*----------------------------------------------------------------------
  GetMatrix()
  Purpose: gets the full matrix( including scaling, rotation, and 
    translation) of an animated object with a certain name
    This function can be used instead calling GetScale, GetRotation,
    and GetTranslation and then concatenate these transforms.
  In parameters:
    al   - the linked list of Animations
    name - the name of the Animation
    time - the time of the wanted transformation
  Out parameters:
    m  - the matrix at time, the matrix is of column major form,
         i.e., the translation is in the right most column of the matrix
         So, in order to use it with OpenGl, you have to transpose the
         matrix.
  Returns:
    TRUE if we could find an animation with "name", else FALSE, and
    the matrix will be an identity matrix
  Note: this routine does not check if the object is visible or not.
----------------------------------------------------------------------*/
int GetMatrix(Stack<Animation*> *al,char* name, double time, double m[4][4])
{
   int x,y;
   Animation * a = FindAnimation(name,al);
   if(a)
   {
      _GetMatrix(a, time, m);
      return TRUE;
   }
   /* return identity matrix */
   for(x=0;x<4;x++)
   {
      for(y=0;y<4;y++)
      {
	 if(x==y) m[x][y]=1.0;
	 else m[x][y]=0.0;
      }
   }
   return FALSE;
}
Beispiel #17
0
void GetCamera(struct AnimationList *al, double time, int *gotPosition,
   double viewPos[3], int *gotDirection, double viewDir[3],
   double viewUp[3])
{
   /* If there is an animation called "camera", then use it to animate
    * the camera. */
   
   Animation *a;
   
   char *animName = new char[7];
   strcpy(animName, "camera");
   
   a = FindAnimation(animName, al);
   Animation* anim = (Animation*) a;
   
   delete[] animName;
   
   if(a)
   {
      double m[4][4];
      
      /* Get position of the camera, if there is any. */
      if(a->translations)
      {
         _GetTranslation(anim, time, viewPos);
         *gotPosition = 1;
      }
      else
      {
         *gotPosition = 0;
      }

      /* Get view direction and up vector, if there is any. */
      if(anim->rotations)
      {
         /* Get matrix (we use only the upper 3x3 cells of the matrix to
          * extract dir, and up). */
         _GetMatrix(anim, time, m);
         
         /* The viewer looks along the negative z-axis, with the y-axis
          * up. */
         viewDir[0] = -m[0][2];
         viewDir[1] = -m[1][2];
         viewDir[2] = -m[2][2];
	 
         /* The y-axis is up. */
         viewUp[0] = m[0][1];
         viewUp[1] = m[1][1];
         viewUp[2] = m[2][1];
	 
         *gotDirection=1;
      }  
      else
      {
         *gotDirection=0;
      }
   }
   else
   {
      /* We did not find any position nor a direction. */
      *gotPosition = 0;
      *gotDirection = 0;
   }
}
Beispiel #18
0
/*----------------------------------------------------------------------
  GetVisibility()
  Purpose: to determine whether an object is visible at a certain time
  In parameters:
    al   - the linked list of Animations
    name - the name of the Animation
    time - the time of the wanted visibility
  Out parameters:
    None
  Returns:
    returns 0 if the object is invisible, if visible it returns a
    non-zero number
----------------------------------------------------------------------*/
int GetVisibility(Stack<Animation*> *al, char *name, double time)
{
   Animation* a = FindAnimation(name,al);
   if(a) return _GetVisibility(a, time);
   return 1;  /* visible by default */
}