我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
/ z/ @. R7 P, a' H0 {发生器的代码如下:
/ G8 ]4 F. D* Z% E/**Custom Code*/
3 F2 |7 ?" x2 l6 L, \0 w0 O$ A& [4 |& X- q5 t( t
Object current = ownerobject(c);
; c9 ^" p2 y+ o; ~8 _* y4 T }Object item = param(1);3 X0 T% o3 `+ u* O: {+ d9 N; [8 ^
int port = param(2);
6 I1 ~5 }, Z- `( |+ U8 {5 `0 H+ k* b% _/ b6 e8 B: E# Z& W8 o+ ]/ k n0 g% S
Object involved = item;! O+ w- D2 c: v: T# _6 \2 k% L
double x1 =180;. I* B2 }1 I( C( N) n7 x" O( k% O
double y1 = 0;+ t; h* |: F3 X2 [ c" u3 T
double z1 = 0;& N" k; O1 x; R7 G, S h$ Q% g
6 z+ i, j+ w) [# ?& J9 W; rdouble x2 = 0;6 L% V9 e( m7 T9 S' [
double y2 = 0;2 ]* P; i% {& c3 n; I
double z2 = 180;" k7 E9 c- |, T8 R5 J* M
. u0 a4 f/ d3 ~; u% E- Wdouble x3 = 180;
% V+ ]" D% N4 L* R! j; Q bdouble y3 = 0;
# S! m1 M: {( m3 ^2 n4 mdouble z3 = 180;5 V$ ^' W" V, Z
' W' e* U$ w- I. I2 h$ W F
double x4 = 0;
% x4 [+ p: P' I2 _double y4 = 0;0 _1 b) B' ?2 c$ I7 t
double z4 = 0;1 d/ O c; i+ p4 W- q. J, o) A
& c( \# ^! {/ J: \0 fdouble randomVal = duniform(0, 4);
" J q* h4 v* C g5 G" [- y& j1 tif(randomVal < 1)
& B* z0 v, t G{1 R8 J# N, l2 O2 Q1 t
setrot(involved, x1, y1, z1);$ Q3 x; F. v$ R" U
setlabel(involved,"Rotation","xRotation");, n3 ^: b' h5 N" a6 X: g& Q
}- t U6 p A U" H/ W% i- U- o
else if( randomVal < 2). ?) C: \7 G4 ~7 P( U8 [! m
{ : e7 x# F3 g9 `" B+ b+ _( n
setrot(involved, x2, y2, z2);
" F2 l5 c) n8 K P setlabel(involved,"Rotation","zRotation");; T* j, d: }3 C/ o1 R
}0 l. U4 F" }4 I2 T$ g7 Z% h
else if(randomVal < 3 )
/ c3 G, R( n( R( P; D$ s( }+ |{
6 J6 q: k* n" _6 ? setrot(involved, x3, y3, z3);9 R( R' g$ y5 }: m' x
setlabel(involved,"Rotation","xzRotation");
3 U4 h+ l& C/ v2 g}
0 h' d3 ^. d, \else
" m* t4 |- T8 n+ I' Z{6 {" H7 t, t/ b1 a* O
setrot(involved, x4, y4, z4);
# d O- J* w% R% d1 s setlabel(involved,"Rotation","noRotation");
/ ~9 D+ z5 o' @9 ]}5 s: H- Y; R. D( M! P; u
判断的代码如下:0 Q* C+ { C, b2 I9 {
/**Custom Code*/" C8 _, Y% C) \' a$ p! d- h
Object current =ownerobject(c);
: \# J U- G# p5 S j5 qObject item = param(1);
' s5 g- t# M( [' dint port = param(2);1 ?: k8 x$ P1 m/ Q. ]
) F- U5 G# |& o5 [" k
Object involved = item;$ w" b7 A6 i4 w& o" k; a- M8 {5 G) o' g
8 N! r3 B3 V# C0 C: Bstring labelVal = getlabelstr(involved, "Rotation");
1 s1 c( L# J6 w! e1 G8 T. ^
* w& n3 m, u5 L: D0 G+ Lif(labelVal == "xRotation")
! K- q; F) Q6 j. r/ k% r{6 k _8 ?, d% t; a8 f i) j' p. M3 G" L
return 1; // Divert the item to port 14 d {5 i$ E U/ ^2 {' p% v
}
2 S/ ]! s, \6 w$ t3 V: Y! ?else if(labelVal == "zRotation")2 F9 o3 j0 o. L3 c
{
, B3 P8 F* H! s, _3 O; o- S- l' z return 2; // Divert the item to port 27 m3 H0 t/ T# z) d5 d- N) [: P
}
& a2 E) L1 A$ {else if(labelVal == "xzRotation")3 J9 w9 j) A; o- q' i* |
{
8 i- l$ J9 p) P6 S }& B: Z return 3; // Divert the item to port 3 f, o0 x2 D) n' s
}1 ]" p& `# ?) n5 y* m% f# x% q
else if(labelVal == "noRotation")/ A0 z2 k+ e* C. B
{
) p1 P8 M1 n$ N$ M6 d [ return 4; // Divert the item to port 4
9 X7 H9 C; C/ e# w( K1 a) B}
7 o* b; K# O! }1 Z0 O
* b- Y" X0 ]+ F Z模型附上:
. v) W( i; j1 n7 L7 C- i8 Y' w |