1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// MLPV2 Version 2.3j, by Learjeff Innis, based on
//MLP MULTI-LOVE-POSE V1.2 - Copyright (c) 2006, by Miffy Fluffy (BSD License)
// OpenSim port by Jez Ember
// Meta 7 fixes by onefang Rejected and one by Tatjana Kidd.
integer MAX_BALLS = 6;
integer ch;
integer swap;
integer BallCount;
string pr1;
string pr2;
integer Zoffset;
vector RefPos;
rotation RefRot;
getRefPos() { //reference position
RefPos = llGetPos();
RefRot = llGetRot();
Zoffset = (integer)llGetObjectDesc();
RefPos.z += (float) Zoffset / 100.;
}
list Pdata;
getPosNew(string pdata) {
Pdata = llParseString2List(pdata, [" "],[]);
}
setPos() {
pr1 = (string)((vector)llList2String(Pdata, 0) * RefRot + RefPos);
pr2 = (string)((vector)llList2String(Pdata, 2) * RefRot + RefPos);
pr1 += (string)(llEuler2Rot((vector)llList2String(Pdata, 1) * DEG_TO_RAD) * RefRot);
pr2 += (string)(llEuler2Rot((vector)llList2String(Pdata, 3) * DEG_TO_RAD) * RefRot);
if (BallCount > 1) {
llSay(ch+swap,pr1); //msg to ball1/2
llSay(ch+!swap,pr2);
} else {
llSay(ch,pr1); //msg to ball1/2
}
integer ix;
for (ix = 2; ix < BallCount; ++ix) {
llSay(ch + ix, (string)((vector)llList2String(Pdata, 2*ix) * RefRot + RefPos)
+ (string)(llEuler2Rot((vector)llList2String(Pdata, 2*ix + 1) * DEG_TO_RAD) * RefRot));
}
}
getChan() {
ch = (integer)("0x"+llGetSubString((string)llGetKey(),-4,-1)); //fixed channel for prim
}
default {
state_entry() {
getRefPos();
getChan();
}
on_rez(integer arg) {
getRefPos();
getChan();
}
link_message(integer from, integer num, string cmd, key pkey) {
if (cmd == "PRIMTOUCH"){
return;
}
if (num == 1 && cmd == "STOP") {
swap = 0;
return;
}
if (num) return;
if (cmd == "POSE") {
list parms = llCSV2List((string)pkey);
BallCount = llList2Integer(parms,1);
return;
} else if (cmd == "POSEPOS") {
// p = (integer)((string)pkey
getPosNew((string)pkey);
setPos();
} else if (cmd == "SWAP") {
swap = (integer)((string)pkey) & 1;
llSay(ch+swap,pr1); //msg to ball1/2
llSay(ch+!swap,pr2);
} else if (cmd == "REPOS") {
getRefPos();
} else if (llGetSubString(cmd, 0, 0) == "Z") {
// Changed by Tatjana to make it work :)
integer change;
if (llGetSubString(cmd,1,1) == "+") change = (integer)llGetSubString(cmd,2,10);
else change = (integer)llGetSubString(cmd,1,10);
// End Tatjana changing (Penny helped, of course!)
Zoffset += change;
RefPos.z += (float)change/100.;
setPos();
llOwnerSay("Height Adjustment: change by " + (string) change + "cm, new offset: " + (string)Zoffset + "cm");
llSetObjectDesc((string)Zoffset);
} else if (cmd == "GETREFPOS") {
llMessageLinked(LINK_THIS,8,(string)RefPos,(string)RefRot); //send reference position to pose
}
}
}
|