Hello!
I’m building an fps in ogre and I use blender for everything model-related, including the level editor.
I love blender. I’ve been using it for years now, but I know nothing about python.
It didn’t bother me at all, blender is super handy and lots of fun to use without knowledge of any python.
So I didn’t think I’d need to learn any python, but I’ve hit a wall.
In my game I need ai node locations. I can code them manually into my game, but that would take ages and I’d end up making lots of mistakes, I’m sure.
I did a lot of googling but the best I found was this awesome script on this page.
import bpy
for item in bpy.data.objects:
print(item.name)
if item.type == ‘MESH’:
for vertex in item.data.vertices:
print(vertex.co)
That was pretty awesome, but I need a script that will output vertex x,y,z and all of its neighbours listed as vertex index.
for example, here is a list of vertexes with their index#, x ,y ,z , neighbour1 ,2 ,3 ,4 ,5 ,6
[TABLE=“width: 500”]
x
y
z
n1
n2
n3
n4
n5
n6
1
26.3
11.7
-36.2
2
0
0
0
0
0
2
26.0
-24.7
2.5
1
3
0
0
0
0
3
-0.9
-24.6
3.9
2
4
0
0
0
0
4
-15.1
-25.0
3.2
3
0
0
0
0
0
[/TABLE]
The game I’ve built has an AI node system where each node can have up to 6 neighbours. This is a restriction that I’ve coded in for different reasons, but hopefully that makes things easier here anyway :b
(neighbour 0 means no neighbour)
This is the only time I’ve needed to play with the blender console and python.
It would mean a lot for me and development if someone could write me up a script that could export a mesh’s vertex index #, x,y,z, and all of its 6 neighbours (in ini format would be heavenly)
example:
[1]
x=26.3
y=11.7
z=-36.2
n1=2
[2]
x=26.0
y=-24.7
z=2.5
n1=1
n2=3
[3]
etc…
if that’s too pompous of me, please excuse my manners, I’m just really anxious to move along and trying not to come off as a dink in the process. Please teach me how I can achieve this without having to step into learning a whole new language in the middle of my development schedule. :b
Thanks for reading!
picture of ai node mesh: