Mel Script - Volume Primitive Data [API]

 

 

 

 

Volume primitves are used within maya, normally to define volumetric fog and lighting effects. Each volume primitive is simply a basic shape parented under a transform node. The three types available in Maya are, renderCone, renderBox and renderSphere.

 

 

 

Creating Volume Primitives

The createImplicitVolume function can be used to create one of the volume primitives for you.

 

 


			$sphere = `createImplicitVolume sphere`;
			$cube = `createImplicitVolume cube`;
			$cone = `createImplicitVolume cone`;

			print("sphere= " + $sphere + "\n");
			print("cube=   " + $cube + "\n");
			print("cone=   " + $cone + "\n");
			

 

 

Render Cones

render cones contain both a cone angle and a cone cap. The cap value defines the distance to the cap of the cone, ie it's height.

 

 


		// get a list of all render cones in the scene
		$cones = `ls -type "renderCone"`;

		// loop through each volume cone
		for( $cone in $cones )
		{
			// print the name of the cone
			print( $cone + "\n" );
			
			// and some useful info about the cone
			print( "coneAngle=" + `getAttr ($cone+".coneAngle")` + "\n" );
			print( "coneCap=" + `getAttr ($cone+".coneCap")` + "\n" );
			
		}
		

 

 

Render Boxes

The size of the render box is stored within the "size" attribute.

 

 


		// get a list of all render boxes in the scene
		$boxes = `ls -type "renderBox"`;

		// loop through each volume box
		for( $box in $boxes )
		{
			// print the name of the box
			print( $box + "\n" );
			
			// get the size of the box
			$size = `getAttr ($box+".size")`;
			
			// print useful info...
			print( "size=" + $size[0] + " " + $size[1] + " " + $size[2] + "\n" );
			
		}
		

 

 

Render Spheres

With render sphere's we are only really concerned with the attribute, "radius".

 

 


		// get a list of all render spheres in the scene
		$spheres = `ls -type "renderSphere"`;

		// loop through each volume sphere
		for( $sphere in $spheres )
		{
			// print the name of the sphere
			print( $sphere + "\n" );
			
			// get the radius of the sphere
			$radius = `getAttr ($sphere+".radius")`;
			
			// print radius
			print( "radius=" + $radius + "\n" );
			
		}