我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
$ u$ j* f' T" ?发生器的代码如下:
- g6 G' M3 D k( i+ h2 J) V y9 ?/**Custom Code*/
& `" M( ?/ _. ]3 G [. k/ q$ o! z# u6 y/ C' o
Object current = ownerobject(c);/ U) D1 N5 v; s! C* o
Object item = param(1);
6 y, \7 S- @7 ]: m1 i v7 tint port = param(2);
8 h+ c, { B% g' {2 h" k/ R2 V1 \- W: m5 I: ~
Object involved = item;
3 B {- X- l. K+ ?+ u/ Ddouble x1 =180;" ]' Z# ^. O ?6 T9 J, M: y
double y1 = 0;" G* E, O, u8 @
double z1 = 0;4 U. g. M- k5 X9 q7 J& J6 M2 |
7 n0 s5 y, U1 x7 K+ v3 ndouble x2 = 0;
$ G' `# z8 z$ ]double y2 = 0;
3 w, F' k% T, ?7 i a+ @double z2 = 180;
* W" _, g7 Y. V# B" v
3 J: t! D, K: A# r0 A' ?double x3 = 180;
2 U7 Q0 F6 `, f2 zdouble y3 = 0;- m, ?* K. ?: G# A* k' z ~
double z3 = 180;
" y. N/ R6 A2 o% }# N
: G/ M( [* ^* N( n+ S/ hdouble x4 = 0;+ I( m4 U: s8 Z5 C# l
double y4 = 0;
2 T0 @1 f2 l, n% u# Ldouble z4 = 0;
3 F$ A: v# G" s2 u v" ^; R! x, X6 d2 x* b
double randomVal = duniform(0, 4);
8 k/ [2 A( Q$ j6 ]0 ^if(randomVal < 1)
: A8 w% z% P3 P5 P$ |" S; e0 r0 o{
# k& h( Q. u7 K' Z/ e setrot(involved, x1, y1, z1);
: e( g) R8 \/ n. t setlabel(involved,"Rotation","xRotation");! e! e* C% f' N7 {/ x
}- ]4 r3 D( u: [6 `2 q9 H
else if( randomVal < 2)
8 V8 q8 p. z; i' c+ o; e* Q{
4 {( I, h. I! L" C setrot(involved, x2, y2, z2);
9 r' o$ g! h" I k& z+ ?9 }) m setlabel(involved,"Rotation","zRotation");
' M4 t# @; D. B' X, M# E2 X}. i- n3 F) z* S3 R7 I
else if(randomVal < 3 )' H/ y5 o9 r; o/ F, _
{
* w e1 ?. }9 N H setrot(involved, x3, y3, z3);
2 V# @- T2 \9 I0 G! G$ D, S setlabel(involved,"Rotation","xzRotation");7 o$ d/ g' d* s
}
; o( q" l/ z$ Zelse7 I j1 u7 B+ j4 }* z; W
{
' F; `1 Q0 u7 S$ @ h* Y9 O j6 w( Z setrot(involved, x4, y4, z4);
' I* o( h% n* `2 Q- H setlabel(involved,"Rotation","noRotation");& |, g5 \. L7 ^+ H
}
2 @3 o* d0 F; ]) L, X8 }& g判断的代码如下:
: \* K: }$ Z+ a1 D3 j9 {# g1 W T/**Custom Code*/
) O$ ~9 m# j g0 I% X ]Object current =ownerobject(c);
5 y% y3 ]3 @' ?4 P7 }Object item = param(1);
" o* y7 i5 X, Gint port = param(2);
8 x8 {+ n: d/ i9 O) k5 r& N' C/ F1 N6 j: H4 U
Object involved = item;( d' L* F7 M- w' B _2 Y$ t2 R& e
h4 c9 H) l0 S; y9 vstring labelVal = getlabelstr(involved, "Rotation");
8 `: s6 l. f2 H, D. K4 }
$ l& n/ G6 n2 A3 p% {6 p: W) Bif(labelVal == "xRotation")0 l% V: U( A! Z) Y2 {$ C8 E6 K3 M
{% G4 i/ J* i/ j: ^
return 1; // Divert the item to port 1
4 P/ I; K9 P( O$ I}
6 X, z! d4 P2 |! Relse if(labelVal == "zRotation")
[0 d4 N6 V5 A0 ?0 |2 M2 d l{
) }$ N( M* p* u2 }* U return 2; // Divert the item to port 2
8 O. p0 J. n- G, R}: T Z$ M4 H; T e8 T
else if(labelVal == "xzRotation")8 L( b% E5 ?* {, G6 B/ S
{
/ O3 S, I; j- J' E |0 Z$ C! k" F return 3; // Divert the item to port 3
, A0 G: v4 u- O7 c& x% s% O}% p' A0 S! B$ }" B
else if(labelVal == "noRotation")0 y% n) `, r7 R: g) C6 r" E
{1 H/ _( S. a0 a$ q
return 4; // Divert the item to port 4
1 @0 J/ P! e' e' n3 I) T}
/ F1 g- V6 c7 z0 d; \/ u- `6 R/ O! F( Z# ^# [. T
模型附上:" X% A. y# f3 g+ i1 X/ A
|