From Mike Weiblen, added GLSL datatypes mat2 and mat3 to osg::Uniform, with .osg and .ive support
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* file: include/osg/Uniform
|
||||
* author: Mike Weiblen 2005-05-05
|
||||
/* file: include/osg/Uniform
|
||||
* author: Mike Weiblen 2005-06-03
|
||||
*/
|
||||
|
||||
#ifndef OSG_UNIFORM
|
||||
@@ -33,6 +33,111 @@ namespace osg {
|
||||
class GL2Extensions;
|
||||
class NodeVisitor;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ classes to represent the GLSL-specific "mat2" & "mat3" types.
|
||||
|
||||
class OSG_EXPORT Matrix2
|
||||
{
|
||||
public:
|
||||
Matrix2() { makeIdentity(); }
|
||||
Matrix2( const Matrix2& mat ) { set(mat.ptr()); }
|
||||
Matrix2( float a00, float a01,
|
||||
float a10, float a11 )
|
||||
{
|
||||
set( a00, a01, a10, a11 );
|
||||
}
|
||||
~Matrix2() {}
|
||||
float& operator()(int row, int col) { return _mat[row][col]; }
|
||||
float operator()(int row, int col) const { return _mat[row][col]; }
|
||||
|
||||
Matrix2& operator = (const Matrix2& rhs)
|
||||
{
|
||||
if( &rhs == this ) return *this;
|
||||
set(rhs.ptr());
|
||||
return *this;
|
||||
}
|
||||
|
||||
void set(const Matrix2& rhs) { set(rhs.ptr()); }
|
||||
|
||||
void set(float const * const ptr)
|
||||
{
|
||||
float* local_ptr = (float*)_mat;
|
||||
for(int i=0;i<4;++i) local_ptr[i]=ptr[i];
|
||||
}
|
||||
|
||||
void set(float a00, float a01,
|
||||
float a10, float a11)
|
||||
{
|
||||
_mat[0][0]=a00; _mat[0][1]=a01;
|
||||
_mat[1][0]=a10; _mat[1][1]=a11;
|
||||
}
|
||||
|
||||
float* ptr() { return (float*)_mat; }
|
||||
const float* ptr() const { return (const float*)_mat; }
|
||||
|
||||
float& operator [] (int i) {return ptr()[i];}
|
||||
float operator [] (int i) const {return ptr()[i];}
|
||||
|
||||
void makeIdentity() { set( 1, 0, 0, 1 ); }
|
||||
|
||||
protected:
|
||||
float _mat[2][2];
|
||||
};
|
||||
|
||||
|
||||
class OSG_EXPORT Matrix3
|
||||
{
|
||||
public:
|
||||
Matrix3() { makeIdentity(); }
|
||||
Matrix3( const Matrix3& mat ) { set(mat.ptr()); }
|
||||
Matrix3( float a00, float a01, float a02,
|
||||
float a10, float a11, float a12,
|
||||
float a20, float a21, float a22 )
|
||||
{
|
||||
set( a00, a01, a02, a10, a11, a12, a20, a21, a22 );
|
||||
}
|
||||
~Matrix3() {}
|
||||
float& operator()(int row, int col) { return _mat[row][col]; }
|
||||
float operator()(int row, int col) const { return _mat[row][col]; }
|
||||
|
||||
Matrix3& operator = (const Matrix3& rhs)
|
||||
{
|
||||
if( &rhs == this ) return *this;
|
||||
set(rhs.ptr());
|
||||
return *this;
|
||||
}
|
||||
|
||||
void set(const Matrix3& rhs) { set(rhs.ptr()); }
|
||||
|
||||
void set(float const * const ptr)
|
||||
{
|
||||
float* local_ptr = (float*)_mat;
|
||||
for(int i=0;i<9;++i) local_ptr[i]=ptr[i];
|
||||
}
|
||||
|
||||
void set(float a00, float a01, float a02,
|
||||
float a10, float a11, float a12,
|
||||
float a20, float a21, float a22 )
|
||||
{
|
||||
_mat[0][0]=a00; _mat[0][1]=a01; _mat[0][2]=a02;
|
||||
_mat[1][0]=a10; _mat[1][1]=a11; _mat[1][2]=a12;
|
||||
_mat[2][0]=a20; _mat[2][1]=a21; _mat[2][2]=a22;
|
||||
}
|
||||
|
||||
float* ptr() { return (float*)_mat; }
|
||||
const float* ptr() const { return (const float*)_mat; }
|
||||
|
||||
float& operator [] (int i) {return ptr()[i];}
|
||||
float operator [] (int i) const {return ptr()[i];}
|
||||
|
||||
void makeIdentity() { set( 1, 0, 0, 0, 1, 0, 0, 0, 1 ); }
|
||||
|
||||
protected:
|
||||
float _mat[3][3];
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Uniform encapsulates glUniform values */
|
||||
class OSG_EXPORT Uniform : public Object
|
||||
{
|
||||
@@ -99,8 +204,8 @@ class OSG_EXPORT Uniform : public Object
|
||||
Uniform( const char* name, const osg::Vec2& v2 );
|
||||
Uniform( const char* name, const osg::Vec3& v3 );
|
||||
Uniform( const char* name, const osg::Vec4& v4 );
|
||||
//TODO Uniform( const char* name, const osg::Matrix2& m2 );
|
||||
//TODO Uniform( const char* name, const osg::Matrix3& m3 );
|
||||
Uniform( const char* name, const osg::Matrix2& m2 );
|
||||
Uniform( const char* name, const osg::Matrix3& m3 );
|
||||
Uniform( const char* name, const osg::Matrixf& m4 );
|
||||
Uniform( const char* name, const osg::Matrixd& m4 );
|
||||
Uniform( const char* name, int i0, int i1 );
|
||||
@@ -153,8 +258,8 @@ class OSG_EXPORT Uniform : public Object
|
||||
bool set( const osg::Vec2& v2 );
|
||||
bool set( const osg::Vec3& v3 );
|
||||
bool set( const osg::Vec4& v4 );
|
||||
//TODO bool set( const osg::Matrix2& m2 );
|
||||
//TODO bool set( const osg::Matrix3& m3 );
|
||||
bool set( const osg::Matrix2& m2 );
|
||||
bool set( const osg::Matrix3& m3 );
|
||||
bool set( const osg::Matrixf& m4 );
|
||||
bool set( const osg::Matrixd& m4 );
|
||||
bool set( int i0, int i1 );
|
||||
@@ -171,8 +276,8 @@ class OSG_EXPORT Uniform : public Object
|
||||
bool get( osg::Vec2& v2 ) const;
|
||||
bool get( osg::Vec3& v3 ) const;
|
||||
bool get( osg::Vec4& v4 ) const;
|
||||
//TODO bool get( osg::Matrix2& m2 ) const;
|
||||
//TODO bool get( osg::Matrix3& m3 ) const;
|
||||
bool get( osg::Matrix2& m2 ) const;
|
||||
bool get( osg::Matrix3& m3 ) const;
|
||||
bool get( osg::Matrixf& m4 ) const;
|
||||
bool get( osg::Matrixd& m4 ) const;
|
||||
bool get( int& i0, int& i1 ) const;
|
||||
@@ -227,8 +332,8 @@ class OSG_EXPORT Uniform : public Object
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~Uniform() {}
|
||||
Uniform& operator=(const Uniform&) { return *this; } // disallowed
|
||||
virtual ~Uniform();
|
||||
Uniform& operator=(const Uniform&) { return *this; }
|
||||
|
||||
bool isCompatibleType( Type t ) const;
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ class OSGPRODUCER_EXPORT EventAdapter : public osgGA::GUIEventAdapter
|
||||
/** Get the EventType of the GUI event.*/
|
||||
virtual EventType getEventType() const { return _eventType; }
|
||||
|
||||
inline void setKey(int key) { _key = key; }
|
||||
|
||||
/** key pressed, return -1 if inappropriate for this event. */
|
||||
virtual int getKey() const { return _key; }
|
||||
|
||||
@@ -51,12 +53,18 @@ class OSGPRODUCER_EXPORT EventAdapter : public osgGA::GUIEventAdapter
|
||||
/** window maximum y. */
|
||||
virtual float getYmax() const { return _Ymax; }
|
||||
|
||||
inline void setX(float x) { _mx = x; }
|
||||
|
||||
/** current mouse x position.*/
|
||||
virtual float getX() const { return _mx; }
|
||||
|
||||
inline void setY(float y) { _my = y; }
|
||||
|
||||
/** current mouse y position.*/
|
||||
virtual float getY() const { return _my; }
|
||||
|
||||
inline void setButtonMak(unsigned int mask) { _buttonMask = mask; }
|
||||
|
||||
/** current mouse button state */
|
||||
virtual unsigned int getButtonMask() const { return _buttonMask; }
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/* file: src/osg/Uniform.cpp
|
||||
* author: Mike Weiblen 2005-05-05
|
||||
/* file: src/osg/Uniform.cpp
|
||||
* author: Mike Weiblen 2005-06-03
|
||||
*/
|
||||
|
||||
#include <osg/Notify>
|
||||
@@ -41,27 +41,27 @@ Uniform::Uniform( Type type, const std::string& name ) :
|
||||
|
||||
switch( _type )
|
||||
{
|
||||
case FLOAT: set( 0.0f ); break;
|
||||
case FLOAT_VEC2: set( osg::Vec2() ); break;
|
||||
case FLOAT_VEC3: set( osg::Vec3() ); break;
|
||||
case FLOAT_VEC4: set( osg::Vec4() ); break;
|
||||
case INT: set( 0 ); break;
|
||||
case INT_VEC2: set( 0, 0 ); break;
|
||||
case INT_VEC3: set( 0, 0, 0 ); break;
|
||||
case INT_VEC4: set( 0, 0, 0, 0 ); break;
|
||||
case BOOL: set( false ); break;
|
||||
case BOOL_VEC2: set( false, false ); break;
|
||||
case BOOL_VEC3: set( false, false, false ); break;
|
||||
case BOOL_VEC4: set( false, false, false, false ); break;
|
||||
// TODO case FLOAT_MAT2:
|
||||
// TODO case FLOAT_MAT3:
|
||||
case FLOAT_MAT4: set( osg::Matrixf() ); break;
|
||||
case SAMPLER_1D: set( 0 ); break;
|
||||
case SAMPLER_2D: set( 0 ); break;
|
||||
case SAMPLER_3D: set( 0 ); break;
|
||||
case SAMPLER_CUBE: set( 0 ); break;
|
||||
case SAMPLER_1D_SHADOW: set( 0 ); break;
|
||||
case SAMPLER_2D_SHADOW: set( 0 ); break;
|
||||
case FLOAT: set( 0.0f ); break;
|
||||
case FLOAT_VEC2: set( osg::Vec2() ); break;
|
||||
case FLOAT_VEC3: set( osg::Vec3() ); break;
|
||||
case FLOAT_VEC4: set( osg::Vec4() ); break;
|
||||
case INT: set( 0 ); break;
|
||||
case INT_VEC2: set( 0, 0 ); break;
|
||||
case INT_VEC3: set( 0, 0, 0 ); break;
|
||||
case INT_VEC4: set( 0, 0, 0, 0 ); break;
|
||||
case BOOL: set( false ); break;
|
||||
case BOOL_VEC2: set( false, false ); break;
|
||||
case BOOL_VEC3: set( false, false, false ); break;
|
||||
case BOOL_VEC4: set( false, false, false, false ); break;
|
||||
case FLOAT_MAT2: set( osg::Matrix2() ); break;
|
||||
case FLOAT_MAT3: set( osg::Matrix3() ); break;
|
||||
case FLOAT_MAT4: set( osg::Matrixf() ); break;
|
||||
case SAMPLER_1D: set( 0 ); break;
|
||||
case SAMPLER_2D: set( 0 ); break;
|
||||
case SAMPLER_3D: set( 0 ); break;
|
||||
case SAMPLER_CUBE: set( 0 ); break;
|
||||
case SAMPLER_1D_SHADOW: set( 0 ); break;
|
||||
case SAMPLER_2D_SHADOW: set( 0 ); break;
|
||||
default:
|
||||
osg::notify(osg::WARN) << "UNDEFINED Uniform type" << std::endl;
|
||||
break;
|
||||
@@ -74,6 +74,10 @@ Uniform::Uniform( const Uniform& rhs, const CopyOp& copyop ) :
|
||||
copyData( rhs );
|
||||
}
|
||||
|
||||
Uniform::~Uniform()
|
||||
{
|
||||
}
|
||||
|
||||
void Uniform::addParent(osg::StateSet* object)
|
||||
{
|
||||
osg::notify(osg::INFO)<<"Uniform Adding parent"<<std::endl;
|
||||
@@ -286,8 +290,8 @@ bool Uniform::isCompatibleType( Type t ) const
|
||||
if( getGlApiType(t) == getGlApiType(getType()) ) return true;
|
||||
|
||||
osg::notify(osg::WARN)
|
||||
<< "Cannot assign between Uniform types " << getTypename(t)
|
||||
<< " and " << getTypename(getType()) << std::endl;
|
||||
<< "Cannot assign between Uniform types " << getTypename(t)
|
||||
<< " and " << getTypename(getType()) << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -298,54 +302,54 @@ const char* Uniform::getTypename( Type t )
|
||||
{
|
||||
switch( t )
|
||||
{
|
||||
case FLOAT: return "float";
|
||||
case FLOAT_VEC2: return "vec2";
|
||||
case FLOAT_VEC3: return "vec3";
|
||||
case FLOAT_VEC4: return "vec4";
|
||||
case INT: return "int";
|
||||
case INT_VEC2: return "ivec2";
|
||||
case INT_VEC3: return "ivec3";
|
||||
case INT_VEC4: return "ivec4";
|
||||
case BOOL: return "bool";
|
||||
case BOOL_VEC2: return "bvec2";
|
||||
case BOOL_VEC3: return "bvec3";
|
||||
case BOOL_VEC4: return "bvec4";
|
||||
case FLOAT_MAT2: return "mat2";
|
||||
case FLOAT_MAT3: return "mat3";
|
||||
case FLOAT_MAT4: return "mat4";
|
||||
case SAMPLER_1D: return "sampler1D";
|
||||
case SAMPLER_2D: return "sampler2D";
|
||||
case SAMPLER_3D: return "sampler3D";
|
||||
case SAMPLER_CUBE: return "samplerCube";
|
||||
case SAMPLER_1D_SHADOW: return "sampler1DShadow";
|
||||
case SAMPLER_2D_SHADOW: return "sampler2DShadow";
|
||||
default: return "UNDEFINED";
|
||||
case FLOAT: return "float";
|
||||
case FLOAT_VEC2: return "vec2";
|
||||
case FLOAT_VEC3: return "vec3";
|
||||
case FLOAT_VEC4: return "vec4";
|
||||
case INT: return "int";
|
||||
case INT_VEC2: return "ivec2";
|
||||
case INT_VEC3: return "ivec3";
|
||||
case INT_VEC4: return "ivec4";
|
||||
case BOOL: return "bool";
|
||||
case BOOL_VEC2: return "bvec2";
|
||||
case BOOL_VEC3: return "bvec3";
|
||||
case BOOL_VEC4: return "bvec4";
|
||||
case FLOAT_MAT2: return "mat2";
|
||||
case FLOAT_MAT3: return "mat3";
|
||||
case FLOAT_MAT4: return "mat4";
|
||||
case SAMPLER_1D: return "sampler1D";
|
||||
case SAMPLER_2D: return "sampler2D";
|
||||
case SAMPLER_3D: return "sampler3D";
|
||||
case SAMPLER_CUBE: return "samplerCube";
|
||||
case SAMPLER_1D_SHADOW: return "sampler1DShadow";
|
||||
case SAMPLER_2D_SHADOW: return "sampler2DShadow";
|
||||
default: return "UNDEFINED";
|
||||
}
|
||||
}
|
||||
|
||||
Uniform::Type Uniform::getTypeId( const std::string& tname )
|
||||
{
|
||||
if( tname == "float" ) return FLOAT;
|
||||
if( tname == "vec2" ) return FLOAT_VEC2;
|
||||
if( tname == "vec3" ) return FLOAT_VEC3;
|
||||
if( tname == "vec4" ) return FLOAT_VEC4;
|
||||
if( tname == "int" ) return INT;
|
||||
if( tname == "ivec2" ) return INT_VEC2;
|
||||
if( tname == "ivec3" ) return INT_VEC3;
|
||||
if( tname == "ivec4" ) return INT_VEC4;
|
||||
if( tname == "bool" ) return BOOL;
|
||||
if( tname == "bvec2" ) return BOOL_VEC2;
|
||||
if( tname == "bvec3" ) return BOOL_VEC3;
|
||||
if( tname == "bvec4" ) return BOOL_VEC4;
|
||||
if( tname == "mat2" ) return FLOAT_MAT2;
|
||||
if( tname == "mat3" ) return FLOAT_MAT3;
|
||||
if( tname == "mat4" ) return FLOAT_MAT4;
|
||||
if( tname == "sampler1D" ) return SAMPLER_1D;
|
||||
if( tname == "sampler2D" ) return SAMPLER_2D;
|
||||
if( tname == "sampler3D" ) return SAMPLER_3D;
|
||||
if( tname == "samplerCube" ) return SAMPLER_CUBE;
|
||||
if( tname == "sampler1DShadow" ) return SAMPLER_1D_SHADOW;
|
||||
if( tname == "sampler2DShadow" ) return SAMPLER_2D_SHADOW;
|
||||
if( tname == "float" ) return FLOAT;
|
||||
if( tname == "vec2" ) return FLOAT_VEC2;
|
||||
if( tname == "vec3" ) return FLOAT_VEC3;
|
||||
if( tname == "vec4" ) return FLOAT_VEC4;
|
||||
if( tname == "int" ) return INT;
|
||||
if( tname == "ivec2" ) return INT_VEC2;
|
||||
if( tname == "ivec3" ) return INT_VEC3;
|
||||
if( tname == "ivec4" ) return INT_VEC4;
|
||||
if( tname == "bool" ) return BOOL;
|
||||
if( tname == "bvec2" ) return BOOL_VEC2;
|
||||
if( tname == "bvec3" ) return BOOL_VEC3;
|
||||
if( tname == "bvec4" ) return BOOL_VEC4;
|
||||
if( tname == "mat2" ) return FLOAT_MAT2;
|
||||
if( tname == "mat3" ) return FLOAT_MAT3;
|
||||
if( tname == "mat4" ) return FLOAT_MAT4;
|
||||
if( tname == "sampler1D" ) return SAMPLER_1D;
|
||||
if( tname == "sampler2D" ) return SAMPLER_2D;
|
||||
if( tname == "sampler3D" ) return SAMPLER_3D;
|
||||
if( tname == "samplerCube" ) return SAMPLER_CUBE;
|
||||
if( tname == "sampler1DShadow" ) return SAMPLER_1D_SHADOW;
|
||||
if( tname == "sampler2DShadow" ) return SAMPLER_2D_SHADOW;
|
||||
return UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -404,9 +408,17 @@ Uniform::Uniform( const char* name, const osg::Vec4& v4 ) :
|
||||
set( v4 );
|
||||
}
|
||||
|
||||
//Uniform::Uniform( const char* name, const osg::Matrix2& m2 )
|
||||
Uniform::Uniform( const char* name, const osg::Matrix2& m2 ) :
|
||||
_type(FLOAT_MAT2), _name(name)
|
||||
{
|
||||
set( m2 );
|
||||
}
|
||||
|
||||
//Uniform::Uniform( const char* name, const osg::Matrix3& m3 )
|
||||
Uniform::Uniform( const char* name, const osg::Matrix3& m3 ) :
|
||||
_type(FLOAT_MAT3), _name(name)
|
||||
{
|
||||
set( m3 );
|
||||
}
|
||||
|
||||
Uniform::Uniform( const char* name, const osg::Matrixf& m4 ) :
|
||||
_type(FLOAT_MAT4), _name(name)
|
||||
@@ -509,21 +521,28 @@ bool Uniform::set( const osg::Vec4& v4 )
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO bool Uniform::set( const osg::Matrix2& m2 )
|
||||
bool Uniform::set( const osg::Matrix2& m2 )
|
||||
{
|
||||
if( ! isCompatibleType(FLOAT_MAT2) ) return false;
|
||||
for( int i = 0; i < 4; ++i ) _data.f4[i] = m2[i];
|
||||
dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO bool Uniform::set( const osg::Matrix3& m3 )
|
||||
|
||||
bool Uniform::set( const osg::Matrix3& m3 )
|
||||
{
|
||||
if( ! isCompatibleType(FLOAT_MAT3) ) return false;
|
||||
for( int i = 0; i < 9; ++i ) _data.f9[i] = m3[i];
|
||||
dirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Uniform::set( const osg::Matrixf& m4 )
|
||||
{
|
||||
if( ! isCompatibleType(FLOAT_MAT4) ) return false;
|
||||
int n = 0;
|
||||
for(int row=0; row<4; ++row)
|
||||
{
|
||||
for(int col=0; col<4; ++col)
|
||||
{
|
||||
_data.f16[n++] = m4(row,col);
|
||||
}
|
||||
}
|
||||
const Matrixf::value_type* p = m4.ptr();
|
||||
for( int i = 0; i < 16; ++i ) _data.f16[i] = p[i];
|
||||
dirty();
|
||||
return true;
|
||||
}
|
||||
@@ -531,14 +550,8 @@ bool Uniform::set( const osg::Matrixf& m4 )
|
||||
bool Uniform::set( const osg::Matrixd& m4 )
|
||||
{
|
||||
if( ! isCompatibleType(FLOAT_MAT4) ) return false;
|
||||
int n = 0;
|
||||
for(int row=0; row<4; ++row)
|
||||
{
|
||||
for(int col=0; col<4; ++col)
|
||||
{
|
||||
_data.f16[n++] = static_cast<float>(m4(row,col));
|
||||
}
|
||||
}
|
||||
const Matrixd::value_type* p = m4.ptr();
|
||||
for( int i = 0; i < 16; ++i ) _data.f16[i] = static_cast<float>(p[i]);
|
||||
dirty();
|
||||
return true;
|
||||
}
|
||||
@@ -656,35 +669,31 @@ bool Uniform::get( osg::Vec4& v4 ) const
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO bool Uniform::get( osg::Matrix2& m2 ) const
|
||||
bool Uniform::get( osg::Matrix2& m2 ) const
|
||||
{
|
||||
if( ! isCompatibleType(FLOAT_MAT2) ) return false;
|
||||
m2.set( _data.f4 );
|
||||
return true;
|
||||
}
|
||||
|
||||
//TODO bool Uniform::get( osg::Matrix3& m3 ) const
|
||||
bool Uniform::get( osg::Matrix3& m3 ) const
|
||||
{
|
||||
if( ! isCompatibleType(FLOAT_MAT3) ) return false;
|
||||
m3.set( _data.f9 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Uniform::get( osg::Matrixf& m4 ) const
|
||||
{
|
||||
if( ! isCompatibleType(FLOAT_MAT4) ) return false;
|
||||
int n = 0;
|
||||
for(int row=0; row<4; ++row)
|
||||
{
|
||||
for(int col=0; col<4; ++col)
|
||||
{
|
||||
m4(row,col) = _data.f16[n++];
|
||||
}
|
||||
}
|
||||
m4.set( _data.f16 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Uniform::get( osg::Matrixd& m4 ) const
|
||||
{
|
||||
if( ! isCompatibleType(FLOAT_MAT4) ) return false;
|
||||
int n = 0;
|
||||
for(int row=0; row<4; ++row)
|
||||
{
|
||||
for(int col=0; col<4; ++col)
|
||||
{
|
||||
m4(row,col) = _data.f16[n++];
|
||||
}
|
||||
}
|
||||
m4.set( _data.f16 );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,12 +100,16 @@ void Uniform::write(DataOutputStream* out){
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT2):
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : type mat2 not supported for reading."<<std::endl;
|
||||
osg::Matrix2 m2;
|
||||
get(m2);
|
||||
for(int i=0; i<4; ++i) out->writeFloat(m2[i]);
|
||||
break;
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT3):
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : type mat3 not supported for reading."<<std::endl;
|
||||
osg::Matrix3 m3;
|
||||
get(m3);
|
||||
for(int i=0; i<9; ++i) out->writeFloat(m3[i]);
|
||||
break;
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT4):
|
||||
@@ -117,7 +121,7 @@ void Uniform::write(DataOutputStream* out){
|
||||
}
|
||||
default:
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : uniform "<<getType()<<"type not supported for reading."<<std::endl;
|
||||
osg::notify(osg::WARN)<<"Warning : uniform "<<getType()<<"type not supported for writing."<<std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -202,12 +206,16 @@ void Uniform::read(DataInputStream* in)
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT2):
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : type mat2 not supported for reading."<<std::endl;
|
||||
osg::Matrix2 m2;
|
||||
for(int i=0; i<9; ++i) m2[i]=in->readFloat();
|
||||
set(m2);
|
||||
break;
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT3):
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : type mat3 not supported for reading."<<std::endl;
|
||||
osg::Matrix3 m3;
|
||||
for(int i=0; i<9; ++i) m3[i]=in->readFloat();
|
||||
set(m3);
|
||||
break;
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT4):
|
||||
|
||||
@@ -140,12 +140,27 @@ bool Uniform_readLocalData(Object& obj, Input& fr)
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT2):
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : type mat2 not supported for reading."<<std::endl;
|
||||
osg::Matrix2 value;
|
||||
if (fr[0].getFloat(value[0]) && fr[1].getFloat(value[1]) &&
|
||||
fr[2].getFloat(value[2]) && fr[3].getFloat(value[3]))
|
||||
{
|
||||
uniform.set(value);
|
||||
fr+=4;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT3):
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : type mat3 not supported for reading."<<std::endl;
|
||||
osg::Matrix3 value;
|
||||
if (fr[0].getFloat(value[0]) && fr[1].getFloat(value[1]) && fr[2].getFloat(value[2]) &&
|
||||
fr[3].getFloat(value[3]) && fr[4].getFloat(value[4]) && fr[5].getFloat(value[5]) &&
|
||||
fr[6].getFloat(value[6]) && fr[7].getFloat(value[7]) && fr[8].getFloat(value[8]))
|
||||
{
|
||||
uniform.set(value);
|
||||
fr+=9;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT4):
|
||||
@@ -237,12 +252,19 @@ bool Uniform_writeLocalData(const Object& obj,Output& fw)
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT2):
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : type mat2 not supported for writing."<<std::endl;
|
||||
osg::Matrix2 value;
|
||||
uniform.get(value);
|
||||
fw << value[0]<<" "<<value[1]<<" "
|
||||
<<value[2]<<" "<<value[3];
|
||||
break;
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT3):
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Warning : type mat3 not supported for writing."<<std::endl;
|
||||
osg::Matrix3 value;
|
||||
uniform.get(value);
|
||||
fw << value[0]<<" "<<value[1]<<" "<<value[2]<<" "
|
||||
<<value[3]<<" "<<value[4]<<" "<<value[5]<<" "
|
||||
<<value[6]<<" "<<value[7]<<" "<<value[8];
|
||||
break;
|
||||
}
|
||||
case(osg::Uniform::FLOAT_MAT4):
|
||||
|
||||
Reference in New Issue
Block a user