70 using System.Collections.Generic;
74 using System.Globalization;
86 Color c1 = Color.white;
87 Debug.Log(
"Entering :: DisplayFieldLine");
93 Vector3 locationbegin =
new Vector3(0,0,0);
94 Vector3 curent =
new Vector3(0,0,0);
95 Transform FiledLineManager =
new GameObject(
"FieldLineManager").transform;
99 GameObject FieldLineF =
new GameObject();
100 FieldLineF.name=
"FieldLineF"+i;
101 FieldLineF.transform.parent = FiledLineManager;
103 LineRenderer lineRenderer = FieldLineF.AddComponent<LineRenderer>();
104 lineRenderer.useWorldSpace =
false;
105 lineRenderer.material =
new Material (Shader.Find(
"Custom/FieldLineCg"));
106 lineRenderer.SetColors(c1, c1);
107 lineRenderer.SetWidth(0.2f,0.2f);
109 lineRenderer.SetVertexCount(5);
110 lineRenderer.shadowCastingMode = ShadowCastingMode.Off;
111 lineRenderer.receiveShadows =
false;
120 Vector3 luMin =
new Vector3(
float.MaxValue,
float.MaxValue,
float.MaxValue);
121 Vector3 luWidth =
new Vector3(
float.MinValue,
float.MinValue,
float.MinValue);
122 ArrayList posLookup =
new ArrayList();
137 lineRenderer.SetPosition(j, location);
139 lineRenderer.SetVertexCount(nbPoint+1);
140 locationbegin = location;
142 posLookup.Add(location);
157 xdif = location[0] - locationbegin[0];
158 ydif = location[1] - locationbegin[1];
159 zdif = location[2] - locationbegin[2];
162 if(disttot-(
int)disttot <0.5)
163 nbsegment = 2*(int)disttot;
165 nbsegment = 2 *(int)disttot+1;
169 curent = locationbegin;
170 for (k=0; k<nbsegment;k++){
172 curent[0]+=(xdif/nbsegment);
173 curent[1]+=(ydif/nbsegment);
174 curent[2]+=(zdif/nbsegment);
176 lineRenderer.SetPosition(nbPoint, curent);
179 lineRenderer.SetVertexCount(nbPoint+1);
181 posLookup.Add(curent);
182 for(
int ind=0; ind<3; ind++)
184 luMin[ind] = Mathf.Min(luMin[ind],curent[ind]);
186 luWidth[ind] = Mathf.Max(luWidth[ind],curent[ind]);
191 locationbegin = curent;
203 Texture2D tex_wPos =
new Texture2D(nbPoint,1,TextureFormat.ARGB32,
false);
204 tex_wPos.filterMode = FilterMode.Point;
205 tex_wPos.wrapMode = TextureWrapMode.Clamp;
206 luWidth = luWidth - luMin;
208 for(j=0; j<nbPoint; ++j)
210 Vector3 p = ((Vector3)posLookup[j])-luMin;
211 tex_wPos.SetPixel(j,0,
new Color(p.x/luWidth.x, p.y/luWidth.y, p.z/luWidth.z, 1.0f));
215 lineRenderer.material.SetTexture(
"_PosLookup",tex_wPos);
216 lineRenderer.material.SetVector(
"_MinPosLookup",luMin);
217 lineRenderer.material.SetVector(
"_WidthPosLookup",luWidth);
219 lineRenderer.SetVertexCount(nbPoint);
221 lineRenderer.material.SetFloat(
"_Unsynchronize",
UnityEngine.Random.value * 10.0f);
222 lineRenderer.material.SetFloat(
"_timeOff",Time.time);
223 lineRenderer.material.SetColor(
"_Color",Color.white);
static bool fieldLineFileExists
static void DisplayFieldLine()
static ElectrostaticManager getElectrostaticManager()
static List< List< Vector3 > > FieldLineList
void AddFieldLine(GameObject flgo)