我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
7 v, Y5 G! `5 k1 b发生器的代码如下:- C. c) h9 p" ^: S) z9 M5 ~
/**Custom Code*/
2 R- I5 n9 d& f$ S
Z/ B( W1 W; u5 fObject current = ownerobject(c);" ^2 ?- M4 ?# W m N i
Object item = param(1);
; |" u$ U5 }/ i; a3 k, }int port = param(2);8 Z" g- T6 M( O. a
5 u. t" w4 {7 }$ J( J
Object involved = item;9 N M/ n, v; `4 q( B k
double x1 =180;
; R8 `9 Z/ x5 g; _# G% _1 `% mdouble y1 = 0;
$ n8 o& {* [( K7 b1 ~% Rdouble z1 = 0;
6 w- ^" M- l- u5 E5 V6 f" i% K; y/ m3 K$ h- j U- V8 j
double x2 = 0;, y2 B; O1 S( W# M
double y2 = 0;, b* X0 I+ w3 j
double z2 = 180;5 L9 X% z0 ?, M! y" r( ]8 s$ g
5 L- }6 Q# p* h4 [6 |7 g
double x3 = 180;
, e& Z& {5 z3 x2 W0 Adouble y3 = 0;
/ q t3 f( F! g4 k2 ~double z3 = 180;
0 h% i6 Z2 L6 [) `3 N) w4 e, ?: o b
double x4 = 0;( e. [: M) G& D! @/ M
double y4 = 0;% k/ ^2 A0 ~9 \+ @$ P
double z4 = 0;$ x; f- A- O& O& ^# h- o0 h
/ ?& A' {7 Z4 f1 f
double randomVal = duniform(0, 4);' t2 z! U/ s7 F3 W
if(randomVal < 1)# W$ R* |/ t3 a* F1 b+ g. b ~
{, b6 D$ o9 S2 @
setrot(involved, x1, y1, z1);; l1 s: M, R1 H0 F" G
setlabel(involved,"Rotation","xRotation");: u9 Q! h9 l! E" Q
}
( a. y! _# ]" K5 U5 n; ]else if( randomVal < 2)
* B: L5 l+ c! C7 n6 M: g8 g{ ' ~4 j4 c4 X& i8 V) s% V7 e+ S4 W
setrot(involved, x2, y2, z2);8 @* x" M. h% K `- X, v- E
setlabel(involved,"Rotation","zRotation");
+ i$ u T; t- z# @* C8 i9 G}- r& e% j& N6 ^" y( Q! Z
else if(randomVal < 3 )7 z% c, H' h0 M o9 t6 J% r
{
: W' y6 }) |4 l9 A9 [' h setrot(involved, x3, y3, z3);4 ?) U5 e5 Z8 A' D: u
setlabel(involved,"Rotation","xzRotation");2 v& L# V3 t; g1 F2 D
}
$ {) ^/ v! O+ ^; Xelse
( h* r1 z: i1 `; q8 c{
, ]3 _, @# e7 ` setrot(involved, x4, y4, z4);
( D; c: g4 F3 n& R/ {6 Q setlabel(involved,"Rotation","noRotation");
- I2 Y3 n7 q0 v}) {2 N* C) n; e' o- J
判断的代码如下:
) c# i% Z" E* p( {) U% T) H/**Custom Code*/& O5 I: _$ [+ {3 k* J
Object current =ownerobject(c);. v( x9 s- r ^
Object item = param(1);( j$ ~6 _) l5 t( {
int port = param(2);
2 t6 h7 H# v5 E2 V
* S' d& V' h4 y" n: j$ ^- RObject involved = item;. o- l1 z. R# F. l. C6 o7 A
! j8 U- `% |6 A5 k. I: b& Y: lstring labelVal = getlabelstr(involved, "Rotation");
; E, b% w7 [( s+ c' O- N% S( v# d7 S
if(labelVal == "xRotation")8 F8 u. x/ M2 b3 y7 q: v7 Y: F
{
9 w+ c8 ^& A2 k/ K. ^0 f: J return 1; // Divert the item to port 1! w2 I, L( R2 h: Z2 Y! O' X9 p
}! ]( c2 r/ q* ^: q# J) Y: h
else if(labelVal == "zRotation")
' W8 C3 F. H" {/ @$ Y2 B$ X{0 V: V$ ?$ y! N
return 2; // Divert the item to port 2
) h3 a6 K$ W) Q6 G6 X, k# q4 F}
9 A5 c+ b' q9 Q helse if(labelVal == "xzRotation")
! o/ D0 H5 V6 ]5 x5 Y{
& Z9 E! A; Q0 u* _% a1 O return 3; // Divert the item to port 33 n1 ?$ |! ~7 e4 d2 M6 K' a. x7 l3 |
}2 l1 M1 c8 \$ }* p2 f! K
else if(labelVal == "noRotation")
9 o a) m0 F2 X* D' S{
J. O( w6 B5 s return 4; // Divert the item to port 4
, _! L# b6 @# S9 g}* h7 @5 B- B z8 F" K# P: E' O
) L& P% c; o; u9 M8 _ y* w3 I% O模型附上:9 o4 Y# e5 O5 p5 X
|