2011年12月14日水曜日

scriptのすすめ9 ~if文、spinner、radio button~ maxscript tips

日本語Ver張り忘れていました。。

Before I revise last code, I will show you how to use "if" and "else".
Here is a simple example.

a = 1
if a == 1 then
(
    print "a is one"
)
else
(
    print "a is not one"
)

--------------------------------------------------------------------------------------------------------------------------------------
when we want to separate some actions,we use if and else.
if you change "a = 1" to "a = 5","a is not one" will be printed on lisner.
So,this time I'll show you how to use "Spinner" and "radioButtons".

First let's make a radio button to choose geometry.
Here is an example.









rollout myUI "simpleUI"
(
    radiobuttons rb_type labels:#( "Box","Sphere","Teapot")
    spinner spn_size "Size:" range:[0, 10000, 25]

    button myBtn "Do!!" width:200 height:50
  
    on myBtn pressed do
    (
        if rb_type.state == 1 do
        (
            b = box length:spn_size.value  width:spn_size.value height:spn_size.value
        )
        if rb_type.state == 2 do
        (
            b = sphere radius:(spn_size.value/2)
        )
        if rb_type.state == 3 do
        (
            b = teapot radius:(spn_size.value/2)
        )
      
        for i = 1 to 10 do
        (
            for j =1 to 10 do
            (
                for k=1 to 10 do
                (
                    ib = instance b
                    ib.pos = [i,j,k]*spn_size.value
                )
            ) 
         
        )
        delete b
    )
)
createdialog myUI  240 100

--------------------------------------------------------------------------------------------------------------------------------------
I added 2 UI parts and modify some code.
First one is a radio button.

radiobuttons rb_type labels:#( "Box","Sphere","Teapot")

"rad_type" is the radio button's name whitch is used for access its state.
if you choose "Box", it will return 1, if you choose "Sphere", it will return 2,if you choose "Teapot"it will return 3.
We can access the number by using ".state".
radio buttons is for just returning a number whitch button is selected.

spinner spn_size "Size:" range:[0, 10000, 25]

"spn_size" is the spineer"s name whitch is used for access its value is the same as radio buttons.
spineer needs 3 numbers,in this case,"0" is minimum value of this spinner,"10000" is maximum value and 25 is default value.
We can access the spinner's value by using  ".value".

Lastly let's add spinners to control how many objects is created along the each axis.













--------------------------------------------------------------------------------------------------------------------------------------
rollout myUI "simpleUI"
(
    radiobuttons rb_type labels:#( "Box","Sphere","Teapot")
    spinner spn_size "Size:" range:[0, 10000, 25]
  
    spinner spn_x "X:" type:#integer range:[1, 10000, 10]
    spinner spn_y "Y:" type:#integer range:[1, 10000, 10]
    spinner spn_z "Z:" type:#integer range:[1, 10000, 10]
  
    button myBtn "Do!!" width:200 height:50
  
    on myBtn pressed do
    (
        if rb_type.state == 1 do
        (
            b = box length:spn_size.value  width:spn_size.value height:spn_size.value
        )
        if rb_type.state == 2 do
        (
            b = sphere radius:(spn_size.value/2)
        )
        if rb_type.state == 3 do
        (
            b = teapot radius:(spn_size.value/2)
        )
      
        for i = 1 to spn_x.value do
        (
            for j =1 to spn_y.value do
            (
                for k=1 to spn_z.value do
                (
                    ib = instance b
                    ib.pos = [i,j,k]*spn_size.value
                )
            ) 
         
        )
        delete b
    )
)
createdialog myUI  240 170

--------------------------------------------------------------------------------------------------------------------------------------
That's it this time.
See you then, next time!!
Thank you.
--------------------------------------------------------------------------------------------------------------------------------------
前回のコードを拡張していく前に、if文elseの使い方を説明しておこうと思います。
こちら、簡単な例です。

a = 1
if a == 1 then
(
    print "a is one"
)
else
(
    print "a is not one"
)

--------------------------------------------------------------------------------------------------------------------------------------

a が1のときは、a is one それ以外のときは,"a is not one"とプリントされます。
何かの条件で分岐したいときに使うというだけです。
試しにa=1 をa = 5に変えてみると、,"a is not one"とプリントされると思います。

では、ここからはスピナーとラジオボタンの使い方を説明しようと思います。
まずは、ジオメトリを選ぶ為のラジオボタンを作ってみようと思います。
例です。










rollout myUI "simpleUI"
(
    radiobuttons rb_type labels:#( "Box","Sphere","Teapot")
    spinner spn_size "Size:" range:[0, 10000, 25]

    button myBtn "Do!!" width:200 height:50
  
    on myBtn pressed do
    (
        if rb_type.state == 1 do
        (
            b = box length:spn_size.value  width:spn_size.value height:spn_size.value
        )
        if rb_type.state == 2 do
        (
            b = sphere radius:(spn_size.value/2)
        )
        if rb_type.state == 3 do
        (
            b = teapot radius:(spn_size.value/2)
        )
      
        for i = 1 to 10 do
        (
            for j =1 to 10 do
            (
                for k=1 to 10 do
                (
                    ib = instance b
                    ib.pos = [i,j,k]*spn_size.value
                )
            ) 
         
        )
        delete b
    )
)
createdialog myUI  240 100


--------------------------------------------------------------------------------------------------------------------------------------
2つのUIと少しコードを足してみました。
1つ目はラジオボタンです。

radiobuttons rb_type labels:#( "Box","Sphere","Teapot")

"rad_type" はこのラジオボタンの名前でどの状態にあるか取得する為に使います。
 "Box"を選択していれば1を返し、"Sphere"なら 2、"Teapot"なら3の値を返します。
".state"を使って、このラジオボタンにアクセスできます。
ラジオボタンはただどのボタンが選択されているか、ということをナンバーで返すものです。

spinner spn_size "Size:" range:[0, 10000, 25]

"spn_size" はこのスピナの名まで、ラジオボタン同様値を得る為に使います。
"0"は最小値"10000"最大値で 25はデフォルトの値です。
スピナの値には".value"を使ってアクセスできます。

最後に、軸それぞれに幾つオブジェクトを並べるか決めるスピナーを追加してみましょう。













--------------------------------------------------------------------------------------------------------------------------------------
rollout myUI "simpleUI"
(
    radiobuttons rb_type labels:#( "Box","Sphere","Teapot")
    spinner spn_size "Size:" range:[0, 10000, 25]
  
    spinner spn_x "X:" type:#integer range:[1, 10000, 10]
    spinner spn_y "Y:" type:#integer range:[1, 10000, 10]
    spinner spn_z "Z:" type:#integer range:[1, 10000, 10]
  
    button myBtn "Do!!" width:200 height:50
  
    on myBtn pressed do
    (
        if rb_type.state == 1 do
        (
            b = box length:spn_size.value  width:spn_size.value height:spn_size.value
        )
        if rb_type.state == 2 do
        (
            b = sphere radius:(spn_size.value/2)
        )
        if rb_type.state == 3 do
        (
            b = teapot radius:(spn_size.value/2)
        )
      
        for i = 1 to spn_x.value do
        (
            for j =1 to spn_y.value do
            (
                for k=1 to spn_z.value do
                (
                    ib = instance b
                    ib.pos = [i,j,k]*spn_size.value
                )
            ) 
         
        )
        delete b
    )
)
createdialog myUI  240 170

--------------------------------------------------------------------------------------------------------------------------------------
今回は以上です。
ではでは、また次回。

2011年11月29日火曜日

The Smurfs making

スマーフのメイキング。とても良い感じです。 キャラの作りこみ、アニメーション、シェーダー、ライティングどれもいい感じですねー

2011年11月28日月曜日

Reel Luca Zappala 2011

http://vimeo.com/31275216
爆発・煙系のFXアーティストでは今まで一番凄いです。埋め込みが出来ないのでリンクです。
必見!

2011年11月25日金曜日

scriptのすすめ8 ~UIの基本~ maxscript tips

It's been a while again (^^;)
This time I will explain how to make UI.

First I will show you the simpliest example.


----------------------------------------------
rollout myUI "simpleUI"
(
)
createdialog myUI  240 80

----------------------------------------------

"rollout" and "createdialog" is a minimum of set to create UI.
"myUI" is this window's name you can use any words and "simpleUI" is a label which you want show on the Bar.

"createdialog" makes a dialog which is defined by "rollout" and you can specify size of the dialog.
As above example width is 240 and height is 120.

Next let's make a button on this UI when you press it something will happen.


----------------------------------------------
rollout myUI "simpleUI"
(
 button myBtn "Do!!" width:200 height:50
)
createdialog myUI  240 80

----------------------------------------------


"button" needs two parameters which are name of the button and text on the button.
"width" and "height" is not always necessary because it has default value.

That completed making UI however if you press the button nothing happen.
So let's meke some processings when you press "myBtn".

--------------------------------------------------------------------------------------------
rollout myUI "simpleUI"
(
    button myBtn "Do!!" width:200 height:50
    on myBtn pressed do
    (
        b = box()
        for i = 1 to 10 do
        (
            for j =1 to 10 do
            (
                for k=1 to 10 do
                (
                    ib = instance b
                    ib.pos = [i,j,k]*25
                )
            )   
           
        )
        delete b
    )
)
createdialog myUI  240 80



--------------------------------------------------------------------------------------------
I added "on myBtn pressed do......".
Below "on myBtn pressed do" is the processing when you press the button.
I used for loop 3 times, I think this is little bit complicated but it's buildup of  previous my post.

This is the result.


That's all this time.
I will revise this next time.
See you then, thak you!
----------------------------------------------------------------------------
またまた時間が空いてしまいました。
今回は、UIの作り方を説明できたらと思います。

まずは一番シンプルなUIのサンプルを。

----------------------------------------------
rollout myUI "simpleUI"
(
)
createdialog myUI  240 80

----------------------------------------------

"rolleout"と"createdialog" はUIを作るうえで最低限のセットで、myUIはこのウィンドウ(ロールアウト)の名前です。どんな名前でも付けれます。
"simpleUI"の部分はこのUIに表示する名札のようなものです。

 "createdialog" は"rolleout"で定義したダイアログを作るメソッドで、サイズも指定できます。
上の例では、幅240高さ80です。

次にここに押したら何かが起きるボタンを作ってみましょう。



----------------------------------------------
rollout myUI "simpleUI"
(
 button myBtn "Do!!" width:200 height:50
)
createdialog myUI  240 80

----------------------------------------------

 "button"は2つのパラメータが必要で、このボタンの名前と表示するテキストです。
widthとheigthは必ずしも必要では無いです。無ければ、デフォルト値が設定されます。

これで、UIは完成しましたが、ボタンを押しても何もおきません。
では、ボタンをおしたら何かの処理が行われるようにしましょう。
--------------------------------------------------------------------------------------------
rollout myUI "simpleUI"
(
    button myBtn "Do!!" width:200 height:50
    on myBtn pressed do
    (
        b = box()
        for i = 1 to 10 do
        (
            for j =1 to 10 do
            (
                for k=1 to 10 do
                (
                    ib = instance b
                    ib.pos = [i,j,k]*25
                )
            )   
           
        )
        delete b
    )
)
createdialog myUI  240 80

--------------------------------------------------------------------------------------------
 "on myBtn pressed do......".以下を足しました。
on myBtn pressed do から下の部分が、myBtnを押した時に行われる処理です。
処理の中身はforループを3回使用して少しトリッキーですが、前回の発展系です。

結果は以下のとおり。


今回は以上で。
次はこれの発展と他の機能を紹介でしたらと思います。
ではでは。

2011年11月2日水曜日

Houdini メモ

ForEachの中でForEachを使う時、要注意。
Stampの名前を変更しないと色々問題あるときがある。
理由は謎だけども、中のForEachが上のStampValueを上書きしてしまう?

2011年10月31日月曜日

"Have You Seen My Sister Evelyn"


Evelyn EvelynのMV。
アイディアもテクニックも最高です。
こうゆう、センスと技術が高いレベルで融合した作品を見るとやる気沸きますね。