我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!9 L6 b; m: d' q* Q) H6 i" Y
发生器的代码如下:
4 Z0 [, \6 q8 o+ a/**Custom Code*/8 E8 [, e: g0 o0 w; U n
& c- r9 {* e* T, G! o6 z f0 F' c
Object current = ownerobject(c);
) d, p) e8 u, _Object item = param(1);
1 A2 O& l3 F6 q1 [int port = param(2);
- c W1 ?1 g% d$ ]/ t: O5 P: d5 P/ w) [/ i
Object involved = item;" g. ]2 w! t, _% M C
double x1 =180;3 Z: D+ f5 r, E4 a% F. m
double y1 = 0;
( J) N" Y$ B! T# R9 T# rdouble z1 = 0;" N1 x4 N; j, N& _3 M( X* z
- a8 C* f* M1 { }" ]double x2 = 0;0 t6 e7 A: v6 ^
double y2 = 0;
! ~, v* P) \ |' R" [double z2 = 180;
: Y+ E6 W# {, W; C$ d1 i |
6 i* x# c/ Z( D8 x4 e% J# ydouble x3 = 180;
1 x5 e* u4 @0 C- @+ Vdouble y3 = 0;9 K% V7 J! V' H+ x3 L* z
double z3 = 180;
, N' B1 z; ~) t( U% G7 N' [5 @4 r/ X, P; N
double x4 = 0;9 R$ B3 B& B4 Z7 P {) _/ ]
double y4 = 0;" q$ U# o3 Y o1 z9 K1 G& D
double z4 = 0;
* a$ A( W" \+ a/ y/ O5 p! R/ R# Z3 b
double randomVal = duniform(0, 4);
' Y; `8 x9 x3 j* ?6 V( Y; oif(randomVal < 1)
1 ^3 x @5 z3 s" |* Z{
1 @' u7 i; G4 E setrot(involved, x1, y1, z1);
& }* X& u7 j2 d. r; ^( m setlabel(involved,"Rotation","xRotation");
8 T* P; H1 ~# {# l# L# L; [3 w}
; n0 r0 N, c4 ]. telse if( randomVal < 2)# _' J) w* \5 n& O
{ 7 B- |$ D# \+ D# @: e: ^" O5 F. t
setrot(involved, x2, y2, z2);, o# b7 B# S0 `+ Z
setlabel(involved,"Rotation","zRotation");- Y& V/ m7 I# z
}* G2 S, u* O5 Z
else if(randomVal < 3 )" L) f+ s0 d6 y" ~
{& U' [' Q( v( n# T2 w
setrot(involved, x3, y3, z3);8 Q8 E. I3 ^# _* Y) S3 [ K8 s8 a
setlabel(involved,"Rotation","xzRotation");( o# R, R* p9 g( W. J
}4 e* B+ ?+ @: _
else/ \9 [6 x! U( e$ Y( K
{' ~0 s7 C+ J$ Y1 t" K
setrot(involved, x4, y4, z4);
7 i4 w( n+ E/ R& h7 U* u setlabel(involved,"Rotation","noRotation");
0 s( M2 I" h! L% p+ M. r! m} k4 e& x5 K G7 N, c1 D+ |
判断的代码如下:
0 C/ Z6 ?" p( _( m/**Custom Code*/
$ o3 n* Z4 l, o1 fObject current =ownerobject(c);
% |% k! ^5 p WObject item = param(1);
! C- l( f4 o) E5 x6 W. `$ cint port = param(2);( R( n+ T5 R% C
1 l: H/ w; m6 ]4 J) Z7 A5 S4 |+ cObject involved = item;" {7 v, m. Z7 {0 w* i
?; ~( e" P' |. E1 h+ ]* n. M
string labelVal = getlabelstr(involved, "Rotation");. @4 Z. k7 h3 ~8 v. e% A$ v
3 e! f" V- W- \) e0 l9 _
if(labelVal == "xRotation")
6 r+ k1 l- j# r9 V' `$ Y. K( D{) x9 \2 H, h* C* H4 T1 J
return 1; // Divert the item to port 1: e) {+ a! b; J
}: B" [ A: W( x' K
else if(labelVal == "zRotation")' n5 n% K8 e6 I x0 t
{
8 P0 R3 f: u0 j1 w! k2 N( P; ~. h return 2; // Divert the item to port 2
" @% b7 u* b* l2 I/ t7 x& g}; ~5 ^0 c/ {7 u0 C) f
else if(labelVal == "xzRotation"). K2 n9 `% J! t# e# a: p" Y
{
5 i; B& O& e- d, }* P return 3; // Divert the item to port 32 d( F8 m$ n& R3 B8 c5 y
}" z9 G# F: I. k) V
else if(labelVal == "noRotation")4 T, l# h! A& ?1 R1 B
{
! ?5 S$ w `! l$ @+ C( ^ return 4; // Divert the item to port 4
1 n, ~7 h6 P2 Z {* ?5 [9 H5 y$ f}: H: u* b k& m3 u4 H
5 w* g( I5 r+ _. |0 F# M% A模型附上:( E8 G5 D& H9 m; v
|