On 09/11/2016 at 09:07, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform:
Language(s) :
---------
Hi, I'm trying to embed a falloff into a plugin, but it appears that nothing except for
C4D_Falloff::AddFalloffToDescription() has any effect. I can see the Falloff description,
but besides that, nothing else works.
The falloff parameters are not initialized, no handles are displayed, the description doesn't act
dynamically as it usually does (eg. showing different parameters when choosing a different
falloff type), etc.
Does someone have an example of how to do this correctly? My attemp below
#pragma once
#include "c4d.h"
#include "c4d_falloffdata.h"
class FalloffObjectData : public ObjectData {
protected:
AutoAlloc<C4D_Falloff> falloff;
public:
// ObjectData Overrides
virtual DRAWRESULT Draw(BaseObject* op, DRAWPASS pass, BaseDraw* bd, BaseDrawHelp* bh) override {
if (!op) return DRAWRESULT_ERROR;
auto* bc = op->GetDataInstance();
if (!bc) return DRAWRESULT_ERROR;
if (!this->falloff->Draw(bd, bh, pass, bc)) return DRAWRESULT_ERROR;
return DRAWRESULT_OK;
}
virtual Int32 GetHandleCount(BaseObject* op) override {
if (!op) return 0;
auto* bc = op->GetDataInstance();
if (!bc) return 0;
return this->falloff->GetHandleCount(bc);
}
virtual void GetHandle(BaseObject* op, Int32 index, HandleInfo& info) override {
if (!op) return;
auto* bc = op->GetDataInstance();
if (!bc) return;
this->falloff->GetHandle(index, bc, info);
}
virtual void SetHandle(BaseObject* op, Int32 index, Vector pos, HandleInfo const& info) override {
if (!op) return;
auto* bc = op->GetDataInstance();
if (!bc) return;
this->falloff->SetHandle(index, pos, bc, info);
}
// NodeData Overrides
virtual Bool Init(GeListNode* node_) override {
if (!this->falloff) return false;
auto* op = static_cast<BaseObject*>(node_);
if (!op) return false;
auto* bc = op->GetDataInstance();
if (!bc) return false;
BaseContainer* falloff_vals = this->falloff->GetContainerInstance();
if (!falloff_vals) return false;
bc->MergeContainer(*falloff_vals);
return ObjectData::Init(node_);
}
virtual Bool GetDDescription(GeListNode* node_, Description* desc, DESCFLAGS_DESC& flags) override {
auto* op = static_cast<BaseObject*>(node_);
if (!op || !desc) return false;
auto* bc = op->GetDataInstance();
if (!bc) return false;
if (!desc->LoadDescription(op->GetType())) return false;
flags |= DESCFLAGS_DESC_LOADED;
if (!this->falloff->AddFalloffToDescription(desc, bc)) return false;
return ObjectData::GetDDescription(node_, desc, flags);
}
virtual Bool Message(GeListNode* node_, Int32 msg, void* pdata) override {
auto* op = static_cast<BaseObject*>(node_);
if (!op) return false;
auto* bc = op->GetDataInstance();
if (!bc) return false;
if (!this->falloff->Message(msg, bc, pdata)) return false;
return ObjectData::Message(node_, msg, pdata);
}
};
Thanks,
-Niklas