View this page "occlusion result in nvmOSGART"

5 views
Skip to first unread message

sylvi

unread,
Apr 14, 2007, 8:07:56 AM4/14/07
to NAVER based on OSG

Click on http://groups.google.com/group/naver-based-on-osg/web/occlusion-result-in-nvmosgart?hl=en
- or copy & paste it into your browser's address bar if that doesn't
work.

Raphael...@gmail.com

unread,
Nov 11, 2007, 4:19:28 AM11/11/07
to NAVER based on OSG
hello,

I think the problem is coming of the inaccuracy of the tracking and a
bad calibration step. If you are using ARToolKit 2.7, it's probably
not the most accurate solution, you should use either ARToolKit
Professional (commercial license from ARToolWorks), ARToolKitPlus++
(integrate in new version of osgart).
Also you should properly setup your camera, i.e. running a calibration
process (maybe using OpenCV and convert it to a format readable by
ARToolKit, see for that the ARToolKit forum).
Also, maybe a last issue is related to the usage of multi-marker: are
you using multi-marker tracking?


sylvi

unread,
Nov 11, 2007, 8:01:59 AM11/11/07
to NAVER based on OSG
Hi Raphael,

Thank you for your comments.

We use OSGART 1.0. I guess it use ARToolkit 2.7, right?
and we also use multi marker tracking in our application.
I did a callibration on my camera using calib_camera2.exe from
ARToolkit library.

You mentioned about trying another tracking plugin, how can we do
that?
Currently we use osgart_artoolkit_tracker and osgart_artoolkit plugin.

About activating distortion correction for the video,
should we do this in the camera program setting or can we set that
inside OSGART?


Joachim.Svela

unread,
Feb 9, 2008, 10:02:44 PM2/9/08
to NAVER based on OSG
This is fantastic work! I'm trying to create object occlusion myself
using osgart, but find it very difficult. Is there any chance you
could share your sourcecode?

-Joachim

sylvi

unread,
Feb 11, 2008, 3:50:45 AM2/11/08
to NAVER based on OSG
The main idea is simple, we need to draw the occlusion object (e.g.
the stair) only in the depth buffer by using DrawCallback function
from OSG.
We have the 3D model of the stair that has the same size as the real
LEGO stair. At the initialization, we attach a drawcallback function
to the OSG node.
In the drawcallback function, we disable the color buffer of the
specific geode (in this case, the stair). As the result, we can see
the occlusion on the domino by the stair.

Here is the part of the source code used to generate the object
occlusion.
class DrawableOcclusionDrawCallback : public
osg::Drawable::DrawCallback
{
public:
//...
virtual void drawImplementation(
osg::State& state,const osg::Drawable* drawable) const
{
glPushAttrib(GL_COLOR_BUFFER_BIT);
//disable color buffer
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
drawable->drawImplementation(state);
glPopAttrib();
}
};


class InsertOcclusionCallbacksVisitor : public osg::NodeVisitor
{
public:
...
virtual void apply(osg::Node& node) { traverse(node); }
virtual void apply(osg::Geode& geode)
{
for(unsigned int i=0;i<geode.getNumDrawables();++i)
{
geode.getDrawable(i)->setDrawCallback(new
rawableOcclusionDrawCallback());
}
}

virtual void apply(osg::Transform& node)
{ apply((osg::Node&)node); }
};

int main()
{
//initialization
if (isOcclusionNode(modelTransform))
{
InsertOcclusionCallbacksVisitor
icv=InsertOcclusionCallbacksVisitor() ;
modelTransform->accept(icv);
}

//...
}

Joachim.Svela

unread,
Feb 13, 2008, 11:05:26 AM2/13/08
to NAVER based on OSG
Thank you very, very much for your help!

I have been working for weeks with getting the occlusion to work, and
at last someone has pointed me in the right direction!
I am trying to develop an open-source software for architect-students
(like myself) to be able to work with AR easily.
If you like, you can follow my project (ARive) at www.formbureauet.com

-I will credit you for the help you have given me, and if you come to
Norway, you can get some wine at the release party! (If I get that
far) ;-)

I have one more question:

With the above code, how do I specify what model (GEODE?) to occlude?

-I have seen in another post here that you use XML to load your model-
file, and can define it there, but I am basing my application on
osgart_simple, so i do not know how to do that.
Just beginning to learn C++

Many thanks for your help,
Joachim

sylvi

unread,
Feb 17, 2008, 5:59:41 AM2/17/08
to NAVER based on OSG

Hi,

In my case, I use XML to specify which model to occlude. We develop a
NAVER library that can be used to develop VR and AR application. it
consists of several modules which can be configured through XML
configuration file.

In your case, I think you can put it inside the main() function.

For example:

int main()
{
....
//initialization

osg::Node* modelNode = osgDB::readNodeFile(name);
osg::Matrix modelScale;
osg::Matrix modelTranslate;
osg::Matrix modelRot;

osg::MatrixTransform* osgTransform = new osg::MatrixTransform;
osgTransform->setMatrix( modelScale * modelRot * modelTranslate );
osgTransform->addChild(modelNode);

InsertOcclusionCallbacksVisitor icv =
InsertOcclusionCallbacksVisitor() ;
osgTransform->accept(icv);

while ()
{

}

}


In the example above, we set the callback function for osgTransform
node. As the result, modelNode (which is the child of osgTransform)
will only be rendered in the depth buffer.

I hope this can answer your question.

sylvi

In the example above
Reply all
Reply to author
Forward
0 new messages