18 if(mainCamera == null)
19 mainCamera = Camera.main;
20 if (arrowParent == null)
22 arrowParent =
new GameObject(
"Arrow");
25 arrow = GameObject.CreatePrimitive(PrimitiveType.Cube);
26 arrow.transform.parent = arrowParent.transform;
27 arrow.transform.localScale =
new Vector3(0.4f, 3.5f, 0.4f);
28 arrow.transform.Translate(arrow.transform.up * 2.0f);
29 arrow.GetComponent<Renderer>().enabled =
true;
31 arrowParent.transform.position = transform.position;
32 arrowParent.transform.parent = transform;
38 if(Input.GetMouseButton(0)){
42 Vector3 p = Input.mousePosition;
43 p.z = mainCamera.WorldToScreenPoint(transform.position).z;
45 Vector3 worldCoords = mainCamera.ScreenToWorldPoint(p);
46 Vector3 force = worldCoords - transform.position;
47 manager.
send_forces(1,
new int[] {this.atomId},
new float[] {force.x, force.y, force.z});
49 float distance = Vector3.Distance(worldCoords, transform.position);
50 float arrowZScale = distance / 8.0f;
51 float arrowScale = distance / 12.0f;
52 arrowParent.transform.up = force;
53 arrowParent.transform.localScale =
new Vector3(arrowScale, arrowZScale, arrowScale);
61 manager.
send_forces(1,
new int[] {this.atomId},
new float[] {0.0f, 0.0f, 0.0f});
66 if (arrowParent != null)
68 GameObject.DestroyImmediate(arrowParent);
static ArtemisManager getArtemisManager()
void setAtomId(int atomId)
void send_forces(int nb_forces, int[] indices, float[] coordinates)