Re: [osg-users] transfer data to shader with osg::texture

2016-10-04 Thread Sebastian Messerschmidt



Am 10/5/2016 um 3:37 AM schrieb liu ming:

Hi Wojtek ,Thank you for your reply,I have  tried GL_RGBA16F_ARB instead like that 
"texture0->setInternalFormat(GL_RGBA16F_ARB);",but  it seemed like not 
valid.The value still is 0..1 range.Are there other solutions? Thank you.
So they are now _between_ 0 and , instead of 0 _or_ 1? Then, at least, 
you're on the right track.

What  seems wrong however is your sampler setup. Try this instead:

osg::Uniform* sampler = new osg::Uniform(osg::Uniform::SAMPLER_1D, "data");
sampler->set(0); //assign unit

ss->addUniform(sampler);

ss->setTextureAttribute(0/*unit*/, texture0 ,osg::StateAttribute::ON );

Cheers
Sebastian





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





___
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] transfer data to shader with osg::texture

2016-10-04 Thread liu ming
Hi Wojtek ,Thank you for your reply,I have  tried GL_RGBA16F_ARB instead like 
that "texture0->setInternalFormat(GL_RGBA16F_ARB);",but  it seemed like not 
valid.The value still is 0..1 range.Are there other solutions? Thank you.

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





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


Re: [osg-users] transfer data to shader with osg::texture

2016-10-04 Thread Wojciech Lewandowski
Hi,

I think internal format GL_RGBA16 normalizes your float values to 0..1
range. Try GL_RGBA16F_ARB instead.

Cheers,
Wojtek Lewandowski

2016-10-04 17:00 GMT+02:00 liu ming <81792...@qq.com>:

> Hi,
>
>   I want to send a set of data to geometry shader with osg::texture,I've
> got a problem:in the geometry shader,I can use glsl  function"texelFetch"to
> get the texel's values,and use the values to draw a triangle,But the values
> is not correct.  the values always are "0" or "1",not the original input.It
> make me confused. whether the code" texture0->setInternalFormat(GL_RGBA16);"
> wrong?How can I get the correctly texel's values?
>
> The code:
>
>
> Code:
>   //.
> osg::ref_ptr< osg::StateSet > ss = new osg::StateSet;
> osg::Texture1D * texture0 = new osg::Texture1D;
> texture0->setDataVariance(osg::Object::DYNAMIC);
> osg::ref_ptr image = new osg::Image;
> image->allocateImage( 4, 1, 1,  GL_RGB, GL_FLOAT );
> //write data to the image
>osg::Vec3* ptr1 = (osg::Vec3*)image->data();
>*ptr1=osg::Vec3( 0.0,0.0,0.0);
>*ptr1++;
>*ptr1= osg::Vec3( 40.0,0.0,0.0);
>*ptr1++;
>*ptr1=osg::Vec3( 20.0,0.0,20.0);
>
>  texture0->setImage(image);
>  texture0->setInternalFormat(GL_RGBA16);
> //
> osg::ref_ptr< osg::Uniform > sample0 = new osg::Uniform( "data", 0 );
>ss->addUniform(sample0);
> ss->setTextureAttributeAndModes(0,
> texture0,osg::StateAttribute::ON);
>// 
>
>   //--
>   //geometyr shader code
>   //--
>   //.
>   uniform sampler1D data;
>   void main()
> {
> //get the texel's value,but the value is wrong
> vec4 C0=vec4(texelFetch(data,0,0).xyz,1.0);
> vec4 C1=vec4(texelFetch(data,1,0).xyz,1.0);
> vec4 C2=vec4(texelFetch(data,2,0).xyz,1.0);
>
> //use value to draw a triangle
> gl_Position=osg_ModelViewProjectionMatrix*C0;
> EmitVertex();
> gl_Position=osg_ModelViewProjectionMatrix*C1;
> EmitVertex();
> gl_Position=osg_ModelViewProjectionMatrix*C2;
> EmitVertex();
>
> EndPrimitive();
> }
>
>
>
> Thank you! My english is poor ,sorry.
>
> Cheers,
> liu
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68848#68848
>
>
>
>
>
> ___
> 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] transfer data to shader with osg::texture

2016-10-04 Thread liu ming
Hi,

  I want to send a set of data to geometry shader with osg::texture,I've got a 
problem:in the geometry shader,I can use glsl  function"texelFetch"to get the 
texel's values,and use the values to draw a triangle,But the values is not 
correct.  the values always are "0" or "1",not the original input.It make me 
confused. whether the code" texture0->setInternalFormat(GL_RGBA16);"  wrong?How 
can I get the correctly texel's values?

The code:
   
 
Code:
  //.
osg::ref_ptr< osg::StateSet > ss = new osg::StateSet;
osg::Texture1D * texture0 = new osg::Texture1D;  
texture0->setDataVariance(osg::Object::DYNAMIC);
osg::ref_ptr image = new osg::Image;
image->allocateImage( 4, 1, 1,  GL_RGB, GL_FLOAT );
//write data to the image
   osg::Vec3* ptr1 = (osg::Vec3*)image->data();
   *ptr1=osg::Vec3( 0.0,0.0,0.0); 
   *ptr1++;
   *ptr1= osg::Vec3( 40.0,0.0,0.0); 
   *ptr1++;
   *ptr1=osg::Vec3( 20.0,0.0,20.0); 

 texture0->setImage(image);  
 texture0->setInternalFormat(GL_RGBA16);
//
osg::ref_ptr< osg::Uniform > sample0 = new osg::Uniform( "data", 0 );
   ss->addUniform(sample0);
ss->setTextureAttributeAndModes(0,
texture0,osg::StateAttribute::ON);  
   // 
  
  //--
  //geometyr shader code
  //--
  //.
  uniform sampler1D data;
  void main()
{
//get the texel's value,but the value is wrong
vec4 C0=vec4(texelFetch(data,0,0).xyz,1.0);
vec4 C1=vec4(texelFetch(data,1,0).xyz,1.0);
vec4 C2=vec4(texelFetch(data,2,0).xyz,1.0);

//use value to draw a triangle
gl_Position=osg_ModelViewProjectionMatrix*C0;
EmitVertex();
gl_Position=osg_ModelViewProjectionMatrix*C1;
EmitVertex();
gl_Position=osg_ModelViewProjectionMatrix*C2;
EmitVertex();

EndPrimitive();
}



Thank you! My english is poor ,sorry.

Cheers,
liu

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





___
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-10-04 Thread Trajce Nikolov NICK
good :) .. Glad you found your own way !

Cheers,
Nick

On Tue, Oct 4, 2016 at 4:14 PM, Mary-Ann Zorra  wrote:

> Hi Nick,
>
> I decided to restart this part, and reimplement the whole code.
> Fortunately it worked fine, and my program behaves as expected. I have no
> idea, what the problem was, but thanks for your help!
>
> Mary-Ann
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68846#68846
>
>
>
>
>
> ___
> 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] multiple input with osgwidgets

2016-10-04 Thread Gianni Ambrosio
Honestly I usually derive from osgGA::GUIEventHandler to handle mouse events.

Cheers,
Gianni

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





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


[osg-users] convert std::vector to osg::BufferObject

2016-10-04 Thread Mary-Ann Zorra
Hi guys,

I have some problems with passing an std::vector to my shader as a uniform, and 
I was wondering, if anyone has some idea, how to do this. So my issue is that 
an std::vector of a custom defined data type have to get bound to the shader. I 
have an osg::UniformBufferObject and I would like to fill it with 
addBufferData(myVector). The problem is, that this method expects an osg 
BufferObject, and I can not figure it out, how I could convert my custom 
vector. I thought it should be possible, to create an osg::Array with any 
(custom) data type. But it seems, that you can only use  the from osg 
predefined objects. So is there maybe an other way, to convert a vector to a 
BufferObject or am I doing something wrong? :/

Thank you!

Cheers,
Mary

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





___
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-10-04 Thread Mary-Ann Zorra
Hi Nick,

I decided to restart this part, and reimplement the whole code. Fortunately it 
worked fine, and my program behaves as expected. I have no idea, what the 
problem was, but thanks for your help!

Mary-Ann

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





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


Re: [osg-users] Error with osgDB::readRefNodeFiles

2016-10-04 Thread Robert Osfield
HI Inna,

The osgDB::readRefNodeFile(..) function is a relatively recent
addition, older versions of the OSG don't have have it.  Were you
following a new code example against an older version of the OSG?

Robert.

On 4 October 2016 at 12:15, Inna Reddy  wrote:
> Hi all ,
>
> In my code , I have been using the osgDB::readRefNodefiles. When I do compile 
> the code it throwing me an error saying :
>
>
>
> Error   2   error C2039: 'readRefNodeFiles' : is not a member of 'osgDB'
>
> Error   3   error C3861: 'readRefNodeFiles': identifier not found
>
> IntelliSense: namespace "osgDB" has no member "readRefNodeFiles"
>
>
> I have included the libs also.
>
> #include 
> #include 
> #include 
>
>
> Code:
> and the code part is
> osg::ref_ptr loadedModel = osgDB::readRefNodeFiles(arguments);
> if (loadedModel.valid())
> {
> mainGroup->addChild(loadedModel);
>
> center = loadedModel->getBound().center();
> diameter = loadedModel->getBound().radius() * 2.0f;
> }
>
>
>
>
> Thank you!
>
> Cheers,
> Inna
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68840#68840
>
>
>
>
>
> ___
> 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] Camera manipulator changes for inverted y axis

2016-10-04 Thread Tunc Bahcecioglu
Hi,

I reverted the y axis by adjusting the camera projection matrix:

Code:
camera->setProjectionMatrixAsPerspective(30.0f, 
static_cast(traits->width) / static_cast(traits->height), 1.0f, 
1.0f);
auto originalProjection = camera->getProjectionMatrix();
osg::Matrixd reverseYMat;
reverseYMat.makeScale(osg::Vec3d(1.0, -1.0, 1.0));
camera->setProjectionMatrix(reverseYMat * originalProjection);



The code works, however I have a problem with the trackball manipulator.
The manipulator sets the home position reverse in Z direction: everything is 
positioned upside down. Furthermore when I rotate the camera the movement in 
the Z direction seems to be reversed.

What should I do to change the behavior of the manipulator to the expected one?

Thank you!

Cheers,
tunc

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





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


Re: [osg-users] multiple input with osgwidgets

2016-10-04 Thread Sebastian Schmidt

gambr wrote:
> Hi Meldryt,
> I worked with osgWidget in the past. I move a widget with 
> left_mouse+mouse_move and resize it with central_mouse_button+mouse_move.
> I also tried to show a contextual menu clicking with right mouse button on it.
> Now I'm on OSG 3.4.0 but moved recentrly from OSG 3.0.1.
> 
> Could you please just write "one" of the cases not working in your 
> implemetation?
> 
> Cheers,
> Gianni


This all is one case. Its also not triggering for my parent window (canvas).

When i have two buttons pressed and release one of them, i get no event 
(release or drag) for the second button.

I don't know why this is happening with osgWidget::Input but not with my 
CameraManipulator.

I could try this with 3.4.0, maybe it was fixed in the past.

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





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


Re: [osg-users] Vector script out of range

2016-10-04 Thread Sebastian Messerschmidt



Hi Uma,

There is no model attached.
Without giving us a model that shows this behavior and some basic 
information on your OSG-Version, build environment etc. it is hard to 
guess what is going on.
Most likely the ply-reader produces the error, so please try to attach 
the model so we can investigate. In case you are building OSG yourself, 
it should be easy to attach a debugger and check what is going on for 
yourself ...


Cheers
Sebastian

Hi,

I have tried a simple program in C++ to render 3d model using Osg Viewer.
When I am trying to run the code I am getting "vector script out of range error 
" for some 3d model.

This is my code.

/*osg header files */

int main(int argc,char**argv)
{


/*using ref_ptr*/
osg::ref_ptr root = osgDB::readNodeFile("bunny.ply");
osgViewer::Viewer viewer;
viewer.setSceneData(root.get());
return viewer.run();
}

can some body tell me what is the problem. but it is working for some models. I 
have attached the 3d model file. I have loaded 2963 KB file


Thank you!

Cheers,
Uma

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





___
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] Vector script out of range

2016-10-04 Thread Uma Devi Selvaraj
Hi,

I have tried a simple program in C++ to render 3d model using Osg Viewer.
When I am trying to run the code I am getting "vector script out of range error 
" for some 3d model.

This is my code.

/*osg header files */

int main(int argc,char**argv)
{


/*using ref_ptr*/
osg::ref_ptr root = osgDB::readNodeFile("bunny.ply");
osgViewer::Viewer viewer;
viewer.setSceneData(root.get());
return viewer.run();
}

can some body tell me what is the problem. but it is working for some models. I 
have attached the 3d model file. I have loaded 2963 KB file


Thank you!

Cheers,
Uma

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





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


Re: [osg-users] Error with osgDB::readRefNodeFiles

2016-10-04 Thread Inna Reddy
Hi,

Sorry, I found my mistake.  :) 

I have to use osg::ref_ptr loadedModel = 
osgDB::readNodeFiles(arguments);

//not the readRefNodeFiles. 


thanks all . 
... 

Thank you!

Cheers,
Inna

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





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


[osg-users] Error with osgDB::readRefNodeFiles

2016-10-04 Thread Inna Reddy
Hi all ,

In my code , I have been using the osgDB::readRefNodefiles. When I do compile 
the code it throwing me an error saying : 



Error   2   error C2039: 'readRefNodeFiles' : is not a member of 'osgDB'

Error   3   error C3861: 'readRefNodeFiles': identifier not found   

IntelliSense: namespace "osgDB" has no member "readRefNodeFiles"


I have included the libs also.

#include  
#include 
#include 


Code:
and the code part is 
osg::ref_ptr loadedModel = osgDB::readRefNodeFiles(arguments);
if (loadedModel.valid())
{
mainGroup->addChild(loadedModel);

center = loadedModel->getBound().center();
diameter = loadedModel->getBound().radius() * 2.0f;
}




Thank you!

Cheers,
Inna

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





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