-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbellCollider.h
86 lines (68 loc) · 2.55 KB
/
bellCollider.h
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
#include <maya/MPxLocatorNode.h>
#include <maya/MPxDrawOverride.h>
#include <maya/MDrawRegistry.h>
#include <maya/MPointArray.h>
#include <vector>
#include <string>
using namespace std;
struct DrawData
{
MObject bellMesh;
vector<MObject> ringMeshList;
vector<MPoint> collisionPointBellList;
vector<MPoint> collisionPointRingList;
vector<MVector> ringDirectionList;
vector<MPoint> ringPositionList;
MPoint bellCenter;
MColor color;
bool drawInXRay;
};
class BellCollider : public MPxLocatorNode
{
public:
static MTypeId typeId;
static MString drawDbClassification;
static MString drawRegistrantId;
static MObject attr_bellMatrix;
static MObject attr_ringMatrix;
static MObject attr_bellAxis;
static MObject attr_ringAxis;
static MObject attr_bellSubdivision;
static MObject attr_ringSubdivision;
static MObject attr_bellBottomRadius;
static MObject attr_falloffMode;
static MObject attr_falloff;
static MObject attr_falloffMaxDistance;
static MObject attr_distancePower;
static MObject attr_positionCount;
static MObject attr_drawColor;
static MObject attr_drawInXRay;
static MObject attr_outputPositions;
static MObject attr_outputRotations;
static MObject attr_outputCurve;
DrawData drawData;
static void* creator() { return new BellCollider(); }
static MStatus initialize();
MStatus compute(const MPlug&, MDataBlock&);
void drawUI(MHWRender::MUIDrawManager&);
private:
};
class BellColliderDrawData : public MUserData
{
public:
BellColliderDrawData() : MUserData(false) {} // deleteAfterUse = false
BellCollider* bellCollider{nullptr};
};
class BellColliderDrawOverride : public MHWRender::MPxDrawOverride
{
public:
static MHWRender::MPxDrawOverride* creator(const MObject& obj) { return new BellColliderDrawOverride(obj); }
MHWRender::DrawAPI supportedDrawAPIs() const { return MHWRender::kOpenGL | MHWRender::kDirectX11 | MHWRender::kOpenGLCoreProfile; }
MUserData* prepareForDraw(const MDagPath& objPath, const MDagPath& cameraPath, const MHWRender::MFrameContext& frameContext, MUserData* oldData);
virtual bool hasUIDrawables() const { return true; }
virtual void addUIDrawables(const MDagPath& objPath, MHWRender::MUIDrawManager& drawManager, const MHWRender::MFrameContext& frameContext, const MUserData* data);
//bool isBounded(const MDagPath &objPath, const MDagPath &cameraPath) const {return true;}
//MBoundingBox boundingBox(const MDagPath &objPath, const MDagPath &cameraPath) const {return MBoundingBox();}
private:
BellColliderDrawOverride(const MObject& obj) : MHWRender::MPxDrawOverride(obj, NULL, true) {} // alwaysDirty is true
};