NurbsCurve Rotation (SOLVED)

I have a NurbsCurve that I’m loading from a .egg file that is has to be aligned to a piece of geometry.

Now, I figured out a way to reposition the curve by moving each CV of the NurbsCurve to the geometry’s position, saving this new curve as a new .egg and loading that back in. The problem I’m having now is aligning the NurbsCurve to the geometry if the geometry has been rotated.

I’m using this for a motion path. Which I will probably create at the end by seaming all of the NurbsCurves together. If there is an easier way than my approach, I’d like to hear it.

Why not just setPosHpr() the whole curve node to the appropriate position relative to your geometry?

David

That was the first thing I tried and I got an error message pretty much saying that NurbsCurves don’t have that method available to them.

And the same goes for mopath’s.

Then, the reason the paths keep going to world space is that the mopath’s are loaded from the file or the nodepath

Unless there is something wrong with my node hierarchy which is possible…

You’re right, of course–a NurbsCurve doesn’t have this method. Neither does a Mopath object. But the node that you’re using the Mopath to control does.

Something like this:

from direct.directutil.Mopath import Mopath
from direct.interval.IntervalGlobal import *

mopath = Mopath()
mopath.loadFile('my_mopath.egg')

smiley = loader.loadModel('smiley.egg')
root = render.attachNewNode('root')
smiley.reparentTo(root)
root.setPosHpr(blah blah blah)

ival = MopathInterval(mopath, smiley)
ival.loop()

So, here the MopathInterval moves the node smiley along its path, in the relative coordinate space of the Mopath. But since smiley is parented to the node called root, you can set root to whatever coordinate space you like (“blah blah blah” in my example above), and smiley will inherit that coordinate space.

David

1 Like

Thanks, that helped and worked pretty well!

Can I also reparent the camera to this root if I would want to follow the object moving on the path or is there something different I can do with the camera?

edit
nevermind, you can reparent the camera and it works quite well.

Thanks for the help, :slight_smile: