R14 Snap system
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/09/2012 at 02:29, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 14
Platform:
Language(s) : C++ ;---------
HiHow do I get the position of the settings when you snap and snap the new R14.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/09/2012 at 02:43, xxxxxxxx wrote:
Hi,
Could you explain better what's the position from snapping you want to get?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/09/2012 at 08:33, xxxxxxxx wrote:
Hi.
If you check the settings of the snap on the R13 is.BaseContainer* bc=doc->GetSettingsInstance(DOCUMENTSETTINGS_MODELING);
if(bc->GetBool( SNAP_ENABLE))
{
****
}If you want to set the snap.
BaseContainer bc;
bc.SetBool( SNAP_ENABLE, TRUE);
doc->SetData(DOCUMENTSETTINGS_MODELING,bc);If you look at the position of the snap when you.
AutoAlloc<DetectSnapping> snap;
if (!snap) return FALSE;
snap->Init(doc, bd, NULL, Vector(), 0, FALSE, TRUE, TRUE);
Vector delta;
if(snap->IsEnabled(doc))
{
if (snap->SnapTo(pos, δ))
{
pos += delta;
}
}All the code does not work in R14.
What I want how I write?
Thanks in advance. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/09/2012 at 12:16, xxxxxxxx wrote:
Yes the snapping system in CINEMA has been completely changed in R14.
To check if snapping is enabled in a document we have to call now:
IsSnapEnabled(doc)
And to enable snapping in a document:
EnableSnap(TRUE, doc)
These functions are defined c4d_snapdata.h so be sure to include this header.
And the new snap interface class is SnapCore.
I'll come up with a working example as soon as possible. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/09/2012 at 19:42, xxxxxxxx wrote:
Now you can set the snap. Thank you.
I would like to ask another, please tell me how to set up and switching SNAP_SETTINGS_MODE.
Thank you. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/09/2012 at 04:31, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I would like to ask another, please tell me how to set up and switching SNAP_SETTINGS_MODE.
Here's how to setup SNAP_SETTINGS_MODE in R14:
BaseContainer bc = SnapSettings(doc); bc.SetLong(SNAP_SETTINGS_MODE, SNAP_SETTINGS_MODE_2D); SnapSettings(doc, bc);
Snap settings are defined in resource\res\description\dmodeling.h.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/09/2012 at 08:15, xxxxxxxx wrote:
Originally posted by xxxxxxxx
If you look at the position of the snap when you.
AutoAlloc<DetectSnapping> snap;
if (!snap) return FALSE;
snap->Init(doc, bd, NULL, Vector(), 0, FALSE, TRUE, TRUE);
Vector delta;
if(snap->IsEnabled(doc))
{
if (snap->SnapTo(pos, &delta))
{
pos += delta;
}
}Here's this code converted to use the new snapping classes in R14:
SnapResult res; AutoAlloc<SnapCore> snap; if (!snap) return FALSE; snap->Init(doc, bd); if (IsSnapEnabled(doc)) { if (snap->Snap(pos, res)) { pos += res.delta; } }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/09/2012 at 18:22, xxxxxxxx wrote:
I understand this snap.
Thank you very much. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/10/2012 at 09:28, xxxxxxxx wrote:
Following you're examples I have snapping working in my plugin but I've got an issue. I'm calling Snap() from within a MouseDrag while loop which works fine, but once Snap() returns True it will never return False again. Is this a bug or do I need to clear out the SnapCore or something?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/10/2012 at 00:34, xxxxxxxx wrote:
Hi,
Here's how to use SnapCore within a MouseDrag() loop:
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; } AutoAlloc<SnapCore> snap; // Allocate snap if (!snap) return FALSE; snap->Init(doc, bd); Real dx, dy; BaseContainer bc; BaseContainer device; Vector pos; SnapResult res; BaseObject *active = doc->GetActiveObject(); win->MouseDragStart(button, mx, my, MOUSEDRAGFLAGS_DONTHIDEMOUSE|MOUSEDRAGFLAGS_NOMOVE); while (win->MouseDrag(&dx,&dy,&device)==MOUSEDRAGRESULT_CONTINUE) // Start drag { // Increment mouse position during drag mx += dx; my += dy; pos = bd->SW(Vector(mx, my, 500)); // Update pos if (snap->Snap(pos, res)) // If point snap anywhere { pos += res.delta; // Pos will be updated with snapped delta } if (active) active->SetAbsPos(pos); // Set the object position to the new one! DrawViews(DRAWFLAGS_ONLY_ACTIVE_VIEW|DRAWFLAGS_NO_THREAD|DRAWFLAGS_NO_ANIMATION); // Update viewport } win->MouseDragEnd(); // Reset viewport status EventAdd();
This code snaps the active object; you can test it in Liquid Painting Tool example (LiquidToolData::MouseInput()).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/10/2012 at 05:31, xxxxxxxx wrote:
Yeah that's pretty much the code I was using though you also have to tell the snap system to ignore the active object or it will go crazy, but I still have the issue. It isn't really noticeable on workplane snapping but the other modes it is.
So using the code you provided, if you create a scene with a cube and a sphere, if you turn on vertex snapping, select the sphere and then activate the tool, in this case the LiquidTool, you can drag around the scene and the sphere will follow. But once you snap it to one of the vertices on the cube you'll never be able to unsnap it off the cube until you release the mouse button and reclick. I would think if your mouse is nowhere near a vertex it should go back to just following your cursor.