Hi folks!
I rewrote the tut3 for myself to work without cgkit. I work with
python 2.4, and there's no package of cgkit1 for this, at least on
Debian... Furthermore, I couldn't get cgkit2 to work as a drop-in
replacement (some C++ ABI errors I forgot), so I decided to see if I
could remove it completely, and succeeded.
I think this would be quite useful for people who can't / don't want
to install cgkit, because cgkit1 doesn't exist in a packaged form for
python2.4, or they're afraid to try to replace it with cgkit2 (oooh,
'alpha'! fear!). After all, reducing dependancies is a Good Thing, no?
OK, maybe not for tutorials where you want things to be as clear as
possible. But I think it would be interesting to give it as an
alternate download for those who are frustrated by the dependancies
(as I was).
The result is slightly less tidy than the original. An additional
requirement is to import Numerical. But since that package is a
requirement for PyOpenGL which is already used, I don't think that's a
problem. I had to add a small function that flattens a Numerical.array
object, since the included array.tolist() function doesn't do it
correctly, at least for our use.
If you run down the sources, I have added comments "#use this..." and
"#instead of this" to show what I have replaced (hint: "use.."
precedes the new part, and "instead" precedes the old part).
in Prepare_GL(), it's actually shorter to use the libraries included
functions gluPerspective() and gluLookAt(). As we're alrady importing
GLU, why not use them?
in draw_body(), I directly worked with the flattened matrix returned
by getRotation(). Nothing to see here...
In drop_object(), I used GL's matrix operations to make and retrieve
the rotation matrix, then my flatten function I mentioned above to put
that with setRotation()
In explosion, I basically extracted the length() and normalize()
functions from vec3 :)
Same for inside pull()
Oh, and in the meantime, the Debian package isn't getting anywhere.
All of a sudden, having pyode already installed removes most of the
incentive :(
And a last thing: it's late, it's possible (probable) I'm blathering
nonsense somewhere (everywhere). Be kind ;)
John
|