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:
Cinema 4D Version: 9.6-11.5
Platform: Windows ; Mac ;
Language(s) : C++ ;
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();
GePrint("snap is on");
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.
On 22/01/2010 at 03:08, xxxxxxxx wrote:
so nobody has any experience with this ?
(aka bump ..)
On 25/01/2010 at 09:19, xxxxxxxx wrote:
does anbody know what delta exactly returns ?
i always assumed it was the difference between the argument vector of SnapTo, and the nearest possible snap point, according to the snap settings.
seems to give me some unrealistic values though in my tests..
On 26/01/2010 at 00:41, xxxxxxxx wrote:
The delta is indeed the difference between the position to check for snapping and the snap position. Check if SnapTo returns TRUE and if so a snapping was found and delta filled accordingly.
This is the code I used in one of my plugins.
if (!snap) return FALSE;
snap->Init(doc, bd, NULL, Vector(), 0, FALSE, TRUE, TRUE);
Vector pos = ...; //pos is the position i want to check for snapping
if (snap->SnapTo(pos, &delta))
pos += delta; //if pos can be snapped it is set accordingly