On 31/08/2015 at 10:01, xxxxxxxx wrote:
Howdy,
Well, actually the handles aren't an issue. I've got them working perfectly with the Cinema 4D native tools in R12 and R13+.
The problem I'm having is how to calculate the matrix properly in the test tool to manipulate the handles in R12.
Here's my test code for TestTool::MouseInput() :
Bool TestTool::MouseInput(BaseDocument *doc, BaseContainer &data, BaseDraw *bd,EditorWindow *win, const BaseContainer &msg)
{
Real mx = msg.GetReal(BFM_INPUT_X);
Real my = msg.GetReal(BFM_INPUT_Y);
LONG button;
switch (msg.GetLong(BFM_INPUT_CHANNEL))
{
case BFM_INPUT_MOUSELEFT : button=KEY_MLEFT; break;
case BFM_INPUT_MOUSERIGHT: button=KEY_MRIGHT; break;
default: return TRUE;
}
BaseContainer state;
GetInputState(BFM_INPUT_KEYBOARD, BFM_INPUT_CHANNEL, state);
QUALIFIER qlfy = (QUALIFIER)state.GetLong(BFM_INPUT_QUALIFIER);
BaseObject *op = doc->GetActiveObject();
Matrix opM = op->GetMg();
BaseObject *cam = bd->GetEditorCamera(); if(!cam) return true;
Real mz = 0.0;
if(bd->GetProjection() == 0)
{
mz = Len(op->GetMg().off - cam->GetMg().off);
}
else
{
Vector pPos = bd->WS(op->GetMg().off);
mz = pPos.z;
}
ObjectData *oNode = static_cast<ObjectData*>(op->GetNodeData());
Real dx,dy;
BaseList2D *undo = NULL;
doc->AddUndo(UNDOTYPE_CHANGE, op);
undo = doc->GetUndoPtr();
BaseContainer device;
win->MouseDragStart(button,mx,my,MOUSEDRAGFLAGS_DONTHIDEMOUSE|MOUSEDRAGFLAGS_NOMOVE);
while (win->MouseDrag(&dx,&dy,&device)==MOUSEDRAGRESULT_CONTINUE)
{
if(undo->GetType() != op->GetType()) break;
mx+=dx;
my+=dy;
#if API_VERSION < 13000
Matrix m = Matrix();
m.off = Vector(mx,my,mz);
oNode->MoveHandle(op, (BaseObject* )undo, m, hID, qlfy)
#else
oNode->MoveHandle(op, (BaseObject* )undo, Vector(mx,my,mz), hID, qlfy, bd);
#ndif
DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW|DRAWFLAGS_NO_THREAD|DRAWFLAGS_NO_ANIMATION);
}
EventAdd();
return TRUE;
}
The above code works somewhat in R12 but not at all angles. It works perfectly in R13. So, I'm assuming the matrix "m" that I'm passing to ObjectData::MoveHandle() for R12 is not correct. The rounded tube example for R12 isn't showing the use of GetHandle(), SetHandle(), but I managed to get that working creating my own HandleInfo class for R12. There is no example anywhere of a tool to manipulate object handles, so even though I've figured out how to get that to work in R13+, it doesn't work quite right for R12 because R12 needs a matrix passed to the ObjectData::MoveHandle() function instead of a vector, as with R13+.
All I really need to know is how to properly calculate that matrix for R12 and the tool will work properly in R12, too. :wink:
Adios,
Cactus Dan