サンプルコード
の編集
http://nive.jp/NiVE2/index.php?%A5%B5%A5%F3%A5%D7%A5%EB%A5%B3%A1%BC%A5%C9
[
トップ
] [
編集
|
差分
|
バックアップ
|
添付
|
リロード
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
-- 雛形とするページ --
BracketName
FAQ
FormattingRules
FrontPage
Help
IRC
InterWiki
InterWikiName
InterWikiSandBox
MenuBar
NiVE2 Wiki
NiVEについて
PHP
PukiWiki
PukiWiki/1.4
PukiWiki/1.4/Manual
PukiWiki/1.4/Manual/Plugin
PukiWiki/1.4/Manual/Plugin/A-D
PukiWiki/1.4/Manual/Plugin/E-G
PukiWiki/1.4/Manual/Plugin/H-K
PukiWiki/1.4/Manual/Plugin/L-N
PukiWiki/1.4/Manual/Plugin/O-R
PukiWiki/1.4/Manual/Plugin/S-U
PukiWiki/1.4/Manual/Plugin/V-Z
RecentDeleted
SandBox
WikiEngines
WikiName
WikiWikiWeb
サンプルコード
バグ報告
プラグイン
プラグイン/コメント
プラグイン/バグ報告
質問箱
目安箱
* サンプルコード [#nf978271] > エクスプレッション、オートメーションのサンプルコードを投稿するページです。 > ''投稿者の方へ''&br; 投稿時は、下記の書式に従って記述して下さい。&br; ~#code(言語名){{ ~//ここにコードを記述 ~}} &br; 言語名に関しては、オートメーション、エクスプレッションはcsharp、プロパティスクリプトはpropertyscriptとしてください。 &br;&br; また、長いコードは&br; ~#code(言語名, コード) &br;&br; の様に言語名の後に適当な名前を指定するとコードを折りたたむことが出来ます。&br; &br; ※投稿時にはコード種別(オートメーションなのかエクスプレッションなのか、プロパティスクリプトなのか)を明示するようにして下さい。&br; ※オートメーションの場合は「保存」でテキスト形式で保存し、そのテキストファイルの内容をそのまま貼り付けて下さい。&br; ※エクスプレッションの場合は「エクスプレッションの保存」でテキスト形式で保存し、そのテキストファイルの内容をそのまま貼り付けて下さい。&br; > ''投稿されたコードを使用しようと考えている方へ''&br; エクスプレッション、オートメーションは、ある程度NiVEの操作に慣れている方用の機能です。&br; これらの使用方法については、付属の「エクスプレッション・オートメーションについて.pdf」をご覧下さい。&br; &br; ※オートメーションの場合は、コードをメモ帳にコピーして、文字コードを「UTF-8」にして保存し、&br; オートメーションの「読み込み」からそのテキストファイルを開き、実行します。&br; ※エクスプレッションの場合は、コードをメモ帳にコピーして、文字コードを「UTF-8」にして保存し、&br; 「エクスプレッションの読み込み」からそのテキストファイルを開き、実行します。&br; &br; また、質問に関しては、言語に関する質問や、コードの書き方等、投稿されたコードに関係ない質問はご遠慮下さい。&br; &br; // #comment_kcaptcha **円エフェクトの半径と不透明度をランダムに > (2011-03-12 (土) 16:04:56)~ ~ ディスプレイスメントマップを使って波紋を作っているんですが、マップで波紋のように変形させるため円エフェクトを使っています。~ 半径を0から300、それに合わせて不透明度を100から0を2秒で行うようにに設定しています。~ それを何個か並べているのですが動きがみな同じなため、機械的な波紋に見えてしまいます。エクスプレッションで半径と不透明度をランダムに設定することはできないのでしょうか?~ ~ プロジェクトファイルを上げました。~ http://u9.getuploader.com/nicoAE/download/522/%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E7%AD%89.zip~ よろしくお願いします。~ ~ // #comment_kcaptcha **プロパティスクリプト投稿テスト >[[うp主]] (2011-02-21 (月) 18:40:24)~ ~ プロパティスクリプトのサンプルのテスト。~ 開始や終了を1フレームごとに1文字分変化させるのに便利な感じのスクリプト。~ ~ #code(propertyscript){{ return 100.0 / strLen(replace(getProperty("ソーステキスト"), "\r\n", "")) * timeToFrames(time); }} ~ // #comment_kcaptcha **レンダラの選択サンプル [#s0a7822b] >[[うp主]] (2011-02-09 (水) 14:36:03)~ ~ オートメーションでのレンダラの選択について質問があったので、適当ですがやってみました。~ ~ #code(csharp,rendererSelectSample){{ [MainCode] using (RendererSelectWindow window = new RendererSelectWindow(manager)) { if (window.ShowDialog() == DialogResult.OK) { manager.NewComposition("", new CompositionSetting(window.SelectedRendererName, window.SelectedRenderer, new Size(640, 480), 30.0, 10.0, 180.0, -90.0, 16)); } } [MethodCode] class RendererSelectWindow : Form { public RendererSelectWindow(IAutomationManager manager) { InitializeComponent(); //プラグイン名取得 renderer = new Dictionary<string, string>(); foreach (KeyValuePair<string, Type> plugin in manager.GetAllRendererPlugin()) { using (RendererBase r = (RendererBase)Activator.CreateInstance(plugin.Value)) { renderer.Add(r.PluginName, plugin.Key); rendererComboBox.Items.Add(r.PluginName); } } rendererComboBox.SelectedIndex = 0; } Dictionary<string, string> renderer = null; ComboBox rendererComboBox = null; public string SelectedRenderer { get { return renderer[(string)rendererComboBox.SelectedItem]; } } public string SelectedRendererName { get { return (string)rendererComboBox.SelectedItem; } } void InitializeComponent() { Label label = new Label(); label.Text = "レンダラ:"; label.Location = new Point(12, 15); label.AutoSize = true; Button okButton = new Button(); okButton.Location = new Point(12, 42); okButton.Text = "OK"; okButton.DialogResult = DialogResult.OK; Button cancelButton = new Button(); cancelButton.Location = new Point(91, 42); cancelButton.Text = "キャンセル"; cancelButton.DialogResult = DialogResult.Cancel; rendererComboBox = new ComboBox(); rendererComboBox.Location = new Point(58, 12); rendererComboBox.Width = 150; rendererComboBox.DropDownStyle = ComboBoxStyle.DropDownList; this.ClientSize = new Size(220, 75); this.MaximizeBox = false; this.MinimizeBox = false; this.ShowIcon = false; this.ShowInTaskbar = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.StartPosition = FormStartPosition.CenterParent; this.Text = "レンダラの選択"; this.Controls.Add(label); this.Controls.Add(rendererComboBox); this.Controls.Add(okButton); this.Controls.Add(cancelButton); } } [UsingNamespace] [Reference] }} ~ // #comment_kcaptcha **投稿方法について [#e20ffa78] >[[金の髭]] (2010-12-26 (日) 21:05:58)~ ~ Wikiそのものの質問になってしまって恐縮なのですが・・・。~ 質問1.試しに以下の例のように記述して投稿してみたところ、他の記事も含めて全体が折りたたまれてしまいました。~ 投稿時はcode(csharp)だけで投稿し、regionは投稿後ページ編集で付け足す必要があるのでしょうか?~ (下の例では行頭の#は省略しています)~ 質問2.regionが使われるたびに、その後の記事のインデントがずれていっているようですがこれは仕様になりますでしょうか。~ ~ ↓投稿例~ ~ region(←コードはこちら)~ ~ code(csharp){{~ ~ int a=0;~ ~ }}~ ~ endregion~ ~ // - 確認しました。どうやら、&nop(#endregion);の後に&nop(~);が入ることによって、影響範囲がおかしくなってしまうようです。また、インデントについては&nop(#region);の次の行に&nop(~);を入れると解消されるようです。いずれも修正できる場合は修正しておきます。 -- [[うp主]] &new{2010-12-29 (水) 19:15:22}; - と思ったら、どうやら&nop(~);を挟んでもインデントは解除されないようです orz &nop(#region)自体が結構裏技的なことをやっているそうなので、この問題の解決は難しいかもしれません。 -- [[うp主]] &new{2010-12-29 (水) 20:12:07}; - codeプラグインの方に手を加えてregionプラグインを使用せずに折りたためるようにしてみました。これで多分インデントの問題も解決できるかと思うので、そちらを試してみてください。 -- [[うp主]] &new{2010-12-30 (木) 01:12:24}; - 上の例でうまくいくことを確認しました。対応ありがとうございます。色々すみません。 -- [[金の髭]] &new{2010-12-31 (金) 23:36:29}; #comment_kcaptcha **ウィグル適用ウインドウ [#gbad8610] >[[うp主]] (2010-12-12 (日) 13:17:57)~ ~ 指定したプロパティにウィグルを適用し、キーフレームを設定します。~ ~ 使い方:~ 各コンボボックスから適用したいものを選択します。~ 間隔、複雑度、強さ、開始時間、終了時間を入力し、適用を押します。~ ~ パラメータの説明:~ 対象 : プロパティを所持するエフェクト、またはレイヤープロパティを指定します~ 次元 : 値を適用する次元(軸)を選択します。~ 間隔 : 1秒間にキーフレームをいくつ置くかを設定します。~ 複雑度 : 振動の激しさを設定します。~ 強さ : 値の変化の度合いを設定します。~ 開始時間: キーフレームの設置を開始する時間をレイヤーのローカル時間で設定します。~ 終了時間: キーフレームの設置を終了する時間をレイヤーのローカル時間で設定します。~ 適用 : 設定を元にキーフレームを設定します。~ 閉じる : ウインドウを閉じます。~ コンポジション更新: コンポジションの情報を更新します。~ これ以外のコンボボックス: 見たままなので略。~ ~ 以下コード。長め注意~ ~ #code(csharp, コード){{ [MainCode] WiggleSettingWindow window = new WiggleSettingWindow(manager); window.Show(); [MethodCode] //ウィグル用メソッドのデリゲート delegate PropertyBase WiggleMethod(PropertyBase property, float x, int oct, double amp, int dimension); //各プロパティで対応する次元とウィグル用メソッドを格納するクラス class PropertyData { public PropertyData(string[] dim, WiggleMethod method, PropertyInterpolationType type) { Type = type; DimensionName = dim; WiggleMethod = method; } public PropertyInterpolationType Type = default(PropertyInterpolationType); public string[] DimensionName = null; public WiggleMethod WiggleMethod = null; } class WiggleSettingWindow : Form { public WiggleSettingWindow(IAutomationManager manager) { //対応する型を設定する propertyData = new Dictionary<Type, PropertyData>(); propertyData.Add(typeof(NumberProperty), new PropertyData(new string[] { "なし" }, WiggleNumberProperty, PropertyInterpolationType.Fixed | PropertyInterpolationType.Liner | PropertyInterpolationType.CatmullRom)); propertyData.Add(typeof(RadianProperty), new PropertyData(new string[] { "なし" }, WiggleRadianProperty, PropertyInterpolationType.Fixed | PropertyInterpolationType.Liner | PropertyInterpolationType.CatmullRom)); propertyData.Add(typeof(VertexProperty), new PropertyData(new string[] { "X", "Y", "Z", "各軸個別", "各軸同一" }, WiggleVertexProperty, PropertyInterpolationType.Fixed | PropertyInterpolationType.Liner | PropertyInterpolationType.CatmullRom)); //対応する型を増やす場合はここ以下に記述する //書式: //propertyData.Add(typeof(対応する型), new PropertyData(new string[] { 対応する次元 }, ウィグル用メソッド, 対応する補間タイプ)); //例: //propertyData.Add(typeof(ColorProperty), new PropertyData(new string[] { "R", "G", "B", "A", "RGB同一", "RGBA同一" }, WiggleColorProperty, PropertyInterpolationType.Fixed | PropertyInterpolationType.Liner | PropertyInterpolationType.CatmullRom)); InitializeComponent(); m = manager; //ランダムシードはここで変更する seed = this.GetHashCode(); RefreshComposition(); } //各種コントロール ComboBox compositionComboBox = null; ComboBox layerComboBox = null; ComboBox targetComboBox = null; ComboBox propertyComboBox = null; ComboBox dimensionComboBox = null; ComboBox interpolationComboBox = null; TextBox keyframeTextBox = null; TextBox octTextBox = null; TextBox ampTextBox = null; TextBox startTimeTextBox = null; TextBox endTimeTextBox = null; Button applyButton = null; //オートメーションマネージャ IAutomationManager m = null; //コンポジション IComposition[] composition = null; //レイヤー ILayer[] layer = null; //エフェクト IEffect[] effect = null; //プロパティの名前 string[] propertyName = null; //プロパティの型 Dictionary<string, Type> propertyType = null; //各プロパティの設定 Dictionary<Type, PropertyData> propertyData = null; //複雑度 int octave = 6; //ランダムシード int seed = 0; //コンボボックスの"なし"のインデックス用パディング const int itemPadding = 1; //上の定数のエフェクト用 const int effectPadding = 2; //コンポジションの更新 void RefreshComposition() { composition = m.GetComposition(); layer = null; compositionComboBox.Items.Clear(); compositionComboBox.Items.Add("なし"); for (int i = 0; i < composition.Length; i++) { compositionComboBox.Items.Add(composition[i].Setting.Name); } compositionComboBox.SelectedIndex = 0; } //NumberProperty用ウィグルメソッド PropertyBase WiggleNumberProperty(PropertyBase property, float x, int oct, double amp, int dimension) { NumberProperty np = (NumberProperty)property; np.DoubleValue = ExpressionUtils.Wiggle(seed, x, oct, np.DoubleValue, amp); return property; } //RadianProperty用ウィグルメソッド PropertyBase WiggleRadianProperty(PropertyBase property, float x, int oct, double amp, int dimension) { RadianProperty rp = (RadianProperty)property; return new RadianProperty(rp.PropertyName, 0, ExpressionUtils.Wiggle(seed, x, oct, rp.ToAngle(), amp)); return property; } //VertexProperty用ウィグルメソッド //次元についてはコンストラクタ、またはメソッド内で使用しているプロパティを参照のこと PropertyBase WiggleVertexProperty(PropertyBase property, float x, int oct, double amp, int dimension) { VertexProperty vp = (VertexProperty)property; switch(dimension) { case 0: { vp.X = ExpressionUtils.Wiggle(seed, x, oct, vp.X, amp); break; } case 1: { vp.Y = ExpressionUtils.Wiggle(seed, x, oct, vp.Y, amp); break; } case 2: { vp.Z = ExpressionUtils.Wiggle(seed, x, oct, vp.Z, amp); break; } case 3: { vp.VertexValue = ExpressionUtils.Wiggle(seed, x, oct, vp.VertexValue, new Vertex(amp, amp, amp)); break; } case 4: { double w = ExpressionUtils.Wiggle(seed, x, oct, 0.0, amp); vp.X += w; vp.Y += w; vp.Z += w; break; } } return property; } //対応する型のウィグル用メソッドを追加する。書式はWiggleMethodデリゲートに従う。 //例: //PropertyBase WiggleColorProperty(PropertyBase property, float x, int oct, double amp, int dimension) //{ // ColorProperty cp = (ColorProperty)property; // switch(dimension) // { // case 0: // { // cp.R = (byte)Math.Min(Math.Max(ExpressionUtils.Wiggle(seed, x, oct, cp.R, amp), 0.0), 255.0); // break; // } // case 1: // { // cp.G = (byte)Math.Min(Math.Max(ExpressionUtils.Wiggle(seed, x, oct, cp.G, amp), 0.0), 255.0); // break; // } // case 2: // { // cp.B = (byte)Math.Min(Math.Max(ExpressionUtils.Wiggle(seed, x, oct, cp.B, amp), 0.0), 255.0); // break; // } // case 3: // { // cp.A = (byte)Math.Min(Math.Max(ExpressionUtils.Wiggle(seed, x, oct, cp.A, amp), 0.0), 255.0); // break; // } // case 4: // { // double w = ExpressionUtils.Wiggle(seed, x, oct, 0.0, amp); // cp.R = (byte)Math.Min(Math.Max(cp.R + w, 0.0), 255.0); // cp.G = (byte)Math.Min(Math.Max(cp.G + w, 0.0), 255.0); // cp.B = (byte)Math.Min(Math.Max(cp.B + w, 0.0), 255.0); // break; // } // case 5: // { // double w = ExpressionUtils.Wiggle(seed, x, oct, 0.0, amp); // cp.R = (byte)Math.Min(Math.Max(cp.R + w, 0.0), 255.0); // cp.G = (byte)Math.Min(Math.Max(cp.G + w, 0.0), 255.0); // cp.B = (byte)Math.Min(Math.Max(cp.B + w, 0.0), 255.0); // cp.A = (byte)Math.Min(Math.Max(cp.A + w, 0.0), 255.0); // break; // } // } // // return property; //} //キーフレームを設定する void SetWiggle(int keyframeRate, int oct, double amp, double startTime, double endTime, int dimension, PropertyInterpolationType type, WiggleMethod wiggle, ILayer targetLayer, IEffect targetEffect, Func<double, PropertyBase> propertyGetter) { double rate = 1.0 / (double)keyframeRate; int count = (int)((endTime - startTime) / rate); float addx = 360.0F / (float)count; if (count > 0) { //一度キーフレームを全て作成してから追加する KeyFrame[] keyFrame = new KeyFrame[count]; for (int i = 0; i < count; i++) { double time = Math.Round(startTime + rate * i, ReferenceData.MinimumTimeDigit, MidpointRounding.ToEven); keyFrame[i] = new KeyFrame(time, wiggle(propertyGetter(time), addx * i, oct, amp, dimension), type); } //対象が入力・レイヤープロパティの場合はtargetEffectはnull if (targetEffect != null) { for (int i = 0; i < count; i++) { m.AddKeyFrame(targetEffect, keyFrame[i]); } } else { for (int i = 0; i < count; i++) { m.AddKeyFrame(targetLayer, keyFrame[i]); } } } } //コンポジション選択時のイベント void compositionComboBox_SelectedIndexChanged(object sender, EventArgs e) { layer = null; layerComboBox.Items.Clear(); layerComboBox.Items.Add("なし"); try { if (compositionComboBox.SelectedIndex > 0) { //レイヤーを取得 layer = composition[compositionComboBox.SelectedIndex - itemPadding].GetLayer(); for (int i = 0; i < layer.Length; i++) { layerComboBox.Items.Add(layer[i].ItemName); } } } catch { } layerComboBox.SelectedIndex = 0; } //レイヤー選択時のイベント void layerComboBox_SelectedIndexChanged(object sender, EventArgs e) { effect = null; targetComboBox.Items.Clear(); targetComboBox.Items.Add("なし"); if (layer != null && layerComboBox.SelectedIndex > 0) { targetComboBox.Items.Add("レイヤー"); //エフェクトを取得 effect = layer[layerComboBox.SelectedIndex - itemPadding].GetEffect(); for (int i = 0; i < effect.Length; i++) { targetComboBox.Items.Add(effect[i].ItemName); } } targetComboBox.SelectedIndex = 0; } //対象選択時のイベント void targetComboBox_SelectedIndexChanged(object sender, EventArgs e) { propertyName = null; propertyType = new Dictionary<string, Type>(); propertyComboBox.Items.Clear(); propertyComboBox.Items.Add("なし"); if (targetComboBox.SelectedIndex > 0) { //"レイヤー"の場合は入力・レイヤープロパティを対象とする if (targetComboBox.SelectedIndex > 1) { //対象のエフェクト IEffect se = effect[targetComboBox.SelectedIndex - effectPadding]; propertyName = m.GetPropertyNames(se); for (int i = 0; i < propertyName.Length; i++) { PropertyBase p = m.GetProperty(se, propertyName[i], 0.0); //ウィグルに対応するプロパティのみを表示 if (p != null && propertyData.ContainsKey(p.GetType())) { propertyType.Add(propertyName[i], p.GetType()); } } } else { //対象のレイヤー ILayer sl = layer[layerComboBox.SelectedIndex - itemPadding]; propertyName = m.GetPropertyNames(sl); for (int i = 0; i < propertyName.Length; i++) { PropertyBase p = m.GetProperty(sl, propertyName[i], 0.0); //ウィグルに対応するプロパティのみを表示 if (p != null && propertyData.ContainsKey(p.GetType())) { propertyType.Add(propertyName[i], p.GetType()); } } } //対応するプロパティの名前をコンボボックスに追加 propertyName = new string[propertyType.Count]; propertyType.Keys.CopyTo(propertyName, 0); propertyComboBox.Items.AddRange(propertyName); } propertyComboBox.SelectedIndex = 0; } //プロパティ選択時のイベント void propertyComboBox_SelectedIndexChanged(object sender, EventArgs e) { dimensionComboBox.Items.Clear(); interpolationComboBox.Items.Clear(); //対応する次元と補間タイプを表示 if (propertyComboBox.SelectedIndex > 0) { PropertyData sp = propertyData[propertyType[propertyName[propertyComboBox.SelectedIndex - 1]]]; dimensionComboBox.Items.AddRange(sp.DimensionName); if ((sp.Type & PropertyInterpolationType.Fixed) != 0) { interpolationComboBox.Items.Add(PropertyInterpolationType.Fixed); } if ((sp.Type & PropertyInterpolationType.Liner) != 0) { interpolationComboBox.Items.Add(PropertyInterpolationType.Liner); } if ((sp.Type & PropertyInterpolationType.CatmullRom) != 0) { interpolationComboBox.Items.Add(PropertyInterpolationType.CatmullRom); } } else { dimensionComboBox.Items.Add("なし"); interpolationComboBox.Items.Add("なし"); } dimensionComboBox.SelectedIndex = 0; interpolationComboBox.SelectedIndex = 0; } //適用ボタン押下時のイベント void applyButton_Click(object sentder, EventArgs e) { try { if (propertyComboBox.SelectedIndex > 0) { int keyframeRate = 0; int oct = 0; double amp = 0.0; double startTime = 0.0; double endTime = 0.0; ILayer tl = null; IEffect te = null; Func<double, PropertyBase> propertyGetter = null; if (!int.TryParse(keyframeTextBox.Text, out keyframeRate)) { MessageBox.Show("間隔の値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!int.TryParse(octTextBox.Text, out oct)) { MessageBox.Show("複雑度の値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!double.TryParse(ampTextBox.Text, out amp)) { MessageBox.Show("強さの値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!double.TryParse(startTimeTextBox.Text, out startTime)) { MessageBox.Show("開始時間の値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!double.TryParse(endTimeTextBox.Text, out endTime)) { MessageBox.Show("終了時間の値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (keyframeRate < 1) { MessageBox.Show("間隔の値を0以下にすることは出来ません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (oct < 1 || oct > 100) { MessageBox.Show("複雑度の値を0以下、または100以上にすることは出来ません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (amp == 0.0) { MessageBox.Show("強さの値を0にすることは出来ません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (startTime > endTime) { MessageBox.Show("開始時間を終了時間より大きくすることは出来ません。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (startTime == endTime) { MessageBox.Show("開始時間と終了時間を同じにすることは出来ません。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } tl = layer[layerComboBox.SelectedIndex - 1]; //対象が"レイヤー"の場合は(ry if (targetComboBox.SelectedIndex > 1) { te = effect[targetComboBox.SelectedIndex - 2]; propertyGetter = new Func<double, PropertyBase>(delegate(double x) { return m.GetProperty(te, propertyName[propertyComboBox.SelectedIndex - 1], x); }); } else { propertyGetter = new Func<double, PropertyBase>(delegate(double x) { return m.GetProperty(tl, propertyName[propertyComboBox.SelectedIndex - 1], x); }); } //キーフレームを設定 SetWiggle(keyframeRate, oct, amp, startTime, endTime, dimensionComboBox.SelectedIndex, (PropertyInterpolationType)interpolationComboBox.SelectedItem, propertyData[propertyType[propertyName[propertyComboBox.SelectedIndex - 1]]].WiggleMethod, tl, te, propertyGetter); } else { MessageBox.Show("プロパティが選択されていません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("実行中にエラーが発生しました", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //閉じるボタン押下時のイベント void closeButton_Click(object sentder, EventArgs e) { this.Close(); } //コンポジション更新ボタン押下時のイベント void refreshCompositionButton_Click(object sentder, EventArgs e) { RefreshComposition(); } //コンボボックス、テキストボックスでEnterを押した場合は適用ボタンを押した事にする void _KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { applyButton.PerformClick(); } } void InitializeComponent() { this.SuspendLayout(); //各種ラベル Label label = new Label(); label.AutoSize = true; label.Text = "コンポジション:"; label.Location = new Point(12, 15); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "レイヤー:"; label.Location = new Point(36, 41); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "対象:"; label.Location = new Point(50, 67); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "プロパティ:"; label.Location = new Point(30, 93); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "次元:"; label.Location = new Point(50, 119); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "補間方法:"; label.Location = new Point(26, 145); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "間隔:"; label.Location = new Point(250, 15); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "個/秒"; label.Location = new Point(393, 15); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "複雑度:"; label.Location = new Point(238, 40); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "強さ:"; label.Location = new Point(254, 65); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "開始時間:"; label.Location = new Point(226, 90); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "秒"; label.Location = new Point(393, 90); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "終了時間:"; label.Location = new Point(226, 115); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "秒"; label.Location = new Point(393, 115); this.Controls.Add(label); //各種コンボボックス ComboBox comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 12); comboBox.Size = new Size(121, 20); comboBox.Name = ""; comboBox.SelectedIndexChanged += new EventHandler(compositionComboBox_SelectedIndexChanged); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); compositionComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 38); comboBox.Size = new Size(121, 20); comboBox.SelectedIndexChanged += new EventHandler(layerComboBox_SelectedIndexChanged); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); layerComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 64); comboBox.Size = new Size(121, 20); comboBox.SelectedIndexChanged += new EventHandler(targetComboBox_SelectedIndexChanged); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); targetComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 90); comboBox.Size = new Size(121, 20); comboBox.SelectedIndexChanged += new EventHandler(propertyComboBox_SelectedIndexChanged); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); propertyComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 116); comboBox.Size = new Size(121, 20); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); dimensionComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 142); comboBox.Size = new Size(121, 20); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); interpolationComboBox = comboBox; //各種テキストボックス TextBox textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 12); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); keyframeTextBox = textBox; textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 37); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); octTextBox = textBox; textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 62); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); ampTextBox = textBox; textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 87); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); startTimeTextBox = textBox; textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 112); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); endTimeTextBox = textBox; //各種ボタン Button button = new Button(); button.Size = new Size(75, 23); button.Location = new Point(12, 177); button.Text = "適用"; button.Click += new EventHandler(applyButton_Click); this.Controls.Add(button); applyButton = button; button = new Button(); button.Size = new Size(75, 23); button.Location = new Point(93, 177); button.Text = "閉じる"; button.Click += new EventHandler(closeButton_Click); this.Controls.Add(button); button = new Button(); button.Size = new Size(120, 23); button.Location = new Point(174, 177); button.Text = "コンポジション更新"; button.Click += new EventHandler(refreshCompositionButton_Click); this.Controls.Add(button); this.ClientSize = new Size(440, 212); this.FormBorderStyle = FormBorderStyle.FixedToolWindow; this.MaximizeBox = false; this.MinimizeBox = false; this.ShowIcon = false; this.ShowInTaskbar = false; this.TopMost = true; this.Text = "ウィグル"; this.ResumeLayout(false); this.PerformLayout(); } } [UsingNamespace] NiVE2.CodeDom.Expression }} ~ // - effectPaddingの宣言行がコロンで終わっていたので勝手ながらセミコロンに修正しました。また、どうもコード表示で不等号の扱いにクセがあるようで、Dictionary型のpropertyDataなどの宣言や初期化が死んでます。不等号のあとに半角スペースを入れるようにすれば問題ないようですが、他にも何かあるようで、ブラウザからそのままメモ帳にコピペしても動作せず、編集画面を開いてコピーしないと動かないようです。if文とかでも不等号のあとにスペースをあけずに変数を書いてしまうとおかしくなってしまうようです。 -- [[金の髭]] &new{2010-12-13 (月) 07:04:05}; - 報告&修正ありがとうございます。codeプラグインの方を修正して不等号を&nop(<);などの特殊文字で置き換えるようにしてみました。コードをテキストに保存して読み込んでも動かない件についてですが、テキストファイルからのオートメーションの読み込みがUTF-8のみに対応しているため、それ以外の文字コードで書かれたものが文字化けしているためではないかと思われます。 -- [[うp主]] &new{2010-12-13 (月) 08:42:30}; - 対応ありがとうございます。ちょっと調べてみましたが、空行に必ず半角スペースが入っているので、名前空間や参照に半角スペースの行が入ってしまい、エラーになるようです。こちらも対応できるでしょうか?というかここまで試してから報告すべきでしたね。何度もすみません。orz -- [[金の髭]] &new{2010-12-13 (月) 13:29:31}; - すみませんといいながら更にもう1つ・・・。質問箱などのように、投稿ごとにリンクというかラベルがつくようになると嬉しいです。 -- [[金の髭]] &new{2010-12-15 (水) 00:08:03}; - UI付きかっこいいです・・・今のところ金の髭さんのおっしゃる通りWikiからコピペするとスペースが入ってエラーを吐くようです。編集からコピペすると上手く動くようです。 -- [[K]] &new{2010-12-15 (水) 00:20:06}; - 空白行のスペースを追加しないようにしてみましたが、firefox関連のなんらかの問題の対策用に空白行にスペース追加されていたようなので、もしかするとこの変更によってfirefoxでレイアウトが崩れたりするという問題があるかもしれません。 -- [[うp主]] &new{2010-12-15 (水) 13:35:30}; - 対応ありがとうございます。お時間のある時で構いませんので記事ごとのリンク自動生成の件も対応していただければ幸いです。 -- [[金の髭]] &new{2010-12-15 (水) 22:32:52}; - とりあえず、原因とおぼしき部分は修正しましたが、なぜか最新の投稿のみアンカーがつかないようです。原因がわかり次第修正しますが、ちょっと時間がかかりそうです。 -- [[うp主]] &new{2010-12-16 (木) 03:19:05}; - ありがとうございます。色々すみません。 -- [[金の髭]] &new{2010-12-16 (木) 08:26:31}; #comment_kcaptcha **キネティックタイポグラフィーとかに使ってほしいオートメーション [#q3105411] >[[K]] (2010-12-08 (水) 01:42:02)~ ~ オートメーションなのですがここに書いてよろしいのでしょうか・・・~ ~ キネタイをやったとき歌詞などのテキストレイヤーを一行一行追加していくのがめんどくさくなったのでつくりました。~ ~ テキストファイルを読み込んで、各行に分割してテキストレイヤーを作ります。~ ~ 実行する前に~ MainCode直下の~ string compName = "Comp 2";~ の部分を追加したいコンポジション名に書き換えてください。~ ~ あと読み込めるテキストの改行コードはCrLfのみとしました。~ ~ 文字コードを判別するメソッドはまるまるパクリですw~ ~ #code(csharp, コード){{ [MethodCode] /// <summary> /// 文字コードを判別する /// </summary> /// <remarks> /// Jcode.pmのgetcodeメソッドを移植したものです。 /// Jcode.pm(http://openlab.ring.gr.jp/Jcode/index-j.html) /// Jcode.pmのCopyright: Copyright 1999-2005 Dan Kogai /// </remarks> /// <param name="byts">文字コードを調べるデータ</param> /// <returns>適当と思われるEncodingオブジェクト。 /// 判断できなかった時はnull。</returns> System.Text.Encoding GetCode(byte[] bytes) { const byte bEscape = 0x1B; const byte bAt = 0x40; const byte bDollar = 0x24; const byte bAnd = 0x26; const byte bOpen = 0x28; //'(' const byte bB = 0x42; const byte bD = 0x44; const byte bJ = 0x4A; const byte bI = 0x49; int len = bytes.Length; byte b1, b2, b3, b4; //Encode::is_utf8 は無視 bool isBinary = false; for (int i = 0; i < len; i++) { b1 = bytes[i]; if (b1 <= 0x06 || b1 == 0x7F || b1 == 0xFF) { //'binary' isBinary = true; if (b1 == 0x00 && i < len - 1 && bytes[i + 1] <= 0x7F) { //smells like raw unicode return System.Text.Encoding.Unicode; } } } if (isBinary) { return null; } //not Japanese bool notJapanese = true; for (int i = 0; i < len; i++) { b1 = bytes[i]; if (b1 == bEscape || 0x80 <= b1) { notJapanese = false; break; } } if (notJapanese) { return System.Text.Encoding.ASCII; } for (int i = 0; i < len - 2; i++) { b1 = bytes[i]; b2 = bytes[i + 1]; b3 = bytes[i + 2]; if (b1 == bEscape) { if (b2 == bDollar && b3 == bAt) { //JIS_0208 1978 //JIS return System.Text.Encoding.GetEncoding(50220); } else if (b2 == bDollar && b3 == bB) { //JIS_0208 1983 //JIS return System.Text.Encoding.GetEncoding(50220); } else if (b2 == bOpen && (b3 == bB || b3 == bJ)) { //JIS_ASC //JIS return System.Text.Encoding.GetEncoding(50220); } else if (b2 == bOpen && b3 == bI) { //JIS_KANA //JIS return System.Text.Encoding.GetEncoding(50220); } if (i < len - 3) { b4 = bytes[i + 3]; if (b2 == bDollar && b3 == bOpen && b4 == bD) { //JIS_0212 //JIS return System.Text.Encoding.GetEncoding(50220); } if (i < len - 5 && b2 == bAnd && b3 == bAt && b4 == bEscape && bytes[i + 4] == bDollar && bytes[i + 5] == bB) { //JIS_0208 1990 //JIS return System.Text.Encoding.GetEncoding(50220); } } } } //should be euc|sjis|utf8 //use of (?:) by Hiroki Ohzaki <ohzaki@iod.ricoh.co.jp> int sjis = 0; int euc = 0; int utf8 = 0; for (int i = 0; i < len - 1; i++) { b1 = bytes[i]; b2 = bytes[i + 1]; if (((0x81 <= b1 && b1 <= 0x9F) || (0xE0 <= b1 && b1 <= 0xFC)) && ((0x40 <= b2 && b2 <= 0x7E) || (0x80 <= b2 && b2 <= 0xFC))) { //SJIS_C sjis += 2; i++; } } for (int i = 0; i < len - 1; i++) { b1 = bytes[i]; b2 = bytes[i + 1]; if (((0xA1 <= b1 && b1 <= 0xFE) && (0xA1 <= b2 && b2 <= 0xFE)) || (b1 == 0x8E && (0xA1 <= b2 && b2 <= 0xDF))) { //EUC_C //EUC_KANA euc += 2; i++; } else if (i < len - 2) { b3 = bytes[i + 2]; if (b1 == 0x8F && (0xA1 <= b2 && b2 <= 0xFE) && (0xA1 <= b3 && b3 <= 0xFE)) { //EUC_0212 euc += 3; i += 2; } } } for (int i = 0; i < len - 1; i++) { b1 = bytes[i]; b2 = bytes[i + 1]; if ((0xC0 <= b1 && b1 <= 0xDF) && (0x80 <= b2 && b2 <= 0xBF)) { //UTF8 utf8 += 2; i++; } else if (i < len - 2) { b3 = bytes[i + 2]; if ((0xE0 <= b1 && b1 <= 0xEF) && (0x80 <= b2 && b2 <= 0xBF) && (0x80 <= b3 && b3 <= 0xBF)) { //UTF8 utf8 += 3; i += 2; } } } //M. Takahashi's suggestion //utf8 += utf8 / 2; System.Diagnostics.Debug.WriteLine( string.Format("sjis = {0}, euc = {1}, utf8 = {2}", sjis, euc, utf8)); if (euc > sjis && euc > utf8) { //EUC return System.Text.Encoding.GetEncoding(51932); } else if (sjis > euc && sjis > utf8) { //SJIS return System.Text.Encoding.GetEncoding(932); } else if (utf8 > euc && utf8 > sjis) { //UTF8 return System.Text.Encoding.UTF8; } return null; } // ---------------------------------------------------------- // ◆テキスト入力ダイアログを表示し指定したテキストファイルを読み込む。 // ○返り値 // 取得されたテキストファイルの内容 // // ---------------------------------------------------------- String GetTextFile(){ //最後に返り値を入れる用 string retStr= ""; //ファイル入力ダイアログのインスタンス化 OpenFileDialog ofd = new OpenFileDialog(); //タイトルの設定 ofd.Title = "改行分割するテキストファイルを選択してください"; //ダイアログボックスを閉じる前に現在のディレクトリを復元するようにする ofd.RestoreDirectory = true; //[ファイルの種類]に表示される選択肢を指定する ofd.Filter ="txt files (*.txt)|*.txt|All files (*.*)|*.*"; //[ファイルの種類]ではじめにtxt filesが選択されるようにする ofd.FilterIndex = 1; //ダイアログを表示する if (ofd.ShowDialog() == DialogResult.OK) { //OKボタンがクリックされたとき //選択されたファイルを読み取り専用で開く System.IO.Stream stream; stream = ofd.OpenFile(); if (stream != null) { //テキストファイルを開く System.IO.FileStream fs = new System.IO.FileStream(ofd.FileName, System.IO.FileMode.Open,System.IO.FileAccess.Read); byte[] bs = new byte[fs.Length]; //byte配列に読み込む fs.Read(bs, 0, bs.Length); fs.Close(); //文字コードを取得する System.Text.Encoding enc = GetCode(bs); //デコードして返り値を退避 retStr = enc.GetString(bs); } } //返す return retStr; } // ---------------------------------------------------------- // ◆指定したコンポジション名を持つコンポジションの取得 // ○引数 // IComposition[] comps // 比較するコンポジション配列 // // string compName // テキストレイヤーを追加したいコンポジション名(指定したコンポジション名) // // ○返り値 // 指定したコンポジション名(compName)と同名のコンポジション // // ---------------------------------------------------------- IComposition GetTargetComp(IComposition[] comps,string compName) { // 指定コンポジション名を持つコンポジションの添え字を取得 int compNum = 0; for (int i = 0; i < comps.Length; i++) { if (compName == comps[i].Setting.Name) { compNum = i; break; } } return comps[compNum]; } // ---------------------------------------------------------- // ◆テキストレイヤーを追加し引数のstring(lyric)をリネーム、ソーステキストに設定 // ○引数 // IAutomationManager manager // これ渡さないとうごかないので。 // // IComposition targetComp // 追加対象のコンポジション // // string lyric // リネーム、ソーステキストにプロパティを追加する歌詞(lyric) // // ○返り値 // なし、コンポジションにレイヤーが追加される // ---------------------------------------------------------- void SetTextLayer(IAutomationManager manager, IComposition targetComp,string lyric) { //テキストレイヤーを作成しtextLayerに入れる ILayer textLayer = manager.AddText(targetComp); //レイヤー名を歌詞にする manager.ChangeLayerName(textLayer,lyric); //テキストレイヤーのテキストに歌詞を入れる StringProperty strp = new StringProperty("ソーステキスト",lyric ); KeyFrame strk = new KeyFrame(0, strp, PropertyInterpolationType.None); manager.AddKeyFrame(textLayer, strk); } [MainCode] // 注意:実行前に入力すること! // コンポジション名 string compName = "Comp 2"; // テキストファイルの内容取得 string lyric = GetTextFile(); //改行コード、デリミタの設定 char[] delimiterChars = { '\r', '\n'}; // テキストファイルの内容を配列に分割 string[] lyrics = lyric.Split(delimiterChars); // コンポジション配列取得 IComposition[] comps = manager.GetComposition(); // 対象のコンポジションの取得 IComposition targetComp = GetTargetComp(comps,compName); //テキストファイルの行数分だけループ for (int i=0; i < lyrics.Length; i++){ //lyrics[i]が空文字("")ならレイヤーを追加しない if(lyrics[i].Length!=0){ //テキストレイヤーの設置、リネームとプロパティの追加 SetTextLayer(manager, targetComp,lyrics[i]); } } //でばっぐよう //MessageBox.Show("テキスト"); }} ~ // - 長すぎですなwwwwごめんなさいw -- [[K]] &new{2010-12-08 (水) 01:42:50}; #comment_kcaptcha **クロスフェード [#q69ee8a6] > (2010-12-06 (月) 03:05:24)~ ~ このエクスプレッションをはりつけたレイヤー同士のかぶった部分に、自動でクロスフェードをかけます。かならずフェードアウトするレイヤーのひとつ下に、フェードインするレイヤーをおいてください。~ デフォルトでは、フェードインするレイヤーは実際にはフェードイン処理していません。透明部分があるレイヤーがフェードアウトする場合は、フェードインする側のレイヤーのエクスプレッションのfadeinの値をtrueに変更してみてください。~ ~ #code(csharp){{ [MainCode] //フェードインはデフォルトで無効(有効にするときはfalseをtrueに変更する) bool fadein = false; // エフェクトの不透明度のプロパティを取得 NumberProperty opaque = (NumberProperty)property.GetProperty(thisItem, "不透明度"); // クロスフェードさせる相手レイヤーを探す // (自分のレイヤーの上下のレイヤーを探すだけ) ILayer layer = (ILayer)thisItem; ILayer fin = null, fout = null; ILayer[] ls = layer.Composition.GetLayer(); for (int i = 0; i < ls.Length; i++) { if (ls[i].Equals(layer) == true) { if (i > 0) fout = ls[i - 1]; if (i < ls.Length - 1) fin = ls[i + 1]; break; } } // クロスフェード処理 // ワールド時間を求める double wtime = layer.ToWorldTime(time); // レイヤーの開始・終了時間のワールド時間を求める double start = layer.Position + layer.InPoint; double end = layer.Position + layer.OutPoint; // フェードイン if (fout != null && fadein == true) { // 相手レイヤーの開始・終了時間のワールド時間を求める double fstart = fout.Position + fout.InPoint; double fend = fout.Position + fout.OutPoint; // 重なっている部分があったらフェードイン処理 if (start < fend && wtime < fend) opaque.DoubleValue = (wtime - start) / (fend - start) * 100; } // フェードアウト if (fin != null) { // 相手レイヤーの開始・終了時間のワールド時間を求める double fstart = fin.Position + fin.InPoint; double fend = fin.Position + fin.OutPoint; // 重なっている部分があったらフェードアウト処理 if (fstart < end && fstart < wtime) opaque.DoubleValue = (end - wtime) / (end - fstart) * 100; } // 0-100に丸める opaque.DoubleValue = Math.Max(Math.Min(opaque.DoubleValue, 100), 0); // 変更したプロパティを反映 property.SetProperty(thisItem, opaque); }} ~ // #comment_kcaptcha **フェードイン・フェードアウト [#r46e6c8d] > (2010-12-05 (日) 21:22:48)~ ~ 不透明度のパラメータが存在するエフェクトまたはレイヤーの開始点から、終了点までの1秒にフェード処理を行います。~ ~ #code(csharp){{ [MainCode] // フェードイン・フェードアウトにかかる時間(秒) double fadeinterval = 1.0; ILayer layer; if (thisItem is IEffect) { // このエクスプレッションはエフェクトに適用されている // エフェクトのあるレイヤーの情報を取得 IExpressionItem thisLayer = thisItem.ParentItem; layer = (ILayer)thisLayer; } else { // このエクスプレッションはレイヤーに適用されている layer = (ILayer)thisItem; } // エフェクトの不透明度のプロパティを取得 NumberProperty opaque = (NumberProperty)property.GetProperty(thisItem, "不透明度"); // フェードイン処理 if (layer.InPoint + fadeinterval > time) opaque.DoubleValue = (time - layer.InPoint) / fadeinterval * 100; // フェードアウト処理 if (layer.OutPoint - fadeinterval < time) opaque.DoubleValue = (layer.OutPoint - time) / fadeinterval * 100; // 変更したプロパティを反映 property.SetProperty(thisItem, opaque); }} ~ // #comment_kcaptcha **サンプルいくつか [#b4b29e7d] >[[うp主]] (2010-12-05 (日) 16:39:09)~ ~ 投稿テストもかねていくつか。~ ~ レイヤーの位置にWiggleを掛ける~ #code(csharp){{ [MainCode] //ランダムシード int seed = thisItem.GetHashCode(); //複雑度 int oct = 6; //振幅 Vertex amp = new Vertex(100.0, 100.0, 100.0); //振動の速度 double speed = 15.0; //展開 float x = (float)((time * speed) % 360.0); //位置のプロパティ VertexProperty position = (VertexProperty)property.GetProperty(thisItem, "位置"); //ExpressionUtils.Wiggleを使って振動させる position.VertexValue = ExpressionUtils.Wiggle(seed, x, oct, position.VertexValue, amp); property.SetProperty(thisItem, position); }} ~ イージングを適用しつつ移動~ #code(csharp){{ [MainCode] //位置のプロパティ VertexProperty position = (VertexProperty)property.GetProperty(thisItem, "位置"); //開始時間 double startTime = 0.0; //終了時間 double endTime = 2.0; //開始位置 Vertex startPosition = position.VertexValue; //終了位置 Vertex endPosition = Vertex.Add(startPosition, new Vertex(640.0, 480.0, 0.0)); //加速度 double ease = 2.0; position.VertexValue = ExpressionUtils.Ease(startTime, startPosition, endTime, endPosition, time, ease); property.SetProperty(thisItem, position); }} ~ コンポジション内のレイヤーを円運動させる~ #code(csharp){{ [MainCode] //このコンポジション内の全てのレイヤー ILayer[] layer = ((IComposition)thisItem.ParentItem).GetLayer(); //レイヤーごとの開始角度 double rad = 360.0 / (double)(layer.Length - 1); //円の半径 Vertex radius = new Vertex(0.0, 200.0, 0.0); //各軸それぞれの回転 double xMove = time * 180.0; double yMove = time * 180.0; double zMove = time * 90.0; //位置計算用の行列 Matrix4D matrix = new Matrix4D(); for (int i = 0, c = 0; i < layer.Length; i++) { //Nullオブジェクトやカメラなどを除く if (!layer[i].IsSpecialItem) { //行列を初期化 matrix.LoadIdentity(); //回転 matrix.Rotate(xMove, yMove, rad * i + zMove, true); VertexProperty pos = (VertexProperty)property.GetProperty(layer[i], "位置"); pos.VertexValue = Vertex.Add(pos.VertexValue, matrix.Transform(radius)); property.SetProperty(layer[i], pos); c++; } } }} ~ // - 追記: 円運動のエクスプレッションを使用する際は、Nullオブジェクトかなにかをコンポジションの一番下において、そこにエクスプレッションをコピペして下さい。 -- [[うp主]] &new{2010-12-05 (日) 16:50:29}; - カメラを400x300x0から400x300x-1000までイージングを適用しつつ移動させたいんですが、上記のコードをコピペして適宜位置の値を変えて使えばよろしいのでしょうか? -- &new{2010-12-12 (日) 23:08:00}; #comment_kcaptcha **てすと [#z773fcc9] > (2010-12-05 (日) 16:17:23)~ ~ テスト~ #code(csharp){{ //test namespace Test { class TestClass { static void Main(string[] args) { System.Windows.Forms.MessageBox("Hello World!"); } } } }} ~ // #comment_kcaptcha
タイムスタンプを変更しない
* サンプルコード [#nf978271] > エクスプレッション、オートメーションのサンプルコードを投稿するページです。 > ''投稿者の方へ''&br; 投稿時は、下記の書式に従って記述して下さい。&br; ~#code(言語名){{ ~//ここにコードを記述 ~}} &br; 言語名に関しては、オートメーション、エクスプレッションはcsharp、プロパティスクリプトはpropertyscriptとしてください。 &br;&br; また、長いコードは&br; ~#code(言語名, コード) &br;&br; の様に言語名の後に適当な名前を指定するとコードを折りたたむことが出来ます。&br; &br; ※投稿時にはコード種別(オートメーションなのかエクスプレッションなのか、プロパティスクリプトなのか)を明示するようにして下さい。&br; ※オートメーションの場合は「保存」でテキスト形式で保存し、そのテキストファイルの内容をそのまま貼り付けて下さい。&br; ※エクスプレッションの場合は「エクスプレッションの保存」でテキスト形式で保存し、そのテキストファイルの内容をそのまま貼り付けて下さい。&br; > ''投稿されたコードを使用しようと考えている方へ''&br; エクスプレッション、オートメーションは、ある程度NiVEの操作に慣れている方用の機能です。&br; これらの使用方法については、付属の「エクスプレッション・オートメーションについて.pdf」をご覧下さい。&br; &br; ※オートメーションの場合は、コードをメモ帳にコピーして、文字コードを「UTF-8」にして保存し、&br; オートメーションの「読み込み」からそのテキストファイルを開き、実行します。&br; ※エクスプレッションの場合は、コードをメモ帳にコピーして、文字コードを「UTF-8」にして保存し、&br; 「エクスプレッションの読み込み」からそのテキストファイルを開き、実行します。&br; &br; また、質問に関しては、言語に関する質問や、コードの書き方等、投稿されたコードに関係ない質問はご遠慮下さい。&br; &br; // #comment_kcaptcha **円エフェクトの半径と不透明度をランダムに > (2011-03-12 (土) 16:04:56)~ ~ ディスプレイスメントマップを使って波紋を作っているんですが、マップで波紋のように変形させるため円エフェクトを使っています。~ 半径を0から300、それに合わせて不透明度を100から0を2秒で行うようにに設定しています。~ それを何個か並べているのですが動きがみな同じなため、機械的な波紋に見えてしまいます。エクスプレッションで半径と不透明度をランダムに設定することはできないのでしょうか?~ ~ プロジェクトファイルを上げました。~ http://u9.getuploader.com/nicoAE/download/522/%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E7%AD%89.zip~ よろしくお願いします。~ ~ // #comment_kcaptcha **プロパティスクリプト投稿テスト >[[うp主]] (2011-02-21 (月) 18:40:24)~ ~ プロパティスクリプトのサンプルのテスト。~ 開始や終了を1フレームごとに1文字分変化させるのに便利な感じのスクリプト。~ ~ #code(propertyscript){{ return 100.0 / strLen(replace(getProperty("ソーステキスト"), "\r\n", "")) * timeToFrames(time); }} ~ // #comment_kcaptcha **レンダラの選択サンプル [#s0a7822b] >[[うp主]] (2011-02-09 (水) 14:36:03)~ ~ オートメーションでのレンダラの選択について質問があったので、適当ですがやってみました。~ ~ #code(csharp,rendererSelectSample){{ [MainCode] using (RendererSelectWindow window = new RendererSelectWindow(manager)) { if (window.ShowDialog() == DialogResult.OK) { manager.NewComposition("", new CompositionSetting(window.SelectedRendererName, window.SelectedRenderer, new Size(640, 480), 30.0, 10.0, 180.0, -90.0, 16)); } } [MethodCode] class RendererSelectWindow : Form { public RendererSelectWindow(IAutomationManager manager) { InitializeComponent(); //プラグイン名取得 renderer = new Dictionary<string, string>(); foreach (KeyValuePair<string, Type> plugin in manager.GetAllRendererPlugin()) { using (RendererBase r = (RendererBase)Activator.CreateInstance(plugin.Value)) { renderer.Add(r.PluginName, plugin.Key); rendererComboBox.Items.Add(r.PluginName); } } rendererComboBox.SelectedIndex = 0; } Dictionary<string, string> renderer = null; ComboBox rendererComboBox = null; public string SelectedRenderer { get { return renderer[(string)rendererComboBox.SelectedItem]; } } public string SelectedRendererName { get { return (string)rendererComboBox.SelectedItem; } } void InitializeComponent() { Label label = new Label(); label.Text = "レンダラ:"; label.Location = new Point(12, 15); label.AutoSize = true; Button okButton = new Button(); okButton.Location = new Point(12, 42); okButton.Text = "OK"; okButton.DialogResult = DialogResult.OK; Button cancelButton = new Button(); cancelButton.Location = new Point(91, 42); cancelButton.Text = "キャンセル"; cancelButton.DialogResult = DialogResult.Cancel; rendererComboBox = new ComboBox(); rendererComboBox.Location = new Point(58, 12); rendererComboBox.Width = 150; rendererComboBox.DropDownStyle = ComboBoxStyle.DropDownList; this.ClientSize = new Size(220, 75); this.MaximizeBox = false; this.MinimizeBox = false; this.ShowIcon = false; this.ShowInTaskbar = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.StartPosition = FormStartPosition.CenterParent; this.Text = "レンダラの選択"; this.Controls.Add(label); this.Controls.Add(rendererComboBox); this.Controls.Add(okButton); this.Controls.Add(cancelButton); } } [UsingNamespace] [Reference] }} ~ // #comment_kcaptcha **投稿方法について [#e20ffa78] >[[金の髭]] (2010-12-26 (日) 21:05:58)~ ~ Wikiそのものの質問になってしまって恐縮なのですが・・・。~ 質問1.試しに以下の例のように記述して投稿してみたところ、他の記事も含めて全体が折りたたまれてしまいました。~ 投稿時はcode(csharp)だけで投稿し、regionは投稿後ページ編集で付け足す必要があるのでしょうか?~ (下の例では行頭の#は省略しています)~ 質問2.regionが使われるたびに、その後の記事のインデントがずれていっているようですがこれは仕様になりますでしょうか。~ ~ ↓投稿例~ ~ region(←コードはこちら)~ ~ code(csharp){{~ ~ int a=0;~ ~ }}~ ~ endregion~ ~ // - 確認しました。どうやら、&nop(#endregion);の後に&nop(~);が入ることによって、影響範囲がおかしくなってしまうようです。また、インデントについては&nop(#region);の次の行に&nop(~);を入れると解消されるようです。いずれも修正できる場合は修正しておきます。 -- [[うp主]] &new{2010-12-29 (水) 19:15:22}; - と思ったら、どうやら&nop(~);を挟んでもインデントは解除されないようです orz &nop(#region)自体が結構裏技的なことをやっているそうなので、この問題の解決は難しいかもしれません。 -- [[うp主]] &new{2010-12-29 (水) 20:12:07}; - codeプラグインの方に手を加えてregionプラグインを使用せずに折りたためるようにしてみました。これで多分インデントの問題も解決できるかと思うので、そちらを試してみてください。 -- [[うp主]] &new{2010-12-30 (木) 01:12:24}; - 上の例でうまくいくことを確認しました。対応ありがとうございます。色々すみません。 -- [[金の髭]] &new{2010-12-31 (金) 23:36:29}; #comment_kcaptcha **ウィグル適用ウインドウ [#gbad8610] >[[うp主]] (2010-12-12 (日) 13:17:57)~ ~ 指定したプロパティにウィグルを適用し、キーフレームを設定します。~ ~ 使い方:~ 各コンボボックスから適用したいものを選択します。~ 間隔、複雑度、強さ、開始時間、終了時間を入力し、適用を押します。~ ~ パラメータの説明:~ 対象 : プロパティを所持するエフェクト、またはレイヤープロパティを指定します~ 次元 : 値を適用する次元(軸)を選択します。~ 間隔 : 1秒間にキーフレームをいくつ置くかを設定します。~ 複雑度 : 振動の激しさを設定します。~ 強さ : 値の変化の度合いを設定します。~ 開始時間: キーフレームの設置を開始する時間をレイヤーのローカル時間で設定します。~ 終了時間: キーフレームの設置を終了する時間をレイヤーのローカル時間で設定します。~ 適用 : 設定を元にキーフレームを設定します。~ 閉じる : ウインドウを閉じます。~ コンポジション更新: コンポジションの情報を更新します。~ これ以外のコンボボックス: 見たままなので略。~ ~ 以下コード。長め注意~ ~ #code(csharp, コード){{ [MainCode] WiggleSettingWindow window = new WiggleSettingWindow(manager); window.Show(); [MethodCode] //ウィグル用メソッドのデリゲート delegate PropertyBase WiggleMethod(PropertyBase property, float x, int oct, double amp, int dimension); //各プロパティで対応する次元とウィグル用メソッドを格納するクラス class PropertyData { public PropertyData(string[] dim, WiggleMethod method, PropertyInterpolationType type) { Type = type; DimensionName = dim; WiggleMethod = method; } public PropertyInterpolationType Type = default(PropertyInterpolationType); public string[] DimensionName = null; public WiggleMethod WiggleMethod = null; } class WiggleSettingWindow : Form { public WiggleSettingWindow(IAutomationManager manager) { //対応する型を設定する propertyData = new Dictionary<Type, PropertyData>(); propertyData.Add(typeof(NumberProperty), new PropertyData(new string[] { "なし" }, WiggleNumberProperty, PropertyInterpolationType.Fixed | PropertyInterpolationType.Liner | PropertyInterpolationType.CatmullRom)); propertyData.Add(typeof(RadianProperty), new PropertyData(new string[] { "なし" }, WiggleRadianProperty, PropertyInterpolationType.Fixed | PropertyInterpolationType.Liner | PropertyInterpolationType.CatmullRom)); propertyData.Add(typeof(VertexProperty), new PropertyData(new string[] { "X", "Y", "Z", "各軸個別", "各軸同一" }, WiggleVertexProperty, PropertyInterpolationType.Fixed | PropertyInterpolationType.Liner | PropertyInterpolationType.CatmullRom)); //対応する型を増やす場合はここ以下に記述する //書式: //propertyData.Add(typeof(対応する型), new PropertyData(new string[] { 対応する次元 }, ウィグル用メソッド, 対応する補間タイプ)); //例: //propertyData.Add(typeof(ColorProperty), new PropertyData(new string[] { "R", "G", "B", "A", "RGB同一", "RGBA同一" }, WiggleColorProperty, PropertyInterpolationType.Fixed | PropertyInterpolationType.Liner | PropertyInterpolationType.CatmullRom)); InitializeComponent(); m = manager; //ランダムシードはここで変更する seed = this.GetHashCode(); RefreshComposition(); } //各種コントロール ComboBox compositionComboBox = null; ComboBox layerComboBox = null; ComboBox targetComboBox = null; ComboBox propertyComboBox = null; ComboBox dimensionComboBox = null; ComboBox interpolationComboBox = null; TextBox keyframeTextBox = null; TextBox octTextBox = null; TextBox ampTextBox = null; TextBox startTimeTextBox = null; TextBox endTimeTextBox = null; Button applyButton = null; //オートメーションマネージャ IAutomationManager m = null; //コンポジション IComposition[] composition = null; //レイヤー ILayer[] layer = null; //エフェクト IEffect[] effect = null; //プロパティの名前 string[] propertyName = null; //プロパティの型 Dictionary<string, Type> propertyType = null; //各プロパティの設定 Dictionary<Type, PropertyData> propertyData = null; //複雑度 int octave = 6; //ランダムシード int seed = 0; //コンボボックスの"なし"のインデックス用パディング const int itemPadding = 1; //上の定数のエフェクト用 const int effectPadding = 2; //コンポジションの更新 void RefreshComposition() { composition = m.GetComposition(); layer = null; compositionComboBox.Items.Clear(); compositionComboBox.Items.Add("なし"); for (int i = 0; i < composition.Length; i++) { compositionComboBox.Items.Add(composition[i].Setting.Name); } compositionComboBox.SelectedIndex = 0; } //NumberProperty用ウィグルメソッド PropertyBase WiggleNumberProperty(PropertyBase property, float x, int oct, double amp, int dimension) { NumberProperty np = (NumberProperty)property; np.DoubleValue = ExpressionUtils.Wiggle(seed, x, oct, np.DoubleValue, amp); return property; } //RadianProperty用ウィグルメソッド PropertyBase WiggleRadianProperty(PropertyBase property, float x, int oct, double amp, int dimension) { RadianProperty rp = (RadianProperty)property; return new RadianProperty(rp.PropertyName, 0, ExpressionUtils.Wiggle(seed, x, oct, rp.ToAngle(), amp)); return property; } //VertexProperty用ウィグルメソッド //次元についてはコンストラクタ、またはメソッド内で使用しているプロパティを参照のこと PropertyBase WiggleVertexProperty(PropertyBase property, float x, int oct, double amp, int dimension) { VertexProperty vp = (VertexProperty)property; switch(dimension) { case 0: { vp.X = ExpressionUtils.Wiggle(seed, x, oct, vp.X, amp); break; } case 1: { vp.Y = ExpressionUtils.Wiggle(seed, x, oct, vp.Y, amp); break; } case 2: { vp.Z = ExpressionUtils.Wiggle(seed, x, oct, vp.Z, amp); break; } case 3: { vp.VertexValue = ExpressionUtils.Wiggle(seed, x, oct, vp.VertexValue, new Vertex(amp, amp, amp)); break; } case 4: { double w = ExpressionUtils.Wiggle(seed, x, oct, 0.0, amp); vp.X += w; vp.Y += w; vp.Z += w; break; } } return property; } //対応する型のウィグル用メソッドを追加する。書式はWiggleMethodデリゲートに従う。 //例: //PropertyBase WiggleColorProperty(PropertyBase property, float x, int oct, double amp, int dimension) //{ // ColorProperty cp = (ColorProperty)property; // switch(dimension) // { // case 0: // { // cp.R = (byte)Math.Min(Math.Max(ExpressionUtils.Wiggle(seed, x, oct, cp.R, amp), 0.0), 255.0); // break; // } // case 1: // { // cp.G = (byte)Math.Min(Math.Max(ExpressionUtils.Wiggle(seed, x, oct, cp.G, amp), 0.0), 255.0); // break; // } // case 2: // { // cp.B = (byte)Math.Min(Math.Max(ExpressionUtils.Wiggle(seed, x, oct, cp.B, amp), 0.0), 255.0); // break; // } // case 3: // { // cp.A = (byte)Math.Min(Math.Max(ExpressionUtils.Wiggle(seed, x, oct, cp.A, amp), 0.0), 255.0); // break; // } // case 4: // { // double w = ExpressionUtils.Wiggle(seed, x, oct, 0.0, amp); // cp.R = (byte)Math.Min(Math.Max(cp.R + w, 0.0), 255.0); // cp.G = (byte)Math.Min(Math.Max(cp.G + w, 0.0), 255.0); // cp.B = (byte)Math.Min(Math.Max(cp.B + w, 0.0), 255.0); // break; // } // case 5: // { // double w = ExpressionUtils.Wiggle(seed, x, oct, 0.0, amp); // cp.R = (byte)Math.Min(Math.Max(cp.R + w, 0.0), 255.0); // cp.G = (byte)Math.Min(Math.Max(cp.G + w, 0.0), 255.0); // cp.B = (byte)Math.Min(Math.Max(cp.B + w, 0.0), 255.0); // cp.A = (byte)Math.Min(Math.Max(cp.A + w, 0.0), 255.0); // break; // } // } // // return property; //} //キーフレームを設定する void SetWiggle(int keyframeRate, int oct, double amp, double startTime, double endTime, int dimension, PropertyInterpolationType type, WiggleMethod wiggle, ILayer targetLayer, IEffect targetEffect, Func<double, PropertyBase> propertyGetter) { double rate = 1.0 / (double)keyframeRate; int count = (int)((endTime - startTime) / rate); float addx = 360.0F / (float)count; if (count > 0) { //一度キーフレームを全て作成してから追加する KeyFrame[] keyFrame = new KeyFrame[count]; for (int i = 0; i < count; i++) { double time = Math.Round(startTime + rate * i, ReferenceData.MinimumTimeDigit, MidpointRounding.ToEven); keyFrame[i] = new KeyFrame(time, wiggle(propertyGetter(time), addx * i, oct, amp, dimension), type); } //対象が入力・レイヤープロパティの場合はtargetEffectはnull if (targetEffect != null) { for (int i = 0; i < count; i++) { m.AddKeyFrame(targetEffect, keyFrame[i]); } } else { for (int i = 0; i < count; i++) { m.AddKeyFrame(targetLayer, keyFrame[i]); } } } } //コンポジション選択時のイベント void compositionComboBox_SelectedIndexChanged(object sender, EventArgs e) { layer = null; layerComboBox.Items.Clear(); layerComboBox.Items.Add("なし"); try { if (compositionComboBox.SelectedIndex > 0) { //レイヤーを取得 layer = composition[compositionComboBox.SelectedIndex - itemPadding].GetLayer(); for (int i = 0; i < layer.Length; i++) { layerComboBox.Items.Add(layer[i].ItemName); } } } catch { } layerComboBox.SelectedIndex = 0; } //レイヤー選択時のイベント void layerComboBox_SelectedIndexChanged(object sender, EventArgs e) { effect = null; targetComboBox.Items.Clear(); targetComboBox.Items.Add("なし"); if (layer != null && layerComboBox.SelectedIndex > 0) { targetComboBox.Items.Add("レイヤー"); //エフェクトを取得 effect = layer[layerComboBox.SelectedIndex - itemPadding].GetEffect(); for (int i = 0; i < effect.Length; i++) { targetComboBox.Items.Add(effect[i].ItemName); } } targetComboBox.SelectedIndex = 0; } //対象選択時のイベント void targetComboBox_SelectedIndexChanged(object sender, EventArgs e) { propertyName = null; propertyType = new Dictionary<string, Type>(); propertyComboBox.Items.Clear(); propertyComboBox.Items.Add("なし"); if (targetComboBox.SelectedIndex > 0) { //"レイヤー"の場合は入力・レイヤープロパティを対象とする if (targetComboBox.SelectedIndex > 1) { //対象のエフェクト IEffect se = effect[targetComboBox.SelectedIndex - effectPadding]; propertyName = m.GetPropertyNames(se); for (int i = 0; i < propertyName.Length; i++) { PropertyBase p = m.GetProperty(se, propertyName[i], 0.0); //ウィグルに対応するプロパティのみを表示 if (p != null && propertyData.ContainsKey(p.GetType())) { propertyType.Add(propertyName[i], p.GetType()); } } } else { //対象のレイヤー ILayer sl = layer[layerComboBox.SelectedIndex - itemPadding]; propertyName = m.GetPropertyNames(sl); for (int i = 0; i < propertyName.Length; i++) { PropertyBase p = m.GetProperty(sl, propertyName[i], 0.0); //ウィグルに対応するプロパティのみを表示 if (p != null && propertyData.ContainsKey(p.GetType())) { propertyType.Add(propertyName[i], p.GetType()); } } } //対応するプロパティの名前をコンボボックスに追加 propertyName = new string[propertyType.Count]; propertyType.Keys.CopyTo(propertyName, 0); propertyComboBox.Items.AddRange(propertyName); } propertyComboBox.SelectedIndex = 0; } //プロパティ選択時のイベント void propertyComboBox_SelectedIndexChanged(object sender, EventArgs e) { dimensionComboBox.Items.Clear(); interpolationComboBox.Items.Clear(); //対応する次元と補間タイプを表示 if (propertyComboBox.SelectedIndex > 0) { PropertyData sp = propertyData[propertyType[propertyName[propertyComboBox.SelectedIndex - 1]]]; dimensionComboBox.Items.AddRange(sp.DimensionName); if ((sp.Type & PropertyInterpolationType.Fixed) != 0) { interpolationComboBox.Items.Add(PropertyInterpolationType.Fixed); } if ((sp.Type & PropertyInterpolationType.Liner) != 0) { interpolationComboBox.Items.Add(PropertyInterpolationType.Liner); } if ((sp.Type & PropertyInterpolationType.CatmullRom) != 0) { interpolationComboBox.Items.Add(PropertyInterpolationType.CatmullRom); } } else { dimensionComboBox.Items.Add("なし"); interpolationComboBox.Items.Add("なし"); } dimensionComboBox.SelectedIndex = 0; interpolationComboBox.SelectedIndex = 0; } //適用ボタン押下時のイベント void applyButton_Click(object sentder, EventArgs e) { try { if (propertyComboBox.SelectedIndex > 0) { int keyframeRate = 0; int oct = 0; double amp = 0.0; double startTime = 0.0; double endTime = 0.0; ILayer tl = null; IEffect te = null; Func<double, PropertyBase> propertyGetter = null; if (!int.TryParse(keyframeTextBox.Text, out keyframeRate)) { MessageBox.Show("間隔の値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!int.TryParse(octTextBox.Text, out oct)) { MessageBox.Show("複雑度の値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!double.TryParse(ampTextBox.Text, out amp)) { MessageBox.Show("強さの値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!double.TryParse(startTimeTextBox.Text, out startTime)) { MessageBox.Show("開始時間の値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (!double.TryParse(endTimeTextBox.Text, out endTime)) { MessageBox.Show("終了時間の値が異常です", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (keyframeRate < 1) { MessageBox.Show("間隔の値を0以下にすることは出来ません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (oct < 1 || oct > 100) { MessageBox.Show("複雑度の値を0以下、または100以上にすることは出来ません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (amp == 0.0) { MessageBox.Show("強さの値を0にすることは出来ません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (startTime > endTime) { MessageBox.Show("開始時間を終了時間より大きくすることは出来ません。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (startTime == endTime) { MessageBox.Show("開始時間と終了時間を同じにすることは出来ません。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } tl = layer[layerComboBox.SelectedIndex - 1]; //対象が"レイヤー"の場合は(ry if (targetComboBox.SelectedIndex > 1) { te = effect[targetComboBox.SelectedIndex - 2]; propertyGetter = new Func<double, PropertyBase>(delegate(double x) { return m.GetProperty(te, propertyName[propertyComboBox.SelectedIndex - 1], x); }); } else { propertyGetter = new Func<double, PropertyBase>(delegate(double x) { return m.GetProperty(tl, propertyName[propertyComboBox.SelectedIndex - 1], x); }); } //キーフレームを設定 SetWiggle(keyframeRate, oct, amp, startTime, endTime, dimensionComboBox.SelectedIndex, (PropertyInterpolationType)interpolationComboBox.SelectedItem, propertyData[propertyType[propertyName[propertyComboBox.SelectedIndex - 1]]].WiggleMethod, tl, te, propertyGetter); } else { MessageBox.Show("プロパティが選択されていません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("実行中にエラーが発生しました", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //閉じるボタン押下時のイベント void closeButton_Click(object sentder, EventArgs e) { this.Close(); } //コンポジション更新ボタン押下時のイベント void refreshCompositionButton_Click(object sentder, EventArgs e) { RefreshComposition(); } //コンボボックス、テキストボックスでEnterを押した場合は適用ボタンを押した事にする void _KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { applyButton.PerformClick(); } } void InitializeComponent() { this.SuspendLayout(); //各種ラベル Label label = new Label(); label.AutoSize = true; label.Text = "コンポジション:"; label.Location = new Point(12, 15); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "レイヤー:"; label.Location = new Point(36, 41); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "対象:"; label.Location = new Point(50, 67); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "プロパティ:"; label.Location = new Point(30, 93); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "次元:"; label.Location = new Point(50, 119); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "補間方法:"; label.Location = new Point(26, 145); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "間隔:"; label.Location = new Point(250, 15); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "個/秒"; label.Location = new Point(393, 15); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "複雑度:"; label.Location = new Point(238, 40); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "強さ:"; label.Location = new Point(254, 65); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "開始時間:"; label.Location = new Point(226, 90); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "秒"; label.Location = new Point(393, 90); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "終了時間:"; label.Location = new Point(226, 115); this.Controls.Add(label); label = new Label(); label.AutoSize = true; label.Text = "秒"; label.Location = new Point(393, 115); this.Controls.Add(label); //各種コンボボックス ComboBox comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 12); comboBox.Size = new Size(121, 20); comboBox.Name = ""; comboBox.SelectedIndexChanged += new EventHandler(compositionComboBox_SelectedIndexChanged); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); compositionComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 38); comboBox.Size = new Size(121, 20); comboBox.SelectedIndexChanged += new EventHandler(layerComboBox_SelectedIndexChanged); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); layerComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 64); comboBox.Size = new Size(121, 20); comboBox.SelectedIndexChanged += new EventHandler(targetComboBox_SelectedIndexChanged); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); targetComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 90); comboBox.Size = new Size(121, 20); comboBox.SelectedIndexChanged += new EventHandler(propertyComboBox_SelectedIndexChanged); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); propertyComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 116); comboBox.Size = new Size(121, 20); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); dimensionComboBox = comboBox; comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Location = new Point(87, 142); comboBox.Size = new Size(121, 20); comboBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(comboBox); interpolationComboBox = comboBox; //各種テキストボックス TextBox textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 12); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); keyframeTextBox = textBox; textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 37); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); octTextBox = textBox; textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 62); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); ampTextBox = textBox; textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 87); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); startTimeTextBox = textBox; textBox = new TextBox(); textBox.Size = new Size(100, 19); textBox.Location = new Point(287, 112); textBox.KeyDown += new KeyEventHandler(_KeyDown); this.Controls.Add(textBox); endTimeTextBox = textBox; //各種ボタン Button button = new Button(); button.Size = new Size(75, 23); button.Location = new Point(12, 177); button.Text = "適用"; button.Click += new EventHandler(applyButton_Click); this.Controls.Add(button); applyButton = button; button = new Button(); button.Size = new Size(75, 23); button.Location = new Point(93, 177); button.Text = "閉じる"; button.Click += new EventHandler(closeButton_Click); this.Controls.Add(button); button = new Button(); button.Size = new Size(120, 23); button.Location = new Point(174, 177); button.Text = "コンポジション更新"; button.Click += new EventHandler(refreshCompositionButton_Click); this.Controls.Add(button); this.ClientSize = new Size(440, 212); this.FormBorderStyle = FormBorderStyle.FixedToolWindow; this.MaximizeBox = false; this.MinimizeBox = false; this.ShowIcon = false; this.ShowInTaskbar = false; this.TopMost = true; this.Text = "ウィグル"; this.ResumeLayout(false); this.PerformLayout(); } } [UsingNamespace] NiVE2.CodeDom.Expression }} ~ // - effectPaddingの宣言行がコロンで終わっていたので勝手ながらセミコロンに修正しました。また、どうもコード表示で不等号の扱いにクセがあるようで、Dictionary型のpropertyDataなどの宣言や初期化が死んでます。不等号のあとに半角スペースを入れるようにすれば問題ないようですが、他にも何かあるようで、ブラウザからそのままメモ帳にコピペしても動作せず、編集画面を開いてコピーしないと動かないようです。if文とかでも不等号のあとにスペースをあけずに変数を書いてしまうとおかしくなってしまうようです。 -- [[金の髭]] &new{2010-12-13 (月) 07:04:05}; - 報告&修正ありがとうございます。codeプラグインの方を修正して不等号を&nop(<);などの特殊文字で置き換えるようにしてみました。コードをテキストに保存して読み込んでも動かない件についてですが、テキストファイルからのオートメーションの読み込みがUTF-8のみに対応しているため、それ以外の文字コードで書かれたものが文字化けしているためではないかと思われます。 -- [[うp主]] &new{2010-12-13 (月) 08:42:30}; - 対応ありがとうございます。ちょっと調べてみましたが、空行に必ず半角スペースが入っているので、名前空間や参照に半角スペースの行が入ってしまい、エラーになるようです。こちらも対応できるでしょうか?というかここまで試してから報告すべきでしたね。何度もすみません。orz -- [[金の髭]] &new{2010-12-13 (月) 13:29:31}; - すみませんといいながら更にもう1つ・・・。質問箱などのように、投稿ごとにリンクというかラベルがつくようになると嬉しいです。 -- [[金の髭]] &new{2010-12-15 (水) 00:08:03}; - UI付きかっこいいです・・・今のところ金の髭さんのおっしゃる通りWikiからコピペするとスペースが入ってエラーを吐くようです。編集からコピペすると上手く動くようです。 -- [[K]] &new{2010-12-15 (水) 00:20:06}; - 空白行のスペースを追加しないようにしてみましたが、firefox関連のなんらかの問題の対策用に空白行にスペース追加されていたようなので、もしかするとこの変更によってfirefoxでレイアウトが崩れたりするという問題があるかもしれません。 -- [[うp主]] &new{2010-12-15 (水) 13:35:30}; - 対応ありがとうございます。お時間のある時で構いませんので記事ごとのリンク自動生成の件も対応していただければ幸いです。 -- [[金の髭]] &new{2010-12-15 (水) 22:32:52}; - とりあえず、原因とおぼしき部分は修正しましたが、なぜか最新の投稿のみアンカーがつかないようです。原因がわかり次第修正しますが、ちょっと時間がかかりそうです。 -- [[うp主]] &new{2010-12-16 (木) 03:19:05}; - ありがとうございます。色々すみません。 -- [[金の髭]] &new{2010-12-16 (木) 08:26:31}; #comment_kcaptcha **キネティックタイポグラフィーとかに使ってほしいオートメーション [#q3105411] >[[K]] (2010-12-08 (水) 01:42:02)~ ~ オートメーションなのですがここに書いてよろしいのでしょうか・・・~ ~ キネタイをやったとき歌詞などのテキストレイヤーを一行一行追加していくのがめんどくさくなったのでつくりました。~ ~ テキストファイルを読み込んで、各行に分割してテキストレイヤーを作ります。~ ~ 実行する前に~ MainCode直下の~ string compName = "Comp 2";~ の部分を追加したいコンポジション名に書き換えてください。~ ~ あと読み込めるテキストの改行コードはCrLfのみとしました。~ ~ 文字コードを判別するメソッドはまるまるパクリですw~ ~ #code(csharp, コード){{ [MethodCode] /// <summary> /// 文字コードを判別する /// </summary> /// <remarks> /// Jcode.pmのgetcodeメソッドを移植したものです。 /// Jcode.pm(http://openlab.ring.gr.jp/Jcode/index-j.html) /// Jcode.pmのCopyright: Copyright 1999-2005 Dan Kogai /// </remarks> /// <param name="byts">文字コードを調べるデータ</param> /// <returns>適当と思われるEncodingオブジェクト。 /// 判断できなかった時はnull。</returns> System.Text.Encoding GetCode(byte[] bytes) { const byte bEscape = 0x1B; const byte bAt = 0x40; const byte bDollar = 0x24; const byte bAnd = 0x26; const byte bOpen = 0x28; //'(' const byte bB = 0x42; const byte bD = 0x44; const byte bJ = 0x4A; const byte bI = 0x49; int len = bytes.Length; byte b1, b2, b3, b4; //Encode::is_utf8 は無視 bool isBinary = false; for (int i = 0; i < len; i++) { b1 = bytes[i]; if (b1 <= 0x06 || b1 == 0x7F || b1 == 0xFF) { //'binary' isBinary = true; if (b1 == 0x00 && i < len - 1 && bytes[i + 1] <= 0x7F) { //smells like raw unicode return System.Text.Encoding.Unicode; } } } if (isBinary) { return null; } //not Japanese bool notJapanese = true; for (int i = 0; i < len; i++) { b1 = bytes[i]; if (b1 == bEscape || 0x80 <= b1) { notJapanese = false; break; } } if (notJapanese) { return System.Text.Encoding.ASCII; } for (int i = 0; i < len - 2; i++) { b1 = bytes[i]; b2 = bytes[i + 1]; b3 = bytes[i + 2]; if (b1 == bEscape) { if (b2 == bDollar && b3 == bAt) { //JIS_0208 1978 //JIS return System.Text.Encoding.GetEncoding(50220); } else if (b2 == bDollar && b3 == bB) { //JIS_0208 1983 //JIS return System.Text.Encoding.GetEncoding(50220); } else if (b2 == bOpen && (b3 == bB || b3 == bJ)) { //JIS_ASC //JIS return System.Text.Encoding.GetEncoding(50220); } else if (b2 == bOpen && b3 == bI) { //JIS_KANA //JIS return System.Text.Encoding.GetEncoding(50220); } if (i < len - 3) { b4 = bytes[i + 3]; if (b2 == bDollar && b3 == bOpen && b4 == bD) { //JIS_0212 //JIS return System.Text.Encoding.GetEncoding(50220); } if (i < len - 5 && b2 == bAnd && b3 == bAt && b4 == bEscape && bytes[i + 4] == bDollar && bytes[i + 5] == bB) { //JIS_0208 1990 //JIS return System.Text.Encoding.GetEncoding(50220); } } } } //should be euc|sjis|utf8 //use of (?:) by Hiroki Ohzaki <ohzaki@iod.ricoh.co.jp> int sjis = 0; int euc = 0; int utf8 = 0; for (int i = 0; i < len - 1; i++) { b1 = bytes[i]; b2 = bytes[i + 1]; if (((0x81 <= b1 && b1 <= 0x9F) || (0xE0 <= b1 && b1 <= 0xFC)) && ((0x40 <= b2 && b2 <= 0x7E) || (0x80 <= b2 && b2 <= 0xFC))) { //SJIS_C sjis += 2; i++; } } for (int i = 0; i < len - 1; i++) { b1 = bytes[i]; b2 = bytes[i + 1]; if (((0xA1 <= b1 && b1 <= 0xFE) && (0xA1 <= b2 && b2 <= 0xFE)) || (b1 == 0x8E && (0xA1 <= b2 && b2 <= 0xDF))) { //EUC_C //EUC_KANA euc += 2; i++; } else if (i < len - 2) { b3 = bytes[i + 2]; if (b1 == 0x8F && (0xA1 <= b2 && b2 <= 0xFE) && (0xA1 <= b3 && b3 <= 0xFE)) { //EUC_0212 euc += 3; i += 2; } } } for (int i = 0; i < len - 1; i++) { b1 = bytes[i]; b2 = bytes[i + 1]; if ((0xC0 <= b1 && b1 <= 0xDF) && (0x80 <= b2 && b2 <= 0xBF)) { //UTF8 utf8 += 2; i++; } else if (i < len - 2) { b3 = bytes[i + 2]; if ((0xE0 <= b1 && b1 <= 0xEF) && (0x80 <= b2 && b2 <= 0xBF) && (0x80 <= b3 && b3 <= 0xBF)) { //UTF8 utf8 += 3; i += 2; } } } //M. Takahashi's suggestion //utf8 += utf8 / 2; System.Diagnostics.Debug.WriteLine( string.Format("sjis = {0}, euc = {1}, utf8 = {2}", sjis, euc, utf8)); if (euc > sjis && euc > utf8) { //EUC return System.Text.Encoding.GetEncoding(51932); } else if (sjis > euc && sjis > utf8) { //SJIS return System.Text.Encoding.GetEncoding(932); } else if (utf8 > euc && utf8 > sjis) { //UTF8 return System.Text.Encoding.UTF8; } return null; } // ---------------------------------------------------------- // ◆テキスト入力ダイアログを表示し指定したテキストファイルを読み込む。 // ○返り値 // 取得されたテキストファイルの内容 // // ---------------------------------------------------------- String GetTextFile(){ //最後に返り値を入れる用 string retStr= ""; //ファイル入力ダイアログのインスタンス化 OpenFileDialog ofd = new OpenFileDialog(); //タイトルの設定 ofd.Title = "改行分割するテキストファイルを選択してください"; //ダイアログボックスを閉じる前に現在のディレクトリを復元するようにする ofd.RestoreDirectory = true; //[ファイルの種類]に表示される選択肢を指定する ofd.Filter ="txt files (*.txt)|*.txt|All files (*.*)|*.*"; //[ファイルの種類]ではじめにtxt filesが選択されるようにする ofd.FilterIndex = 1; //ダイアログを表示する if (ofd.ShowDialog() == DialogResult.OK) { //OKボタンがクリックされたとき //選択されたファイルを読み取り専用で開く System.IO.Stream stream; stream = ofd.OpenFile(); if (stream != null) { //テキストファイルを開く System.IO.FileStream fs = new System.IO.FileStream(ofd.FileName, System.IO.FileMode.Open,System.IO.FileAccess.Read); byte[] bs = new byte[fs.Length]; //byte配列に読み込む fs.Read(bs, 0, bs.Length); fs.Close(); //文字コードを取得する System.Text.Encoding enc = GetCode(bs); //デコードして返り値を退避 retStr = enc.GetString(bs); } } //返す return retStr; } // ---------------------------------------------------------- // ◆指定したコンポジション名を持つコンポジションの取得 // ○引数 // IComposition[] comps // 比較するコンポジション配列 // // string compName // テキストレイヤーを追加したいコンポジション名(指定したコンポジション名) // // ○返り値 // 指定したコンポジション名(compName)と同名のコンポジション // // ---------------------------------------------------------- IComposition GetTargetComp(IComposition[] comps,string compName) { // 指定コンポジション名を持つコンポジションの添え字を取得 int compNum = 0; for (int i = 0; i < comps.Length; i++) { if (compName == comps[i].Setting.Name) { compNum = i; break; } } return comps[compNum]; } // ---------------------------------------------------------- // ◆テキストレイヤーを追加し引数のstring(lyric)をリネーム、ソーステキストに設定 // ○引数 // IAutomationManager manager // これ渡さないとうごかないので。 // // IComposition targetComp // 追加対象のコンポジション // // string lyric // リネーム、ソーステキストにプロパティを追加する歌詞(lyric) // // ○返り値 // なし、コンポジションにレイヤーが追加される // ---------------------------------------------------------- void SetTextLayer(IAutomationManager manager, IComposition targetComp,string lyric) { //テキストレイヤーを作成しtextLayerに入れる ILayer textLayer = manager.AddText(targetComp); //レイヤー名を歌詞にする manager.ChangeLayerName(textLayer,lyric); //テキストレイヤーのテキストに歌詞を入れる StringProperty strp = new StringProperty("ソーステキスト",lyric ); KeyFrame strk = new KeyFrame(0, strp, PropertyInterpolationType.None); manager.AddKeyFrame(textLayer, strk); } [MainCode] // 注意:実行前に入力すること! // コンポジション名 string compName = "Comp 2"; // テキストファイルの内容取得 string lyric = GetTextFile(); //改行コード、デリミタの設定 char[] delimiterChars = { '\r', '\n'}; // テキストファイルの内容を配列に分割 string[] lyrics = lyric.Split(delimiterChars); // コンポジション配列取得 IComposition[] comps = manager.GetComposition(); // 対象のコンポジションの取得 IComposition targetComp = GetTargetComp(comps,compName); //テキストファイルの行数分だけループ for (int i=0; i < lyrics.Length; i++){ //lyrics[i]が空文字("")ならレイヤーを追加しない if(lyrics[i].Length!=0){ //テキストレイヤーの設置、リネームとプロパティの追加 SetTextLayer(manager, targetComp,lyrics[i]); } } //でばっぐよう //MessageBox.Show("テキスト"); }} ~ // - 長すぎですなwwwwごめんなさいw -- [[K]] &new{2010-12-08 (水) 01:42:50}; #comment_kcaptcha **クロスフェード [#q69ee8a6] > (2010-12-06 (月) 03:05:24)~ ~ このエクスプレッションをはりつけたレイヤー同士のかぶった部分に、自動でクロスフェードをかけます。かならずフェードアウトするレイヤーのひとつ下に、フェードインするレイヤーをおいてください。~ デフォルトでは、フェードインするレイヤーは実際にはフェードイン処理していません。透明部分があるレイヤーがフェードアウトする場合は、フェードインする側のレイヤーのエクスプレッションのfadeinの値をtrueに変更してみてください。~ ~ #code(csharp){{ [MainCode] //フェードインはデフォルトで無効(有効にするときはfalseをtrueに変更する) bool fadein = false; // エフェクトの不透明度のプロパティを取得 NumberProperty opaque = (NumberProperty)property.GetProperty(thisItem, "不透明度"); // クロスフェードさせる相手レイヤーを探す // (自分のレイヤーの上下のレイヤーを探すだけ) ILayer layer = (ILayer)thisItem; ILayer fin = null, fout = null; ILayer[] ls = layer.Composition.GetLayer(); for (int i = 0; i < ls.Length; i++) { if (ls[i].Equals(layer) == true) { if (i > 0) fout = ls[i - 1]; if (i < ls.Length - 1) fin = ls[i + 1]; break; } } // クロスフェード処理 // ワールド時間を求める double wtime = layer.ToWorldTime(time); // レイヤーの開始・終了時間のワールド時間を求める double start = layer.Position + layer.InPoint; double end = layer.Position + layer.OutPoint; // フェードイン if (fout != null && fadein == true) { // 相手レイヤーの開始・終了時間のワールド時間を求める double fstart = fout.Position + fout.InPoint; double fend = fout.Position + fout.OutPoint; // 重なっている部分があったらフェードイン処理 if (start < fend && wtime < fend) opaque.DoubleValue = (wtime - start) / (fend - start) * 100; } // フェードアウト if (fin != null) { // 相手レイヤーの開始・終了時間のワールド時間を求める double fstart = fin.Position + fin.InPoint; double fend = fin.Position + fin.OutPoint; // 重なっている部分があったらフェードアウト処理 if (fstart < end && fstart < wtime) opaque.DoubleValue = (end - wtime) / (end - fstart) * 100; } // 0-100に丸める opaque.DoubleValue = Math.Max(Math.Min(opaque.DoubleValue, 100), 0); // 変更したプロパティを反映 property.SetProperty(thisItem, opaque); }} ~ // #comment_kcaptcha **フェードイン・フェードアウト [#r46e6c8d] > (2010-12-05 (日) 21:22:48)~ ~ 不透明度のパラメータが存在するエフェクトまたはレイヤーの開始点から、終了点までの1秒にフェード処理を行います。~ ~ #code(csharp){{ [MainCode] // フェードイン・フェードアウトにかかる時間(秒) double fadeinterval = 1.0; ILayer layer; if (thisItem is IEffect) { // このエクスプレッションはエフェクトに適用されている // エフェクトのあるレイヤーの情報を取得 IExpressionItem thisLayer = thisItem.ParentItem; layer = (ILayer)thisLayer; } else { // このエクスプレッションはレイヤーに適用されている layer = (ILayer)thisItem; } // エフェクトの不透明度のプロパティを取得 NumberProperty opaque = (NumberProperty)property.GetProperty(thisItem, "不透明度"); // フェードイン処理 if (layer.InPoint + fadeinterval > time) opaque.DoubleValue = (time - layer.InPoint) / fadeinterval * 100; // フェードアウト処理 if (layer.OutPoint - fadeinterval < time) opaque.DoubleValue = (layer.OutPoint - time) / fadeinterval * 100; // 変更したプロパティを反映 property.SetProperty(thisItem, opaque); }} ~ // #comment_kcaptcha **サンプルいくつか [#b4b29e7d] >[[うp主]] (2010-12-05 (日) 16:39:09)~ ~ 投稿テストもかねていくつか。~ ~ レイヤーの位置にWiggleを掛ける~ #code(csharp){{ [MainCode] //ランダムシード int seed = thisItem.GetHashCode(); //複雑度 int oct = 6; //振幅 Vertex amp = new Vertex(100.0, 100.0, 100.0); //振動の速度 double speed = 15.0; //展開 float x = (float)((time * speed) % 360.0); //位置のプロパティ VertexProperty position = (VertexProperty)property.GetProperty(thisItem, "位置"); //ExpressionUtils.Wiggleを使って振動させる position.VertexValue = ExpressionUtils.Wiggle(seed, x, oct, position.VertexValue, amp); property.SetProperty(thisItem, position); }} ~ イージングを適用しつつ移動~ #code(csharp){{ [MainCode] //位置のプロパティ VertexProperty position = (VertexProperty)property.GetProperty(thisItem, "位置"); //開始時間 double startTime = 0.0; //終了時間 double endTime = 2.0; //開始位置 Vertex startPosition = position.VertexValue; //終了位置 Vertex endPosition = Vertex.Add(startPosition, new Vertex(640.0, 480.0, 0.0)); //加速度 double ease = 2.0; position.VertexValue = ExpressionUtils.Ease(startTime, startPosition, endTime, endPosition, time, ease); property.SetProperty(thisItem, position); }} ~ コンポジション内のレイヤーを円運動させる~ #code(csharp){{ [MainCode] //このコンポジション内の全てのレイヤー ILayer[] layer = ((IComposition)thisItem.ParentItem).GetLayer(); //レイヤーごとの開始角度 double rad = 360.0 / (double)(layer.Length - 1); //円の半径 Vertex radius = new Vertex(0.0, 200.0, 0.0); //各軸それぞれの回転 double xMove = time * 180.0; double yMove = time * 180.0; double zMove = time * 90.0; //位置計算用の行列 Matrix4D matrix = new Matrix4D(); for (int i = 0, c = 0; i < layer.Length; i++) { //Nullオブジェクトやカメラなどを除く if (!layer[i].IsSpecialItem) { //行列を初期化 matrix.LoadIdentity(); //回転 matrix.Rotate(xMove, yMove, rad * i + zMove, true); VertexProperty pos = (VertexProperty)property.GetProperty(layer[i], "位置"); pos.VertexValue = Vertex.Add(pos.VertexValue, matrix.Transform(radius)); property.SetProperty(layer[i], pos); c++; } } }} ~ // - 追記: 円運動のエクスプレッションを使用する際は、Nullオブジェクトかなにかをコンポジションの一番下において、そこにエクスプレッションをコピペして下さい。 -- [[うp主]] &new{2010-12-05 (日) 16:50:29}; - カメラを400x300x0から400x300x-1000までイージングを適用しつつ移動させたいんですが、上記のコードをコピペして適宜位置の値を変えて使えばよろしいのでしょうか? -- &new{2010-12-12 (日) 23:08:00}; #comment_kcaptcha **てすと [#z773fcc9] > (2010-12-05 (日) 16:17:23)~ ~ テスト~ #code(csharp){{ //test namespace Test { class TestClass { static void Main(string[] args) { System.Windows.Forms.MessageBox("Hello World!"); } } } }} ~ // #comment_kcaptcha
テキスト整形のルールを表示する