Re: [osg-users] Getting the height of a 3DS node

2018-03-13 Thread Robert Osfield
HI Adrian,

On 13 March 2018 at 02:13, Adrian Jelffs  wrote:
> Awesome, this works great! Thank you for steering me in the right direction.
>
> osg::BoundingSphere bs = _myNode->getBound();
>
> Is there anything that can get just the height of the node? In my case the 
> node is quite long but not very tall so using a sphere places my text much 
> further away than necessary.

A generic subgraph/node doesn't have a "height".  The various
polygons/lines/points within the subgraph will have various heights,
all depending upon the model you have.

If you scene is axis aligned then potentially you could use the
osg::ComputeBoundsVisitor that computes a tightly bound bounding box
around a subgraph, this will have small extents than the bounding
sphere's.

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


Re: [osg-users] Getting the height of a 3DS node

2018-03-12 Thread Adrian Jelffs
Hi Robert,

Awesome, this works great! Thank you for steering me in the right direction.

osg::BoundingSphere bs = _myNode->getBound(); 

Is there anything that can get just the height of the node? In my case the node 
is quite long but not very tall so using a sphere places my text much further 
away than necessary.

Many thanks for your help!

Cheers,

Adrian

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





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


Re: [osg-users] Getting the height of a 3DS node

2018-03-10 Thread Robert Osfield
HI Adrian,

On 10 March 2018 at 04:11, Adrian Jelffs  wrote:
> Hello,
>
> I am loading a 3DS file in to my scene and I need to find out the height of 
> the object. I want to place some text above the object which moves with a 
> fixed offset but I don't always know the size of the object.
>
> I am currently loading it like this:
>
> _myNode = osgDB::readNodeFile("adrian.3ds");
>
> I thought I could do something like this but hf always returns NULL.
>
> osg::ref_ptr hf = osgDB::readHeightFieldFile("adrian.3ds");
>
> float height = hf->getSkirtHeight();

HeightField's are specific type of scene graph object but not one that
is ever loaded with a 3ds scene.  A 3ds scene graph will just contain
groups, geometry and stateset's.  Also SkirtHeight is not the actual
height of HeightField, it's the just the size of the skirt used for
hiding gaps between adjacent tiles.  HeightField is really just about
defining heights for terrain tiles.  I can only guess you've been just
searching around in the OSG code base for references to heights and
followed the wrong trail.  For the particular you want
osg::HeightField is not at all relevant.

When positioning objects in the scene graph relative to each other you
need to have a number of different routes you can take.  The easiest
would be to place the your text alongside the _myNode subgraph, I
presume you have added this to the main scene graph such as adding it
to a Group, so you'd add the Text to this same Group.

The next bit is local positioning to place the test above the _myNode
subgraph, to do this do:

osg::BoundingSphere bs = _myNode->getBound();
text->setPosition(bs.center()+osg::Vec3d(0.0, 0.0, bs.radius()));


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


[osg-users] Getting the height of a 3DS node

2018-03-09 Thread Adrian Jelffs
Hello,

I am loading a 3DS file in to my scene and I need to find out the height of the 
object. I want to place some text above the object which moves with a fixed 
offset but I don't always know the size of the object.

I am currently loading it like this:

_myNode = osgDB::readNodeFile("adrian.3ds");
 
I thought I could do something like this but hf always returns NULL.

osg::ref_ptr hf = osgDB::readHeightFieldFile("adrian.3ds");

float height = hf->getSkirtHeight();


Many thanks for your help!!

Adrian

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





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