internal void BuildDrawInfo(PathGraph graph) { FreeVBs(); List <Vector3> verts = new List <Vector3>(); List <Vector3> norms = new List <Vector3>(); List <UInt32> indexes = new List <UInt32>(); List <int> vertCounts = new List <int>(); graph.GetNodePolys(verts, indexes, norms, vertCounts); if (verts.Count == 0) { return; } VPosNormCol0 [] nodeVerts = new VPosNormCol0[verts.Count]; for (int i = 0; i < nodeVerts.Length; i++) { nodeVerts[i].Position = verts[i] + Vector3.UnitY; //boost up 1 nodeVerts[i].Normal.X = norms[i].X; nodeVerts[i].Normal.Y = norms[i].Y; nodeVerts[i].Normal.Z = norms[i].Z; nodeVerts[i].Normal.W = 1f; } int idx = 0; for (int i = 0; i < vertCounts.Count; i++) { Color col = Mathery.RandomColor(mRand); for (int j = 0; j < vertCounts[i]; j++) { nodeVerts[idx + j].Color0 = col; } idx += vertCounts[i]; } mVBNodes = VertexTypes.BuildABuffer(mGD.GD, nodeVerts, VertexTypes.GetIndex(nodeVerts[0].GetType())); mIBNodes = VertexTypes.BuildAnIndexBuffer(mGD.GD, indexes.ToArray()); mVBBNodes = VertexTypes.BuildAVBB(VertexTypes.GetIndex(nodeVerts[0].GetType()), mVBNodes); mNodeIndexCount = indexes.Count; //connexions List <PathGraph.LineSeg> segz = graph.GetNodeConnections(); if (segz.Count <= 0) { return; } VPosNormCol0 [] segVerts = new VPosNormCol0[segz.Count * 3]; UInt32 index = 0; indexes.Clear(); foreach (PathGraph.LineSeg seg in segz) { Color col = Mathery.RandomColor(mRand); //endpoint segVerts[index].Position = seg.mB; Vector3 lineVec = seg.mB - seg.mA; //get a perpindicular axis to the a to b axis //so the back side of the connection can flare out a bit Vector3 crossVec = Vector3.Cross(lineVec, Vector3.UnitY); crossVec.Normalize(); Vector3 normVec = Vector3.Cross(crossVec, lineVec); normVec.Normalize(); crossVec *= 2f; segVerts[index + 1].Position = seg.mA - crossVec + Mathery.RandomDirectionXZ(mRand); segVerts[index + 2].Position = seg.mA + crossVec + Mathery.RandomDirectionXZ(mRand); segVerts[index].Color0 = col; segVerts[index + 1].Color0 = col; segVerts[index + 2].Color0 = col; //adjust up segVerts[index].Position += Vector3.UnitY * 2f; segVerts[index + 1].Position += Vector3.UnitY * 1.7f; segVerts[index + 2].Position += Vector3.UnitY * 1.7f; Half4 norm; norm.X = normVec.X; norm.Y = normVec.Y; norm.Z = normVec.Z; norm.W = 1f; segVerts[index].Normal = norm; segVerts[index + 1].Normal = norm; segVerts[index + 2].Normal = norm; indexes.Add(index); indexes.Add(index + 1); indexes.Add(index + 2); index += 3; } mVBCons = VertexTypes.BuildABuffer(mGD.GD, segVerts, VertexTypes.GetIndex(segVerts[0].GetType())); mIBCons = VertexTypes.BuildAnIndexBuffer(mGD.GD, indexes.ToArray()); mVBBCons = VertexTypes.BuildAVBB(VertexTypes.GetIndex(segVerts[0].GetType()), mVBCons); mConIndexCount = indexes.Count; }