Re: [PyOpenGL-Users] best way to set up matrices and vertex arrays?
Brought to you by:
mcfletch
From: Ian M. <geo...@gm...> - 2010-03-09 20:45:59
|
On Tue, Mar 9, 2010 at 2:58 AM, Kolja Kaehler <kol...@av...>wrote: > - My hope was to avoid having to do my own 3D-vector- and > matrix-classes for doing linear algebra, and just use numpy’s abilities. It > turns out that this is not always so effortless – e.g. to multiply a matrix > with a vector from the right, I have to make sure it’s a column vector. 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 4th element again. > Looks like it would be cleaner to write out the whole matrix/vector > multiplication by hand. > Scale and rotate matrices need only be 3x3 matrices. Translation matrices, which must be 4x4, can instead be expressed as simple addition: e.g., vertex_array += array([1,2,6]) You might also want to consider keeping your vertices as vec4s--that's how OpenGL stores vertices interally, even if you only define the x and y, or the x,y, and z coordinates. You may also consider using OpenGL's own matrix system. It's technically deprecated--but it's still an awes Ian |