Game Development Community

dev|Pro Game Development Curriculum

Plan for Jeff Gran

by Jeff Gran · 08/15/2005 (4:28 am) · 2 comments

Yeah, I figured out how to use Blender's Object ScriptLinks to define custom controllers for objects. It's actually extremely powerful. Anything you can express in code you can use to control your objects.

I was annoyed by the fact that (a) there's no parent constraint or position/rotation constraint with offsets, and (b) You currently can't create constraints from script. But now I can have an object be the "parent" of another object, with my own custom and dynamic offset values, all without actually affecting the hierarchy - both objects are still at the scene root. I'm sure it doesn't sound that exciting to most, but I'm jazzed that I figured it out and it opens up a lot of possibilities with my python scripting that I thought were dead ends. So, progress on TorqueSkel Blender continues.

Here's the code for the hell of it - pretty simple really (now that it's here in front of me :))

import Blender
##########################
parent =  Blender.Object.Get("Sphere")
###################################


obj = Blender.link

obj.addProperty("offsetX", (obj.LocX - parent.LocX), "FLOAT")
obj.addProperty("offsetY", (obj.LocY - parent.LocY), "FLOAT")
obj.addProperty("offsetZ", (obj.LocZ - parent.LocZ), "FLOAT")

LV=Blender.Mathutils.Vector([obj.getProperty("offsetX").getData(),obj.getProperty("offsetY").getData(),obj.getProperty("offsetZ").getData()])

PM = parent.getMatrix()
PM = PM.rotationPart()

newX = (LV.x * PM[0][0]) + (LV.y * PM[1][0]) + (LV.z * PM[2][0])
newY = (LV.x * PM[0][1]) + (LV.y * PM[1][1]) + (LV.z * PM[2][1])
newZ = (LV.x * PM[0][2]) + (LV.y * PM[1][2]) + (LV.z * PM[2][2])

obj.loc = [parent.LocX + newX, parent.LocY + newY, parent.LocZ + newZ]
obj.rot = parent.rot

Oh, and I also have a super-spiffy addition to TorqueSkel MAX almost finished... but I'll wait 'till it's done and tested to unveil it.

#1
08/15/2005 (8:06 am)
Quote:Oh, and I also have a super-spiffy addition to TorqueSkel MAX almost finished... but I'll wait 'till it's done and tested to unveil it.

Damn teasing ! :)

btw awesome news on blender progress, I know a lot of people are looking forward to it.
#2
08/15/2005 (12:23 pm)
Cool! One step closer to a useable Blender IK rig :) This is some groundbreaking work you're doing towards unifying the art pipeline(s) for character creation. I've always kinda felt that blender users were the redheaded stepchildren of the torque art world, but if this comes to fruition it has the potential to make blender one of the primary tools for 3d modeling with Torque. Thanks again.