Re: [osg-users] Sync main camera with slave camera rotation

2016-04-05 Thread Jannik Heller
Hi,

The camera manipulator (which sets the main camera's view matrix) is updated at 
the end of the update traversal. So, you need to make sure your sync code runs 
after the update traversal and not before - else you'll be working with the 
last frame's data which is probably what's introducing the flicker.

Something like this should work. There may be a more elegant solution.

// instead of mViewer->frame(); syncCamera(); :

mViewer->eventTraversal();
mViewer->updateTraversal();
syncCamera();
mViewer->renderingTraversals();

Cheers,
Jannik

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





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


Re: [osg-users] PolytopeVisitor's sample

2016-04-05 Thread François Cami
Hi,

On Tue, Apr 5, 2016 at 11:56 AM, yusuke morikawa  wrote:
> Hello
>
> I am looking for a sample program of PolytopeVisitor in order to select 
> plural objects( a group of points) inside the rectangular region according to 
> the mouse rectangular selection.
> My OSG version is 3.2.1.  I am looking forward to receiving a good reply.

I don't know what you mean by "a good reply" :)

I've quickly adapted the PickingMain.cpp example from the Quick Start
Guide to be able to select (lower left to upper right) the left cow,
the right cow, or both, by using
osgUtil::PolytopeIntersector::getIntersections() instead of
osgUtil::PolytopeIntersector::getFirstIntersection().

Start reading line 236:
https://github.com/fcami/osgqsg/blob/master/Examples/Picking/RectangularPickingMain.cpp

I'm using OpenSceneGraph 3.4.0 but the code should work with 3.2.1.

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


[osg-users] Error when trying to draw text with Qt

2016-04-05 Thread Bruno Oliveira
Hello,

I have a QGLWidget that wrappes a osg::Viewer, and I am trying to render
text with Qt API as follows

glPushMatrix();
   qglColor(Qt::white);
renderText(10, 10, "Ola" );
glPopMatrix();

This is called inside the widget's paintEvent

After this is called, the following warning shows up:


*Warning: detected OpenGL error 'stack overflow' at after
RenderBin::draw(..)*

What could be wrong here?
Thank you
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Sync main camera with slave camera rotation

2016-04-05 Thread Bruno Oliveira
Hello,

I have an osg::Viewer with a regular camera, and now I added a slave camera
to that viewer. The main camera is controlled by a TrackballManipulator.

Now I would like to sync the rotation of both cameras, i.e., when I
manipulate the main camera with the mouse, I want to apply the same
rotation (ROTATION ONLY!) to the slave camera.

This is how I am doing it:

osg::Matrixd mat = osg::Matrixd::identity();
osg::Quat rot = m_mainCamera->getViewMatrix().getRotate();

m_slaveCamera->setViewMatrix(mat.rotate(rot));


But this does not work very well as it introduces some flicker. How should
this be done correctly?
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [build] using 3Ds Model in osgFX::BumpMapping and the Texture UV Coords for diffuse are not loaded

2016-04-05 Thread Christian Buchner
> I implemented the OSG BumpMap with no need to use shaders, as follow:
> osgFX::BumpMapping* bump_mapping = new osgFX::BumpMapping();

Hmm, by default this osgFX effect module will use shaders according to its
documentation:

"This effect defines a preferred technique which uses ARB vertex & fragment
programs, and a fallback technique which doesn't use fragment programs."

ARB fragment and vertex programs are some of the oldest types of
programmable shaders.

Christian


2016-04-04 18:12 GMT+02:00 Tiago Trocoli :

> Hi Tobias
>
> I implemented the OSG BumpMap with no need to use shaders, as follow:
>
> function source
>
>
> Code:
>
> void bumpMapOSG(osg::Geode *geode, osg::Group *group, osg::Image
> *normal_image, osg::Image *difuse_image, double scale_x,
> double scale_y) {
>
> if (!normal_image || !difuse_image) {
> std::cout << "IMAGE FAIL" << std::endl;
> exit(0);
> }
>
> osg::StateSet* bumpState = new osg::StateSet();
>
> // Set textures
> osg::ref_ptr normal_texture(new osg::Texture2D());
> osg::ref_ptr difuse_texture(new osg::Texture2D());
>
> normal_texture->setImage(normal_image);
> normal_texture->setDataVariance(osg::Object::DYNAMIC);
> normal_texture->setFilter(osg::Texture::MIN_FILTER,
> osg::Texture::LINEAR_MIPMAP_LINEAR);
> normal_texture->setFilter(osg::Texture::MAG_FILTER,
> osg::Texture::LINEAR);
> normal_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
> normal_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
> normal_texture->setResizeNonPowerOfTwoHint(false);
> normal_texture->setMaxAnisotropy(8.0f);
>
> difuse_texture->setImage(difuse_image);
> difuse_texture->setDataVariance(osg::Object::DYNAMIC);
> difuse_texture->setFilter(osg::Texture::MIN_FILTER,
> osg::Texture::LINEAR_MIPMAP_LINEAR);
> difuse_texture->setFilter(osg::Texture::MAG_FILTER,
> osg::Texture::LINEAR);
> difuse_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
> difuse_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
> difuse_texture->setResizeNonPowerOfTwoHint(false);
> difuse_texture->setMaxAnisotropy(8.0f);
>
> const int TEXTURE_UNIT_NORMAL = 1;
> const int TEXTURE_UNIT_DIFUSE = 2;
>
> bumpState->setTextureAttributeAndModes(TEXTURE_UNIT_NORMAL,
> normal_texture, osg::StateAttribute::ON);
> bumpState->setTextureAttributeAndModes(TEXTURE_UNIT_DIFUSE,
> difuse_texture, osg::StateAttribute::ON);
>
> osg::ref_ptr geometry =
> geode->asGeode()->getDrawable(0)->asGeometry();
> osg::Vec2Array* tex_coord =
> dynamic_cast(geometry->getTexCoordArray(0));
>
> for (unsigned int i = 0; i < tex_coord->getNumElements(); ++i)
> (*tex_coord)[i].set((*tex_coord)[i].x() * scale_x,
> (*tex_coord)[i].y() * scale_y);
>
> geometry->setStateSet(bumpState);
> if (tex_coord) {
> geometry->setTexCoordArray(TEXTURE_UNIT_NORMAL, tex_coord);
> geometry->setTexCoordArray(TEXTURE_UNIT_DIFUSE, tex_coord);
> } else {
> std::cout << "MISS TEXTURE COORDINATE " << std::endl;
> exit(0);
> }
>
> osgFX::BumpMapping* bump_mapping = new osgFX::BumpMapping();
> bump_mapping->setEnabled(true);
> bump_mapping->setLightNumber(0);
> bump_mapping->setNormalMapTextureUnit(TEXTURE_UNIT_NORMAL);
> bump_mapping->setDiffuseTextureUnit(TEXTURE_UNIT_DIFUSE);
> bump_mapping->addChild(geode);
> bump_mapping->prepareChildren();
> group->addChild(bump_mapping);
>
> }
> [\code]
>
>
>
> Thank you!
>
> Cheers,
> Tiago
>
>
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=66724#66724
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] how to integrate osg with QT5.6 on VS2015

2016-04-05 Thread Andrew Cunningham
Great tip! I had no idea about that one.

Thanks!

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





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


[osg-users] DatabasePager Crash

2016-04-05 Thread Jeff White
I am running a osgEarth-based (v2.7) application that uses OpenSceneGraph 3.4.0 
built with mingw (gcc v.4.9.2).  When I am running in cache-only mode on some 
machines I am seeing a crash in the osgDB::DatabasePager class. I have seen 
some traffic in the past related to DatabasePager issues so I figured it would 
be worth asking on here.  It is crashing on a OSG info log statement which 
seems strange.  It looks like it is trying to iterate over an empty container.  
Has anyone seen this behavior before?  My OSG_NUM_DATABASE_THREADS are set to 4 
and the machine it crashes on has 8 cores.  I tried setting the value to 8 and 
still got the same result.


 Here is the call stack along with some information from GDB:

(gdb) info threads
  Id   Target Id Frame
  18   Thread 8804.0x1ce8 0x77dd1f86 in ntdll!ZwWaitForWorkViaWorkerFactory () 
from C:\Windows\SysWOW64\ntdll.dll
  17   Thread 8804.0x1738 0x77dd019d in ntdll!ZwWaitForMultipleObjects () from 
C:\Windows\SysWOW64\ntdll.dll
  16   Thread 8804.0x210c 0x77dd019d in ntdll!ZwWaitForMultipleObjects () from 
C:\Windows\SysWOW64\ntdll.dll
  15   Thread 8804.0x213c 0x61d50a0a in 
std::_List_const_iterator::operator++ 
(this=0x54bbfd10)
at C:/Qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/bits/stl_list.h:244
* 14   Thread 8804.0x18e8 0x77dd019d in ntdll!ZwWaitForMultipleObjects () from 
C:\Windows\SysWOW64\ntdll.dll
  13   Thread 8804.0x15e8 0x77dd019d in ntdll!ZwWaitForMultipleObjects () from 
C:\Windows\SysWOW64\ntdll.dll
  12   Thread 8804.0x1dd0 0x77dd019d in ntdll!ZwWaitForMultipleObjects () from 
C:\Windows\SysWOW64\ntdll.dll
  7Thread 8804.0x1e98 0x77dd019d in ntdll!ZwWaitForMultipleObjects () from 
C:\Windows\SysWOW64\ntdll.dll
  5Thread 8804.0x1d48 0x77dcfdd1 in ntdll!ZwDelayExecution () from 
C:\Windows\SysWOW64\ntdll.dll
  4Thread 8804.0x910 0x77dd1f86 in ntdll!ZwWaitForWorkViaWorkerFactory () 
from C:\Windows\SysWOW64\ntdll.dll
  3Thread 8804.0x2190 0x77dd1f86 in ntdll!ZwWaitForWorkViaWorkerFactory () 
from C:\Windows\SysWOW64\ntdll.dll
  2Thread 8804.0xb14 0x77dd019d in ntdll!ZwWaitForMultipleObjects () from 
C:\Windows\SysWOW64\ntdll.dll
  1Thread 8804.0x3ac 0x77de805d in ntdll!RtlGetNtGlobalFlags () from 
C:\Windows\SysWOW64\ntdll.dll
(gdb) thread 15
[Switching to thread 15 (Thread 8804.0x213c)]
#0  0x61d50a0a in std::_List_const_iterator::operator++ (this=0x54bbfd10)
at C:/Qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/bits/stl_list.h:244
244 C:/Qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/bits/stl_list.h: 
No such file or directory.
(gdb) bt
#0  0x61d50a0a in std::_List_const_iterator::operator++ (this=0x54bbfd10)
at C:/Qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/bits/stl_list.h:244
#1  0x61d8a093 in 
std::__distance > 
(__first=..., __last=...)
at 
C:/Qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/bits/stl_iterator_base_funcs.h:82
#2  0x61d9740c in 
std::distance > 
(__first=..., __last=...)
at 
C:/Qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/bits/stl_iterator_base_funcs.h:118
#3  0x61d3e48c in std::list >::size (this=0x3b905d7c)
at C:/Qt/Tools/mingw492_32/i686-w64-mingw32/include/c++/bits/stl_list.h:887
#4  0x61cd828c in osgDB::DatabasePager::DatabaseThread::run (this=0x3c3285a0)
at 
C:\msys\1.0\home\MWoodJ\Projects\OSG\OpenSceneGraph-3.4.0\src\osgDB\DatabasePager.cpp:731
#5  0x66a08538 in OpenThreads::ThreadPrivateActions::StartThread(void*)@4 
(data=0x3c3285ac)
at 
C:\msys\1.0\home\MWoodJ\Projects\OSG\OpenSceneGraph-3.4.0\src\OpenThreads\win32\Win32Thread.cpp:113
#6  0x77131287 in msvcrt!_itow_s () from C:\Windows\syswow64\msvcrt.dll
#7  0x77131328 in msvcrt!_endthreadex () from C:\Windows\syswow64\msvcrt.dll
#8  0x7757336a in KERNEL32!BaseThreadInitThunk () from 
C:\Windows\syswow64\kernel32.dll
#9  0x77de9882 in ntdll!RtlInitializeExceptionChain () from 
C:\Windows\SysWOW64\ntdll.dll
#10 0x77de9855 in ntdll!RtlInitializeExceptionChain () from 
C:\Windows\SysWOW64\ntdll.dll
#11 0x in ?? ()


(gdb) frame 4
#4  0x61cd828c in osgDB::DatabasePager::DatabaseThread::run (this=0x3c3285a0)
at 
C:\msys\1.0\home\MWoodJ\Projects\OSG\OpenSceneGraph-3.4.0\src\osgDB\DatabasePager.cpp:731
731 
C:\msys\1.0\home\MWoodJ\Projects\OSG\OpenSceneGraph-3.4.0\src\osgDB\DatabasePager.cpp:
 No such file or directory.


(gdb) info locals
fileLocationCallback = {_ptr = 0x0}
databaseRequest = {_ptr = 0x0}
readFromFileCache = false
fileCache = {_ptr = 0x0}
dr_loadOptions = {_ptr = 0x0}
fileName = {static npos = ,
  _M_dataplus = { = {<__gnu_cxx::new_allocator> = 
{}, },
_M_p = 0x3ab7e0c4 "î_î_î_î_î_î_î_î_î_î_L\033¿\b"}}
frameNumberLastRequest = 0
cacheNodes = false
firstTime = false
read_queue = {_ptr = 0x3b905d40}
out_queue = {_ptr = 0x3b923cf8}



(gdb) print 

Re: [osg-users] [build] using 3Ds Model in osgFX::BumpMapping and the Texture UV Coords for diffuse are not loaded

2016-04-05 Thread Tiago Trocoli
Hi Tobias

I implemented the OSG BumpMap with no need to use shaders, as follow:

function source


Code:
 
void bumpMapOSG(osg::Geode *geode, osg::Group *group, osg::Image *normal_image, 
osg::Image *difuse_image, double scale_x,
double scale_y) {

if (!normal_image || !difuse_image) {
std::cout << "IMAGE FAIL" << std::endl;
exit(0);
}

osg::StateSet* bumpState = new osg::StateSet();

// Set textures
osg::ref_ptr normal_texture(new osg::Texture2D());
osg::ref_ptr difuse_texture(new osg::Texture2D());

normal_texture->setImage(normal_image);
normal_texture->setDataVariance(osg::Object::DYNAMIC);
normal_texture->setFilter(osg::Texture::MIN_FILTER, 
osg::Texture::LINEAR_MIPMAP_LINEAR);
normal_texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
normal_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
normal_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
normal_texture->setResizeNonPowerOfTwoHint(false);
normal_texture->setMaxAnisotropy(8.0f);

difuse_texture->setImage(difuse_image);
difuse_texture->setDataVariance(osg::Object::DYNAMIC);
difuse_texture->setFilter(osg::Texture::MIN_FILTER, 
osg::Texture::LINEAR_MIPMAP_LINEAR);
difuse_texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
difuse_texture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
difuse_texture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
difuse_texture->setResizeNonPowerOfTwoHint(false);
difuse_texture->setMaxAnisotropy(8.0f);

const int TEXTURE_UNIT_NORMAL = 1;
const int TEXTURE_UNIT_DIFUSE = 2;

bumpState->setTextureAttributeAndModes(TEXTURE_UNIT_NORMAL, normal_texture, 
osg::StateAttribute::ON);
bumpState->setTextureAttributeAndModes(TEXTURE_UNIT_DIFUSE, difuse_texture, 
osg::StateAttribute::ON);

osg::ref_ptr geometry = 
geode->asGeode()->getDrawable(0)->asGeometry();
osg::Vec2Array* tex_coord = 
dynamic_cast(geometry->getTexCoordArray(0));

for (unsigned int i = 0; i < tex_coord->getNumElements(); ++i)
(*tex_coord)[i].set((*tex_coord)[i].x() * scale_x, (*tex_coord)[i].y() 
* scale_y);

geometry->setStateSet(bumpState);
if (tex_coord) {
geometry->setTexCoordArray(TEXTURE_UNIT_NORMAL, tex_coord);
geometry->setTexCoordArray(TEXTURE_UNIT_DIFUSE, tex_coord);
} else {
std::cout << "MISS TEXTURE COORDINATE " << std::endl;
exit(0);
}

osgFX::BumpMapping* bump_mapping = new osgFX::BumpMapping();
bump_mapping->setEnabled(true);
bump_mapping->setLightNumber(0);
bump_mapping->setNormalMapTextureUnit(TEXTURE_UNIT_NORMAL);
bump_mapping->setDiffuseTextureUnit(TEXTURE_UNIT_DIFUSE);
bump_mapping->addChild(geode);
bump_mapping->prepareChildren();
group->addChild(bump_mapping);

}
[\code]



Thank you!

Cheers,
Tiago



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





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


[osg-users] Draw trackball (sphere with constant radius)

2016-04-05 Thread Bruno Oliveira
Hello,

I have a osg::viewer instance which I manipulate using
TrackballManipulator. I would like to draw the trackball sphere, which
cannot be done with this code because this sphere will be rescaled
everytime I scale my scene view using the mouse wheel:


m_rootNode = new osg::Group();

// Add trackball sphere
osg::ref_ptr trackSphere = new osg::Sphere(
osg::Vec3(0,0,0), m_manipulator->getTrackballSize());
osg::ref_ptr trackSphereDrawable = new
osg::ShapeDrawable(trackSphere);
osg::ref_ptr trackSphereGeode = new osg::Geode();
trackSphereGeode->addDrawable(trackSphereDrawable);

m_rootNode->addChild(trackSphereGeode);


How can I draw a trackball sphere that keeps its size in the window even
when I rescale my scene?
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] PolytopeVisitor's sample

2016-04-05 Thread yusuke morikawa
Hello

I am looking for a sample program of PolytopeVisitor in order to select plural 
objects( a group of points) inside the rectangular region according to the 
mouse rectangular selection. 
My OSG version is 3.2.1.  I am looking forward to receiving a good reply.

Thank you!

Cheers,
yusuke

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





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


[osg-users] applying BVH motion to a model?

2016-04-05 Thread Christian Buchner
Hi

I am able to load BVH motion captures into OSG and I have generated a
nicely looking male model with a matching skeleton with MakeHuman 1.1.0 rc2
as an FBX model.

The BVH import plug-in generates a subgraph made of osgAnimation nodes
representing the bone hierarchy and their transformations.

A similar skeleton graph graph is also found in the loaded FBX model's
subgraph, except that it's also tied to various drawables of the model
through vertex weights.

I was wondering what the most efficient way might be to transfer motion
from the BVH graph in the the FBX graph. Doing this via update callbacks in
every frame might be a bit expensive, CPU-wise (it's almost 40 bones).

I was wondering if it is possible to tie the animation data channels from
the BVH subgraph directly to the FBX model somehow.

Has anyone else faced the challenge of copying motion information from one
model to another?

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


Re: [osg-users] how to integrate osg with QT5.6 on VS2015

2016-04-05 Thread Alistair Baxter
Actually, you ought to be able to achieve the same effect (forcing desktop 
OpenGL) by calling the static method

QApplication::setAttribute(Qt::AA_UseDesktopOpenGL, true);

Before you create your QApplication instance.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org