void Start() { wn = 8; // channel hn = 8; // midi note objs = new List <List <GameObject> >(); notes = new List <List <Cuboctahedron> >(); for (int w = 0; w < wn; w++) { List <GameObject> olist = new List <GameObject>(); List <Cuboctahedron> nlist = new List <Cuboctahedron>(); for (int h = 0; h < hn; h++) { float s = Cuboctahedron.outerSize; Vector3 pos = new Vector3((w - wn / 2 + 0.5f) * s, (h + 0.5f) * s + height, 0); pos = pos + transform.position; GameObject g = Instantiate(cuboctahedron, pos, Quaternion.identity); g.transform.parent = transform; olist.Add(g); Cuboctahedron co = g.GetComponent <Cuboctahedron>(); nlist.Add(co); } objs.Add(olist); notes.Add(nlist); } }
public void AddNote(int x, int y, int z, float v, Cuboctahedron _co) { int ch = x + 1; int nnum = MapMidiNumber(x, y); Note note = new Note(x, y, z, ch, nnum, v, _co); activeNotes[z].Add(note); }
public Note(int _x, int _y, int _z, int _ch, int _note, float _vel, Cuboctahedron _co) { x = _x; y = _y; z = _z; ch = _ch; note = _note; velocity = _vel; co = _co; //Bang(); }
protected override void InitializeService() { SpawnPosition = new Vector3(0.0f, 2.0f, 0.0f); // "alpha" is used as player ship { float sq3 = (float)Math.Sqrt(3.0f); Geometry gLow = new CustomTetrahedron(1.0f, sq3 / 2.0f, 2.0f); gLow.BuildEdges(); Geometry g = new SubdivideGeometryOperation(gLow).Destination; //g.Transform(Matrix4.CreateScale(1.6f)); //g = new CatmullClarkGeometryOperation(g).Destination; //g = new CatmullClarkGeometryOperation(g).Destination; var gm = new GeometryMesh( g, NormalStyle.PolygonNormals ); var m = gm.GetMesh; alpha = new UnitType( "Alpha", materialManager["magenta"], m, MakeShape(gLow), g.ComputeBoundingSphere(), 10.0f, // max health 1.0f, // density null, //typeof(PhysicsFrameController) typeof(LookAtPhysicsFrameController) ); } { Geometry g = new Cuboctahedron(1.0f); helium = new UnitType( "Helium", materialManager["red"], new GeometryMesh(g, NormalStyle.PolygonNormals).GetMesh, MakeShape(g), g.ComputeBoundingSphere(), 5.0f, 1.0f, seeker as IAI, typeof(LookAtPhysicsFrameController) ); } }
// Update is called once per frame void Update() { if (pd_a.IsActive && pd_b.IsActive) { if (!isPinched) { // Pinch Start isPinched = true; Vector3 m = (pd_a.Position + pd_b.Position) * 0.5f; float s = Cuboctahedron.outerSize; float h = Grid8x8.height; bool isOutArea = m.x <-s *4f || m.x> s * 4f || m.y <h || m.y> h + s * 8f || m.z <-s * 8f || m.z> s * 8f; if (!isOutArea) { xyz = CalcCoordToIndex(m); currentObj = GetObj(xyz[0], xyz[1], xyz[2]); } } else { // Pinching if (currentObj != null) { float dist = Vector3.Distance(pd_a.Position, pd_b.Position); float d = dist / (Cuboctahedron.innerSize * Mathf.Sqrt(2f)); currentObj.UpdateVelocity(d); } } } else { // Pinch End if (currentObj != null) { Note n = manager.GetNote(xyz[0], xyz[1], xyz[2]); if (currentObj.isOn) { if (n != null) { // update n.SetVeloctiy(currentObj.vel); //n.Bang(); } else { // add manager.AddNote(xyz[0], xyz[1], xyz[2], currentObj.vel, currentObj); currentObj.SetData(manager.GetNote(xyz[0], xyz[1], xyz[2])); } } else { // off if (n != null) { manager.DeleteNote(xyz[0], xyz[1], xyz[2]); } } } // reset isPinched = false; currentObj = null; xyz = null; } }