aboutsummaryrefslogtreecommitdiff
path: root/libexe/shaveCALLBACK.h
blob: c57e68e63d8565ec0d66ff06a99f3f3764cf3ff1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962

// Callback functions (shave calls you)
#include <maya/MStringArray.h>
#include <maya/MFnField.h>
#include <maya/MDagPath.h>
#include <maya/MItSelectionList.h>
#include <maya/MVector.h>
#include <maya/MVectorArray.h>
#include <maya/MPoint.h>
#include <maya/MPointArray.h>
#include <maya/MFloatPoint.h>
#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 )
	{
	}

};