我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
, d1 w) T9 \0 n$ s发生器的代码如下:
# t/ b- ], _2 C( \/**Custom Code*/ W5 r2 M9 C8 C
" o3 J* g1 R; VObject current = ownerobject(c);. d5 d. F7 H3 j) y. T# C# L- T, F. F
Object item = param(1);
, r. S2 F1 Q! o& R$ S! jint port = param(2);
' [* p! B" }$ K6 v, A2 f
% k) r2 C8 a# t% G ~! AObject involved = item;
& ?0 w2 [0 `8 bdouble x1 =180;6 u& e0 C0 B: A! Y6 F6 M: D
double y1 = 0;
. l& @$ W) [& H. O2 Z* j( Adouble z1 = 0;' I: I3 x! }4 y2 S
4 }' Y5 l0 `7 B# C
double x2 = 0;, H. W* g h* V0 l$ x* B' [. Q7 e
double y2 = 0;
4 a0 g1 {0 N6 l5 q/ y$ f( j. Adouble z2 = 180;
; s" q0 e6 A- n5 X& u& i# _7 h$ r% A5 V
double x3 = 180;% v: X% y; f% r2 {' U- ]. z
double y3 = 0;
: I9 N1 _' t7 \9 D4 _7 `; ~6 ]double z3 = 180;
5 V4 o& V# E* v) E" C& F# {& f* B7 Q9 f8 V0 x D
double x4 = 0;! ?5 Q0 i+ j% f1 Z* ^1 Y- h
double y4 = 0;1 |& I" j% G% d' q A! z7 P) s
double z4 = 0;
9 _4 f. S: I. B9 D" @! g* \ L+ I
double randomVal = duniform(0, 4);
3 y, M1 i( x3 h# `if(randomVal < 1)' u, D/ @2 h4 A( W4 F
{8 I* b9 t0 e$ L6 W9 k
setrot(involved, x1, y1, z1);, y( G1 _- o( }& o8 g) \/ S
setlabel(involved,"Rotation","xRotation");
8 {$ v7 I- x! j* U. i ?$ g* {6 y1 N}9 b" D: [$ Z/ o3 D/ |- K# }
else if( randomVal < 2)
$ ?# k+ P0 e, ]2 B" A6 X3 W{ % H+ ]7 \6 U B3 q. r3 {
setrot(involved, x2, y2, z2);% Y8 Z* S* K& \9 _8 @4 B' C& R
setlabel(involved,"Rotation","zRotation");* R. V3 D- [5 g( L. N
}& @' t' j4 g5 H# c+ i
else if(randomVal < 3 )
6 ]4 e7 k k4 `; [. Z{
6 G" E6 r, G( y! m. E setrot(involved, x3, y3, z3);. a0 B5 f6 D8 [7 l3 u1 U
setlabel(involved,"Rotation","xzRotation");
$ `" P! D8 a: b9 o}
0 ~/ Q" x# `( K& |else% S- L$ L M" y& h9 U" X
{7 W/ E0 |% t4 A6 p3 }
setrot(involved, x4, y4, z4);
+ j! I# e' q) s setlabel(involved,"Rotation","noRotation");
8 z; ~3 t7 L' j}. E# S7 y; T% u
判断的代码如下:
( E% O. u% P' r+ s/**Custom Code*/+ z( c# X1 k) h+ O
Object current =ownerobject(c);' } P b7 b# u, t: J( j
Object item = param(1);/ R" { @1 \ c. e
int port = param(2);( V; C: v2 l( @2 c3 T+ a+ I
* i" J2 }1 U' U: f! L/ t0 j& gObject involved = item;& B; c& m- u4 l a9 Q
, N1 [+ R0 M6 Y; sstring labelVal = getlabelstr(involved, "Rotation");
! \; [! t1 v: ]: f+ N3 J4 J- V8 ^& \# c2 Y5 x$ h
if(labelVal == "xRotation")
9 i+ g" I- M$ r3 @, W{& @1 }) `9 B' h
return 1; // Divert the item to port 1
& _& ^' o* Y8 }8 F5 B& o7 a1 j% f}
* c0 f2 l' z% O& }$ Y+ X. Nelse if(labelVal == "zRotation")
; ^& v$ u' y; |0 ]: s0 R{/ y h* M, K b: S! q& V
return 2; // Divert the item to port 2
7 G* C) {5 }% r}% D$ e! B5 f6 h
else if(labelVal == "xzRotation")
5 f2 A% q- M! G. X! c2 d{2 o1 M9 x: {; l3 H' d, Y( A+ q
return 3; // Divert the item to port 3
4 P/ L; R: u7 D& M* G$ H}
; E' C' C$ x, w% s; w% H1 h" k% selse if(labelVal == "noRotation")
8 H5 h9 N: f& k{7 F' U; k) ~& g. l
return 4; // Divert the item to port 4
$ r7 q/ y0 V6 {6 w1 @}
% L. C- d' N! A
! t+ _$ H7 [) B, g4 s模型附上:' o/ O; i9 Z( \4 c, G9 a/ X
|