Tuesday, February 09, 2010

Panda is great! But...

...there are some details that sorta spoil the fun.

One thing i dislike is for once the fact that the libraries are quite big. That's not really a problem, if your game is big, but an unoptimized "hello world" program took about 60 megabyte. Nodody would download a small game with such a size! That's an issue it owes to it's huge functionality...

Another thing i am sorta unhappy with is the matrix/vector functionality. I compared it to the implementation of the (supposedly discontinued) "Python Computer Graphics Kit" and i prefer the cgkit's version much more. For example you can multiply a vector (Vec3) directly with a transformation matrix (Mat4) via the normal multiply operator (*), which isn't really crucial, but a nice touch:

Panda3D:
>>> myVector=Vec3(2.0,2.0,2.0)
>>> myMatrix=Mat4()
>>> myMatrix.scaleMat(Vec3(2.0,2.0,2.0))
Mat4(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)
>>> myMatrix.xformPoint(myVector)
VBase3(2, 2, 2)
>>> myVector
Vec3(2, 2, 2)


(which isn't the correct result anyways... wtf?!)

CGKit:
>>> myMatrix=mat4(1.0)
>>> myMatrix.scale(vec3(2.0,2.0,2.0))
[2, 0, 0, 0]
[0, 2, 0, 0]
[0, 0, 2, 0]
[0, 0, 0, 1]
>>> myVector=vec3(2.0)
>>> myMatrix*myVector
(4, 4, 4)


Another one is the fact that when Panda3D is scaling a transformation matrix, it overwrites the matrix with a comletely new scale matrix:

Panda3D:
>>> myMatrix=Mat4()
>>> myMatrix
Mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
>>> myMatrix.setTranslateMat(Vec3(2.0,3.0,4.0))
>>> myMatrix
Mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1)
>>> myMatrix.setScaleMat(Vec3(2.0,2.0,2.0))
>>> myMatrix
Mat4(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)


...does pretty much the same as...

>>> myMatrix=Mat4()
>>> myMatrix
Mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
>>> myMatrix.translateMat(Vec3(2.0,3.0,4.0))
Mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 3, 4, 1)
>>> myMatrix.scaleMat(Vec3(2.0,2.0,2.0))
Mat4(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)


...whereas CGKit is doing this:

>>> myMatrix=mat4(1.0)
>>> myMatrix.translate(vec3(2.0,3.0,4.0))
[1, 0, 0, 2]
[0, 1, 0, 3]
[0, 0, 1, 4]
[0, 0, 0, 1]
>>> myMatrix.scale(vec3(2.0,2.0,2.0))
[2, 0, 0, 2]
[0, 2, 0, 3]
[0, 0, 2, 4]
[0, 0, 0, 1]


I have no clue why, but i am not too experienced with that stuff so far, so maybe i'm just thinking wrong. Nevertheless most of the time you don't need that kind of stuff anyways, Panda3D does a great job keeping these issues away from the user. I just had to use these vector calculations for my tree project.