Thanks to all...
3 days ago I started looking into OSG to solve my latest computing problem. After looking the examples and getting a few answers from this e-mail service, I want to thank all who are responsible for this and for helping me.

I submitted some code earlier. Here the code update that has gotten me the affect I want.

Good day!

osg::Group* createShapes()
{
   osg::TessellationHints* hints = new osg::TessellationHints;
   hints->setDetailRatio(1.0f);

   osg::Group* group = new osg::Group();
   osg::MatrixTransform* transform =new osg::MatrixTransform();
   group->addChild(transform);

   osg::Matrix m = osg::Matrix::identity();
   m.makeRotate((float)(M_PI/2.0), 1.0f, 0.0f, 0.0f);
   osg::Geode* geode = new osg::Geode();
   transform->addChild(geode);
   float radius = 0.8f;
   float height = 3.0f;

   osg::MatrixTransform* t2 = new osg::MatrixTransform();
geode->addDrawable(new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f,0.0f,-height/2),radius,height),hints));

   transform->addChild(t2);
   osg::Geode* geode2 = new osg::Geode();
geode2->addDrawable(new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f,0.0f,-height/2),radius,height),hints));
   t2->addChild(geode2);
   t2->setMatrix(m);
   return group;
}

James

Gordon Tomlinson wrote:
 This shows how you can do this in a modeler such as Creator

See  http://www.vis-sim.com/creator/creator_dof1_ex_04.pdf this is a doc I
used to help people new to Creator to understand your problem and how to use
Dof nodes( transforms) in Creator by positioning them or placing your model
in the desired location

__________________________________________________________
Gordon Tomlinson
[EMAIL PROTECTED]
IM: [EMAIL PROTECTED]
www.vis-sim.com www.gordontomlinson.com __________________________________________________________


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Saturday, October 04, 2008 4:15 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] rotation axis at beginning of object instead of the
barycenter of object

Jean-Sebastien,
I suffer the curse of wanting to be lazy.

Thanks!
James

Hello James,

I placed 2 cylinder objects in a scene and rotated 1 of the 2 objects 90
degrees from the other (using radians).  The 2nd object was rotated
about the barycenter instead of the beginning position of the object.
Is there a global variable I can set to force rotations about an end of
an object instead of the barycenter?

Basically the code below will render a '+' instead of a shape '|_' -- I
prefer the '|_' shape.
You need to understand coordinate systems and how they relate to
transformations.

The cylinder objects are constructed so that their origin is in their
center (this is often the norm for graphical models). Therefore, any
rotation matrix you apply to them will rotate them around that center.

What you need to do in order to get the result you want is to use two
transformations. The first will translate the coordinate system to the
end of the object. The second will apply the rotation you want.

So your graph will look like this:

root
   |
MatrixTransform (rotation)
   |
MatrixTransform (translation)
   |
cylinder

To understand why this works, draw it on a piece of paper, starting from
the bottom up. First you have a cylinder whose origin is in its center.
Then you translate that origin to an edge of the cylinder. Then you
rotate around that edge.

So you see, you don't need any "global variable" to control how
rotations are done, you just need to apply the right transformations.
This is all under your control.

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    [EMAIL PROTECTED]
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

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


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

Reply via email to