[osg-users] Qt (4.x) and QGraphicsScene

2013-11-04 Thread Sebastian Messerschmidt

Hi folks,

I know this has been issued before, but I need some example to do the 
following:


1. Let the viewer render to an offscreen-target.
2. Use the Qt Graphicsscene to display the rendered scene as background 
image.

3. Let Qt render the other items in the graphicsview.

Can someone give me a minimal example or some hints to do this right.
I'm not an Qt-expert, so I'm asking if someone has some example ready to 
use. It would also make a good example for the OSG, as this might be a 
common task if someone was about to create some interactive map etc.


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


Re: [osg-users] Drawing lines using OpenGL ES 2.0

2013-11-04 Thread John Moore
I found a solution which involves computing the barycentric coordinates. 
However it seems that is not working properly.

To compute the barycentric coordinates I need to associate to the vertices of 
the triangles a coordinate among
(1,0,0) (0,1,0) (0,0,1)
for doing that I use the following function, which is based on the assumption I 
load the 3d model using the option noTriStripPolygons so that each polygon is a 
triangle (and not a strip of triangles).


Code:

void OSGGraphicsUtils::setBarycentricCoordinates(osg::Node * object, 
osg::Program *shaderProgram)
{
   
GeodeFinder myGeodeFinder;
std::vector osg::Geode * listOfGeodes;

object-accept(myGeodeFinder);

listOfGeodes = myGeodeFinder.getNodeList();

std::cout  there are   listOfGeodes.size()   geodes  std::endl;

for (int j = 0; j  listOfGeodes.size() ; j++)
{
//get the current geode
osg::Geode* currentGeode = listOfGeodes.at(j);

if (currentGeode != NULL)
{

for (int i = 0; i  currentGeode-getNumDrawables(); i++)
{

osg::Geometry *cubeGeometry = 
currentGeode-getDrawable(i)-asGeometry();

if (!cubeGeometry) continue;

int numAttribs = 
cubeGeometry-getVertexArray()-getNumElements();
std::cout number of vertices is numAttribsstd::endl;

osg::ref_ptr osg::Vec3Array cubeVertexVector;
if (! strcmp (cubeGeometry-getVertexArray()-className(), 
Vec3Array))
{
cubeVertexVector = (osg::Vec3Array *) 
cubeGeometry-getVertexArray();
} else {
//handle the error however you want -- here all I do is 
print a warning and bail out.
std::cerr  Unexpected VertexArray className.\n  
std::endl;
return;
}

osg::Vec3Array *array = new 
osg::Vec3Array(cubeVertexVector-size());
std::map osg::Vec3, int vertexMap;

osg::Vec3 nextVertex;

int j = 0;
for (int i = 0; i  cubeVertexVector-size(); i++) {
nextVertex = cubeVertexVector-at(i);

if (j == 3) j = 0;

if(vertexMap.find(nextVertex) == vertexMap.end())
{//check if it is the first, the second o the third vertex 
of the triangle and associate appropriate attribute
if (j==0)
{
array-at(i) = (osg::Vec3(1.0,0.0,0.0));
vertexMap[nextVertex] = i;
}
else if (j==1)
{
array-at(i) = (osg::Vec3(0.0,1.0,0.0));
vertexMap[nextVertex] = i;

}
else if (j==2)
{
array-at(i) = (osg::Vec3(0.0,0.0,1.0));
vertexMap[nextVertex] = i;
}
}
else
{
//std::cout Vertex already present in the map at 
index  vertexMap[nextVertex]  std::endl;
array-at(i) = 
osg::Vec3(array-at(vertexMap[nextVertex]));
}

j++;
}

if( !cubeGeometry-getVertexAttribArray( 31 ) )
{
//cubeGeometry-setVertexAttribData(31, 
osg::Geometry::ArrayData(array,osg::Geometry::BIND_PER_VERTEX, GL_FALSE ) );
std::cout  setting barycentric attr unit array of size  
 array-getNumElements()  std::endl;
cubeGeometry-setVertexAttribArray(31, array);
cubeGeometry-setVertexAttribBinding(BARYCENTRIC_ATTR_UNIT, 
osg::Geometry::BIND_PER_VERTEX);
}


}
}
}
}




The attribute is binded to the program with the line of code

Code:

void OSGGraphicsUtils::loadShaders(osg::ref_ptrosg::StateSet objectStateSet, 
const char *vsSource, const char *fsSource, osg::ref_ptrosg::Node object, 
const char *shaderName)
{

// set shader for mammoth
osg::ref_ptrosg::Program shaderProgram = new osg::Program;
shaderProgram-setName(shaderName);
shaderProgram-addShader( new osg::Shader( osg::Shader::VERTEX, vsSource ) 
);
shaderProgram-addShader( new osg::Shader( osg::Shader::FRAGMENT, fsSource 
) );

objectStateSet = object-getOrCreateStateSet();

objectStateSet-setAttributeAndModes(shaderProgram, osg::StateAttribute::ON 
);
if (strcmp(shaderName,ShaderWireframe)==0)
{
std::cout  adding 

Re: [osg-users] Track map on a 3D view

2013-11-04 Thread Gianni Ambrosio
Hi All,
to disable mouse intaraction I used:

view-getCamera()-setAllowEventFocus(false);

Does it make sense? Is there a better way?

In case this another option I have to set manually in my track map object copy 
constructor since a clone method is not available for a view.

Moreover, I set a camera manipulator to the track map view just to call home() 
method to fit the track. In fact the home() implementation works only if a 
manipulator is set. Since I really don't need a manipulator fot that view, what 
should I do get the same behavior without a manipulator?

Regards,
Gianni

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





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


Re: [osg-users] Track map on a 3D view

2013-11-04 Thread Trajce Nikolov NICK
Hi Gianni,

since you dont need manipulator for the map view you can only set the
viewmatrix. Something like

view-getCamera()-setViewMatrixAsLookAt() and you make a top down view

Nick


On Mon, Nov 4, 2013 at 3:24 PM, Gianni Ambrosio ga...@vi-grade.com wrote:

 Hi All,
 to disable mouse intaraction I used:

 view-getCamera()-setAllowEventFocus(false);

 Does it make sense? Is there a better way?

 In case this another option I have to set manually in my track map object
 copy constructor since a clone method is not available for a view.

 Moreover, I set a camera manipulator to the track map view just to call
 home() method to fit the track. In fact the home() implementation works
 only if a manipulator is set. Since I really don't need a manipulator fot
 that view, what should I do get the same behavior without a manipulator?

 Regards,
 Gianni

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





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




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


[osg-users] How to detect scene changes?

2013-11-04 Thread Ale Maro
Hi,

I am trying to find a way to detect any changes of the scene graph 
automatically?
I would like to implement an undo/redo mechanism and also I would like to know 
when my scene changes and needs to be saved.
For example I would like a callback is called when a manipulator changes a 
transformation node (avoiding modification on manipulators)
Is there something already implemented in OSG that can help me?

Thank you!

Cheers,
Ale

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





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


Re: [osg-users] How to detect scene changes?

2013-11-04 Thread Peter Amstutz

Hi Ale,

There is no such capability built-in.  You need to build your own layer 
on top to manage changes to the scene graph.  You should write your own 
manipulator (or modify an existing one) to route changes through your 
change management layer, rather than having it change the underlying 
transform node directly.  I have found the best practice is to treat osg 
as just the display layer it is intended to be, and not to try and use 
it as your application's primary data model.


Good luck,
Peter

On 11/4/2013 10:02 AM, Ale Maro wrote:

Hi,

I am trying to find a way to detect any changes of the scene graph 
automatically?
I would like to implement an undo/redo mechanism and also I would like to know 
when my scene changes and needs to be saved.
For example I would like a callback is called when a manipulator changes a 
transformation node (avoiding modification on manipulators)
Is there something already implemented in OSG that can help me?

Thank you!

Cheers,
Ale

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





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



--
Peter Amstutz
Senior Software Engineer
Technology Solutions Experts
Natick, MA
02131

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


Re: [osg-users] How to detect scene changes?

2013-11-04 Thread Ale Maro
Hi Peter,
thanks for the reply. 
At the moment the only part I have not separated from osg layer are 
transformations so I will need to modify manipulators.

Cheers,
Ale

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





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


Re: [osg-users] CompositeViewer regression between OSG 3.1.4 and 3.2

2013-11-04 Thread Glenn Waldron
Here is a minimal program that demonstrates the issue.

OSG 3.2: the mouse scroll wheel works in the inset view; all other mouse
events pass through to the underlying view.

OSG 3.1.4: works as expected.


#include osgViewer/CompositeViewer
#include osgDB/ReadFile

int main(int argc, char** argv)
{
osg::ArgumentParser arguments(argc,argv);

osg::Node* node = osgDB::readNodeFiles(arguments);
if ( !node ) return -1;

osgViewer::CompositeViewer cv( arguments );

osgViewer::View* mainview = new osgViewer::View();
mainview-setUpViewInWindow( 100, 100, 1600, 1024 );
mainview-setSceneData( node );
cv.addView( mainview );

osg::GraphicsContext* gc = mainview-getCamera()-getGraphicsContext();
osg::Camera* camera = new osg::Camera();
camera-setGraphicsContext( gc );
camera-setViewport( 20, 20, 700, 500 );
camera-setProjectionMatrixAsPerspective( 45.0, 7.0/5.0, 1.0, 1e6 );

osgViewer::View* insetview = new osgViewer::View();
insetview-setCamera( camera );
insetview-setSceneData( node );
cv.addView( insetview );

cv.run();
}



Glenn Waldron / @glennwaldron


On Fri, Nov 1, 2013 at 3:47 PM, Glenn Waldron gwald...@gmail.com wrote:

 Hi folks,

 I have an app that uses a CompositeViewer with one Master View that
 fills the window and multiple inset Views that sit on top of the main
 View. All Views share the same scene graph, but you can manipulate each one
 separately.

 In OSG 3.1.4 this worked, but after upgrading the OSG 3.2, now none of the
 inset Views response to the mouse (except for the scroll wheel, which
 oddly appears for work as before). Instead, mouse actions in any inset are
 handled only by the master View.

 I've tracked some significant changes in View.cpp and related classes but
 before delving too deeply I'd love to hear whether anyone's seen or
 addressed this issue first. Thanks to all.

 Glenn Waldron / @glennwaldron / osgEarth


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


Re: [osg-users] Grayscale texture

2013-11-04 Thread Boon Wah
Hi,

   I notice that glCompressedTexImage2D takes the longest time during texture 
loading. Can I understand what does this function actually does? 

I thought the texture decompression is handled by GPU, and loading to GPU 
actually should be significantly fast. In my testing,  uncompress texture loads 
faster than compressed texture and this does not make sense to me.

I will like to reduce the time in glCompressedTexImage2D as it ia 
significant in my application. Can somebody please advise me? Thanks.


Kind Regards, 
Jimmy

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





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


[osg-users] again_question about black-out(BO) of airport runway(light control)

2013-11-04 Thread Kim JongBum
Hi, guys 

i m trying to develop flight simulation with osg. 

as i attached the picture,
i used 3DViewer program to load the .ive airport map.
and you can see the black-out(BO) of airport runway
and the properties of light point.

so my question is 
is it possible and how to control the black-out(BO) of airport runway(light 
control)? 
i want to turn on(or off) the light. 

Thanks in advance guys ; ) 

Cheers, 
Kim

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




Attachments: 
http://forum.openscenegraph.org//files/ive_light_108.png


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