I need some way to have a node turn some number of degrees towards another, like:
I’ve made a few of my own versions, but they all suffer from weird gimbal problems or crazy behavior. There must be ‘proper’ way to do it (builtin, involving quats, whatever) that I’ve not heard of.
Anybody got any tips?
Does that work?
no that would not work.
while start < 0 : start += 360
while stop < 0 : stop += 360
while start >= 360 : start -= 360
while stop >= 360 : stop -= 360
delta = abs(start-stop)
delta = min(delta,360-delta)
if delta < degree: degree = delta
diff = stop-start
if (diff > 0 and diff <= 180) or (diff < -180):
hpr = node.getHpr()
wantHpr = node.getHpr()
hpr = turnHpr(hpr,wantHpr,degree)
I was looking for this the other day myself, as I wanted to extract a quaternion from lookAt. I found an older thread where Treeform and drwr had posted very similar code.
Personally I would rather see a version of lookAt which returns a transform directly instead of having it effect the nodepath directly, but I can see why it was done that way.
Still puzzling through the vector/math operations that Panda provides here too.
Got that too:
m = Mat4()
q = Quat
Oh! Awesome! But where is that coming from? It’s a global function I am guessing?
from pandac.PandaModules import lookAt