Volume Primitives [MEL]



 

 

Volume primitves are used within maya, normally to define volumetric fog and lighting effects. There is no reason however, why you cannot use the volume primitives for collision objects, level triggers etc. Each volume primitive is simply a basic shape parented under a transform node.

 

 

 

 

 

Volume Primitives

 

Maya contains a number of basic volume primitives. These primitives can prove to be useful for items such as collision primitves, level triggers etc.

 

 

 

 

 

 

 

 


#include<maya/MItDag.h>

// create an iterator to go through all nodes
MItDag it(MFn::kInvalid);

while(!it.isDone())
{
 

// only want non-history items
if(it.item().apiType() == MFn::kRenderSphere ) {

  // described below
OutputVolumeSphere(it.item());

} else if(it.item().apiType() == MFn::kRenderBox ) {

  // described below
OutputVolumeBox(it.item());

} else if(it.item().apiType() == MFn::kRenderCone ) {

  // described below
OutputVolumeCone(it.item());

}

// get next object
it.next();

}

 

 

Volume Sphere

 

The volume sphere type simply contains a radius attribute.

 

 

 

 

 

 


#include<maya/MFnMesh.h>
#include<maya/MItDagNode.h>

void OutputVolumeSphere(MObject &obj)
{
 

MFnDagNode fnDep(obj);
MFnDagNode fnParent(fnDep.parent(0));

// get the radius of the sphere
float
radius;
MPlug plgRadius = fnDep.findPlug("radius");
plgRadius.
getValue(radius);

cout << "VolumeSphere " << fnDep.name().asChar()
<< "\n\tParent " << fnParent.name().asChar()
<< "\n\tRadius " << radius
<< "\n";

}




 

Volume Box

 

The volume box simply contains the three sizes for the x, y and z axes.

 

 

 

 

 

 

 

 

 


#include<maya/MFnMesh.h>

void OutputVolumeBox(MObject &obj)
{
 

MFnDagNode fnDep(obj);
MFnDagNode fnParent(fnDep.parent(0));

// get the dimensions of the cube
float x,y,z;
MPlug plgX = fnDep.findPlug("sizeX");
MPlug plgY = fnDep.findPlug("sizeY");
MPlug plgZ = fnDep.findPlug("sizeZ");
plgX.
getValue(x);
plgY.
getValue(y);
plgZ.
getValue(z);

cout << "VolumeBox" << fnDep.name().asChar()
<< "\n\tparent " << fnParent.name().asChar()
<< "\n\tsizeX " << x
<< "\n\tsizeY " << y
<< "\n\tsizeZ " << z
<< "\n";

}


 

 

Volume Cone

 

The volume cone is simply defined by a cone angle, and a caps length. The caps value signifies the height of the cone.

 

 

 

 

 

 

 


#include<maya/MFnMesh.h>

void OutputVolumeCone(MObject &obj)
{

 

MFnDagNode fnDep(obj);
MFnDagNode fnParent(fnDep.parent(0));

// get the cone angle and caps
float angle,cap;
MPlug plgAngle = fnDep.findPlug("ca");
MPlug plgCap = fnDep.findPlug("cap");
plgAngle.
getValue(angle);
plgCap.
getValue(cap);

cout << "VolumeCone " << fnDep.name().asChar()
<< "\n\tparent " << fnParent.name().asChar()
<< "\n\tconeAngle " << angle
<< "\n\tcaps " << cap
<< "\n";

}



 

 

What Next?

Transformation Data

Dynamics Fields


Particle Systems


Animation Data


Animation Curves

index

Rob Bateman [2004]

[HOME] [MEL] [API]