THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/11/2004 at 11:40, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.5+
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
---------
Howdy,
I'm trying to emulate the Move Tool and need some advice. I've looked at the C++SDK Liquid Tool for an example and made alterations to fit the MoveTestPlugin. Everything works except the actual movement. The object zooms out of view. When I'm in 4 Views and drag the mouse in the Top View, I can see the object in the Perspective View zooming away from the camera, no matter which direction I drag the mouse in the Top View.
Anyway here is the test code for MousInput() :
Bool MoveTestPlugin::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;
}
BaseObject *op=doc->GetActiveObject();if (!op) return FALSE;
Matrix opMatrix = op->GetMg();
doc->AddUndo(UNDO_CHANGE, op);
Vector cngVec, opPos, newPos, oldPos=bd->SW(Vector(mx,my,500.0));
Real dx,dy;
BaseContainer device;
win->MouseDragStart(button,mx,my,MOUSEDRAG_NOMOVE);
while (win->MouseDrag(&dx;,&dy;,&device;)==MOUSEDRAG_CONTINUE)
{
if (dx==0.0 && dy==0.0) continue;
newPos = bd->SW(Vector(dx,dy,500.0));
cngVec = newPos - oldPos;
opMatrix.off = opMatrix.off + cngVec;
op->SetMg(opMatrix);
DrawViews(DA_ONLY_ACTIVE_VIEW|DA_NO_THREAD|DA_NO_ANIMATION);
}
if (win->MouseDragEnd()==MOUSEDRAG_ESCAPE)
{
doc->DoUndo(TRUE);
}
EventAdd();
return TRUE;
}
I took a stab in the dark, figuring if I got the old positon of the mouse in WC and the new position of the mouse in WC, calculate the vector between the two, then add that to the position of the object, it would give me the new position, but, obviously my thinking is not quite right.
Any suggestions? Am I mission something else?
Adios,
Cactus Dan