サンプルコード
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
* サンプルコード [#nf978271]
> エクスプレッション、オートメーションのサンプルコードを...
> ''投稿者の方へ''&br;
投稿時は、下記の書式に従って記述して下さい。&br;
~#code(言語名){{
~//ここにコードを記述
~}}
&br;
言語名に関しては、オートメーション、エクスプレッションはc...
&br;&br;
また、長いコードは&br;
~#code(言語名, コード)
&br;&br;
の様に言語名の後に適当な名前を指定するとコードを折りたた...
&br;
※投稿時にはコード種別(オートメーションなのかエクスプレッ...
※オートメーションの場合は「保存」でテキスト形式で保存し、...
※エクスプレッションの場合は「エクスプレッションの保存」で...
> ''投稿されたコードを使用しようと考えている方へ''&br;
エクスプレッション、オートメーションは、ある程度NiVEの操...
これらの使用方法については、付属の「エクスプレッション・...
&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%E...
よろしくお願いします。~
~
//
#comment_kcaptcha
**プロパティスクリプト投稿テスト
>[[うp主]] (2011-02-21 (月) 18:40:24)~
~
プロパティスクリプトのサンプルのテスト。~
開始や終了を1フレームごとに1文字分変化させるのに便利な感...
~
#code(propertyscript){{
return 100.0 / strLen(replace(getProperty("ソーステキスト...
}}
~
//
#comment_kcaptcha
**レンダラの選択サンプル [#s0a7822b]
>[[うp主]] (2011-02-09 (水) 14:36:03)~
~
オートメーションでのレンダラの選択について質問があったの...
~
#code(csharp,rendererSelectSample){{
[MainCode]
using (RendererSelectWindow window = new RendererSelectWi...
{
if (window.ShowDialog() == DialogResult.OK)
{
manager.NewComposition("", new CompositionSetting...
}
}
[MethodCode]
class RendererSelectWindow : Form
{
public RendererSelectWindow(IAutomationManager manager)
{
InitializeComponent();
//プラグイン名取得
renderer = new Dictionary<string, string>();
foreach (KeyValuePair<string, Type> plugin in man...
{
using (RendererBase r = (RendererBase)Activat...
{
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.Sele...
}
}
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.Dr...
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.CenterPare...
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(~);を挟んでもインデントは解除...
- codeプラグインの方に手を加えてregionプラグインを使用せ...
- 上の例でうまくいくことを確認しました。対応ありがとうご...
#comment_kcaptcha
**ウィグル適用ウインドウ [#gbad8610]
>[[うp主]] (2010-12-12 (日) 13:17:57)~
~
指定したプロパティにウィグルを適用し、キーフレームを設定...
~
使い方:~
各コンボボックスから適用したいものを選択します。~
間隔、複雑度、強さ、開始時間、終了時間を入力し、適用を押...
~
パラメータの説明:~
対象 : プロパティを所持するエフェクト、またはレイヤー...
次元 : 値を適用する次元(軸)を選択します。~
間隔 : 1秒間にキーフレームをいくつ置くかを設定します。~
複雑度 : 振動の激しさを設定します。~
強さ : 値の変化の度合いを設定します。~
開始時間: キーフレームの設置を開始する時間をレイヤーのロ...
終了時間: キーフレームの設置を終了する時間をレイヤーのロ...
適用 : 設定を元にキーフレームを設定します。~
閉じる : ウインドウを閉じます。~
コンポジション更新: コンポジションの情報を更新します。~
これ以外のコンボボックス: 見たままなので略。~
~
以下コード。長め注意~
~
#code(csharp, コード){{
[MainCode]
WiggleSettingWindow window = new WiggleSettingWindow(mana...
window.Show();
[MethodCode]
//ウィグル用メソッドのデリゲート
delegate PropertyBase WiggleMethod(PropertyBase property,...
//各プロパティで対応する次元とウィグル用メソッドを格納す...
class PropertyData
{
public PropertyData(string[] dim, WiggleMethod method...
{
Type = type;
DimensionName = dim;
WiggleMethod = method;
}
public PropertyInterpolationType Type = default(Prope...
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 Prop...
propertyData.Add(typeof(RadianProperty), new Prop...
propertyData.Add(typeof(VertexProperty), new Prop...
//対応する型を増やす場合はここ以下に記述する
//書式:
//propertyData.Add(typeof(対応する型), new Proper...
//例:
//propertyData.Add(typeof(ColorProperty), new Pro...
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]....
}
compositionComboBox.SelectedIndex = 0;
}
//NumberProperty用ウィグルメソッド
PropertyBase WiggleNumberProperty(PropertyBase proper...
{
NumberProperty np = (NumberProperty)property;
np.DoubleValue = ExpressionUtils.Wiggle(seed, x, ...
return property;
}
//RadianProperty用ウィグルメソッド
PropertyBase WiggleRadianProperty(PropertyBase proper...
{
RadianProperty rp = (RadianProperty)property;
return new RadianProperty(rp.PropertyName, 0, Exp...
return property;
}
//VertexProperty用ウィグルメソッド
//次元についてはコンストラクタ、またはメソッド内で使...
PropertyBase WiggleVertexProperty(PropertyBase proper...
{
VertexProperty vp = (VertexProperty)property;
switch(dimension)
{
case 0:
{
vp.X = ExpressionUtils.Wiggle(seed, x...
break;
}
case 1:
{
vp.Y = ExpressionUtils.Wiggle(seed, x...
break;
}
case 2:
{
vp.Z = ExpressionUtils.Wiggle(seed, x...
break;
}
case 3:
{
vp.VertexValue = ExpressionUtils.Wigg...
break;
}
case 4:
{
double w = ExpressionUtils.Wiggle(see...
vp.X += w;
vp.Y += w;
vp.Z += w;
break;
}
}
return property;
}
//対応する型のウィグル用メソッドを追加する。書式はWig...
//例:
//PropertyBase WiggleColorProperty(PropertyBase prope...
//{
// ColorProperty cp = (ColorProperty)property;
// switch(dimension)
// {
// case 0:
// {
// cp.R = (byte)Math.Min(Math.Max(Expr...
// break;
// }
// case 1:
// {
// cp.G = (byte)Math.Min(Math.Max(Expr...
// break;
// }
// case 2:
// {
// cp.B = (byte)Math.Min(Math.Max(Expr...
// break;
// }
// case 3:
// {
// cp.A = (byte)Math.Min(Math.Max(Expr...
// break;
// }
// case 4:
// {
// double w = ExpressionUtils.Wiggle(s...
// cp.R = (byte)Math.Min(Math.Max(cp.R...
// cp.G = (byte)Math.Min(Math.Max(cp.G...
// cp.B = (byte)Math.Min(Math.Max(cp.B...
// break;
// }
// case 5:
// {
// double w = ExpressionUtils.Wiggle(s...
// cp.R = (byte)Math.Min(Math.Max(cp.R...
// cp.G = (byte)Math.Min(Math.Max(cp.G...
// cp.B = (byte)Math.Min(Math.Max(cp.B...
// cp.A = (byte)Math.Min(Math.Max(cp.A...
// break;
// }
// }
//
// return property;
//}
//キーフレームを設定する
void SetWiggle(int keyframeRate, int oct, double amp,...
{
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...
keyFrame[i] = new KeyFrame(time, wiggle(p...
}
//対象が入力・レイヤープロパティの場合はtarge...
if (targetEffect != null)
{
for (int i = 0; i < count; i++)
{
m.AddKeyFrame(targetEffect, keyFrame[...
}
}
else
{
for (int i = 0; i < count; i++)
{
m.AddKeyFrame(targetLayer, keyFrame[i...
}
}
}
}
//コンポジション選択時のイベント
void compositionComboBox_SelectedIndexChanged(object ...
{
layer = null;
layerComboBox.Items.Clear();
layerComboBox.Items.Add("なし");
try
{
if (compositionComboBox.SelectedIndex > 0)
{
//レイヤーを取得
layer = composition[compositionComboBox.S...
for (int i = 0; i < layer.Length; i++)
{
layerComboBox.Items.Add(layer[i].Item...
}
}
}
catch { }
layerComboBox.SelectedIndex = 0;
}
//レイヤー選択時のイベント
void layerComboBox_SelectedIndexChanged(object sender...
{
effect = null;
targetComboBox.Items.Clear();
targetComboBox.Items.Add("なし");
if (layer != null && layerComboBox.SelectedIndex ...
{
targetComboBox.Items.Add("レイヤー");
//エフェクトを取得
effect = layer[layerComboBox.SelectedIndex - ...
for (int i = 0; i < effect.Length; i++)
{
targetComboBox.Items.Add(effect[i].ItemNa...
}
}
targetComboBox.SelectedIndex = 0;
}
//対象選択時のイベント
void targetComboBox_SelectedIndexChanged(object sende...
{
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.Select...
propertyName = m.GetPropertyNames(se);
for (int i = 0; i < propertyName.Length; ...
{
PropertyBase p = m.GetProperty(se, pr...
//ウィグルに対応するプロパティのみを...
if (p != null && propertyData.Contain...
{
propertyType.Add(propertyName[i],...
}
}
}
else
{
//対象のレイヤー
ILayer sl = layer[layerComboBox.SelectedI...
propertyName = m.GetPropertyNames(sl);
for (int i = 0; i < propertyName.Length; ...
{
PropertyBase p = m.GetProperty(sl, pr...
//ウィグルに対応するプロパティのみを...
if (p != null && propertyData.Contain...
{
propertyType.Add(propertyName[i],...
}
}
}
//対応するプロパティの名前をコンボボックスに...
propertyName = new string[propertyType.Count];
propertyType.Keys.CopyTo(propertyName, 0);
propertyComboBox.Items.AddRange(propertyName);
}
propertyComboBox.SelectedIndex = 0;
}
//プロパティ選択時のイベント
void propertyComboBox_SelectedIndexChanged(object sen...
{
dimensionComboBox.Items.Clear();
interpolationComboBox.Items.Clear();
//対応する次元と補間タイプを表示
if (propertyComboBox.SelectedIndex > 0)
{
PropertyData sp = propertyData[propertyType[p...
dimensionComboBox.Items.AddRange(sp.Dimension...
if ((sp.Type & PropertyInterpolationType.Fixe...
{
interpolationComboBox.Items.Add(PropertyI...
}
if ((sp.Type & PropertyInterpolationType.Line...
{
interpolationComboBox.Items.Add(PropertyI...
}
if ((sp.Type & PropertyInterpolationType.Catm...
{
interpolationComboBox.Items.Add(PropertyI...
}
}
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...
if (!int.TryParse(keyframeTextBox.Text, o...
{
MessageBox.Show("間隔の値が異常です",...
return;
}
else if (!int.TryParse(octTextBox.Text, o...
{
MessageBox.Show("複雑度の値が異常です...
return;
}
else if (!double.TryParse(ampTextBox.Text...
{
MessageBox.Show("強さの値が異常です",...
return;
}
else if (!double.TryParse(startTimeTextBo...
{
MessageBox.Show("開始時間の値が異常で...
return;
}
else if (!double.TryParse(endTimeTextBox....
{
MessageBox.Show("終了時間の値が異常で...
return;
}
else if (keyframeRate < 1)
{
MessageBox.Show("間隔の値を0以下にす...
return;
}
else if (oct < 1 || oct > 100)
{
MessageBox.Show("複雑度の値を0以下、...
return;
}
else if (amp == 0.0)
{
MessageBox.Show("強さの値を0にするこ...
return;
}
else if (startTime > endTime)
{
MessageBox.Show("開始時間を終了時間よ...
return;
}
else if (startTime == endTime)
{
MessageBox.Show("開始時間と終了時間を...
return;
}
tl = layer[layerComboBox.SelectedIndex - ...
//対象が"レイヤー"の場合は(ry
if (targetComboBox.SelectedIndex > 1)
{
te = effect[targetComboBox.SelectedIn...
propertyGetter = new Func<double, Pro...
}
else
{
propertyGetter = new Func<double, Pro...
}
//キーフレームを設定
SetWiggle(keyframeRate, oct, amp, startTi...
}
else
{
MessageBox.Show("プロパティが選択されてい...
}
}
catch
{
MessageBox.Show("実行中にエラーが発生しました...
}
}
//閉じるボタン押下時のイベント
void closeButton_Click(object sentder, EventArgs e)
{
this.Close();
}
//コンポジション更新ボタン押下時のイベント
void refreshCompositionButton_Click(object sentder, 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.DropDownLi...
comboBox.Location = new Point(87, 12);
comboBox.Size = new Size(121, 20);
comboBox.Name = "";
comboBox.SelectedIndexChanged += new EventHandler...
comboBox.KeyDown += new KeyEventHandler(_KeyDown);
this.Controls.Add(comboBox);
compositionComboBox = comboBox;
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownLi...
comboBox.Location = new Point(87, 38);
comboBox.Size = new Size(121, 20);
comboBox.SelectedIndexChanged += new EventHandler...
comboBox.KeyDown += new KeyEventHandler(_KeyDown);
this.Controls.Add(comboBox);
layerComboBox = comboBox;
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownLi...
comboBox.Location = new Point(87, 64);
comboBox.Size = new Size(121, 20);
comboBox.SelectedIndexChanged += new EventHandler...
comboBox.KeyDown += new KeyEventHandler(_KeyDown);
this.Controls.Add(comboBox);
targetComboBox = comboBox;
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownLi...
comboBox.Location = new Point(87, 90);
comboBox.Size = new Size(121, 20);
comboBox.SelectedIndexChanged += new EventHandler...
comboBox.KeyDown += new KeyEventHandler(_KeyDown);
this.Controls.Add(comboBox);
propertyComboBox = comboBox;
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownLi...
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.DropDownLi...
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_Clic...
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_Clic...
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(refreshCompositi...
this.Controls.Add(button);
this.ClientSize = new Size(440, 212);
this.FormBorderStyle = FormBorderStyle.FixedToolW...
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の宣言行がコロンで終わっていたので勝手なが...
- 報告&修正ありがとうございます。codeプラグインの方を修正...
- 対応ありがとうございます。ちょっと調べてみましたが、空...
- すみませんといいながら更にもう1つ・・・。質問箱などの...
- UI付きかっこいいです・・・今のところ金の髭さんのおっし...
- 空白行のスペースを追加しないようにしてみましたが、firef...
- 対応ありがとうございます。お時間のある時で構いませんの...
- とりあえず、原因とおぼしき部分は修正しましたが、なぜか...
- ありがとうございます。色々すみません。 -- [[金の髭]] &n...
#comment_kcaptcha
**キネティックタイポグラフィーとかに使ってほしいオートメ...
>[[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]...
{
//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(5...
}
else if (b2 == bDollar && b3 == bB)
{
//JIS_0208 1983
//JIS
return System.Text.Encoding.GetEncoding(5...
}
else if (b2 == bOpen && (b3 == bB || b3 == bJ))
{
//JIS_ASC
//JIS
return System.Text.Encoding.GetEncoding(5...
}
else if (b2 == bOpen && b3 == bI)
{
//JIS_KANA
//JIS
return System.Text.Encoding.GetEncoding(5...
}
if (i < len - 3)
{
b4 = bytes[i + 3];
if (b2 == bDollar && b3 == bOpen && b4 ==...
{
//JIS_0212
//JIS
return System.Text.Encoding.GetEncodi...
}
if (i < len - 5 &&
b2 == bAnd && b3 == bAt && b4 == bEsc...
bytes[i + 4] == bDollar && bytes[i + ...
{
//JIS_0208 1990
//JIS
return System.Text.Encoding.GetEncodi...
}
}
}
}
//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 &&...
((0x40 <= b2 && b2 <= 0x7E) || (0x80 <= b2 &&...
{
//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 &&...
(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 && ...
{
//UTF8
utf8 += 2;
i++;
}
else if (i < len - 2)
{
b3 = bytes[i + 2];
if ((0xE0 <= b1 && b1 <= 0xEF) && (0x80 <= b2...
(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}"...
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...
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 co...
{
// 指定コンポジション名を持つコンポジションの添え字を取得
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
// リネーム、ソーステキストにプロパティを追加する歌詞(lyr...
//
// ○返り値
// なし、コンポジションにレイヤーが追加される
// ------------------------------------------------------...
void SetTextLayer(IAutomationManager manager, ICompositio...
{
//テキストレイヤーを作成しtextLayerに入れる
ILayer textLayer = manager.AddText(targetComp);
//レイヤー名を歌詞にする
manager.ChangeLayerName(textLayer,lyric);
//テキストレイヤーのテキストに歌詞を入れる
StringProperty strp = new StringProperty("ソーステキスト"...
KeyFrame strk = new KeyFrame(0, strp, PropertyInterpolati...
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...
#comment_kcaptcha
**クロスフェード [#q69ee8a6]
> (2010-12-06 (月) 03:05:24)~
~
このエクスプレッションをはりつけたレイヤー同士のかぶった...
デフォルトでは、フェードインするレイヤーは実際にはフェー...
~
#code(csharp){{
[MainCode]
//フェードインはデフォルトで無効(有効にするときはfalseをt...
bool fadein = false;
// エフェクトの不透明度のプロパティを取得
NumberProperty opaque = (NumberProperty)property.GetPrope...
// クロスフェードさせる相手レイヤーを探す
// (自分のレイヤーの上下のレイヤーを探すだけ)
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 - st...
}
// フェードアウト
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 - fstar...
}
// 0-100に丸める
opaque.DoubleValue = Math.Max(Math.Min(opaque.DoubleValue...
// 変更したプロパティを反映
property.SetProperty(thisItem, opaque);
}}
~
//
#comment_kcaptcha
**フェードイン・フェードアウト [#r46e6c8d]
> (2010-12-05 (日) 21:22:48)~
~
不透明度のパラメータが存在するエフェクトまたはレイヤーの...
~
#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.GetPrope...
// フェードイン処理
if (layer.InPoint + fadeinterval > time)
opaque.DoubleValue = (time - layer.InPoint) / fadeint...
// フェードアウト処理
if (layer.OutPoint - fadeinterval < time)
opaque.DoubleValue = (layer.OutPoint - time) / fadein...
// 変更したプロパティを反映
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.GetPro...
//ExpressionUtils.Wiggleを使って振動させる
position.VertexValue = ExpressionUtils.Wiggle(seed, x, oc...
property.SetProperty(thisItem, position);
}}
~
イージングを適用しつつ移動~
#code(csharp){{
[MainCode]
//位置のプロパティ
VertexProperty position = (VertexProperty)property.GetPro...
//開始時間
double startTime = 0.0;
//終了時間
double endTime = 2.0;
//開始位置
Vertex startPosition = position.VertexValue;
//終了位置
Vertex endPosition = Vertex.Add(startPosition, new Vertex...
//加速度
double ease = 2.0;
position.VertexValue = ExpressionUtils.Ease(startTime, st...
property.SetProperty(thisItem, position);
}}
~
コンポジション内のレイヤーを円運動させる~
#code(csharp){{
[MainCode]
//このコンポジション内の全てのレイヤー
ILayer[] layer = ((IComposition)thisItem.ParentItem).GetL...
//レイヤーごとの開始角度
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.Get...
pos.VertexValue = Vertex.Add(pos.VertexValue, mat...
property.SetProperty(layer[i], pos);
c++;
}
}
}}
~
//
- 追記: 円運動のエクスプレッションを使用する際は、Nullオ...
- カメラを400x300x0から400x300x-1000までイージングを適用...
#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;
言語名に関しては、オートメーション、エクスプレッションはc...
&br;&br;
また、長いコードは&br;
~#code(言語名, コード)
&br;&br;
の様に言語名の後に適当な名前を指定するとコードを折りたた...
&br;
※投稿時にはコード種別(オートメーションなのかエクスプレッ...
※オートメーションの場合は「保存」でテキスト形式で保存し、...
※エクスプレッションの場合は「エクスプレッションの保存」で...
> ''投稿されたコードを使用しようと考えている方へ''&br;
エクスプレッション、オートメーションは、ある程度NiVEの操...
これらの使用方法については、付属の「エクスプレッション・...
&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%E...
よろしくお願いします。~
~
//
#comment_kcaptcha
**プロパティスクリプト投稿テスト
>[[うp主]] (2011-02-21 (月) 18:40:24)~
~
プロパティスクリプトのサンプルのテスト。~
開始や終了を1フレームごとに1文字分変化させるのに便利な感...
~
#code(propertyscript){{
return 100.0 / strLen(replace(getProperty("ソーステキスト...
}}
~
//
#comment_kcaptcha
**レンダラの選択サンプル [#s0a7822b]
>[[うp主]] (2011-02-09 (水) 14:36:03)~
~
オートメーションでのレンダラの選択について質問があったの...
~
#code(csharp,rendererSelectSample){{
[MainCode]
using (RendererSelectWindow window = new RendererSelectWi...
{
if (window.ShowDialog() == DialogResult.OK)
{
manager.NewComposition("", new CompositionSetting...
}
}
[MethodCode]
class RendererSelectWindow : Form
{
public RendererSelectWindow(IAutomationManager manager)
{
InitializeComponent();
//プラグイン名取得
renderer = new Dictionary<string, string>();
foreach (KeyValuePair<string, Type> plugin in man...
{
using (RendererBase r = (RendererBase)Activat...
{
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.Sele...
}
}
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.Dr...
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.CenterPare...
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(~);を挟んでもインデントは解除...
- codeプラグインの方に手を加えてregionプラグインを使用せ...
- 上の例でうまくいくことを確認しました。対応ありがとうご...
#comment_kcaptcha
**ウィグル適用ウインドウ [#gbad8610]
>[[うp主]] (2010-12-12 (日) 13:17:57)~
~
指定したプロパティにウィグルを適用し、キーフレームを設定...
~
使い方:~
各コンボボックスから適用したいものを選択します。~
間隔、複雑度、強さ、開始時間、終了時間を入力し、適用を押...
~
パラメータの説明:~
対象 : プロパティを所持するエフェクト、またはレイヤー...
次元 : 値を適用する次元(軸)を選択します。~
間隔 : 1秒間にキーフレームをいくつ置くかを設定します。~
複雑度 : 振動の激しさを設定します。~
強さ : 値の変化の度合いを設定します。~
開始時間: キーフレームの設置を開始する時間をレイヤーのロ...
終了時間: キーフレームの設置を終了する時間をレイヤーのロ...
適用 : 設定を元にキーフレームを設定します。~
閉じる : ウインドウを閉じます。~
コンポジション更新: コンポジションの情報を更新します。~
これ以外のコンボボックス: 見たままなので略。~
~
以下コード。長め注意~
~
#code(csharp, コード){{
[MainCode]
WiggleSettingWindow window = new WiggleSettingWindow(mana...
window.Show();
[MethodCode]
//ウィグル用メソッドのデリゲート
delegate PropertyBase WiggleMethod(PropertyBase property,...
//各プロパティで対応する次元とウィグル用メソッドを格納す...
class PropertyData
{
public PropertyData(string[] dim, WiggleMethod method...
{
Type = type;
DimensionName = dim;
WiggleMethod = method;
}
public PropertyInterpolationType Type = default(Prope...
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 Prop...
propertyData.Add(typeof(RadianProperty), new Prop...
propertyData.Add(typeof(VertexProperty), new Prop...
//対応する型を増やす場合はここ以下に記述する
//書式:
//propertyData.Add(typeof(対応する型), new Proper...
//例:
//propertyData.Add(typeof(ColorProperty), new Pro...
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]....
}
compositionComboBox.SelectedIndex = 0;
}
//NumberProperty用ウィグルメソッド
PropertyBase WiggleNumberProperty(PropertyBase proper...
{
NumberProperty np = (NumberProperty)property;
np.DoubleValue = ExpressionUtils.Wiggle(seed, x, ...
return property;
}
//RadianProperty用ウィグルメソッド
PropertyBase WiggleRadianProperty(PropertyBase proper...
{
RadianProperty rp = (RadianProperty)property;
return new RadianProperty(rp.PropertyName, 0, Exp...
return property;
}
//VertexProperty用ウィグルメソッド
//次元についてはコンストラクタ、またはメソッド内で使...
PropertyBase WiggleVertexProperty(PropertyBase proper...
{
VertexProperty vp = (VertexProperty)property;
switch(dimension)
{
case 0:
{
vp.X = ExpressionUtils.Wiggle(seed, x...
break;
}
case 1:
{
vp.Y = ExpressionUtils.Wiggle(seed, x...
break;
}
case 2:
{
vp.Z = ExpressionUtils.Wiggle(seed, x...
break;
}
case 3:
{
vp.VertexValue = ExpressionUtils.Wigg...
break;
}
case 4:
{
double w = ExpressionUtils.Wiggle(see...
vp.X += w;
vp.Y += w;
vp.Z += w;
break;
}
}
return property;
}
//対応する型のウィグル用メソッドを追加する。書式はWig...
//例:
//PropertyBase WiggleColorProperty(PropertyBase prope...
//{
// ColorProperty cp = (ColorProperty)property;
// switch(dimension)
// {
// case 0:
// {
// cp.R = (byte)Math.Min(Math.Max(Expr...
// break;
// }
// case 1:
// {
// cp.G = (byte)Math.Min(Math.Max(Expr...
// break;
// }
// case 2:
// {
// cp.B = (byte)Math.Min(Math.Max(Expr...
// break;
// }
// case 3:
// {
// cp.A = (byte)Math.Min(Math.Max(Expr...
// break;
// }
// case 4:
// {
// double w = ExpressionUtils.Wiggle(s...
// cp.R = (byte)Math.Min(Math.Max(cp.R...
// cp.G = (byte)Math.Min(Math.Max(cp.G...
// cp.B = (byte)Math.Min(Math.Max(cp.B...
// break;
// }
// case 5:
// {
// double w = ExpressionUtils.Wiggle(s...
// cp.R = (byte)Math.Min(Math.Max(cp.R...
// cp.G = (byte)Math.Min(Math.Max(cp.G...
// cp.B = (byte)Math.Min(Math.Max(cp.B...
// cp.A = (byte)Math.Min(Math.Max(cp.A...
// break;
// }
// }
//
// return property;
//}
//キーフレームを設定する
void SetWiggle(int keyframeRate, int oct, double amp,...
{
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...
keyFrame[i] = new KeyFrame(time, wiggle(p...
}
//対象が入力・レイヤープロパティの場合はtarge...
if (targetEffect != null)
{
for (int i = 0; i < count; i++)
{
m.AddKeyFrame(targetEffect, keyFrame[...
}
}
else
{
for (int i = 0; i < count; i++)
{
m.AddKeyFrame(targetLayer, keyFrame[i...
}
}
}
}
//コンポジション選択時のイベント
void compositionComboBox_SelectedIndexChanged(object ...
{
layer = null;
layerComboBox.Items.Clear();
layerComboBox.Items.Add("なし");
try
{
if (compositionComboBox.SelectedIndex > 0)
{
//レイヤーを取得
layer = composition[compositionComboBox.S...
for (int i = 0; i < layer.Length; i++)
{
layerComboBox.Items.Add(layer[i].Item...
}
}
}
catch { }
layerComboBox.SelectedIndex = 0;
}
//レイヤー選択時のイベント
void layerComboBox_SelectedIndexChanged(object sender...
{
effect = null;
targetComboBox.Items.Clear();
targetComboBox.Items.Add("なし");
if (layer != null && layerComboBox.SelectedIndex ...
{
targetComboBox.Items.Add("レイヤー");
//エフェクトを取得
effect = layer[layerComboBox.SelectedIndex - ...
for (int i = 0; i < effect.Length; i++)
{
targetComboBox.Items.Add(effect[i].ItemNa...
}
}
targetComboBox.SelectedIndex = 0;
}
//対象選択時のイベント
void targetComboBox_SelectedIndexChanged(object sende...
{
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.Select...
propertyName = m.GetPropertyNames(se);
for (int i = 0; i < propertyName.Length; ...
{
PropertyBase p = m.GetProperty(se, pr...
//ウィグルに対応するプロパティのみを...
if (p != null && propertyData.Contain...
{
propertyType.Add(propertyName[i],...
}
}
}
else
{
//対象のレイヤー
ILayer sl = layer[layerComboBox.SelectedI...
propertyName = m.GetPropertyNames(sl);
for (int i = 0; i < propertyName.Length; ...
{
PropertyBase p = m.GetProperty(sl, pr...
//ウィグルに対応するプロパティのみを...
if (p != null && propertyData.Contain...
{
propertyType.Add(propertyName[i],...
}
}
}
//対応するプロパティの名前をコンボボックスに...
propertyName = new string[propertyType.Count];
propertyType.Keys.CopyTo(propertyName, 0);
propertyComboBox.Items.AddRange(propertyName);
}
propertyComboBox.SelectedIndex = 0;
}
//プロパティ選択時のイベント
void propertyComboBox_SelectedIndexChanged(object sen...
{
dimensionComboBox.Items.Clear();
interpolationComboBox.Items.Clear();
//対応する次元と補間タイプを表示
if (propertyComboBox.SelectedIndex > 0)
{
PropertyData sp = propertyData[propertyType[p...
dimensionComboBox.Items.AddRange(sp.Dimension...
if ((sp.Type & PropertyInterpolationType.Fixe...
{
interpolationComboBox.Items.Add(PropertyI...
}
if ((sp.Type & PropertyInterpolationType.Line...
{
interpolationComboBox.Items.Add(PropertyI...
}
if ((sp.Type & PropertyInterpolationType.Catm...
{
interpolationComboBox.Items.Add(PropertyI...
}
}
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...
if (!int.TryParse(keyframeTextBox.Text, o...
{
MessageBox.Show("間隔の値が異常です",...
return;
}
else if (!int.TryParse(octTextBox.Text, o...
{
MessageBox.Show("複雑度の値が異常です...
return;
}
else if (!double.TryParse(ampTextBox.Text...
{
MessageBox.Show("強さの値が異常です",...
return;
}
else if (!double.TryParse(startTimeTextBo...
{
MessageBox.Show("開始時間の値が異常で...
return;
}
else if (!double.TryParse(endTimeTextBox....
{
MessageBox.Show("終了時間の値が異常で...
return;
}
else if (keyframeRate < 1)
{
MessageBox.Show("間隔の値を0以下にす...
return;
}
else if (oct < 1 || oct > 100)
{
MessageBox.Show("複雑度の値を0以下、...
return;
}
else if (amp == 0.0)
{
MessageBox.Show("強さの値を0にするこ...
return;
}
else if (startTime > endTime)
{
MessageBox.Show("開始時間を終了時間よ...
return;
}
else if (startTime == endTime)
{
MessageBox.Show("開始時間と終了時間を...
return;
}
tl = layer[layerComboBox.SelectedIndex - ...
//対象が"レイヤー"の場合は(ry
if (targetComboBox.SelectedIndex > 1)
{
te = effect[targetComboBox.SelectedIn...
propertyGetter = new Func<double, Pro...
}
else
{
propertyGetter = new Func<double, Pro...
}
//キーフレームを設定
SetWiggle(keyframeRate, oct, amp, startTi...
}
else
{
MessageBox.Show("プロパティが選択されてい...
}
}
catch
{
MessageBox.Show("実行中にエラーが発生しました...
}
}
//閉じるボタン押下時のイベント
void closeButton_Click(object sentder, EventArgs e)
{
this.Close();
}
//コンポジション更新ボタン押下時のイベント
void refreshCompositionButton_Click(object sentder, 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.DropDownLi...
comboBox.Location = new Point(87, 12);
comboBox.Size = new Size(121, 20);
comboBox.Name = "";
comboBox.SelectedIndexChanged += new EventHandler...
comboBox.KeyDown += new KeyEventHandler(_KeyDown);
this.Controls.Add(comboBox);
compositionComboBox = comboBox;
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownLi...
comboBox.Location = new Point(87, 38);
comboBox.Size = new Size(121, 20);
comboBox.SelectedIndexChanged += new EventHandler...
comboBox.KeyDown += new KeyEventHandler(_KeyDown);
this.Controls.Add(comboBox);
layerComboBox = comboBox;
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownLi...
comboBox.Location = new Point(87, 64);
comboBox.Size = new Size(121, 20);
comboBox.SelectedIndexChanged += new EventHandler...
comboBox.KeyDown += new KeyEventHandler(_KeyDown);
this.Controls.Add(comboBox);
targetComboBox = comboBox;
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownLi...
comboBox.Location = new Point(87, 90);
comboBox.Size = new Size(121, 20);
comboBox.SelectedIndexChanged += new EventHandler...
comboBox.KeyDown += new KeyEventHandler(_KeyDown);
this.Controls.Add(comboBox);
propertyComboBox = comboBox;
comboBox = new ComboBox();
comboBox.DropDownStyle = ComboBoxStyle.DropDownLi...
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.DropDownLi...
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_Clic...
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_Clic...
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(refreshCompositi...
this.Controls.Add(button);
this.ClientSize = new Size(440, 212);
this.FormBorderStyle = FormBorderStyle.FixedToolW...
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の宣言行がコロンで終わっていたので勝手なが...
- 報告&修正ありがとうございます。codeプラグインの方を修正...
- 対応ありがとうございます。ちょっと調べてみましたが、空...
- すみませんといいながら更にもう1つ・・・。質問箱などの...
- UI付きかっこいいです・・・今のところ金の髭さんのおっし...
- 空白行のスペースを追加しないようにしてみましたが、firef...
- 対応ありがとうございます。お時間のある時で構いませんの...
- とりあえず、原因とおぼしき部分は修正しましたが、なぜか...
- ありがとうございます。色々すみません。 -- [[金の髭]] &n...
#comment_kcaptcha
**キネティックタイポグラフィーとかに使ってほしいオートメ...
>[[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]...
{
//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(5...
}
else if (b2 == bDollar && b3 == bB)
{
//JIS_0208 1983
//JIS
return System.Text.Encoding.GetEncoding(5...
}
else if (b2 == bOpen && (b3 == bB || b3 == bJ))
{
//JIS_ASC
//JIS
return System.Text.Encoding.GetEncoding(5...
}
else if (b2 == bOpen && b3 == bI)
{
//JIS_KANA
//JIS
return System.Text.Encoding.GetEncoding(5...
}
if (i < len - 3)
{
b4 = bytes[i + 3];
if (b2 == bDollar && b3 == bOpen && b4 ==...
{
//JIS_0212
//JIS
return System.Text.Encoding.GetEncodi...
}
if (i < len - 5 &&
b2 == bAnd && b3 == bAt && b4 == bEsc...
bytes[i + 4] == bDollar && bytes[i + ...
{
//JIS_0208 1990
//JIS
return System.Text.Encoding.GetEncodi...
}
}
}
}
//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 &&...
((0x40 <= b2 && b2 <= 0x7E) || (0x80 <= b2 &&...
{
//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 &&...
(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 && ...
{
//UTF8
utf8 += 2;
i++;
}
else if (i < len - 2)
{
b3 = bytes[i + 2];
if ((0xE0 <= b1 && b1 <= 0xEF) && (0x80 <= b2...
(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}"...
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...
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 co...
{
// 指定コンポジション名を持つコンポジションの添え字を取得
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
// リネーム、ソーステキストにプロパティを追加する歌詞(lyr...
//
// ○返り値
// なし、コンポジションにレイヤーが追加される
// ------------------------------------------------------...
void SetTextLayer(IAutomationManager manager, ICompositio...
{
//テキストレイヤーを作成しtextLayerに入れる
ILayer textLayer = manager.AddText(targetComp);
//レイヤー名を歌詞にする
manager.ChangeLayerName(textLayer,lyric);
//テキストレイヤーのテキストに歌詞を入れる
StringProperty strp = new StringProperty("ソーステキスト"...
KeyFrame strk = new KeyFrame(0, strp, PropertyInterpolati...
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...
#comment_kcaptcha
**クロスフェード [#q69ee8a6]
> (2010-12-06 (月) 03:05:24)~
~
このエクスプレッションをはりつけたレイヤー同士のかぶった...
デフォルトでは、フェードインするレイヤーは実際にはフェー...
~
#code(csharp){{
[MainCode]
//フェードインはデフォルトで無効(有効にするときはfalseをt...
bool fadein = false;
// エフェクトの不透明度のプロパティを取得
NumberProperty opaque = (NumberProperty)property.GetPrope...
// クロスフェードさせる相手レイヤーを探す
// (自分のレイヤーの上下のレイヤーを探すだけ)
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 - st...
}
// フェードアウト
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 - fstar...
}
// 0-100に丸める
opaque.DoubleValue = Math.Max(Math.Min(opaque.DoubleValue...
// 変更したプロパティを反映
property.SetProperty(thisItem, opaque);
}}
~
//
#comment_kcaptcha
**フェードイン・フェードアウト [#r46e6c8d]
> (2010-12-05 (日) 21:22:48)~
~
不透明度のパラメータが存在するエフェクトまたはレイヤーの...
~
#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.GetPrope...
// フェードイン処理
if (layer.InPoint + fadeinterval > time)
opaque.DoubleValue = (time - layer.InPoint) / fadeint...
// フェードアウト処理
if (layer.OutPoint - fadeinterval < time)
opaque.DoubleValue = (layer.OutPoint - time) / fadein...
// 変更したプロパティを反映
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.GetPro...
//ExpressionUtils.Wiggleを使って振動させる
position.VertexValue = ExpressionUtils.Wiggle(seed, x, oc...
property.SetProperty(thisItem, position);
}}
~
イージングを適用しつつ移動~
#code(csharp){{
[MainCode]
//位置のプロパティ
VertexProperty position = (VertexProperty)property.GetPro...
//開始時間
double startTime = 0.0;
//終了時間
double endTime = 2.0;
//開始位置
Vertex startPosition = position.VertexValue;
//終了位置
Vertex endPosition = Vertex.Add(startPosition, new Vertex...
//加速度
double ease = 2.0;
position.VertexValue = ExpressionUtils.Ease(startTime, st...
property.SetProperty(thisItem, position);
}}
~
コンポジション内のレイヤーを円運動させる~
#code(csharp){{
[MainCode]
//このコンポジション内の全てのレイヤー
ILayer[] layer = ((IComposition)thisItem.ParentItem).GetL...
//レイヤーごとの開始角度
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.Get...
pos.VertexValue = Vertex.Add(pos.VertexValue, mat...
property.SetProperty(layer[i], pos);
c++;
}
}
}}
~
//
- 追記: 円運動のエクスプレッションを使用する際は、Nullオ...
- カメラを400x300x0から400x300x-1000までイージングを適用...
#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
ページ名: