for a gup plugin it could be condensed to the following.....
// IMyInterface.h
#include "iFnPub.h"
#define MY_INTERFACE_ID Interface_ID(0x4bc35422, 0x70000ea7)
class IMyInterface : public FPStaticInterface
{
public:
enum functionID { kthefunction, knumfunctions };
virtual float theFunction(float x) = 0;
};
inline IMyInterface* GetMyInterface() { return static_cast<IMyInterface*>(GetCOREInterface(MY_INTERFACE_ID));
// myutil.cpp
#include "IMyInterface.h"
// create the interface class
class MyUtilFPInterface: public IMyInterface
{
public:
DECLARE_DESCRIPTOR(MyUtilFPInterface);
BEGIN_FUNCTION_MAP
FN_1(kthefunction, TYPE_FLOAT, theFunction)
END_FUNCTION_MAP
float theFunction() { return sin(x); }
};
// create the global instance of our interface
static MyUtilFPInterface MyUtilFP(MY_INTERFACE_ID, _T("myutils"),
IDS_UTIL_CLASS_NAME, NULL, FP_CORE,
IMyInterface::kthefunction, _T("theFunction"), -1, TYPE_FLOAT, FP_NO_REDRAW, 1,
_T("x"), 0, TYPE_FLOAT,
p_end);
// then any other .cpp file its....
#include "IMyInterface.h"
IMyInterface* util = GetMyInterface();
float y = util->theFunction(x);
// and any mxs file
local y = myutils.theFunction(x);
you can hook into the original gup plugin by creating a static instance of it eg.....
static MyUtil gmyutil;
the call from that in the interface
class MyUtilFPInterface: public IMyInterface
{
public:
DECLARE_DESCRIPTOR(MyUtilFPInterface);
BEGIN_FUNCTION_MAP
FN_1(kthefunction, TYPE_FLOAT, theFunction)
END_FUNCTION_MAP
float theFunction() { return gmyutil.sin(x); }
};