IEnumerator Delay(float time) { int i = 0; while (true) { if (i == 1) Application.LoadLevel(1); else if(i == 0) take = Take.Take01; i++; yield return new WaitForSeconds(time); } }
private void LoadStoryAndTakes() { Story addStory = new Story() ; addStory.UID = 1 ; addStory.StartTakeUID = 1 ; addStory.EndTakeUID = 5 ; m_ConversationManagerSharePointer.Stories.Add( addStory ) ; Take addTake = new Take() ; addTake.WaitingTime = 5.0f ; addTake.UID = 1 ; addTake.Potraits.Add( "ConversationManagerSprite_1" ) ; m_ConversationManagerSharePointer.Takes.Add( addTake ) ; addTake = new Take() ; addTake.WaitingTime = 5.0f ; addTake.UID = 2 ; addTake.Potraits.Add( "ConversationManagerSprite_1" ) ; addTake.Contents.Add( "ConversationManagerSprite_3:Cowbay" ) ; m_ConversationManagerSharePointer.Takes.Add( addTake ) ; addTake = new Take() ; addTake.WaitingTime = 5.0f ; addTake.UID = 3 ; addTake.Potraits.Add( "ConversationManagerSprite_1" ) ; addTake.Potraits.Add( "ConversationManagerSprite_2" ) ; addTake.Contents.Add( "ConversationManagerSprite_3:Cowbay" ) ; m_ConversationManagerSharePointer.Takes.Add( addTake ) ; addTake = new Take() ; addTake.WaitingTime = 5.0f ; addTake.UID = 4 ; addTake.Potraits.Add( "ConversationManagerSprite_1" ) ; addTake.Potraits.Add( "ConversationManagerSprite_2" ) ; addTake.Contents.Add( "ConversationManagerSprite_4:WTF..." ) ; m_ConversationManagerSharePointer.Takes.Add( addTake ) ; addTake = new Take() ; addTake.WaitingTime = 5.0f ; addTake.UID = 5 ; addTake.Potraits.Add( "" ) ; addTake.Potraits.Add( "ConversationManagerSprite_2" ) ; addTake.Contents.Add( "ConversationManagerSprite_4:..." ) ; m_ConversationManagerSharePointer.Takes.Add( addTake ) ; #if DEBUG Debug.Log( "Stories.Count=" + m_ConversationManagerSharePointer.Stories.Count ) ; Debug.Log( "Takes.Count=" + m_ConversationManagerSharePointer.Takes.Count ) ; #endif }
IEnumerator Delay(float time) { int i = 0; while (true) { if (i == 4) break; else if(i == 0) take = Take.Take01; else if(i == 1) take = Take.Take02; else if(i == 2) take = Take.Take03; else if(i == 3) take = Take.Take04; i++; yield return new WaitForSeconds(time); } }
protected override NameValueCollection GetQueryString() { var queryString = HttpUtility.ParseQueryString(string.Empty); queryString["q"] = Query; queryString["prerelease"] = Prerelease.ToString(); queryString["ignoreFilter"] = IgnoreFilter.ToString(); queryString["CountOnly"] = CountOnly.ToString(); if (Skip.HasValue) { queryString["Skip"] = Skip.ToString(); } if (Take.HasValue) { queryString["Take"] = Take.ToString(); } if (IncludeSemVer2) { queryString["semVerLevel"] = "2.0.0"; } if (!string.IsNullOrWhiteSpace(SortBy)) { queryString["sortBy"] = SortBy; } if (LuceneQuery.HasValue) { queryString["luceneQuery"] = LuceneQuery.ToString(); } return(queryString); }
public bool contextSelectionHasKeys(Take take) { Track track = getSelectedTrack(take); if (track != null) { foreach (Key key in track.keys) { for (int i = 0; i < contextSelection.Count; i += 2) { // if selection start frame > frame, break out of sorted list if (contextSelection[i] > key.frame) { break; } if (contextSelection[i] <= key.frame && contextSelection[i + 1] >= key.frame) { return(true); } } } } return(false); }
public void FromVegas(Vegas vegas) { myVegas = vegas; System.Collections.Generic.List <OFXDouble2DKeyframe> locations = new System.Collections.Generic.List <OFXDouble2DKeyframe>(); Tuple <Timecode, Timecode> durationTrackEvent; VideoEvent trackEvent = (VideoEvent)FindFirstSelectedEventUnderCursor(); if (trackEvent == null) { MessageBox.Show("Please select the video event on which VEGAS Bezier Masking has been applied.", "No selected event", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { durationTrackEvent = new Tuple <Timecode, Timecode>(trackEvent.Start, trackEvent.End); Effects fxs = trackEvent.Effects; bool bezierWasFound = false; foreach (Effect fx in fxs) { bezierWasFound = fx.PlugIn.UniqueID == "{Svfx:com.sonycreativesoftware:bzmasking}"; if (bezierWasFound) { OFXParameters parameter = fx.OFXEffect.Parameters; foreach (OFXParameter param in parameter) { if (param.Name == "Location_0") { OFXDouble2DParameter locationTracking = (OFXDouble2DParameter)param; locations = new List <OFXDouble2DKeyframe>(locationTracking.Keyframes); break; } } break; } } if (!bezierWasFound) { MessageBox.Show("Please apply VEGAS Bezier Masking to the video event", "VEGAS Bezier Masking not applied", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (locations.Count == 0) { MessageBox.Show("Please add Motion Tracking to the VEGAS Bezier Masking FX", "No tracking data", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { using (OffsetDialog offsetPrompt = new OffsetDialog()) { DialogResult result = offsetPrompt.ShowDialog(); if (result == DialogResult.OK) { VideoTrack titleTrack = myVegas.Project.AddVideoTrack(); PlugInNode textAndTitles = myVegas.Generators.GetChildByUniqueID("{Svfx:com.sonycreativesoftware:titlesandtext}"); // GetChildByName("VEGAS Titles & Text");// Timecode lengthEvent = durationTrackEvent.Item2 - durationTrackEvent.Item1; Media media = new Media(textAndTitles, "Placeholder"); media.Length = lengthEvent; VideoEvent vEvent = titleTrack.AddVideoEvent(durationTrackEvent.Item1, lengthEvent); Take take = new Take(media.Streams[0]); vEvent.Takes.Add(take); Effect fxText = media.Generator; OFXParameters parameter = fxText.OFXEffect.Parameters; foreach (OFXParameter param in parameter) { if (param.Name == "Location") { OFXDouble2DParameter locationText = (OFXDouble2DParameter)param; locationText.Keyframes.Clear(); foreach (OFXDouble2DKeyframe location in locations) { OFXDouble2D tmpValue = location.Value; tmpValue.X += offsetPrompt.X; tmpValue.Y += offsetPrompt.Y; locationText.SetValueAtTime(location.Time, tmpValue); } break; } } } } } }
private string ToCountSqlString() { base.AppendFilter(); string oldOrderValue = this.OrderByValue; string result = null; sql = new StringBuilder(); sql.AppendFormat(SqlTemplate, "Count(*)", GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString); if (IsCount) { return(sql.ToString()); } if (Skip != null && Take == null) { if (this.OrderByValue == "ORDER BY ") { this.OrderByValue += GetSelectValue.Split(',')[0]; } result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, (Skip != null || Take != null) ? null : GetOrderByString, Skip.ObjToInt(), long.MaxValue); } else if (Skip == null && Take != null) { if (this.OrderByValue == "ORDER BY ") { this.OrderByValue += GetSelectValue.Split(',')[0]; } result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, 0, Take.ObjToInt()); } else if (Skip != null && Take != null) { if (this.OrderByValue == "ORDER BY ") { this.OrderByValue += GetSelectValue.Split(',')[0]; } result = string.Format(PageTempalte, GetSelectValue, GetTableNameString, GetWhereValueString, GetGroupByString + HavingInfos, GetOrderByString, Skip.ObjToInt() > 0 ? Skip.ObjToInt() : 0, Take); } else { result = sql.ToString(); } this.OrderByValue = oldOrderValue; return(result); }
public void FromVegas(Vegas vegas) { Project proj = vegas.Project; foreach (Track track in proj.Tracks) { foreach (TrackEvent trackEvent in track.Events) { if (!trackEvent.Selected) { continue; } Take activeTake = trackEvent.ActiveTake; if (null == activeTake) { continue; } Media media = activeTake.Media; if (null == media) { continue; } Timecode eventStart = trackEvent.Start; Timecode eventEnd = eventStart + trackEvent.Length; Timecode takeOffset = activeTake.Offset; Timecode position; foreach (MediaMarker mm in media.Markers) { position = mm.Position + eventStart - takeOffset; if (position < eventStart || position > eventEnd) { continue; } Marker marker = new Marker(position, mm.Label); try { proj.Markers.Add(marker); } catch (Exception e) { AddError(e, mm, position); } } foreach (MediaRegion mr in media.Regions) { position = mr.Position + eventStart - takeOffset; if (position < eventStart || position > eventEnd) { continue; } Region region = new Region(position, mr.Length, mr.Label); try { proj.Regions.Add(region); } catch (Exception e) { AddError(e, mr, position); } } } } if (0 < myErrors.Count) { StringBuilder msg = new StringBuilder(); msg.Append("Some problems occured in promoting the selected media markers to the project level:\r\n"); foreach (String err in myErrors) { msg.Append("\r\n"); msg.Append(err); } MessageBox.Show(msg.ToString()); } }
public _(Take <TResult> parent, IObserver <TResult> observer) : base(parent, observer) { _remaining = Params._count; }
public void setDelegates(CanAccept canAcc, Take take) { _canAccept = canAcc; this.take = take; }
IEnumerator DoConvertTake(AMTakeData oldTake, Take newTake, bool isMeta, string assetPath) { newTake.name = oldTake.name; newTake.frameRate = oldTake.frameRate; newTake.endFramePadding = oldTake.endFramePadding; newTake.numLoop = oldTake.numLoop; newTake.loopMode = oldTake.loopMode; newTake.loopBackToFrame = oldTake.loopBackToFrame; newTake.trackCounter = oldTake.track_count; newTake.groupCounter = oldTake.group_count; //go through groups newTake.rootGroup = new Group(); newTake.rootGroup.group_name = oldTake.rootGroup.group_name; newTake.rootGroup.group_id = oldTake.rootGroup.group_id; newTake.rootGroup.elements = new List <int>(oldTake.rootGroup.elements); newTake.rootGroup.foldout = oldTake.rootGroup.foldout; newTake.groupValues = new List <Group>(); foreach (var oldGroup in oldTake.groupValues) { var newGroup = new Group(); newGroup.group_name = oldGroup.group_name; newGroup.group_id = oldGroup.group_id; newGroup.elements = new List <int>(oldGroup.elements); newGroup.foldout = oldGroup.foldout; newTake.groupValues.Add(newGroup); } //go through tracks newTake.trackValues = new List <Track>(); foreach (var oldTrack in oldTake.trackValues) { AddMessage(" - convert track: " + oldTrack.name); Track newTrack = null; if (oldTrack is AMAnimationTrack) { newTrack = new UnityAnimationTrack(); ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newTrack.keys = new List <Key>(); foreach (AMAnimationKey oldKey in oldTrack.keys) { var newKey = new UnityAnimationKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.wrapMode = oldKey.wrapMode; newKey.amClip = oldKey.amClip; newKey.crossfade = oldKey.crossfade; newKey.crossfadeTime = oldKey.crossfadeTime; newTrack.keys.Add(newKey); } } else if (oldTrack is AMAudioTrack) { newTrack = new AudioTrack(); ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newTrack.keys = new List <Key>(); foreach (AMAudioKey oldKey in oldTrack.keys) { var newKey = new AudioKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.audioClip = oldKey.audioClip; newKey.loop = oldKey.loop; newKey.oneShot = oldKey.oneShot; newTrack.keys.Add(newKey); } } else if (oldTrack is AMCameraSwitcherTrack) { newTrack = new CameraSwitcherTrack(); ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newTrack.keys = new List <Key>(); for (int i = 0; i < oldTrack.keys.Count; i++) { var oldKey = (AMCameraSwitcherKey)oldTrack.keys[i]; var newKey = new CameraSwitcherKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.type = oldKey.type; newKey.typeEnd = oldKey.typeEnd; newKey.color = oldKey.color; newKey.colorEnd = oldKey.colorEnd; newKey.cameraFadeType = oldKey.cameraFadeType; newKey.cameraFadeParameters = new List <float>(oldKey.cameraFadeParameters); newKey.irisShape = oldKey.irisShape; newKey.still = oldKey.still; newKey.endFrame = oldKey.endFrame; if (isMeta) { newKey.SetCameraDirect(null, oldKey.cameraTargetPath); newKey.SetCameraEndDirect(null, oldKey.cameraEndTargetPath); } else { newKey.SetCameraDirect(oldKey.getCamera(null), ""); newKey.SetCameraDirect(oldKey.getCameraEnd(null), ""); } newTrack.keys.Add(newKey); } } else if (oldTrack is AMEventTrack) { var newEventTrack = new EventTrack(); newTrack = newEventTrack; ConvertTrackCommonFields(oldTrack, newTrack, false, isMeta); newTrack.keys = new List <Key>(); string eventCompName = null; //TODO: create new tracks per different components from keys //for now we only allow conversion of one component, so the first key will be used. foreach (AMEventKey oldKey in oldTrack.keys) { string keyCompName = oldKey.getComponentName(); if (string.IsNullOrEmpty(eventCompName)) { if (!string.IsNullOrEmpty(keyCompName)) { eventCompName = keyCompName; AddMessage(" - EventTrack using component: " + eventCompName); if (isMeta) { newEventTrack.SetTargetAsComponentDirect(oldTrack.targetPath, null, eventCompName); } else { newEventTrack.SetTargetAsComponentDirect("", oldKey.getComponentRef(), eventCompName); } } } //only add if component matched if (string.IsNullOrEmpty(eventCompName) || keyCompName != eventCompName) { AddMessage(" - Cannot add EventKey with Component: " + eventCompName, Color.yellow); continue; } var newKey = new EventKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.useSendMessage = oldKey.useSendMessage; newKey.methodName = oldKey.methodName; newKey.parameters = new List <EventParameter>(oldKey.parameters.Count); for (int i = 0; i < oldKey.parameters.Count; i++) { var oldParm = oldKey.parameters[i]; var newParm = new EventParameter(); ConvertEventParameter(oldParm, newParm); newKey.parameters.Add(newParm); } newTrack.keys.Add(newKey); } } else if (oldTrack is AMGOSetActiveTrack) { var oldGOTrack = (AMGOSetActiveTrack)oldTrack; var newGOTrack = new GOSetActiveTrack(); newTrack = newGOTrack; ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newGOTrack.startActive = oldGOTrack.startActive; newTrack.keys = new List <Key>(); foreach (AMGOSetActiveKey oldKey in oldTrack.keys) { var newKey = new GOSetActiveKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.setActive = oldKey.setActive; newKey.endFrame = oldKey.endFrame; newTrack.keys.Add(newKey); } } else if (oldTrack is AMMaterialTrack) { var oldMatTrack = (AMMaterialTrack)oldTrack; var newMatTrack = new MaterialTrack(); newTrack = newMatTrack; ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newMatTrack.materialIndex = oldMatTrack.materialIndex; newMatTrack.property = oldMatTrack.property; newMatTrack.propertyType = (MaterialTrack.ValueType)oldMatTrack.propertyType; newTrack.keys = new List <Key>(); foreach (AMMaterialKey oldKey in oldTrack.keys) { var newKey = new MaterialKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.endFrame = oldKey.endFrame; newKey.texture = oldKey.texture; newKey.vector = oldKey.vector; newTrack.keys.Add(newKey); } } else if (oldTrack is AMOrientationTrack) { newTrack = new OrientationTrack(); ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newTrack.keys = new List <Key>(); foreach (AMOrientationKey oldKey in oldTrack.keys) { var newKey = new OrientationKey(); ConvertKeyCommonFields(oldKey, newKey); if (isMeta) { newKey.SetTargetDirect(null, oldKey.GetTargetPath()); } else { newKey.SetTargetDirect(oldKey.GetTarget(null), ""); } newKey.endFrame = oldKey.endFrame; newTrack.keys.Add(newKey); } } else if (oldTrack is AMPropertyTrack) { var oldPropTrack = (AMPropertyTrack)oldTrack; var newPropTrack = new PropertyTrack(); newTrack = newPropTrack; ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newPropTrack.valueType = (PropertyTrack.ValueType)oldPropTrack.valueType; if (oldPropTrack.isPropertySet()) { Component comp = oldPropTrack.GetTargetComp(null); string compName = oldPropTrack.getComponentName(); bool isField = oldPropTrack.isField; string fieldName = oldPropTrack.getMemberName(); if (isMeta) { newPropTrack.SetTargetCompDirect(null, compName, isField, fieldName); } else { newPropTrack.SetTargetCompDirect(comp, compName, isField, fieldName); } } newTrack.keys = new List <Key>(); foreach (AMPropertyKey oldKey in oldTrack.keys) { var newKey = new PropertyKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.endFrame = oldKey.endFrame; newKey.val = oldKey.val; newKey.valString = oldKey.valString; newKey.valObj = oldKey.valObj; newKey.vect4 = oldKey.vect4; newTrack.keys.Add(newKey); } } else if (oldTrack is AMRotationEulerTrack) { var oldRotEulerTrack = (AMRotationEulerTrack)oldTrack; var newRotEulerTrack = new RotationEulerTrack(); newTrack = newRotEulerTrack; ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newRotEulerTrack.axis = (AxisFlags)oldRotEulerTrack.axis; newTrack.keys = new List <Key>(); foreach (AMRotationEulerKey oldKey in oldTrack.keys) { var newKey = new RotationEulerKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.rotation = oldKey.rotation; newKey.endFrame = oldKey.endFrame; newTrack.keys.Add(newKey); } } else if (oldTrack is AMRotationTrack) { newTrack = new RotationTrack(); ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newTrack.keys = new List <Key>(); foreach (AMRotationKey oldKey in oldTrack.keys) { var newKey = new RotationKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.rotation = oldKey.rotation; newKey.endFrame = oldKey.endFrame; newTrack.keys.Add(newKey); } } else if (oldTrack is AMTranslationTrack) { var oldTransTrack = (AMTranslationTrack)oldTrack; var newTransTrack = new TranslationTrack(); newTrack = newTransTrack; ConvertTrackCommonFields(oldTrack, newTrack, true, isMeta); newTransTrack.pixelPerUnit = oldTransTrack.pixelPerUnit; newTransTrack.pixelSnap = oldTransTrack.pixelSnap; newTrack.keys = new List <Key>(); foreach (AMTranslationKey oldKey in oldTrack.keys) { var newKey = new TranslationKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.position = oldKey.position; newKey.endFrame = oldKey.endFrame; newKey.isConstSpeed = oldKey.isConstSpeed; newKey.path = new Vector3[oldKey.path.Length]; System.Array.Copy(oldKey.path, newKey.path, newKey.path.Length); newTrack.keys.Add(newKey); } } else if (oldTrack is AMTriggerTrack) //convert TriggerTrack to EventTrack with TriggerSignal { var newTriggerTrack = new EventTrack(); newTrack = newTriggerTrack; ConvertTrackCommonFields(oldTrack, newTrack, false, isMeta); //grab/create signal for this trigger string signalPath = GetTriggerSignalPath(assetPath); TriggerSignal triggerSignal; if (!mTriggerSignalLookup.TryGetValue(signalPath, out triggerSignal)) { //try to load it if it exists triggerSignal = AssetDatabase.LoadAssetAtPath <TriggerSignal>(signalPath); if (!triggerSignal) { AddMessage(" - Creating Trigger Signal: " + signalPath); triggerSignal = ScriptableObject.CreateInstance <TriggerSignal>(); AssetDatabase.CreateAsset(triggerSignal, signalPath); AssetDatabase.SaveAssets(); yield return(new WaitForFixedUpdate()); } mTriggerSignalLookup.Add(signalPath, triggerSignal); } newTriggerTrack.SetTargetAsObject(triggerSignal); newTrack.keys = new List <Key>(); foreach (AMTriggerKey oldKey in oldTrack.keys) { var newKey = new EventKey(); ConvertKeyCommonFields(oldKey, newKey); newKey.useSendMessage = false; newKey.methodName = "Invoke"; newKey.parameters = new List <EventParameter>(3); newKey.parameters.Add(new EventParameter() { valueType = EventData.ValueType.String, val_string = oldKey.valueString }); newKey.parameters.Add(new EventParameter() { valueType = EventData.ValueType.Integer, val_int = oldKey.valueInt }); newKey.parameters.Add(new EventParameter() { valueType = EventData.ValueType.Float, val_float = oldKey.valueFloat }); newTrack.keys.Add(newKey); } } newTake.trackValues.Add(newTrack); yield return(new WaitForFixedUpdate()); } }
private void Expand(Take take) { builder.AppendLine().Append("fetch next "); ExpandExpression(new Constant(take.Rows)); // Could be TabularDataSource builder.Append(" rows only"); }
// Start is called before the first frame update void Start() { d_gamescene = GameObject.Find("Canvas").GetComponent <D_GameScene>(); take_tile = GameObject.Find("Canvas").GetComponent <Take>(); }
public static void Main( string[] args ) { // Print Dependencies. //DependenciesDisplayer.PrintDependencies(typeof(TakToBvhBatch).Assembly); string logFilePath = Path.GetFullPath(@".\TakToBvhBatch.log"); using (StreamWriter loger = new StreamWriter(logFilePath)) { int loadingErros = 0; int bvhExportErrors = 0; int videoExportErrors = 0; // Select Directory containing Takes. string takeFileDirectory = SelectTakesRootDirectory(); if (Directory.Exists(takeFileDirectory)) { // Create take processors : to trajectorize, fill gaps, filter. IEnumerable<TakeProcessor> takeProcessors = CreateTakeProcessors(); // Exporters BVHExporter bvhExporter = CreateBVHExporter(); VideoExporter videoExporter = new VideoExporter(); // Process each take. IEnumerable<string> takeFiles = Directory.EnumerateFiles(takeFileDirectory, "*.tak", SearchOption.AllDirectories); foreach (string takeFile in takeFiles) { string takeFileFullPath = Path.GetFullPath(takeFile); Log(loger, string.Format("==> Loading take : {0}", takeFileFullPath)); Take take = null; try { take = new Take(takeFileFullPath); } catch (Exception e) { Log(loger, String.Format("\tError : failed to load take {0}: {1}", takeFileFullPath, e.Message)); ++loadingErros; } if(take != null) { Log(loger, "\t==> Take loaded successfully !"); int bvhExportEr = 0; if (ExportBVHs(take, takeProcessors, bvhExporter, loger, ref bvhExportEr)) { videoExportErrors += ExportVideo(take, videoExporter, loger); } bvhExportErrors += bvhExportEr; // Takes can use a lot of memory. Might not want to wait around for the garbage collector to do its clean up. take.Dispose(); } Log(loger, "\n================================================================================"); } } else { Log(loger, "No Directory selected ! Abort..."); } int totalErrors = loadingErros + bvhExportErrors + videoExportErrors; if (totalErrors > 0) { Log(loger, "==> Batch finished !"); Log(loger, string.Format("{0} Take Load Error(s)", loadingErros)); Log(loger, string.Format("{0} BVH Export Error(s)", bvhExportErrors)); Log(loger, string.Format("{0} Video Export Error(s)", videoExportErrors)); } else { Log(loger, "==> Batch finished with success (no errors) !"); } Console.WriteLine("See {0} for details", logFilePath); Console.WriteLine("\nAppuyer sur Entrée pour quitter..."); Console.ReadLine(); } }
public void VisitTake(Take take) { Console.WriteLine($"take {take.Tuple}"); }
public void FromVegas(Vegas vegas) { // select a midi file MessageBox.Show("请选择一个MIDI文件。"); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "*.mid|*.mid|所有文件|*.*"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { midiName = openFileDialog.FileName; } else { return; } MidiFile midi = new MidiFile(midiName); // generate statistics of each midi track String[] trackInfo = new String[midi.Events.Tracks]; int ticksPerQuarter = midi.DeltaTicksPerQuarterNote; double msPerQuarter = 0; for (int i = 0; i < midi.Events.Tracks; i++) { String info1 = "轨道 " + i.ToString() + ": "; String info2 = ""; int notesCount = 0; String info3 = "起音 "; foreach (MidiEvent midiEvent in midi.Events[i]) { if ((midiEvent is NoteEvent) && !(midiEvent is NoteOnEvent)) { NoteEvent noteEvent = midiEvent as NoteEvent; if (notesCount == 0) { info3 = info3 + noteEvent.NoteName; } notesCount++; } if ((midiEvent is PatchChangeEvent) && info2.Length == 0) { PatchChangeEvent patchEvent = midiEvent as PatchChangeEvent; for (int j = 4; j < patchEvent.ToString().Split(' ').Length; j++) { info2 += patchEvent.ToString().Split(' ')[j]; } } if ((midiEvent is TempoEvent) && msPerQuarter == 0) { TempoEvent tempoEvent = midiEvent as TempoEvent; msPerQuarter = Convert.ToDouble(tempoEvent.MicrosecondsPerQuarterNote) / 1000; } } trackInfo[i] = info1 + info2 + "; 音符数: " + notesCount.ToString() + "; " + info3; } // select a video clip MessageBox.Show("请选择一个视频或图片素材片段。"); openFileDialog.Filter = "所有文件|*.*"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { clipName = openFileDialog.FileName; } else { return; } Media media = new Media(clipName); double mediaLength = media.Length.ToMilliseconds(); // start configuration Form2 configForm = new Form2(); for (int i = 1; i < midi.Events.Tracks; i++) { configForm.comboBox1.Items.Add(trackInfo[i]); } configForm.comboBox1.SelectedIndex = 0; Application.Run(configForm); // apply condiguration for (int i = 1; i < midi.Events.Tracks; i++) { if (trackInfo[i] == configForm.comboBox1.SelectedItem.ToString()) { midiTrack = i; } } sheetWidth = int.Parse(configForm.width); sheetPosition = int.Parse(configForm.position); sheetGap = int.Parse(configForm.gap); if (configForm.comboBox2.Text == "2/4") { sheetTempo = 2; } if (configForm.comboBox2.Text == "3/4") { sheetTempo = 3; } if (configForm.comboBox3.Text == "低音") { sheetCelf = 1; } // start processing MIDI VideoTrack[] noteTracks = new VideoTrack[100]; int trackCount = -1; int trackPointer = 0; double barStartTime = 0; double barLength = msPerQuarter * sheetTempo; foreach (MidiEvent midiEvent in midi.Events[midiTrack]) { if (midiEvent is NoteOnEvent) { NoteEvent noteEvent = midiEvent as NoteEvent; NoteOnEvent noteOnEvent = midiEvent as NoteOnEvent; double startTime = midiEvent.AbsoluteTime * msPerQuarter / ticksPerQuarter; double duration = noteOnEvent.NoteLength * msPerQuarter / ticksPerQuarter; int pitch = noteEvent.NoteNumber; // next page while (startTime >= barStartTime + barLength) { barStartTime = barStartTime + barLength; trackPointer = 0; } // generate video events if (trackPointer > trackCount) { trackCount = trackCount + 1; noteTracks[trackCount] = vegas.Project.AddVideoTrack(); } VideoEvent videoEvent = noteTracks[trackPointer].AddVideoEvent(Timecode.FromMilliseconds(startTime), Timecode.FromMilliseconds(barStartTime + barLength - startTime)); Take take = videoEvent.AddTake(media.GetVideoStreamByIndex(0)); TrackEvent trackEvent = videoEvent as TrackEvent; trackEvent.Loop = true; TrackMotionKeyframe keyFrame = noteTracks[trackPointer].TrackMotion.InsertMotionKeyframe(Timecode.FromMilliseconds(startTime)); keyFrame.Type = VideoKeyframeType.Hold; keyFrame.Width = sheetGap * 2 * vegas.Project.Video.Width / vegas.Project.Video.Height; keyFrame.Height = sheetGap * 2; keyFrame.PositionX = -sheetWidth / 2 + sheetWidth / barLength * (startTime - barStartTime); int octave = pitch / 12; int line = pitchMap[pitch % 12]; keyFrame.PositionY = sheetPosition - sheetGap * 3 + (octave - 5) * sheetGap * 3.5 + line * sheetGap * 0.5 + sheetCelf * 12; trackPointer = trackPointer + 1; } } }
public override Result Process(Take take) { MaxGapFillWidth = (int)(take.FrameRate * 0.05); return base.Process(take); }
public static ProcessResultArray <Clip> ProcessCommand(Command command, Clip[] incomingClips, ClipMetaData targetMetadata) { var clips = new Clip[incomingClips.Length]; for (var i = 0; i < incomingClips.Length; i++) { clips[i] = new Clip(incomingClips[i]); } ProcessResultArray <Clip> resultContainer; switch (command.Id) { case TokenType.Arpeggiate: resultContainer = Arpeggiate.Apply(command, clips); break; case TokenType.Concat: resultContainer = Concat.Apply(clips); break; case TokenType.Crop: resultContainer = Crop.Apply(command, clips); break; case TokenType.Filter: resultContainer = Filter.Apply(command, clips); break; case TokenType.Interleave: resultContainer = Interleave.Apply(command, targetMetadata, clips); break; case TokenType.InterleaveEvent: var(success, msg) = OptionParser.TryParseOptions(command, out InterleaveOptions options); if (!success) { return(new ProcessResultArray <Clip>(msg)); } options.Mode = InterleaveMode.Event; resultContainer = Interleave.Apply(options, targetMetadata, clips); break; case TokenType.Legato: resultContainer = Legato.Apply(clips); break; case TokenType.Mask: resultContainer = Mask.Apply(command, clips); break; case TokenType.Monophonize: resultContainer = Monophonize.Apply(clips); break; case TokenType.Quantize: resultContainer = Quantize.Apply(command, clips); break; case TokenType.Ratchet: resultContainer = Ratchet.Apply(command, clips); break; case TokenType.Relength: resultContainer = Relength.Apply(command, clips); break; case TokenType.Resize: resultContainer = Resize.Apply(command, clips); break; case TokenType.Scale: resultContainer = Scale.Apply(command, clips); break; case TokenType.Scan: resultContainer = Scan.Apply(command, clips); break; case TokenType.SetLength: resultContainer = SetLength.Apply(command, clips); break; case TokenType.SetRhythm: resultContainer = SetRhythm.Apply(command, clips); break; case TokenType.Shuffle: resultContainer = Shuffle.Apply(command, clips); break; case TokenType.Skip: resultContainer = Skip.Apply(command, clips); break; case TokenType.Slice: resultContainer = Slice.Apply(command, clips); break; case TokenType.Take: resultContainer = Take.Apply(command, clips); break; case TokenType.Transpose: resultContainer = Transpose.Apply(command, clips); break; default: return(new ProcessResultArray <Clip>($"Unsupported command {command.Id}")); } return(resultContainer); }
private void end() { switch (action) { case Action.Take: takeState = Take.End; break; case Action.Activate: activateState = Activate.End; break; case Action.Deactivate: deactivateState = Deactivate.End; break; case Action.Release: releaseState = Release.End; break; case Action.Taste: tasteState = Taste.End; break; case Action.Smell: smellState = Smell.End; break; case Action.Move: moveState = Move.End; break; case Action.Rotate: rotateState = Rotate.End; break; case Action.Turn: turnState = Turn.End; break; case Action.HeadFocus: headFocusState = HeadFocus.End; break; case Action.HeadReset: headResetState = HeadReset.End; break; case Action.LookFor: lookForState = LookFor.End; break; case Action.Speak: speakState = Speak.End; break; case Action.Cancel: cancelState = Cancel.End; break; default: break;; } }
private static IEnumerable <GTLocation> ProcessTake(Guid cameraId, Take take, Mat reference) { var media = take.Media.Single(m => m.CameraId == cameraId); var camera = new Capture(media.Url.AbsoluteUri + "full_720p.mp4"); var gtLocations = new List <GTLocation>(); CvInvoke.NamedWindow("Feed"); CvInvoke.NamedWindow("Reference"); CvInvoke.NamedWindow("Delta"); var frame = new Mat(); var resize = new Mat(); var delta = new Mat(); var grey = new Mat(); var blur = new Mat(); var thresh = new Mat(); var dilate = new Mat(); camera.Start(); var frameCount = camera.GetCaptureProperty(CapProp.FrameCount); var fps = camera.GetCaptureProperty(CapProp.Fps); var frameNumber = 0; camera.ImageGrabbed += (sender, eventArgs) => { try { Console.Write($"\r Processing frame: {frameNumber}/{frameCount}"); camera.Retrieve(frame); CvInvoke.Resize(frame, resize, Resolution); CvInvoke.CvtColor(resize, grey, ColorConversion.Bgr2Gray); CvInvoke.GaussianBlur(grey, blur, new Size(21, 21), 0); CvInvoke.AbsDiff(reference, blur, delta); CvInvoke.Threshold(delta, thresh, 25, 255, ThresholdType.Binary); CvInvoke.Rectangle(thresh, new Rectangle(0, 0, Resolution.Width, Resolution.Height - ROI.Height), new MCvScalar(0), -1); CvInvoke.Imshow("Reference", reference); CvInvoke.Dilate(thresh, dilate, null, Point.Empty, 0, BorderType.Default, new MCvScalar()); CvInvoke.Imshow("Delta", dilate); VectorOfVectorOfPoint conts = new VectorOfVectorOfPoint(); CvInvoke.FindContours(dilate, conts, null, RetrType.External, ChainApproxMethod.ChainApproxSimple); for (var i = 0; i < conts.Size; i++) { if (CvInvoke.ContourArea(conts[i]) < MinArea) { continue; } var rect = CvInvoke.BoundingRectangle(conts[i]); CvInvoke.Rectangle(resize, rect, new MCvScalar(0, 255), 2); CvInvoke.Rectangle(resize, ROI, new MCvScalar(255), 2); CvInvoke.Imshow("Reference", resize); var location = new GTLocation { Timestamp = media.StartTime.AddSeconds(frameNumber / fps), Position = new Rect { X = (float)rect.X / frame.Width, Y = (float)rect.Y / frame.Height, Width = (float)rect.Width / frame.Width, Height = (float)rect.Height / frame.Height } }; location.Estimated = location.Position.X + location.Position.Width / 2; gtLocations.Add(location); } } catch (Exception e) { Console.WriteLine($" Unable to process capture: {take.Name} - {e.Message}:{e.StackTrace}"); } frameNumber++; }; while (frameNumber < frameCount) { CvInvoke.WaitKey(100); } camera.Stop(); camera.Dispose(); return(gtLocations); }
public void LoadFromFile() { List <AnnotationText> textAnnotationList = new List <AnnotationText> (); List <AnnotationMark> markAnnotationList = new List <AnnotationMark> (); List <AnnotationInk> inkAnnotationList = new List <AnnotationInk> (); List <AnnotationLink> linkAnnotationList = new List <AnnotationLink>(); if (annotationXmlPath == null) { Debug.Log("ERROR - XML path null"); return; } TextAsset textAsset = new TextAsset(); textAsset = (TextAsset)Resources.Load(annotationXmlPath, typeof(TextAsset)); if (textAsset == null) { if (annotationXmlPath.Contains(".xml")) { Debug.Log("ERROR - the filename can't have extension. Delete .xml from the filename"); } else { Debug.Log("ERROR - There was a problem loading xml file"); } return; } XmlDocument xml = new XmlDocument(); xml.LoadXml(textAsset.text); // Load Take XmlNodeList xmlTakeList = xml.SelectNodes("/annotation_document/session/take"); for (int j = 0; j < xmlTakeList.Count; j++) { XmlNodeList xmlAnnotationSetList = xmlTakeList.Item(j).SelectNodes("annotations/annotation_set"); if (xmlAnnotationSetList.Count == 0) { continue; } take = CreateTake(xmlTakeList.Item(j)); if (take == null) { Debug.Log("ERROR creating class Take"); return; } // Load Annotations //XmlNodeList xmlAnnotationSetList = xml.SelectNodes ("/annotation_document/session/take/annotations/annotation_set"); int nNodes = xmlAnnotationSetList.Count; //Debug.Log ("annotation set count: " + nNodes); for (int i = 0; i < nNodes; i++) { //Debug.Log("annotation set name: " + xmlAnnotationSetList.Item(i).Name); XmlNodeList tmpList = xmlAnnotationSetList.Item(i).SelectNodes("annotation"); //Debug.Log("annotation count: " + tmpList.Count); for (int w = 0; w < tmpList.Count; w++) { XmlNode xmlAnnotation = tmpList.Item(w); // Debug.Log("type = " + xmlAnnotation.Attributes[0].InnerText); switch (xmlAnnotation.Attributes [0].InnerText) { case "text": AnnotationText annotation = CreateAnnotationText(xmlAnnotation); if (annotation == null) { continue; } annotation.Type = "text"; textAnnotationList.Add(annotation); Debug.Log("TEXT annotation"); continue; case "mark": AnnotationMark annotationMark = new AnnotationMark(); annotationMark.Type = "mark"; annotationMark = (AnnotationMark)AddAnnotationCommonFields(xmlAnnotation, annotationMark); markAnnotationList.Add(annotationMark); Debug.Log("MARK annotation"); continue; case "ink": AnnotationInk annotationInk = new AnnotationInk(); annotationInk.Type = "ink"; annotationInk = CreateAnnotationInk(xmlAnnotation); inkAnnotationList.Add(annotationInk); Debug.Log("INK annotation"); continue; case "link": AnnotationLink annotationLink = new AnnotationLink(); annotationLink.Type = "link"; annotationLink = CreateAnnotationLink(xmlAnnotation); linkAnnotationList.Add(annotationLink); Debug.Log("LINK annotation"); continue; case "audio": Debug.Log("Audio annotation"); continue; default: continue; } } } take.TextAnnotationList = textAnnotationList; take.InkAnnotationList = inkAnnotationList; take.MarkAnnotationList = markAnnotationList; take.LinkAnnotationList = linkAnnotationList; Debug.Log("Number of Text Annotation: " + take.TextAnnotationList.Count); Debug.Log("Number of Mark Annotation: " + take.MarkAnnotationList.Count); Debug.Log("Number of Ink Annotation: " + take.InkAnnotationList.Count); Debug.Log("Number of Link Annotation: " + take.LinkAnnotationList.Count); } }
static bool ExportBVHs(Take pTake, IEnumerable<TakeProcessor> pTakeProcessors, BVHExporter pExporter, StreamWriter pLoger, ref int pNbErrors) { pNbErrors = 0; IEnumerable<Node> activeSkels = pTake.Scene.AllSkeletons().Where(skel => skel.Active); if (activeSkels.Count() > 0) { Log(pLoger, "==> Exporting BVH files (1 per skeleton)... !"); // We will export BVHs only if all processors succeed. bool allProcessesSucceeded = true; foreach (TakeProcessor processor in pTakeProcessors) { try { Result processResult = processor.Process(pTake); if (!processResult.Success) { Log(pLoger, String.Format("\tError : process {0} failed : {1}", processor.Name, processResult.Message)); allProcessesSucceeded = false; ++pNbErrors; break; } } catch (Exception e) { Log(pLoger, String.Format("\tError : process {0} failed : {1}", processor.Name, e.Message)); allProcessesSucceeded = false; ++pNbErrors; break; } } if (allProcessesSucceeded) { string takeDir = Path.GetDirectoryName(pTake.FileName); // Exporting all active skeletons to a bvh file. for (int i = 0; i < activeSkels.Count(); ++i) { Node skeleton = activeSkels.ElementAt(i); string bvhFilePath = Path.GetFileNameWithoutExtension(pTake.FileName) + "_" + skeleton.Name + "." + pExporter.Extension; bvhFilePath = Path.GetFullPath(Path.Combine(takeDir, bvhFilePath)); try { pExporter.SkeletonName = skeleton.Name; pExporter.Scale = 1.0f; pExporter.StartFrame = pTake.FullFrameRange.Start; pExporter.EndFrame = pTake.FullFrameRange.End; pExporter.FrameRate = (float)pTake.FrameRate; Result exportResult = pExporter.Export(pTake, bvhFilePath, true); if (exportResult.Success) { Log(pLoger, String.Format("\t==> BVH {0}/{1} exported successfully to file {2}", i+1, activeSkels.Count(), bvhFilePath)); } else { Log(pLoger, String.Format("\tError : cannot export BVH {0}/{1} : {2} => {3}", i+1, activeSkels.Count(), bvhFilePath, exportResult.Message)); ++pNbErrors; } } catch (Exception e) { Log(pLoger, String.Format("\tError : cannot export BVH {0}/{1} : {2} => {3}", i+1, activeSkels.Count(), bvhFilePath, e.Message)); ++pNbErrors; } } } } else { Log(pLoger, "\t==> No active skeleton found !"); return false; } return pNbErrors == 0; }
public void FromVegas(Vegas vegas) { Project proj = vegas.Project; foreach (Track track in proj.Tracks) { foreach (TrackEvent trackEvent in track.Events) { if (!trackEvent.Selected) { continue; } Take activeTake = trackEvent.ActiveTake; if (null == activeTake) { continue; } Media media = activeTake.Media; if (null == media) { continue; } if (IsPairedAudioEvent(trackEvent, media)) { continue; } Timecode eventStart = trackEvent.Start; Timecode eventEnd = eventStart + trackEvent.Length; Timecode takeOffset = activeTake.Offset; Timecode position; foreach (MediaCommandMarker mcm in media.CommandMarkers) { position = mcm.Position + eventStart - takeOffset; if (position < eventStart || position > eventEnd) { continue; } CommandMarker commandmarker = new CommandMarker(position, mcm.CommandType, /*param*/ mcm.CommandParameter, /*comment*/ mcm.Label); try { proj.CommandMarkers.Add(commandmarker); } catch (Exception e) { AddError(e, mcm, position); } } } } if (0 < myErrors.Count) { StringBuilder msg = new StringBuilder(); msg.Append("Some problems occured in promoting the selected media command markers to the project level:\r\n"); foreach (String err in myErrors) { msg.Append("\r\n"); msg.Append(err); } MessageBox.Show(msg.ToString()); } }
static int ExportVideo(Take pTake, VideoExporter pExporter, StreamWriter pLoger) { int nbErrors = 0; Log(pLoger, "==> Exporting video..."); if (pTake.HasData(Take.DataType.Video)) { string takeDir = Path.GetDirectoryName(pTake.FileName); string videoFilePath = Path.GetFileNameWithoutExtension(pTake.FileName) + "." + pExporter.Extension; videoFilePath = Path.GetFullPath(Path.Combine(takeDir, videoFilePath)); try { //pExporter.FrameRate = VideoExporter.FrameRateValue.Quarter; DataStream videoStream = DataStreamWarehouse.OpenFile(videoFilePath, DataStream.StreamOpenMode.WriteOnly, pExporter.IsBinary); // Works since Motive 1.9.x Result exportResult = pExporter.Export(pTake, videoStream); if (exportResult.Success) { Log(pLoger, String.Format("\t==> Video exported successfully to file {0}", videoFilePath)); } else { Log(pLoger, String.Format("\tError : cannot export Video {0} => {1}", videoFilePath, exportResult.Message)); nbErrors = 1; } //videoStream.Dispose(); } catch (Exception e) { Log(pLoger, String.Format("\tError : cannot export Video {0} => {1}", videoFilePath, e.Message)); nbErrors = 1; } } else { Log(pLoger, "\t==> No video found !"); } return nbErrors; }
public void LoadFromFile() { List<AnnotationText> textAnnotationList = new List<AnnotationText> (); List<AnnotationMark> markAnnotationList = new List<AnnotationMark> (); List<AnnotationInk> inkAnnotationList = new List<AnnotationInk> (); List<AnnotationLink> linkAnnotationList = new List<AnnotationLink>(); if (annotationXmlPath == null) { Debug.Log ("ERROR - XML path null"); return; } TextAsset textAsset = new TextAsset(); textAsset = (TextAsset)Resources.Load(annotationXmlPath, typeof(TextAsset)); if (textAsset == null) { if(annotationXmlPath.Contains(".xml")) { Debug.Log ("ERROR - the filename can't have extension. Delete .xml from the filename"); } else { Debug.Log ("ERROR - There was a problem loading xml file"); } return; } XmlDocument xml = new XmlDocument (); xml.LoadXml (textAsset.text); // Load Take XmlNodeList xmlTakeList = xml.SelectNodes ("/annotation_document/session/take"); for (int j = 0; j < xmlTakeList.Count; j++) { XmlNodeList xmlAnnotationSetList = xmlTakeList.Item(j).SelectNodes("annotations/annotation_set"); if(xmlAnnotationSetList.Count == 0) continue; take = CreateTake(xmlTakeList.Item(j)); if(take == null) { Debug.Log("ERROR creating class Take"); return; } // Load Annotations //XmlNodeList xmlAnnotationSetList = xml.SelectNodes ("/annotation_document/session/take/annotations/annotation_set"); int nNodes = xmlAnnotationSetList.Count; //Debug.Log ("annotation set count: " + nNodes); for (int i = 0; i < nNodes; i++) { //Debug.Log("annotation set name: " + xmlAnnotationSetList.Item(i).Name); XmlNodeList tmpList = xmlAnnotationSetList.Item (i).SelectNodes ("annotation"); //Debug.Log("annotation count: " + tmpList.Count); for (int w = 0; w < tmpList.Count; w++) { XmlNode xmlAnnotation = tmpList.Item (w); // Debug.Log("type = " + xmlAnnotation.Attributes[0].InnerText); switch (xmlAnnotation.Attributes [0].InnerText) { case "text": AnnotationText annotation = CreateAnnotationText (xmlAnnotation); if(annotation == null) continue; annotation.Type = "text"; textAnnotationList.Add (annotation); Debug.Log ("TEXT annotation"); continue; case "mark": AnnotationMark annotationMark = new AnnotationMark (); annotationMark.Type = "mark"; annotationMark = (AnnotationMark)AddAnnotationCommonFields (xmlAnnotation, annotationMark); markAnnotationList.Add (annotationMark); Debug.Log ("MARK annotation"); continue; case "ink": AnnotationInk annotationInk = new AnnotationInk (); annotationInk.Type = "ink"; annotationInk = CreateAnnotationInk (xmlAnnotation); inkAnnotationList.Add (annotationInk); Debug.Log ("INK annotation"); continue; case "link": AnnotationLink annotationLink = new AnnotationLink (); annotationLink.Type = "link"; annotationLink = CreateAnnotationLink (xmlAnnotation); linkAnnotationList.Add (annotationLink); Debug.Log ("LINK annotation"); continue; case "audio": Debug.Log ("Audio annotation"); continue; default: continue; } } } take.TextAnnotationList = textAnnotationList; take.InkAnnotationList = inkAnnotationList; take.MarkAnnotationList = markAnnotationList; take.LinkAnnotationList = linkAnnotationList; Debug.Log ("Number of Text Annotation: " + take.TextAnnotationList.Count); Debug.Log ("Number of Mark Annotation: " + take.MarkAnnotationList.Count); Debug.Log ("Number of Ink Annotation: " + take.InkAnnotationList.Count); Debug.Log ("Number of Link Annotation: " + take.LinkAnnotationList.Count); } }
Take GenerateTakeText(Vegas vegas, string text) { if (text.Length == 0) { return(null); } // テキストを順次追加 PlugInNode plugin = vegas.Generators.GetChildByName("VEGAS タイトルおよびテキスト"); // 日本語版だとプラグイン名はこれです。英語版は不明 Media media = new Media(plugin); // これちょっと遅いです if (media.Generator == null) { return(null); } if (!media.Generator.IsOFX) { return(null); } // Text属性を得る。 // 全属性を見たい場合はウォッチのOfxEffect.Parameters.Results Viewを見るとある。(多分21個) OFXEffect ofxEffect = media.Generator.OFXEffect; OFXStringParameter textParam = (OFXStringParameter)ofxEffect.FindParameterByName("Text"); if (textParam == null) { return(null); } // テキストをセット RichTextBox richtextBox1 = new RichTextBox(); richtextBox1.Text = text; richtextBox1.SelectAll(); // 全テキストが対象 richtextBox1.SelectionFont = new System.Drawing.Font(_fontFamily, _fontSize); // フォント変更 //richtextBox.SaveFile(file); // debug. フォントが変わったか確認してみよう // OFXEffectの"Text" Parameterに対して再登録する System.Xml.XmlDocument textValDoc = new System.Xml.XmlDocument(); textValDoc.LoadXml("<OfxParamValue>" + textParam.Value + "</OfxParamValue>"); System.Xml.XmlNode textPValue = textValDoc.FirstChild; textPValue.InnerText = richtextBox1.Rtf; // your new rtf words. textParam.Value = textPValue.InnerText; textParam.ParameterChanged(); // Apply changed. // これらはTextが見つかれば絶対全部見つかるからnullチェックしない OFXRGBAParameter textColorParam = (OFXRGBAParameter)ofxEffect.FindParameterByName("TextColor"); OFXDouble2DParameter locationParam = (OFXDouble2DParameter)ofxEffect.FindParameterByName("Location"); OFXChoiceParameter alignmentParam = (OFXChoiceParameter)ofxEffect.FindParameterByName("Alignment"); OFXDoubleParameter outlineWidthParam = (OFXDoubleParameter)ofxEffect.FindParameterByName("OutlineWidth"); OFXRGBAParameter outlineColorParam = (OFXRGBAParameter)ofxEffect.FindParameterByName("OutlineColor"); OFXBooleanParameter shadowEnableParam = (OFXBooleanParameter)ofxEffect.FindParameterByName("ShadowEnable"); //OFXStringParameter shadowColorParam = (OFXStringParameter)ofxEffect.FindParameterByName("ShadowColor"); // パラメータセット // // TextColor textColorParam.Value = _fontColor;// new OFXColor(50.0f / 255.0, 100.0f / 255.0f, 150.0f / 255.0f); // Alignment // alignmentParam.Choiesを確認すること // OFXChoiceはReadOnly型なのでなにもできません alignmentParam.Value = alignmentParam.Choices[_Align]; //alignmentParam.Choices[7]; //Location OFXDouble2D loc; loc.X = _locationX; loc.Y = _locationY; locationParam.Value = loc; // Outline outlineWidthParam.Value = _outlineWidth; outlineColorParam.Value = _outlineColor;// new OFXColor(10 / 255.0, 10 / 255.0f, 10 / 255.0f); MediaStream stream = media.Streams[0]; //VideoEvent videoEvent = new VideoEvent(Timecode.FromSeconds(_currentTime), Timecode.FromSeconds(_timeLength)); //track.Events.Add(videoEvent); Take take = new Take(stream); //videoEvent.Takes.Add(take); //_currentTime += _timeLength; return(take); }
Take CreateTake(XmlNode xmlTake) { Take take = new Take (); if (xmlTake.Attributes.Count < 2) { Debug.Log ("XML Node TAKE is missing attributes"); return null; } take.Name = xmlTake.Attributes.Item (0).InnerText; take.MultiVideo = Int32.Parse(xmlTake.Attributes.Item (1).InnerText); return take; }
public Talkback(Take <T> take) { _take = take; }
private void changeStatus(int value) { if (commandStatus != CommandStatus.Fail && commandStatus != CommandStatus.Success) { switch (action) { case Action.Take: if (takeState != Take.End) takeState+=value; break; case Action.Activate: if (activateState != Activate.End) activateState += value; break; case Action.Deactivate: if (deactivateState != Deactivate.End) deactivateState += value; break; case Action.Release: if (releaseState != Release.End) releaseState += value; break; case Action.Taste: if (tasteState != Taste.End) tasteState += value; break; case Action.Smell: if (smellState != Smell.End) smellState += value; break; case Action.Move: if (moveState != Move.End) moveState+=value; break; case Action.Rotate: if (rotateState != Rotate.End) rotateState+=value; break; case Action.Turn: if (turnState != Turn.End) turnState+=value; break; case Action.HeadFocus: if (headFocusState != HeadFocus.End) headFocusState+=value; break; case Action.HeadReset: if (headResetState != HeadReset.End) headResetState+=value; break; case Action.LookFor: if (lookForState != LookFor.End) lookForState += value; break; case Action.Speak: if (speakState != Speak.End) speakState += value; break; case Action.Cancel: if (cancelState != Cancel.End) cancelState += value; break; case Action.GetSenses: if (getSensesState != GetSenses.End) getSensesState += value; break; default: break; } commandStatus = CommandStatus.Running; } }
public void SubscriptionStateVisitor_Basics() { var state = new MockOperatorStateContainer(); var writerFactory = state.CreateWriter(); var readerFactory = state.CreateReader(); var xs = new SimpleSubject <int>(); var o = xs.CreateObserver(); var ys = new Take <int>(xs, 5); { var s1 = ys.Subscribe(Observer.Create <int>(_ => { }, _ => { }, () => { })); var v = new SubscriptionInitializeVisitor(s1); v.Subscribe(); v.Start(); o.OnNext(42); o.OnNext(43); var sv = new SubscriptionStateVisitor(s1); Assert.IsTrue(sv.HasStateChanged()); sv.SaveState(writerFactory); Assert.IsTrue(sv.HasStateChanged()); sv.OnStateSaved(); Assert.IsFalse(sv.HasStateChanged()); o.OnNext(44); o.OnNext(45); Assert.IsTrue(sv.HasStateChanged()); } { var done = false; var s2 = ys.Subscribe(Observer.Create <int>(_ => { }, _ => { }, () => { done = true; })); var sv = new SubscriptionStateVisitor(s2); sv.LoadState(readerFactory); var v = new SubscriptionInitializeVisitor(s2); v.Subscribe(); v.Start(); o.OnNext(46); Assert.IsFalse(done); o.OnNext(47); Assert.IsFalse(done); o.OnNext(48); Assert.IsTrue(done); } }
void OnTakeComplete(Animate anim, Take take) { Repaint(); }
private void removeDelegates() { _canAccept = null; take = null; }
public override string ToString() { return ($"{Select?.ToString()} {From?.ToString()} {Where?.ToString()} {GroupBy?.ToString()} {OrderBy?.ToString()} {Skip?.ToString()} {Take?.ToString()}"); }
public void FromVegas(Vegas vegas) { try { int num = 1; //number of the current song track Timecode curr_song_lenght; //the lenght of the current song Timecode start_song_start; //the start of the current song //The track with songs must be the first one AudioTrack track_with_songs = (AudioTrack)vegas.Project.Tracks[0]; //create a new track for the numbers VideoTrack new_track = new VideoTrack(0, "Numerotation"); vegas.Project.Tracks.Add(new_track); foreach (TrackEvent song_event in track_with_songs.Events) { curr_song_lenght = song_event.Length; start_song_start = song_event.Start; //create the video event with the corresponding number of the song VideoEvent new_event = new VideoEvent(start_song_start, curr_song_lenght); PlugInNode plugIn = vegas.Generators.FindChildByUniqueID("{Svfx:com.sonycreativesoftware:titlesandtext}"); Media media = new Media(plugIn); new_track.Events.Add(new_event); MediaStream stream = media.Streams[0]; Take take = new Take(stream); new_event.Takes.Add(take); //Set the text Effect effect = new_event.ActiveTake.Media.Generator; OFXEffect fxo = effect.OFXEffect; OFXStringParameter tparm = (OFXStringParameter)fxo.FindParameterByName("Text"); RichTextBox rtfText = new RichTextBox(); rtfText.Text = num.ToString(); //the text rtfText.SelectAll(); Font font = new Font(Constants.FONT_FAMILY, Constants.TEXT_SIZE, FontStyle.Bold); //font and size rtfText.SelectAll(); rtfText.SelectionColor = Color.Cyan;//Constants.TEXT_COLOR; rtfText.SelectionFont = font; tparm.Value = rtfText.Rtf; fxo.AllParametersChanged(); num++; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private IResponse[] GetAndLock(Take take) { while (true) { int getAndLockRequestNumber = this.client.GetRequestNumber(); int unlockRequestNumber = 0; GetAndLockRequest getAndLockRequest = new GetAndLockRequest( this.client.ViewNumber, this.client.Id, getAndLockRequestNumber, take.Tuple); IResponse[] responses = { }; while (this.client.ViewServers.Length != responses.Length) { int numberOfLockedRequests = this.client.ViewServers.Length; Uri[] servers = this.client.ViewServers; responses = this.messageServiceClient.RequestMulticast( getAndLockRequest, servers, numberOfLockedRequests, Timeout.TIMEOUT_XL_CLIENT, true).ToArray(); if (responses.Length != this.client.ViewServers.Length) { this.client.DoHandShake(); getAndLockRequest.ViewNumber = this.client.ViewNumber; } if (responses.Length == 0) { continue; } // Check if refused // No-one refused if (responses.Length == numberOfLockedRequests) { return(responses); } // Some refused but the majority locked if (responses.Length >= (numberOfLockedRequests / 2) + 1) { continue; } if (this.client.RequestNumber == getAndLockRequestNumber) { unlockRequestNumber = this.client.GetRequestNumber(); } // The majority didn't lock so it's needed to unlock UnlockRequest unlockRequest = new UnlockRequest( this.client.ViewNumber, this.client.Id, unlockRequestNumber); // Unlock this.messageServiceClient.RequestMulticast( unlockRequest, servers, numberOfLockedRequests, -1, false); break; } return(responses); } }
public void deleteSelectedGroup(Take take, bool deleteContents) { take.deleteGroup(selectedGroup, deleteContents); // select root group selectedGroup = 0; }
public class EntryPoint { //The usual stuff for a Vegas script, I'll explain it later (no) public void FromVegas(Vegas myVegas) { PlugInNode pipeffect = myVegas.VideoFX.GetChildByName("VEGAS Picture In Picture"); //Getting the PiP effetc if (pipeffect == null) //if the effect doesn't exists we exit the script with an error message { MessageBox.Show("You don't have the VEGAS Picture In Picture effect. \n Please install it and try again!"); return; } List <VideoEvent> videvents = new List <VideoEvent>(); //A list for the selected events foreach (Track myTrack in myVegas.Project.Tracks) //going through every track and every event, adding the selected video events to the list { foreach (TrackEvent myEvent in myTrack.Events) { if ((myEvent.MediaType == MediaType.Video) && (myEvent.Selected == true)) { videvents.Add((VideoEvent)myEvent); } } } double proWidth = myVegas.Project.Video.Width; //the project's width double proHeight = myVegas.Project.Video.Height; //the project's height VideoMotionBounds newBound; //variable for the crop's size VideoMotionBounds newerBound; //variable for crop size if the first one doesn't fit the whole picture foreach (VideoEvent pipevent in videvents) // for each video event in the list { Take piptake = pipevent.ActiveTake; //getting the width and height of the event's source VideoStream pipstream = piptake.MediaStream as VideoStream; int myWidth = pipstream.Width; //the event's width int myHeight = pipstream.Height; //the event"s height double proAspect = myWidth / (myHeight * (proWidth / proHeight)); //calculating the correct number to multiply later the width/height later VideoMotionKeyframe reframe = new VideoMotionKeyframe(Timecode.FromFrames(0)); //creating a new Pan/Crop keyframe at the beginning of the event pipevent.VideoMotion.Keyframes.Add(reframe); if (myWidth > myHeight) //calculating the size of the pan/crop keyframe with the help of the previously calculated value (proAspect) (EXTREMLY COMPLEX AND DANGEROUS, handle with care) { newBound = new VideoMotionBounds(new VideoMotionVertex((float)(reframe.Center.X - (double)(myWidth / 2)), (float)(reframe.Center.Y - (double)(myHeight / 2) * proAspect)), new VideoMotionVertex((float)(reframe.Center.X + (double)(myWidth / 2)), (float)(reframe.Center.Y - (double)(myHeight / 2) * proAspect)), new VideoMotionVertex((float)(reframe.Center.X + (double)(myWidth / 2)), (float)(reframe.Center.Y + (double)(myHeight / 2) * proAspect)), new VideoMotionVertex((float)(reframe.Center.X - (double)(myWidth / 2)), (float)(reframe.Center.Y + (double)(myHeight / 2) * proAspect))); if (Math.Abs(newBound.TopLeft.Y - newBound.BottomLeft.Y) < myHeight) //if the crop is the correct aspect ration, but it still cuts out part of the image, this code will run and make a cropize, which covers the whole picture with the correct ratio (MORE MATH) { float multiply = myHeight / Math.Abs(newBound.TopLeft.Y - newBound.BottomLeft.Y); float actWidth = Math.Abs(newBound.TopRight.X - newBound.TopLeft.X) / 2; float toHeight = myHeight / 2; newerBound = new VideoMotionBounds(new VideoMotionVertex(reframe.Center.X - actWidth * multiply, reframe.Center.Y - toHeight), new VideoMotionVertex(reframe.Center.X + actWidth * multiply, reframe.Center.Y - toHeight), new VideoMotionVertex(reframe.Center.X + actWidth * multiply, reframe.Center.Y + toHeight), new VideoMotionVertex(reframe.Center.X - actWidth * multiply, reframe.Center.Y + toHeight)); newBound = newerBound; } } else //almost same as above, casual math { newBound = new VideoMotionBounds(new VideoMotionVertex((float)(reframe.Center.X - (double)(myWidth / 2) / proAspect), (float)(reframe.Center.Y - (double)(myHeight / 2))), new VideoMotionVertex((float)(reframe.Center.X + (double)(myWidth / 2) / proAspect), (float)(reframe.Center.Y - (double)(myHeight / 2))), new VideoMotionVertex((float)(reframe.Center.X + (double)(myWidth / 2) / proAspect), (float)(reframe.Center.Y + (double)(myHeight / 2))), new VideoMotionVertex((float)(reframe.Center.X - (double)(myWidth / 2) / proAspect), (float)(reframe.Center.Y + (double)(myHeight / 2)))); if (Math.Abs(newBound.TopRight.X - newBound.TopLeft.X) < myWidth) { float multiply = myHeight / Math.Abs(newBound.TopRight.X - newBound.TopLeft.X); float toWidth = myWidth / 2; float actHeight = Math.Abs(newBound.TopLeft.Y - newBound.BottomLeft.Y / 2); newerBound = new VideoMotionBounds(new VideoMotionVertex(reframe.Center.X - toWidth, reframe.Center.Y - actHeight * multiply), new VideoMotionVertex(reframe.Center.X + toWidth, reframe.Center.Y - actHeight * multiply), new VideoMotionVertex(reframe.Center.X + toWidth, reframe.Center.Y + actHeight * multiply), new VideoMotionVertex(reframe.Center.X - toWidth, reframe.Center.Y + actHeight * multiply)); newBound = newerBound; } } reframe.Bounds = newBound; //setting the keyframe's size pipevent.Effects.AddEffect(pipeffect); //adding the PiP effect to the event } }
/*public Key[] getContextSelectionKeys() { * List<Key> keys = new List<Key>(); * foreach(Key key in getSelectedTrack().keys) { * for(int i=0;i<contextSelection.Count;i+=2) { * // if selection start frame > frame, break out of sorted list * if(contextSelection[i] > key.frame) break; * if(contextSelection[i] <= key.frame && contextSelection[i+1] >= key.frame) keys.Add(key); * } * } * return keys.ToArray(); * }*/ // offset context selection frames by an amount. can be positive or negative //returns keys that are to be deleted public Key[] offsetContextSelectionFramesBy(Take take, ITarget itarget, int offset) { if (offset == 0) { return(new Key[0]); } if (contextSelection.Count <= 0) { return(new Key[0]); } List <Key> rkeys = new List <Key>(); List <Key> keysToDelete = new List <Key>(); foreach (int track_id in contextSelectionTrackIds) { bool shouldUpdateCache = false; Track _track = take.getTrack(track_id); foreach (Key key in _track.keys) { for (int i = 0; i < contextSelection.Count; i += 2) { // move context selection if (contextSelection[i] <= key.frame && contextSelection[i + 1] >= key.frame) { // if there is already a key in the new frame position, mark for deletion bool keyToOverwriteInContextSelection = false; if (_track.hasKeyOnFrame(key.frame + offset)) { // check if the key is in the selection for (int j = 0; j < contextSelection.Count; j += 2) { if (contextSelection[j] <= (key.frame + offset) && contextSelection[j + 1] >= (key.frame + offset)) { keyToOverwriteInContextSelection = true; break; } } // if not key is not in selection, mark for deletion if (!keyToOverwriteInContextSelection) { keysToDelete.Add(_track.getKeyOnFrame(key.frame + offset)); } } key.frame += offset; if (!shouldUpdateCache) { shouldUpdateCache = true; } break; } } } // delete keys that were overwritten foreach (Key key in keysToDelete) { _track.keys.Remove(key); rkeys.Add(key); } keysToDelete.Clear(); // update cache if (shouldUpdateCache) { _track.updateCache(itarget); } } // update context selection for (int i = 0; i < contextSelection.Count; i++) { // move context selection contextSelection[i] += offset; } // clear ghost selection ghostSelection = new List <int>(); return(rkeys.ToArray()); }
/// <summary> /// This will only duplicate the tracks and groups, includeKeys=true to also duplicate keys /// </summary> /// <param name="take"></param> public void DuplicateTake(Take dupTake, bool includeKeys) { Take a = new Take(); a.name = dupTake.name; MakeTakeNameUnique(a); a.numLoop = dupTake.numLoop; a.loopMode = dupTake.loopMode; a.frameRate = dupTake.frameRate; a.endFramePadding = dupTake.endFramePadding; //a.lsTracks = new List<Track>(); //a.dictTracks = new Dictionary<int,Track>(); if (dupTake.rootGroup != null) { a.rootGroup = dupTake.rootGroup.duplicate(); } else { a.initGroups(); } a.groupCounter = dupTake.groupCounter; if (dupTake.groupValues != null) { a.groupValues = new List <Group>(); foreach (var grp in dupTake.groupValues) { a.groupValues.Add(grp.duplicate()); } } a.trackCounter = dupTake.trackCounter; a.trackValues = new List <Track>(); foreach (var track in dupTake.trackValues) { var dupTrack = SerializeData.CreateTrack(track.serializeType); track.CopyTo(dupTrack); a.trackValues.Add(dupTrack); dupTrack.maintainTrack(mDataTarget); Object tgtObj = dupTrack.GetTarget(mDataTarget); //if there's no target, then we can't add the keys for events and properties if (includeKeys && !(tgtObj == null && (dupTrack is PropertyTrack || dupTrack is EventTrack))) { foreach (var key in track.keys) { var dupKey = SerializeData.CreateKey(key.serializeType); if (dupKey != null) { key.CopyTo(dupKey); dupKey.maintainKey(mDataTarget, tgtObj); dupTrack.keys.Add(dupKey); } } dupTrack.updateCache(mDataTarget); } } takes.Add(a); }