*** empty log message ***

This commit is contained in:
Robert Osfield
2001-09-27 16:34:41 +00:00
parent ba47264c5e
commit 2a9848ea95
14 changed files with 88 additions and 78 deletions

View File

@@ -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];

View File

@@ -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];
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -15,5 +15,5 @@ TexMat::~TexMat()
void TexMat::apply(State&) const
{
glMatrixMode( GL_TEXTURE );
glLoadMatrixf( (GLfloat *)_matrix._mat );
glLoadMatrixf( _matrix.ptr() );
}

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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)

View File

@@ -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;