aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Henry <nusmuk@users.sourceforge.net>2014-01-31 10:25:51 +0000
committerCyrille Henry <nusmuk@users.sourceforge.net>2014-01-31 10:25:51 +0000
commitd42c6bfc5c07014f122671a963278360deae846f (patch)
tree8d905bcfc2173311ca07bcb80a72b3b5ce1bcfd6
parent911fe2c2cf1e281f6fd8190473c1cd2fa356c140 (diff)
remoce forceXT messages familly and merge fonctionality with force messages familly (to be consistent with other messages that accept table input
svn path=/trunk/externals/pmpd/; revision=17262
-rw-r--r--CHANGELOG.txt8
-rw-r--r--examples/66_setK_table.pd16
-rw-r--r--pmpd-help.pd41
-rw-r--r--pmpd.c2
-rw-r--r--pmpd2d-help.pd40
-rw-r--r--pmpd2d.c4
-rw-r--r--pmpd2d_various.c80
-rw-r--r--pmpd3d-help.pd47
-rw-r--r--pmpd3d.c6
-rw-r--r--pmpd3d_various.c106
-rw-r--r--pmpd_various.c36
11 files changed, 279 insertions, 107 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 47a1ad4..2851530 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,7 +1,7 @@
from version 0.10 to version 0.11
- code refactorisation
-- all messages name switch to singular for messages uniformisation
+- all messages name switch to singular for messages uniformisation (old are keep for compatbility)
- add fonctionality to messages masses*L in order to add filter on masses Id (symbol only)
- same for links*L messages
- New messages linkEnd[1,2][X,Y,Z]T
@@ -13,7 +13,6 @@ from version 0.10 to version 0.11
- new messages testMassL and testLinkL (idem as testMass and testLink but with list)
- new messages massDistance Id Id : return message : massesDistance float_Id float_Id distance
- new messages setLCurrent Id [proportion] to change a link size depending on it's size and it's curent length
-- new message : forceXT [Id] table (same in other dimention), to add a force to many masses, value come from the table.
- new message : setActive, setInactive for links
- new statistics messages for links
- new interactors messages
@@ -25,4 +24,7 @@ from version 0.10 to version 0.11
- debug "setL Id" with no arg : bad computation of link length (2d / 3d)
- lot's of bugfix
- switch to makefile template 1.0.14
-- addd default aguments for mass and link creation. (this allow to create a mass with a [mass< message better than [mass mass 1 1 0< message)
+- add default aguments for mass and link creation. (this allow to create a mass with a [mass< message better than [mass mass 1 1 0< message)
+- new examples
+- few set messages can accept 2 symbol : 1 for the class of link/mass to control, 1 for the table name to use as source for the data (so that 1 single message can set lot's of mass/link with diferent data in a very efficient way)
+
diff --git a/examples/66_setK_table.pd b/examples/66_setK_table.pd
index 2c0f3f8..6815e3b 100644
--- a/examples/66_setK_table.pd
+++ b/examples/66_setK_table.pd
@@ -1,9 +1,9 @@
-#N canvas 80 656 798 297 10;
+#N canvas 111 480 772 393 10;
#X declare -lib Gem;
#X obj 52 8 loadbang;
#X obj 64 31 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
-#N canvas 1296 344 692 614 creation 0;
+#N canvas 1227 349 692 614 creation 0;
#X obj 41 20 inlet;
#X obj 51 48 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
@@ -102,15 +102,21 @@
#X array force 100 float 2;
#X coords 0 1 99 -1 200 140 1;
#X restore 491 3 graph;
-#X msg 146 52 setK tab_force force \, bang \, massPos mobil;
#X text 404 -56 draw in the table to change link rigidity independendy
of each link;
+#N canvas 0 50 450 250 (subpatch) 0;
+#X array K 100 float 2;
+#X coords 0 1 99 -1 200 140 1;
+#X restore 489 165 graph;
+#X msg 146 52 setK tab_force K \, bang \, massPos mobil;
+#X msg 163 81 force mobil force;
#X connect 0 0 2 0;
#X connect 1 0 2 0;
#X connect 2 0 10 0;
#X connect 4 0 5 0;
-#X connect 5 0 12 0;
+#X connect 5 0 14 0;
#X connect 6 0 7 0;
#X connect 8 0 9 0;
#X connect 10 0 8 0;
-#X connect 12 0 10 0;
+#X connect 14 0 10 0;
+#X connect 15 0 10 0;
diff --git a/pmpd-help.pd b/pmpd-help.pd
index 91c22fe..bca64e8 100644
--- a/pmpd-help.pd
+++ b/pmpd-help.pd
@@ -1,4 +1,4 @@
-#N canvas 165 139 590 764 10;
+#N canvas 161 149 590 764 10;
#X obj 4 369 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X obj 5 709 cnv 15 550 40 empty empty empty 20 12 0 14 -158509 -66577
@@ -186,7 +186,7 @@ on outlet No 1;
#X text 187 652 Put position of the 2 link end on a table [\$1] \,
filter on link Id is possible;
#X restore 12 517 pd links_attributes ___;
-#N canvas 161 121 997 789 dynamic 0;
+#N canvas 157 131 997 789 dynamic 0;
#X obj 5 3 cnv 15 900 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 10 85 cnv 15 130 650 empty empty empty 20 12 0 14 -233017 -66577
@@ -209,7 +209,6 @@ filter on link Id is possible;
#X msg 20 265 setFixed \$1;
#X text 146 94 Set position of fixed mass(es);
#X text 187 125 \$2 : Value;
-#X text 188 179 \$2 : Value;
#X text 147 196 Set minimimum and maximum position of all masses;
#X text 147 244 Set mass to mobile or fixed;
#X msg 471 150 setD \$1 \$2;
@@ -304,6 +303,7 @@ that amplifies forces that oppose to movment. Use at your own risk.
#X text 631 642 \$2 : overdamp value (float or table);
#X text 183 690 \$2 : damping (float or table);
#X text 184 629 \$1 : damping (float or table);
+#X text 188 179 \$2 : Value (float or symbol);
#X restore 12 477 pd dynamic settings ___;
#N canvas 573 185 571 697 creation____________ 0;
#X obj 11 95 cnv 15 100 60 empty empty empty 20 12 0 14 -233017 -66577
@@ -566,7 +566,7 @@ or fixed \, in this case forces applied to them automatically \, by
links \, or manually \, by messages \, don't do anything.;
#X connect 1 0 2 0;
#X restore 18 715 pd More_Info;
-#N canvas 422 178 607 825 masses_attributes___ 0;
+#N canvas 420 183 614 722 masses_attributes___ 0;
#X obj 5 3 cnv 15 590 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 7 307 cnv 15 150 100 empty empty empty 20 12 0 14 -233017 -66577
@@ -585,15 +585,15 @@ links \, or manually \, by messages \, don't do anything.;
#X obj 8 414 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X text 206 383 \$1 (optional): Masses Id;
-#X obj 9 658 cnv 15 150 150 empty empty empty 20 12 0 14 -233017 -66577
+#X obj 9 558 cnv 15 150 150 empty empty empty 20 12 0 14 -233017 -66577
0;
-#X obj 9 637 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
+#X obj 9 537 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
0;
-#X text 172 666 output the closest mass;
-#X text 201 680 \$1 : position;
-#X text 12 637 others :;
-#X msg 17 666 closestMass \$1 (\$2);
-#X text 201 695 \$2 : none or Id;
+#X text 172 566 output the closest mass;
+#X text 201 580 \$1 : position;
+#X text 12 537 others :;
+#X msg 17 566 closestMass \$1 (\$2);
+#X text 201 595 \$2 : none or Id;
#X obj 5 75 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X text 7 74 General :;
@@ -605,16 +605,8 @@ links \, or manually \, by messages \, don't do anything.;
#X msg 14 224 massForce [\$1];
#X text 201 238 massPos symbolId number forceX forceY forceZ;
#X msg 14 165 massSpeed [\$1];
-#X obj 9 538 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
-0;
-#X text 202 592 \$1 : table name;
-#X text 201 611 \$2 : masses name;
-#X obj 10 559 cnv 15 150 70 empty empty empty 20 12 0 14 -233017 -66577
-0;
-#X msg 21 566 forceXT \$1 [\$2];
-#X text 12 538 Table in:;
-#X msg 16 717 massDistance [\$1 [\$2]];
-#X text 199 732 distance mass1 mass2 distanceX \, distanceY \, distanceZ
+#X msg 16 617 massDistance [\$1 [\$2]];
+#X text 199 632 distance mass1 mass2 distanceX \, distanceY \, distanceZ
\, distance;
#X msg 17 320 massPosL (\$1);
#X msg 17 340 massForceL (\$1);
@@ -634,16 +626,15 @@ links \, or manually \, by messages \, don't do anything.;
#X text 15 30 The attributes messages ask the object to output some
of its internal parameters. They can be output as lists for positions
and forces of masses.;
-#X text 170 569 apply a force to masses. Force comes from a table;
-#X text 175 718 output a series of messages :;
+#X text 175 618 output a series of messages :;
#X text 11 414 Tables out:;
#X text 167 444 Output all masses positions on a table;
#X text 167 465 Output all forces applied on masses on a table;
#X text 167 485 Output all speeds of the masses on a table;
#X text 200 517 \$2 (optional): Masses Id);
#X text 200 502 \$1 = table name;
-#X text 197 760 \$1 (optional): Masses Id;
-#X text 197 776 \$2 (optional): Masses Id;
+#X text 197 660 \$1 (optional): Masses Id;
+#X text 197 676 \$2 (optional): Masses Id;
#X restore 12 497 pd masses_attributes___;
#N canvas 410 289 631 464 statistics 0;
#X obj 20 41 cnv 15 170 150 empty empty empty 20 12 0 14 -233017 -66577
diff --git a/pmpd.c b/pmpd.c
index 470b407..d22fc05 100644
--- a/pmpd.c
+++ b/pmpd.c
@@ -227,7 +227,7 @@ void pmpd_setup(void)
class_addmethod(pmpd_class, (t_method)pmpd_grabMass, gensym("grabMass"), A_DEFFLOAT, A_DEFFLOAT, 0);
class_addmethod(pmpd_class, (t_method)pmpd_closestMass, gensym("closestMass"), A_GIMME, 0);
class_addmethod(pmpd_class, (t_method)pmpd_massDistances, gensym("massDistance"), A_GIMME, 0);
- class_addmethod(pmpd_class, (t_method)pmpd_forcesXT, gensym("forceXT"), A_GIMME, 0);
+// class_addmethod(pmpd_class, (t_method)pmpd_forcesXT, gensym("forceXT"), A_GIMME, 0);
/*
pmpd_deprecated
diff --git a/pmpd2d-help.pd b/pmpd2d-help.pd
index 4787a01..04369b9 100644
--- a/pmpd2d-help.pd
+++ b/pmpd2d-help.pd
@@ -1,4 +1,4 @@
-#N canvas 297 149 572 750 10;
+#N canvas 295 154 572 750 10;
#X declare -lib Gem;
#X obj 4 309 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
@@ -574,7 +574,7 @@ the model. Messages create links and masses or destroy them.;
links. They work as general links but their calculation is made following
a vector.;
#X restore 12 407 pd creation____________;
-#N canvas 88 109 1057 814 dynamic 0;
+#N canvas 86 114 1057 814 dynamic 0;
#X obj -35 3 cnv 15 900 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj -30 85 cnv 15 150 670 empty empty empty 20 12 0 14 -233017 -66577
@@ -625,7 +625,6 @@ a vector.;
#X msg 0 506 setForceY \$1 \$2;
#X text 150 131 \$2 / \$3 : Value;
#X msg -20 163 force \$1 \$2 \$3;
-#X text 152 202 \$2 / \$3 : Value;
#X text 156 241 \$1 / \$2 : Value;
#X msg -1 550 setSpeedX \$1 \$2;
#X msg -1 569 setSpeedY \$1 \$2;
@@ -699,10 +698,11 @@ uses this argument as the value applied to all masses (or links);
#X text 160 748 \$2 : damping (float or table);
#X text 160 693 \$2 : damping (float or table);
#X text 159 445 \$2 : New Id;
+#X text 152 202 \$2 / \$3 : Value (float or symbol);
#X restore 12 427 pd dynamic settings ___;
#X text 112 658 54_pmpd2dtest.pd;
#X obj 325 272 print;
-#N canvas 10 95 1153 632 masses_attributes___ 0;
+#N canvas 50 100 1153 632 masses_attributes___ 0;
#X obj 5 75 cnv 15 500 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X obj 5 3 cnv 15 500 15 empty empty empty 20 12 0 14 -233017 -66577
@@ -760,26 +760,17 @@ uses this argument as the value applied to all masses (or links);
#X msg 550 278 massForcesXT \$1 [\$2];
#X msg 550 297 massForcesYT \$1 [\$2];
#X msg 550 315 massSpeedsNormT \$1 [\$2];
-#X obj 545 491 cnv 15 170 110 empty empty empty 20 12 0 14 -233017
+#X obj 545 401 cnv 15 170 110 empty empty empty 20 12 0 14 -233017
-66577 0;
-#X obj 543 469 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
+#X obj 543 379 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
0;
-#X text 725 498 output the closest mass;
-#X text 546 469 others :;
-#X msg 555 557 massDistance [\$1 [\$2]];
-#X text 764 572 distance mass1 mass2 distanceX \, distanceY \, distanceZ
+#X text 725 408 output the closest mass;
+#X text 546 379 others :;
+#X msg 555 467 massDistance [\$1 [\$2]];
+#X text 764 482 distance mass1 mass2 distanceX \, distanceY \, distanceZ
\, distance;
-#X obj 542 380 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
-0;
-#X text 764 428 \$1 : table name;
-#X text 763 444 \$2 : masses name;
-#X obj 543 401 cnv 15 170 50 empty empty empty 20 12 0 14 -233017 -66577
-0;
-#X msg 551 408 forceXT \$1 [\$2];
-#X msg 571 428 forceYT \$1 [\$2];
-#X msg 551 500 closestMass \$1 \$2 \$3 [\$4];
-#X text 545 380 Table in:;
-#X text 764 541 \$3 : none or Id;
+#X msg 551 410 closestMass \$1 \$2 \$3 [\$4];
+#X text 764 451 \$3 : none or Id;
#X text 15 30 The attributes messages ask the object to output some
of its internal parameters. They can be output as lists for positions
and forces of masses.;
@@ -789,8 +780,7 @@ and forces of masses.;
#X text 172 499 Output all forces applied to masses in a list on outlet
No 1;
#X text 724 263 Output all forces applied to masses on a table;
-#X text 730 406 apply a force to masses. Force comes from a table;
-#X text 729 558 output a series of messages :;
+#X text 729 468 output a series of messages :;
#X text 170 310 Output all mass positions in a list on outlet No 1
;
#X text 168 361 Output all norm of position vectors (sqrt(x*x+y*y))
@@ -816,8 +806,8 @@ a table;
#X text 724 315 Output all norm of force vectors (sqrt(x*x+y*y)) on
a table;
#X text 544 5 tables out :;
-#X text 764 512 \$1 : x position;
-#X text 764 527 \$2 : y position;
+#X text 764 422 \$1 : x position;
+#X text 764 437 \$2 : y position;
#X restore 12 447 pd masses_attributes___;
#N canvas 437 480 725 566 tests 0;
#X obj 5 3 cnv 15 700 15 empty empty empty 20 12 0 14 -233017 -66577
diff --git a/pmpd2d.c b/pmpd2d.c
index 665089d..4d71b19 100644
--- a/pmpd2d.c
+++ b/pmpd2d.c
@@ -308,8 +308,8 @@ void pmpd2d_setup(void)
class_addmethod(pmpd2d_class, (t_method)pmpd2d_closestMass, gensym("closestMass"), A_GIMME, 0);
class_addmethod(pmpd2d_class, (t_method)pmpd2d_massDistances, gensym("massDistance"), A_GIMME, 0);
- class_addmethod(pmpd2d_class, (t_method)pmpd2d_forcesXT, gensym("forceXT"), A_GIMME, 0);
- class_addmethod(pmpd2d_class, (t_method)pmpd2d_forcesYT, gensym("forceYT"), A_GIMME, 0);
+// class_addmethod(pmpd2d_class, (t_method)pmpd2d_forcesXT, gensym("forceXT"), A_GIMME, 0);
+// class_addmethod(pmpd2d_class, (t_method)pmpd2d_forcesYT, gensym("forceYT"), A_GIMME, 0);
/*
pmpd3d_deprecated
diff --git a/pmpd2d_various.c b/pmpd2d_various.c
index 2e90cd1..d0deec0 100644
--- a/pmpd2d_various.c
+++ b/pmpd2d_various.c
@@ -39,7 +39,10 @@ void pmpd2d_force(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
// add a force to a specific mass
int tmp, i;
-
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+
if ( (argc == 3) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
@@ -58,13 +61,38 @@ void pmpd2d_force(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ if (n >= npoints-2) break;
+ x->mass[i].forceX += vec[n].w_float;
+ n++;
+ x->mass[i].forceY += vec[n].w_float;
+ n++;
+ }
+ }
+ }
+ }
}
void pmpd2d_forceX(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
// add a force to a specific mass
int tmp, i;
-
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+
if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
@@ -81,13 +109,35 @@ void pmpd2d_forceX(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
-}
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ x->mass[i].forceX += vec[n].w_float;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }}
void pmpd2d_forceY(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
// add a force to a specific mass
int tmp, i;
-
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+
if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
@@ -104,6 +154,26 @@ void pmpd2d_forceY(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ x->mass[i].forceY += vec[n].w_float;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }
}
void pmpd2d_min(t_pmpd2d *x, t_float minX, t_float minY)
@@ -382,6 +452,7 @@ void pmpd2d_massDistances(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
}
}
+/*
void pmpd2d_forcesXT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
{
// add forces to masses. forces comes from a table, masse can be filter on ther Id or not
@@ -473,3 +544,4 @@ void pmpd2d_forcesYT(t_pmpd2d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+*/
diff --git a/pmpd3d-help.pd b/pmpd3d-help.pd
index c0d6000..0a3dc24 100644
--- a/pmpd3d-help.pd
+++ b/pmpd3d-help.pd
@@ -1,4 +1,4 @@
-#N canvas 1018 178 570 717 10;
+#N canvas 1016 183 570 717 10;
#X declare -lib Gem;
#X obj 4 289 cnv 15 550 15 empty empty empty 20 12 0 14 -158509 -66577
0;
@@ -129,7 +129,7 @@ mass mob 1 100 1 0 -1 \, mass mob 1 100 0 0 -1 \, mass mob 1 100 1
#X obj 17 226 pmpd3d;
#X text 417 226 2 Send forces;
#X text 112 617 01_pmpd3dtest.pd;
-#N canvas 254 213 950 547 creation____________ 0;
+#N canvas 252 218 950 547 creation____________ 0;
#X obj 5 75 cnv 15 450 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X obj 5 3 cnv 15 450 15 empty empty empty 20 12 0 14 -233017 -66577
@@ -200,7 +200,7 @@ the model. Messages create links and masses or destroy them.;
links. They work as general links except their calculation is made
following a vector.;
#X restore 12 377 pd creation____________;
-#N canvas 72 184 1143 866 dynamic 0;
+#N canvas 70 189 1143 866 dynamic 0;
#X obj 5 3 cnv 15 1050 15 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 5 84 cnv 15 150 750 empty empty empty 20 12 0 14 -233017 -66577
@@ -249,7 +249,6 @@ following a vector.;
#X msg 39 521 setForceY \$1 \$2;
#X text 189 131 \$2 / \$3 : Value;
#X msg 15 171 force \$1 \$2 \$3;
-#X text 189 212 \$2 / \$3 : Value;
#X text 173 730 Change environement damping;
#X msg 39 582 setSpeedX \$1 \$2;
#X msg 39 601 setSpeedY \$1 \$2;
@@ -334,9 +333,10 @@ uses this argument as the value applied to all masses (or links);
#X text 193 819 \$2 : damping (float or table);
#X text 195 761 \$2 : damping (float or table);
#X text 193 467 \$2 : New Id;
+#X text 189 212 \$2 / \$3 : Value (float or symbol);
#X restore 12 397 pd dynamic settings ___;
#X text 158 397 To set the model parameters after creation.;
-#N canvas 155 259 1157 693 masses_attributes 0;
+#N canvas 153 264 1157 693 masses_attributes 0;
#X obj 5 95 cnv 15 500 15 empty empty empty 20 12 0 14 -158509 -66577
0;
#X obj 5 3 cnv 15 500 15 empty empty empty 20 12 0 14 -233017 -66577
@@ -361,16 +361,16 @@ No 1;
#X text 206 627 \$1 (optional): Masses Id;
#X text 769 383 \$2 (optional): Masses Id;
#X text 768 370 \$1 : table name;
-#X obj 551 541 cnv 15 170 110 empty empty empty 20 12 0 14 -233017
+#X obj 551 431 cnv 15 170 110 empty empty empty 20 12 0 14 -233017
-66577 0;
-#X obj 549 519 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
-0;
-#X text 730 548 output the closest mass;
-#X text 552 519 others :;
-#X text 764 564 \$1 : x -position;
-#X text 764 579 \$2 : y -position;
-#X text 764 594 \$3 : z -position;
-#X text 764 606 \$4 : none or Id;
+#X obj 549 409 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
+0;
+#X text 730 438 output the closest mass;
+#X text 552 409 others :;
+#X text 764 454 \$1 : x -position;
+#X text 764 469 \$2 : y -position;
+#X text 764 484 \$3 : z -position;
+#X text 764 496 \$4 : none or Id;
#X msg 9 125 massPos [\$1];
#X text 191 246 \$1 : id float or symbol of masses (nothing for all)
;
@@ -382,13 +382,9 @@ No 1;
#X msg 9 206 massForce [\$1];
#X text 195 218 massPos symbolId number forceX forceY forceZ;
#X msg 9 165 massSpeed [\$1];
-#X msg 560 627 massDistance [\$1 [\$2]];
-#X text 757 643 distance mass1 mass2 distanceX \, distanceY \, distanceZ
+#X msg 560 517 massDistance [\$1 [\$2]];
+#X text 757 533 distance mass1 mass2 distanceX \, distanceY \, distanceZ
\, distance;
-#X obj 548 410 cnv 15 590 15 empty empty empty 20 12 0 14 -158509 -66577
-0;
-#X text 768 453 \$1 : table name;
-#X text 767 469 \$2 : masses name;
#X msg 8 306 massPosL [\$1];
#X msg 8 325 massPosXL [\$1];
#X msg 28 344 massPosYL [\$1];
@@ -404,11 +400,6 @@ No 1;
#X msg 31 551 massForceYL [\$1];
#X msg 30 570 massForceZL [\$1];
#X msg 10 589 massForceNormL [\$1];
-#X obj 549 431 cnv 15 170 80 empty empty empty 20 12 0 14 -233017 -66577
-0;
-#X msg 557 438 forceXT \$1 [\$2];
-#X msg 578 458 forceYT \$1 [\$2];
-#X msg 577 478 forceZT \$1 [\$2];
#X msg 555 38 massPosT \$1 [\$2];
#X msg 555 57 massPosXT \$1 [\$2];
#X msg 575 76 massPosYT \$1 [\$2];
@@ -424,9 +415,8 @@ No 1;
#X msg 576 297 massForcesYT \$1 [\$2];
#X msg 576 316 massForcesZT \$1 [\$2];
#X msg 556 335 massSpeedsNormT \$1 [\$2];
-#X msg 558 549 closestMass \$1 \$2 \$3 [\$4];
+#X msg 558 439 closestMass \$1 \$2 \$3 [\$4];
#X text 548 5 tables out :;
-#X text 551 410 Table in:;
#X text 15 30 The attributes messages ask the object to output some
of its internal parameters. They can be output as lists for positions
and forces of masses \, or directly send value to a table.;
@@ -457,8 +447,7 @@ No 1;
;
#X text 732 335 Output all norm of forces vectors (sqrt(x*x+y*y)) in
a list on outlet No 1;
-#X text 727 433 apply a force to masses. Force comes from a table;
-#X text 725 628 output a series of messages :;
+#X text 725 518 output a series of messages :;
#X restore 12 417 pd masses_attributes __;
#N canvas 164 124 1167 755 links_attributes 0;
#X obj 5 3 cnv 15 550 15 empty empty empty 20 12 0 14 -233017 -66577
diff --git a/pmpd3d.c b/pmpd3d.c
index 037ba97..bbd5ccc 100644
--- a/pmpd3d.c
+++ b/pmpd3d.c
@@ -340,9 +340,9 @@ void pmpd3d_setup(void)
class_addmethod(pmpd3d_class, (t_method)pmpd3d_closestMass, gensym("closestMass"), A_GIMME, 0);
class_addmethod(pmpd3d_class, (t_method)pmpd3d_massDistances, gensym("massDistance"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesXT, gensym("forceXT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesYT, gensym("forceYT"), A_GIMME, 0);
- class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesZT, gensym("forceZT"), A_GIMME, 0);
+// class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesXT, gensym("forceXT"), A_GIMME, 0);
+// class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesYT, gensym("forceYT"), A_GIMME, 0);
+// class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesZT, gensym("forceZT"), A_GIMME, 0);
/*
pmpd3d_deprecated
diff --git a/pmpd3d_various.c b/pmpd3d_various.c
index cb316db..13912ea 100644
--- a/pmpd3d_various.c
+++ b/pmpd3d_various.c
@@ -41,7 +41,10 @@ void pmpd3d_force(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
// add a force to a specific mass
t_int tmp, i;
-
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+
if ( (argc == 4) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) && ( argv[2].a_type == A_FLOAT ) && ( argv[3].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
@@ -62,13 +65,40 @@ void pmpd3d_force(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ if (n >= npoints-3) break;
+ x->mass[i].forceX += vec[n].w_float;
+ n++;
+ x->mass[i].forceY += vec[n].w_float;
+ n++;
+ x->mass[i].forceZ += vec[n].w_float;
+ n++;
+ }
+ }
+ }
+ }
}
void pmpd3d_forceX(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
// add a force to a specific mass
t_int tmp, i;
-
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+
if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
@@ -85,13 +115,36 @@ void pmpd3d_forceX(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ x->mass[i].forceX += vec[n].w_float;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }
}
void pmpd3d_forceY(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
// add a force to a specific mass
t_int tmp, i;
-
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+
if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
@@ -108,13 +161,36 @@ void pmpd3d_forceY(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ x->mass[i].forceY += vec[n].w_float;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }
}
void pmpd3d_forceZ(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
// add a force to a specific mass
t_int tmp, i;
-
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+
if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
@@ -131,6 +207,26 @@ void pmpd3d_forceZ(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ x->mass[i].forceZ += vec[n].w_float;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }
}
void pmpd3d_min(t_pmpd3d *x, t_float minX, t_float minY, t_float minZ)
@@ -449,6 +545,7 @@ void pmpd3d_massDistances(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
+/*
void pmpd3d_forcesXT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
{
// add forces to masses. forces comes from a table, masse can be filter on ther Id or not
@@ -586,3 +683,4 @@ void pmpd3d_forcesZT(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+*/
diff --git a/pmpd_various.c b/pmpd_various.c
index eeaf95b..124368c 100644
--- a/pmpd_various.c
+++ b/pmpd_various.c
@@ -28,14 +28,17 @@ void pmpd_forceX(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
// add a force to a specific mass
int tmp, i;
-
- if ( ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
+ t_garray *a;
+ int npoints, n;
+ t_word *vec;
+
+ if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
tmp = max(0, min( x->nb_mass-1, tmp));
x->mass[tmp].forceX += atom_getfloatarg(1, argc, argv);
}
- if ( ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
{
for (i=0; i< x->nb_mass; i++)
{
@@ -45,6 +48,26 @@ void pmpd_forceX(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+ else if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_SYMBOL ) )
+ {
+ if (!(a = (t_garray *)pd_findbyclass(atom_getsymbolarg(1,argc,argv), garray_class)))
+ pd_error(x, "%s: no such array", atom_getsymbolarg(1,argc,argv)->s_name);
+ else if (!garray_getfloatwords(a, &npoints, &vec))
+ pd_error(x, "%s: bad template for tabLink", atom_getsymbolarg(1,argc,argv)->s_name);
+ else
+ {
+ n=0;
+ for (i=0; i < x->nb_mass; i++)
+ {
+ if ( atom_getsymbolarg(0,argc,argv) == x->mass[i].Id)
+ {
+ x->mass[i].forceX += vec[n].w_float;
+ n++;
+ if (n >= npoints) break;
+ }
+ }
+ }
+ }
}
void pmpd_minX(t_pmpd *x, t_float min)
@@ -61,13 +84,13 @@ void pmpd_addPosX(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
int tmp, i;
- if ( ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
+ if ( (argc == 2) && ( argv[0].a_type == A_FLOAT ) && ( argv[1].a_type == A_FLOAT ) )
{
tmp = atom_getfloatarg(0, argc, argv);
tmp = max(0, min( x->nb_mass-1, tmp));
x->mass[tmp].posX += atom_getfloatarg(1, argc, argv);
}
- if ( ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
+ if ( (argc == 2) && ( argv[0].a_type == A_SYMBOL ) && ( argv[1].a_type == A_FLOAT ) )
{
for (i=0; i< x->nb_mass; i++)
{
@@ -247,7 +270,7 @@ void pmpd_massDistances(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
-
+/*
void pmpd_forcesXT(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
{
// add forces to masses. forces comes from a table, masse can be filter on ther Id or not
@@ -293,3 +316,4 @@ void pmpd_forcesXT(t_pmpd *x, t_symbol *s, int argc, t_atom *argv)
}
}
}
+*/