THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/08/2012 at 11:28, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R12
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;
---------
In my previous builds for Cinema 4D R12, handles were working. Now that I have added some new features to the plugin and rebuilt, the handle no longer shows in Cinema 4D R12.048. I've updated the Resource folder and used the Spherify.cpp as an example but nothing seems to make the handle appear anymore! I am about to rebuild the api library and see if anything changes but this is VERY frustrating. You guys must stop going back and forth on changes and solidify a path wherein updates to the SDK (esp. within the same version) do not break existing code. I am currently working on updating FIVE C4D versions (15 builds!). This could take me weeks - and I have days. Stop already. ;(
// ObjectData.Draw
//*---------------------------------------------------------------------------*
#ifdef C4D_R13
DRAWRESULT UnfurlObj::Draw(BaseObject* op, DRAWPASS drawpass, BaseDraw* bd, BaseDrawHelp* bh)
#else
DRAWRESULT UnfurlObj::Draw(PluginObject* op, DRAWPASS drawpass, BaseDraw* bd, BaseDrawHelp* bh)
#endif
//*---------------------------------------------------------------------------*
{
if (!(op && bd && bh)) return DRAWRESULT_DRAWN;
if (drawpass == DRAWPASS_OBJECT)
{
BaseContainer* bc = op->GetDataInstance();
if (!bc) return SUPER::Draw(op, drawpass, bd, bh);
PolygonObject* dop = GetPolygonObject(op);
if (!dop) return SUPER::Draw(op, drawpass, bd, bh);
BaseTag* tag = dop->GetTag(ID_UNFURL_TAG);
if (!tag) return SUPER::Draw(op, drawpass, bd, bh);
UnfurlTag* uf = static_cast<UnfurlTag*>(tag->GetNodeData());
if (!uf) return SUPER::Draw(op, drawpass, bd, bh);
dop = GetCurrentStateToObject(dop);
if (!dop) return SUPER::Draw(op, drawpass, bd, bh);
uf->MyDraw(tag, dop, bd, bh, bc->GetReal(UNFURL_UNFURL_AMOUNT));
PolygonObject::Free(dop);
}
else if (drawpass == DRAWPASS_HANDLES)
{
#ifdef C4D_R13
LONG hitid = op->GetHighlightHandle(bd);
HandleInfo info;
bd->SetPen(GetViewColor(VIEWCOLOR_ACTIVEPOINT));
bd->SetMatrix_Matrix(op, bh->GetMg());
GetHandle(op, 0L, info);
if (hitid == 0L) bd->SetPen(GetViewColor(VIEWCOLOR_SELECTION_PREVIEW));
else bd->SetPen(GetViewColor(VIEWCOLOR_ACTIVEPOINT));
bd->DrawHandle(info.position, DRAWHANDLE_BIG, 0L);
GetHandle(op, 1L, info);
bd->SetPen(GetViewColor(VIEWCOLOR_ACTIVEPOINT));
bd->DrawLine(info.position, Vector(0.0), 0L);
#else
// Draw "Unfurl Amount" Handle
Matrix m = bh->GetMg();
#ifdef C4D_R12
//bd->SetMatrix_Matrix(NULL, Matrix());
bd->SetMatrix_Matrix(op, m);
#endif
LONG hit = op->GetHighlightHandle(bd);
if (hit == 0L) bd->SetPen(GetViewColor(VIEWCOLOR_SELECTION_PREVIEW));
else bd->SetPen(GetViewColor(VIEWCOLOR_ACTIVEPOINT));
#ifdef C4D_R12
//bd->DrawHandle(GetUnfurlHandle(op),DRAWHANDLE_BIG,0L);
bd->DrawHandle(GetUnfurlHandle(op)*m,DRAWHANDLE_BIG,0L);
#else
bd->Handle3D(GetUnfurlHandle(op)*m,DRAWHANDLE_BIG);
#endif
// Line from center to Handle
bd->SetPen(GetViewColor(VIEWCOLOR_ACTIVEPOINT));
#ifdef C4D_R12
//bd->DrawLine(GetUnfurlHandle(op),Vector(0.0),0L);
bd->DrawLine(GetUnfurlHandle(op)*m,m.off,0L);
#else
bd->Line3D(GetUnfurlHandle(op)*m,m.off);
#endif
#endif
return DRAWRESULT_DRAWN;
}
return SUPER::Draw(op, drawpass, bd, bh);
}
#ifdef C4D_R13
// ObjectData.GetHandle
//*---------------------------------------------------------------------------*
void UnfurlObj::GetHandle(BaseObject* op, LONG i, HandleInfo& info)
//*---------------------------------------------------------------------------*
{
BaseContainer* data = op->GetDataInstance();
if (!data) return;
info.position.x = data->GetReal(UNFURL_UNFURL_AMOUNT)*125.0;
info.direction.x = 1.0;
info.type = HANDLECONSTRAINTTYPE_LINEAR;
}
// ObjectData.DetectHandle
//*---------------------------------------------------------------------------*
LONG UnfurlObj::DetectHandle(BaseObject* op, BaseDraw* bd, LONG x, LONG y, QUALIFIER qualifier)
//*---------------------------------------------------------------------------*
{
HandleInfo info;
GetHandle(op, 0L, info);
return (bd->PointInRange(info.position*op->GetMg(),x,y))?0L:NOTOK;
}
// ObjectData.MoveHandle
//*---------------------------------------------------------------------------*
Bool UnfurlObj::MoveHandle(BaseObject* op, BaseObject* undo, const Vector& mouse_pos, LONG hit_id, QUALIFIER qualifier, BaseDraw* bd)
//*---------------------------------------------------------------------------*
{
BaseContainer* dst = op->GetDataInstance();
if (!dst) return TRUE;
HandleInfo info;
Real val = mouse_pos.x;
GetHandle(op, hit_id, info);
if (bd)
{
Matrix mg = op->GetUpMg() * undo->GetMl();
Vector pos = bd->ProjectPointOnLine(info.position * mg, info.direction ^ mg, mouse_pos.x, mouse_pos.y);
val = (pos * !mg) * info.direction;
}
if (hit_id != 0L) return TRUE;
dst->SetReal(UNFURL_UNFURL_AMOUNT,FCut01(val*0.008));
return TRUE;
}
#else
// UnfurlObj.GetUnfurlHandle
//*---------------------------------------------------------------------------*
Vector UnfurlObj::GetUnfurlHandle(PluginObject* op)
//*---------------------------------------------------------------------------*
{
BaseContainer* bc = op->GetDataInstance();
if (!bc) return Vector(0.0);
return Vector(bc->GetReal(UNFURL_UNFURL_AMOUNT)*125.0,0.0,0.0);
}
// ObjectData.DetectHandle
//*---------------------------------------------------------------------------*
LONG UnfurlObj::DetectHandle(PluginObject* op, BaseDraw* bd, LONG x, LONG y, QUALIFIER qualifier)
//*---------------------------------------------------------------------------*
{
return (bd->PointInRange(GetUnfurlHandle(op)*op->GetMg(),x,y))?0L:NOTOK;
}
// ObjectData.MoveHandle
//*---------------------------------------------------------------------------*
Bool UnfurlObj::MoveHandle(PluginObject* op, PluginObject* undo, const Matrix& tm, LONG hit_id, QUALIFIER qualifier)
//*---------------------------------------------------------------------------*
{
BaseContainer* src = undo->GetDataInstance();
if (!src) return TRUE;
BaseContainer* dst = op->GetDataInstance();
if (!dst) return TRUE;
Real val = src->GetReal(UNFURL_UNFURL_AMOUNT)+(tm.off.x*0.008);
dst->SetReal(UNFURL_UNFURL_AMOUNT, FCut01(val));
return TRUE;
}
#endif