// Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 // Callback functions (shave calls you) #include #include #include #include #include #include #include #include #include #include "shaveGlobals.h" extern "C" { //#ifndef _SHAVESDK_CALLBACK_ //#define _SHAVESDK_CALLBACK_ // extern float SHAVEapply_texture( CURVEINFO * ci, VERT rest_root_worldpos, unsigned long shaveINSTID, int parm, float inbound_value ) { // this function callback gives you the opportunity to apply external texture to any/every // channel in shave // CURVEINFO contains all kinds of basis information // rest_root_worldpos is the world coord for the hair's root in the rest position // shaveINSTID contains the ID you burned the restMEM (at creation) that's // being rendered // parm tells you which channel is being evaluated from SHAVEPARMS // this function is called during rendering // inbound contains the param value as evaluated internally (slider * weight * texture) // do something to inbound value here before it's returned return ( inbound_value ); } // this needs to be here as well, but you won't be using it // the 'MAYA' in the name is due to back compatibility with a MAYAShave version extern void MAYAexternal_forces( VERT * lastpos, VERT * velocity ) { MStringArray fieldList; MStatus stat; MDagPath dagPath; MSelectionList list; MFnField field; int fieldCount = 0; MGlobal::executeCommand( "ls -dag -type field", fieldList ); MPoint p( lastpos->x, lastpos->y, lastpos->z ); MVector v( velocity->x, velocity->y, velocity->z ); MPointArray pointArray; pointArray.append( p ); MVectorArray forces; MVectorArray velocityArray; velocityArray.append( v ); MDoubleArray massArray; fieldCount = fieldList.length( ); for( int i = 0; i < fieldCount; i++ ) { list.add( fieldList[i] ); } MItSelectionList listIter( list ); for( fieldList.reset( ); !fieldList.isDone( ); fieldList.next( ) ) { fieldList.getDagPath( dagPath ); field.setObject( dagPath ); stat = field.getForceAtPoint( pointArray, velocityArray, massArray, forces, NULL ); } // forces are worldspace vectors velocity->x += forces[0].x * 0.01; velocity->y += forces[0].y * 0.01; velocity->z += forces[0].z * 0.01; } // this is an illumination callback (see docs) extern VERT SHAVEapply_illumination( int LIGHTID, VERT wpos, VERT vector, VERT color ) { // this function is now obsolete!! // ranges are 0.0 - 1.0 (return isn't clipped until after shading) // modify or replace 'color' - it contains light info for current test before // shave shadows are applied return ( color ); } extern void SHAVEapply_illuminationWF( int LIGHTID, WFTYPE * samples ) { // ranges are 0.0 - 1.0 (return isn't clipped until after shading) // modify or replace 'samples->color' - it contains light info for current test before // shave shadows are applied // samples->v is the position // samples->totalverts is the total number of points } extern float SHAVEapply_falloff( int lightNUM, VERT pos, float cone ) { return ( cone ); } // this is a callback for applying atmospherics/depth cueing extern VERT SHAVEapply_atmosphere( VERT wpos, VERT inbound_color ) { // range = 0.0 - 255.0 (shave will clip out of bound returns) // do your tint here based on wpos // ie - make it really bright : // inbound_color.x*=3.0f; // inbound_color.y*=3.0f; // inbound_color.z*=3.0f; return ( inbound_color ); } //#endif extern void SHAVEcoord_convertTOSHAVE( VERT * in ) { } extern void SHAVEcoord_convertFROMSHAVE( VERT * in ) { } };