Hi Mike, all,

In fact, before sending the mail to the mailing list, I searched in the code
where was the "rendering of the cone"....

I found it in the ShapeDrawable.cpp >> line 578 (checkout OSG tag 2.2.0)

void DrawShapeVisitor::apply(const Cone& cone)
...

In that function there is only a glTranslate ... at the very beginning ...

glTranslatef(cone.getCenter().x(),cone.getCenter().y(),cone.getCenter
().z());

I thought that the cone.getCenter() would return the center I passed in the
cone constructor... but, I guess it is not.

Now that it seems that the code is doing was it is expected, i.e, it is a
feature :), I found that in the line

float topz=cone.getHeight()+cone.getBaseOffset();

The getBaseOffset is defined in the include file Shape, just in the
declaration of the Cone class.

(line 287 of Shape)
inline float getBaseOffsetFactor() const { return 0.25f; }

And there it is the 0.25 factor!!!!

I would suggest to document it a little bit, at least in the cone class
declaration, so the auto documentation would include that the center of the
cone is the Centroid, instead of the tip, the center of the base, or
whatever...

Bye.




On Thu, Feb 14, 2008 at 11:47 PM, Mike Weiblen <[EMAIL PROTECTED]>
wrote:

> Hi,
>
> The origin of the cone is at its center of mass, not its geometric base.
>
> osgShapes are internally defined parametrically, rather than in terms of
> triangles, so as to be used as intersection volumes, etc.  The fact that
> they are also drawable is just a convenience overload of their primary
> purpose.
>
> This is a recurring misconception/FAQ, and deserves to be documented
> clearly. Could you have a look at the code, and if it's not clearly
> documented, pls submit a code change that puts comments where you would
> have found them.
>
> Thanks
> -- mew
>
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:osg-users-
> > [EMAIL PROTECTED] On Behalf Of Aitor Moreno
> > Sent: Thursday, February 14, 2008 8:13 AM
> > To: [email protected]
> > Subject: [osg-users] Possible bug in the position of the osg::Cone
> >
> > Hi osg-users,
> >
> > I am trying to do a very simple application, and when I was required
> to
> > add some cones, I added a new osg::Cone with the desired parameters.
> > Unfortunatelly, the cone didn't appeared where it was suppossed to.
> >
> > I clean up the code and I copy here a snipset of the code I used and a
> > screenshot.
> >
> > This code adds a Cone and a Box.
> > Both objects with the same origin. The box is only for reference (it
> > represents the XY plane at z=0).
> >
> > As you can see in the attached screenshot, the cone is displaced 25%
> > below the XY plane (100 units). Its size is 400.
> >
> > I was expected to that the bottom of the cone at z=0. Or, as in other
> > API's, the center of the cone at z=0.
> >
> > Any ideas? is it a bug?
> >
> > Thanks
> >
> >
> > =============== CODE =======================
> >
> >        ViewerQT* viewerWindow = new ViewerQT;
> >
> >         //create a group and add the loaded model => terrain
> >         osg::ref_ptr<osg::Group> groupRoot = new osg::Group;
> >
> >         //Add the Cone
> >         osg::Geode* geo = new osg::Geode();
> >         geo->addDrawable(new osg::ShapeDrawable(new
> > osg::Cone(osg::Vec3(0,0,0), 50, 400)));
> >         geo->addDrawable(new osg::ShapeDrawable(new osg::Box(
> > osg::Vec3(0,0,0) , 100, 100, 0.05f )));
> >         groupRoot->addChild ( geo);
> >
> >         //set camera and set the root node.
> >         viewerWindow->setCameraManipulator(new
> > osgGA::TrackballManipulator);
> >
> >         osg::ref_ptr<osgText::Text> updateText = new osgText::Text;
> >         // add the HUD subgraph.
> >         groupRoot->addChild(createHUD(updateText.get()));
> >         viewerWindow->addEventHandler(new
> > PickHandler(updateText.get()));
> >
> >         viewerWindow->setSceneData(groupRoot.get());
> >
> > =============== CODE =======================
> >
> > --
> > Aitor Moreno
> > aitormoreno [EMAIL PROTECTED] gmail.com <mailto:[EMAIL PROTECTED]>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Aitor Moreno
[EMAIL PROTECTED]
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to