|
|
我想达成的结果是——通过发生器创建四种不同的临时实体,分别是绕x轴旋转180度、绕z轴旋转180度、绕x轴和z轴旋转180度、不旋转这四种临时实体,同时给这四种临时实体赋标签分别为xRotation、zRotation、xzRotation、noRotation。然后从PF里的判断命令中引出4条支线1、2、3、4分别对应上面四种实体,判断里的代码总是识别不了我给临时实体设置的标签,有没有哪位老师可以帮我看一下,是哪里的问题,该怎么办才能解决,十分感谢!
发生器的代码如下:
/**Custom Code*/
Object current = ownerobject(c);
Object item = param(1);
int port = param(2);
Object involved = item;
double x1 =180;
double y1 = 0;
double z1 = 0;
double x2 = 0;
double y2 = 0;
double z2 = 180;
double x3 = 180;
double y3 = 0;
double z3 = 180;
double x4 = 0;
double y4 = 0;
double z4 = 0;
double randomVal = duniform(0, 4);
if(randomVal < 1)
{
setrot(involved, x1, y1, z1);
setlabel(involved,"Rotation","xRotation");
}
else if( randomVal < 2)
{
setrot(involved, x2, y2, z2);
setlabel(involved,"Rotation","zRotation");
}
else if(randomVal < 3 )
{
setrot(involved, x3, y3, z3);
setlabel(involved,"Rotation","xzRotation");
}
else
{
setrot(involved, x4, y4, z4);
setlabel(involved,"Rotation","noRotation");
}
判断的代码如下:
/**Custom Code*/
Object current =ownerobject(c);
Object item = param(1);
int port = param(2);
Object involved = item;
string labelVal = getlabelstr(involved, "Rotation");
if(labelVal == "xRotation")
{
return 1; // Divert the item to port 1
}
else if(labelVal == "zRotation")
{
return 2; // Divert the item to port 2
}
else if(labelVal == "xzRotation")
{
return 3; // Divert the item to port 3
}
else if(labelVal == "noRotation")
{
return 4; // Divert the item to port 4
}
模型附上:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|