Re: [PyOpenGL-Users] best way to set up matrices and vertex arrays?
Brought to you by:
mcfletch
From: Greg E. <gre...@ca...> - 2010-03-09 23:36:58
|
Kolja Kaehler wrote: > - Row-major vs. column-major matrices. With the default > row-major layout used by numpy, I always have to pass in matrices as the > transpose of what I expect. I found out I can create numpy arrays with > ‘F’ order, but I still have to transpose matrices I get back from > PyOpenGL, it seems. You might like to consider just working with the transposed arrays as they are. Thinking about this recently, I realised that the OpenGL order may actually be more convenient for some things, such as transforming an array of vertices. With a transposed matrix, you can do A*M, where A is an n-by-4 array. With a non-transposed matrix, you would have to do M*A and transpose A into a 4-by-n array. > - What’s a good way to build a dynamically growing vertex > array? ... Currently, I am setting up an array with > shape(n,3) and concatenate another array of length 3 to it. ... I > believe it’s always making a copy. Yes, that will be horribly inefficient. I would build up a list of vertices first, and then convert the whole list to an array in one go. > To transform a 3D vector with a 4x4 matrix, I have to append an > extra 1.0 element, do the multiplication, and then slice off the 4^th > element again. Another way is to work with 4-element vectors throughout. -- Greg |