00001
00013 #include "SoftVolumeSphere.h"
00014 #include <maya/MFnDagNode.h>
00015 #include <maya/MColor.h>
00016
00018 const MTypeId SoftVolumeSphere::typeId( 0x70015 );
00019
00021 const MString SoftVolumeSphere::typeName( "softVolumeSphere" );
00022
00023
00025 MObject SoftVolumeSphere::m_Radius;
00026
00027
00028 MObject SoftVolumeSphere::m_Weight;
00029
00030
00031 void SoftVolumeSphere:: OnDraw( M3dView::DisplayStyle style,
00032 M3dView::DisplayStatus status)
00033 {
00034 float radius,inner;
00035
00036
00037
00038
00039
00040 MFnDagNode fn( thisMObject() );
00041
00042 MPlug RadiusPlug = fn.findPlug( m_Radius );
00043 RadiusPlug.getValue( radius );
00044
00045
00046
00047
00048
00049
00050
00051 MColor outlineCol = colorRGB(status);
00052
00053
00054
00055
00056
00057 if(status == M3dView::kLead )
00058 glColor4f(0.0f,1.0f,0.0f,0.5f);
00059 else
00060
00061 glColor4f(outlineCol.r,outlineCol.g,outlineCol.b,0.5f);
00062
00063 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
00064 glEnable(GL_BLEND);
00065 DrawCircleXY( radius, 32 );
00066 DrawCircleXZ( radius, 32 );
00067 DrawCircleYZ( radius, 32 );
00068 DrawCrossXY( 2*radius, 2*radius );
00069 DrawCrossXZ( 2*radius, 2*radius );
00070 DrawCrossYZ( 2*radius, 2*radius );
00071 glDisable(GL_BLEND);
00072
00073
00074 }
00075
00076
00077 MBoundingBox SoftVolumeSphere::boundingBox() const
00078 {
00079 float radius,inner;
00080
00081
00082
00083
00084
00085 MFnDagNode fn( thisMObject() );
00086
00087 MPlug RadiusPlug = fn.findPlug( m_Radius );
00088 RadiusPlug.getValue( radius );
00089
00090
00091 MBoundingBox bbox;
00092
00093 bbox.expand( MPoint( -radius, 0.0f, 0.0f ) );
00094 bbox.expand( MPoint( radius, 0.0f, 0.0f ) );
00095
00096 bbox.expand( MPoint( 0.0f,radius, 0.0f ) );
00097 bbox.expand( MPoint( 0.0f,-radius, 0.0f ) );
00098
00099 bbox.expand( MPoint( 0.0f, 0.0f, -radius ) );
00100 bbox.expand( MPoint( 0.0f, 0.0f, radius ) );
00101
00102 return bbox;
00103 }
00104
00105 void* SoftVolumeSphere::creator()
00106 {
00107 return new SoftVolumeSphere();
00108 }
00109
00110
00111 MStatus SoftVolumeSphere::initialize()
00112 {
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 MFnUnitAttribute fn;
00130 MFnNumericAttribute nfn;
00131
00132 MStatus stat;
00133
00134
00135
00136 m_Radius = fn.create( "radius", "r", MFnUnitAttribute::kDistance );
00137
00138
00139 fn.setDefault( MDistance(5.0, MDistance::uiUnit()) );
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 fn.setKeyable( true );
00152
00153
00154 fn.setMin( 0.1f );
00155
00156
00157 stat = addAttribute( m_Radius );
00158
00159
00160 if( stat != MS::kSuccess ) {
00161 stat.perror("Unable to attach radius attribute to the softVolumeSphere node");
00162 return stat;
00163 }
00164
00165 m_Weight = nfn.create("weight","w",MFnNumericData::kFloat);
00166 nfn.setDefault(1.0f);
00167 nfn.setKeyable(true);
00168 stat = addAttribute(m_Weight);
00169
00170
00171 if( stat != MS::kSuccess ) {
00172 stat.perror("Unable to attach innerSize attribute to the softVolumeSphere node");
00173 return stat;
00174 }
00175
00176 return MS::kSuccess;
00177 }