我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
0 _5 k9 T, G5 t6 Q/ f+ m发生器的代码如下:) P9 u0 }4 c1 G2 b
/**Custom Code*/& G. k) `9 R* n- M+ @: P1 [0 S
: G; S' [0 d: u& H& L2 ?3 O
Object current = ownerobject(c);
2 @3 P" r$ _; A) C3 w/ R g7 `Object item = param(1);
, B+ _( g% I i. W+ ~0 [int port = param(2);
- M2 v! r" K3 `5 f! g* Z& x% B2 g6 `0 g
Object involved = item;
, c; Q# A4 F5 v* t {" O S3 d/ rdouble x1 =180;
% Y3 _& f: u' A& b, v, L: i9 k+ \double y1 = 0;+ u' e4 h& x6 V6 i3 q! S) b
double z1 = 0;
7 E& N3 N1 W5 y) s4 ?0 J: y% h8 o
) \* R, g3 \* J1 |2 @5 t7 mdouble x2 = 0;+ \6 d( X' H) V( | ` _4 T
double y2 = 0;0 T) P2 w8 Y$ q9 y9 e- k) X) h1 L
double z2 = 180;
& s4 d7 L2 |, M+ J
% r: e' D6 q( mdouble x3 = 180;
' w N5 r2 ~+ `" r: ^# c ydouble y3 = 0;! X# x8 f0 i0 [+ ^* h
double z3 = 180;
; ]* y9 w0 n6 x4 {% e. f- O$ X4 X
double x4 = 0;
1 D( ^8 D7 H" C# hdouble y4 = 0;
" \! i7 [5 V' `2 C( y: Q1 idouble z4 = 0;
5 M2 ^" h9 Z& J* Q4 w5 p# m2 d* u* W
double randomVal = duniform(0, 4);/ E3 Z9 h" c( p7 E
if(randomVal < 1)
9 Q8 f* o% H: Y{
2 i: ~$ l2 \( o, x0 @* m setrot(involved, x1, y1, z1);7 E+ L6 j; [2 Q% W7 u
setlabel(involved,"Rotation","xRotation");
& h! |8 G+ T% b' H7 ~4 o}" G' q- L- l( `
else if( randomVal < 2): X+ k' w ~" V( d; Y3 E
{
0 c# M' U' u, R8 b! N U: Z) D' M setrot(involved, x2, y2, z2);
7 ^# _- ^2 z6 }, s' d6 @/ U# f setlabel(involved,"Rotation","zRotation");; V8 m6 O+ n j0 w
}
" I/ B8 k2 r4 t! {8 g1 [: }- Relse if(randomVal < 3 )- @! D9 j& f8 [- i9 \
{
- Y I# j9 P! w" Q; ` setrot(involved, x3, y3, z3);4 t9 R: e' c2 s5 M: W f2 H
setlabel(involved,"Rotation","xzRotation");
* u7 Z4 c# R, h$ C) F Q1 g4 i. P}/ U. x4 U, j X& v. a/ z: v. P- D
else8 n; r! m! u8 R$ Z; m
{5 g0 k- s" L3 v3 |- h4 o. C" p, s! ^
setrot(involved, x4, y4, z4);; H% ~. ~$ ?1 w! s( [3 w6 o+ N: ?
setlabel(involved,"Rotation","noRotation");4 k) H! x% q' v( S! ? \1 p
}* g/ ]. c- S! U4 H; Q/ G
判断的代码如下:4 o" P+ N; ?3 n" n6 k
/**Custom Code*/; U( T0 Y/ h) |# N
Object current =ownerobject(c);
1 q4 u2 {' [8 w1 \Object item = param(1);7 v5 f) T& M. k" p) I; A9 [
int port = param(2);
+ }# @2 l/ D7 N! d: ^ p' X; [% t. k- h
& x3 y w( v9 V1 U* n+ A( NObject involved = item;+ H2 \0 Q" ?5 I m6 |% z
4 H F) E7 D: h# `5 Z$ ~- j: astring labelVal = getlabelstr(involved, "Rotation");
! n3 a3 C7 E/ g9 I5 b6 v
i3 J; y$ O; Xif(labelVal == "xRotation")& F% J% z( O, V: L7 L# U
{
1 d0 y2 k5 j" z" f# F- L return 1; // Divert the item to port 1
+ z, L- X+ @6 @0 }/ r) O}6 P, @% u+ i5 ?( G0 x( g5 @: P
else if(labelVal == "zRotation")) N1 q8 V) y: U" |8 j: h
{7 F$ Y" t( w* s
return 2; // Divert the item to port 2* |0 f4 O) ~& y+ {3 B9 r, X/ ]
}0 L! K( o, @9 D" C
else if(labelVal == "xzRotation"), t- J" u3 O: P5 g" M9 V& U
{( Y( ~% @4 l& F+ v+ O! f
return 3; // Divert the item to port 3! E, L. U- m" S0 ?
}
: ]& m1 ^/ t! V, @4 e; p+ O# welse if(labelVal == "noRotation")
4 t( S! l. m. @2 G{& S, I4 ~6 b" @0 V* _8 b
return 4; // Divert the item to port 4
; O% `3 |( a# ` h}
0 W+ u. p; z& P) \6 J/ n
2 D. p. K/ x& o% B: W5 o* D模型附上:% d1 l; L- c, ~9 b+ G) z0 k
|