Re: [osg-users] (no subject)

2016-04-23 Thread Marko Käning
Hi Grendah,

On 23 Apr 2016, at 15:35 , Grendah Garidi  wrote:

> hi,  I want to use Qt with OSG(2.9.12_x86VC2008) and I need a Binaries 
> library of osg version 3.x.x

do you perhaps want to consider installing all dependencies needed to build OSG 
via MSYS2 [1]
and start using the MinGW toolchain instead of Microsoft’s Visual C++?

Greets,
Marko


[1] http://msys2.github.io/___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] (no subject)

2016-04-23 Thread Grendah Garidi
hi,  I want to use Qt with OSG(2.9.12_x86VC2008) and I need a Binaries library 
of osg version 3.x.x ___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Create a custom StandardManipulator

2016-04-23 Thread Florian GOLESTIN
Hi everyone,

I'm trying to develop my own Camera Manipulator (in order to have a Doom-like 
view). I've looked at documentations but there are still questions for me.

First question I had was "How to translate an object relatively to its own 
position (and not to the world)". I'm still looking for a way doing this with 
Matrix, however, I've found a solution with quaternion :
You can multiply a Quaternion with a Vector to move relatively to the 
direction. 

For instance: 

Code:

_position += _attitude * translation;



where 

"_position" is a Vec3 representing the current position (e.g. from 
osg::PositionAttitudeTransform)
"_attitude" is a quaternion representing the current direction (e.g. from 
osg::PositionAttitudeTransform)
"translation" is the relative translation (as Vec3) to apply


This solution provides me good result but is it a good way?



Then I wanted to create the camera manipulator, so I've extended the class such 
as:

Header

Code:

class FirstPersonManipulator : public osgGA::StandardManipulator, public 
osg::PositionAttitudeTransform




Source

Code:

FirstPersonManipulator::FirstPersonManipulator(const osg::Vec3d , const 
osg::Vec3d )
{
  osg::Vec3 up(0.0, 0.0, 1.0);

  setTransformation(eye, center, up);

  _homeEye = eye;
  _homeCenter = center;
  _homeUp = up;
  _autoComputeHomePosition = false;
}
  
FirstPersonManipulator::~FirstPersonManipulator(void)
{
}

void  FirstPersonManipulator::setTransformation(const osg::Vec3d , const 
osg::Quat )
{

  std::cout << "FirstPersonManipulator::setTransformation: Old Position [" << 
_position << " X " << _attitude
 << "] New Position: [" <<  eye << " X " << rotation << "]\n";
  this->_position = eye;
  this->_attitude = rotation;
}

void  FirstPersonManipulator::setTransformation(const osg::Vec3d , const 
osg::Vec3d , const osg::Vec3d )
{
  osg::Matrixd view;

  view.makeLookAt(eye, center, up);

  /* This line is required otherwise the canera seems "head-down" */
  view.makeRotate(osg::DegreesToRadians(90.0), osg::Vec3(1, 0, 0));


  std::cout << "FirstPersonManipulator::setTransformation: " << view  << "\n";

  this->setTransformation(eye, view.getRotate());
}

void  FirstPersonManipulator::getTransformation(osg::Vec3d , osg::Quat 
) const
{
  eye = this->_position;
  rotation = this->_attitude;
}

void  FirstPersonManipulator::getTransformation(osg::Vec3d , osg::Vec3d 
, osg::Vec3d ) const
{
  osg::Matrixd view;

  view.setTrans(this->_position);
  view.setRotate(this->_attitude);
  view.getLookAt(eye, center, up);
}

void  FirstPersonManipulator::setByMatrix(const osg::Matrixd )
{
  std::cout << "FirstPersonManipulator::setByMatrix: " << matrix << "\n";
  this->setTransformation(matrix.getTrans(), matrix.getRotate());
}
  
void  FirstPersonManipulator::setByInverseMatrix(const osg::Matrixd )
{
  std::cout << "FirstPersonManipulator::setByInverseMatrix: " << matrix << "\n";
  setByMatrix(osg::Matrixd::inverse(matrix));
}

osg::Matrixd  FirstPersonManipulator::getMatrix() const
{
  osg::Matrixd view;

  view.setTrans(this->_position);
  view.setRotate(this->_attitude);
  std::cout << "FirstPersonManipulator::getMatrix: " << view << "\n";
  return view;
}
  
osg::Matrixd  FirstPersonManipulator::getInverseMatrix() const
{
  std::cout << "FirstPersonManipulator::getInverseMatrix: " << 
osg::Matrixd::inverse(getMatrix()) << "\n";
  return osg::Matrixd::inverse(getMatrix());
}




Here the camera is correctly positioned and oriented but I had to add this line 
(in FirstPersonManipulator::setTransformation):

Code:

  /* This line is required otherwise the canera seems "head-down" */
  view.makeRotate(osg::DegreesToRadians(90.0), osg::Vec3(1, 0, 0));



Otherwise the camera seemed to had foot up and head down.

Is the code above correct?
Do you have an idea about the rotation I had to do?


(PS: Sorry I cannot get rid of the 'question-mark '?' - I've replaced all tab 
and spaces but they still appears)

Thanks,
Florian[/list]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66937#66937





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org