Re: [osg-users] Intersect Point Cloud wth precision

2016-12-23 Thread Chris Hanson
Take the results from the PolytopeIntersector, project them to screen
space, measure the distance from your mouse XY to the projected point, sort
the result set by this metric and take the closest.

On Fri, Dec 23, 2016 at 3:22 AM, Robert Osfield 
wrote:

> HI Bruno,
>
> For a point cloud you may be best to implement your own
> osgUtil::Intersector, the design is meant to facilitate this,
> LineSegmentIntersector and PolytopeIntersector are both examples of
> subclasses from Intersector so you could use these as inspriation.
>
> Robert
>
> On 22 December 2016 at 17:02, Bruno Oliveira
>  wrote:
> > Hello,
> >
> > I have a point cloud and need to get the intersection of my mouse with
> that
> > point cloud. For that I use a PolytopeIntersector. I use this intersector
> > because I found out that a LineSegmentIntersector will not do the trick.
> >
> > I set the polytope width and height to 5.0 and therefore I get lots of
> > intersections, which is not good for me since I need to get the neartest
> > intersection to my mouse, and if I pick the first intersection of the
> > polytope I am not guaranteed to have that. A way of doing this would be
> to
> > change the polytope size to, for instance, 1.0 or 0.5, but this sometimes
> > results in no intersections.
> >
> > How can I get the cloud point that is neartest to the polytope's center?
> >
> > ___
> > 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
>



-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Code Forensics • Digital Imaging • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] looking for a terrain database building toolchain

2016-12-23 Thread Nickolai Medvedev
Hi, Terry.

You should pay attention to Proland:

http://proland.inrialpes.fr/index.html

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





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


Re: [osg-users] Material Properties to Change the Normal Intensity

2016-12-23 Thread Sebastian Messerschmidt


Hi Rômulo,

If you pass a normal map, you could either use the alpha-channel of said 
texture or pass another "grayscale" texture which containst the scale if 
you need it per pixel.
In case you need to control the scale for the object you can set an 
uniform value per object containing the desired scale. The uniform or 
texture value can then be used in your shader to scale the resulting 
normal.


Cheers
Sebastian


Hi,

I have simulated a sonar sensor using normal depth map by custom 3D shader from 
OpenSceneGraph scene.

I already implemented the Bump Mapping technique to change the normal 
directions. For now, I need to change the material properties (e.g. 
reflectance) of scene's objects to increase/decrease the normal values. Is it 
possible?

Thank you!

Cheers,
Rômulo

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





___
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] Material Properties to Change the Normal Intensity

2016-12-23 Thread Rômulo Cerqueira
Hi,

I have simulated a sonar sensor using normal depth map by custom 3D shader from 
OpenSceneGraph scene.

I already implemented the Bump Mapping technique to change the normal 
directions. For now, I need to change the material properties (e.g. 
reflectance) of scene's objects to increase/decrease the normal values. Is it 
possible?  

Thank you!

Cheers,
Rômulo

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





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


[osg-users] [How to reset FBO attachments?]

2016-12-23 Thread Julien Valentin
Hi,

For some obscures reasons I don't want to debate here, I would like to reset 
the attachments of a osg::FrameBufferObject.

Is the any particular reason why there's no such a public

Code:
inline void clearAttachments(){_attachments.clear();}


method  present in osg/FrameBufferObject?


Thank you!

Cheers,
Julien

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





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


Re: [osg-users] Texture projection on terrain and gl_TextureMatrix[0...7]

2016-12-23 Thread Sebastian Messerschmidt



Hi Ekaterina:

Hello,

after checking more the forum, I have found another topic
http://forum.openscenegraph.org/viewtopic.php?t=9182=jotschi

with the following code, which I have slightly modified.

I would be very grateful, if someone can explain to me why the basic model is 
black and how to avoid it?


Because the shader is written to only project the texture. If you need 
to blend it on top, you will need to either explicitly use the original 
texture information or do a multipass rendering with this code blending 
additively over your current scene.


Cheers
Sebastian


Or maybe, someone has a very simple example with any texture projection on the 
terrain.

#include 
#include 
#include 
#include 
#include 

#include 

#include 
#include 
#include 
#include 

#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 


#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 

#include 
#include 

using namespace std;

osgViewer::View* viewA = new osgViewer::View;
osg::TexMat* texMat = new osg::TexMat;
osg::Uniform* ViewMatInv = new osg::Uniform(osg::Uniform::FLOAT_MAT4,
"ViewMatInv");
int spotTUnit = 3;



const char* VertexShader = {
"uniform mat4 ViewMatInv;\n"
"void main()\n"
"{\n"
"vec4 posEye = gl_ModelViewMatrix * gl_Vertex;\n"
"gl_TexCoord[3].s = dot( posEye, gl_EyePlaneS[3]);\n"
"gl_TexCoord[3].t = dot( posEye, gl_EyePlaneT[3]);\n"
"gl_TexCoord[3].p = dot( posEye, gl_EyePlaneR[3]);\n"
"gl_TexCoord[3].q = dot( posEye, gl_EyePlaneQ[3]);\n"
"gl_Position = gl_ProjectionMatrix * posEye;\n"
"}\n"
};

const char* FragmentShader = {
"uniform sampler2D projectionMap;\n"
"varying vec4 projCoord;\n"
 "void main()\n"
"{\n"
"gl_FragColor = texture2DProj(projectionMap, gl_TexCoord[3]);\n"
//"#if TEST_FOR_REVERSE_PROJECTION\n"
//"if (gl_TexCoord[3].q > 0.0)\n"
//"gl_FragColor = texture2DProj(projectionMap, gl_TexCoord[3]);\n"
//"else\n"
//"gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
  //   "#endif\n"
"}\n"
};


osg::ref_ptr addShader()
{
osg::ref_ptr projProg = new osg::Program;
//osg::ref_ptr 
projvertexShader(osg::Shader::readShaderFile(
//  osg::Shader::VERTEX, "surface.main.vert.glsl"));
//osg::ref_ptr projfragShader(osg::Shader::readShaderFile(
//  osg::Shader::FRAGMENT, "surface.main.frag.glsl"));
//projProg->addShader(projvertexShader.get());
//projProg->addShader(projfragShader.get());

projProg->addShader(new osg::Shader(osg::Shader::VERTEX, VertexShader));
projProg->addShader(new osg::Shader(osg::Shader::FRAGMENT, 
FragmentShader));

return projProg;
}

void addProjectionInfoToState(osg::StateSet* stateset, string fn)
{

osg::Vec4 centerColour(1.0f, 1.0f, 1.0f, 1.0f);
osg::Vec4 ambientColour(0.05f, 0.05f, 0.05f, 1.0f);

/* 1. Load the texture that will be projected */
osg::Texture2D* texture = new osg::Texture2D();

texture->setImage(osgDB::readImageFile(fn));//VTB::createSpotLightImage(centerColour,
 ambientColour, 64, 1.0));
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_BORDER);
stateset->setTextureAttributeAndModes((int)spotTUnit, texture, 
osg::StateAttribute::ON);


// set up tex gens
stateset->setTextureMode((int)spotTUnit, GL_TEXTURE_GEN_S, 
osg::StateAttribute::ON);
stateset->setTextureMode((int)spotTUnit, GL_TEXTURE_GEN_T, 
osg::StateAttribute::ON);
stateset->setTextureMode((int)spotTUnit, GL_TEXTURE_GEN_R, 
osg::StateAttribute::ON);
stateset->setTextureMode((int)spotTUnit, GL_TEXTURE_GEN_Q, 
osg::StateAttribute::ON);

/* 3. Handover the texture to the fragment shader via uniform */
osg::Uniform* texUniform = new osg::Uniform(osg::Uniform::SAMPLER_2D,
"projectionMap");
texUniform->set((int)spotTUnit);
stateset->addUniform(texUniform);

/* 4. set Texture matrix*/

//If you want to create the texture matrix by yourself you can do this 
like this way:
//osg::Vec3 projectorPos = osg::Vec3(0.0f, 0.0f, 324.0f);
//osg::Vec3 projectorDirection = 
osg::Vec3(osg::inDegrees(dirX),osg::inDegrees(dirY), osg::inDegrees(dirZ));
//osg::Vec3 up(0.0f, 1.0f, 0.0f);
//osg::Vec3 target = osg::Vec3(0.0f, 0.0f,0.0f);
//float projectorAngle = 80.f; //FOV
//mat = osg::Matrixd::lookAt(projectorPos, projectorPos*target ,up) * 
osg::Matrixd::perspective(projectorAngle, 1.0, 1.0, 10);

osg::Matrix mat = viewA->getCamera()->getViewMatrix()
  

Re: [osg-users] Texture projection on terrain and gl_TextureMatrix[0...7]

2016-12-23 Thread Ekaterina Fokina
Hello,

after checking more the forum, I have found another topic 
http://forum.openscenegraph.org/viewtopic.php?t=9182=jotschi

with the following code, which I have slightly modified.

I would be very grateful, if someone can explain to me why the basic model is 
black and how to avoid it?

Or maybe, someone has a very simple example with any texture projection on the 
terrain.

#include 
#include 
#include 
#include 
#include 

#include 

#include 
#include 
#include 
#include 

#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 


#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 

#include 
#include 

using namespace std;

osgViewer::View* viewA = new osgViewer::View;
osg::TexMat* texMat = new osg::TexMat;
osg::Uniform* ViewMatInv = new osg::Uniform(osg::Uniform::FLOAT_MAT4,
"ViewMatInv");
int spotTUnit = 3;



const char* VertexShader = {
"uniform mat4 ViewMatInv;\n"
"void main()\n"
"{\n"
"vec4 posEye = gl_ModelViewMatrix * gl_Vertex;\n"
"gl_TexCoord[3].s = dot( posEye, gl_EyePlaneS[3]);\n"
"gl_TexCoord[3].t = dot( posEye, gl_EyePlaneT[3]);\n"
"gl_TexCoord[3].p = dot( posEye, gl_EyePlaneR[3]);\n"
"gl_TexCoord[3].q = dot( posEye, gl_EyePlaneQ[3]);\n"
"gl_Position = gl_ProjectionMatrix * posEye;\n"
"}\n"
};

const char* FragmentShader = {
"uniform sampler2D projectionMap;\n"
"varying vec4 projCoord;\n"
"void main()\n"
"{\n"
"gl_FragColor = texture2DProj(projectionMap, gl_TexCoord[3]);\n"
//"#if TEST_FOR_REVERSE_PROJECTION\n"
//"if (gl_TexCoord[3].q > 0.0)\n"
//"gl_FragColor = texture2DProj(projectionMap, gl_TexCoord[3]);\n"
//"else\n"
//"gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
 //   "#endif\n"
"}\n"
};


osg::ref_ptr addShader()
{
osg::ref_ptr projProg = new osg::Program;
//osg::ref_ptr 
projvertexShader(osg::Shader::readShaderFile(
//  osg::Shader::VERTEX, "surface.main.vert.glsl"));
//osg::ref_ptr projfragShader(osg::Shader::readShaderFile(
//  osg::Shader::FRAGMENT, "surface.main.frag.glsl"));
//projProg->addShader(projvertexShader.get());
//projProg->addShader(projfragShader.get());

projProg->addShader(new osg::Shader(osg::Shader::VERTEX, VertexShader));
projProg->addShader(new osg::Shader(osg::Shader::FRAGMENT, 
FragmentShader));

return projProg;
}

void addProjectionInfoToState(osg::StateSet* stateset, string fn)
{

osg::Vec4 centerColour(1.0f, 1.0f, 1.0f, 1.0f);
osg::Vec4 ambientColour(0.05f, 0.05f, 0.05f, 1.0f);

/* 1. Load the texture that will be projected */
osg::Texture2D* texture = new osg::Texture2D();

texture->setImage(osgDB::readImageFile(fn));//VTB::createSpotLightImage(centerColour,
 ambientColour, 64, 1.0));
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_BORDER);
stateset->setTextureAttributeAndModes((int)spotTUnit, texture, 
osg::StateAttribute::ON);


// set up tex gens
stateset->setTextureMode((int)spotTUnit, GL_TEXTURE_GEN_S, 
osg::StateAttribute::ON);
stateset->setTextureMode((int)spotTUnit, GL_TEXTURE_GEN_T, 
osg::StateAttribute::ON);
stateset->setTextureMode((int)spotTUnit, GL_TEXTURE_GEN_R, 
osg::StateAttribute::ON);
stateset->setTextureMode((int)spotTUnit, GL_TEXTURE_GEN_Q, 
osg::StateAttribute::ON);

/* 3. Handover the texture to the fragment shader via uniform */
osg::Uniform* texUniform = new osg::Uniform(osg::Uniform::SAMPLER_2D,
"projectionMap");
texUniform->set((int)spotTUnit);
stateset->addUniform(texUniform);

/* 4. set Texture matrix*/

//If you want to create the texture matrix by yourself you can do this 
like this way:
//osg::Vec3 projectorPos = osg::Vec3(0.0f, 0.0f, 324.0f);
//osg::Vec3 projectorDirection = 
osg::Vec3(osg::inDegrees(dirX),osg::inDegrees(dirY), osg::inDegrees(dirZ));
//osg::Vec3 up(0.0f, 1.0f, 0.0f);
//osg::Vec3 target = osg::Vec3(0.0f, 0.0f,0.0f);
//float projectorAngle = 80.f; //FOV
//mat = osg::Matrixd::lookAt(projectorPos, projectorPos*target ,up) * 
osg::Matrixd::perspective(projectorAngle, 1.0, 1.0, 10);

osg::Matrix mat = viewA->getCamera()->getViewMatrix()
* viewA->getCamera()->getProjectionMatrix();

texMat->setMatrix(mat);
stateset->setTextureAttributeAndModes((int)spotTUnit, texMat, 
osg::StateAttribute::ON);


stateset->addUniform(ViewMatInv);
}

osg::StateSet* createProjectorState()
{

Re: [osg-users] Intersect Point Cloud wth precision

2016-12-23 Thread Robert Osfield
HI Bruno,

For a point cloud you may be best to implement your own
osgUtil::Intersector, the design is meant to facilitate this,
LineSegmentIntersector and PolytopeIntersector are both examples of
subclasses from Intersector so you could use these as inspriation.

Robert

On 22 December 2016 at 17:02, Bruno Oliveira
 wrote:
> Hello,
>
> I have a point cloud and need to get the intersection of my mouse with that
> point cloud. For that I use a PolytopeIntersector. I use this intersector
> because I found out that a LineSegmentIntersector will not do the trick.
>
> I set the polytope width and height to 5.0 and therefore I get lots of
> intersections, which is not good for me since I need to get the neartest
> intersection to my mouse, and if I pick the first intersection of the
> polytope I am not guaranteed to have that. A way of doing this would be to
> change the polytope size to, for instance, 1.0 or 0.5, but this sometimes
> results in no intersections.
>
> How can I get the cloud point that is neartest to the polytope's center?
>
> ___
> 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