Hi all,

I've moved some code of mine from PAT objects to MatrixTransform ones,
which suit my needs better. I'm still having a problem getting the
coordinates back. After a quick look, I figured I might be able to
transform an MT into a Transform, and then back into a PAT using the
following:
|   MatrixTransform *mt = new MatrixTransform();
|   {
|     Matrix t = Matrix::translate(5, 0, 0);
|     Matrix r = Matrix::rotate(45, 0, 0, 1);
|     mt->setMatrix(t*r);
|   }
| 
|   Transform *t = mt->asTransform();
|   assert(t!=0);
| 
|   Transform *pat = t->asPositionAttitudeTransform();
|   assert(pat!=0);

(For reference, whole source code attached.)

I'm getting that:
| a.out: asPAT.cpp:27: int main(): Assertion `pat!=0' failed.

Should I understand that those functions, mimicking dynamic_cast calls,
would only work when a PAT object gets casted into a Transform one and
then back to a PAT object?

If so, I guess I'd have to extract the translation from the matrix I'd
have with mt->getMatrix()?

Thanks for your time.

Cheers,
-- 
Cyril Brulebois
#include <osg/Matrix>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/Transform>

#include <cassert>

using namespace osg;

int main(void) {
  MatrixTransform *mt = new MatrixTransform();
  {
    Matrix t = Matrix::translate(5, 0, 0);
    Matrix r = Matrix::rotate(45, 0, 0, 1);
    mt->setMatrix(t*r);
  }

  Transform *t = mt->asTransform();
  assert(t!=0);

  Transform *re_mt = t->asMatrixTransform();
  assert(re_mt!=0);

  Transform *pat = t->asPositionAttitudeTransform();
  assert(pat!=0);

  return 0;
}

Attachment: signature.asc
Description: Digital signature

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

Reply via email to