Lerps?

In part of my code, I have a task repeating the command “self.frame.setH(self.frame.getH()+1)”. In other words, it should be spinning around the Z-axis centered to its centerpoint. The problem: it doesn’t do that. The object is a sphere, and it’s supposed to simply rotate around its pole. The center point in Blender when I exported it was the center of the sphere. Could this have changed through exporting with chicken? What the object currently does is rotate around a different point (as if orbiting around a point on its outside).

(For reference, the full relevant code:)

def loadface(self):
    self.face=self.loader.loadModel("/<stuff>")
    self.frame=self.loader.loadModel("/<stuff>")
    self.frame.reparentTo(self.face)
    self.face.reparentTo(self.render)
    self.face.setPos(0,20,3)
    self.frame.setRenderModeWireframe()

This code loads on program startup. I have tried just not reparenting it to the face model but rather as its own independant model, but it makes no difference.

def CC(self, task):
    from direct.task import Task
    self.frame.setH(self.frame.getH()+1)
    return Task.cont

It activates the task just fine, but for some reason… I think it might be moving the centerpoint of the model. Is there any way to find out the centerpoint? Does anyone see the flaw in the code?

Just FIY – you don’t need a task to do such a thing. Instead, use the Panda’s intervals. It’s much more straightforward when all you need to do is animate an object’s rotation, position and/or scale. Check the manual: panda3d.org/manual/index.php/Lerp_Intervals

As far as the actual problem, the only thing that comes to my mind is that you did something wrong in Blender. Either you didn’t set the center correctly after all, or maybe you forgot to apply some transformation you did in object mode.

I’ll look in to that tomorrow. :slight_smile: Thanks.

See, this is odd. I created two pieces of the same model in blender, and I set them both to have the same center. Then when I put them at the same location in panda, they mesh just like they should-in other words, the centers seem to be fine up until then. So technically, the centerpoint of the circle, which SetH uses to determine the XZ coordinates of the Y axis, SHOULD be its center. But it doesn’t do that. :frowning: I’ll try the Lerps later, see if that fixes it. Worst case scenario, I’ll animate it in blender. :laughing:

I’m not quite sure how to use those…

lerp.LerpPosInterval(self.face, 1, VBase3(float(xvar),float(yvar),float(3)), name="me")

AFAIK, what this should do is set the point self.fae is supposed to go to to xvar/yvar/3, and bring it there in 1 second. xvar and yvar are different from the current position (I had it check, too)… But the figure is not moving at all. What’s wrong?

Did you start the interval? I frequently forget about that.

lerp.LerpPosInterval(self.face, 1, VBase3(float(xvar),float(yvar),float(3)), name="me").start()

or

myInterval = lerp.LerpPosInterval(self.face, 1, VBase3(float(xvar),float(yvar),float(3)), name="me")
myInterval.start()

model.reparentTo(self.render) should not work :wink:

from direct.interval.FunctionInterval import HprInterval

sphere_rotation_interval = sphere.hprInterval(10,Vec3(360,0,0))
		
sphere_rotation_interval.loop()

D’OH! Good to know. BTW, that’s not in the manual…

panda3d.org/manual/index.php/Intervals

It is :wink:

Dammit. :laughing:

Now I feel even more stupid. Both the people on this forum and my tech teacher both have a knack for that. :laughing: