Re: [osg-users] First recipe from cookbook won't compile with given source code

2019-01-18 Thread Rodrigo Dias
Thank you, Julien.

Though there are two different CMakeLists.txt files 
(https://github.com/xarray/osgRecipes/CMakeLists.txt and 
https://github.com/xarray/osgRecipes/tree/master/cookbook/CMakeLists.txt), I 
tried with the first one, because you said so. I had to give a value to the 
OPENSCENEGRAPH_LIB_DIR (/usr/local/lib64) in CMake, but it still gives me an 
error:


> Could NOT find OpenCV (missing:  OpenCV_ROOT_DIR OpenCV_LIBRARIES_RELEASE 
> OpenCV_LIBRARIES_DEBUG OpenCV_LIBRARIES) 
> Could NOT find ALVAR (missing:  ALVAR_ROOT_DIR ALVAR_INCLUDE_DIRS 
> ALVAR_LIBRARIES_RELEASE ALVAR_LIBRARIES_DEBUG ALVAR_LIBRARIES) 
> CMake Error: The following variables are used in this project, but they are 
> set to NOTFOUND.
> Please set them or make sure they are set and tested correctly in the CMake 
> files:
> GLEW_LIBRARY
> linked by target "osgnanovg" in directory 
> /home/rodrigo/Videos/osg/rodrigo/osgRecipes-master/integrations/osgnanovg
> 
> Configuring incomplete, errors occurred!
> See also 
> "/home/rodrigo/Videos/osg/rodrigo/osgRecipes-build/CMakeFiles/CMakeOutput.log".
> See also 
> "/home/rodrigo/Videos/osg/rodrigo/osgRecipes-build/CMakeFiles/CMakeError.log".
> 


And with this I cannot "make" or "make install" it. The readme gives an even 
more incomplete direction (say nothing about the OPENSCENEGRAPH_LIB_DIR 
variable, and why not use the default set by OSG?). Going the way I was going, 
I managed to compile and run most of the recipes in chapter 2. I wouldn't mind 
giving up one recipe or another just because I didn't install some obscure 
library. So, maybe using g++ is an easier option? (This includes me losing 
years with Borland Delphi, instead of learning and dominating C++ and CMake 
stuff. Shame on me!)

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





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


Re: [osg-users] First recipe from cookbook won't compile with given source code

2019-01-18 Thread Julien Valentin
Hi
use cmake with provided CMakelist.txt (https://github.com/xarray/osgRecipes)
Cheers

Rodrigo wrote:
> Hi,
> 
> I'm following the OpenSceneGraph 3 Cookbook 
> (http://ahux.narod.ru/olderfiles/1/OSG3_Cookbook.pdf) to learn more about 
> OSG. So I created a directory Cookbook following the directory structure from 
> the source code here 
> (https://github.com/xarray/osgRecipes/tree/master/cookbook).
> 
> Before compiling the first recipe 
> (https://github.com/xarray/osgRecipes/blob/master/cookbook/chapter2/ch02_01/observer_ptr.cpp),
>  I had copied the "Common Functions" from the textbook (pages 38-39), into a 
> file called "CommonFunctions". When compiling (with g++ on Linux) I got the 
> following error:
> 
> 
> > $ g++ observer_ptr.cpp -I../.. -losg -losgDB -losgGA -losgText -losgUtil 
> > -losgViewer -o observer_ptr
> > 
> > In file included from observer_ptr.cpp:11:0:
> > ../../CommonFunctions: In member function ‘virtual bool 
> > osgCookBook::PickHandler::handle(const osgGA::GUIEventAdapter&, 
> > osgGA::GUIActionAdapter&)’:
> > ../../CommonFunctions:47:62: error: binding ‘const 
> > osgUtil::LineSegmentIntersector::Intersection’ to reference of type 
> > ‘osgUtil::LineSegmentIntersector::Intersection&’ discards qualifiers
> >   osgUtil::LineSegmentIntersector::Intersection& result = 
> > *(intersector->getIntersections().begin());
> > 
> 
> 
> ../.. is the path to the CommonFunctions file. I tried a few const_cast 
> operations, but I don't have so much experience with C++ and couldn't solve 
> it. I commented out this two lines and the program compiled fine and ran, 
> though clicking on the objects wouldn't dismiss them (guess that's what these 
> lines do).
> 
> Then I noticed they have this "CommonFunctions" file together with the given 
> source code, so I replaced mine with theirs (CommonFunctions and 
> CommonFunctions.cpp). But when compiling, a new error:
> 
> 
> > $ g++ observer_ptr.cpp -I../.. -losg -losgDB -losgGA -losgText -losgUtil 
> > -losgViewer -o observer_ptr
> > 
> > /tmp/cca0xsAB.o: In function `main':
> > observer_ptr.cpp:(.text+0x79): undefined reference to 
> > `osgCookBook::createText(osg::Vec3f const&, 
> > std::__cxx11::basic_string, 
> > std::allocator > const&, float)'
> > observer_ptr.cpp:(.text+0x103): undefined reference to 
> > `osgCookBook::createHUDCamera(double, double, double, double)'
> > /tmp/cca0xsAB.o:(.data.rel.ro._ZTV18RemoveShapeHandler[_ZTV18RemoveShapeHandler]+0xb8):
> >  undefined reference to 
> > `osgCookBook::PickHandler::handle(osgGA::GUIEventAdapter const&, 
> > osgGA::GUIActionAdapter&)'
> > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x18):
> >  undefined reference to `typeinfo for osgCookBook::PickHandler'
> > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0xb8):
> >  undefined reference to 
> > `osgCookBook::PickHandler::handle(osgGA::GUIEventAdapter const&, 
> > osgGA::GUIActionAdapter&)'
> > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0xe0):
> >  undefined reference to `typeinfo for osgCookBook::PickHandler'
> > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x218):
> >  undefined reference to `typeinfo for osgCookBook::PickHandler'
> > /tmp/cca0xsAB.o:(.data.rel.ro._ZTC18RemoveShapeHandler0_N11osgCookBook11PickHandlerE[_ZTV18RemoveShapeHandler]+0x428):
> >  undefined reference to `typeinfo for osgCookBook::PickHandler'
> > /tmp/cca0xsAB.o:(.data.rel.ro._ZTI18RemoveShapeHandler[_ZTI18RemoveShapeHandler]+0x10):
> >  undefined reference to `typeinfo for osgCookBook::PickHandler'
> > collect2: error: ld returned 1 exit status
> > 
> 
> 
> Can anybody please tell me what am I doing wrong?
> 
> Thank you!
> 
> Cheers,
> Rodrigo



Twirling twirling twirling toward freedom

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





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


Re: [osg-users] Capturing all visible nodes

2019-01-18 Thread Julien Valentin
Hi
You have to setup cullcallbacks of your drawables 

Code:
drawable->setCullCallback(new MyCullCallback);


it then will be called during osgViewer cull traversal...
Cheers



ijwolf8 wrote:
> Hello all,
> 
> I've looked everywhere for this, and have tried to piece together examples 
> I've found online, but I am having no luck accomplishing what conceptually 
> seems like a very simple task.
> 
> The overall goal is to take all nodes within view and send them to UV space 
> for texture mapping. The only part I can't get down is the first 
> part-capturing all visible nodes within view.
> 
> I've read through several posts on this site (removed links because "You must 
> have 2 posts before you can post URL's/Links."), but they all end without a 
> real solution. The last one in particular just confuses me:
> 
> "Just write a NodeVisitor that has it's traversal mode set to 
> TRAVERSE_ALL_CHILDREN i.e. ..."
> 
> But that wasn't the question? It was to get all visible nodes, not ALL nodes?
> 
> Either way, I've attempted to implement these codes and more, but I just 
> don't understand the structure of node visitors and callbacks enough to make 
> progress. For example, one of the posts contained this code that seemed very 
> promising:
> 
> 
> Code:
> 
> class MyCullCallback : public osg::NodeCallback 
> { 
> 
> void operator()(osg::Node* node, osg::NodeVisitor* nv) 
> { 
> // osgUtil::CullVisitor* cv = nv->asCullVisitor(); 
> osgUtil::CullVisitor* cv = dynamic_cast(nv); 
> if (!cv->isCulled(*node)) 
> { 
> std::cout << "Node is visible: "<< endl; 
> } 
> 
> if ( cv->isCulled(*node)) 
> { 
> 
> std::cout << "Node is NOT visible: "< 
> } 
> traverse(node,nv); 
> } 
> }; 
> 
> 
> 
> 
> I tried the following code along with it, but it just throws an error and 
> freezes.
> 
> 
> Code:
> 
>   MyCullCallback* cb = new MyCullCallback();
>   osg::NodeVisitor* nv = new osg::NodeVisitor();
>   //cb->operator()(myGroup, nv);
> 
> 
> 
> 
> So how exactly am I supposed to utilize it? Do I have to initialize 
> NodeVisitor with an initial node? If so which do I chose?
> 
> If there's anymore information I can give please let me know. I've researched 
> all sorts of frustum culling, node visitors, and manually capturing visible 
> nodes with ray tracing, but I figure there has got to be a simpler way to do 
> this!
> 
> Thanks for any and all help,
> 
> Isaac



Twirling twirling twirling toward freedom

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





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


Re: [osg-users] [Any feedback welcome] possible lack of robustness of the VAO path

2019-01-18 Thread Julien Valentin
The following code exibits crashes with VAO path 
 
Code:

#include 
#include 
#include 

#include 
#include 

#include 
#include 


class GeomLoaderCB : public osg::Camera::DrawCallback//  osg::NodeCallback
{
public:
int _thresremoval;int _nbaddedatatime;
GeomLoaderCB(int thresremoval=1,int 
nbaddedatatime=1):_nbaddedatatime(nbaddedatatime),_thresremoval(thresremoval) {}
mutable std::list > _geoms;
void setGeometryList(osgUtil::GeometryCollector::GeometryList c) {
for(auto f : c)
_geoms.push_back(f);
}
virtual void operator () (const osg::Camera&  camera ) const {
osg::Node * node=const_cast()->getChild(0);

if(_geoms.empty())return;
osg::ref_ptr  gr = node->asGroup();

if(gr->getNumChildren()>_thresremoval)
{
OSG_WARN<<"removing "<<  gr->getChild(0) ::iterator it= _geoms.begin();
int cpt=0;
while(it!=_geoms.end()&++<_nbaddedatatime ) {
gr->addChild((osg::Drawable*) 
(*it)->clone(osg::CopyOp::DEEP_COPY_ALL));
OSG_WARN<<"add "<<  (*it ) 
->getVertexArray()->getNumElements()accept(geomcollector);

osg::Group * root=new osg::Group;
//osg::Camera * root=new osg::Camera;
GeomLoaderCB * loader=new 
GeomLoaderCB(geomcountabovewichweremove,geomcountaddedatatime);
loader->setGeometryList(   geomcollector.getGeometryList() );

osgViewer::Viewer viewer;
viewer.addEventHandler(new osgViewer::StatsHandler);
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
viewer.addEventHandler(new osgViewer::ThreadingHandler);

viewer.realize();
viewer.setSceneData( root);

viewer.getCamera()->setFinalDrawCallback(loader);
loaded=0;

viewer.run();
}
}




if you want my test sample:
https://drive.google.com/file/d/0BxIH-jcsgYDdTG5ha21HZE1jX1E/view?usp=sharing
for ex It fails  with args :
BIGCITY.ive --remove 150 --add 100 

I believe there's a bugso I'd be glad if someone validate it...
note: toggling statshandler prevent crash

Thanks in advance
Cheers




mp3butcher wrote:
> Hi all,
> I wrote a sample code exibiting crash with my scene
> https://github.com/openscenegraph/OpenSceneGraph/issues/692
> 
> If you'd have 5 min to waste, i would be glad you confirm with your own 
> scene...
> 
> Thank you!
> 
> Cheers,
> Julien



Twirling twirling twirling toward freedom

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





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


[osg-users] Capturing all visible nodes

2019-01-18 Thread Isaac Wolf
Hello all,

I've looked everywhere for this, and have tried to piece together examples I've 
found online, but I am having no luck accomplishing what conceptually seems 
like a very simple task.

The overall goal is to take all nodes within view and send them to UV space for 
texture mapping. The only part I can't get down is the first part-capturing all 
visible nodes within view.

I've read through several posts on this sight (removed links because "You must 
have 2 posts before you can post URL's/Links.")

But they all end without a real solution. The last one in particular just 
confuses me:

"Just write a NodeVisitor that has it's traversal mode set to 
TRAVERSE_ALL_CHILDREN i.e. ..."

But that wasn't the question? It was to get all visible nodes, not ALL nodes?

Either way, I've attempted to implement these codes and more, but I just don't 
understand the structure of node visitors and callbacks enough to make progress.

For example, one of the posts contained this code that seemed very promising:


Code:

class MyCullCallback : public osg::NodeCallback 
{ 

void operator()(osg::Node* node, osg::NodeVisitor* nv) 
{ 
// osgUtil::CullVisitor* cv = nv->asCullVisitor(); 
osgUtil::CullVisitor* cv = dynamic_cast(nv); 
if (!cv->isCulled(*node)) 
{ 
std::cout << "Node is visible: "<< endl; 
} 

if ( cv->isCulled(*node)) 
{ 

std::cout << "Node is NOT visible: "

[osg-users] Converting an osg::Matrix to osg::PositionAttitudeTransform using decompose?

2019-01-18 Thread Jad Killian
I have a matrix that is constructed as follows:


Code:
osg::Matrix final;
final.preMultScale(inverseParentScale);
final.preMultRotate((worldRotation * inverseWorld).getRotate());
final.preMultScale(parentScale);



What I'm basically trying to do is rotate a child by first calculating a world 
rotation and then converting it to a local rotation by multiplying by the 
inverse world transform. The problem is that if the parent is non-uniformly 
scaled, the result is weirdly sheared. So I thought I would remove the parent 
scale, rotate, then apply the parent scale back, which is what I think the 
above lines do, but please feel free to correct me.

Now what I want is to convert the result to a PositionAttitudeTransform. But 
I'm not getting correct results doing the following:


Code:
osg::Vec3d t, s;
osg::Quat r, so;
final.decompose(t, r, s, so);
_childTransform->setScale(s);
_childTransform->setAttitude(r);



I suspect that the "scale factor" parameter is the issue, since it has non-zero 
values and Im not using them, but I'm not sure what it even is.

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





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