我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
/ a* }$ V1 z% C. S$ S' n发生器的代码如下:
$ N' r5 ~0 O1 k; i2 }( N/**Custom Code*/) U7 S3 C* y7 U. q1 H
; u+ P/ l& Z& s: W$ N
Object current = ownerobject(c);
% L, y& o. |' G1 q: L' M7 C4 Z. kObject item = param(1);, U- K% f+ k; L- e6 D
int port = param(2);& m h) E4 B: }
) M2 B5 g" E( |$ A7 {5 D. H
Object involved = item;
/ `5 `% r% M1 j3 sdouble x1 =180;
" w2 \6 e/ j, y; H9 p. q* zdouble y1 = 0;
. }$ N& W3 |; i. N- ]6 Mdouble z1 = 0;, U& u- n; I$ ?9 K3 k/ B( r
. C# Y$ T+ w: ?double x2 = 0;( j* h4 G' K- N( y
double y2 = 0;
$ F) i" Y& I7 q; ?$ B/ wdouble z2 = 180;$ r1 v5 @5 J: f
, |( I& o z. x9 Y
double x3 = 180;" K/ g4 b2 k7 C9 @. b
double y3 = 0;
( @( j) S2 D2 q7 b# W% p Y* {7 rdouble z3 = 180;" ~6 n W# r) j, n# R* d& g
+ Y c; |3 C/ ~ M( T# ~. p% u
double x4 = 0;: N7 J' P$ r" T8 f" a$ ?
double y4 = 0;
9 ?, f# ^' K# ^: g& j" B' Q* qdouble z4 = 0;2 `1 n& x0 g3 Q/ {% K+ d3 @, m
" t% `% @- k( ^8 O: x
double randomVal = duniform(0, 4);) |# y1 b, l. C4 V8 z
if(randomVal < 1)
3 h8 |$ z# i0 X% n, c{/ }: b1 G$ a0 I& B& \
setrot(involved, x1, y1, z1);
7 c. x+ t- }, K. B9 d2 S- s! f$ s setlabel(involved,"Rotation","xRotation");
* c; ~/ J4 i4 M4 Y3 H}
- R) `4 l( h5 }5 H1 C, m- Jelse if( randomVal < 2)
7 j! B, V' E. j* }{ 5 y* H" @6 V: C
setrot(involved, x2, y2, z2);
. m' f2 I& p$ l setlabel(involved,"Rotation","zRotation");
* k- \& H1 Q& ` e' q3 h}& v! ]4 d2 R# }9 m5 i# y
else if(randomVal < 3 )
2 n# w1 K s3 ]1 a, `: a{* v: g" I" [- a" R0 f" ]) c
setrot(involved, x3, y3, z3);7 q; \: n3 M! u0 }' H! r
setlabel(involved,"Rotation","xzRotation");& a( {5 t5 G4 ?: D0 W* _
}
3 Z' t- ^# Q: V" Y4 uelse( l; M4 K- d4 T' y' ?
{
4 G" v9 X' o! ?/ s setrot(involved, x4, y4, z4);
. i3 J& C: P- K3 F6 q& U setlabel(involved,"Rotation","noRotation");, Z4 t+ E$ q8 C+ X6 [2 ~& e
}$ c* M" s" m* {4 X2 P4 X/ Q6 K* M- K' _
判断的代码如下:% Z2 M$ E5 j( t( e8 I3 d* y) v
/**Custom Code*/3 V( g! P% S: {, A g7 W; }3 \0 Z
Object current =ownerobject(c);
3 y z3 s* _3 ^# d3 CObject item = param(1);; j: p0 k# ^7 @: c, x. ~2 P5 ~
int port = param(2);
; m+ I! f/ D1 r9 e8 O C' h+ e
5 `* q1 W! M* z3 @Object involved = item;) H; G8 K; k2 }6 L* V
, k- ?2 E7 E' J# G- Kstring labelVal = getlabelstr(involved, "Rotation");
( @2 N; y, e# Y1 R
5 V, r r4 N- w( F1 m) s# y ]if(labelVal == "xRotation")$ }/ ?2 Z- D: a# G3 K6 [
{3 A0 u3 \5 }; U# f3 r& z$ I9 M7 ]
return 1; // Divert the item to port 1
( H& T" |* j5 ?}
& S* w8 ` x% d6 p3 xelse if(labelVal == "zRotation")
3 E% _' A+ O! p: ^0 j{
3 k, O% W/ K9 Y" P( ^# B return 2; // Divert the item to port 2
( D1 N0 e9 U9 g& @5 v2 m}& h& y# c/ y- [: u9 Q/ t
else if(labelVal == "xzRotation")
' ^7 c+ k& }! |# N9 D! [{$ Q9 I7 ]/ H7 g
return 3; // Divert the item to port 3! M2 e ~8 D: @* n" L& s
}9 X$ K. d" |! R, d% _, E3 @1 e
else if(labelVal == "noRotation")
/ N6 G5 Z9 C8 \" a" T/ M{4 x; Y; F% O9 t8 n1 M! w4 y
return 4; // Divert the item to port 4# a1 Y! Z' ], N( Q
}
0 e7 D/ K1 t" h7 `% L: \& _: T: A' N4 s$ W3 t4 @
模型附上:
2 m8 M' ^! m/ x' [ |