MELの応用2 (岩石)

岩石を作る 2

前回のスクリプトを少し改良して岩・石を自動生成するスクリプトを作ってみる。
(ポリゴンの分割数を変えて、最後にスムースをかけている。)

岩石を作るプログラム2

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

  1. 以下のプロシージャをmakeRock4.melと言う名前でファイルに書き込む。
    global proc makeRock4()
    {
    	string $poly[] = `polySphere -subdivisionsX 5 -subdivisionsY 5`;
    	$x = rand(1, 2);
    	$y = rand(1, 2);
    	$z = rand(1, 2);
    	scale $x $y $z;
    	string $ver[] = `polyListComponentConversion -toVertex $poly[0]`;
    	string $verE[] = `filterExpand -selectionMask 31 $ver`;
    	for($obj in $verE)
    	{
    		select -r $obj;
    		$x = rand(-0.2, 0.2);
    		$y = rand(-0.2, 0.2);
    		$z = rand(-0.2, 0.2);
    		move -r $x $y $z;
    	}
    	string $polyS[] = `listRelatives -shapes $poly[0]`;
    	polySmooth -divisions 2 -continuity 0.5 $polyS[0];
    }
    
  2. File -> Source Script でmakeRock4.melを読み込む。
  3. Script Editor で以下のコマンドを実行してみる。
    makeRock4();

練習

参考

練習課題


Prev | Next
Home | Contents
abe@injapan.net