Hi,

I am just trying to implement some sliding textures for things like waterfalls 
and what have you. I figure that the best way to do this is to modify the 
texture matrix. So, if I want to slide a texture in the U direction by 0.1 
units, I would use a texture matrix that looks like this:


Code:
1.0 0.0 0.0 0.1
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0



Right? So I set out to do this, but it doesn't seem to work. I am wondering if 
anyone can help me make sure that I am doing this correctly? So the code I 
would use would look something like this, right?


Code:

// Create the texture matrix.
osg::Matrix textureMatrix;
textureMatrix.makeTranslate(0.1, 0.0, 0.0);

// Create the Texture Matrix attribute
osg::ref_ptr<osg::TexMat> textureMatrixAttribute = new osg::TexMat;
textureMatrixAttribute->setMatrix(textureMatrix);

// Set the Texture Matrix attribute
osg::ref_ptr<osg::StateSet> stateSet = myNode->getOrCreateStateSet();
stateSet->setTextureAttribute(0, textureMatrixAttribute.get(), 
osg::StateAttribute::OVERRIDE); 
stateSet->setTextureMode(0, GL_TEXTURE_MATRIX, osg::StateAttribute::ON);



Is that about it? I'm having trouble getting this to work. If I call this code 
each frame, with a new texture offset each time (first argument of the 
makeTranslate method call above), I do not get a scrolling texture. Instead, 
the texture doesn't move.

Now, I know that this could be caused by a number of things, and that one could 
not possibly diagnose the problem for me without seeing the above code in the 
context of the entire system. However, I'm hoping that someone here will be 
able to spot something wrong about the above code, the solution to which might 
also be a solution to my problem. =) 

Thank you!

Cheers,
Frank[/code]

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to