Previous Thread  Next Thread

chat icon Camera matrix problems in 2.26

jmerritt

Posted: Sun May 04, 2003 6:30 am
Joined: 15 Feb 2003
Posts: 10
Hi Everyone,

I've been trying to access the inverse camera transform matrix from within Blender 2.26. On both Linux and Windows platforms, the following script:

Code:

from Blender import *

scene = Scene.getCurrent()
camera = scene.getCurrentCamera()
imatrix = camera.getInverseMatrix()

print imatrix
print imatrix[0]
print imatrix[1]
print imatrix[2]
print imatrix[3]


gives the following results (in the console):

Code:

((9.9419775405734622e+033, 1.0065780829052295e+034, 1.0032974180071193e+034, -1.
#QNAN), (0.0, 0.0, 7.8967025252677283e+033, 1.9190860941642372e-038), (2.5783891
743576634e-043, 1.9273616023751538e-038, 7.834125275251872e+033, -1.#QNAN), (1.2
235017151712843e-040, 7.89685541086258e+033, 1.7433498142726476e-039, 7.89688202
65734247e+033))
[9.9419775405734622e+033, 1.9273548761425251e-038, 9.9419366885521658e+033, 1.60
73891110312251e-038]
[9.9419540197127158e+033, 1.6108531208350361e-038, 1.9273559971812965e-038, 4.20
38953929744512e-045]
[7.0064923216240854e-045, 5.6051938572992683e-044, 1.9273582392588395e-038, 1.92
73559971812965e-038]
[0.0, 0.0, 0.0, 4.2038953929744512e-045]


Sorry if that's a bit messy! Confused

Anyway, as you can see, each row vector from the matrix appears different when accessed via the sequence operator than they do when dumped via print.

What's going on here? Is there something I'm doing wrong? The source code for this looks vaguely correct (I'm looking at the file: opy_matrix.c), so is there something subtle happening (perhaps a reference counting issue)?

Jonathan Merritt.

PS - Where do I find out about Python development within Blender. I'm finding it really difficult to locate anything!!! Sad
Reply with quote


alien-xmp

Posted: Mon May 05, 2003 12:41 am
Joined: 06 Apr 2003
Posts: 217
Definately broken...

The returned matrix object contains a pointer to float inverse[4][4] which is only valid inside Object_getInverseMatrix.

inverse has to be allocated memory (and freed when finished) for this to work.

Code:

static PyObject *Object_getInverseMatrix(PyObject *self, PyObject *args)
{
   Object *ob= PYBLOCK_AS_OBJECT(self);
   float inverse[4][4];                          // <- *******************
   Mat4Invert(inverse, ob->obmat);
   return newMatrixObject(inverse);
}


Code:

PyObject *newMatrixObject(Matrix4Ptr mat) {
   MatrixObject *self;

   self= PyObject_NEW(MatrixObject, &Matrix_Type);
   self->mat= mat;              // <- **************************

   BPY_TRY(self->rows[0]= newVectorObject(GETROWVECTOR(self->mat, 0), 4));
   BPY_TRY(self->rows[1]= newVectorObject(GETROWVECTOR(self->mat, 1), 4));
   BPY_TRY(self->rows[2]= newVectorObject(GETROWVECTOR(self->mat, 2), 4));
   BPY_TRY(self->rows[3]= newVectorObject(GETROWVECTOR(self->mat, 3), 4));

   return (PyObject*) self;
}
Reply with quote


jmerritt

Posted: Mon May 05, 2003 4:19 am
Joined: 15 Feb 2003
Posts: 10
Thanks for confirming that issue (and the full explanation! Cool ). I have since evaded the problem by accessing the non-inverted matrix and inverting it myself.

Can somebody tell me where the current Python development is being discussed? Is there a website with bits-and-pieces, a mailing list, etc? I'm subscribed to bf-committers, but there doesn't seem to have been any Python discussion for the last week or so. Is that the right place? I'd be much more motivated to try to solve problems like this if I knew that my efforts were actually focused on "current" code, and were going to be committed...

Thanks, Smile
Reply with quote


Michel

Posted: Mon May 05, 2003 8:03 am
Joined: 16 Oct 2002
Posts: 209
jmerritt wrote:

Can somebody tell me where the current Python development is being discussed? Is there a website with bits-and-pieces, a mailing list, etc? I'm subscribed to bf-committers, but there doesn't seem to have been any Python discussion for the last week or so. Is that the right place? I'd be much more motivated to try to solve problems like this if I knew that my efforts were actually focused on "current" code, and were going to be committed...

Thanks, Smile


Hi,

Python development is being discussed at the bf-committers list. And, if there's no discussion for a week, then that doesn't necessarilly mean that we're not active Twisted Evil

Anyway, our current work is in the new API implementation. Ofcourse, any bugs found in the current implementation - that will still be active for 2.27 - is important. So feel free to submit a patch or discuss this at the mailing list.

With regards,
Michel
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group