| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- //--- OBJECT WRITE BEGIN ---
- %guiContent = new GuiControl(CreateNewNavMeshDlg) {
- position = "0 0";
- extent = "1024 768";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiDefaultProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "1";
- new GuiWindowCtrl() {
- text = "New NavMesh";
- resizeWidth = "0";
- resizeHeight = "0";
- canMove = "1";
- canClose = "1";
- canMinimize = "0";
- canMaximize = "0";
- canCollapse = "0";
- closeCommand = "Canvas.popDialog(CreateNewNavMeshDlg);";
- edgeSnap = "1";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "283 240";
- extent = "200 176";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiWindowProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- new GuiTextCtrl() {
- text = "Name:";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "12 29";
- extent = "39 21";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextRightProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl() {
- historySize = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- password = "0";
- passwordMask = "*";
- text = "Nav";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "59 30";
- extent = "129 18";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextEditProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- internalName = "MeshName";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "Position:";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "12 51";
- extent = "39 21";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextRightProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl() {
- historySize = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- password = "0";
- passwordMask = "*";
- text = "0 0 0";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "59 52";
- extent = "129 18";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextEditProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- internalName = "MeshPosition";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "Scale:";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "12 73";
- extent = "39 21";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextRightProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl() {
- historySize = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- password = "0";
- passwordMask = "*";
- text = "50 50 20";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "59 74";
- extent = "129 18";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextEditProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- internalName = "MeshScale";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiCheckBoxCtrl(MeshMissionBounds) {
- text = " Fit NavMesh to mission area";
- groupNum = "-1";
- buttonType = "ToggleButton";
- useMouseEvents = "1";
- position = "22 99";
- extent = "159 15";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiCheckBoxProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- tooltip = "Positions and scales the NavMesh so it includes all your mission objects.";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiCheckBoxCtrl(MeshTerrainBounds) {
- text = " Include terrain";
- groupNum = "-1";
- buttonType = "ToggleButton";
- useMouseEvents = "0";
- position = "22 121";
- extent = "159 15";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiCheckBoxProfile";
- visible = "1";
- active = "0";
- tooltipProfile = "GuiToolTipProfile";
- tooltip = "Consider terrain when calculating NavMesh bounds.";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiButtonCtrl() {
- text = "Create!";
- groupNum = "-1";
- buttonType = "PushButton";
- useMouseEvents = "0";
- position = "12 146";
- extent = "87 19";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiButtonProfile";
- visible = "1";
- active = "1";
- command = "CreateNewNavMeshDlg.create();";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiButtonCtrl() {
- text = "Cancel";
- groupNum = "-1";
- buttonType = "PushButton";
- useMouseEvents = "0";
- position = "104 146";
- extent = "84 19";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiButtonProfile";
- visible = "1";
- active = "1";
- command = "Canvas.popDialog(CreateNewNavMeshDlg);";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- };
- };
- //--- OBJECT WRITE END ---
- function CreateNewNavMeshDlg::onWake(%this)
- {
- %this-->MeshName.setText("Nav");
- %this-->MeshPosition.setText("0 0 0");
- %this-->MeshScale.setText("50 50 20");
- MeshMissionBounds.setStateOn(false);
- MeshTerrainBounds.setStateOn(true);
- }
- function MissionBoundsExtents(%group)
- {
- %box = "0 0 0 0 0 0";
- foreach(%obj in %group)
- {
- %cls = %obj.getClassName();
- if(%cls $= "SimGroup" || %cls $= "SimSet" || %cls $= "Path")
- {
- // Need to recursively check grouped objects.
- %wbox = MissionBoundsExtents(%obj);
- }
- else
- {
- // Skip objects that are too big and shouldn't really be considered
- // part of the scene, or are global bounds and we therefore can't get
- // any sensible information out of them.
- if(%cls $= "LevelInfo")
- continue;
- if(!MeshTerrainBounds.isStateOn() && %cls $= "TerrainBlock")
- continue;
- if(!(%obj.getType() & $TypeMasks::StaticObjectType) ||
- %obj.getType() & $TypeMasks::EnvironmentObjectType)
- continue;
- if(%obj.isGlobalBounds())
- continue;
- %wbox = %obj.getWorldBox();
- }
- // Update min point.
- for(%j = 0; %j < 3; %j++)
- {
- if(GetWord(%box, %j) > GetWord(%wbox, %j))
- %box = SetWord(%box, %j, GetWord(%wbox, %j));
- }
- // Update max point.
- for(%j = 3; %j < 6; %j++)
- {
- if(GetWord(%box, %j) < GetWord(%wbox, %j))
- %box = SetWord(%box, %j, GetWord(%wbox, %j));
- }
- }
- return %box;
- }
- function CreateNewNavMeshDlg::create(%this)
- {
- %name = %this-->MeshName.getText();
- if(%name $= "" || nameToID(%name) != -1)
- {
- MessageBoxOk("Error", "A NavMesh must have a unique name!");
- return;
- }
- %mesh = 0;
- if(MeshMissionBounds.isStateOn())
- {
- if(!isObject(MissionGroup))
- {
- MessageBoxOk("Error", "You must have a MissionGroup to use the mission bounds function.");
- return;
- }
- // Get maximum extents of all objects.
- %box = MissionBoundsExtents(MissionGroup);
- %pos = GetBoxCenter(%box);
- %scale = (GetWord(%box, 3) - GetWord(%box, 0)) / 2 + 5
- SPC (GetWord(%box, 4) - GetWord(%box, 1)) / 2 + 5
- SPC (GetWord(%box, 5) - GetWord(%box, 2)) / 2 + 5;
- %mesh = new NavMesh(%name)
- {
- position = %pos;
- scale = %scale;
- };
- }
- else
- {
- %mesh = new NavMesh(%name)
- {
- position = %this-->MeshPosition.getText();
- scale = %this-->MeshScale.getText();
- };
- }
- MissionGroup.add(%mesh);
- NavEditorGui.selectObject(%mesh);
- Canvas.popDialog(CreateNewNavMeshDlg);
- }
- function MeshMissionBounds::onClick(%this)
- {
- MeshTerrainBounds.setActive(%this.isStateOn());
- }
|