我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
! g3 V: f+ Z+ O# w% r发生器的代码如下:6 a8 X$ k3 Q: u$ `" j
/**Custom Code*/
, ]0 x) f' B: }" ?+ K0 l; z6 K4 U% \& m; O
Object current = ownerobject(c);
, _' _5 {7 S& RObject item = param(1);, {9 S0 ^0 F2 c' g: I- q2 {5 m
int port = param(2);
) e4 S6 ?9 J3 \5 t" F( U# g* ] K) `$ |& `% ]5 ]3 w
Object involved = item;
- t8 O! M# K9 L0 Ydouble x1 =180;- Q% T5 {, ~# d
double y1 = 0;
0 @" i8 v) G9 \* ydouble z1 = 0;# ]$ F x1 r6 ]- k/ s: Q( ~" j
- |! T) x2 \9 E4 S& P, a( G4 ddouble x2 = 0;
3 z4 @: v9 k# odouble y2 = 0;$ [+ v) `5 Q8 ~+ K( ]6 s# C
double z2 = 180;
7 A9 p. Z1 Q) N; y$ X
. s* D& t# ] N, p6 U4 idouble x3 = 180;
/ w8 A6 b; G [ Odouble y3 = 0;; ~% }% z* t9 n( T
double z3 = 180;
, p5 P3 S# | U5 K' W9 {/ Q8 M: L6 _& i% f: Y) g, a
double x4 = 0;) h8 W' c( q1 X; O% e
double y4 = 0;4 k, I% A; @& v* R6 R
double z4 = 0;! z$ E E/ w& Z/ P% W- [7 [
+ X! t( \0 f! \" n- ~9 M
double randomVal = duniform(0, 4);
. p; p4 B0 {. i4 I, @* j* l4 xif(randomVal < 1)
7 v5 [+ P6 `( H{7 [4 I$ `2 O H V
setrot(involved, x1, y1, z1);3 R+ @/ w( [5 I6 d- Q6 M
setlabel(involved,"Rotation","xRotation");
! Q6 _: F5 `! w3 y) m$ z8 `! C}2 M# |: C; i+ I+ |% c$ g& S6 ?+ s" `
else if( randomVal < 2). ]" t6 e$ t/ k9 i0 n: g t& W& r
{ 7 ^( u9 |/ x' P* Z8 b2 f
setrot(involved, x2, y2, z2);6 H! B5 ?" g$ ? U; e) ]: o0 F
setlabel(involved,"Rotation","zRotation");+ B2 w! ^/ ?+ S C- H y& L* ^
}
* @7 G( C' D5 ~4 jelse if(randomVal < 3 )
6 R, x9 W) ^- d% v3 {- n; M{; d" {1 U: r4 X
setrot(involved, x3, y3, z3);
- s& Z5 J7 E! I( t( r7 @ setlabel(involved,"Rotation","xzRotation");
' x: I+ Y" d8 E0 S1 X}
% P. r. Q4 x* _- K! J6 _else
1 i% a! b& C& y1 k- ~{$ C) b* F( I o9 _
setrot(involved, x4, y4, z4);
8 G8 a4 c0 q1 ~3 F( g! B1 ] setlabel(involved,"Rotation","noRotation");
' }" y5 m! A* t2 o; @* f}$ @* A1 E+ ]" B" E G
判断的代码如下:& @, j- q0 b* Q& q: v5 \- ~
/**Custom Code*/
( x, _1 o; ^' q. GObject current =ownerobject(c);/ M9 k3 G( i0 Z8 G% V/ @8 O
Object item = param(1);- y- d' T( a' Q. D' q9 p8 x1 n& k# [
int port = param(2);; A2 W9 T6 W; u0 M3 G$ G
2 D5 D9 K0 n, p& a4 n4 u \ Z
Object involved = item;9 l& U, {9 c/ S
4 U6 r( k. H4 r4 P& Ustring labelVal = getlabelstr(involved, "Rotation");( w; U- ]* @$ z3 y
6 W* {5 s; M L* n) [, `if(labelVal == "xRotation")1 t/ r' ?% }/ B( ?" z' y
{
. E. ~! M6 u- b) e/ R return 1; // Divert the item to port 1( j% f5 \7 y$ [, S" F1 i
}
% Z/ ?& q, l( q2 u# ^5 q! Jelse if(labelVal == "zRotation")) A) s! O8 M! G0 d i$ D
{
, i( U4 K4 a1 O5 V/ r: I3 n7 Y R return 2; // Divert the item to port 2% ~- z# }' x6 q) p+ S
}0 f- T0 X8 @: N8 o) X5 D2 R, @ X3 A
else if(labelVal == "xzRotation")
: Q u& h9 h; s{" B6 Y9 d! V+ X+ h
return 3; // Divert the item to port 3
0 S: S' I* R( I0 p8 t H3 ^% I}
8 }0 ]# u' _, a B! Helse if(labelVal == "noRotation")4 X6 `" Y1 _! h2 S. i
{
; k$ z4 Q2 K% g4 ]7 G) b return 4; // Divert the item to port 48 Z& b% F% O/ t
}9 ~ d( N- z2 b* [' K- ^
: `. z% m0 k# K模型附上:
! p" R+ J7 Q, \ |