dan see this plz

[pascal]


TAINodes =record
NodePosition : D3DVECTOR;
NodeAround:array of Integer;
NodeAroundNum : Integer;
NodeAroundCnt:integer;
// Flags : Integer;
NodeDistance:array of Single;
End;

AIGraph=record
Node:array of TAINodes;
NumNode : Integer;
End;

TDXPathFind=class
private
ResearchRadius, MaxChangeAltitude:single;
public
Graph : AIGraph;
procedure AddNode(Position : D3DVECTOR);
procedure CreateAIGraph;
Function FindPath(StartPos ,EndPos : D3DVECTOR; var StorePath : TDXPath) : Boolean;
procedure Render;
constructor create;
end;



Function VModulus(V : D3DVECTOR) : Single;
begin
//result:= D3DXVec3Length(V);
with v do Result:= Sqrt(x*x + y*y + z*z);

End;
Function VSubtract(V1: D3DVECTOR; V2 : D3DVECTOR) : D3DVECTOR;
begin
result.x:= v1.x - v2.x;
result.y:= v1.y - v2.y;
result.z:= v1.z - v2.z;



End;

constructor TDXPathFind.create;
begin
// setlength( Node,1);
MaxChangeAltitude := 50;
ResearchRadius := 600;
Graph.NumNode:=0;

end;

procedure TDXPathFind.CreateAIGraph;

// '##BD Links the nodes each others in order to speed up the path finding. Note : You must call this method before using any path finding method.
var
i , Node :integer;
Distance : Single;
Changed:boolean;
begin
For I := 1 To succ(Graph.NumNode) do
begin
setlength(Graph.Node[I].NodeDistance,0);
setlength(Graph.Node[I].NodeAround,0);
For Node := 1 To succ(Graph.NumNode) do
begin
If Node <> I Then
begin

Distance := VModulus(VSubtract(Graph.Node[I].NodePosition, Graph.Node[Node].NodePosition));
If Distance < ResearchRadius Then
begin
{ If (Collsion(Graph.Node[I].NodePosition, Graph.Node[Node].NodePosition) = False)
And (Graph.Node[I].NodePosition.y - Graph.Node[Node].NodePosition.y < MaxChangeAltitude)
then
begin
}
With Graph.Node[I] do
begin
// Distance:=20;
setlength(NodeAround,length(NodeAround) + 1);
setlength(NodeDistance,length(NodeDistance) + 1);
NodeAroundNum := NodeAroundNum + 1;
NodeAround[high(NodeAround)] := Node;
NodeDistance[high(NodeDistance)] := Distance;
End;// With
end;

// end;
End;
end ;//for Node
end;//for I
//'Let a place to the end and start point
// setlength(Graph.Node,high(Graph.Node) + 3);
setlength(Graph.Node,succ(Graph.NumNode + 2));
End;

Function TDXPathFind.FindPath(StartPos ,EndPos : D3DVECTOR; var StorePath : TDXPath) : Boolean;
// Function TDXPathFind.FindPath(StartPos ,EndPos : D3DVECTOR) : Boolean;
// '##BD Find a path from the start vector to the end vector. Returns True if a path has been found, False else.
// '##PD StartPos Start vector in the 3d world
// '##PD EndPos End vector in the 3d world
// '##PD Path Path in what the found path will be stored.
var
inode,StartNode,
EndNode : Integer;
Score:array of Single;
Distance,BestScore : Single;
node,Index,s,i : Integer;
BestNode,N : Integer;
NodePath:array of integer;
Changed:boolean;
trys:integer;
begin
result:=false;
setlength(Score,succ(Graph.NumNode) + 2);

Graph.Node[Graph.NumNode +1].NodePosition := StartPos;
Graph.Node[Graph.NumNode +2].NodePosition := EndPos;


For I := Graph.NumNode + 1 To Graph.NumNode + 2 do
begin
setlength(graph.Node[i].NodeDistance,0);
setlength(graph.Node[i].NodeAround,0);

For Node := 1 To Graph.NumNode do
begin
If Node <> I Then
begin
Distance := VModulus(VSubtract(Graph.Node[I].NodePosition, Graph.Node[Node].NodePosition));
// showmessage(floattostr(Distance));
If Distance < ResearchRadius Then
begin

{ If (Collsion(Graph.Node[i].NodePosition, Graph.Node[node].NodePosition) = false) then
begin
}
With Graph.Node[I] do
begin


setlength(NodeAround ,succ(high(NodeAround) + 2));
setlength(NodeDistance,succ(high(NodeDistance) + 2));

setlength(Graph.Node[Node].NodeAround ,pred(Graph.Node[Node].NodeAroundNum+1));
setlength(Graph.Node[Node].NodeDistance,pred(Graph.Node[Node].NodeAroundNum+1));


Graph.Node[Node].NodeAround[high(Graph.Node[Node].NodeAround)] := I;
Graph.Node[Node].NodeDistance[high(Graph.Node[Node].NodeDistance)] := Distance;

NodeAround[high(NodeAround)] := Node;
NodeDistance[high(NodeDistance)] := Distance;


End;
End;
// End;
end;
end;
end;



//' Voodoo VB Path finding algorithm.
Score[Graph.NumNode + 2] := 1;


//'Create a node map from the end node

Changed := False;
repeat

For I := 1 To Graph.NumNode + 2 do
begin
With Graph.Node[I] do
begin
If Score[I] <> 0 Then
begin
For N := 1 To high(NodeAround) do
begin
ProcessMessages;
If (Score[I] + NodeDistance[N] < Score[NodeAround[N]])
Or (Score[NodeAround[N]] = 0) Then
begin;
Score[NodeAround[N]] := Score[I] + NodeDistance[N];
Changed := True;
End;
end;
End;
End;

end;

Changed := False;

Until Changed = False;


// //Now search the path
S := Graph.NumNode +1 ;
repeat

BestNode := -1;
BestScore := 10000000;// 'let's take a impossible number

For I := 1 To high(Graph.Node[S].NodeAround) do
begin
Index := Graph.Node[S].NodeAround[I];
If (Score[Index] < BestScore) And (Score[Index] <> 0) Then
begin
BestScore := Score[Index];
BestNode := Index;
End;
end;
ProcessMessages;
If BestNode = -1 Then
begin
showmessage ('No found in searching');
exit;
End;
setlength(NodePath,high(NodePath) + 2);
NodePath[high(NodePath)] := BestNode;
If BestNode = Graph.NumNode + 2 Then break;
S := BestNode;

until false;
//end;


StorePath.AddPathNode(Graph.Node[Graph.NumNode + 1].NodePosition);
For I := 1 To high(NodePath) do
begin
StorePath.AddPathNode(Graph.Node[NodePath[I]].NodePosition);
end;
StorePath.AddPathNode(Graph.Node[Graph.NumNode + 2].NodePosition);
result:=true;

End;


procedure TDXPathFind.AddNode(Position : D3DVECTOR);
begin
//'##BD Add a node to the path finding system nodes list. Note : When all the nodes are added, you have to call the AICreateGraph function.
// '##PD Position Position in the 3d world of the new node.
Graph.NumNode := Graph.NumNode + 1;
setlength(Graph.Node,Graph.NumNode+2);
Graph.Node[Graph.NumNode].NodePosition := Position

End;

[/pascal]

what is doing wrong :?