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 

Third-Person Camera Manipulator


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


Joined: 27 Jul 2015
Posts: 11

PostPosted: Wed Oct 14, 2015 12:29 am    Post subject:
Third-Person Camera Manipulator
Reply with quote

Hi,

I'm trying to write a simple third-person camera manipulator, and I seem to be confused about something to do with how it handles the coordinate system. I am inheriting from the osgGA::StandardManipulator.

Code:

ThirdPersonManipulator::ThirdPersonManipulator()
  : osgGA::StandardManipulator(),
    distance(100),
    eye(0, -distance, 0),
    center(0, 0, 0),
    up(0, 0, 1)
{
  setHomePosition(eye, center, up);
}

void ThirdPersonManipulator::setByMatrix(const osg::Matrixd& matrix_)
{
  matrix = matrix_;
}

void ThirdPersonManipulator::setByInverseMatrix(const osg::Matrixd& matrix_)
{
  setByMatrix(osg::Matrixd::inverse(matrix_));
}

osg::Matrixd ThirdPersonManipulator::getMatrix() const { return matrix; }

osg::Matrixd ThirdPersonManipulator::getInverseMatrix() const
{
  return osg::Matrixd::inverse(matrix);
}

bool ThirdPersonManipulator::handleFrame(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
{
  osg::Vec3d pos = GameManager::instance().player.pos;

  matrix =
    osg::Matrixd::translate(pos);

  return false;
}


This kind of produces the results I wanted, but what I expect to be "forwards" is actually "up".

Here is a screenshot showing that it affects the models and the placement of the camera: http://imgur.com/ZUsRYvU

The models appear to be rotated 180 deg around the x-axis, but the camera orientation seems to be 90 degrees around the x-axis... I'm exporting the models from blender using the built-in fbx exporter. And I export them with a coordinate system that is "Y Forwards / Z Up". I believe that is the same coordinate system that osg uses by default. The little axis objects match blender's coordinate colors (red (+x), green(+y), blue(+z)).

Thank you!

Cheers,
Michael
Back to top
View user's profile Send private message Send e-mail
kabbotta
Newbie


Joined: 27 Jul 2015
Posts: 11

PostPosted: Tue Oct 27, 2015 8:09 pm    Post subject:
Reply with quote

Hi,

This turned out to be an issue with the FBX file format when exported from Blender. The issue only occurred when I was exporting my model as the "FBX 7.4 binary" option. When I switched to the "FBX 6.1 ascii" option, then the model exported with the correct scale and coordinate frame. Evidently, the osg fbx plugin is intended to be used with the older ascii file format.

Thank you!

Cheers,
Michael
Back to top
View user's profile Send private message Send e-mail
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 Projection matrix with camera looking... AlexSavo General 0 Thu Jul 25, 2019 2:34 am View latest post
No new posts osgVIEWER problem camera skehal General 1 Tue Jul 23, 2019 9:17 am View latest post
No new posts Keeping camera fixed alasca General 3 Fri May 31, 2019 10:08 am View latest post
No new posts AddSlave & removeSlave camera see... bclay General 2 Wed Apr 10, 2019 6:52 pm View latest post
No new posts FPS camera Ligvest General 0 Mon Apr 01, 2019 1:03 pm 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