How to emulate the Move Tool?
-
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 -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/11/2004 at 14:01, xxxxxxxx wrote:
Howdy,
OK, I made a few of changes and got it to work except not in the Perspective view. The Top, Side and Front views are working as expected, but in the Perspective view the object does not move at all.
Here is the revised code:
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 transMatrix, opMatrix = op->GetMg();
transMatrix = opMatrix;doc->AddUndo(UNDO_CHANGE, op);
Vector cngVec, opPos = opMatrix.off , newPos, oldPos=bd->SW(Vector(mx,my,0.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;mx+=dx;
my+=dy;
newPos = bd->SW(Vector(mx,my,0.0));
cngVec = (newPos - oldPos)*opMatrix;
transMatrix.off = cngVec - opPos ;
op->SetMg(transMatrix);DrawViews(DA_ONLY_ACTIVE_VIEW|DA_NO_THREAD|DA_NO_ANIMATION);
}
if (win->MouseDragEnd()==MOUSEDRAG_ESCAPE)
{
doc->DoUndo(TRUE);
}EventAdd();
return TRUE;
}Why does it not work in the Perspective view? Any ideas?
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/11/2004 at 14:27, xxxxxxxx wrote:
Howdy,
Aha, it is moving in the perspective view, but in micro increments. If I keep the mouse button down and pick the mouse up and start moving it over and over again, the object does move.
if I change the lines "bd->SW(Vector(mx,my,0.0))" back to "bd->SW(Vector(mx,my,500.0))" it moves good in the Perspective view but way too fast in the other views. I reckon I just need to check which view is active and change that value accordingly.
Thanks anyway, but I got it working myself. Don't you just love it?
Adios,
Cactus Dan