Re: [osg-users] about the cull mechanism in osg

2012-10-19 Thread Zhiyu Liu
hi xiexing:
osg offer the frustum culling and  you can set the Culling Mode , also if
you want to realize customer culling function please look the
osgUtil::CullVisitor

Liu zhiyu

2012/10/19 wh_xiexing wh_xiex...@sina.com

 **
 dear friends:

  i am newbie . my question is , i have a group which contains a
 lot a gode.  in order to speed the rendering .  i don't know whether i need
 to write a  cull callback .  or do nothing and let the osg system do the
 culling work instead .  does osg automatically traverse the group and  cull
 the node which lay out the frustum ???


 Shawl

 ___
 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] osgFX::Outline implementation for OpenGL ES?

2012-10-19 Thread Filip Arlet
Hi,

osgFX wont help in this case, but I think MatrixTransform or 
PositionAttitudeTranform (preffered) can do scaling, or second camera, at 
closer z position.

Cheers,
Filip

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





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


Re: [osg-users] osgQt::GraphicsWindowQt parent parameter

2012-10-19 Thread Gianni Ambrosio
Hi,
there may be a bug in osgQt::GraphicsWindowQt(osg::GraphicsContext::Traits* 
traits, QWidget* parent = NULL, const QGLWidget* shareWidget = NULL, 
Qt::WindowFlags f = 0) constructor.

Anyway I solved as follows: basically using the other GraphicsWindowQt 
constructor available and creating a GLWidget from my own (so that I can also 
use the forwardKeyEvents parameter otherwise impossible to set).

Here is the code:

Code:
QGLFormat format = osgQt::GraphicsWindowQt::traits2qglFormat(traits);
osgQt::GLWidget* glwidget = new osgQt::GLWidget(format, this, 0, 0, true);
camera-setGraphicsContext(new osgQt::GraphicsWindowQt(glwidget));




Gianni

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





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


[osg-users] Problem with picking a manipulator in a HUD

2012-10-19 Thread Kristofer Tingdahl
Hi all,

I am trying to get a Dragger on my HUD display, but I am not able to
manipulate it at all. If I add it the identical dragger to the normal
scene, it works as expected. Any insight in this is appreciated as I have
reached the end of trying to traverse the scene trying to gain
understanding in this matter.


- Kristofer

-- 
Kristofer Tingdahl, Ph. D.
dGB Earth Sciences
/*+
 * (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
 * AUTHOR   : Kristofer Tingdahl
 * DATE : May 2000
-*/


#include QtGui/QApplication

#include osgViewer/Viewer
#include osgGA/TrackballManipulator
#include osgQt/GraphicsWindowQt

#include osg/ShapeDrawable
#include osg/MatrixTransform
#include osgManipulator/TabBoxDragger


int main( int argc, char** argv )
{
QApplication app(argc, argv);
osgQt::initQtWindowingSystem();

osg::Group* sceneroot = new osg::Group;
osg::Camera* hudcamera = new osg::Camera;

sceneroot-addChild( hudcamera );
hudcamera-setReferenceFrame(osg::Transform::ABSOLUTE_RF);
hudcamera-setViewMatrix(osg::Matrix::identity());
hudcamera-setClearMask(GL_DEPTH_BUFFER_BIT);
hudcamera-setRenderOrder(osg::Camera::POST_RENDER);
hudcamera-setAllowEventFocus(false);
hudcamera-setName(HUD Camera );

osg::Matrix mat;
mat.makeTranslate( 200, 200, -200 );
mat.preMult( osg::Matrix::scale( 200, 200, 200 ) );

osgManipulator::TabBoxDragger* tbd = new osgManipulator::TabBoxDragger;
hudcamera-addChild( tbd );
tbd-setupDefaultGeometry();
tbd-setMatrix( mat );
tbd-setHandleEvents( true );

osg::Geode* geode = new osg::Geode;
geode-addDrawable( new osg::ShapeDrawable(new osg::Box) );
sceneroot-addChild( geode );

osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer;
viewer-setSceneData( sceneroot );
viewer-setCameraManipulator( new osgGA::TrackballManipulator );
osgQt::setViewer( viewer.get() );

osgQt::GLWidget* glw = new osgQt::GLWidget;
osgQt::GraphicsWindowQt* graphicswin = new osgQt::GraphicsWindowQt( glw );
hudcamera-setProjectionMatrix(osg::Matrix::ortho2D(0,glw-width(),0,glw-height()));

viewer-getCamera()-setViewport( new osg::Viewport(0, 0, glw-width(), glw-height() ) );
viewer-getCamera()-setGraphicsContext( graphicswin );

glw-show();

return app.exec();
}
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Can we add Viewer::setSkipCloseWindowEvent to prevent Window from being closed upon receiving CLOSE_WINDOW?

2012-10-19 Thread michael kapelko
Hi.
I've looked at the code (OSG 3.0.1) of Viewer::eventTraversal and
noticed that it checks for CLOSE_WINDOW event and closes the window,
so there's no way to prevent the window from closing. I've googled for
window close prevention with no luck, too.
Can we add something like Viewer::setSkipCloseWindowEvent to OSG?
Thanks.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] question about Optimizer and FLATTEN_STATIC_TRANSFORMS

2012-10-19 Thread Michael Schanne
Hi,

I have a model that I converted from an .stl file to .osg.  I wanted to apply a 
scaling to the model, so I added a MatrixTransform with a scaling matrix above 
the model's root node.  For maximum efficiency I wanted to apply the transform 
directly to the vertices, so I tried to run the .osg file through osgconv a 
second time, with the OSG_OPTIMIZER env variable set to 
FLATTEN_STATIC_TRANSFORMS.  However, the new file was identical to the previous 
file, with the parent MatrixTransform still in place.  I set the DataVariance 
of the transform to STATIC, and it had no effect.  Is there something else that 
could interfere with the Optimizer flattening the transform, or am I expecting 
FLATTEN_STATIC_TRANSFORMS to do something that it's not intended to do?

... 

Thank you!

Cheers,
Michael

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





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


[osg-users] vsync under qt

2012-10-19 Thread Roman Grigoriev
Hi,
tried to set  under qt window
traits-vsync=true;
but in doesn't work 
How can I enable vsync?

Thank you!

Cheers,
Roman

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





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


[osg-users] copying contents of osg::Group to rendered Group

2012-10-19 Thread Joe Doob
Hi all.

I have two osg::Groups, one which is being rendered in my viewer and another 
which is used as a buffer that collects geodes as they are created.

Periodically, I want to flush the contents of my root group and copy over all 
the contents in the buffer.

I have tried several methods of copying the contents of the buffer group to the 
root group, but I never actually see the new contents appear in my view. 
Specifically I have tried looping over all children in the buffer and calling 
root-addChild on each of these. I have also tried assigning the root to a deep 
copy clone of the buffer. In both cases I can verify that the root contains the 
data in the buffer using getNumChildren(), but they never show up.

Does anyone know why this would be? Or, am I just going about this the wrong 
way?

Thanks,
S

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





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


Re: [osg-users] vsync under qt

2012-10-19 Thread Gianni Ambrosio
Hi Roman,
are you using osgQt classes? Why are you saying vsync is not working?

Gianni

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





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


Re: [osg-users] question about Optimizer and FLATTEN_STATIC_TRANSFORMS

2012-10-19 Thread Jason Daly

On 10/19/2012 09:28 AM, Michael Schanne wrote:

Hi,

I have a model that I converted from an .stl file to .osg.  I wanted to apply a 
scaling to the model, so I added a MatrixTransform with a scaling matrix above 
the model's root node.  For maximum efficiency I wanted to apply the transform 
directly to the vertices, so I tried to run the .osg file through osgconv a 
second time, with the OSG_OPTIMIZER env variable set to 
FLATTEN_STATIC_TRANSFORMS.  However, the new file was identical to the previous 
file, with the parent MatrixTransform still in place.  I set the DataVariance 
of the transform to STATIC, and it had no effect.  Is there something else that 
could interfere with the Optimizer flattening the transform, or am I expecting 
FLATTEN_STATIC_TRANSFORMS to do something that it's not intended to do?


Hi, Michael,

The structure of the scene itself can sometimes prevent the transform 
from being flattened away.  What happens if you try 
FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS (sometimes,  you 
just need a bigger hammer  :-) ).


--J

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


[osg-users] osgFX::Registry::Proxy proxy

2012-10-19 Thread Peterakos
Hello.

What osgFX::Registry::Proxy proxy(new MyEffect); does ?
Couldnt find any reference anywhere. i see it is used in predefined Effects
like Outline.

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


Re: [osg-users] nVidia bug with multiple windows

2012-10-19 Thread Leigh Stivers
Hi Baker.

Perhaps your issue is the same that i fixed and submitted 9/27/2012.

http://forum.openscenegraph.org/viewtopic.php?t=11124

We had this problem which shows up with nVidia's latest Quadro driver, 305.93 
- and older drivers when the nVidia's setting Thread Optimization was turned 
on, running Windows 7. The symptom, is that after creating a first view and 
using it, and then creating a second view, the first view will never render 
anything but black. 

What happens is this: 
A view is created, and then the viewers thread is created and runs. 
The setReleaseContextAtEndOfFrameHint is true. 
To create a second view, the viewer is setDone(true), and we wait for the 
thread exit. 

At this point, inside the ViewerBase::RenderingTraversals code, there are 
places where it reads if(_done) return; 

The problem, is that it won't reach the code that will releaseContext(). 

Apparently, this driver won't let any other thread to makeCurrent(), if another 
thread (dead or not) has ownership. So when the Viewers is re-started, the 
first view won't be able to use the gc. 


-- Leigh

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





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


Re: [osg-users] Using the notification API with multi-threading - heap corruption errors

2012-10-19 Thread Torben Dannhauer
Hi,

What is the current status of this issue?

Currently I'm working with openthreads and learn a lot, but as the 
threadstartedreported,
the application crashes more or less frequently if I use the notify macro 
heavily.

Thank you!

Cheers,
Torben

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





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


[osg-users] [forum] Problem when nesting osgFX::Outline effects

2012-10-19 Thread celandre dzimiwine
Hi,

I am trying to add an osgFX::Outline effect (as grand child) to another 
osgFx::Outline effect to have an outlined node of which child is also outlined. 
But I am getting a weird result: The child is displayed in fill mode and line 
mode (wireframe over fill mode rendering). I kinda understand what the problem 
is but I don't have a solution to that. Do you know if there is any solution to 
this bug?

Thank you!

Cheers,
celandre

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





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


Re: [osg-users] OSG-3.0.0 Windows Prebuilt Installer

2012-10-19 Thread Avit Hohol
Wow, an answer directly from the writer of the book ?! :)

Thank you Rui, thats understandable, iam downloading the binaries now.

All the best !

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





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


Re: [osg-users] How to change the text with osg::Text?

2012-10-19 Thread Eungil, Kim
It works very well. :)
Thank you!

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





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


[osg-users] I want to animate a shape.

2012-10-19 Thread Eungil, Kim
Hi,

I made a rectangle and want to animate it from (0, 0, 0) to (n, 0, 0) 2pixel 
per a sec.

I found an update code and I call the method in here.
while(!viewer.done())
{
viewer.frame();
   update(second);
}

but i don't know how to calculate it to meet the issue. 

here's a part of update code.
void update(float dt)
{
   myTimer += dt;
   Vec3d currentPosition = transform[0]-getPosition();
   Vec3d *newPosition;
   newPosition = new Vec3d(currentPosition.x() + dt * , 
currentPosition.y(), currentPosition.z());

   object-setPosition(Vec3(newPosition-x(), newPosition-y(), 
newPosition-z()));
}

I guess this line (newPosition = new Vec3d(currentPosition.x() + dt * , 
currentPosition.y(), currentPosition.z());) is to animate the shape.

currentPosition.x() + dt * ??? -- how ?

Sorry about posting very basic thing which is very hard to me. :(

anyone have any good link for me to understand the logic or can explan the 
process?

Thank you!

Cheers,
Eungil,

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





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


[osg-users] Fail to install due to osg80-osgDBd.dll is missing

2012-10-19 Thread Kevin Tang
Hi, I am new to OSG as well as VC++ programming, I just follow the instruction 
for how to install from pre-compiled binaries on my Windows 7.  I set the path, 
System Variable, and all other dependencies when I run VC++.  But it just jump 
out the error..



 
 The program can't start because osg80-osgDBd.dll is missing from your 
 computer.  Try reinstalling the program to fix that problem.


and its also display this at output

 
 'OSGDefaultProject.exe': Loaded 'C:\Users\Kevin\Documents\Visual Studio 
 2008\Projects\OSGDefaultProject\Debug\OSGDefaultProject.exe', Symbols loaded.
 'OSGDefaultProject.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
 'OSGDefaultProject.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
 'OSGDefaultProject.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
 The program '[3120] OSGDefaultProject.exe: Native' has exited with code 
 -1073741515 (0xc135).


I notice I wasn't able to see osgversion at cmd, 
it responed as

 'osgversion' is not recognized as an internal or external command, operable 
 program or batch file


but I was able to see all the paht by enter echo %OSG_ROOT% and in cmd, and 
all the path are set base on instruction. 

OSG_ROOT
C:\Program Files\OpenSceneGraph-3.0.1

OSG_BIN_PATH
%OSG_ROOT%\bin
 
OSG_INCLUDE_PATH
%OSG_ROOT%\include
 
OSG_LIB_PATH
%OSG_ROOT%\lib
 
OSG_SAMPLES_PATH
%OSG_ROOT%\share\OpenSceneGraph\bin
 
OSG_FILE_PATH
%OSG_ROOT%\samples\OpenSceneGraph-Data-3.0.0

also I add these two in the Path
%OSG_BIN_PATH%;%OSG_SAMPLES_PATH%;

 but in the end its just not work, I search on the osg form and try all the 
solutions, but I still not able to solve it, can anyone give me some 
suggestion.  

Thank you very much.

... 

Thank you!

Cheers,
Kevin

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





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


[osg-users] setUseVertexAttributeAliasing and frame buffer objects not working together

2012-10-19 Thread Stuart Miller
Hi all,
I'm trying to implement a deferred shading model based on some papers around 
the web but I'm running into issues when using both 
setUseVertexAttributeAliasing and rendering to a texture using FBO. I can 
render to an FBO fine with attribute aliasing off, and attribute aliasing 
appears to work fine with my shaders when not rendering to any FBOs, but using 
both at the same time causes my FBO textures to be either black or just an RGB 
gradient. Basically I'm doing this:

Code:

   ref_ptrosgViewer::Viewer pOsgViewer = new osgViewer::Viewer();
   pOsgViewer-setUpViewOnSingleScreen(1);
   pOsgViewer-setCameraManipulator(new osgGA::OrbitManipulator());
   pOsgViewer-setThreadingModel(osgViewer::ViewerBase::AutomaticSelection);

   pOsgViewer-realize();
   
pOsgViewer-getCamera()-getGraphicsContext()-getState()-setUseModelViewAndProjectionUniforms(true);
   
pOsgViewer-getCamera()-getGraphicsContext()-getState()--setUseVertexAttributeAliasing(true);
   std::string filename = blah.3DS;
   ref_ptrNode pModel = osgDB::readNodeFile(filename);

   unsigned int textureWidth = 1024;
   unsigned int textureHeight = 1024;

   // Initialize the GBuffer
   // Create osg::Texture2D objects to store the image data and map them to 
GBuffer types
   ref_ptrTexture2D pNormalTex = new Texture2D();
   pNormalTex-setTextureSize(textureWidth, textureHeight);
   pNormalTex-setInternalFormat(GL_RGBA);
   pNormalTex-setFilter(Texture2D::MIN_FILTER, Texture2D::LINEAR);
   pNormalTex-setFilter(Texture2D::MAG_FILTER, Texture2D::LINEAR);

   ref_ptrCamera pNormalCam = new Camera();

   pNormalCam-setClearColor(Vec4(1.0, 1.0, 1.0, 1.0));
   pNormalCam-setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
pNormalCam-setGraphicsContext(pOsgViewer-getCamera()-getGraphicsContext());
   pNormalCam-setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT);
   pNormalCam-setRenderOrder(Camera::PRE_RENDER);
   pNormalCam-setViewport(0, 0, pNormalTex-getTextureWidth(), 
pNormalTex-getTextureHeight());
   pNormalCam-attach(Camera::COLOR_BUFFER, pNormalTex.get(), 0, 0, false);
   attachShader(pNormalCam, GBUFFER_NORMAL);
   pNormalCam-addChild(pModel.get());

   ref_ptrosg::Group pGroup = new Group();
   pGroup-addChild(pNormalCam.get());
   pGroup-addChild(pModel.get());
   pOsgViewer-setSceneData(pGroup.get());

   pOsgViewer-run();



attachShader() just looks like this:

Code:

bool ShadedScene::attachShader(Camera* pCam, GBufferTypes programType)
{
   if (pCam == NULL)
   {
  return false;
   }

   ref_ptrShader pVertShader = new Shader(Shader::VERTEX);
   ref_ptrShader pFragShader = new Shader(Shader::FRAGMENT);
   ref_ptrProgram pShaderProgram = new Program();
   pShaderProgram-addShader(pVertShader.get());
   pShaderProgram-addShader(pFragShader.get());

   StateSet* pCamSs = pCam-getOrCreateStateSet();
   if (pCamSs == NULL)
   {
  return false;
   }
   pCamSs-setAttributeAndModes(pShaderProgram.get(), StateAttribute::ON);

   switch (programType)
   {
   case GBUFFER_NORMAL:
  pVertShader-setShaderSource(normalVertShader);
  pFragShader-setShaderSource(normalFragShader);
  break;
   default:
  break;
   }

   return true;
}



My shaders:

Code:
static std::string normalVertShader = uniform mat4 
osg_ModelViewProjectionMatrix;\n
   uniform mat3 osg_NormalMatrix;\n
   varying vec3 vVaryingNormal;\n
   void main(void)\n
   {\n
  vVaryingNormal = osg_NormalMatrix * gl_Normal;\n
  gl_Position = osg_ModelViewProjectionMatrix * gl_Vertex;\n
   }\n;

static std::string normalFragShader =
   #version 120\n
   varying vec3 vVaryingNormal;\n
   void main(void)\n
   {\n
  gl_FragColor.rgb = vVaryingNormal;\n
   }\n;




I'm using OSG trunk rev13134 for what I'm working on but I also had similar 
issues back when using 3.0.1. I'm not sure if I'm missing something or what. 
Some of this stuff is doable without attribute aliasing but it's more 
complicated - i.e. accessing the texture coordinates for a model doesn't seem 
particularly straightforward and I've not seen a simple way to do it when 
loading in a 3D model. Just curious if I'm missing something glaringly obvious. 
What I posted is a stripped-down version of what I'm working on but it covers 
everything I'm actually doing in relation to OSG.

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





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