我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!/ W1 @# F. M* x
发生器的代码如下:
) w7 E0 b6 m* K) h# t/**Custom Code*/
9 B4 z$ Y' T3 }/ ], C
& z2 Q$ b! X ]3 k; {. hObject current = ownerobject(c);% I3 K: H$ g3 p# W
Object item = param(1);# _2 j* B e: n
int port = param(2);8 ^3 e: K- F& v8 T, @/ c
9 { { _9 m/ I$ q; G1 QObject involved = item;
( I- J ?. `3 B3 j; i3 ddouble x1 =180;
& V- {6 F* m! O" }! s* F( wdouble y1 = 0;
% `; p5 _) I' X5 I, `, pdouble z1 = 0;
. J: m$ p# J# p# u/ v2 e8 l, h' L" X: T/ K y1 m3 C
double x2 = 0;' R' Z ?' {. b% w5 [
double y2 = 0;
6 g# ?0 m4 S- ]! mdouble z2 = 180;7 R2 ?- b! q$ h% \
. x; W. k. @: U* c/ e8 kdouble x3 = 180;
8 W7 t' y5 U; a9 Y% I$ Gdouble y3 = 0;
8 O. s) C6 V/ q9 A( O, l: @5 hdouble z3 = 180;; G! J. \8 q& E
2 k9 g0 c4 D- k5 l# L
double x4 = 0;+ B) Q, m L5 u' B' ~* B z
double y4 = 0;" v7 b4 Q4 x& R/ d' f
double z4 = 0;
7 A) `: @; I* `" @( f" B) \& P) @; Y& [- N: |# M l2 D
double randomVal = duniform(0, 4);
5 v2 P, z/ l9 ]if(randomVal < 1)2 n+ s$ t. p+ v4 G2 E
{
- J. L* B1 k9 F. v. ^ setrot(involved, x1, y1, z1);7 i; D! r/ \% g+ e) h# w
setlabel(involved,"Rotation","xRotation");# v4 D2 y% k3 t ]/ p
}
9 E+ Y' w3 A/ W. |" Z* {else if( randomVal < 2)7 r; H2 Q: x& U0 z& A" B* A8 |
{
7 g& P1 I$ z ? k. i# y( ` setrot(involved, x2, y2, z2);
- t+ K) B! f$ }. R: S9 ?1 Z setlabel(involved,"Rotation","zRotation");
5 S( c' E; Q. x# t6 V* k: @}
6 y) P; I0 i" b( P9 C1 t6 xelse if(randomVal < 3 )5 s2 k; P% V7 `3 r
{8 {# F) m" V; S0 q9 t
setrot(involved, x3, y3, z3);
3 L K6 g% o4 K/ n setlabel(involved,"Rotation","xzRotation");
% \" d0 r' B( q}1 e& M. R( q W1 g$ `/ a
else" T) Y, J* m2 N9 U
{- e O4 n( o$ \4 v7 q0 H' ?, A; c
setrot(involved, x4, y4, z4);8 O: R6 }7 B" B4 k
setlabel(involved,"Rotation","noRotation");
7 D+ ^& _# o7 y8 A% C; G* m! L}: I7 R$ g5 v8 N
判断的代码如下:/ l' j3 P& J, l+ ^
/**Custom Code*/
! d7 \7 n( n4 F4 D7 LObject current =ownerobject(c);5 d D3 o2 R9 ?! j# |* W- `9 U
Object item = param(1);
, ~5 I) r) \8 U- Kint port = param(2);
1 W- z& r8 z* f% f
( g$ s2 V. G H3 BObject involved = item;
# q$ T& ^0 y1 ~ d( t( e$ ]2 d2 J% J. d, |- ~, ~4 P) |: K' V& a
string labelVal = getlabelstr(involved, "Rotation");! s$ \# y$ ]) ]8 O% ~7 r! z$ |
7 T6 P! ^) d3 R* [ U8 U
if(labelVal == "xRotation")
- x! h% g& ^( r9 g6 D0 s{3 r& w2 ^5 u* p @
return 1; // Divert the item to port 15 g x) g4 L7 k2 [/ B4 L1 ^
}
) \! b' E) W6 ~" G5 d: }* Ielse if(labelVal == "zRotation")
$ p5 W6 N, c& x0 d5 r! B/ Z{
2 \8 q! G \! ~! c1 M3 g return 2; // Divert the item to port 2
D( x; `9 X6 ~. ]2 {* o( D}
/ h4 w% w: Z8 z' N- v9 B' h, d& celse if(labelVal == "xzRotation")9 d: K' Y. P& l8 g' g0 w9 S% T
{
4 ^0 h1 n/ T' T- ` return 3; // Divert the item to port 3
: `7 _- u2 o0 @5 S2 ]1 _/ B& F0 z$ C}* L5 Q; q6 H2 H4 W- p
else if(labelVal == "noRotation")# J& {' {. }! \/ }
{( j0 o" L8 n, j! F
return 4; // Divert the item to port 4) N. {' D3 C$ A* m' \
}; w0 k4 E( O/ C4 n4 B
* w8 d5 _: Q6 n) ]7 C5 o' p2 W模型附上:
4 ~8 U4 E3 L! s1 {' Y |