[osg-users] Problems using ortho camera

2014-08-06 Thread Nikolay Brezin
Hi, everyone, sorry for may be stupid question. I need to  use orthographic 
camera in my application instead of perspective and I have some troubles with 
it. 

Following code  DISPLAYS cow.

Code:
int main( int argc, char **argv ) 
{ 
int width = 1024; int height = 768;
osg::Node *scene = osgDB::readNodeFile("cow.osgt");
osg::ref_ptr viewer = new osgViewer::Viewer(); 
viewer->setSceneData( scene ); 
viewer->run();
return 0; 
} 



Following code DOES NOT display cow.

Code:
int main( int argc, char **argv ) 
{ 
int width = 1024; int height = 768;
osg::Node *scene = osgDB::readNodeFile("cow.osgt");
osg::ref_ptr viewer = new osgViewer::Viewer();

viewer->getCamera()->setProjectionMatrixAsOrtho( -10, 10, -10, 10, -10, 10 );

viewer->setSceneData( scene ); 
viewer->run();
return 0; 
}



Following code  DISPLAYS cow again.

Code:
int main( int argc, char **argv )
{
int width = 1024; int height = 768;
osg::Node *scene = osgDB::readNodeFile("cow.osgt");
osg::ref_ptr viewer = new osgViewer::Viewer();

// this line works only with 3 following lines
viewer->getCamera()->setProjectionMatrixAsOrtho( -10, 10, -10, 10, -10, 10 ); 

// following block of lines required for orthographic projection to work 
//--- block start -
osg::ref_ptr traits = new 
osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = width;
traits->height = height;
traits->doubleBuffer = true; 
osg::ref_ptr gc = 
osg::GraphicsContext::createGraphicsContext( traits.get() ); 
viewer->getCamera()->setGraphicsContext( gc.get() );
viewer->getCamera()->setViewport( new osg::Viewport( 0, 0, width, height) );
//--- block end -

viewer->setSceneData( scene );
viewer->run();
return 0;
}



Can anyone point me to what is wrong with my usage of orthographic camera? May 
be I'm missing something? I'm using OSG 3.2.1 32 bit stable on Windows 7x64 
with VS2010.

Thank you!

Cheers,
Nikolay[/code]

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





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


[osg-users] [build] Building for Android on Mac

2014-08-06 Thread Mike Strean
Hi! all

I've previously ( several months ago ) had success compiling for Android ... 
with the latest source I get


Code:
/usr/local/src/build-android/include/osg/GL:107:32: fatal error: 
TargetConditionals.h: No such file or directory



commenting out the #include for TargetConditionals.h gets me


Code:
/usr/local/src/build-android/include/osg/GL:108:29: fatal error: 
OpenGLES/ES2/gl.h: No such file or directory



I'm on OS X 10.9.4 compiling for GLES2 with


Code:
cmake ../OpenSceneGraph -DOSG_BUILD_PLATFORM_ANDROID=ON 
-DANDROID_NDK=/Users/mike/Development/android-ndk -DDYNAMIC_OPENTHREADS=OFF 
-DDYNAMIC_OPENSCENEGRAPH=OFF -DOSG_GL1_AVAILABLE=OFF -DOSG_GL2_AVAILABLE=OFF 
-DOSG_GL3_AVAILABLE=OFF -DOSG_GLES1_AVAILABLE=OFF -DOSG_GLES2_AVAILABLE=ON 
-DOSG_GL_LIBRARY_STATIC=OFF -DOSG_GL_DISPLAYLISTS_AVAILABLE=OFF 
-DOSG_GL_MATRICES_AVAILABLE=OFF -DOSG_GL_VERTEX_FUNCS_AVAILABLE=OFF 
-DOSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE=OFF -DOSG_GL_FIXED_FUNCTION_AVAILABLE=OFF 
-DANDROID_ABI="armeabi armeabi-v7a" -DANDROID_PLATFORM=16 
-DANDROID_STL="gnustl_static" -DANDROID_OPTIM=NEON -DANDROID_OPTIM=ARM32 -DJ=4 
-DCMAKE_INSTALL_PREFIX=/usr/local/android




Thanks!

--
Mike

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





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


Re: [osg-users] Multiple instances of same Drawable in different colors

2014-08-06 Thread Friederike Schneemann
Hi Robert,

Thank you very much for your quick reply. I didn't know that using 
ShapeDrawables is not recommended at all, but as a beginner it's the first 
which comes across while using google to learn osg :) 

I will maximum place 64 geometry instances (each currently consisting of 3 
ShapeDrawables) in my scene, so I guess either of your suggestions will work 
for me.

As soons as I have the time to work on this again, I will post my solution here 
for other beginners who are interested.

Thank you again.

Cheers,

Frieda

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





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


Re: [osg-users] MinimalShadowMap::ViewData::clampProjection

2014-08-06 Thread Trajce Nikolov NICK
Hi again Wojtek,

I read the code of MinimalShadowMap and tried to understand it (at least
the part of the clamping of the projection matrix). Did some hacks and got
some result. The best results I have got is that the shadows are now still
but flickering. Before they were based on the heading and were changing
with the heading. Nevermind. Here are my findings:

It seam that you clamp the projection matrix only if you have the far plane
set for the polytope to cut the scene for shadow receival. This is the
snippet from MinimalShadowMap::ViewData::cullShadowReceivingScene:

// Aditionally clamp far plane if shadows don't need to be cast as
// far as main projection far plane
if( 0 < *_maxFarPlanePtr )
clampProjection( _clampedProjection, 0.f, *_maxFarPlanePtr );

and only there. Now in clampProjection and did some changes to force the
algorithm path to follow as this is a standard projection matrix but affect
only those parts of the matrix which are affected by the far plane. Bellow
is the hacked method. Now all seam to be good across channels only the
shadows are somewhat as very low res even the setting of the far plane is
very near (1000m) and the resolution of the texture is pretty high (2048).
When I set the the far plane to 0 I have the shadow low res again since the
polytope of the scene is not clamped. Any hints? Thanks again:

void MinimalShadowMap::ViewData::clampProjection
( osg::Matrixd & projection, float new_near, float
new_far )
{
double r, l, t, b, n, f;
bool perspective = projection.getFrustum( l, r, b, t, n, f );
perspective = true;
if( !perspective && !projection.getOrtho( l, r, b, t, n, f ) )
{
// What to do here ?
OSG_WARN << "MinimalShadowMap::clampProjectionFarPlane failed - non
standard matrix" << std::endl;

} else if( n < new_near || new_far < f ) {

#if 0
if( n < new_near && new_near < f ) {
if( perspective ) {
l *= new_near / n;
r *= new_near / n;
b *= new_near / n;
t *= new_near / n;
}
n = new_near;
}
#endif
//if( n < new_far && new_far < f )
{
f = new_far;
}

if( perspective )
#if 0
projection.makeFrustum( l, r, b, t, n, f );
#else
{
n = 0.0;
double C = (fabs(f)>DBL_MAX) ? -1. : -(f+n)/(f-n);
double D = (fabs(f)>DBL_MAX) ? -2.*n : -2.0*f*n/(f-n);
//SET_ROW(0, 2.0*zNear/(right-left),0.0, 0.0,  0.0 )
//SET_ROW(1,0.0, 2.0*zNear/(top-bottom), 0.0,  0.0 )
//SET_ROW(2,  A,  B,   C, -1.0 )
//SET_ROW(3,0.0,0.0,   D,  0.0 )
projection(2,2) = C;
projection(3,2) = D;
}
#endif
else
projection.makeOrtho( l, r, b, t, n, f );
}
}




On Wed, Aug 6, 2014 at 12:05 PM, Trajce Nikolov NICK <
trajce.nikolov.n...@gmail.com> wrote:

> Hi Wojtek,
>
> thanks for the fast reply. I am going to investigate this but there is no
> source code (black box) so it is hard to say. I took very naive approach
> for the moment since I am not familiar with the code of the
> MinimalShadowMap that much and will try to force the conditions in the
> snippet as the non standard matrix is valid projection matrix and see the
> results. But will wait for you when you get back from vacation and will
> ping you again if you can give more hints. Enjoy the vacation
>
> Thanks as always!
>
> Nick
>
>
> On Wed, Aug 6, 2014 at 11:59 AM, Wojciech Lewandowski <
> w.p.lewandow...@gmail.com> wrote:
>
>> Hi, Trajce,
>>
>> I am on vacations. Quick answer is impossible in my opinion. I would bet
>> that projection software uses some matrix tricks and it would be hard to
>> figure it out without seeing the code and solution. There is a chance
>> though, that matrix obtained there is not a right projection matrix used to
>> render particular channels. As far as I know such solutions, there are a
>> channel passes which render each channel to offscreen texture/pixelbuffer
>> and final pass which projects those on sphere or other irregular surface
>> and then blasts this to screen and projector optics does the rest. So it
>> may be a chance that projection matrix obtained is for final pass and if
>> you obtain channel matrices they may turn out to be regular. This of course
>> brings question why the code obtained wrong perspective matrix instead of
>> right one ? And here I have no answer too, it has to be traced and debugged
>> with original code.
>>
>> Cheers,
>> Wojciech Lewandowski
>>
>>
>> 2014-08-06 0:44 GMT+02:00 Trajce Nikolov NICK <
>> trajce.nikolov.n...@gmail.com>:
>>
>>> Hi Community,
>>>
>>> My client have a setup with image distortion over a dome, multiple
>>> channels, and along with the projectors there is an API coming that is well
>>> integrated in OSG - it modifies the projection matrix somehow. And we are
>>> facing issues with shadows, in the

Re: [osg-users] How to texturing a cube using shaders

2014-08-06 Thread Robert Osfield
Hi Ying,

The cow.osg model uses osg::TexGen (wrapper for glTexGen) to generate the
texture coordinates so the ones assigned to actual geometry are ignored.
 glTexGen is part of the fixed function pipeline in OpenGL so you don't get
this functionality when using shaders.  You'll have to implement your own
texgen to generate the texture coordinates for this model, or apply your
own.

Might I suggest using other models that do have appropriate texture
coordinate on them for testing.

Robert.


On 6 August 2014 15:52, ying song  wrote:

> Hello Robert,
>
> Yes, you are right. The reason is that I didn't set up the texture
> coordinates. I did the following change, and I could texturing the model in
> the shader. I think the problem is that gl_MultiTexCoord0 actually didn't
> give out any texture coordinates in my first code.
>
> vertex shader:
> varying vec2 texCoord;
> void main()
> {
>
> gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> texCoord = gl_Vertex.xy;
> }
>
> fragment shader:
> uniform sampler2D texture;
> varying vec2 texCoord ;
> void main()
> {
>vec4 color = texture2D(texture, texCoord );
> gl_FragColor = color;
> }
>
> But in this way, I set the texture coordinate according to gl_Vertex,
> which is still not what I wanted.
>
> If I want to render the cow.osg model using shaders, how could I get the
> texture coordinates from the osg file? I checked the original osg file of
> the cow model, and found that the texture coordinates are all set to (0,0)
> in this file. I wonder whether it's necessary to use texture coordinates if
> I want to render the cow model.
>
> If I want to render the exact same cow model using shaders, would you tell
> me how could I do it?
>
> Thanks,
> Ying
>
> robertosfield wrote:
> > Hi Ying,
> >
> > It's not possible to pinpoint what is wrong as you provide no guidance
> of how you set up your osg::Geometry.  My best guess would be that you
> don't set up the texture coordinates.
> >
> >
> > Have a look at the osgshaders example for inspiration,
> >
> >
> > Robert.
> >
> >
> >
> > On 5 August 2014 16:31, ying song < ()> wrote:
> >
> > > Hello everyone,
> > >
> > > I tried texturing a cube by using shaders, but failed. I already tried
> all the way I could think about, but the rendered cube is still totally
> black if I use shaders. Could someone help me on this?
> > >
> > > Here is mycode:
> > > cpp file:
> > > osg::ref_ptr image =
> osgDB::readImageFile("Images/reflect.rgb");
> > > osg::ref_ptr node = createNode(); //create the cube
> > >
> > > osg::StateSet* squareState = node->getOrCreateStateSet();
> > >  osg::Program* squareProgramObject = new osg::Program;
> > >osg::Shader* squareVertexObject = new osg::Shader(
> osg::Shader::VERTEX );
> > >osg::Shader* squareFragmentObject = new osg::Shader(
> osg::Shader::FRAGMENT );
> > >squareProgramObject->addShader( squareFragmentObject );
> > >squareProgramObject->addShader( squareVertexObject );
> > >squareVertexObject->loadShaderSourceFromFile(
> "shaders/cubeRender.vert");
> > >
>  squareFragmentObject->loadShaderSourceFromFile("shaders/cubeRender.frag");
> > >squareState->setAttributeAndModes(squareProgramObject,
> osg::StateAttribute::ON);
> > >
> > >osg::ref_ptr texture = new osg::Texture2D();
> > > texture->setImage(image.get());
> > >
> texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::NEAREST_MIPMAP_NEAREST);
> //choose the nearest texture unit value
> > >
> texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); //choose
> the average of the nearest 4 pixel values as texture
> > >
> > > osg::Uniform* myTextureU = new
> osg::Uniform("myTexture",texture.get());
> > > squareState->addUniform(myTextureU);
> > >
> > >  viewer->setSceneData(node.get());
> > >
> > > vertex shader:
> > >
> > > void main()
> > > {
> > >
> > > gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> > > gl_TexCoord[0] = gl_MultiTexCoord0;
> > > }
> > >
> > > fragment shader:
> > > uniform sampler2D myTexture;
> > >
> > > void main()
> > > {
> > > vec4 color = texture2D(myTexture, gl_TexCoord[0].st);
> > > gl_FragColor = color;
> > > }
> > >
> > > Thanks a lot!
> > >
> > > Cheers,
> > > ying[/b]
> > >
> > > --
> > > Read this topic online here:
> > > http://forum.openscenegraph.org/viewtopic.php?p=60539#60539 (
> http://forum.openscenegraph.org/viewtopic.php?p=60539#60539)
> > >
> > >
> > >
> > >
> > >
> > > ___
> > > osg-users mailing list
> > >  ()
> > >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> )
> > >
> >
> >
> >  --
> > Post generated by Mail2Forum
>
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewto

Re: [osg-users] How to texturing a cube using shaders

2014-08-06 Thread ying song
Hello Robert,

Yes, you are right. The reason is that I didn't set up the texture coordinates. 
I did the following change, and I could texturing the model in the shader. I 
think the problem is that gl_MultiTexCoord0 actually didn't give out any 
texture coordinates in my first code.

vertex shader:
varying vec2 texCoord;
void main()
{

        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
        texCoord = gl_Vertex.xy;
}

fragment shader:
uniform sampler2D texture;
varying vec2 texCoord ;
void main()
{
       vec4 color = texture2D(texture, texCoord );
gl_FragColor = color;
}

But in this way, I set the texture coordinate according to gl_Vertex, which is 
still not what I wanted. 

If I want to render the cow.osg model using shaders, how could I get the 
texture coordinates from the osg file? I checked the original osg file of the 
cow model, and found that the texture coordinates are all set to (0,0) in this 
file. I wonder whether it's necessary to use texture coordinates if I want to 
render the cow model.

If I want to render the exact same cow model using shaders, would you tell me 
how could I do it?

Thanks,
Ying

robertosfield wrote:
> Hi Ying,
> 
> It's not possible to pinpoint what is wrong as you provide no guidance of how 
> you set up your osg::Geometry.  My best guess would be that you don't set up 
> the texture coordinates.
> 
> 
> Have a look at the osgshaders example for inspiration,
> 
> 
> Robert.
> 
> 
> 
> On 5 August 2014 16:31, ying song < ()> wrote:
> 
> > Hello everyone,
> > 
> > I tried texturing a cube by using shaders, but failed. I already tried all 
> > the way I could think about, but the rendered cube is still totally black 
> > if I use shaders. Could someone help me on this?
> > 
> > Here is mycode:
> > cpp file:
> >         osg::ref_ptr image = 
> > osgDB::readImageFile("Images/reflect.rgb");
> >         osg::ref_ptr node = createNode(); //create the cube
> > 
> > osg::StateSet* squareState = node->getOrCreateStateSet();
> >          osg::Program* squareProgramObject = new osg::Program;
> >        osg::Shader* squareVertexObject = new osg::Shader( 
> > osg::Shader::VERTEX );
> >        osg::Shader* squareFragmentObject = new osg::Shader( 
> > osg::Shader::FRAGMENT );
> >        squareProgramObject->addShader( squareFragmentObject );
> >        squareProgramObject->addShader( squareVertexObject );
> >            squareVertexObject->loadShaderSourceFromFile( 
> > "shaders/cubeRender.vert");
> >            
> > squareFragmentObject->loadShaderSourceFromFile("shaders/cubeRender.frag");
> >        squareState->setAttributeAndModes(squareProgramObject, 
> > osg::StateAttribute::ON);
> > 
> >            osg::ref_ptr texture = new osg::Texture2D();
> >         texture->setImage(image.get());
> >         
> > texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::NEAREST_MIPMAP_NEAREST);
> >  //choose the nearest texture unit value
> >         texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); 
> > //choose the average of the nearest 4 pixel values as texture
> > 
> >         osg::Uniform* myTextureU = new 
> > osg::Uniform("myTexture",texture.get());
> >         squareState->addUniform(myTextureU);
> > 
> >          viewer->setSceneData(node.get());
> > 
> > vertex shader:
> > 
> > void main()
> > {
> > 
> >         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> >         gl_TexCoord[0] = gl_MultiTexCoord0;
> > }
> > 
> > fragment shader:
> > uniform sampler2D myTexture;
> > 
> > void main()
> > {
> >         vec4 color = texture2D(myTexture, gl_TexCoord[0].st);
> >         gl_FragColor = color;
> > }
> > 
> > Thanks a lot!
> > 
> > Cheers,
> > ying[/b]
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=60539#60539 
> > (http://forum.openscenegraph.org/viewtopic.php?p=60539#60539)
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
>  --
> Post generated by Mail2Forum


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





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


Re: [osg-users] How to texturing a cube using shaders

2014-08-06 Thread ying song
Hello Robert,

Yes, you are right. The reason is that I didn't set up the texture coordinates. 
I did the following change, and I could texturing the model in the shader. I 
think the problem is that gl_MultiTexCoord0 actually didn't give out any 
texture coordinates in my first code.

vertex shader:
varying vec2 texCoord;
void main()
{

        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
        texCoord = gl_Vertex.xy;
}

fragment shader:
uniform sampler2D texture;
varying vec2 texCoord ;
void main()
{
       vec4 color = texture2D(texture, texCoord );
gl_FragColor = color;
}

But in this way, I set the texture coordinate according to gl_Vertex, which is 
still not what I wanted. 

If I want to render the cow.osg model using shaders, how could I get the 
texture coordinates from the osg file? I checked the original osg file of the 
cow model, and found that the texture coordinates are all set to (0,0) in this 
file. I wonder whether it's necessary to use texture coordinates if I want to 
render the cow model.

If I want to render the exact same cow model using shaders, would you tell me 
how could I do it?

Thanks,
Ying

robertosfield wrote:
> Hi Ying,
> 
> It's not possible to pinpoint what is wrong as you provide no guidance of how 
> you set up your osg::Geometry.  My best guess would be that you don't set up 
> the texture coordinates.
> 
> 
> Have a look at the osgshaders example for inspiration,
> 
> 
> Robert.
> 
> 
> 
> On 5 August 2014 16:31, ying song < ()> wrote:
> 
> > Hello everyone,
> > 
> > I tried texturing a cube by using shaders, but failed. I already tried all 
> > the way I could think about, but the rendered cube is still totally black 
> > if I use shaders. Could someone help me on this?
> > 
> > Here is mycode:
> > cpp file:
> >         osg::ref_ptr image = 
> > osgDB::readImageFile("Images/reflect.rgb");
> >         osg::ref_ptr node = createNode(); //create the cube
> > 
> > osg::StateSet* squareState = node->getOrCreateStateSet();
> >          osg::Program* squareProgramObject = new osg::Program;
> >        osg::Shader* squareVertexObject = new osg::Shader( 
> > osg::Shader::VERTEX );
> >        osg::Shader* squareFragmentObject = new osg::Shader( 
> > osg::Shader::FRAGMENT );
> >        squareProgramObject->addShader( squareFragmentObject );
> >        squareProgramObject->addShader( squareVertexObject );
> >            squareVertexObject->loadShaderSourceFromFile( 
> > "shaders/cubeRender.vert");
> >            
> > squareFragmentObject->loadShaderSourceFromFile("shaders/cubeRender.frag");
> >        squareState->setAttributeAndModes(squareProgramObject, 
> > osg::StateAttribute::ON);
> > 
> >            osg::ref_ptr texture = new osg::Texture2D();
> >         texture->setImage(image.get());
> >         
> > texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::NEAREST_MIPMAP_NEAREST);
> >  //choose the nearest texture unit value
> >         texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); 
> > //choose the average of the nearest 4 pixel values as texture
> > 
> >         osg::Uniform* myTextureU = new 
> > osg::Uniform("myTexture",texture.get());
> >         squareState->addUniform(myTextureU);
> > 
> >          viewer->setSceneData(node.get());
> > 
> > vertex shader:
> > 
> > void main()
> > {
> > 
> >         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> >         gl_TexCoord[0] = gl_MultiTexCoord0;
> > }
> > 
> > fragment shader:
> > uniform sampler2D myTexture;
> > 
> > void main()
> > {
> >         vec4 color = texture2D(myTexture, gl_TexCoord[0].st);
> >         gl_FragColor = color;
> > }
> > 
> > Thanks a lot!
> > 
> > Cheers,
> > ying[/b]
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=60539#60539 
> > (http://forum.openscenegraph.org/viewtopic.php?p=60539#60539)
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org 
> > (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
>  --
> Post generated by Mail2Forum


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





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


Re: [osg-users] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Sonya Blade
Thank You sincerely, 
Shame on me,Regards,

> Date: Wed, 6 Aug 2014 14:53:32 +0200
> From: peter.hre...@intes.de
> To: osg-users@lists.openscenegraph.org
> Subject: Re: [osg-users] Erratical behaviour with PolytopeIntersector
> 
> Hello,
> 
> On 08/06/2014 02:33 PM, Sonya Blade wrote:
> > Thank you for the entrypoint,
> > 
> > What you mean by rescaling the geomtry directly? Directly modify the 
> > vertices and dirty the displaylist, rather than using 
> > transformation matrices? I'll try that workaround, it sounds quite coherent 
> > for the reason of discrepancy.
> 
> Yes, I meant modifying the vertex coordinates.
>  
> >> I can see that you are using 
> >> setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE )
> >> which should be doing what I meant by "only-first-intersection".
> > I personally not observed any improvement in Polytope behaviour in any of 
> > the (/NO_LIMIT, //LIMIT_ONE_PER_DRAWABLE/
> > , /LIMIT_NEAREST/  etcc.. settings, in any case it retrieves plenty of 
> > objects.
> 
> I found the the reason why your code produces to many intersection:
> You must call 
> setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE )
> before the result collection starts, i.e.:
> 
>   
> polytop->setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE );
>   osgUtil::IntersectionVisitor iv(polytop);
>   view->getCamera()->accept(iv);
> 
> Then I do get at most 5 intersecions with your example as is to be expected.
> 
> > Regards,
> 
> Cheers,
> 
> Peter
> 
> 
> >> Date: Wed, 6 Aug 2014 14:16:31 +0200
> >> From: peter.hre...@intes.de
> >> To: osg-users@lists.openscenegraph.org
> >> Subject: Re: [osg-users] Erratical behaviour with PolytopeIntersector
> >>
> >> Hello again,
> >>
> >> On 08/06/2014 10:28 AM, Sonya Blade wrote:
> >> > Hi All and Thanks for your feedback,
> >> >
> >> > Please find the reproduced example and obj file at the attachment, it 
> >> > doesn't have any visual aids,
> >> > with 1st user click program creates leftbottom of rectangle, second user 
> >> > click creates righttop,
> >> > for intersection rectangle and invokes PolytopeIntersector. If I select 
> >> > them all I'd expect totally 5
> >> > objects to be picked, but program produces 420. There is a high chance 
> >> > that as Sebastian Messerschmidt
> >> > emphasized, I pick all vertices but can you confirm it ?
> >>
> >> Thanks for your example.
> >>
> >> I can see that you are using 
> >> setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE )
> >> which should be doing what I meant by "only-first-intersection".
> >>
> >> Testing your example I do get a lot more intersecions than is to be 
> >> expected.
> >> Clearly something is wrong there.
> >>
> >> But I think I found the reason for the "erratic" part of your problem:
> >> Currently PolytopeIntersector does not produce correct results in presence
> >> of scaling transformations (which are used in your example).
> >>
> >> As a workaround you could rescale your geometry directly.
> >>
> >>
> >> Cheers,
> >>
> >> Peter
> 
> ___
> 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] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Peter Hrenka
Hello,

On 08/06/2014 02:33 PM, Sonya Blade wrote:
> Thank you for the entrypoint,
> 
> What you mean by rescaling the geomtry directly? Directly modify the vertices 
> and dirty the displaylist, rather than using 
> transformation matrices? I'll try that workaround, it sounds quite coherent 
> for the reason of discrepancy.

Yes, I meant modifying the vertex coordinates.
 
>> I can see that you are using 
>> setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE )
>> which should be doing what I meant by "only-first-intersection".
> I personally not observed any improvement in Polytope behaviour in any of the 
> (/NO_LIMIT, //LIMIT_ONE_PER_DRAWABLE/
> , /LIMIT_NEAREST/  etcc.. settings, in any case it retrieves plenty of 
> objects.

I found the the reason why your code produces to many intersection:
You must call setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE 
)
before the result collection starts, i.e.:

  
polytop->setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE );
  osgUtil::IntersectionVisitor iv(polytop);
  view->getCamera()->accept(iv);

Then I do get at most 5 intersecions with your example as is to be expected.

> Regards,

Cheers,

Peter


>> Date: Wed, 6 Aug 2014 14:16:31 +0200
>> From: peter.hre...@intes.de
>> To: osg-users@lists.openscenegraph.org
>> Subject: Re: [osg-users] Erratical behaviour with PolytopeIntersector
>>
>> Hello again,
>>
>> On 08/06/2014 10:28 AM, Sonya Blade wrote:
>> > Hi All and Thanks for your feedback,
>> >
>> > Please find the reproduced example and obj file at the attachment, it 
>> > doesn't have any visual aids,
>> > with 1st user click program creates leftbottom of rectangle, second user 
>> > click creates righttop,
>> > for intersection rectangle and invokes PolytopeIntersector. If I select 
>> > them all I'd expect totally 5
>> > objects to be picked, but program produces 420. There is a high chance 
>> > that as Sebastian Messerschmidt
>> > emphasized, I pick all vertices but can you confirm it ?
>>
>> Thanks for your example.
>>
>> I can see that you are using 
>> setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE )
>> which should be doing what I meant by "only-first-intersection".
>>
>> Testing your example I do get a lot more intersecions than is to be expected.
>> Clearly something is wrong there.
>>
>> But I think I found the reason for the "erratic" part of your problem:
>> Currently PolytopeIntersector does not produce correct results in presence
>> of scaling transformations (which are used in your example).
>>
>> As a workaround you could rescale your geometry directly.
>>
>>
>> Cheers,
>>
>> Peter

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


Re: [osg-users] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Sonya Blade
Thank you for the entrypoint,
What you mean by rescaling the geomtry directly? Directly modify the vertices 
and dirty the displaylist, rather than using transformation matrices? I'll try 
that workaround, it sounds quite coherent for the reason of discrepancy.
> I can see that you are using 
> setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE )
> which should be doing what I meant by "only-first-intersection".I personally 
> not observed any improvement in Polytope behaviour in any of the (NO_LIMIT, 
> LIMIT_ONE_PER_DRAWABLE, LIMIT_NEAREST  etcc.. settings, in any case it 
> retrieves plenty of objects.
Regards,
> Date: Wed, 6 Aug 2014 14:16:31 +0200
> From: peter.hre...@intes.de
> To: osg-users@lists.openscenegraph.org
> Subject: Re: [osg-users] Erratical behaviour with PolytopeIntersector
> 
> Hello again,
> 
> On 08/06/2014 10:28 AM, Sonya Blade wrote:
> > Hi All and Thanks for your feedback,
> > 
> > Please find the reproduced example and obj file at the attachment, it 
> > doesn't have any visual aids,
> > with 1st user click program creates leftbottom of rectangle, second user 
> > click creates righttop, 
> > for intersection rectangle and invokes PolytopeIntersector. If I select 
> > them all I'd expect totally 5 
> > objects to be picked, but program produces 420.  There is a high chance 
> > that as Sebastian Messerschmidt
> > emphasized, I pick all vertices but can you confirm it ?
> 
> Thanks for your example.
> 
> I can see that you are using 
> setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE )
> which should be doing what I meant by "only-first-intersection".
> 
> Testing your example I do get a lot more intersecions than is to be expected.
> Clearly something is wrong there.
> 
> But I think I found the reason for the "erratic" part of your problem:
> Currently PolytopeIntersector does not produce correct results in presence
> of scaling transformations (which are used in your example).
> 
> As a workaround you could rescale your geometry directly.
> 
> 
> Cheers,
> 
> Peter
>  
> 
> ___
> 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] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Peter Hrenka
Hello again,

On 08/06/2014 10:28 AM, Sonya Blade wrote:
> Hi All and Thanks for your feedback,
> 
> Please find the reproduced example and obj file at the attachment, it doesn't 
> have any visual aids,
> with 1st user click program creates leftbottom of rectangle, second user 
> click creates righttop, 
> for intersection rectangle and invokes PolytopeIntersector. If I select them 
> all I'd expect totally 5 
> objects to be picked, but program produces 420.  There is a high chance that 
> as Sebastian Messerschmidt
> emphasized, I pick all vertices but can you confirm it ?

Thanks for your example.

I can see that you are using 
setIntersectionLimit(osgUtil::Intersector::LIMIT_ONE_PER_DRAWABLE )
which should be doing what I meant by "only-first-intersection".

Testing your example I do get a lot more intersecions than is to be expected.
Clearly something is wrong there.

But I think I found the reason for the "erratic" part of your problem:
Currently PolytopeIntersector does not produce correct results in presence
of scaling transformations (which are used in your example).

As a workaround you could rescale your geometry directly.


Cheers,

Peter
 

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


Re: [osg-users] [MASSMAIL] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Sebastian Messerschmidt

Hi Sonya,



Hi All and Thanks for your feedback,

Please find the reproduced example and obj file at the attachment, it 
doesn't have any visual aids,
with 1st user click program creates leftbottom of rectangle, second 
user click creates righttop,
for intersection rectangle and invokes PolytopeIntersector. If I 
select them all I'd expect totally 5
objects to be picked, but program produces 420.  There is a high 
chance that as Sebastian Messerschmidt

emphasized, I pick all vertices but can you confirm it ?
Sorry I cannot do the debugging for you. I'd attach a debugger and check 
what I get back from the interface.




> Admittedly, the current behaviour is of PolytopeIntersector is not 
very space- or time-efficient
> for your use-case. I think a useful extension would be some kind of 
"only-first-intersection"-flag
> which should reduce the number of generated intersecions for cases 
like yours.


I'm bit confused here, its a common practice to use rectangular, 
polygonal circle area selection in
3D applicaitons (e.g. Blender),that is even been suggested by the OSG 
Beginner book Chapter 9
"Have a go hero -- selecting geometries in a rectangular region" the 
proper usage is POlytopeIntersector.
It is fast enough for most use cases I've encountered. It is a general 
implementation and not necessarily the most efficient one - so if you 
encounter performance issues you can always write your own intersector 
implementation, so there is no need for confusion :-)




Regards,

> Date: Wed, 6 Aug 2014 09:43:14 +0200
> From: peter.hre...@intes.de
> To: osg-users@lists.openscenegraph.org
> Subject: Re: [osg-users] [MASSMAIL] Erratical behaviour with 
PolytopeIntersector

>
> Hello,
>
> On 08/04/2014 11:18 AM, Sonya Blade wrote:
> > Dear All,
> >
> > I'm experiencing very weird problem when using the polytope 
intersector. Since there is not any explicit example on how
> > to use polytope example with rectangular selection I use osgPick 
example in OSG and modify the codes to suit my need.

>
> The canonical example for PolytopeIntersector is osgkeyboardmouse 
which shows one possible usage.

>
> > Normally the below code picks the objects on scene but shows that 
400 picked objects which is not correct and far beyond of
> > scene object range where that I have, I only have 5-6 object in 
scene,

>
> As Sebastian Messerschmidt has suggested the PolytopeIntersector 
returns intersections on
> a per-primitive level and that also includes all primitives inside 
the polytope.

>
> If you only want results on a higher level (e.g. per drawable) you 
can just modify

> the counting loop in you code to eliminate duplicate drawables.
>
> Admittedly, the current behaviour is of PolytopeIntersector is not 
very space- or time-efficient
> for your use-case. I think a useful extension would be some kind of 
"only-first-intersection"-flag
> which should reduce the number of generated intersecions for cases 
like yours.

>
>
> Cheers,
>
> Peter
>
> > What could be the reason of that malfunctioning ? I 'll appreciate 
your guidance on that !.

> >
> > case (osgGA::GUIEventAdapter::RELEASE):
> > {
> > if (btn_counter == 1 )
> > {
> > firstX = ea.getX(); firstY = ea.getY();
> > btn_counter = 2;
> > break;
> > }
> >
> > if (btn_counter==2)
> > {
> > btn_counter = 1;
> > osgUtil::PolytopeIntersector* polytop = new 
osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW, 
firstX,firstY, ea.getX(), ea.getY() );

> > osgUtil::IntersectionVisitor iv(polytop);
> > view->getCamera()->accept(iv);
> >
> > int k;
> > if (polytop->containsIntersections() )
> > {
> >
> > osgUtil::PolytopeIntersector::Intersections intersections= 
polytop->getIntersections();

> > osg::Vec3 screenpos = osg::Vec3(ea.getX(),ea.getY(),0);
> >
> > for(osgUtil::PolytopeIntersector::Intersections::iterator hitr = 
intersections.begin();

> > hitr != intersections.end(); ++hitr)
> > {
> > k+=1;
> > std::cout<< k << "" << hitr->drawable->getName()<< 
hitr->drawable->className()<<"\n" ;

> >
> > }
> > }
> > }
> > }
> > }
> > }
> > };
> >
> >
> >
> > ___
> > 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


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


Re: [osg-users] MinimalShadowMap::ViewData::clampProjection

2014-08-06 Thread Trajce Nikolov NICK
Hi Wojtek,

thanks for the fast reply. I am going to investigate this but there is no
source code (black box) so it is hard to say. I took very naive approach
for the moment since I am not familiar with the code of the
MinimalShadowMap that much and will try to force the conditions in the
snippet as the non standard matrix is valid projection matrix and see the
results. But will wait for you when you get back from vacation and will
ping you again if you can give more hints. Enjoy the vacation

Thanks as always!

Nick


On Wed, Aug 6, 2014 at 11:59 AM, Wojciech Lewandowski <
w.p.lewandow...@gmail.com> wrote:

> Hi, Trajce,
>
> I am on vacations. Quick answer is impossible in my opinion. I would bet
> that projection software uses some matrix tricks and it would be hard to
> figure it out without seeing the code and solution. There is a chance
> though, that matrix obtained there is not a right projection matrix used to
> render particular channels. As far as I know such solutions, there are a
> channel passes which render each channel to offscreen texture/pixelbuffer
> and final pass which projects those on sphere or other irregular surface
> and then blasts this to screen and projector optics does the rest. So it
> may be a chance that projection matrix obtained is for final pass and if
> you obtain channel matrices they may turn out to be regular. This of course
> brings question why the code obtained wrong perspective matrix instead of
> right one ? And here I have no answer too, it has to be traced and debugged
> with original code.
>
> Cheers,
> Wojciech Lewandowski
>
>
> 2014-08-06 0:44 GMT+02:00 Trajce Nikolov NICK <
> trajce.nikolov.n...@gmail.com>:
>
>> Hi Community,
>>
>> My client have a setup with image distortion over a dome, multiple
>> channels, and along with the projectors there is an API coming that is well
>> integrated in OSG - it modifies the projection matrix somehow. And we are
>> facing issues with shadows, in the following snippet:
>>
>> void MinimalShadowMap::ViewData::clampProjection
>> ( osg::Matrixd & projection, float new_near, float
>> new_far )
>> {
>> double r, l, t, b, n, f;
>> bool perspective = projection.getFrustum( l, r, b, t, n, f );
>> if( !perspective && !projection.getOrtho( l, r, b, t, n, f ) )
>> {
>> // What to do here ?
>> OSG_WARN << "MinimalShadowMap::clampProjectionFarPlane failed -
>> non standard matrix" << std::endl;
>>
>> } else ...
>>
>> You can see the comment // What to do here ?.
>>
>> Well, what is to be done there since the distorted matrix coming from the
>> API seam to be recognized by non standard matrix? Someone have a clue?
>>
>> Thanks as always !
>>
>> Nick
>>
>> --
>> trajce nikolov nick
>>
>> ___
>> 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
>
>


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


Re: [osg-users] osgviewer can\'t read dds file....is this a bug?

2014-08-06 Thread Trajce Nikolov NICK
strange. I did "osgviewer --image sample.dds" and it works just fine.
Attached is a screenshot. is there any message on the console? Can you
locate osgdb_dds.dll (you on windows??? or linux)? is your osg bin folder
in your PATH?

Nick


On Wed, Aug 6, 2014 at 11:45 AM, Shyguy  wrote:

> I used that option --image.
>
> Coverted with nvDXT to with some format -u565 -u888 works fine.
>
> Other tool cant read my file. but osgviewer can't...
>
> I put my sample file in this mail. thanks
>
> *-- Original Message --*
>
> *Date:* Wednesday, Aug 6, 2014 06:32:36 PM
> *From:* "Trajce Nikolov NICK" 
> *To:* "OpenSceneGraph Users" 
> *Subject:* Re: [osg-users] osgviewer can\'t read dds fileis this a
> bug?
>
> Hi,
>
> osg can read S3TC images. I think you have to do osgviewer --image
> myfile.dds. Do osgviewer --help you will see the correct option
>
> Cheers,
> Nick
>
>
> On Wed, Aug 6, 2014 at 11:25 AM, Shyguy  wrote:
>
>> osgviewer can't read dds file which format is dxt1.
>>
>> I am using osg 3.3.1 and I converted that file to dxt3 , dxt5...with
>> nvDXT tool...
>>
>> but it results same...
>>
>>
>> I wonder if this is natutral or any other method to read dds file...
>>
>>
>> Anyway...thanks in advence.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 당신과 제가 다름이 세상을 풍요롭게 합니다...^^v
>> Differences between U and me make the world plentiful...^^v
>>
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
>
> --
> trajce nikolov nick
>
>
>
>
>
>
>
>
>
>
> 당신과 제가 다름이 세상을 풍요롭게 합니다...^^v
> Differences between U and me make the world plentiful...^^v
>
> ___
> 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


Re: [osg-users] MinimalShadowMap::ViewData::clampProjection

2014-08-06 Thread Wojciech Lewandowski
Hi, Trajce,

I am on vacations. Quick answer is impossible in my opinion. I would bet
that projection software uses some matrix tricks and it would be hard to
figure it out without seeing the code and solution. There is a chance
though, that matrix obtained there is not a right projection matrix used to
render particular channels. As far as I know such solutions, there are a
channel passes which render each channel to offscreen texture/pixelbuffer
and final pass which projects those on sphere or other irregular surface
and then blasts this to screen and projector optics does the rest. So it
may be a chance that projection matrix obtained is for final pass and if
you obtain channel matrices they may turn out to be regular. This of course
brings question why the code obtained wrong perspective matrix instead of
right one ? And here I have no answer too, it has to be traced and debugged
with original code.

Cheers,
Wojciech Lewandowski


2014-08-06 0:44 GMT+02:00 Trajce Nikolov NICK :

> Hi Community,
>
> My client have a setup with image distortion over a dome, multiple
> channels, and along with the projectors there is an API coming that is well
> integrated in OSG - it modifies the projection matrix somehow. And we are
> facing issues with shadows, in the following snippet:
>
> void MinimalShadowMap::ViewData::clampProjection
> ( osg::Matrixd & projection, float new_near, float
> new_far )
> {
> double r, l, t, b, n, f;
> bool perspective = projection.getFrustum( l, r, b, t, n, f );
> if( !perspective && !projection.getOrtho( l, r, b, t, n, f ) )
> {
> // What to do here ?
> OSG_WARN << "MinimalShadowMap::clampProjectionFarPlane failed -
> non standard matrix" << std::endl;
>
> } else ...
>
> You can see the comment // What to do here ?.
>
> Well, what is to be done there since the distorted matrix coming from the
> API seam to be recognized by non standard matrix? Someone have a clue?
>
> Thanks as always !
>
> Nick
>
> --
> trajce nikolov nick
>
> ___
> 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] osgviewer can\'t read dds file....is this a bug?

2014-08-06 Thread Shyguy
I used that option --image.Coverted with nvDXT to with some format -u565 -u888 works fine.Other tool cant read my file. but osgviewer can't...I put my sample file in this mail. thanks
-- Original Message --
Date: Wednesday, Aug 6, 2014 06:32:36 PM
From: "Trajce Nikolov NICK" 
To: "OpenSceneGraph Users" 
Subject: Re: [osg-users] osgviewer can\'t read dds fileis this a bug?

Hi,osg can read S3TC images. I think you have to do osgviewer --image myfile.dds. Do osgviewer --help you will see the correct optionCheers,Nick
On Wed, Aug 6, 2014 at 11:25 AM, Shyguy  wrote:
osgviewer can't read dds file which format is dxt1.I am using osg 3.3.1 and I converted that file to dxt3 , dxt5...with nvDXT tool...
but it results same...I wonder if this is natutral or any other method to read dds file...Anyway...thanks in advence.

 
 
 
 
 
 
 
 
 
당신과 제가 다름이 세상을 풍요롭게 합니다...^^v
Differences between U and me make the world plentiful...^^v
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-- trajce nikolov nick


 
 
 
 
 
 
 
 
 
당신과 제가 다름이 세상을 풍요롭게 합니다...^^v
Differences between U and me make the world plentiful...^^v

sample.dds
Description: application/unknown
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Missing namespace causes collisions

2014-08-06 Thread Robert Osfield
On 5 August 2014 22:36, Benjamin Beier  wrote:

> If you would move your typedefs inside the 'osg' namespace each framework
> would prioritize their own definitions correctly.
>

OSG typedefs ARE inside OSG namespaces.  Be clear, it's only GL fallback
typedef's that are kept in the global namespace, as per OpenGL headers.

Moving the GL fallback typedefs into OSG namespaces would require those
typedefs to be used with an OSG namespace or to force end users to use
using namespace, which when you are mixing lots of namespaces is not
recommend.

For existing users if we did put the GL fallback typedefs into an OSG
namespace then their code would have to account for fallback typedef's
being used and add the OSG namespace for those instances rather than
standard GL typedef's.  Since GL headers can change from platform to
platform when and where fallback typedef's are used is not consistent so
you would be pushing a problem onto users.

I'm not about risking breakong end user code on whim to appease one user
that happened to have an issue with a 3rd party library, that was easily
resolved anyway.

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


Re: [osg-users] osgviewer can't read dds file....is this a bug?

2014-08-06 Thread Trajce Nikolov NICK
Hi,

osg can read S3TC images. I think you have to do osgviewer --image
myfile.dds. Do osgviewer --help you will see the correct option

Cheers,
Nick


On Wed, Aug 6, 2014 at 11:25 AM, Shyguy  wrote:

> osgviewer can't read dds file which format is dxt1.
>
> I am using osg 3.3.1 and I converted that file to dxt3 , dxt5...with nvDXT
> tool...
>
> but it results same...
>
>
> I wonder if this is natutral or any other method to read dds file
>
>
> Anyway...thanks in advence.
>
>
>
>
>
>
>
>
>
> 당신과 제가 다름이 세상을 풍요롭게 합니다...^^v
> Differences between U and me make the world plentiful...^^v
>
> ___
> 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] osgviewer can't read dds file....is this a bug?

2014-08-06 Thread Shyguy
osgviewer can't read dds file which format is dxt1.I am using osg 3.3.1 and I converted that file to dxt3 , dxt5...with nvDXT tool...but it results same...I wonder if this is natutral or any other method to read dds fileAnyway...thanks in advence.
 
 
 
 
 
 
 
 
 
당신과 제가 다름이 세상을 풍요롭게 합니다...^^v
Differences between U and me make the world plentiful...^^v___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [MASSMAIL] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Sonya Blade
Hi All and Thanks for your feedback,
Please find the reproduced example and obj file at the attachment, it doesn't 
have any visual aids,with 1st user click program creates leftbottom of 
rectangle, second user click creates righttop, for intersection rectangle and 
invokes PolytopeIntersector. If I select them all I'd expect totally 5 objects 
to be picked, but program produces 420.  There is a high chance that as 
Sebastian Messerschmidtemphasized, I pick all vertices but can you confirm it ?
> Admittedly, the current behaviour is of PolytopeIntersector is not very 
> space- or time-efficient
> for your use-case. I think a useful extension would be some kind of 
> "only-first-intersection"-flag
> which should reduce the number of generated intersecions for cases like yours.

I'm bit confused here, its a common practice to use rectangular, polygonal 
circle area selection in 3D applicaitons (e.g. Blender),that is even been 
suggested by the OSG Beginner book Chapter 9 "Have a go hero – selecting 
geometries in a rectangular region" the proper usage is POlytopeIntersector.
Regards,

> Date: Wed, 6 Aug 2014 09:43:14 +0200
> From: peter.hre...@intes.de
> To: osg-users@lists.openscenegraph.org
> Subject: Re: [osg-users] [MASSMAIL] Erratical behaviour with  
> PolytopeIntersector
> 
> Hello,
> 
> On 08/04/2014 11:18 AM, Sonya Blade wrote:
> > Dear All,
> > 
> > I'm experiencing very weird problem when using the polytope intersector. 
> > Since there is not any explicit example on how 
> > to use polytope example with rectangular selection I use osgPick example in 
> > OSG and modify the codes to suit my need.
> 
> The canonical example for PolytopeIntersector is osgkeyboardmouse which shows 
> one possible usage.
>  
> > Normally the below code picks the objects on scene but shows that 400 
> > picked objects which is not correct and far beyond of 
> > scene object range where that I have, I only have 5-6 object in scene, 
> 
> As Sebastian Messerschmidt has suggested the PolytopeIntersector returns 
> intersections on
> a per-primitive level and that also includes all primitives inside the 
> polytope.
> 
> If you only want results on a higher level (e.g. per drawable) you can just 
> modify 
> the counting loop in you code to eliminate duplicate drawables.
> 
> Admittedly, the current behaviour is of PolytopeIntersector is not very 
> space- or time-efficient
> for your use-case. I think a useful extension would be some kind of 
> "only-first-intersection"-flag
> which should reduce the number of generated intersecions for cases like yours.
> 
> 
> Cheers,
> 
> Peter
> 
> > What could be the reason of that malfunctioning ? I 'll appreciate your 
> > guidance on that !.
> > 
> > case (osgGA::GUIEventAdapter::RELEASE):
> > {
> > if (btn_counter == 1 )
> > {
> > firstX = ea.getX(); firstY = ea.getY();
> > btn_counter = 2;
> > break;
> > }
> > 
> > if (btn_counter==2)
> > {
> > btn_counter = 1;
> > osgUtil::PolytopeIntersector* polytop = new 
> > osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW,  firstX,firstY, 
> > ea.getX(), ea.getY() );
> > osgUtil::IntersectionVisitor iv(polytop);
> > view->getCamera()->accept(iv);
> > 
> > int k;
> > if (polytop->containsIntersections() )
> > {
> > 
> >  osgUtil::PolytopeIntersector::Intersections 
> > intersections= polytop->getIntersections();
> >  osg::Vec3 screenpos = 
> > osg::Vec3(ea.getX(),ea.getY(),0);
> > 
> >  
> > for(osgUtil::PolytopeIntersector::Intersections::iterator hitr = 
> > intersections.begin();
> > hitr != intersections.end(); ++hitr)
> >  {
> >  k+=1;
> > std::cout<< k << "" << 
> > hitr->drawable->getName()<< hitr->drawable->className()<<"\n" ;
> > 
> >  }
> > }
> > }
> > }
> > }
> > }
> > };
> > 
> > 
> > 
> > ___
> > 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
  

test.obj
Description: Binary data

/* OpenSceneGraph example, osganimate.
*
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the "Software"), 

Re: [osg-users] [MASSMAIL] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Peter Hrenka
Hello,

On 08/04/2014 11:18 AM, Sonya Blade wrote:
> Dear All,
> 
> I'm experiencing very weird problem when using the polytope intersector. 
> Since there is not any explicit example on how 
> to use polytope example with rectangular selection I use osgPick example in 
> OSG and modify the codes to suit my need.

The canonical example for PolytopeIntersector is osgkeyboardmouse which shows 
one possible usage.
 
> Normally the below code picks the objects on scene but shows that 400 picked 
> objects which is not correct and far beyond of 
> scene object range where that I have, I only have 5-6 object in scene, 

As Sebastian Messerschmidt has suggested the PolytopeIntersector returns 
intersections on
a per-primitive level and that also includes all primitives inside the polytope.

If you only want results on a higher level (e.g. per drawable) you can just 
modify 
the counting loop in you code to eliminate duplicate drawables.

Admittedly, the current behaviour is of PolytopeIntersector is not very space- 
or time-efficient
for your use-case. I think a useful extension would be some kind of 
"only-first-intersection"-flag
which should reduce the number of generated intersecions for cases like yours.


Cheers,

Peter

> What could be the reason of that malfunctioning ? I 'll appreciate your 
> guidance on that !.
> 
> case (osgGA::GUIEventAdapter::RELEASE):
> {
> if (btn_counter == 1 )
> {
> firstX = ea.getX(); firstY = ea.getY();
> btn_counter = 2;
> break;
> }
> 
> if (btn_counter==2)
> {
> btn_counter = 1;
> osgUtil::PolytopeIntersector* polytop = new 
> osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW,  firstX,firstY, 
> ea.getX(), ea.getY() );
> osgUtil::IntersectionVisitor iv(polytop);
> view->getCamera()->accept(iv);
> 
> int k;
> if (polytop->containsIntersections() )
> {
> 
>  osgUtil::PolytopeIntersector::Intersections 
> intersections= polytop->getIntersections();
>  osg::Vec3 screenpos = 
> osg::Vec3(ea.getX(),ea.getY(),0);
> 
>  
> for(osgUtil::PolytopeIntersector::Intersections::iterator hitr = 
> intersections.begin();
> hitr != intersections.end(); ++hitr)
>  {
>  k+=1;
> std::cout<< k << "" << 
> hitr->drawable->getName()<< hitr->drawable->className()<<"\n" ;
> 
>  }
> }
> }
> }
> }
> }
> };
> 
> 
> 
> ___
> 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] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Sebastian Messerschmidt

Hi Sonya,

I'm not sure, but I guess the result simply contains all vertices 
contained. So you will have to filter the results yourself or check the 
interface for options to configure the results filtering.




Your comments will be appreciated,
Regards,

From: sonyablade2...@hotmail.com
To: osg-users@lists.openscenegraph.org
Date: Mon, 4 Aug 2014 10:18:39 +0100
Subject: [osg-users] Erratical behaviour with PolytopeIntersector

Dear All,

I'm experiencing very weird problem when using the polytope 
intersector. Since there is not any explicit example on how
to use polytope example with rectangular selection I use osgPick 
example in OSG and modify the codes to suit my need.


Normally the below code picks the objects on scene but shows that 400 
picked objects which is not correct and far beyond of

scene object range where that I have, I only have 5-6 object in scene,

What could be the reason of that malfunctioning ? I 'll appreciate 
your guidance on that !.


case (osgGA::GUIEventAdapter::RELEASE):
{
if (btn_counter == 1 )
{
  firstX = ea.getX(); firstY = ea.getY();
  btn_counter = 2;
  break;
}

if (btn_counter==2)
{
  btn_counter = 1;
  osgUtil::PolytopeIntersector* polytop = new 
osgUtil::PolytopeIntersector( osgUtil::Intersector::WINDOW,  
firstX,firstY, ea.getX(), ea.getY() );

  osgUtil::IntersectionVisitor iv(polytop);
view->getCamera()->accept(iv);

  int k;
  if (polytop->containsIntersections() )
  {

 osgUtil::PolytopeIntersector::Intersections intersections= 
polytop->getIntersections();

osg::Vec3 screenpos = osg::Vec3(ea.getX(),ea.getY(),0);

 for(osgUtil::PolytopeIntersector::Intersections::iterator hitr = 
intersections.begin();

  hitr != intersections.end(); ++hitr)
   {
   k+=1;
  std::cout<< k << "" << hitr->drawable->getName()<< 
hitr->drawable->className()<<"\n" ;


   }
  }
}
  }
}
}
};


___ 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] Erratical behaviour with PolytopeIntersector

2014-08-06 Thread Robert Osfield
On 6 August 2014 07:13, Sonya Blade  wrote:

> Your comments will be appreciated,
>

There is no way for me to provide an answer without reproducing the problem
first hand to see what the issue might be, no doubt others are a similar
position and simply can't provide an answer given the details.   Could you
provide a working example?

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


Re: [osg-users] Multiple instances of same Drawable in different colors

2014-08-06 Thread Robert Osfield
Hi Frie,

osg::ShapeDrawable was never intended with this type of usage, it's just a
convenience for the occasional visualization the shape primitives.
osg::Geometry is the class intended for general usage in the scene graph
and is designed around OpenGL fast paths so you can achieve the better
performance using osg::Geometry.

The use of Transform's to place instances of geometries in the scene graph
is also something that scales well, if you have perhaps a thousands
instances then this will perform OK, but if you have then's of thousands
then it won't scale well at all because of the CPU overhead.  For a more
scalable solution use vertex shaders and geometry instancing.

Finally we the issue how to have individual colours for each Geometry.  You
can push the colour manage up in to an osg::Material and have an individual
StateSet with Material assigned to each Transform/Group.  This would work
but would have the CPU overhead mentioned above as well as a GPU overhead
with changing state.

Now what solution is best will depend very much on just how many geometry
instances you want to place in your scene.  If it's just a few
Transform+StateSet/Material would work fine.  Simply having different
osg::Geometry would work fine too.  For simple geometries the CPU+GPU
memory overhead isn't very high so duplicating them will not be an issue.
If you do need lots of instances then look at using the GPU more actively,
the osgforest example has a range of options of how to implement lots of
instances of trees, one of these approach might suit your task.

Robert.


On 6 August 2014 00:17, Friederike Schneemann <
friederike.schneem...@gmail.com> wrote:

> Hi,
>
> I use osg for the first time to create a low level visualization to show
> the position of tracked objects in a 3D world.
>
> To make it memory efficient I created a tree structure with multiple
> transformation matrices which are all pointing to the same Geode, which
> contains the ShapeDrawables representing my object.
>
> I thought this makes sense, as I can get multiple instances of the objects
> at different positions. So far this works very well for me.
>
> But now, I want to extend this by showing every object in an other color,
> (currently I set the color via the setColor(..)-Function of the
> ShapeDrawable, so all instances of the object have the same color).
>
> Is there a node type which I could add e.g. after the transformation
> matrix and before pointing to the drawable, so I can change the color of
> the object.
>
> For illustration, this is what my tree structure looks like:
>
> root -> MatrixTransform1 -> GEODE -> ShapeDrawable1 (setShape() & setColor)
> root -> MatrixTransform1 -> GEODE -> ShapeDrawable2 (setShape() & setColor)
> root -> MatrixTransform2 -> GEODE -> ShapeDrawable1 (setShape() & setColor)
> root -> MatrixTransform2 -> GEODE -> ShapeDrawable2 (setShape() & setColor)
> ...
>
> I already googled and searched the forum but couldn't find anything
> related to this.
>
> Thank you!
>
> Cheers,
> Frie
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=60547#60547
>
>
>
>
>
> ___
> 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