Ok, an update:
I have successfully generated a 128X128 tile mesh, saved it as a bam file and converted it to an egg. Then with the PandAi meshgen tool I have created a navmesh.csv file and followed the instructions from the manual to load everything in.
It works!
Or, at least sort of. I get no errors, the files all load and the character paths upon calling the pathFindTo function. BUT, it only paths to a single location. Here is my code for the pathing
def __getMousePos(self):
if base.mouseWatcherNode.hasMouse():
mpos = base.mouseWatcherNode.getMouse()
pos3d = Point3()
nearPoint = Point3()
farPoint = Point3()
base.camLens.extrude(mpos, nearPoint, farPoint)
if self.plane.intersectsLine(pos3d, render.getRelativePoint(globals.mainCam._gameCam, nearPoint), \
render.getRelativePoint(globals.mainCam._gameCam, farPoint)):
print pos3d
globals.actors['ralph']._AIbehaviors.pathFindTo(pos3d)
That print gives me the correct coords every time I click, but the pathing module sends me to a single destination and/or says ‘couldnt find destination’.
Some random facts:
I used the same egg file for my main mesh and my collision mesh in my meshgen call.
My navmesh.csv prints ‘grid size: 50’ at the top even though the mesh has 128x128 geoms. (pairs of triangles forming squares.)
If you need anymore information please feel free to ask!
Thanks in advance!
PS - here is the code for making the mesh… maybe my construction style is confusing the meshgen tool:
class mesh:
def __init__(self, tiles):
self._geomNode = GeomNode('map')
self._size = (128,128)
self._tiles = []
self._gvd = GeomVertexData('map_maker', GeomVertexFormat.getV3t2(), Geom.UHStatic)
self._vertex_writer = GeomVertexWriter(self._gvd, 'vertex')
self._texcoord_writer = GeomVertexWriter(self._gvd, 'texcoord')
for x in xrange(0,self._size[0]):
self._tiles.append([])
for z in xrange(0,self._size[1]):
geom = Geom(self._gvd)
prim = GeomTriangles(Geom.UHStatic)
self._vertex_writer.addData3f(x, 0, z)
self._texcoord_writer.addData2f(0, 0)
self._vertex_writer.addData3f(x, 0, z+1)
self._texcoord_writer.addData2f(0, 1)
self._vertex_writer.addData3f(x+1, 0, z+1)
self._texcoord_writer.addData2f(1, 1)
self._vertex_writer.addData3f(x+1, 0, z)
self._texcoord_writer.addData2f(1, 0)
d = ((x*self._size[0]) + z) * 4
prim.addVertices(d, d + 2, d + 1)
prim.addVertices(d, d + 3, d + 2)
prim.closePrimitive()
geom.addPrimitive(prim)
i = randint(0, len(tiles)-1)
self._tiles[x].append( {
'geom':geom,
'prim':prim,
'tile':tiles[i],
'geomIndex': d/4
}
)
rock = loader.loadTexture('assets/img/modifiers/rock.png')
rock.setMagfilter(Texture.FTLinearMipmapLinear)
rock.setMinfilter(Texture.FTLinearMipmapLinear)
for x in self._tiles:
for z in x:
self._geomNode.addGeom(z['geom'])
attrib = TextureAttrib.make(z['tile']._tex)
if z['geomIndex'] % 15 == 0:
stage = TextureStage('modifiers')
stage.setMode(TextureStage.MDecal)
attrib = attrib.addOnStage(stage, rock)
self._geomNode.setGeomState(z['geomIndex'], self._geomNode.getGeomState(z['geomIndex']).addAttrib\
(attrib))