我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!6 P4 u$ W" O7 J$ }, w9 q0 x
发生器的代码如下:
- D- ?# F& B* d: @" ~/**Custom Code*/
! z) c# b: ` ^- P& o8 H* _" b# ]9 Q
6 g B3 s& M) n6 i9 D7 @* bObject current = ownerobject(c);- l a1 t- |' e' R
Object item = param(1);
; J+ V4 N1 N' y5 k' N' j, n3 sint port = param(2);( ]% {2 ~( l) x1 A, q9 ]4 V/ I
V X5 N8 f' AObject involved = item;
$ P( [2 _/ Z z! E" N" H3 Ddouble x1 =180;
4 n& @0 c" M" }double y1 = 0;
+ F4 }% d+ B9 K* D- wdouble z1 = 0;
4 E/ [) H+ d* |$ j. `* ], t7 ?1 ?$ L7 Y! G- c! T- `
double x2 = 0;- K( _: b: d5 q" y# n% X
double y2 = 0;
; X8 x3 c$ H e8 \% k. t _double z2 = 180;; M0 p( A1 ^: u; j
( {$ h4 e& G% v5 {' l) ?
double x3 = 180;
/ e7 {1 H" g9 O& R$ D0 Edouble y3 = 0;# t: K/ X$ o R
double z3 = 180;' @* x+ o8 ? P, r* l
2 X2 @& h+ r t2 i
double x4 = 0;
6 n; B# M# C; \2 U$ ]+ Hdouble y4 = 0;
& d/ r% V+ l. U, | p0 j9 Qdouble z4 = 0; N! l1 y6 E, E$ ^
1 y% e6 |. I! H' v; k4 G& N, w
double randomVal = duniform(0, 4);3 M- t" |: w& `% }1 s% n
if(randomVal < 1)) m# _7 f! t4 c' O" f+ D
{8 w. Q/ V3 R5 p Q& D# e: L; L
setrot(involved, x1, y1, z1);
6 z+ c4 u: P, x# e setlabel(involved,"Rotation","xRotation");
s* o3 R# T; p) X: `: w" W: Z}1 B2 {4 u( I3 C5 U0 \
else if( randomVal < 2)/ t7 j* R. z/ h$ f' |/ O
{
' x; J9 j) P* d1 G1 r- T) V setrot(involved, x2, y2, z2);* v9 ^! I! F9 g# m! h) l( K! E _
setlabel(involved,"Rotation","zRotation");' N( W/ Q% x5 K8 C; a1 j% ^/ ^
}% x! `$ D1 ~5 r8 o$ {
else if(randomVal < 3 )& @ z6 R# f1 g
{
% p. @+ A; R6 @# i( `, M) ]+ i& s; x setrot(involved, x3, y3, z3);
$ X( U2 U6 N5 T& U% s4 ^( ?5 s setlabel(involved,"Rotation","xzRotation");
2 }0 \+ h6 _' p2 G! [}8 w8 C! \- y; B% o) U7 l
else s5 {, G. ^1 F& E5 a
{3 U8 Y2 R6 I% B
setrot(involved, x4, y4, z4);
F! d9 y) J9 [- M% f, {$ U, c setlabel(involved,"Rotation","noRotation");
& L- l: n' z: ~, L! n: p}
+ V1 t$ M5 t0 A2 f# `7 o+ s判断的代码如下:
5 \5 u( i! X( i# w# ?! }8 b/**Custom Code*/
; Y" H$ A& r" rObject current =ownerobject(c);
- X7 E2 J6 Y+ Q$ G9 O3 F0 VObject item = param(1);! C; [- c' n. [2 @( w* y
int port = param(2);, d1 p3 ^% l0 @9 a
' C4 Z8 s1 Q P) G% u# m
Object involved = item;0 A5 m, c! a7 \+ G! u
. X) l9 W+ x2 A
string labelVal = getlabelstr(involved, "Rotation");7 {. Q- `/ E: h8 M
3 G6 w" {% T( c
if(labelVal == "xRotation")' k' k3 V" o% z8 f$ A. _
{- ?- _2 O0 ?+ W G) ?
return 1; // Divert the item to port 16 K6 B4 m* U! Y* ?$ P
}
9 [4 }- y' _) E) V" s1 relse if(labelVal == "zRotation")
7 z! X! W% `. z. x{; P& @8 j. d$ r( }
return 2; // Divert the item to port 2
& I9 _5 \: @2 `& t: R+ X4 [6 W}
3 ?9 J2 f3 f B% m) ]) zelse if(labelVal == "xzRotation")
" w) O' G3 G( C( I0 d{; K+ O- Q1 O' }' O% w0 y
return 3; // Divert the item to port 30 P# a& K% c) F7 i
}. l3 i: c# [! y2 X% \ T
else if(labelVal == "noRotation")
; c- c& i/ Y" r4 S8 I9 e' a{
6 y: E, G3 D" B& h return 4; // Divert the item to port 4
/ H: u3 E4 S. ~}, `+ w9 a: l* u( Z
0 J8 L; s0 }, w) w0 C5 {
模型附上:
5 U6 A) W) }: v |