private void RenderMapMatrix(LipSyncMapData mapData, PhonemeType phoneme) { SetupPictureEffect(); if (LipSyncMode == LipSyncMode.MarkCollection) { TimeSpan lastMarkTime = StartTime; foreach (var mark in _marks) { if (!AllowMarkGaps) { var gapDuration = mark.StartTime - lastMarkTime; if (gapDuration.TotalMilliseconds > 10) { //Fill the gap with a rest var restImage = mapData.ImageForPhoneme("REST"); if (restImage != null) { _thePic.StartTime = mark.StartTime - StartTime - gapDuration; _thePic.Image = restImage; _thePic.TimeSpan = gapDuration; _thePic.MarkDirty(); var result = _thePic.Render(); result.OffsetAllCommandsByTime(lastMarkTime - StartTime); _elementData.Add(result); } } lastMarkTime = mark.EndTime; } var image = mapData.ImageForPhoneme(mark.Text); if (image != null) { _thePic.StartTime = mark.StartTime - StartTime; _thePic.Image = image; _thePic.TimeSpan = mark.Duration; _thePic.MarkDirty(); var result = _thePic.Render(); result.OffsetAllCommandsByTime(mark.StartTime - StartTime); _elementData.Add(result); } } if (!AllowMarkGaps) { _thePic.StartTime = lastMarkTime - StartTime; var gapDuration = StartTime + TimeSpan - lastMarkTime; if (gapDuration.TotalMilliseconds > 10) { //Fill the gap with a rest var restImage = mapData.ImageForPhoneme("REST"); if (restImage != null) { _thePic.Image = restImage; _thePic.TimeSpan = gapDuration; _thePic.MarkDirty(); var result = _thePic.Render(); result.OffsetAllCommandsByTime(lastMarkTime - StartTime); _elementData.Add(result); } } } } else { var image = mapData.ImageForPhoneme(phoneme); if (image != null) { _thePic.Image = image; _thePic.TimeSpan = TimeSpan; _thePic.MarkDirty(); var result = _thePic.Render(); _elementData.Add(result); } } TearDownPictureEffect(); }
// renders the given node to the internal ElementData dictionary. If the given node is // not a element, will recursively descend until we render its elements. private void RenderNodes() { EffectIntents result; LipSyncMapData mapData = null; List <ElementNode> renderNodes = TargetNodes.SelectMany(x => x.GetNodeEnumerator()).ToList(); if (LipSyncMode == LipSyncMode.MarkCollection) { SetupMarks(); } if (_data.PhonemeMapping != null) { if (!_library.Library.ContainsKey(_data.PhonemeMapping)) { _data.PhonemeMapping = _library.DefaultMappingName; } PhonemeType phoneme = _data.StaticPhoneme; if (_library.Library.TryGetValue(_data.PhonemeMapping, out mapData)) { if (mapData.IsMatrix) { SetupPictureEffect(); if (LipSyncMode == LipSyncMode.MarkCollection) { foreach (var mark in _marks) { var file = mapData.PictureFileName(mark.Text.ToUpper()); _thePic.Image = LoadImage(file); _thePic.TimeSpan = mark.Duration; _thePic.MarkDirty(); result = _thePic.Render(); result.OffsetAllCommandsByTime(mark.StartTime - StartTime); _elementData.Add(result); //} } } else { var file = mapData.PictureFileName(phoneme); if (File.Exists(file)) { _thePic.Image = LoadImage(file); result = _thePic.Render(); _elementData.Add(result); } } if (null != _thePic) { result = _thePic.Render(); _elementData.Add(result); } } else { renderNodes.ForEach(delegate(ElementNode element) { LipSyncMapItem item = mapData.FindMapItem(element.Name); if (item != null) { if (LipSyncMode == LipSyncMode.MarkCollection && _marks != null) { foreach (var mark in _marks) { if (mapData.PhonemeState(element.Name, mark.Text.ToUpper(), item)) { var colorVal = mapData.ConfiguredColorAndIntensity(element.Name, mark.Text.ToUpper(), item); result = CreateIntentsForPhoneme(element, colorVal.Item1, colorVal.Item2, mark.Duration); result.OffsetAllCommandsByTime(mark.StartTime - StartTime); _elementData.Add(result); } } } else { if (mapData.PhonemeState(element.Name, phoneme.ToString(), item)) { var colorVal = mapData.ConfiguredColorAndIntensity(element.Name, phoneme.ToString(), item); result = CreateIntentsForPhoneme(element, colorVal.Item1, colorVal.Item2, TimeSpan); _elementData.Add(result); } } } }); TearDownPictureEffect(); } } } }