Should I even bother?

I’m thinking about starting on my first Python scripting project (a two parter). I’ll set it out for you and see if it’s even possible before I invest the time. Also, any pitfalls you can see.

Overview of script 1: an object randomization script. You select the objects that you want to have randomized, enter your parameters in the script (max/min/progression type) for local x,y,z, rotations and scales. The script then randomly varies the objects’ locations/rotations/scales based on the provided criteria. This would be good for making “natural” distributions of objects, like pebbles in a stream, trees in a forest, etc.

Overview of script 2: an object orientation script. This script would orient any object that conformed to a defined naming convention (“Tree*”) toward the camera, on a definable axis basis. You would only rotate the object along it’s local “up” axis. It’s sort of like a standard track relationship, but effected on many objects at once and contrained to rotation along a single axis.

The whole point of this is to mimic trees in a forest. This is the same technique used in the animated short “The Hunt”, which, if you haven’t seen it, is incredible. You can find a link to it from http://www.cgchannel.com. All of the forest flyovers are done with exactly this technique, rectangles with image/alpha mapped trees, via a plugin for 3DSMAX, and it looks phenomenal. As far as I can see, this would not be horribly difficult to reproduce for Blender with Python.

So what you would need (I think) would be the ability to:

  • Look up objects based on their name
  • Access and manipulate the coordinate/rotation/scale data for those objects
  • Recheck the orientation on a frame-wise basis to make sure the objects always face the camera.

That’s it. Is this possible? From what I know about programming, it seems that this would not be a horribly difficult set of scripts to write. BTW, if you’re skeptical about the power of this technique, I strongly encourage you to check out “The Hunt”.

Also, does anyone know of scripts with similar functionality (even the update-per-frame thing) that I could take a look at?

Thanks. Oh, I’m planning to proceed even if no one responds. I was just hoping to make the way a bit easier before I begin.

coming as it does from a total python noob, I’m still quite sure that this is entirely possible. Damn! that’s what they did for the hunt? I have to re-watch it now.

So what you would need (I think) would be the ability to:

  • Look up objects based on their name
  • Access and manipulate the coordinate/rotation/scale data for those objects
  • Recheck the orientation on a frame-wise basis to make sure the objects always face the camera.

All of them could be done.

Blender.Object.Get(name) will return the object associated to the name, or none if no object is associated.

that object will have properties called loc, rot and size which will return a list of three floats representing respectivly the location, rotation and size of the object. You can also modify those.

for the last one, you’ll have to use a scriptlink, with FrameChange as event.

Martin

Thanks. I’ll get cranking on it this weekend. New programming language and something useful to do with it! Woohoo!