我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!+ j; y! D' R2 L% t5 K$ t& k
发生器的代码如下:9 \6 m; d; Q' Y% z* v
/**Custom Code*/
" _1 w$ o! ^9 Q
5 d( [1 T+ U9 U5 m/ AObject current = ownerobject(c);- c- C& Q- B: D, N2 d) s3 c! f
Object item = param(1);
9 M4 e/ c1 u5 @/ `4 U$ P' Gint port = param(2);
8 t, l& K. [- z8 n$ b ~
9 Z: l" C; S# ^5 |/ y! XObject involved = item;
. L- K9 E" P0 T8 Y' O0 }6 Idouble x1 =180;- t5 Y. o5 i# l" y
double y1 = 0;
( M9 s$ s3 J6 cdouble z1 = 0;
$ h: M. _+ b8 J8 i4 d# v& X% p3 m; d4 | k
double x2 = 0;
( F2 H4 J# t4 c$ j* pdouble y2 = 0;+ e3 D5 m# a7 j6 ]; b" F& g
double z2 = 180;5 h4 t6 V9 }1 t5 o9 R6 T* ]
" N" J2 R4 l+ Wdouble x3 = 180;& x! H8 }, d2 U9 a$ P5 a: ?
double y3 = 0;
4 A2 ?( J; T1 B) }double z3 = 180;* z! `7 s. `, ?
% a! e# h; } M) G' j$ Fdouble x4 = 0;
/ f, \7 F) K) D$ Pdouble y4 = 0;
7 f5 `9 b- i4 N1 R$ pdouble z4 = 0;' V& O9 r I$ x; q0 C3 V$ j7 E
% i5 c+ `9 t7 i: ~. i8 Sdouble randomVal = duniform(0, 4);, C: Q% k# S0 |2 u& l
if(randomVal < 1)
q$ m9 b8 m8 [+ |* G* e/ B{
, z8 O+ Z; w j; e: {7 M setrot(involved, x1, y1, z1); }, n" L8 ~" s) c
setlabel(involved,"Rotation","xRotation");
" Q/ x- g$ z2 M* D: h& y} Z3 Q( n6 }7 |0 ^
else if( randomVal < 2)
) L y j5 I' k$ _8 c8 ]{ 4 i; ^) h# N- P% S% b
setrot(involved, x2, y2, z2);0 U7 J9 D0 B4 b( ~" ]+ C. t
setlabel(involved,"Rotation","zRotation");$ v& |* A3 H6 A1 T; A) z& i5 y
}
# f5 l7 Q2 }; S& g) i$ o9 helse if(randomVal < 3 )
/ V3 i. A5 l6 a{
# F4 w1 _0 e( Z9 S7 O setrot(involved, x3, y3, z3);# V9 U+ `1 ~! g: C3 S! o0 e
setlabel(involved,"Rotation","xzRotation");
9 \. l; t! _' S+ F6 ?}) j4 Z& O: q% E$ u, T
else
* d7 X( z) H W/ D8 |2 G{
5 K# ^3 C, f" H( `# K4 i setrot(involved, x4, y4, z4);2 M5 u1 x+ {3 @ W9 W) d% n2 t
setlabel(involved,"Rotation","noRotation"); X5 d4 M8 w* f$ \! g: a
}0 R3 G) f) A5 h9 t9 q) V' P2 W
判断的代码如下:
* u$ C( Z4 h# |* @- b. F/**Custom Code*/
7 H) T U, V- h; nObject current =ownerobject(c);/ n# Z. r) ^7 B+ m/ @
Object item = param(1);! U, \0 z9 _# j1 u, R$ S
int port = param(2);
, \0 ~& ]) K2 V
. [! y3 l' H" W3 n0 o+ g1 I. C [Object involved = item;
+ z1 F+ F/ t" V6 y1 i% ~1 k7 w, F0 j
) y) H9 I! m, h$ J1 Dstring labelVal = getlabelstr(involved, "Rotation");) J/ v2 C) }! _2 I
3 j% h) I$ U1 i, |if(labelVal == "xRotation")7 v( y% _. t* ]( ?4 ]
{
$ `4 t1 \6 L9 T8 ]1 [' B return 1; // Divert the item to port 1! ?4 F a1 U( C
}
4 [' d: L9 K; ]# J" d0 [else if(labelVal == "zRotation")
4 n5 n) M/ G* D3 E% h( y{
7 [; M0 a: C* q3 w8 g, A return 2; // Divert the item to port 2
/ Y4 X0 p3 e) T+ L" M! k' @* h}, k1 K* S8 Z( o/ p) @( U
else if(labelVal == "xzRotation")3 _' e$ x6 X$ m+ A
{
9 Z0 V. m6 h- R2 ?9 f/ F2 p5 B( P( h return 3; // Divert the item to port 3/ x4 ?8 I3 c5 Q1 z) }/ D
}/ O* |6 N- w, k+ E
else if(labelVal == "noRotation")/ X, j( L& D6 k' u O6 B) X( O
{) N+ O% K0 B- k4 P
return 4; // Divert the item to port 4# h" b; D: h# E) }* g
}
2 v9 S- G% C3 M
0 B. ^1 C+ H# g& {& L模型附上:
0 a! i$ y9 k5 y# j0 Y/ @ |