MELの応用3 (岩石)

岩石を作る 3

前回までとは違う方法で岩・石を自動生成するスクリプトを作ってみる。
今回のスクリプトは水晶のような形の岩・石を作るものである。

岩石を作るプログラム2

まず、1個岩石を作るスクリプトを作ってみる。

  1. 以下のプロシージャをmakeRock7.melと言う名前でファイルに書き込む。
    global proc makeRock7()
    {
    	string $poly[] = `polyCylinder -radius 1.0 -height 2.0 -subdivisionsX 6 -subdivisionsY 1 -subdivisionsZ 1`;
    	string $ver[] = `polyListComponentConversion -toVertex $poly[0]`;
    	string $verE[] = `filterExpand -selectionMask 31 $ver`;
    	for($i = 0; $i < 6; $i++)
    	{
    		select -r $verE[$i];
    		$x = rand(-0.2, 0.2);
    		$z = rand(-0.2, 0.2);
    		move -r $x 0 $z;
    	}
    	for($i = 6; $i < 12; $i++)
    	{
    		select -r $verE[$i];
    		$y = rand(-0.3, 0.3);
    		move -r 0 $y 0;
    	}
    	select -r $verE[13];
    	$y = rand(0.5, 1.0);
    	move -r 0 $y 0;
    }
    
  2. File -> Source Script でmakeRock7.melを読み込む。
  3. Script Editor で以下のコマンドを実行してみる。
    makeRock7();

練習

参考

練習課題


Prev | Next
Home | Contents
abe@injapan.net