75 using System.Collections.Generic;
150 LoadBox = GameObject.Find (
"LoadBox");
152 mainCamera = Camera.main;
153 LocCamera = mainCamera.gameObject;
156 Molecule3DComp = LoadBox.GetComponent<
Molecule3D> ();
160 GameObject go =
new GameObject (
"Cam Target");
162 target = go.transform;
165 distance = Vector3.Distance (transform.position, target.position);
170 position = transform.position;
171 rotation = transform.rotation;
174 currentRotation = transform.rotation;
175 desiredRotation = transform.rotation;
177 xDeg = Vector3.Angle (Vector3.right, transform.right);
178 yDeg = Vector3.Angle (Vector3.up, transform.up);
180 newUIToggle = GameObject.Find(
"New UI Toggle Canvas/Toggle New GUI");
224 if (Input.GetButtonUp (
"Spin Molecule")) {
225 Debug.Log (
"Space push");
231 if (Input.GetKeyUp (KeyCode.R)) {
232 cameraTranslation =
true;
233 centerChanged =
true;
234 newposition = Vector3.zero;
237 if (Input.GetKeyUp (KeyCode.C)) {
252 cameraTranslation =
true;
253 centerChanged =
true;
259 Vector3 barycenter =
new Vector3 ();
260 float xTot = 0.0f, yTot = 0.0f, zTot = 0.0f;
262 for (
int i=0; i<mainCamera.GetComponent<
ClickAtom>().objList.Count; i++) {
270 barycenter.x = xTot / mainCamera.GetComponent<
ClickAtom> ().objList.Count;
272 barycenter.z = zTot / mainCamera.GetComponent<
ClickAtom> ().objList.Count;
274 newposition = barycenter;
276 cameraTranslation =
true;
277 centerChanged =
true;
298 if (Input.GetMouseButton (1) && !(
UIData.
newUIActivated & EventSystem.current.IsPointerOverGameObject())) {
305 desiredDistance -= Input.GetAxis (
"Mouse Y") * Time.deltaTime *
zoomRate;
308 else if (Input.GetMouseButton (0)
313 if (Input.mousePosition.x < Screen.width * 0.85f && Input.mousePosition.y < Screen.height * 0.85f && Input.mousePosition.y > Screen.height * 0.15f) {
314 xDeg = Input.GetAxis (
"Mouse X") * xSpeed * 0.02f;
315 yDeg = -Input.GetAxis (
"Mouse Y") * ySpeed * 0.02f;
316 }
else if (Input.mousePosition.x > Screen.width * 0.85f) {
317 yDeg = -Input.GetAxis (
"Mouse Y") * xSpeed * 0.02f;
319 }
else if (Input.mousePosition.y > Screen.height * 0.85f) {
320 xDeg = Input.GetAxis (
"Mouse X") * xSpeed * 0.02f;
323 zDeg = Input.GetAxis (
"Mouse X") * ySpeed * 0.02f;
330 else if (Input.GetMouseButton (2) && !(
UIData.
newUIActivated & EventSystem.current.IsPointerOverGameObject()) ) {
334 Vector3 v = LocCamera.transform.localPosition;
335 v.x -= Input.GetAxis (
"Mouse X") *
panSpeed;
336 v.y -= Input.GetAxis (
"Mouse Y") *
panSpeed;
337 LocCamera.transform.localPosition = v;
349 if(mainCamera.orthographic && !(
UIData.
newUIActivated & EventSystem.current.IsPointerOverGameObject())){
351 float tmp_size = mainCamera.orthographicSize - Input.GetAxis (
"Mouse ScrollWheel") * Time.deltaTime *
zoomRate;
353 mainCamera.orthographicSize = tmp_size;
356 else if(!mainCamera.orthographic && !(
UIData.
newUIActivated & EventSystem.current.IsPointerOverGameObject())){
357 desiredDistance -= Input.GetAxis (
"Mouse ScrollWheel") * Time.deltaTime *
zoomRate;
361 if (automove ==
true) {
364 xDeg += Mathf.Lerp (0.0F, 100.0F, Time.deltaTime * 0.8f);
372 if (cameraTranslation) {
374 weight_cam += Time.deltaTime * 1;
375 target.localPosition = Vector3.Lerp (target.localPosition, newposition, weight_cam);
377 mainCamera.transform.localPosition = Vector3.Lerp (mainCamera.transform.localPosition, Vector3.zero, weight_cam);
381 if (target.position == newposition && mainCamera.transform.localPosition== Vector3.zero) {
384 cameraTranslation =
false;
385 centerChanged =
false;
389 if(xDeg != 0 || yDeg != 0 || zDeg != 0){
391 desiredRotation *= Quaternion.Euler (yDeg, xDeg, zDeg);
392 currentRotation = transform.rotation;
393 rotation = Quaternion.Lerp (currentRotation, desiredRotation, Time.deltaTime * zoomDampening);
400 currentDistance = Mathf.Lerp (currentDistance, desiredDistance, Time.deltaTime * zoomDampening);
401 position = target.position - (rotation * Vector3.forward * currentDistance +
targetOffset);
418 private static float ClampAngle (
float angle,
float min,
float max)
424 return Mathf.Clamp (angle, min, max);
429 LocCamera.transform.localPosition = Vector3.zero;
430 target.transform.localPosition = Vector3.zero;
432 LocCamera.transform.rotation =
new Quaternion (0, 0, 0, 0);
433 transform.rotation = Quaternion.identity;
434 centerChanged =
false;
443 target.rotation = transform.rotation;
445 Vector3 v = LocCamera.transform.localPosition;
450 v.x -= (Input.GetAxis (
"Horizontal") * panSpeed * Time.deltaTime);
451 v.y -= (Input.GetAxis (
"Vertical") * panSpeed * Time.deltaTime);
453 LocCamera.transform.localPosition = v;
458 if (Input.GetAxis (
"Axis3") > joypadDeadzone || (Input.GetAxis (
"Axis3") < -
joypadDeadzone))
460 xDeg = Input.GetAxis (
"Axis3") * xSpeed * 0.08f;
463 if (Input.GetAxis (
"Axis4") > joypadDeadzone || (Input.GetAxis (
"Axis4") < -
joypadDeadzone))
465 yDeg = Input.GetAxis (
"Axis4") * ySpeed * 0.08f;
469 if (Input.GetButton(
"Rotate Z Right"))
471 zDeg = Time.deltaTime * xSpeed * 0.5f;
474 if (Input.GetButton(
"Rotate Z Left"))
476 zDeg = - Time.deltaTime * xSpeed * 0.5f;
480 if (Input.GetButton(
"Zoom In")) {
481 desiredDistance -= Time.deltaTime * zoomRate * 0.08f;
486 if (Input.GetButton(
"Zoom Out")) {
487 desiredDistance += Time.deltaTime * zoomRate * 0.08f;
503 if (Input.GetButton (
"Rotate X Right")){
508 if (Input.GetButton (
"Rotate X Left")) {
517 if (Input.GetButton (
"Rotate Y Up")){
522 if (Input.GetButton (
"Rotate Y Down")){
void ToNotParticle()
Switch the protein representation to Hyperball.
static float ClampAngle(float angle, float min, float max)
static bool newUIActivated
Vector3 originalCamPosition
void ToParticle()
Switch the protein representation to Particle.
static float currentDistance
Quaternion currentRotation
static Vector3 cameraLocation
Quaternion desiredRotation
static GameObject LocCamera
!WiP Includes FLAGS of GUI.
The GNParameters class regroups settings used for Guided Navigation and GLIC spreading.
static float desiredDistance
static Vector3 targetOffset
static bool toggle_NA_CLICK
Molecule3D Molecule3DComp
void keyboardOperate()
Manage the camera rotation with keyboard inputs.
static bool toggle_NA_AUTOMOVE
static float minOrthoSize
Vector3 cameraLocalPositionSave
List< GameObject > objList
static List< float[]> atomsLocationlist
The coordinates of each atom.