Re: [osg-users] Positional Animation

2014-11-12 Thread Chris Hidden
This needed a very different approach then what I thought. Managed to find a 
very nice way to solve positional animation based on input see:

http://forum.openscenegraph.org/viewtopic.php?t=14272start=0postdays=0postorder=aschighlight=

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





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


[osg-users] Positional Animation

2014-09-05 Thread Chris Hidden
Hey everyone.

I may be interpreting how this is done improperly, but all I want at the moment 
is to animate two hand models.  

I have two osg::MatrixTransform objects which I add my loaded hand models too.

I then attach an instance of a class that extends from osg::NodeCallback

Then in that class i have: 


Code:

public:
HandMovementX() :incrementer(-0.5), incrementer2(-0.5), pitch(-90.0), 
roll(12.0){}

virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{

OSG_FATAL  Being called  std::endl;
roll += incrementer2;
if (roll  57)
incrementer2 = -0.5;
if (roll  -33)
incrementer2 = 0.5;

pitch += incrementer;
if (pitch  -135)
incrementer = 0.5;
if (pitch  -90)
incrementer = -0.5;


osg::MatrixTransform *trans = dynamic_castosg::MatrixTransform 
* (node);
if (trans != NULL)
{
osg::Matrixd handRotation;
handRotation.makeRotate(
osg::inDegrees(90.0f), osg::X_AXIS,
osg::inDegrees(pitch), osg::Y_AXIS,
osg::inDegrees(roll), osg::Z_AXIS
);
trans-setMatrix(handRotation * 
osg::Matrix::translate(15, 0, 8) );
worldCoordMatrix = 
osg::computeLocalToWorld(nv-getNodePath());

}
traverse(node, nv);
}

private:
osg::Matrix worldCoordMatrix;
float pitch;
float roll;
float incrementer;
float incrementer2;





The hands are moving, but not at all how I want them too and it seems that it 
animates first the Y axis and then the Z axis and then the translate.  I want 
all positions to be taken into account in a single movement on each frame. Am I 
approaching this totally wrong or what?

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





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


Re: [osg-users] Positional Animation

2014-09-05 Thread Jason MacDonald
I'm unsure of your method, but here is how I handle it:
_position is a PositionAttitudeTransform

Quat h,r,p;
h.makeRotate(osg::DegreesToRadians(heading), Vec3d(0,0,1));
p.makeRotate(osg::DegreesToRadians(pitch), Vec3d(0,1,0));
r.makeRotate(osg::DegreesToRadians(roll), Vec3d(1,0,0));
_position-setAttitude(r*p*h);

Jason

-Original Message-
From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Chris Hidden
Sent: Friday, September 05, 2014 5:35 AM
To: osg-users@lists.openscenegraph.org
Subject: [osg-users] Positional Animation

Hey everyone.

I may be interpreting how this is done improperly, but all I want at the moment 
is to animate two hand models.

I have two osg::MatrixTransform objects which I add my loaded hand models too.

I then attach an instance of a class that extends from osg::NodeCallback

Then in that class i have:


Code:

public:
HandMovementX() :incrementer(-0.5), incrementer2(-0.5), pitch(-90.0), 
roll(12.0){}

virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{

OSG_FATAL  Being called  std::endl;
roll += incrementer2;
if (roll  57)
incrementer2 = -0.5;
if (roll  -33)
incrementer2 = 0.5;

pitch += incrementer;
if (pitch  -135)
incrementer = 0.5;
if (pitch  -90)
incrementer = -0.5;


osg::MatrixTransform *trans = dynamic_castosg::MatrixTransform 
* (node);
if (trans != NULL)
{
osg::Matrixd handRotation;
handRotation.makeRotate(
osg::inDegrees(90.0f), osg::X_AXIS,
osg::inDegrees(pitch), osg::Y_AXIS,
osg::inDegrees(roll), osg::Z_AXIS
);
trans-setMatrix(handRotation * 
osg::Matrix::translate(15, 0, 8) );
worldCoordMatrix = 
osg::computeLocalToWorld(nv-getNodePath());

}
traverse(node, nv);
}

private:
osg::Matrix worldCoordMatrix;
float pitch;
float roll;
float incrementer;
float incrementer2;





The hands are moving, but not at all how I want them too and it seems that it 
animates first the Y axis and then the Z axis and then the translate.  I want 
all positions to be taken into account in a single movement on each frame. Am I 
approaching this totally wrong or what?

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
This email and any files transmitted with it from The Charles Machine Works, 
Inc. are confidential and intended solely for the use of the individual or 
entity to which they are addressed. If you have received this email in error 
please notify the sender. Our company accepts no liability for the contents of 
this email, or for the consequences of any actions taken on the basis of the 
information provided, unless that information is subsequently confirmed in 
writing. Please note that any views or opinions presented in this email are 
solely those of the author and do not necessarily represent those of the 
company. Finally, the recipient should check this email and any attachments for 
the presence of viruses. The company accepts no liability for any damage caused 
by any virus transmitted by this email.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org