animation in the ogre for iphone

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Ananditha Roy
Kobold
Posts: 30
Joined: Wed Mar 14, 2012 2:25 pm

animation in the ogre for iphone

Post by Ananditha Roy »

Hi ,

I am trying to do the robot skeleton animation in iphone . I Have followed the steps given in the
http://www.ogre3d.org/tikiwiki/Intermed ... =Tutorials, event though it is not displaying .. Please help me :( :?

Thanks&regards
anu
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: animation in the ogre for iphone

Post by masterfalcon »

Could you be a lot more specific about what is not displaying? Anything? The robot? The animation?
Ananditha Roy
Kobold
Posts: 30
Joined: Wed Mar 14, 2012 2:25 pm

Re: animation in the ogre for iphone

Post by Ananditha Roy »

Hi ,
Yes , I am trying to dislay robot animation only
1) I took the robot.mesh and robot.skeleton files form the ogresdk and i have saved in my application
2)I created the entity and sene node

Code: Select all

  animtedEntityl=OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("robot","robot.mesh");
       animateSceneNode=OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("robotnode",Ogre::Vector3(0.0f, 0.0f, 25.0f));
       
    animateSceneNode->attachObject(animtedEntityl);
created the walk list
Create the walking list

Code: Select all

 mWalkList.push_back(Ogre::Vector3(550.0f,  0.0f,  50.0f ));
        mWalkList.push_back(Ogre::Vector3(-100.0f,  0.0f, -200.0f));
I have the created the objects

Code: Select all

Ogre::Entity *ent;
        Ogre::SceneNode *node;
        
        ent = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Knot1", "knot.mesh");
        node = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Knot1Node",
                                                                  Ogre::Vector3(0.0f, -10.0f,  25.0f));
        node->attachObject(ent);
        node->setScale(0.1f, 0.1f, 0.1f);
        
        ent = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Knot2", "knot.mesh");
        node = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Knot2Node",
                                                                   Ogre::Vector3(550.0f, -10.0f,  50.0f));
        node->attachObject(ent);
        node->setScale(0.1f, 0.1f, 0.1f);
        
        ent = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Knot3", "knot.mesh");
        node = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Knot3Node",
                                                                   Ogre::Vector3(-100.0f, -10.0f,-200.0f));
        node->attachObject(ent);
        node->setScale(0.1f, 0.1f, 0.1f);
I have created the camera

Code: Select all

m_camera->setPosition(-500.0f, 280.0f, 535.0f);
       m_camera->pitch(Ogre::Degree(-30.0f));
     m_camera->yaw(Ogre::Degree(-15.0f)); 
// i created the method createframelistener

Code: Select all

void DemoApp::createFrameListener(void){
    
    mAnimationState = animtedEntityl->getAnimationState("Idle");
    mAnimationState->setLoop(true);
    mAnimationState->setEnabled(true);
[b]// what is the this baseapllication::framelistener
 instead of this i wrote below code[/b]
    Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
   OIS::ParamList pl;
   size_t windowHnd = 0;
    std::ostringstream windowHndStr;
    
    mWindow->getCustomAttribute("WINDOW", &windowHnd);
    windowHndStr << windowHnd;
   pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    
    mInputManager = OIS::InputManager::createInputSystem( pl );
    
    mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
    mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
    
    //Set initial mouse clipping size
    windowResized(mWindow);
    
//    //Register as a Window listener
    Ogre::WindowEventUtilities::addWindowEventListener(mWindow,this);
    
    
    mWalkspeed = 35.0f;
    mDirection = Ogre::Vector3::ZERO;
}

I have created the method called

Code: Select all

bool DemoApp::frameRenderingQueued(const Ogre::FrameEvent &evt){
    
    
    
    
    if (mDirection == Ogre::Vector3::ZERO) 
        {
           if (nextLocation()) 
            {
                    // Set walking animation
                    mAnimationState = animtedEntityl->getAnimationState("Walk");
                    mAnimationState->setLoop(true);
                    mAnimationState->setEnabled(true);
                   }
             }
    else
        {
           Ogre::Real move = mWalkspeed * evt.timeSinceLastFrame;
            mDistance -= move;
            
            if (mDistance <= 0.0f)
               {
                  animateSceneNode->setPosition(mDestination);
                    mDirection = Ogre::Vector3::ZERO;
                    // Set animation based on if the robot has another point to walk to. 
                   if (! nextLocation())
                    {
                             // Set Idle animation                     
                            mAnimationState = animtedEntityl->getAnimationState("Idle");
                            mAnimationState->setLoop(true);
                             mAnimationState->setEnabled(true);
                            } 
                            else
                              {
                             // Rotation Code will go here later
                            if (mDirection == Ogre::Vector3::ZERO) 
                                {
                                     if (nextLocation()) 
                                     {
                                            // Set walking animation
                                           mAnimationState = animtedEntityl->getAnimationState("Walk");
                                           mAnimationState->setLoop(true);
                                           mAnimationState->setEnabled(true);
                                           ///rotateRobotToDirection();
                                          }
                                    }
                            
                            }//
                    }
            else
               {
                    animateSceneNode->translate(mDirection * move);
                   } // else
           } // if
    mDirection != Ogre::Vector3::ZERO; 
    mAnimationState->addTime(evt.timeSinceLastFrame);
    return DemoApp::frameRenderingQueued(evt);
   return true;
    
}
Last edited by Ananditha Roy on Wed Mar 21, 2012 6:01 am, edited 1 time in total.
Ananditha Roy
Kobold
Posts: 30
Joined: Wed Mar 14, 2012 2:25 pm

Re: animation in the ogre for iphone

Post by Ananditha Roy »

Hi ,
Yes , I am trying to dislay robot animation only
1) I took the robot.mesh and robot.skeleton files form the ogresdk and i have saved in my application
2)I created the entity and sene node

Code: Select all

  animtedEntityl=OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("robot","robot.mesh");
       animateSceneNode=OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("robotnode",Ogre::Vector3(0.0f, 0.0f, 25.0f));
       
    animateSceneNode->attachObject(animtedEntityl);
created the walk list
Create the walking list

Code: Select all

 mWalkList.push_back(Ogre::Vector3(550.0f,  0.0f,  50.0f ));
        mWalkList.push_back(Ogre::Vector3(-100.0f,  0.0f, -200.0f));
I have the created the objects

Code: Select all

Ogre::Entity *ent;
        Ogre::SceneNode *node;
        
        ent = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Knot1", "knot.mesh");
        node = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Knot1Node",
                                                                  Ogre::Vector3(0.0f, -10.0f,  25.0f));
        node->attachObject(ent);
        node->setScale(0.1f, 0.1f, 0.1f);
        
        ent = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Knot2", "knot.mesh");
        node = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Knot2Node",
                                                                   Ogre::Vector3(550.0f, -10.0f,  50.0f));
        node->attachObject(ent);
        node->setScale(0.1f, 0.1f, 0.1f);
        
        ent = OgreFramework::getSingletonPtr()->m_pSceneMgr->createEntity("Knot3", "knot.mesh");
        node = OgreFramework::getSingletonPtr()->m_pSceneMgr->getRootSceneNode()->createChildSceneNode("Knot3Node",
                                                                   Ogre::Vector3(-100.0f, -10.0f,-200.0f));
        node->attachObject(ent);
        node->setScale(0.1f, 0.1f, 0.1f);
I have created the camera

Code: Select all

m_camera->setPosition(-500.0f, 280.0f, 535.0f);
       m_camera->pitch(Ogre::Degree(-30.0f));
     m_camera->yaw(Ogre::Degree(-15.0f)); 
// i created the method createframelistener

Code: Select all

void DemoApp::createFrameListener(void){
    
    mAnimationState = animtedEntityl->getAnimationState("Idle");
    mAnimationState->setLoop(true);
    mAnimationState->setEnabled(true);
[b]// what is the this baseapllication::framelistener
 instead of this i wrote below code[/b]
    Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
   OIS::ParamList pl;
   size_t windowHnd = 0;
    std::ostringstream windowHndStr;
    
    mWindow->getCustomAttribute("WINDOW", &windowHnd);
    windowHndStr << windowHnd;
   pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
    
    mInputManager = OIS::InputManager::createInputSystem( pl );
    
    mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
    mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
    
    //Set initial mouse clipping size
    windowResized(mWindow);
    
//    //Register as a Window listener
    Ogre::WindowEventUtilities::addWindowEventListener(mWindow,this);
    
    
    mWalkspeed = 35.0f;
    mDirection = Ogre::Vector3::ZERO;
}

I have created the method called

Code: Select all

bool DemoApp::frameStarted(const Ogre::FrameEvent &evt){
 if (mDirection == Ogre::Vector3::ZERO) 
    {
        if (nextLocation()) 
        {
            // Set walking animation
           mAnimationState = animtedEntityl->getAnimationState("Walk");
            mAnimationState->setLoop(true);
           mAnimationState->setEnabled(true);
       }
   }

     mAnimationState->addTime(evt.timeSinceLastFrame);
	//return DemoApp::frameRenderingQueued(evt);
    return true;
    
}
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: animation in the ogre for iphone

Post by masterfalcon »

Thanks. And what is the issue? Do you see any errors in the log? Have you tried debugging it?
Ananditha Roy
Kobold
Posts: 30
Joined: Wed Mar 14, 2012 2:25 pm

Re: animation in the ogre for iphone

Post by Ananditha Roy »

Hi ,

Issue is robot not animating . Its is not showing any error also . Just displaying the robot image and three knot.mesh . Thats it.
Do i need to call the frameRenderingQueued method separately . If so what will be the parameter i need . Sorry for not providing the all info at once
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: animation in the ogre for iphone

Post by masterfalcon »

Yes, you'll need to override frameRenderingQueued and call addTime on each animation that you want to update.