*** empty log message ***
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
OSG Change log
|
||||
==============
|
||||
|
||||
o Placed #ifdef USE_DEPRECATED_MATRIX_METHODS about pre/postScale,
|
||||
pre/postTrans and pre/postRot methods since these are now
|
||||
deprecated, there functionality replace by scale,trans,rotate
|
||||
static methods which create matices to do pre and post multiplication
|
||||
by. Converted the rest of the OSG to use thse new methods.
|
||||
o Converted hangglide to use the sky and base as an earth/sky implementation
|
||||
which replaces the standard glClear done in RenderStage, therefore
|
||||
reducing the fill rate requirements for each frame, and increasing
|
||||
|
||||
@@ -12,19 +12,22 @@
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
// temporary #define to keep backwards compatibility.
|
||||
#define USE_DEPRECATED_MATRIX_METHODS
|
||||
|
||||
namespace osg {
|
||||
|
||||
class Quat;
|
||||
|
||||
class SG_EXPORT Matrix : public Object
|
||||
{
|
||||
// private:
|
||||
public:
|
||||
private:
|
||||
|
||||
float _mat[4][4];
|
||||
bool fully_realized;
|
||||
|
||||
public:
|
||||
// const char* name() { return "My Matrix "; }
|
||||
|
||||
META_Object(Matrix);
|
||||
|
||||
Matrix();
|
||||
@@ -53,7 +56,9 @@ class SG_EXPORT Matrix : public Object
|
||||
float a10, float a11, float a12, float a13,
|
||||
float a20, float a21, float a22, float a23,
|
||||
float a30, float a31, float a32, float a33);
|
||||
const float * values() { return (const float *)_mat; }
|
||||
|
||||
float * ptr() { return (float *)_mat; }
|
||||
const float * ptr() const { return (const float *)_mat; }
|
||||
|
||||
void makeIdent();
|
||||
void makeScale( const Vec3& );
|
||||
@@ -90,8 +95,6 @@ class SG_EXPORT Matrix : public Object
|
||||
inline Vec4 postMult( const Vec4& v ) const;
|
||||
inline Vec4 operator* ( const Vec4& v ) const;
|
||||
|
||||
//start of Deprecated methods
|
||||
|
||||
void setTrans( float tx, float ty, float tz );
|
||||
void setTrans( const Vec3& v );
|
||||
Vec3 getTrans() const { return Vec3(_mat[3][0],_mat[3][1],_mat[3][2]); }
|
||||
|
||||
@@ -30,10 +30,10 @@ static void conv( const Vec3& a, const Matrix& mat, Vec3& b )
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
t[i] = (a[0] * mat._mat[0][i]) +
|
||||
(a[1] * mat._mat[1][i]) +
|
||||
(a[2] * mat._mat[2][i]) +
|
||||
mat._mat[3][i];
|
||||
t[i] = (a[0] * mat(0,i)) +
|
||||
(a[1] * mat(1,i)) +
|
||||
(a[2] * mat(2,i)) +
|
||||
mat(3,i);
|
||||
}
|
||||
b[0] = t[0];
|
||||
b[1] = t[1];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "osg/Billboard"
|
||||
|
||||
#include <osg/Billboard>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -88,10 +89,10 @@ void Billboard::calcRotation(const Vec3& eye_local, const Vec3& pos_local,Matrix
|
||||
float inv = 1.0f/ev_length;
|
||||
float c = ev.y()*inv;
|
||||
float s = ev.x()*inv;
|
||||
mat._mat[0][0] = c;
|
||||
mat._mat[0][1] = -s;
|
||||
mat._mat[1][0] = s;
|
||||
mat._mat[1][1] = c;
|
||||
mat(0,0) = c;
|
||||
mat(0,1) = -s;
|
||||
mat(1,0) = s;
|
||||
mat(1,1) = c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -138,9 +139,9 @@ void Billboard::calcTransform(const Vec3& eye_local, const Vec3& pos_local,Matri
|
||||
calcRotation(eye_local,pos_local,mat);
|
||||
|
||||
// mat.postTrans(pos_local[0],pos_local[1],pos_local[2]);
|
||||
mat._mat[3][0] += pos_local[0];
|
||||
mat._mat[3][1] += pos_local[1];
|
||||
mat._mat[3][2] += pos_local[2];
|
||||
mat(3,0) += pos_local[0];
|
||||
mat(3,1) += pos_local[1];
|
||||
mat(3,2) += pos_local[2];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,10 @@ using namespace osg;
|
||||
#define DEG2RAD(x) ((x)*M_PI/180.0)
|
||||
#define RAD2DEG(x) ((x)*180.0/M_PI)
|
||||
|
||||
|
||||
// temporary #define's for warning that deprecated methods are being
|
||||
// used which should be replaced by the new variants.
|
||||
#define WARN_DEPRECATED
|
||||
#define ABORT_DEPRECATED
|
||||
//#define ABORT_DEPRECATED
|
||||
|
||||
#ifdef WARN_DEPRECATED
|
||||
#ifdef ABORT_DEPRECATED
|
||||
|
||||
@@ -172,7 +172,7 @@ void Quat::set( const Matrix& m )
|
||||
|
||||
int nxt[3] = {1, 2, 0};
|
||||
|
||||
tr = m._mat[0][0] + m._mat[1][1] + m._mat[2][2];
|
||||
tr = m(0,0) + m(1,1) + m(2,2);
|
||||
|
||||
// check the diagonal
|
||||
if (tr > 0.0)
|
||||
@@ -180,31 +180,31 @@ void Quat::set( const Matrix& m )
|
||||
s = (float)sqrt (tr + 1.0);
|
||||
QW = s / 2.0f;
|
||||
s = 0.5f / s;
|
||||
QX = (m._mat[1][2] - m._mat[2][1]) * s;
|
||||
QY = (m._mat[2][0] - m._mat[0][2]) * s;
|
||||
QZ = (m._mat[0][1] - m._mat[1][0]) * s;
|
||||
QX = (m(1,2) - m(2,1)) * s;
|
||||
QY = (m(2,0) - m(0,2)) * s;
|
||||
QZ = (m(0,1) - m(1,0)) * s;
|
||||
}
|
||||
else
|
||||
{
|
||||
// diagonal is negative
|
||||
i = 0;
|
||||
if (m._mat[1][1] > m._mat[0][0])
|
||||
if (m(1,1) > m(0,0))
|
||||
i = 1;
|
||||
if (m._mat[2][2] > m._mat[i][i])
|
||||
if (m(2,2) > m(i,i))
|
||||
i = 2;
|
||||
j = nxt[i];
|
||||
k = nxt[j];
|
||||
|
||||
s = (float)sqrt ((m._mat[i][i] - (m._mat[j][j] + m._mat[k][k])) + 1.0);
|
||||
s = (float)sqrt ((m(i,i) - (m(j,j) + m(k,k))) + 1.0);
|
||||
|
||||
tq[i] = s * 0.5f;
|
||||
|
||||
if (s != 0.0f)
|
||||
s = 0.5f / s;
|
||||
|
||||
tq[3] = (m._mat[j][k] - m._mat[k][j]) * s;
|
||||
tq[j] = (m._mat[i][j] + m._mat[j][i]) * s;
|
||||
tq[k] = (m._mat[i][k] + m._mat[k][i]) * s;
|
||||
tq[3] = (m(j,k) - m(k,j)) * s;
|
||||
tq[j] = (m(i,j) + m(j,i)) * s;
|
||||
tq[k] = (m(i,k) + m(k,i)) * s;
|
||||
|
||||
QX = tq[0];
|
||||
QY = tq[1];
|
||||
@@ -239,23 +239,23 @@ void Quat::get( Matrix& m ) const
|
||||
wy = QW * y2;
|
||||
wz = QW * z2;
|
||||
|
||||
m._mat[0][0] = 1.0f - (yy + zz);
|
||||
m._mat[0][1] = xy - wz;
|
||||
m._mat[0][2] = xz + wy;
|
||||
m._mat[0][3] = 0.0f;
|
||||
m(0,0) = 1.0f - (yy + zz);
|
||||
m(0,1) = xy - wz;
|
||||
m(0,2) = xz + wy;
|
||||
m(0,3) = 0.0f;
|
||||
|
||||
m._mat[1][0] = xy + wz;
|
||||
m._mat[1][1] = 1.0f - (xx + zz);
|
||||
m._mat[1][2] = yz - wx;
|
||||
m._mat[1][3] = 0.0f;
|
||||
m(1,0) = xy + wz;
|
||||
m(1,1) = 1.0f - (xx + zz);
|
||||
m(1,2) = yz - wx;
|
||||
m(1,3) = 0.0f;
|
||||
|
||||
m._mat[2][0] = xz - wy;
|
||||
m._mat[2][1] = yz + wx;
|
||||
m._mat[2][2] = 1.0f - (xx + yy);
|
||||
m._mat[2][3] = 0.0f;
|
||||
m(2,0) = xz - wy;
|
||||
m(2,1) = yz + wx;
|
||||
m(2,2) = 1.0f - (xx + yy);
|
||||
m(2,3) = 0.0f;
|
||||
|
||||
m._mat[3][0] = 0;
|
||||
m._mat[3][1] = 0;
|
||||
m._mat[3][2] = 0;
|
||||
m._mat[3][3] = 1;
|
||||
m(3,0) = 0;
|
||||
m(3,1) = 0;
|
||||
m(3,2) = 0;
|
||||
m(3,3) = 1;
|
||||
}
|
||||
|
||||
@@ -15,5 +15,5 @@ TexMat::~TexMat()
|
||||
void TexMat::apply(State&) const
|
||||
{
|
||||
glMatrixMode( GL_TEXTURE );
|
||||
glLoadMatrixf( (GLfloat *)_matrix._mat );
|
||||
glLoadMatrixf( _matrix.ptr() );
|
||||
}
|
||||
|
||||
@@ -265,24 +265,24 @@ public:
|
||||
r2=r3^r1;
|
||||
}
|
||||
for (int j=0; j<3; j++) { // and create the transpose matrix (inverse of rotation matrix)
|
||||
mx._mat[0][j]=r1[j];
|
||||
mx._mat[1][j]=r2[j];
|
||||
mx._mat[2][j]=r3[j];
|
||||
mx(0,j)=r1[j];
|
||||
mx(1,j)=r2[j];
|
||||
mx(2,j)=r3[j];
|
||||
}
|
||||
// mx.postTrans(mx,0.5f,0.5f,0.0f);
|
||||
mx._mat[0][0]*=1.0f/wid;
|
||||
mx._mat[1][0]*=1.0f/wid;
|
||||
mx._mat[0][1]*=1.0f/ht;
|
||||
mx._mat[1][1]*=1.0f/ht;
|
||||
mx(0,0)*=1.0f/wid;
|
||||
mx(1,0)*=1.0f/wid;
|
||||
mx(0,1)*=1.0f/ht;
|
||||
mx(1,1)*=1.0f/ht;
|
||||
if (mat->isFullFace()) { // set offset such that mx*verts[idx[0]] -> uv=(0,0)
|
||||
Vec3 pos;
|
||||
pos=mx*verts[idx[0]];
|
||||
mx._mat[0][3]=pos.x();
|
||||
mx._mat[1][3]=pos.y();
|
||||
mx._mat[2][3]=pos.z();
|
||||
mx(0,3)=pos.x();
|
||||
mx(1,3)=pos.y();
|
||||
mx(2,3)=pos.z();
|
||||
} else { // scale inversely to the texture preferred repeat size
|
||||
mx._mat[0][3]=0.5f/wid;
|
||||
mx._mat[1][3]=0.5f/ht;
|
||||
mx(0,3)=0.5f/wid;
|
||||
mx(1,3)=0.5f/ht;
|
||||
}
|
||||
// mx.postScale(mx,1.0f/themat->TextureWidth, 1.0f/themat->TextureHeight,1);
|
||||
}
|
||||
@@ -1002,9 +1002,9 @@ class ReaderWriterDW : public osgDB::ReaderWriter
|
||||
} else if( strncmp(buff,"UVW:",4)==0) { // texture application matrix
|
||||
Matrix mx;
|
||||
sscanf(buff+4,"%f %f %f%f %f %f%f %f %f",
|
||||
&mx._mat[0][0], &mx._mat[0][1], &mx._mat[0][2],
|
||||
&mx._mat[1][0], &mx._mat[1][1], &mx._mat[1][2],
|
||||
&mx._mat[2][0], &mx._mat[2][1], &mx._mat[2][2]);
|
||||
&mx(0,0), &mx(0,1), &mx(0,2),
|
||||
&mx(1,0), &mx(1,1), &mx(1,2),
|
||||
&mx(2,0), &mx(2,1), &mx(2,2));
|
||||
obj.settmat(&mx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ osg::Node* ConvertFromFLT::visitMatrix(osg::Group* osgParent, MatrixRecord* rec)
|
||||
{
|
||||
for(int j=0;j<4;++j)
|
||||
{
|
||||
m._mat[i][j] = pSMatrix->sfMat[i][j];
|
||||
m(i,j) = pSMatrix->sfMat[i][j];
|
||||
}
|
||||
}
|
||||
dcs->setMatrix(m);
|
||||
|
||||
@@ -39,7 +39,7 @@ bool Matrix_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
for(int j=0;j<4;++j)
|
||||
{
|
||||
fr[k].getFloat(matrix._mat[i][j]);
|
||||
fr[k].getFloat(matrix(i,j));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
@@ -55,10 +55,10 @@ bool Matrix_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const Matrix& matrix = static_cast<const Matrix&>(obj);
|
||||
|
||||
fw.indent() << matrix._mat[0][0] << " " << matrix._mat[0][1] << " " << matrix._mat[0][2] << " " << matrix._mat[0][3] << endl;
|
||||
fw.indent() << matrix._mat[1][0] << " " << matrix._mat[1][1] << " " << matrix._mat[1][2] << " " << matrix._mat[1][3] << endl;
|
||||
fw.indent() << matrix._mat[2][0] << " " << matrix._mat[2][1] << " " << matrix._mat[2][2] << " " << matrix._mat[2][3] << endl;
|
||||
fw.indent() << matrix._mat[3][0] << " " << matrix._mat[3][1] << " " << matrix._mat[3][2] << " " << matrix._mat[3][3] << endl;
|
||||
fw.indent() << matrix(0,0) << " " << matrix(0,1) << " " << matrix(0,2) << " " << matrix(0,3) << endl;
|
||||
fw.indent() << matrix(1,0) << " " << matrix(1,1) << " " << matrix(1,2) << " " << matrix(1,3) << endl;
|
||||
fw.indent() << matrix(2,0) << " " << matrix(2,1) << " " << matrix(2,2) << " " << matrix(2,3) << endl;
|
||||
fw.indent() << matrix(3,0) << " " << matrix(3,1) << " " << matrix(3,2) << " " << matrix(3,3) << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ bool TexMat_readLocalData(Object& obj, Input& fr)
|
||||
{
|
||||
for(int j=0;j<4;++j)
|
||||
{
|
||||
fr[k].getFloat(matrix._mat[i][j]);
|
||||
fr[k].getFloat(matrix(i,j));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
@@ -59,9 +59,9 @@ bool TexMat_writeLocalData(const Object& obj, Output& fw)
|
||||
{
|
||||
const TexMat& texmat = static_cast<const TexMat&>(obj);
|
||||
const Matrix& matrix = texmat.getMatrix();
|
||||
fw.indent() << matrix._mat[0][0] << " " << matrix._mat[0][1] << " " << matrix._mat[0][2] << " " << matrix._mat[0][3] << endl;
|
||||
fw.indent() << matrix._mat[1][0] << " " << matrix._mat[1][1] << " " << matrix._mat[1][2] << " " << matrix._mat[1][3] << endl;
|
||||
fw.indent() << matrix._mat[2][0] << " " << matrix._mat[2][1] << " " << matrix._mat[2][2] << " " << matrix._mat[2][3] << endl;
|
||||
fw.indent() << matrix._mat[3][0] << " " << matrix._mat[3][1] << " " << matrix._mat[3][2] << " " << matrix._mat[3][3] << endl;
|
||||
fw.indent() << matrix(0,0) << " " << matrix(0,1) << " " << matrix(0,2) << " " << matrix(0,3) << endl;
|
||||
fw.indent() << matrix(1,0) << " " << matrix(1,1) << " " << matrix(1,2) << " " << matrix(1,3) << endl;
|
||||
fw.indent() << matrix(2,0) << " " << matrix(2,1) << " " << matrix(2,2) << " " << matrix(2,3) << endl;
|
||||
fw.indent() << matrix(3,0) << " " << matrix(3,1) << " " << matrix(3,2) << " " << matrix(3,3) << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ void RenderLeaf::render(State& state,RenderLeaf* previous)
|
||||
if (_matrix.valid())
|
||||
{
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)_matrix->_mat);
|
||||
glMultMatrixf(_matrix->ptr());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,7 +55,7 @@ void RenderLeaf::render(State& state,RenderLeaf* previous)
|
||||
if (_matrix.valid())
|
||||
{
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)_matrix->_mat);
|
||||
glMultMatrixf(_matrix->ptr());
|
||||
}
|
||||
|
||||
_drawable->draw(state);
|
||||
|
||||
@@ -102,7 +102,7 @@ void RenderStage::draw(osg::State& state,RenderLeaf*& previous)
|
||||
const Matrix& projectionMat = _camera->getProjectionMatrix();
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glMultMatrixf((GLfloat*)projectionMat._mat);
|
||||
glMultMatrixf(projectionMat.ptr());
|
||||
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
@@ -115,7 +115,7 @@ void RenderStage::draw(osg::State& state,RenderLeaf*& previous)
|
||||
|
||||
// set up camera modelview.
|
||||
const Matrix& modelView = _camera->getModelViewMatrix();
|
||||
glMultMatrixf((GLfloat*)modelView._mat);
|
||||
glMultMatrixf(modelView.ptr());
|
||||
|
||||
|
||||
if (getLightingMode()==RenderStageLighting::SKY_LIGHT && light)
|
||||
|
||||
@@ -45,7 +45,7 @@ void RenderStageLighting::draw(osg::State& state,RenderLeaf*& previous)
|
||||
if (matrix)
|
||||
{
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)matrix->_mat);
|
||||
glMultMatrixf(matrix->ptr());
|
||||
}
|
||||
|
||||
prev_matrix = matrix;
|
||||
|
||||
Reference in New Issue
Block a user