#ifndef shaveGeometryOverride_h #define shaveGeometryOverride_h // Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "shaveHairShape.h" #if MAYA_API_VERSION < 20180000 class MDagPath; #endif class shaveInstanceDisplay; class shaveGeometryOverride : public MHWRender::MPxGeometryOverride { public: static MPxGeometryOverride* Creator(const MObject& obj) { return new shaveGeometryOverride(obj); } virtual ~shaveGeometryOverride(); virtual MHWRender::DrawAPI supportedDrawAPIs() const; virtual void updateDG(); virtual void updateRenderItems( const MDagPath& path, MHWRender::MRenderItemList& list); virtual void populateGeometry( const MHWRender::MGeometryRequirements& requirements, const MHWRender::MRenderItemList& renderItems, MHWRender::MGeometry& data ); #if MAYA_API_VERSION >= 201600 virtual void updateSelectionGranularity(const MDagPath& path, MHWRender::MSelectionContext& selectCtx); #endif virtual void cleanUp(); #if MAYA_API_VERSION >= 201600 static MStatus registerComponentConverters(); static MStatus deregisterComponentConverters(); #endif // Custom user data to attach to render items // for doing selection. // class SelectionData : public MUserData { public: SelectionData() : MUserData(false) {} virtual ~SelectionData() {} MString mShaveSelectType; // Holds the encoded (guide, vert) value for each // primitive used to draw guide verts. // std::vector mPrimIdxToVertIdx; // Holds the guide index for each primitive used to // draw a guide. // std::vector mPrimIdxToGuideIdx; }; // RenderItem names. // static const MString kHairShadedItemName; static const MString kHairShadedSelectedItemName; static const MString kHairWireItemName; static const MString kHairWireSelectedItemName; static const MString kInstanceShadedItemName; static const MString kInstanceWireItemName; static const MString kInstanceWireSelectedItemName; static const MString kGuidesItemName; static const MString kKnotsItemName; protected: shaveGeometryOverride(const MObject& obj); bool disableRenderItem( MHWRender::MRenderItemList& list, const MString& itemName, MHWRender::MGeometry::Primitive primType, MHWRender::MGeometry::DrawMode drawMode ); virtual void populateHairInstances( const MHWRender::MGeometryRequirements& requirements, const MHWRender::MRenderItemList& renderItems, MHWRender::MGeometry& data ); //uses geometry shader virtual void populateHairLines( const MHWRender::MGeometryRequirements& requirements, const MHWRender::MRenderItemList& renderItems, MHWRender::MGeometry& data ); //polygonal hair virtual void populateHairPolys( const MHWRender::MGeometryRequirements& requirements, const MHWRender::MRenderItemList& renderItems, MHWRender::MGeometry& data ); //uses geometry shader virtual void populateHairGuides( const MHWRender::MGeometryRequirements& requirements, const MHWRender::MRenderItemList& renderItems, MHWRender::MGeometry& data ); void cacheHairPolys(); void cacheGuidePolys(); void cacheKnotPolys(); shaveHairShape* shave; MObject shobj; struct Poly { MVector t[3]; MVector v[3]; MColor c[3]; MVector uv[3]; }; class PolyGroup { public: std::vector p; }; std::vector groups; unsigned int ingroups; struct GuidePoly { MVector v[3]; bool active; }; std::vector guidePolys; struct KnotPoly { MVector v[3]; bool active; }; std::vector knotPolys; MHWRender::MTexture* instex; SelectionData mSelectionData; // We're only allowed to access the DG during updateDG(). Below // are the DG-dependent data that we need to cache for use in subsequent // methods. // unsigned int mNumHairsToDraw; const shaveHairShape::DisplayHairCache* mHairCache; M3dView::LightingMode mLightMode; int mHairDisplayMode; MColor mSpecularTint; MColor mSpecularTint2; float mGloss; float mSpecular; const shaveInstanceDisplay* mInstanceCache; MMatrix mWorldToCam; MVector mViewDir; MVector mUpDir; MVector mRightDir; float mTransparency; bool mDoTipFade; int mPasses; const shaveHairShape::Guides* mGuideCache; float mGuideExtent; }; #endif