Re: [osg-users] Feedback/guidance sought on move of osgQt out into it's own project/repository

2016-09-19 Thread Mathieu MARACHE
Hi Robert,

On Mon, Sep 19, 2016 at 9:46 AM Robert Osfield 
wrote:

> Hi Mathieu,
>
> One of the items that could complicate things is the qfont plugin as this
> would normally be placed in the lib/osgPlugins-version directory.  This
> coupling to a specific OSG version is not helpful for the osgQt build or
> maintainers.
>
> I think the solution is to simply place the
> src/osgPlugins/qfont/ReaderQFont.cpp file directly into the osgQt directory
> and remove the separate plugin completely.  One wouldn't use the qfont
> ReaderWriter without using qt/osgQt so there is nothing to loose from
> making this change, what you gain is simplicity and flexibility.
>

I'm OK with that.


> > One issue will be trigger CI builds without recompiling osg.
>
> Could you explain what specifically is the problem?
>

If I want to compile osgQt using travisCI or appveyor I need to pull also
osg's code to compile it ?


>
> Robert.
> ___
> 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] different materials for a geometry and highlight

2016-09-19 Thread Gianni Ambrosio

Trajce Nikolov NICK wrote:
> Maybe you dirty your color array too?
> 

Thanks Nikolov, in my code the color array don't change. Anyway I tried as you 
suggested and I can confirm that's not the point.

Regards,
Gianni

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





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


Re: [osg-users] Attaching children to the prerender camera

2016-09-19 Thread Trajce Nikolov NICK
Hi Mary-Ann,

I have recently worked on similar issue and the way how I debug the depth
RTT was by rendering the Depth image on a quad (the shader for displaying
the Depth image is here: http://markmail.org/message/
ccscbkzyxsgmb5vl#query:+page:1+mid:c542rbpj3jdw3v5d+state:results )
or simply attach a color texture to the depth RTT as well - might help you
to see if your View/Projection matrices are ok too. The link works with
Depth textures in general so maybe the code there will give you some
inspiration

Hope this helps
Nick

On Mon, Sep 19, 2016 at 5:14 PM, Mary-Ann Zorra  wrote:

> Hi,
>
> I am pretty new in OSG, so sorry if I am asking a bit noob question. But I
> am stuck on this problem, and have no idea how I could solve it.
>
> So I would like to prerender my scene into a framebuffer to have a depth
> map. I tested everything, my shader seems to work if I am using it in my
> main rendering pass, and it is being called in my prerender pass too. But
> for some reason it can not see the objects of the scene, so the depthmap
> gets black (I do linearize the depth values in the fragment shader too).  I
> think the problem is, that I do not attach the subgraph to the framebuffer
> camera properly, but I can not figure it out, what I am missing. So please
> help, I  do not have any new ideas  anymore :(
>
> Here is the code:
>
>
> Code:
> camera = new osg::Camera;;
> camera->setViewport(0, 0, m_textureSizeX, m_textureSizeY);
> camera->setClearColor( osg::Vec4() );
> camera->setClearMask( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
> camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT,
> osg::Camera::PIXEL_BUFFER_RTT );
> camera->setRenderOrder( osg::Camera::PRE_RENDER );
> camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
> camera->setProjectionMatrix( osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0) );
> camera->setViewMatrix( osg::Matrix::identity() );
>
> m_depthTexture = new osg::Texture2D;
> m_depthTexture->setTextureSize(m_textureSizeX, m_textureSizeY);
> m_depthTexture->setInternalFormat(GL_RGBA);
> m_depthTexture->setDataVariance(osg::Object::DYNAMIC);
> m_depthTexture->setFilter(osg::Texture::MIN_FILTER,
> osg::Texture::LINEAR_MIPMAP_LINEAR);
> m_depthTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
> m_depthTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
> m_depthTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
> m_depthTexture->setResizeNonPowerOfTwoHint(false);
>
> m_texImage = new osg::Image;
> m_texImage->allocateImage(m_textureSizeX, m_textureSizeY, 1, GL_RGBA,
> GL_UNSIGNED_BYTE);
>
> camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER),
> m_texImage);
> m_depthTexture->setImage(0, m_texImage);
>
> //m_DBRoot is filled by init(), I checked and the subgraph is there
> camera->addChild(m_DBRoot.get());
> //the root of the scene graph
> root->addChild(camera.get());
>
>
>
>
> Thank you!
>
> Cheers,
> Mary-Ann
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68663#68663
>
>
>
>
>
> ___
> 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] Attaching children to the prerender camera

2016-09-19 Thread Mary-Ann Zorra
Hi,

I am pretty new in OSG, so sorry if I am asking a bit noob question. But I am 
stuck on this problem, and have no idea how I could solve it.

So I would like to prerender my scene into a framebuffer to have a depth map. I 
tested everything, my shader seems to work if I am using it in my main 
rendering pass, and it is being called in my prerender pass too. But for some 
reason it can not see the objects of the scene, so the depthmap gets black (I 
do linearize the depth values in the fragment shader too).  I think the problem 
is, that I do not attach the subgraph to the framebuffer camera properly, but I 
can not figure it out, what I am missing. So please help, I  do not have any 
new ideas  anymore :(

Here is the code:


Code:
camera = new osg::Camera;;
camera->setViewport(0, 0, m_textureSizeX, m_textureSizeY);
camera->setClearColor( osg::Vec4() );
camera->setClearMask( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT, 
osg::Camera::PIXEL_BUFFER_RTT );
camera->setRenderOrder( osg::Camera::PRE_RENDER );
camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
camera->setProjectionMatrix( osg::Matrix::ortho2D(0.0, 1.0, 0.0, 1.0) );
camera->setViewMatrix( osg::Matrix::identity() );

m_depthTexture = new osg::Texture2D;
m_depthTexture->setTextureSize(m_textureSizeX, m_textureSizeY);
m_depthTexture->setInternalFormat(GL_RGBA);
m_depthTexture->setDataVariance(osg::Object::DYNAMIC);
m_depthTexture->setFilter(osg::Texture::MIN_FILTER, 
osg::Texture::LINEAR_MIPMAP_LINEAR);
m_depthTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
m_depthTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
m_depthTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
m_depthTexture->setResizeNonPowerOfTwoHint(false);

m_texImage = new osg::Image;
m_texImage->allocateImage(m_textureSizeX, m_textureSizeY, 1, GL_RGBA, 
GL_UNSIGNED_BYTE);

camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER), 
m_texImage);
m_depthTexture->setImage(0, m_texImage);

//m_DBRoot is filled by init(), I checked and the subgraph is there
camera->addChild(m_DBRoot.get());
//the root of the scene graph
root->addChild(camera.get()); 




Thank you!

Cheers,
Mary-Ann

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





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


Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Gianni Ambrosio
OK,
I found a way to move a triangle from a primitive set to another.
Debugging the code primitive sets are updated correctly but the color remains 
the same.

I call 

sourcePrimitiveSet->dirty();
destinationPrimitiveSet->dirty();
geometry->dirtyBound();

What's wrong with it? Isn't enough?

Regards,
Gianni

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





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


Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Gianni Ambrosio
Hi Sebastian,

SMesserschmidt wrote:
> I might be wrong, but I think the intersector.primitiveIndex might yield 
> the number you are looking for
> 

thanks for the reply but unfortunately it seems to return a number from 0 to 7 
that is the number of triangles in my example geometry. While the number of 
primitive sets is 4 in my example. But in fact I can use it at first to find 
the primitive set (knowing the size of each primitive set and its index). Then 
I have to verify if the "primitiveIndex" attribute of the same triangle changes 
moving that triangle from one primitive set to another.

Regards,
Gianni

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





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


Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Sebastian Messerschmidt

Hi Gianni,

I browsed the LineSegmentIntersector code and it seems, the intersector 
is using a triangleFunctor to traverse your primitive sets as triangles 
anyways. So the Ifnromation
So basically you cannot find out which primitive set was affected 
without reverse-engineering which primitive sets the triangle originated 
from.


One easy way would be to use multiple drawables (I think you could still 
share the vertex data) or to specialize the intersector to traverse per 
primitive set.


Cheers

Sebastian


Am 9/19/2016 um 10:50 AM schrieb Sebastian Messerschmidt:

Hi Gianni,

Code:
osg::Geometry* buildGeometry() {
osg::Geometry* geometry = new osg::Geometry;
geometry->setVertexArray(buildVertices());
geometry->setColorArray(buildColors(), 
osg::Array::BIND_PER_PRIMITIVE_SET);


std::vector elements = buildElements();
for (std::vector::iterator i = 
elements.begin(); i != elements.end(); ++i) {

  geometry->addPrimitiveSet(*i);
}

return geometry;
}



When I pick a triangle, is there a way from the information stored 
into a osgUtil::LineSegmentIntersector::Intersection to get the 
related primitive set?
I might be wrong, but I think the intersector.primitiveIndex might 
yield the number you are looking for

Also be sure to handle all intersections returned.

Cheers
Sebastian


Regards,
Gianni

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





___
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


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


Re: [osg-users] different materials for a geometry and highlight

2016-09-19 Thread Sebastian Messerschmidt

Hi Gianni,

Code:
osg::Geometry* buildGeometry() {
osg::Geometry* geometry = new osg::Geometry;
geometry->setVertexArray(buildVertices());
geometry->setColorArray(buildColors(), 
osg::Array::BIND_PER_PRIMITIVE_SET);

std::vector elements = buildElements();
for (std::vector::iterator i = 
elements.begin(); i != elements.end(); ++i) {
  geometry->addPrimitiveSet(*i);
}

return geometry;
}



When I pick a triangle, is there a way from the information stored into a 
osgUtil::LineSegmentIntersector::Intersection to get the related primitive set?
I might be wrong, but I think the intersector.primitiveIndex might yield 
the number you are looking for

Also be sure to handle all intersections returned.

Cheers
Sebastian


Regards,
Gianni

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





___
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] different materials for a geometry and highlight

2016-09-19 Thread Gianni Ambrosio
Hi All,
I've attached an example. Hope this helps to have a reply from somebody 
(Robert?).

Part of that example is from the OSG 3 Cookbook.
Suppose I have geometry build of triangles. I would like to understand which is 
the better way to change the color of a selected triangle. And if there is a 
preferred way to organize the object geometry to facilitate the color change 
feature.

The user chooses the current color punshing 1,2,3 or 4 key. Then pushing 
CTRL+LEFTMOUSE on the 3D geometry a triangle is selected. I need to apply the 
current selected color to the corresponding selected triangle.

Should I use the osgUtil::LineSegmentIntersector::Intersection::indexList value 
to find the corresponding primitive set the selected triangle belongs to? That 
seems too much of a hack from my point of view.
Isn't that possible in OSG using primitive sets then I have to split the object 
geometry into different pieces? (i.e. one Geode for each color so that I can 
then use the osgUtil::LineSegmentIntersector::Intersection::nodePath instead?)

Thanks for the help.
Gianni

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



#include "stdafx.h"

#include 
#include 
#include 

#include 
#include 
#include 
#include 

#include 
#include 

#include 

#include 

#include 

#include 

const osg::Vec4 selectedColor(1.0f, 1.0f, 1.0f, 0.5f);
const osg::Vec4 color1(1.0f, 0.0f, 0.0f, 1.0f);
const osg::Vec4 color2(0.0f, 1.0f, 0.0f, 1.0f);
const osg::Vec4 color3(0.0f, 0.0f, 1.0f, 1.0f);
const osg::Vec4 color4(1.0f, 0.0f, 1.0f, 1.0f);

class SelectModelHandler : public osgGA::GUIEventHandler
{
public:
SelectModelHandler() : _selector(0), currentColor(color1) {}

osg::Geode* createFaceSelector()
{
osg::ref_ptr colors = new osg::Vec4Array(1);
(*colors)[0] = selectedColor;

_selector = new osg::Geometry;
_selector->setDataVariance( osg::Object::DYNAMIC );
_selector->setUseDisplayList( false );
_selector->setUseVertexBufferObjects( true );
_selector->setVertexArray( new osg::Vec3Array(3) );
_selector->setColorArray( colors.get() );
_selector->setColorBinding( osg::Geometry::BIND_OVERALL );
_selector->addPrimitiveSet( new osg::DrawArrays(GL_TRIANGLES, 0, 3) );

osg::ref_ptr geode = new osg::Geode;
geode->addDrawable( _selector.get() );
geode->getOrCreateStateSet()->setMode( GL_LIGHTING, 
osg::StateAttribute::OFF );
geode->getOrCreateStateSet()->setMode( GL_BLEND, 
osg::StateAttribute::ON );
geode->getOrCreateStateSet()->setRenderingHint( 
osg::StateSet::TRANSPARENT_BIN );
geode->getOrCreateStateSet()->setAttributeAndModes(new 
osg::PolygonOffset(-1.0f, -1.0f));
return geode.release();
}

virtual bool handle( const osgGA::GUIEventAdapter& ea, 
osgGA::GUIActionAdapter& aa )
{
if (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE &&
ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON &&
ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL)
{
   osgViewer::View* viewer = dynamic_cast();
   if ( viewer )
   {
   osg::ref_ptr intersector = new 
osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), 
ea.getY());
   osgUtil::IntersectionVisitor iv(intersector.get());
   osg::Camera* camera = viewer->getCamera();
   camera->accept( iv );

   if ( intersector->containsIntersections() )
   {
   osgUtil::LineSegmentIntersector::Intersection result = 
*(intersector->getIntersections().begin());
   doUserOperations( result );
   }
   }
}
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_1) {
   currentColor = color1;
}
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_2) {
   currentColor = color2;
}
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_3) {
   currentColor = color3;
}
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_4) {
   currentColor = color4;
}
return false;
}

virtual void doUserOperations( 
osgUtil::LineSegmentIntersector::Intersection& result )
{
osg::Geometry* geom = dynamic_cast( 
result.drawable.get() );
if ( !geom || !_selector || geom==_selector ) return;

osg::Vec3Array* vertices = dynamic_cast( 
geom->getVertexArray() );
osg::Vec3Array* selVertices = dynamic_cast( 
_selector->getVertexArray() );
if ( !vertices || !selVertices ) return;

osg::Matrix matrix = osg::computeLocalToWorld( result.nodePath );
const std::vector& selIndices = result.indexList;
for ( unsigned int i=0; i<3 && 

Re: [osg-users] Feedback/guidance sought on move of osgQt out into it's own project/repository

2016-09-19 Thread Robert Osfield
Hi Mathieu,

One of the items that could complicate things is the qfont plugin as this
would normally be placed in the lib/osgPlugins-version directory.  This
coupling to a specific OSG version is not helpful for the osgQt build or
maintainers.

I think the solution is to simply place the
src/osgPlugins/qfont/ReaderQFont.cpp file directly into the osgQt directory
and remove the separate plugin completely.  One wouldn't use the qfont
ReaderWriter without using qt/osgQt so there is nothing to loose from
making this change, what you gain is simplicity and flexibility.

> One issue will be trigger CI builds without recompiling osg.

Could you explain what specifically is the problem?

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