The problem is, i want to keep the fish material and just add the animation shaders to it. As long as I just put a MaterialGroup above each clone, i can add a seperate shader each but i lose the fish texture and so on. When I extract the fish material and add the shader to that material, all fish of one kind have the same material again.

 

There is another thing im struggling with, as long as i used just one MaterialGroup above all fish, with a shader assigned to it that was defined globally and altered in the display routine it worked fine:
global:
VertexProgramChunkPtr vertProg;
main:

vertProg = VertexProgramChunk::create();
beginEditCP(vertProg);

      vertProg->read("data/fish_ani.vp");

endEditCP(vertProg);
display:
Real32 time = glutGet(GLUT_ELAPSED_TIME);

Real32 t = osgsin(time/1000.f)*7;

beginEditCP(vertProg, ProgramChunk::ParamNamesFieldMask);

      vertProg->setParameter((short int)0, Vec4f(t,0,0,0));

      vertProg->setParameter((short int)4, Vec4f(2.2,0,0,0));

endEditCP(vertProg, ProgramChunk::ParamNamesFieldMask);
But now i have a global vector of structs in which for each fish a shader shall be present, like this:
global:
VertexProgramChunkPtr vertProg;
struct sFish {

      fishType type;

      TransformPtr transCore;

      NodePtr matNode;

      VertexProgramChunkPtr vert;

      FragmentProgramChunkPtr frag;

};

vector<sFish> fish;
main:

vertProg = VertexProgramChunk::create();
beginEditCP(vertProg);

      vertProg->read("data/fish_ani.vp");

endEditCP(vertProg);
crea
teScenegraph:
newFish.vert = vertProg
fish.push_back(newFish);

When i
iterate over the fish in the display routine the animation does not work, in fact it gets changed somehow, since the fin of the fish is put at some step of the animation but doesnt animate acording to the time (the animation is stuck at some point). Am I doing something wrong? All fish get the same shader applied (it is loaded once and then assigned to each fish), but i want to change the parameters of the shader for each fish seperately. Is there a way to do that, or can it not be done anyway.
Sorry for all the questions, but im getting a bit lost about this :)
Thanks

Matthias


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to