OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Implementing own manipulator


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
nonnenmacher
Newbie


Joined: 04 Oct 2018
Posts: 2

PostPosted: Thu Oct 04, 2018 1:54 am    Post subject:
Implementing own manipulator
Reply with quote

Hi,

The trackball manipulator is almost what I need for my application. I would like to handle some keyboard inputs to move the camera.

I am trying to derive TrackballManipulator and override the handle() method. Looking at the structure of 'camera manipulators', it seems to me that this is the right way to just handle keyboard inputs.

But somehow the handle method of my manipulator is not being called. just never.

Am I in the right direction?

Code:

class CityManipulator : public osgGA::TrackballManipulator
{

public:
    CityManipulator(int flags = DEFAULT_SETTINGS)
        :osgGA::TrackballManipulator(){}
    CityManipulator( const CityManipulator& tm,
                     const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY )
        :osgGA::TrackballManipulator( tm, copyOp ){}

    META_Object( osgGA, CityManipulator )

protected:
    bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us)
    {
        std::cout << "handling" << std::endl;

        bool handled(false);

        switch(ea.getEventType())
        {
        case(osgGA::GUIEventAdapter::KEYDOWN):
           {
              switch(ea.getKey())
              {
              case 'w':
                 std::cout << "pressing w"  << std::endl;
                 return false;
                 break;
              default:
                 return false;
              }
           }
        default:
           return false;
        }

        return TrackballManipulator::handle(ea, us);
    }
};

//////

CityManipulator * tm = new CityManipulator();

tm->setNode(m_rootNode);

tm_viewer->setCameraManipulator(tm);




...

Thank you!

Cheers,
Vinicius
Code:
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts [customizing manipulator] problem wit... mp3butcher General 1 Tue Apr 24, 2018 3:19 pm View latest post
No new posts Free camera manipulator Styx General 2 Sun Jan 07, 2018 8:06 am View latest post
No new posts Shadow Shenanigans (Implementing shad... AnyOldName3 General 9 Wed Sep 20, 2017 4:07 pm View latest post
No new posts setting 2D manipulator bhanu406 General 1 Wed May 31, 2017 4:55 am View latest post
No new posts Custom camera manipulator Ninin General 1 Wed Dec 28, 2016 8:24 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP