Re: [osg-users] Bone space matrix

2010-07-06 Thread Aitor Ardanza
Hi,

I have a problem ... in my application receives the matrices of bones in each 
time step (bones are updated in real time), and using:


Code:
pBoneUpdate.at(i)->getStackedTransforms().push_back( new 
osgAnimation::StackedQuaternionElement("rotate", mat.getRotate()));


the framerate plummets ...
Is there some method to update the bones without using it?

Thank you!

Cheers,
Aitor

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





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


Re: [osg-users] Bone space matrix

2010-05-06 Thread Cedric Pinson
Hi,

setMatrix in the Bone would update the bone, like a MatrixTransform. So
If you update the matrix and you dont see any update of children on the
screen then there is something wrong.

I suggest to read the UpdateBone.cpp in osgAnimation to see how bones
are updated in 'classical' way.

Another stuff that comes in mind is that maybe you could use the regular
path (like in osganimationskinning) and define your customized
UpdateBone class that could take input from your events and generate a
matrix from that.

Cheers,
Cedric


On Thu, 2010-05-06 at 15:29 +, Aitor Ardanza wrote:
> Hi,
> 
> I've been looking at the example of osganimationskinning... but this example 
> uses a pre-generated animation, and in my case I change the position and 
> direction of the nodes with keyboard events.
> 
> For example, we apply a rotation to bone0Rot (OSG:: Quat) with a keyboard 
> event:
> 
> Code:
> bone0Rot-> makeRotate (rotx-0.04, OSG:: Vec3 (1.0,0,0), roty, OSG:: Vec3 
> (0.0,0,1.0), 0, OSG:: Vec3 (0.0,1,0.0));
> 
> 
> and then, at each time step, I apply that to the bone:
> 
> Code:
> bone0-> setMatrix (OSG:: Matrix:: rotate (bone0Rot));
> 
> 
> with this we would have the matrix of the bone to do the skinning, it works 
> well.
> 
> Code:
> boneMatrices[1] = bone0->getMatrixInBoneSpace();
> 
> 
> boneMatrices communicates with the vertices shader.
> 
> I just be wanting to know how to update the position of the bone on the 
> screen ..
> 
> Thank you!
> 
> Cheers,
> Aitor
> 
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=27619#27619
> 
> 
> 
> 
> 
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 

-- 
Provide OpenGL services around OpenSceneGraph and more
+33 659 598 614 Cedric Pinson mailto:cedric.pin...@plopbyte.net
http://www.plopbyte.net



signature.asc
Description: This is a digitally signed message part
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Bone space matrix

2010-05-06 Thread Aitor Ardanza
Hi,

I've been looking at the example of osganimationskinning... but this example 
uses a pre-generated animation, and in my case I change the position and 
direction of the nodes with keyboard events.

For example, we apply a rotation to bone0Rot (OSG:: Quat) with a keyboard event:

Code:
bone0Rot-> makeRotate (rotx-0.04, OSG:: Vec3 (1.0,0,0), roty, OSG:: Vec3 
(0.0,0,1.0), 0, OSG:: Vec3 (0.0,1,0.0));


and then, at each time step, I apply that to the bone:

Code:
bone0-> setMatrix (OSG:: Matrix:: rotate (bone0Rot));


with this we would have the matrix of the bone to do the skinning, it works 
well.

Code:
boneMatrices[1] = bone0->getMatrixInBoneSpace();


boneMatrices communicates with the vertices shader.

I just be wanting to know how to update the position of the bone on the screen 
..

Thank you!

Cheers,
Aitor

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





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


Re: [osg-users] Bone space matrix

2010-05-06 Thread Cedric Pinson
Hi,
I can't help more without other details, i can just tell you to check
the osganimationskinning example.
My First advise should be to make it work with software implementation.

I could help but i would need to have a small example i could run and
debug to have a quick overview what's wong.

Cheers,
Cedric

On Thu, 2010-05-06 at 08:04 +, Aitor Ardanza wrote:
> Hi,
> 
> Well, I managed to position the nodes to start, but I dont know how can I 
> update them, for viewing, each time step.
> 
> 
> Code:
> bone0 = new osgAnimation::Bone;
>   
> bone0->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(0,0,0)));
> bone0->setName("right0");
>   pBone0Update = new osgAnimation::UpdateBone("right0");
> pBone0Update->getStackedTransforms().push_back(new 
> osgAnimation::StackedTranslateElement(osg::Vec3(0,3,0)));
> bone0->setUpdateCallback(pBone0Update);
> 
> 
> 
> at each time step:
> 
> 
> Code:
> bone0->setMatrix(osg::Matrix::rotate(bone0Rot));
>   bone1->setMatrix(osg::Matrix::rotate(bone1Rot));
>   boneMatrices[1] = bone0->getMatrixInBoneSpace();
>   boneMatrices[2] = bone1->getMatrixInBoneSpace();
> 
> 
> 
> Now the cylinder is transformed correctly, but the nodes dont moves ... I 
> guess I'll have to call in some way to osgAnimation:: UpdateBone...
> 
> [Image: http://img132.imageshack.us/img132/7231/osgskinning1.jpg ]
> 
> Thank you!
> 
> Cheers,
> Aitor
> 
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=27601#27601
> 
> 
> 
> 
> 
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 

-- 
Provide OpenGL services around OpenSceneGraph and more
+33 659 598 614 Cedric Pinson mailto:cedric.pin...@plopbyte.net
http://www.plopbyte.net



signature.asc
Description: This is a digitally signed message part
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Bone space matrix

2010-05-06 Thread Aitor Ardanza
Hi,

Well, I managed to position the nodes to start, but I dont know how can I 
update them, for viewing, each time step.


Code:
bone0 = new osgAnimation::Bone;

bone0->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(0,0,0)));
bone0->setName("right0");
pBone0Update = new osgAnimation::UpdateBone("right0");
pBone0Update->getStackedTransforms().push_back(new 
osgAnimation::StackedTranslateElement(osg::Vec3(0,3,0)));
bone0->setUpdateCallback(pBone0Update);



at each time step:


Code:
bone0->setMatrix(osg::Matrix::rotate(bone0Rot));
bone1->setMatrix(osg::Matrix::rotate(bone1Rot));
boneMatrices[1] = bone0->getMatrixInBoneSpace();
boneMatrices[2] = bone1->getMatrixInBoneSpace();



Now the cylinder is transformed correctly, but the nodes dont moves ... I guess 
I'll have to call in some way to osgAnimation:: UpdateBone...

[Image: http://img132.imageshack.us/img132/7231/osgskinning1.jpg ]

Thank you!

Cheers,
Aitor

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





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


Re: [osg-users] Bone space matrix

2010-05-05 Thread Aitor Ardanza
Hi Cedric,

Thanks for the your answer. I update it to 2.8.3, but I continued to have 
problems. 

I'm implementing hardware animation skinning. The skeleton have three nodes and 
i change de nodes position and orientation by keyboard(it's not preconfigured 
animation). 

I have seen that in the new osgAnimationSkinning.cpp example sets the nodes 
matrixs by:


Code:
root->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(-1,0,0)));



I dont know why but in my case these translations are not met. 
My code:


Code:
osg::ref_ptr skelroot = new osgAnimation::Skeleton;
   // skelroot->setDefaultUpdateCallback();
root = new osgAnimation::Bone;

root->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(,0,0)));
root->setName("root");
boneMatrices[0] = root->getMatrixInBoneSpace();
// root->setDefaultUpdateCallback();

bone0 = new osgAnimation::Bone;

bone0->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(0,3,0)));
bone0->setName("right0");
   // right0->setDefaultUpdateCallback("right0");
boneMatrices[1] = bone0->getMatrixInBoneSpace();

bone1 = new osgAnimation::Bone;

bone1->setInvBindMatrixInSkeletonSpace(osg::Matrix::inverse(osg::Matrix::translate(0,3,0)));
bone1->setName("right1");
   // right1->setDefaultUpdateCallback("right1");
boneMatrices[2] = bone1->getMatrixInBoneSpace();

root->addChild(bone0.get());
bone0->addChild(bone1.get());
skelroot->addChild(root.get());

// we will use local data from the skeleton
osg::MatrixTransform* rootTransform = new osg::MatrixTransform;
rootTransform->getOrCreateStateSet()->setMode(GL_LIGHTING, 
osg::StateAttribute::OFF);
rootTransform->setMatrix(osg::Matrix::rotate(osg::PI_2,osg::Vec3(0,0,0)));
bone0->addChild(createAxis());
bone0->setDataVariance(osg::Object::DYNAMIC);
bone1->addChild(createAxis());
bone1->setDataVariance(osg::Object::DYNAMIC);
osg::MatrixTransform* trueroot = new osg::MatrixTransform;
trueroot->setMatrix(osg::Matrix(root->getMatrixInBoneSpace().ptr()));
trueroot->addChild(createAxis());
trueroot->addChild(skelroot.get());
trueroot->setDataVariance(osg::Object::DYNAMIC);
rootTransform->addChild(trueroot);
scene->addChild(rootTransform);



The result:

[Image: http://img265.imageshack.us/img265/5871/osgskinning.jpg ]

The three nodes are in the same position...

Cheers,
Aitor

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





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


Re: [osg-users] Bone space matrix

2010-05-05 Thread Cedric Pinson
I suspect you use an 'old' version of osgAnimation, osgAnimation has
been changed about that since OpenSceneGraph 2.8.3. I recommand you to
update to the last version.

Cheers,
Cedric

On Wed, 2010-05-05 at 11:22 +, Aitor Ardanza wrote:
> Hi,
> 
> I'm having problems with this issue. I build the skeleton as follows:
> 
> Code:
> osg::ref_ptr skelroot = new osgAnimation::Skeleton;
> skelroot->setDefaultUpdateCallback();
> root = new osgAnimation::Bone;
> {
> root->setBindMatrixInBoneSpace(osg::Matrix::identity());
> root->setBindMatrixInBoneSpace(osg::Matrix::translate(0,0,0));
> root->setName("root");
>   boneMatrices[0] = root->getMatrixInBoneSpace();
>// root->setDefaultUpdateCallback();
> }
> 
>   bone0 = new osgAnimation::Bone;
>   bone0->setBindMatrixInBoneSpace(osg::Matrix::identity());
>   bone0->setTranslation(osg::Vec3(0,3,0));
> bone0->setName("right0");
>// right0->setDefaultUpdateCallback("right0");
>   boneMatrices[1] = bone0->getMatrixInBoneSpace();
> 
>   bone1 = new osgAnimation::Bone;
>   bone1->setBindMatrixInBoneSpace(osg::Matrix::identity());
>   bone1->setTranslation(osg::Vec3(0,3,0));
> bone1->setName("right1");
>// right1->setDefaultUpdateCallback("right1");
>   boneMatrices[2] = bone1->getMatrixInBoneSpace();
> 
> root->addChild(bone0.get());
> bone0->addChild(bone1.get());
> skelroot->addChild(root.get());
> 
> 
> 
> I supposed that bon0-> getMatrixInBoneSpace () return the array without 
> translations, but it is not. 
> 1 0 0 0
> 0 1 0 3
> 0 0 1 0
> 0 0 0 1
> 
> What am I doing wrong?
> 
> Thank you!
> 
> Cheers,
> Aitor
> 
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=27563#27563
> 
> 
> 
> 
> 
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 

-- 
Provide OpenGL services around OpenSceneGraph and more
+33 659 598 614 Cedric Pinson mailto:cedric.pin...@plopbyte.net
http://www.plopbyte.net



signature.asc
Description: This is a digitally signed message part
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Bone space matrix

2010-05-05 Thread Aitor Ardanza
Hi,

I'm having problems with this issue. I build the skeleton as follows:

Code:
osg::ref_ptr skelroot = new osgAnimation::Skeleton;
skelroot->setDefaultUpdateCallback();
root = new osgAnimation::Bone;
{
root->setBindMatrixInBoneSpace(osg::Matrix::identity());
root->setBindMatrixInBoneSpace(osg::Matrix::translate(0,0,0));
root->setName("root");
boneMatrices[0] = root->getMatrixInBoneSpace();
   // root->setDefaultUpdateCallback();
}

bone0 = new osgAnimation::Bone;
bone0->setBindMatrixInBoneSpace(osg::Matrix::identity());
bone0->setTranslation(osg::Vec3(0,3,0));
bone0->setName("right0");
   // right0->setDefaultUpdateCallback("right0");
boneMatrices[1] = bone0->getMatrixInBoneSpace();

bone1 = new osgAnimation::Bone;
bone1->setBindMatrixInBoneSpace(osg::Matrix::identity());
bone1->setTranslation(osg::Vec3(0,3,0));
bone1->setName("right1");
   // right1->setDefaultUpdateCallback("right1");
boneMatrices[2] = bone1->getMatrixInBoneSpace();

root->addChild(bone0.get());
bone0->addChild(bone1.get());
skelroot->addChild(root.get());



I supposed that bon0-> getMatrixInBoneSpace () return the array without 
translations, but it is not. 
1 0 0 0
0 1 0 3
0 0 1 0
0 0 0 1

What am I doing wrong?

Thank you!

Cheers,
Aitor

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





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