// Include/Exclude Light/Item 0.114 @name "Inc/Exc Light/Item" @version 2.5 @warnings @script generic @define DESCRIPT "Inc/Exc Light/Item" @define TYPE_OBJ 1 @define TYPE_LIGHT 2 @define TYPE_MESH 1 @define TYPE_NULL 2 @define TYPE_MESH_NULL 3 var l0; var LB_Items; var ItemNum; var InitBlock; generic { var CurItems = Scene().getSelect(); if(CurItems == nil) return; if(CurItems[1].isBone() || CurItems[1].isCamera()){ error("
You must Select Mesh/Null or Light"); return; } var Obj; var LB_Label; var ItemType; if(CurItems[1].isMesh()){ // 選択がMesh/Null ItemType = TYPE_OBJ; i = 1; Obj = Light(); while(Obj){ LB_Items += Obj.name; Obj = Obj.next(); InitBlock[i] = i; i++; } LB_Items.sortA(); ItemNum = LB_Items.size(); LB_Label = "Effect to MESH/NULL"; }else{ // 選択がLight ItemType = TYPE_LIGHT; ItemNum = 2; LB_Items = @"Mesh","Null"@; InitBlock = @1,2@; LB_Label = "Effect to LIGHT"; } reqbegin(DESCRIPT); reqsize(190,364); l0 = ctllistbox(LB_Label, 160, 280, "lb1_Count", "lb1_Name"); ctlposition(l0, 5, 3); l1 = ctlbutton(" Select All", 80, "lb1_AllSelect"); ctlposition(l1, 6,284); l2 = ctlbutton("DeSelect All",80, "lb1_AllDeselect"); ctlposition(l2,85,284); s0 = ctlsep(0,190); ctlposition(s0, 0,307); c0 = ctlchoice("", 1, @" Include"," Exclude"@); ctlposition(c0, 0,310,166); if(!reqpost()) return; var SelBlock = getvalue(l0); var SelAct = getvalue(c0); reqend(); // SelBlockはIndexの入った配列。選択無しならnil if(SelBlock == nil){ error("
Not Select Target."); return; } var SelNum = SelBlock.size(); var TargID; if(ItemType == TYPE_OBJ){ // シーン選択がMesh/Nullで、リスト選択がLight // リストで選択されたライト名からライトのIDを取り直す for(i = 1; i <= SelNum; i++){ Obj = Light(LB_Items[(SelBlock[i])]); TargID += Obj.id; } // シーン選択のMesh/Null数を取る。ItemNum変数使いまわし ItemNum = CurItems.size(); if(SelAct == 1){ if(ItemNum == 1){ for(c = 1; c <= SelNum; c++) IncludeLight(TargID[c]); }else{ for(i = 1; i <= ItemNum; i++){ SelectItem(CurItems[i].id); for(c = 1; c <= SelNum; c++) IncludeLight(TargID[c]); } } }else{ if(ItemNum == 1){ for(c = 1; c <= SelNum; c++) ExcludeLight(TargID[c]); }else{ for(i = 1; i <= ItemNum; i++){ SelectItem(CurItems[i].id); for(c = 1; c <= SelNum; c++) ExcludeLight(TargID[c]); } } } }else{ // シーン選択がLightで、リスト選択がMesh/Null // SelBlockが[1]なら中身は1か2、[2]なら1と2。 c = (SelNum == 1) ? SelBlock[1] : 3; Obj = Mesh(); switch(c){ case TYPE_MESH: while(Obj){ if(!Obj.null) TargID += Obj.id; Obj = Obj.next(); } break; case TYPE_NULL: while(Obj){ if(Obj.null) TargID += Obj.id; Obj = Obj.next(); } break; case TYPE_MESH_NULL: while(Obj){ TargID += Obj.id; Obj = Obj.next(); } break; default: break; } if(TargID == nil){ error("
Not Found Mesh or Null"); return; } var TargNum = TargID.size(); // シーン選択のLight数を取る。ItemNum変数使いまわし ItemNum = CurItems.size(); if(SelAct == 1){ if(ItemNum == 1){ for(c = 1; c <= TargNum; c++) IncludeObject(TargID[c]); }else{ for(i = 1; i <= ItemNum; i++){ SelectItem(CurItems[i].id); for(c = 1; c <= TargNum; c++) IncludeObject(TargID[c]); } } }else{ if(ItemNum == 1){ for(c = 1; c <= TargNum; c++) ExcludeObject(TargID[c]); }else{ for(i = 1; i <= ItemNum; i++){ SelectItem(CurItems[i].id); for(c = 1; c <= TargNum; c++) ExcludeObject(TargID[c]); } } } } // ↑で先頭(末尾)が最後にSel〜されてるので後は順当にAddする if(ItemNum > 1) for(i = ItemNum - 1; i >= 1; i--) AddToSelection(CurItems[i].id); Refresh(); } // ----------------------------------- lb1_Count { return(ItemNum); } lb1_Name: Index { return(LB_Items[Index]); } lb1_AllSelect { setvalue(l0, InitBlock); } lb1_AllDeselect { setvalue(l0, nil); }