/** * Copia las articulaciones y efector final del Scorbot de este modelo (toda la configuración), * para dejarlos en las variables pasadas. * @param art Articulationes * @param artE Efector final * @return void */ public void InitToCopy(out Articulation[] art, out Transform artE) { GameObject g; art = new Articulation[articulations.Length]; for (int i = 0; i < articulations.Length; i++) { g = new GameObject(); g.name = "CopyArticulation" + scorbotIndex; g.transform.position = articulations[i].transform.position; g.AddComponent <Articulation>(); // Copy articulation config g.GetComponent <Articulation>().SetPlane(articulations[i].GetPlane()); g.GetComponent <Articulation>().SetLimit(articulations[i].lowerLimitCount, articulations[i].upperLimitCount, articulations[i].homeCount, articulations[i].degrees, articulations[i].offset); g.GetComponent <Articulation>().SetCountsAreTransformed(articulations[i].CountsAreTransformed()); // Parenting art[i] = g.GetComponent <Articulation>(); if (i >= 1) { art[i].transform.parent = art[i - 1].transform; } } // Copy E config g = new GameObject(); g.name = "CopyE" + scorbotIndex; g.transform.position = E.position; g.transform.parent = art[art.Length - 1].transform; artE = g.transform; }
private static int TranslateArticulation(KeySwitch keySwitch, Articulation articulation, IXLWorksheet sheet, int row) { // Articulation name var column = SpreadsheetConstants.ColumnDataBegin; sheet.Cell(row, column).Value = articulation.ArticulationName.Value; sheet.Cell(row, column).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; // MIDI data column = SpreadsheetConstants.ColumnMidiMessageBegin; column = TranslateMidiNoteMapping(articulation.MidiNoteOns, sheet, row, column); column = TranslateMidiControlChangeMapping(articulation.MidiControlChanges, sheet, row, column); column = TranslateMidiProgramChangeMapping(articulation.MidiProgramChanges, sheet, row, column); // Extra Data var extraDataTranslator = new ExtraDataTranslator(keySwitch); extraDataTranslator.Translate( sheet, SpreadsheetConstants.RowDataHeader, SpreadsheetConstants.RowDataBegin, column ); return(column); }
private void Translate(Articulation articulation, IXLWorksheet sheet, int startRow, int startColumn) { var column = startColumn; var row = startRow; foreach (var extra in articulation.ExtraData) { var offset = HeaderTextList.IndexOf(extra.Key); sheet.Cell(row, column + offset).Value = extra.Value; } }
public void PlaySound(Note note, Articulation articulation) { List <ISampleProvider> providers = new List <ISampleProvider>(); foreach (Tone tone in note.Sound.Tones()) { ISampleProvider sineWave = new SignalGenerator() { Gain = 1, Frequency = temperament.GetFrequency(tone), Type = SignalGeneratorType.Sin }.Take(TimeSpan.FromSeconds(tempo.MeasureLengthInSeconds * (Articulations[articulation] + note.Length))); providers.Add(sineWave); } if (providers.Count > 0) { MixingSampleProvider mixer = new MixingSampleProvider(providers); WaveOutEvent wo = new WaveOutEvent(); wo.PlaybackStopped += Wo_PlaybackStopped; wo.Init(mixer); wo.Play(); } }
static void AddArticulation(IDictionary <string, ICollection <Articulation> > dictionary, string key, Articulation articulation) { if (!dictionary.ContainsKey(key)) { dictionary[key] = new List <Articulation>(); } dictionary[key].Add(articulation); }
private void Awake() { articulation = this.GetComponent <Articulation>(); }
/** * Aplica el algoritmo CCD para una articulación y la rota. * @param articulations Articulaciones * @param D Posición objetivo * @param E Efector final * @param R Articulación actual * @return void */ private void CCD(Articulation[] articulations, Transform D, Transform E, Articulation R) { // Calculate angle. Radians float beta1 = 0.0f; float beta2 = 0.0f; // Vertical plane if (R.GetPlane().Equals(PlaneHelper.XY)) { Vector3 rLocalPos = Vector3.zero; Vector3 dLocalPos = GetLocalPosition(D, articulations[1].transform); Vector3 eLocalPos = GetLocalPosition(E, articulations[1].transform); if (!articulations[1].Equals(R)) { rLocalPos = GetLocalPosition(R.transform, articulations[1].transform); } else { rLocalPos = Vector3.zero; } beta1 = CalculateAngle(dLocalPos, rLocalPos, R.GetPlane()); beta2 = CalculateAngle(eLocalPos, rLocalPos, R.GetPlane()); } // Horizontal plane else { beta1 = CalculateAngle(D.position, R.GetPosition(), R.GetPlane()); beta2 = CalculateAngle(E.position, R.GetPosition(), R.GetPlane()); } float beta = 0.0f; switch (R.GetPlane()) { case PlaneHelper.XY: beta = (beta1 - beta2); break; case PlaneHelper.XZ: beta = (beta2 - beta1); break; } // Shortest path if (R.GetPlane().Equals(PlaneHelper.XY)) { while (beta > Mathf.PI) { beta -= 2 * Mathf.PI; } while (beta < -Mathf.PI) { beta += 2 * Mathf.PI; } } // Degrees beta = beta * Mathf.Rad2Deg; // Apply angle R.Rotate(beta); }
/** * Mueve o rota un objeto dependiento del objeto seleccionado. Si es un eje se produce un movimiento * con ayuda de los cambios del ratón, si es un eje de rotación se aplica una rotación con ayuda * de los cambios del ratón. * @return void */ private void MoveOrRotate() { // Parent from selected object. An object can contain axis and a selectable object, // these components are contained in a parent object, so to move everything we just move // the parent since its children will automatically follow. Transform parent = selectedObject.transform.parent.transform; // Selected object is an Axis if (selectedObject.tag.Contains(AXIS_TAG)) { Vector3 startPos = parent.position; // Selected object is an Axis X if (selectedObject.tag.Contains(X_TAG)) { // Angle between camera and object float angle = Vector3.Angle(cam.right, parent.right); // Move object around axis x, angle determines forward or backward if (angle < 90f) { parent.Translate(new Vector3(axisSensibityReduction * axisSensibity * Input.GetAxis(MOUSE_X), 0f, 0f)); } else { parent.Translate(new Vector3(axisSensibityReduction * -axisSensibity * Input.GetAxis(MOUSE_X), 0f, 0f)); } } // Selected object is an Axis Y if (selectedObject.tag.Contains(Y_TAG)) { // Move object around axis y parent.Translate(new Vector3(0f, axisSensibityReduction * axisSensibity * Input.GetAxis(MOUSE_Y), 0f)); } // Selected object is an Axis Z if (selectedObject.tag.Contains(Z_TAG)) { // Angle between camera and object float angle = Vector3.Angle(cam.right, parent.forward); // Move object around axis z, angle determines forward or backward if (angle < 90f) { parent.Translate(new Vector3(0f, 0f, axisSensibityReduction * axisSensibity * Input.GetAxis(MOUSE_X))); } else { parent.Translate(new Vector3(0f, 0f, axisSensibityReduction * -axisSensibity * Input.GetAxis(MOUSE_X))); } } // Target (a position) moved. Invalid angles if (selectedObject.tag.Contains(TARGET_TAG) && (!startPos.Equals(parent.position))) { // If it is not a being used by another position (relative), this position not sync anymore if (parent.GetComponent <TargetModel>().GetRelativeTo() == null) { Transform relativePosition = parent.GetComponent <TargetModel>().GetRelativeFrom(); parent.GetComponent <TargetModel>().SetSync(false); // if this position is being used by another position (relative), that position is not sync anymore ; if (parent.GetComponent <TargetModel>().GetRelativeFrom()) { relativePosition.GetComponent <TargetModel>().SetSync(false); // Updating relative position relativePosition.GetComponent <TargetModel>().UpdateRelativePosition(); // Update angles data if (robot.TargetInRange(relativePosition)) { // Reachable. Load data to target relativePosition.GetComponent <TargetModel>().SetAngles(robot.GetAnglesFromCopy()); relativePosition.GetComponent <TargetModel>().SetValid(true); } else // Unreachable { relativePosition.GetComponent <TargetModel>().SetValid(false); } } // Check if it's an unreachable point if (robot.TargetInRange(parent)) { // Reachable. Load data to target parent.GetComponent <TargetModel>().SetAngles(robot.GetAnglesFromCopy()); parent.GetComponent <TargetModel>().SetValid(true); } else // Unreachable { parent.GetComponent <TargetModel>().SetValid(false); } stateMessageControl.UpdatePositionLog(); } else // Moved a relative position, revert position { parent.GetComponent <TargetModel>().UpdateRelativePosition(); } } // Update trayectory in case a position is moved gameController.DrawTrayectory(); } // Selected object is a rotation axis if (selectedObject.tag.Contains(ROTATION_TAG)) { // Scorbot articulation Articulation art = parent.GetComponent <Articulation>(); // If selected object parent is an articulation if (art != null) { // If articulation plane is xz, apply rotation if (art.GetPlane().Equals(PlaneHelper.XZ)) { parent.GetComponent <Articulation>().Rotate(-rotationSensibity * Input.GetAxis(MOUSE_X)); } // If articulation plane is xy, apply rotation if (art.GetPlane().Equals(PlaneHelper.XY)) { // Angle between camera and object float angle = Vector3.Angle(cam.forward, parent.forward); // Rotate object around plane xy, angle determines forward or backward if (angle < 90f) { parent.GetComponent <Articulation>().Rotate(-rotationSensibity * Input.GetAxis(MOUSE_X)); } else { parent.GetComponent <Articulation>().Rotate(rotationSensibity * Input.GetAxis(MOUSE_X)); } } // If articulation plane is yz, apply rotation if (art.GetPlane().Equals(PlaneHelper.YZ)) { // Angle between camera and object float angle = Vector3.Angle(cam.forward, parent.right); // Rotate object around plane yz, angle determines forward or backward if (angle < 90f) { parent.GetComponent <Articulation>().Rotate(-rotationSensibity * Input.GetAxis(MOUSE_X)); } else { parent.GetComponent <Articulation>().Rotate(rotationSensibity * Input.GetAxis(MOUSE_X)); } } } } // If selected object is Scorbot InnerAxis (InnerTarget contains InnerAxis) if (selectedObject.tag.Contains(INNERAXIS_TAG)) { // Move Scorbot to InnerTarget position robot.CCDAlg(innerTarget.transform); } else // Update InnerTarget position to Scorbot end effector position when is not selected { innerTarget.transform.parent.transform.position = robot.GetE().position; } }
public Note(ISingleSound sound, double length, Articulation Articulation = Articulation.Staccato) { this.Sound = sound; this.Length = length; this.Articulation = Articulation; }
public static KeySwitch CreateKeySwitch(Articulation articulation) { return(CreateKeySwitch(new[] { articulation })); }