Hello Joakim,

It works fine now with little amendment mentioned in bold text
Are they conceptually ok  - the 2 lines in bold text?

******************************
  ref_ptr<Geode> capsuleGeode = new Geode;
  ref_ptr<Capsule> capsuleShape = new Capsule(Vec3f(3,0,0),1,2);
  ref_ptr<ShapeDrawable> capsuleDrawable = new ShapeDrawable(capsuleShape.
get());

  capsuleGeode->addDrawable(capsuleDrawable.get());

  ref_ptr<StateSet> capsuleState = capsuleGeode->getOrCreateStateSet();


  //create the shader parameters
  ref_ptr<Program> capsuleProgramObject = new Program;

 * ref_ptr<Shader> capsuleVertexObject = new Shader(*(Shader::**
readShaderFile(Shader::VERTEX,**"shaderSRC/gooch.vert")));
  ref_ptr<Shader> capsuleFragmentObject = new Shader(*(Shader::**
readShaderFile(Shader::**FRAGMENT,"shaderSRC/gooch.**vert")));
*
  capsuleProgramObject->addShader(capsuleVertexObject.get());
  capsuleProgramObject->addShader(capsuleFragmentObject.get());


  //create a new stateset
  //with the default setting
  capsuleState->setAttribute(capsuleProgramObject.get());


  //Passing the uniform variable representing the texture to the shader
  capsuleState->addUniform(new
osg::Uniform("LightPosition",osg::Vec3(0,0,10)));
  capsuleState->addUniform(new
osg::Uniform("SurfaceColor",osg::Vec3(0.75,0.75,0.75)));
  capsuleState->addUniform(new osg::Uniform("WarmColor",osg::Vec3(1,0,0)));
  capsuleState->addUniform(new
osg::Uniform("CoolColor",osg::Vec3(0,0,0.6)));
  capsuleState->addUniform(new osg::Uniform("DiffuseWarm",0.45f));
  capsuleState->addUniform(new osg::Uniform("DiffuseCool", 0.45f));


  root->addChild(capsuleGeode.get());


****************************
I replaced them with the following one

***********************
 ref_ptr<Group> root = new Group();

  ref_ptr<Geode> capsuleGeode = new Geode;
  ref_ptr<Capsule> capsuleShape = new Capsule(Vec3f(3,0,0),1,2);
  ref_ptr<ShapeDrawable> capsuleDrawable = new
ShapeDrawable(capsuleShape.get());

  capsuleGeode->addDrawable(capsuleDrawable.get());

  ref_ptr<StateSet> capsuleState = capsuleGeode->getOrCreateStateSet();


  //create the shader parameters
  ref_ptr<Program> capsuleProgramObject = new Program;

*  ref_ptr<Shader> capsuleVertexShader = new Shader(Shader::VERTEX);
  capsuleVertexShader->loadShaderSourceFromFile("shaderSRC/gooch.vert");
  ref_ptr<Shader> capsuleFragmentShader = new Shader(Shader::FRAGMENT);
  capsuleFragmentShader->loadShaderSourceFromFile("shaderSRC/gooch.frag");
*
  capsuleProgramObject->addShader(capsuleVertexShader.get());
  capsuleProgramObject->addShader(capsuleFragmentShader.get());


  //create a new stateset
  //with the default setting
  capsuleState->setAttribute(capsuleProgramObject.get());


  //Passing the uniform variable representing the texture to the shader
  capsuleState->addUniform(new
osg::Uniform("LightPosition",osg::Vec3(0,0,10)));
  capsuleState->addUniform(new
osg::Uniform("SurfaceColor",osg::Vec3(0.75,0.75,0.75)));
  capsuleState->addUniform(new osg::Uniform("WarmColor",osg::Vec3(1,0,0)));
  capsuleState->addUniform(new
osg::Uniform("CoolColor",osg::Vec3(0,0,0.6)));
  capsuleState->addUniform(new osg::Uniform("DiffuseWarm",0.45f));
  capsuleState->addUniform(new osg::Uniform("DiffuseCool", 0.45f));


  root->addChild(capsuleGeode.get());



***********************

Sajjad


On Wed, Oct 15, 2008 at 11:48 PM, ami guru <[EMAIL PROTECTED]> wrote:

> Thanks Joakim,
>
> I believe that sharing the stateset will be required here
>
> I am trying to attach a simple shader but sharing the stateset is not
> giving me the result
> that i am supposed to have....
>
>
> ******************************
>   ref_ptr<Geode> capsuleGeode = new Geode;
>   ref_ptr<Capsule> capsuleShape = new Capsule(Vec3f(3,0,0),1,2);
>   ref_ptr<ShapeDrawable> capsuleDrawable = new
> ShapeDrawable(capsuleShape.get());
>
>   capsuleGeode->addDrawable(capsuleDrawable.get());
>
>   ref_ptr<StateSet> capsuleState = capsuleGeode->getOrCreateStateSet();
>
>
>   //create the shader parameters
>   ref_ptr<Program> capsuleProgramObject = new Program;
>
>   ref_ptr<Shader> capsuleVertexObject = new
> Shader(*(Shader::readShaderFile(Shader::VERTEX,"shaderSRC/gooch.vert")));
>   ref_ptr<Shader> capsuleFragmentObject = new
> Shader(*(Shader::readShaderFile(Shader::FRAGMENT,"shaderSRC/gooch.vert")));
>
>   capsuleProgramObject->addShader(capsuleVertexObject.get());
>   capsuleProgramObject->addShader(capsuleFragmentObject.get());
>
>
>   //create a new stateset
>   //with the default setting
>   capsuleState->setAttribute(capsuleProgramObject.get());
>
>
>   //Passing the uniform variable representing the texture to the shader
>   capsuleState->addUniform(new
> osg::Uniform("LightPosition",osg::Vec3(0,0,10)));
>   capsuleState->addUniform(new
> osg::Uniform("SurfaceColor",osg::Vec3(0.75,0.75,0.75)));
>   capsuleState->addUniform(new osg::Uniform("WarmColor",osg::Vec3(1,0,0)));
>   capsuleState->addUniform(new
> osg::Uniform("CoolColor",osg::Vec3(0,0,0.6)));
>   capsuleState->addUniform(new osg::Uniform("DiffuseWarm",0.45f));
>   capsuleState->addUniform(new osg::Uniform("DiffuseCool", 0.45f));
>
>
>   root->addChild(capsuleGeode.get());
>
>
> ****************************
> Any hint?
>
>
> Sajjad
>
>
>
> On Wed, Oct 15, 2008 at 10:56 PM, Joakim Simonsson <[EMAIL PROTECTED]>wrote:
>
>> On Wed, 15 Oct 2008 22:43:14 +0200, ami guru <[EMAIL PROTECTED]>
>> wrote:
>>
>>  Hello forum
>>>
>>> Is there any difference between these following:
>>>
>>> 1. osg::ref_ptr<osg::StateSet> nodess3  = new
>>> StateSet((myshapegeode3->getOrCreateStateSet()));
>>> 2. osg::ref_ptr<osg::StateSet>
>>> nodess3((myshapegeode3->getOrCreateStateSet()));
>>>
>>
>> Yes they differ. But do you want to do? Copy the stateset?
>>
>> If you want to share the stateset (for example, edit myshapegeode3's
>> stateset) do this:
>>
>> osg::ref_ptr<osg::StateSet> nodess3 =
>> myshapegeode3->getOrCreateStateSet();
>>
>> If you want to copy it, do this:
>>
>> osg::ref_ptr<osg::StateSet> nodess3 =
>>
>>  myshapegeode3->getOrCreateStateSet()->clone(osg::CopyOp::DEEP_COPY_ALL));
>>
>>
>> --
>> Joakim Simonsson
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to