summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2017-01-02 19:32:11 +0100
committerMarkus Mittendrein <git@maxmitti.tk>2017-01-02 19:32:11 +0100
commit4a84af5a6504fc6cc4e719e3bd54170ef5c70d9c (patch)
treeb456d38e7833b9bf49daa00a37a0fdbbf5e38b5e
downloadDTGrabHelper.c4d-4a84af5a6504fc6cc4e719e3bd54170ef5c70d9c.tar.gz
DTGrabHelper.c4d-4a84af5a6504fc6cc4e719e3bd54170ef5c70d9c.zip
Initial
-rw-r--r--ActMap.txt4
-rw-r--r--DefCore.txt8
-rw-r--r--Graphics.pngbin0 -> 126 bytes
-rw-r--r--Script.c77
4 files changed, 89 insertions, 0 deletions
diff --git a/ActMap.txt b/ActMap.txt
new file mode 100644
index 0000000..a0663b3
--- /dev/null
+++ b/ActMap.txt
@@ -0,0 +1,4 @@
+[Action]
+Name=Attach
+Procedure=ATTACH
+FacetBase=1
diff --git a/DefCore.txt b/DefCore.txt
new file mode 100644
index 0000000..d763936
--- /dev/null
+++ b/DefCore.txt
@@ -0,0 +1,8 @@
+[DefCore]
+Name=Grab helper
+id=GH7I
+Category=C4D_Structure
+Grab=2
+Vertices=1
+Width=1
+Height=1
diff --git a/Graphics.png b/Graphics.png
new file mode 100644
index 0000000..5abc9a7
--- /dev/null
+++ b/Graphics.png
Binary files differ
diff --git a/Script.c b/Script.c
new file mode 100644
index 0000000..1aba68d
--- /dev/null
+++ b/Script.c
@@ -0,0 +1,77 @@
+#strict 2
+
+local target;
+local rect;
+
+func Initialize()
+{
+ SetVisibility(VIS_None);
+}
+
+func Set(object targetObj, array targetRect, string name)
+{
+ target = targetObj;
+ name = name || target->GetName();
+ var category = target->GetCategory();
+ if(category & C4D_StaticBack)
+ {
+ category &= ~C4D_StaticBack;
+ category |= C4D_Structure;
+ }
+ SetName(name);
+ SetCategory(category | C4D_MouseIgnore);
+ SetAction("Attach", target);
+
+ rect = targetRect;
+ UpdateTransferZone();
+
+ SetGraphics(0, this, GetID(target), GFX_Overlay, GFXOV_MODE_Picture);
+
+ return this;
+}
+
+func AttachTargetLost()
+{
+ RemoveObject();
+}
+
+func UpdateTransferZone()
+{
+ if(rect)
+ {
+ SetVertex(0, VTX_X, - rect[0] + GetVertex(0, VTX_X, target), this, VTX_SetPermanentUpd);
+ SetVertex(0, VTX_Y, - rect[1] + GetVertex(0, VTX_Y, target), this, VTX_SetPermanentUpd);
+ SetShape(0, 0, rect[2], rect[3]);
+ }
+}
+
+func ControlLeft() { return target && target->~ControlLeft(...); }
+func ControlLeftDouble() { return target && target->~ControlLeftDouble(...); }
+func ControlLeftSingle() { return target && target->~ControlLeftSingle(...); }
+func ControlLeftReleased() { return target && target->~ControlLeftReleased(...); }
+func ControlRight() { return target && target->~ControlRight(...); }
+func ControlRightDouble() { return target && target->~ControlRightDouble(...); }
+func ControlRightSingle() { return target && target->~ControlRightSingle(...); }
+func ControlRightReleased() { return target && target->~ControlRightReleased(...); }
+func ControlUp() { return target && target->~ControlUp(...); }
+func ControlUpDouble() { return target && target->~ControlUpDouble(...); }
+func ControlUpSingle() { return target && target->~ControlUpSingle(...); }
+func ControlUpReleased() { return target && target->~ControlUpReleased(...); }
+func ControlDown() { return target && target->~ControlDown(...); }
+func ControlDownDouble() { return target && target->~ControlDownDouble(...); }
+func ControlDownSingle() { return target && target->~ControlDownSingle(...); }
+func ControlDownReleased() { return target && target->~ControlDownReleased(...); }
+func ControlThrow() { return target && target->~ControlThrow(...); }
+func ControlThrowDouble() { return target && target->~ControlThrowDouble(...); }
+func ControlThrowSingle() { return target && target->~ControlThrowSingle(...); }
+func ControlThrowReleased() { return target && target->~ControlThrowReleased(...); }
+func ControlDig() { return target && target->~ControlDig(...); }
+func ControlDigDouble() { return target && target->~ControlDigDouble(...); }
+func ControlDigSingle() { return target && target->~ControlDigSingle(...); }
+func ControlDigReleased() { return target && target->~ControlDigReleased(...); }
+func Grabbed() { return target && target->~Grabbed(...); }
+
+global func AddGrabHelper()
+{
+ return CreateObject(GH7I)->Set(this, ...);
+}