我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
, ~/ L. z# p& j& u发生器的代码如下:
& Z! N! }$ p6 ~' S- x7 T/**Custom Code*/
( e8 F' M$ x6 g0 f! \ P$ H# q
# ^% I# I* `) t, V5 PObject current = ownerobject(c);! f8 R2 E; J" U P% J
Object item = param(1);% B& a8 K6 X+ N& I
int port = param(2);
! W4 k& ?( X8 J- c
; U& Z! K4 q$ z) U2 g& X0 |Object involved = item;
/ k1 ]2 ~( y% hdouble x1 =180;" r6 M8 {: ]! b. f9 A
double y1 = 0;
]( M. P5 x5 H! Gdouble z1 = 0;
! h$ W. H0 W9 _. c% e* X" }1 d6 q/ Y
5 I k$ E* P2 i C- Ldouble x2 = 0;; F+ L5 b$ m! r- }9 ^2 I! n/ l
double y2 = 0;
& v! a5 Z- m% k* Z" V5 D; Hdouble z2 = 180;) i, \6 d( E0 D$ |/ L) Z
% T3 a+ N6 f) s& k1 H0 m' P3 S
double x3 = 180;
* T& f1 V# Y+ `0 Q* Z' Edouble y3 = 0;
2 l) N% Z* B+ l% W+ N8 odouble z3 = 180;% m$ v- n( ~' M7 |; [2 _5 N
1 w M* M) \% Y1 t* m5 {+ {
double x4 = 0;+ n5 B# G, e; ?
double y4 = 0;
6 V/ I& _/ Y! A. bdouble z4 = 0;) t- H# q8 A! h
9 ~# s! D2 p; g4 s' F% l, X
double randomVal = duniform(0, 4);% h# ^% R% f# ^% }2 K) U4 v: c
if(randomVal < 1)' C( y5 h; _2 V
{! |0 } T7 ^- |5 m7 Z; t# S
setrot(involved, x1, y1, z1);% V! \$ M8 t# O4 k7 y7 r% ^( |( R
setlabel(involved,"Rotation","xRotation");
( w; ^' O+ V3 D1 I( f}
/ q# K: L% g3 f' s! Z$ telse if( randomVal < 2)" \1 S. O: r9 f n% K. N
{
4 Q( k% m3 u$ C! x$ S& B setrot(involved, x2, y2, z2);
8 o0 V1 u3 I3 O- P- E4 _: t. F setlabel(involved,"Rotation","zRotation");
0 C7 r: _" Y x! r+ R9 a# K v( {}4 K5 [3 K; o9 k
else if(randomVal < 3 )
1 i, u, T* j7 F" \' w( z2 N3 e{
# L+ d1 e$ }7 n- M" D* R7 W. o setrot(involved, x3, y3, z3);# P& ?5 x. x# l& s6 x" U
setlabel(involved,"Rotation","xzRotation");8 U* Z0 T+ u' i% z G/ S
}1 F9 U& w: _. a4 R
else8 N4 V0 P% G1 \. T3 c/ J# T
{
& J( r' y9 S7 F9 v0 x1 q setrot(involved, x4, y4, z4);
. w$ i& I" V9 x setlabel(involved,"Rotation","noRotation");
1 M+ ~9 ]5 P! A8 R}
! q, U6 s. b& A Q判断的代码如下:: V( @" Z* H; ?
/**Custom Code*/8 t* E' n! S( h. W& S5 |
Object current =ownerobject(c);
' e9 `7 ]$ \ [Object item = param(1);5 R1 g3 W7 f/ D$ Y3 q. R1 i5 W
int port = param(2);
& |7 H( ^% a+ h8 Q1 q' M
. \6 Y* Z" Q+ J1 qObject involved = item;
. I, `* d# c7 d- |! k3 j8 ~
/ P' ~* R4 r. U6 w& j- Vstring labelVal = getlabelstr(involved, "Rotation");
4 H# r/ q: m. ^4 R9 ]5 f# L) U; |
! w: ^7 v/ T" W" p& _if(labelVal == "xRotation")
7 m1 m" T, \! I{
& Q* ^3 y% Z" E5 U return 1; // Divert the item to port 1
! j ]9 \7 J3 T4 B& G. I}
" n" o- r% |) X0 [9 Celse if(labelVal == "zRotation")
+ e- r1 ]( T' h& R- Z H{+ J" W! d" q4 E- ~2 M f9 V
return 2; // Divert the item to port 2: S8 U6 w; U6 }$ X, D- W# w+ ]
}. _- C* m( W* E/ {+ W5 [# j* M
else if(labelVal == "xzRotation"). {$ [6 L/ y/ U: J* h
{
5 B$ w+ V) {4 J return 3; // Divert the item to port 38 I. M% u' q& _- W7 N. r! ?1 S
}
5 C$ O! q, M! C/ {: t5 `else if(labelVal == "noRotation")) j+ [ \$ X( a% D9 k" H) {
{
, R$ |( G$ q1 y- f" @6 D( r return 4; // Divert the item to port 45 Y; J* H; y$ [$ c1 }: F5 W( Q
}% s8 n C* D: A1 |9 f- t
* B$ j& j$ d9 I- n$ u模型附上:
A! m# k h0 [) x$ D; b4 V2 k+ l3 K# l |