aboutsummaryrefslogtreecommitdiff
path: root/mayaPlug/shaveAPI.h
diff options
context:
space:
mode:
Diffstat (limited to 'mayaPlug/shaveAPI.h')
-rw-r--r--mayaPlug/shaveAPI.h331
1 files changed, 331 insertions, 0 deletions
diff --git a/mayaPlug/shaveAPI.h b/mayaPlug/shaveAPI.h
new file mode 100644
index 0000000..fee8e28
--- /dev/null
+++ b/mayaPlug/shaveAPI.h
@@ -0,0 +1,331 @@
+#ifndef shaveAPI_h
+#define shaveAPI_h
+// Shave and a Haircut
+// (c) 2019 Epic Games
+// US Patent 6720962
+
+#define SHAVE_API_VERSION 4
+
+#ifdef WIN32
+# ifdef LIBSHAVEAPI_EXPORTS
+# define LIBSHAVEAPI_API __declspec(dllexport)
+# else
+# define LIBSHAVEAPI_API __declspec(dllimport)
+# endif
+#else
+# define LIBSHAVEAPI_API
+#endif
+
+#include <maya/MStatus.h>
+#include <maya/MString.h>
+
+#if MAYA_API_VERSION < 20180000
+class MObjectArray;
+#endif
+
+
+class LIBSHAVEAPI_API shaveAPI
+{
+public:
+ typedef struct
+ {
+ float x;
+ float y;
+ float z;
+ } Vertex;
+
+ typedef struct
+ {
+ float r;
+ float g;
+ float b;
+ } Color;
+
+ class LIBSHAVEAPI_API HairInfo
+ {
+ public:
+ HairInfo();
+ ~HairInfo();
+
+ //
+ // Free up all storage allocated by a call to shaveExportHair().
+ //
+ // Note that a HairInfo object is automatically cleared when it is
+ // destroyed.
+ //
+ void clear();
+
+ //
+ // Number of unique vertices for all hairs in the structure.
+ //
+ int numVertices;
+
+ //
+ // Total number of hairs in the structure.
+ //
+ int numHairs;
+
+ //
+ // Total number of hair vertices in the structure.
+ //
+ // If several hairs share a vertex, it will only be counted once in
+ // 'numVertices', but will be counted once for each hair in
+ // 'numHairVertices'.
+ //
+ int numHairVertices;
+
+ //
+ // 'hairVertices' is an array of indices into the 'vertices' array
+ // and contains one entry for each vertex of each hair. A hair's
+ // vertices run up the center of the hair.
+ //
+ // The indices for hair N start at 'hairStartIndices[N]' and end at
+ // 'hairEndIndices[N] - 1'. <-- NOTE THE -1 !!!
+ //
+ // 'hairVertices' will have 'numHairVertices' elements
+ // 'hairStartIndices' will have 'numHairs' elements.
+ // 'hairEndIndices' will have 'numHairs' elements.
+ //
+ int *hairVertices;
+ int *hairStartIndices;
+ int *hairEndIndices;
+
+ //
+ // Material characteristics.
+ //
+ // Each array has one entry per hair.
+ //
+ float* opacities;
+ float* speculars;
+ float* glosses;
+ float* ambDiffs;
+ Color* rootColors;
+ Color* tipColors;
+ float* rootRadii;
+ float* tipRadii;
+
+ //
+ // 'vertices' is an array of all of the vertices in all of the
+ // exported hair nodes.
+ //
+ // It contains 'numVertices' entries.
+ //
+ Vertex* vertices;
+
+ //
+ // 'velocities' contains the corresponding velocities for each
+ // vertex in the 'vertices' array.
+ //
+ Vertex* velocities;
+
+ //
+ // Texture space coordinates for each vertex. U and V are taken
+ // from the U and V of the growth surface at the point where the
+ // hair is rooted. W ranges from 0.0 at the root of the hair to
+ // 1.0 at the tip.
+ //
+ // 'secondaryUVWs' is not currently used.
+ //
+ Vertex* uvws;
+ Vertex* secondaryUVWs;
+
+ //
+ // Surface normals at the root of each hair. There is one entry
+ // per hair.
+ //
+ // (Added April 16, 2004, version 2.7v4)
+ //
+ Vertex* surfaceNormals;
+
+ //
+ // So let's say that hair number N has 3 vertices. Then its
+ // structure might look something like this:
+ //
+ // hairVertices vertices
+ // : :
+ // : :
+ // +--+ +--+
+ // | | | |
+ // +--+ +--+
+ // | | --> | |
+ // +--+ / +--+
+ // hairStartIndices[N] --> | | ---- / | |
+ // +--+ \ / +--+
+ // | | -------- | |
+ // +--+ \ +--+
+ // | | --- \ | |
+ // +--+ \ \ +--+
+ // hairEndIndices[N] ----> | | \ ----> | |
+ // +--+ \ +--+
+ // | | -------> | |
+ // +--+ +--+
+ // : :
+ //
+ // The X component of the first vertex of hair N would be:
+ //
+ // vertices[hairVertices[hairStartIndices[N]]].x
+ //
+ // The Z component of the velocity vector of the last vertex of
+ // hair N would be:
+ //
+ // velocities[hairVertices[hairEndIndices[N]-1]].z
+ //
+ // Note that per-hair values, such as the various material
+ // characteristics, are simply indexed by hair number. So the green
+ // component of hair N's tip colour would be:
+ //
+ // tipColors[N]
+ //
+ int* index;
+ float *alpha; //was missing
+ };
+
+
+ class LIBSHAVEAPI_API SceneGeom
+ {
+ public:
+ SceneGeom();
+ ~SceneGeom();
+
+ void clear();
+
+ //
+ // Number of unique vertices for all polygons in the structure.
+ //
+ int numVertices;
+
+ //
+ // Total number of polygonal faces in the structure.
+ //
+ int numFaces;
+
+ //
+ // Total number of face vertices in the structure.
+ //
+ // If several faces share a vertex, it will only be counted once in
+ // 'numVertices', but will be counted once for each face in
+ // 'numFaceVertices'.
+ //
+ int numFaceVertices;
+
+ //
+ // 'faceVertices' is an array of indices into the 'vertices' array
+ // and contains one entry for each vertex of each face.
+ //
+ // The indices for face N start at 'faceStartIndices[N]' and end at
+ // 'faceEndIndices[N] - 1'. <-- NOTE THE -1 !!!
+ //
+ // 'faceVertices' will have 'numFaceVertices' elements
+ // 'faceStartIndices' will have 'numFaces' elements.
+ // 'faceEndIndices' will have 'numFaces' elements.
+ //
+ int *faceVertices;
+ int *faceStartIndices;
+ int *faceEndIndices;
+
+ //
+ // 'vertices' is an array of all of the vertices in all of the
+ // geometery contained in the structure.
+ //
+ // It contains 'numVertices' entries.
+ //
+ Vertex* vertices;
+
+ //
+ // 'velocities' contains the corresponding velocities for each
+ // vertex in the 'vertices' array.
+ //
+ Vertex* velocities;
+ };
+
+
+ //
+ // Export all of the hair for all of the shaveNodes in the scene and
+ // place the result in 'hairInfo'.
+ //
+ // If 'renderableOnly' is true then only renderable shaveNodes (e.g.
+ // those which are active and whose display nodes are visible, not
+ // templated, etc) will be exported.
+ //
+ // Return Value:
+ // MS::kSuccess Nodes found and exported.
+ //
+ // MS::kNotFound No shaveNodes found in the scene.
+ //
+ // MS::kUnknownParameter Motion blur is on, but no render camera
+ // was found, so the hair has been exported
+ // without blur (all velocities are zero).
+ //
+ static MStatus exportAllHair(
+ HairInfo* hairInfo, bool renderableOnly = false
+ );
+
+ //
+ // Export all of the hair for all of the shaveNodes specified in the
+ // 'shaveNodes' array and place the result in 'hairInfo'.
+ //
+ // Return Value:
+ // MS::kSuccess Nodes found and exported.
+ //
+ // MS::kNotFound 'shaveNodes' is empty.
+ //
+ // MS::kInvalidParameter 'shaveNodes' contains objects which are
+ // not shaveNodes
+ //
+ // MS::kUnknownParameter Motion blur is on, but no render camera
+ // was found, so the hair has been exported
+ // without blur (all velocities are zero).
+ //
+ static MStatus exportHair(
+ MObjectArray& shaveNodes, HairInfo* hairInfo
+ );
+
+
+ //
+ // Export any geometry capable of occluding hair and/or hair shadows,
+ // based on the 'Occlusion Objects' list in Shave Globals
+ // (shaveGlobals.hairOcclusionObjects attribute).
+ //
+ // If the 'Occlusion Objects' list is set to 'all' then
+ // 'hairOcclusions' will return all visible, non-transparent objects in
+ // the scene while 'shadowOcclusions' will also contain those objects
+ // which have primary visibility off or have transparency.
+ //
+ // If the 'Occlusion Objects' list in Shave Globals is set to an
+ // explicit list of objects then those objects will be exported,
+ // regardless of their visibility and transparency.
+ //
+ // If 'Native Illumination' is turned on in Shave Globals
+ // (shaveGlobals.nativeIllumination attribute) then shadows are being
+ // handled by the renderer itself and 'hairOccclusions' will be empty.
+ //
+ // Either parameter may be NULL.
+ //
+ // Return Value:
+ //
+ // MS::kSuccess Success.
+ //
+ // MS::kUnknownParameter Motion blur is on, but no render camera
+ // was found, so the geometry has been
+ // exported without blur (all velocities
+ // are zero).
+ //
+ static MStatus exportOcclusions(
+ SceneGeom* hairOcclusions, SceneGeom* shadowOcclusions
+ );
+
+
+ //********************************************************************
+ //
+ // OBSOLETE METHODS
+ //
+ //********************************************************************
+
+ // Use shaveAPI::HairInfo::clear() instead
+ static void freeHairInfo(HairInfo* hairInfo);
+
+ // HairInfo objects automatically initialize themselves now.
+ static void initHairInfo(HairInfo* hairInfo);
+};
+
+#endif