2001-12-19 08:38:23 +08:00
|
|
|
#include <osg/TexMat>
|
2001-09-20 05:08:56 +08:00
|
|
|
|
2001-12-19 08:38:23 +08:00
|
|
|
#include <osgDB/Registry>
|
|
|
|
#include <osgDB/Input>
|
|
|
|
#include <osgDB/Output>
|
2001-09-20 05:08:56 +08:00
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
using namespace osgDB;
|
|
|
|
|
|
|
|
// forward declare functions to use later.
|
|
|
|
bool TexMat_readLocalData(Object& obj, Input& fr);
|
|
|
|
bool TexMat_writeLocalData(const Object& obj, Output& fw);
|
|
|
|
|
|
|
|
// register the read and write functions with the osgDB::Registry.
|
|
|
|
RegisterDotOsgWrapperProxy g_TexMatProxy
|
|
|
|
(
|
2002-12-16 21:40:58 +08:00
|
|
|
new osg::TexMat,
|
2001-09-20 05:08:56 +08:00
|
|
|
"TexMat",
|
|
|
|
"Object StateAttribute TexMat",
|
|
|
|
&TexMat_readLocalData,
|
|
|
|
&TexMat_writeLocalData
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
bool TexMat_readLocalData(Object& obj, Input& fr)
|
|
|
|
{
|
|
|
|
bool iteratorAdvanced = false;
|
|
|
|
|
|
|
|
TexMat& texmat = static_cast<TexMat&>(obj);
|
|
|
|
|
|
|
|
bool matched = true;
|
|
|
|
for(int k=0;k<16 && matched;++k)
|
|
|
|
{
|
|
|
|
matched = fr[k].isFloat();
|
|
|
|
}
|
|
|
|
if (matched)
|
|
|
|
{
|
|
|
|
|
|
|
|
Matrix& matrix = texmat.getMatrix();
|
|
|
|
|
|
|
|
int k=0;
|
2003-09-03 18:47:25 +08:00
|
|
|
double v;
|
2001-09-20 05:08:56 +08:00
|
|
|
for(int i=0;i<4;++i)
|
|
|
|
{
|
|
|
|
for(int j=0;j<4;++j)
|
|
|
|
{
|
2003-09-29 21:35:02 +08:00
|
|
|
fr[k].getFloat(v);
|
2003-09-03 18:47:25 +08:00
|
|
|
matrix(i,j)=v;
|
2001-09-20 05:08:56 +08:00
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fr += 16;
|
|
|
|
iteratorAdvanced = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iteratorAdvanced;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool TexMat_writeLocalData(const Object& obj, Output& fw)
|
|
|
|
{
|
|
|
|
const TexMat& texmat = static_cast<const TexMat&>(obj);
|
|
|
|
const Matrix& matrix = texmat.getMatrix();
|
2001-12-15 18:00:43 +08:00
|
|
|
fw.indent() << matrix(0,0) << " " << matrix(0,1) << " " << matrix(0,2) << " " << matrix(0,3) << std::endl;
|
|
|
|
fw.indent() << matrix(1,0) << " " << matrix(1,1) << " " << matrix(1,2) << " " << matrix(1,3) << std::endl;
|
|
|
|
fw.indent() << matrix(2,0) << " " << matrix(2,1) << " " << matrix(2,2) << " " << matrix(2,3) << std::endl;
|
|
|
|
fw.indent() << matrix(3,0) << " " << matrix(3,1) << " " << matrix(3,2) << " " << matrix(3,3) << std::endl;
|
2001-09-20 05:08:56 +08:00
|
|
|
return true;
|
|
|
|
}
|