Discussion:
No intersection on some osg models
Petr Svoboda
2014-03-25 20:25:58 UTC
Permalink
Hi,

I have a very weird problem.
I downloaded some models from Sketchup warehouse, exported as OBJ format and then converted using osgconv to OSG format.

Now, when I use osgUtil::LineSegmentIntersector then on some models "there is" an intersection detected on others there is not. Why is that?
Is there a need of creating some bounding boxes or something like that? Or some osgconv bug? Model bug?

Thank you!

Cheers,
Petr

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=58730#58730
Sebastian Messerschmidt
2014-03-25 21:22:56 UTC
Permalink
Hi Petr,
Post by Petr Svoboda
Hi,
I have a very weird problem.
I downloaded some models from Sketchup warehouse, exported as OBJ format and then converted using osgconv to OSG format.
Could you please provide an example?
Post by Petr Svoboda
Now, when I use osgUtil::LineSegmentIntersector then on some models "there is" an intersection detected on others there is not. Why is that?
Is there a need of creating some bounding boxes or something like that? Or some osgconv bug? Model bug?
How are you using the IntersectionVisitor? Providing an example model
plus the code you are using would give us the means helping you.

cheers
Sebastian
Post by Petr Svoboda
Thank you!
Cheers,
Petr
------------------
http://forum.openscenegraph.org/viewtopic.php?p=58730#58730
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Petr Svoboda
2014-03-25 22:25:14 UTC
Permalink
Post by Sebastian Messerschmidt
Hi Petr,
Post by Petr Svoboda
Hi,
I have a very weird problem.
I downloaded some models from Sketchup warehouse, exported as OBJ format and then converted using osgconv to OSG format.
Could you please provide an example?
Post by Petr Svoboda
Now, when I use osgUtil::LineSegmentIntersector then on some models "there is" an intersection detected on others there is not. Why is that?
Is there a need of creating some bounding boxes or something like that? Or some osgconv bug? Model bug?
How are you using the IntersectionVisitor? Providing an example model
plus the code you are using would give us the means helping you.
cheers
Sebastian
Post by Petr Svoboda
Thank you!
Cheers,
Petr
------------------
http://forum.openscenegraph.org/viewtopic.php?p=58730#58730
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
------------------
Post generated by Mail2Forum
In my scene there are objects:

Code:
osg::Node* m_tv = osgDB::readNodeFile( "external/models/television.osg" );
m_tv->setName("television");
if(!m_tv)
{
std::cout << "Error: Couldn't find model!" << std::endl;
}

osg::ref_ptr<MyObject> television = new TV(this);
television->insertChild(0,m_tv);
television->setName("television");

//MyObject is abstract and it's basically PositionAttitudeTransform




Then I'm looking for intersection with these objects/models

Code:

//some inits etc...

//basic idea is that some of these objects which I'm interested in have names as identifications getName("television") etc.. and I'm looking for them

osgUtil::LineSegmentIntersector::Intersections& intersections = ins->getIntersections();

if ( !ins->containsIntersections() ) return std::string("");
for ( it = intersections.begin() ; it != intersections.end(); ++it )
{
for ( path_it = it->nodePath.rbegin(); path_it != it->nodePath.rend(); ++path_it)
{
MyObject* temp = dynamic_cast<MyObject*>(*path_it);
if ( temp == 0 ) continue;
if ( (*path_it)->getName() != "" ) //if my objects "of interest" has a name
{
cdloc = it->getWorldIntersectPoint();
return (*path_it)->getName(); //returning identification (name) od object
}
}
}




All of objects in the scene are downloaded from SketchUp Warehouse to SketchUp application. Because of some "non compatible" format of models I export them from SketchUp application as OBJ files.

Then using osgconv to convert them to OSG files.

The interesting part is that when I use different object for television, so in code

Code:

osg::Node* m_tv = osgDB::readNodeFile( "external/models/radio_model.osg" );
instead of
osg::Node* m_tv = osgDB::readNodeFile( "external/models/television.osg" )




Then there is no Intersection collision detected or in other worlds


Code:

if ( (*path_it)->getName() != "" ) //if my objects "of interest" has a name
{
cdloc = it->getWorldIntersectPoint();
return (*path_it)->getName(); //returning identification (name) od object
}
else return "";



this piece of code wont ever return other string then "".

I tried like 5 models, all the same way -> downloaded from Sketchup, exported, converted, same code just different model.. Some of them worked (intersection collision returned their identification via getName() ) some of them not.
I hope I explained it clearly

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=58732#58732
Alistair Baxter
2014-03-26 09:45:15 UTC
Permalink
There are some collision issues with LineSegmentIntersector in OSG 3.2.0 and before. The trunk version of LineSegmentIntersector.cpp contains the fix, and 3.2.1, 3.3.0 and 3.3.1 releases ought to have the fix in.

Alistair Baxter
Software Engineer
________________________________
We'll be exhibiting at PDAC 2014 from booth #1607, 2nd - 5th March 2014.
For further information please visit http://www.mve.com/calendar

Midland Valley Exploration Ltd.
144 West George Street
Glasgow G2 2HG
United Kingdom
Tel: +44 (0) 141 332 2681
Fax: +44 (0) 141 332 6792
The structural geology experts


-----Original Message-----
From: osg-users-bounces-***@public.gmane.org [mailto:osg-users-bounces-***@public.gmane.org] On Behalf Of Petr Svoboda
Sent: 25 March 2014 20:26
To: osg-users-***@public.gmane.org
Subject: [osg-users] No intersection on some osg models

Hi,

I have a very weird problem.
I downloaded some models from Sketchup warehouse, exported as OBJ format and then converted using osgconv to OSG format.

Now, when I use osgUtil::LineSegmentIntersector then on some models "there is" an intersection detected on others there is not. Why is that?
Is there a need of creating some bounding boxes or something like that? Or some osgconv bug? Model bug?

Thank you!

Cheers,
Petr

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=58730#58730
Petr Svoboda
2014-03-27 23:19:54 UTC
Permalink
Post by Sebastian Messerschmidt
Hi Petr,
Post by Petr Svoboda
Hi,
I have a very weird problem.
I downloaded some models from Sketchup warehouse, exported as OBJ format and then converted using osgconv to OSG format.
Could you please provide an example?
Post by Petr Svoboda
Now, when I use osgUtil::LineSegmentIntersector then on some models "there is" an intersection detected on others there is not. Why is that?
Is there a need of creating some bounding boxes or something like that? Or some osgconv bug? Model bug?
How are you using the IntersectionVisitor? Providing an example model
plus the code you are using would give us the means helping you.
cheers
Sebastian
Post by Petr Svoboda
Thank you!
Cheers,
Petr
------------------
http://forum.openscenegraph.org/viewtopic.php?p=58730#58730
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
------------------
Post generated by Mail2Forum
Ok, so I found out, that intersection work when I load model like this
osg::Node* m_radio = osgDB::readNodeFile( "external/models/rad.obj" );
m_radio->setName("radio");
//MyObject is PossitionAttitudeTransform and it is abstract class
osg::ref_ptr<MyObject> radio = new Radio(this);
radio->insertChild(0,m_radio);
radio->setName("radio");
radio->setScale( osg::Vec3d(3,3,3));
radio->setAttitude( osg::Quat( osg::DegreesToRadians(-90.0), osg::Vec3(1,0,0)) );
radio->setPosition( osg::Vec3(-5.5,7,38));
This you can see on attachment 1.png
the important part for me is
radio->setAttitude( osg::Quat( osg::DegreesToRadians(-90.0), osg::Vec3(1,0,0))) );
because when I make rotate radio object by 35 degrees around Y like this
radio->setAttitude( osg::Quat( osg::DegreesToRadians(-90.0), osg::Vec3(1,0,0)) * osg::Quat( osg::DegreesToRadians(35.0), osg::Vec3(0,1,0) ) );
as you can see on picture 2.png
Then it is very hard to find a place on model where would that 4-quarters circle appear (you can see on 1.png) - meaning that there is a intersection with that model.
Intersection is just
for ( it = intersections.begin() ; it != intersections.end(); ++it )
{
for ( path_it = it->nodePath.rbegin(); path_it != it->nodePath.rend(); ++path_it)
{
MyObject* temp = dynamic_cast<MyObject*>(*path_it);
if ( temp == 0 ) continue;
if ( (*path_it)->getName() != "" )
{
cdloc = it->getWorldIntersectPoint();
return (*path_it)->getName();
}
}
}
where I basically looking for MyObjects with names ( identification ).
Also, I'm bit confused with that setAttitude function. Is that the right way how to rotate objects? Because when I call this function on an object, it changes its coordinate system and then setPosition makes an object appers (in world coord system) where I didnt expect it ( for example X and Z axes are switched ). Maybe I should start with this basic question :D
Thank you
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=58750#58750

Loading...