我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!$ j7 Q* b8 N' Q& q3 q" r
发生器的代码如下:
6 k# h6 V1 B0 T! r# a/**Custom Code*/
# d. a: W9 l0 w0 m; f2 g, s5 [, O# T( P
Object current = ownerobject(c);$ |7 u& o$ W) Q- w8 k" v; E( ]
Object item = param(1);
/ F9 B2 L* f. r& {9 q' j! t& Mint port = param(2);" e( W# t) f& B. Y" r) H! [, H H
$ O3 }& {/ r" A a3 q9 l* h, k0 T
Object involved = item;4 {% \+ H6 @6 Z$ T
double x1 =180;, ^% k' b" P# D, e
double y1 = 0;* u; @) w8 z+ Z9 |" s1 P/ f$ Z
double z1 = 0;5 ~$ b0 w7 T1 z7 b3 b
: l4 W+ U! h* \, J
double x2 = 0;
. E" F! j) S2 J! I* |% qdouble y2 = 0;5 ^8 y" l7 c8 U( n- k+ M/ W! N
double z2 = 180;
6 Q; J- g. W, I; X7 R$ S/ }
. p- s: U) l0 A& V2 l4 Ddouble x3 = 180;/ F3 k [4 v1 K$ m3 B
double y3 = 0;
" P2 k1 b: _' Q5 ydouble z3 = 180;
8 F& }5 L2 F$ s' X3 y5 p8 w, [
7 S) |9 U4 i6 p9 G! |# edouble x4 = 0;
5 Z9 w% Y% q9 R$ Cdouble y4 = 0;
. z$ l0 q! ?% ~8 ]3 S }. r/ ~double z4 = 0;. A3 M A2 W0 w y4 g
) G5 R* g _( H' s2 b# Xdouble randomVal = duniform(0, 4);
& M4 {; |. Y; tif(randomVal < 1)
e8 Q1 x2 w6 d! ?{" J- y% _& H. K' } t
setrot(involved, x1, y1, z1);
8 m7 N, e" ~# U0 c' ~ setlabel(involved,"Rotation","xRotation");
6 G3 @( y8 ?( L& J3 X8 d}- W. K$ ]. d( f/ a
else if( randomVal < 2)
& j j s2 A3 ]{
% _. u, D/ @7 q8 d. Z setrot(involved, x2, y2, z2);
# f9 w5 g' J. W2 I8 } setlabel(involved,"Rotation","zRotation");7 v- ^) r$ R# l$ s; n. j/ L. `5 `. J
}% G0 `) y! q" a
else if(randomVal < 3 )
+ ^: `; m' G7 ]# p# C{5 _- \6 G! P% u0 v8 s1 T
setrot(involved, x3, y3, z3);
3 K- L3 `5 r7 C9 V8 N setlabel(involved,"Rotation","xzRotation");; O' G1 Z' k y% o) y, H
}2 x* H3 n7 Q, j5 O: g$ o5 k- D0 B
else
8 d/ o3 U5 H G) N{
5 @! z' X" Z+ i. s7 U setrot(involved, x4, y4, z4);
6 H( | ?7 X3 S8 k: t- Q, S setlabel(involved,"Rotation","noRotation");
2 |4 \& j( n1 N [- x( a, ~' ^}2 f" z' ~1 H% m! z+ q
判断的代码如下:) b8 A C% ]! K
/**Custom Code*/. G& u5 P$ X8 x$ p4 t
Object current =ownerobject(c);
# z8 K: p# A9 S0 {Object item = param(1);
3 @5 X1 t; a; K! g0 vint port = param(2);$ d- {# o' o) P+ a1 l
T& I7 Y) v2 e- m! H6 }3 P
Object involved = item;
1 [# Y/ u5 L, z% K
1 q/ v0 n) \7 q) t% u Lstring labelVal = getlabelstr(involved, "Rotation");* |* o) v8 d# P4 ~* @- B
, g& [; ]) m9 l, |& }% Qif(labelVal == "xRotation")
6 a( O: V! j) s& z{
, J6 V) s6 l2 E' G: k) _ return 1; // Divert the item to port 1- h' l# c5 |2 A) {" b& G) v Y
}. t# A8 p6 X ]" f! p
else if(labelVal == "zRotation") P, @: M8 D% _) ^* j
{
/ g" o! ]* u) \6 D! w/ h. H- D return 2; // Divert the item to port 2
: d! p. G8 X& f$ j}
% g" b+ m3 L5 `& h2 a* x+ I" J) }6 ]else if(labelVal == "xzRotation")
) F, w$ @1 X$ |. `9 @2 U{$ Y3 N: C7 t) `& w( U' u7 E
return 3; // Divert the item to port 3: {9 l! v/ _6 @0 j
}( I: P" W5 _, s
else if(labelVal == "noRotation")
% r( q' F$ z9 @! m* g3 f' n( ]{. V* C1 o8 D9 H( ~1 e* F
return 4; // Divert the item to port 4 o# g+ Z5 m3 }5 G: F& M5 ]
}* H3 S [0 l% h. b/ ~" g
3 k* w1 Y+ N& f+ k: |. k模型附上:
% {, f( w$ `* [ |