THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/01/2010 at 03:40, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.6-11.5
Platform: Windows ; Mac ;
Language(s) : C++ ;
---------
Hi,
i want to add some snapping functionality to my Tool plugin, so I'm currently asking myself if i have to compute everything myself, or if I can use the DetectSnapping lib.
So I included the standart snapping tab in my toolPlugin.res, and alloc'd a DetectSnapping object.
Also I added the 'PLUGINFLAG_TOOL_SNAPSETTINGS' flag when registering the ToolPlugin.
Then I try to detect a snap in my MouseInput function, like this:
BaseObject* obj = doc->GetActiveObject();
.
.
AutoAlloc<DetectSnapping> detect;
detect->Init(doc,bd,obj,NULL,0,TRUE,TRUE,TRUE);
Vector delta;
.
.
if(button==KEY_MLEFT){
if(detect->IsEnabled(doc)){
GePrint("snap is on");
detect->SnapTo(res.hitpos,δ);
Utils::printVec("",delta);
}
else GePrint("Snap is off!");
.
.
res.hitpos is the rayCollider hit position on obj, that i click with the mouse.
'IsEnabled' works as it should, it gives me TRUE when its enabled in my snapping tab, but the result in delta seems to be incorrect.
When i set mode to 'Snap3D' and enable point-snap, delta is off like 100-200 units even though i click directly onto a point of obj, in the perspective view.
So my question is how to use the DetectSnapping.lib and does it provide the complete snapping functionality that for example the move tool has ?
Am I on the right track with the above code, or does it not work like that ?
When i call SnapTo() does it take into account all the settings i did in the snapping tab of my plugin automatically,as it is the standart c4d snapping tab, and i set the snapping flag in registerToolPlugin(..) ?
There dont seem to be any examples on how to use it, so the above code is actually just my guess on how to use it.
greetings,
Daniel