You appear to be drawing it from the eye to a hardcoded point. I think
you need to compute the location of a point directly in front of the
eye, and draw the line from there to the hardcoded point (if I am
understanding what you are trying to do correctly).
If I remember correctly, getViewMatrixAsLookAt takes an implicit
parameter to define the distance from the eye to the "center" point that
it returns. So, if you supply that distance, the you should be able to
draw a line from "center" to a hardcoded value.
Paul Martz
Skew Matrix Software LLC
_http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
+1 303 859 9466
Trajce Nikolov wrote:
Hi,
with the following setup I expect to have a line from the center of the
screeen to the point hard coded. It not that case. Any ideas?
Thanks
this is geode update callback
class UpdateCallback : public osg::NodeCallback
{
public:
UpdateCallback(osgViewer::Viewer* viewer)
: mViewer(viewer)
{
}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg::Geode* geode = dynamic_cast<osg::Geode*>(node);
if (!geode) return;
geode->removeDrawables(0,geode->getNumDrawables());
osg::Geometry* geometry = new osg::Geometry;
geode->addDrawable(geometry);
osg::Vec3 eye;
osg::Vec3 center;
osg::Vec3 up;
mViewer->getCamera()->getViewMatrixAsLookAt(eye,center,up);
osg::Vec3Array* verts = new osg::Vec3Array;
verts->push_back(eye);
verts->push_back(osg::Vec3(20,20,20));
geometry->setVertexArray(verts);
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(0,1,0,1));
geometry->setColorArray(colors);
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::LINES,0,verts->size()));
float radius = 0.8f;
float height = 1.0f;
osg::TessellationHints* hints = new osg::TessellationHints;
hints->setDetailRatio(0.5f);
geode->addDrawable(new osg::ShapeDrawable(new
osg::Sphere(osg::Vec3(20.0f,20.0f,20.0f),radius),hints));
geode->dirtyBound();
}
protected:
osgViewer::Viewer* mViewer;
};
Nick
http://www.linkedin.com/in/tnick
Sent from Devlet, Ankara, Turkey
------------------------------------------------------------------------
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org