Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Graphos 05/10/207
- // example of c4d material that store a GvNodeMaster and how to share it using BaseContainer message
- // Usage example http://recordit.co/fJlz8Dnf3Y
- // Python script => https://pastebin.com/CFrpTfrY
- #include <c4d_graphview.h>
- #include "c4d.h"
- #include "c4d_symbols.h"
- #include "msimplematerial.h"
- #include "customgui_matpreview.h"
- #include "main.h"
- // be sure to use a unique ID obtained from www.plugincafe.com
- #define ID_SIMPLEMAT 1001164
- class RedShiftMaterial : public MaterialData
- {
- INSTANCEOF(SimpleMaterial, MaterialData)
- private:
- GvWorld* world;
- GvNodeMaster* NodeMaster;
- public:
- virtual Bool Init(GeListNode* node);
- virtual void Free(GeListNode *node);
- virtual Bool Message(GeListNode* node, Int32 type, void* data);
- static NodeData* Alloc(void) { return NewObjClear(RedShiftMaterial); }
- };
- Bool RedShiftMaterial::Init(GeListNode* node)
- {
- world = GvGetWorld();
- NodeMaster = world->AllocNodeMaster((BaseList2D*)node, false, true);
- return true;
- }
- void RedShiftMaterial::Free(GeListNode* node)
- {
- world->FreeNodeMaster(NodeMaster);
- NodeMaster = nullptr;
- world = nullptr;
- }
- Bool RedShiftMaterial::Message(GeListNode* node, Int32 type, void* data)
- {
- switch (type)
- {
- case MSG_BASECONTAINER:
- {
- BaseContainer* bc = (BaseContainer*)data;
- bc->SetLink(0, NodeMaster);
- return true;
- break;
- }
- }
- return true;
- }
- Bool RegisterSimpleMaterial(void)
- {
- String name = GeGetDefaultFilename(DEFAULTFILENAME_SHADER_VOLUME) + GeLoadString(IDS_SIMPLEMATERIAL); // place in default Shader section
- // add a preview scene that can only be selected in the Simple Material's preview
- AddUserPreviewScene(GeGetPluginResourcePath() + String("scene") + String("Stairs.c4d"), ID_SIMPLEMAT, nullptr);
- return RegisterMaterialPlugin(ID_SIMPLEMAT, name, 0, RedShiftMaterial::Alloc, "Msimplematerial", 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement