[Edu-sig] PyGeo
Kirby Urner
pdx4d@teleport.com
Fri, 03 Mar 2000 07:02:58 -0800
This was me (no quote marks in your reply):
>>Art, as you say, there's much that's similar between our respective
>>approaches. You back end into OpenGL, which gives students direct and
>>immediate feedback on the screen, whereas I back end into Povray.
>
>Suddenly I see where ART's use of immediate redraws instead of explicit
>'ob.draw()' calls pays off: the user gets a 'snapshot' of the current
>status of their world of objects. If they write a for loop to turn every
>object green, they will see each object turn green in sequence.
You could get these snap shots either way, e.g.
for i in range(5):
tri.center = (0,0,i)
tri.draw()
>I think this is the kind of advantage you can get from interfacing Python
>directly with the rendering system, rather than using a separate
>application -- immediate feedback. And to students trying to grasp
>difficult OO concepts, immediate feedback is both helpful and engaging.
>
>Dustin
But we shouldn't exaggerate the difficulty of using a separate
application.
If I have Povray and Python open at the same time, I can render
a file generated by Python within a few seconds.
Plus Povray gives me a "post production" editing phase, where
I can tweek camera distance and angle, background color, textures,
other stuff, without rerunning the script.
Plus -- and I don't know how this works with PyGeo -- since I'm
rendering to a .bmp file (by default), I've got a permanent
copy of my work if I want it, without doing a screen capture.
That's how I get all those .gifs at my website.
Finally, by back ending into Povray, I'm able to keep the
Python code very simple. I can just use XYZ coordinates to
position my objects and don't have to worry about messy issues
around perspective (foreshortening, cylinders appearing
thinner with distance etc.).
Like, here's my function for drawing an edge between two
points:
def edge(self,v1,v2):
# write cylinder from v1.coords to v2.coords
pointA = v1.coords
pointB = v2.coords
self.file.write(("cylinder{<%s, %s, %s>" % pointA
+ ",<%s, %s, %s>," % pointB
+ " %s pigment {color %s} no_shadow}\n"
% (self.cylradius, self.cylcolor)))
That's it! Very short. Mostly it's just about substituting
numbers into a phrase of text, using the %s syntax -- easy
to explain.
v1 and v2 (the parameters) are vector objects, already
familiar, code explained, and usable interactively at
the Python command line.
Povray handles shading, shadows (if I want them) -- all
the stuff that ray tracer stuff which, if done in Python,
would make this _not_ a transparent, beginner's intro
to the language at all, but a full-fledged application
with lots and lots of code.
And _that_ is what would get in the way of my students
appreciating the simplicity of OO. I'm very willing to
accept these trade-offs and, as I've said, it's not
either/or.
Kirby