mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-18 14:13:48 +00:00
392 lines
11 KiB
Text
392 lines
11 KiB
Text
//--- 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());
|
|
}
|