Indice Generale | Struttura Gerarchica |
//File VIAGGIO.JAVA import vrml.*; import vrml.node.*; import vrml.field.*; public class viaggio extends Script { int i, j, k, l; float[] coordX; float[] coordY; float[] coordZ; float[] angolo; float[] translation; float[] rotation; boolean viaggio = false; boolean centro = true; SFVec3f ViaggioTranslation; SFRotation ViaggioRotation; SFBool ViaggioViewBind; public void initialize () { coordX = new float[320]; coordY = new float[320]; coordZ = new float[320]; angolo = new float[320]; translation = new float[3]; rotation = new float[4]; ViaggioTranslation = (SFVec3f) getEventOut("ViaggioTranslation"); ViaggioRotation = (SFRotation) getEventOut("ViaggioRotation"); ViaggioViewBind = (SFBool) getEventOut("ViaggioViewBind"); i = 0; rotation[0] = 0.0f; rotation[1] = 1.0f; rotation[2] = 0.0f; rotation[3] = 0.0f; ViaggioRotation.setValue(rotation); l = 0; for (j = 22000; j >= 2000; j -= 4000) { for (k = 0; k < 64; k++) { coordX[l] = (float) (-j * Math.sin(k * 0.098125f)); coordY[l] = 1000.0f; coordZ[l] = (float) (j * Math.cos(k * 0.098125f)); angolo[l] = (0.3925f - (k * 0.098125f)); l++; } } } public void processEvent(Event e) { String nomeEvento = e.getName(); if (nomeEvento.equals("Move")) { Move(); } if (nomeEvento.equals("StartStop")) { StartStop(); } } public void Move() { translation[0] = coordX[i]; translation[1] = coordY[i]; translation[2] = coordZ[i]; ViaggioTranslation.setValue(translation); rotation[3] = angolo[i]; ViaggioRotation.setValue(rotation); if (centro == true) { i++; if (i == 320) { centro = false; i = 319; } } else { i--; if (i == -1) { centro = true; i = 0; } } } public void StartStop() { if (viaggio == true) { viaggio = false; ViaggioViewBind.setValue(false); } else { viaggio = true; ViaggioViewBind.setValue(true); } } public void shutdown() {} }