[SOLVED] Mopath: Mopath has no curves

My code is this:

mp = Mopath.Mopath()
mp.loadFile("cakePath")
mi1 = MopathInterval(mp, avatar, duration=70, name="sportman")
Sequence(mi1, name='sportman run').start()

cakePath.egg:

<CoordinateSystem> { Z-Up }

<Group> NurbsPath {
  <Transform> {
    <Matrix4> {
      1 0 0 0
      0 1 0 0
      0 0 1 0
      0 -194.999 0 1
    }
  }
  <VertexPool> NurbsPath {
    <Vertex> 0 {
      -0 -196.999 0 1
    }
    <Vertex> 1 {
      -0 -97.143 0 1
    }
    <Vertex> 2 {
      -0.002 -95.886 0 1
    }
    <Vertex> 3 {
      -0.71 -95.179 0 1
    }

...
...
...

    <Vertex> 27 {
      0.004 -76.083 -0 1
    }
    <Vertex> 28 {
      0.004 -9.997 -0 1
    }
  }
  <NurbsCurve> {
    <Scalar> subdiv { 336 }
    <Order> { 0 }
    <Knots> {
      0 0 0 0 0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44
      0.48 0.52 0.56 0.6 0.64 0.68 0.72 0.76 0.8 0.84 0.88 0.92 0.96 1 1
      1 1 1
    }
    <VertexRef> {
      0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
      25 26 27 28
      <Ref> { NurbsPath }
    }
  }
}

In command line:

Mopath: no valid curves in nodePath: cakePath.egg
Mopath: Mopath has no curves
Mopath: Mopath has no curves
Mopath: Mopath has no curves
...
...
...

Make sure that “egg-load-old-curves 1” is in your Config.prc (and not “egg-load-old-curves 0”).

What do you see when you run the following?

m = loader.loadModel("cakePath")
m.ls()

You should see a NurbsCurve object, and not a RopeNode object, in order for Mopath to work properly.

David

It said:

ModelRoot cakePath.egg
  PandaNode 
    PandaNode NurbsPath T:m(pos 0 -194.999 0)
Mopath: no valid curves in nodePath: cakePath.egg
Mopath: Mopath has no curves
Mopath: Mopath has no curves
...
...
...

So I open cakePath.egg, use " NurbsCurve " replace " NurbsPath ", then:

ModelRoot cakePath.egg
  PandaNode 
    PandaNode NurbsCurve T:m(pos 0 -194.999 0)
Mopath: no valid curves in nodePath: cakePath.egg
Mopath: Mopath has no curves
Mopath: Mopath has no curves
...
...
...

The egg file created by blender.

Oh, it’s probably mad because you specified ‘order 0’, which isn’t a valid order. (Order runs from 1 to 4, and is most often 4. But the order also determines the number of knots you must provide.)

Was there an error message when you loaded the egg file the first time?

David

I manually modify " { 0 }" to " { 1 }".

My code is this:

def __init__(self, avatar):
	self.m1 = loader.loadModel("cake")
	self.m1.reparentTo(render)
	self.m2 = loader.loadModel("cake")
	self.m2.setScale( 1,-1,1)
	self.m2.reparentTo(render)
	self.m3 = loader.loadModel("cake")
	self.m2.setScale(-1, 1,1)
	self.m3.reparentTo(render)
	self.m4 = loader.loadModel("cake")
	self.m2.setScale(-1,-1,1)
	self.m4.reparentTo(render)
		
	i1 = LerpPosInterval(base.camera, duration=1, pos=(-1,-5,2), startPos=(-1,-5,3))
	Sequence(i1, name='Move Camera').start()
	
	print "# m = loader.loadModel(cakePath)"
	m = loader.loadModel("cakePath")

	print "# m.ls()"
	m.ls()
		
	print "# mp = Mopath.Mopath()"
	mp = Mopath.Mopath()

	print "# mp.loadFile(cakePath)"
	mp.loadFile("cakePath")

	mi1 = MopathInterval(mp, avatar, duration=70, name="sportman")
	Sequence(mi1, name='sportman run').start()

message:

Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
:display:glxdisplay(warning): No suitable FBConfig contexts available; using XVisual only.
depth_bits=24 color_bits=24 alpha_bits=8 stencil_bits=8 back_buffers=1 force_hardware=1 
:net(error): Unable to open TCP connection to server 127.0.0.1 on port 5185
:pstats(error): Couldn't connect to PStatServer at localhost:5185
# m = loader.loadModel(cakePath)
# m.ls()
ModelRoot cakePath.egg
  PandaNode 
    PandaNode NurbsCurve T:m(pos 0 -194.999 0)
# mp = Mopath.Mopath()
# mp.loadFile(cakePath)
Mopath: no valid curves in nodePath: cakePath.egg
Mopath: Mopath has no curves
Mopath: Mopath has no curves
Mopath: Mopath has no curves
...
...

Whether there are ready examples about path?

You should be seeing an error message, but you will only see it the very first time you load an egg file after changing it (subsequent loads will be cached and won’t generate error messages).

The number of knots must be exactly the number of CV’s plus the order. So, for an order 1 curve, you must have one more knots than you have CV’s. But I really doubt you wanted an order 1 curve; that’s just a collection of disconnected points. You almost certainly meant to create an order 4 curve, which means you must have four more knots than CV’s.

I don’t think Panda ships with any examples of NURBS curves, but NURBS are fairly standard and you should be able to find examples elsewhere on the internet.

David

Here’s a simple sample curve:

<CoordinateSystem> { Z-Up }
<VertexPool> verts {
    <Vertex> 0 {
        0 0 0 1
    }
    <Vertex> 1 {
        0 0.5 0.5 1
    }
    <Vertex> 2 {
        1 0 1 1
    }
    <Vertex> 3 {
        0 -1.5 1.5 1
    }
    <Vertex> 4 {
        -2 0 2 1
    }
    <Vertex> 5 {
        2 2.5 2.5 1
    }
    <Vertex> 6 {
        3 0 3 1
    }
    <Vertex> 7 {
        0 -3.5 3.5 1
    }
}
<NURBSCurve> {   
    <Order> {3}
    <VertexRef> { 0 1 2 3 4 5 6 <Ref> { verts } } 
    <Knots>{0 1 2 3 4 5 6 7 8 9}
}

I deleted cache.

:egg2pg(error): Invalid NURBSCurve number of knots for : got 34 knots, expected 30

Thank you! But I still not understand how to change my .egg file.

This is ma new .egg file:

<Order> { 4 }
<Knots> {
  0 0 0 0 0 0.04 0.08 0.12 0.16 0.2 0.24 0.28 0.32 0.36 0.4 0.44
  0.48 0.52 0.56 0.6 0.64 0.68 0.72 0.76 0.8 0.84 0.88 0.92 0.96 1 1
  1 1    }

It work.