Merge pull request #2328 from Areloch/neverImportMat

Adds a filter for materials to never import when importing a shape
This commit is contained in:
Areloch 2019-05-04 11:51:21 -05:00 committed by GitHub
commit 4e9b9b4724
3 changed files with 81 additions and 16 deletions

View file

@ -90,6 +90,7 @@ namespace ColladaUtils
String neverImport; // List of node names (with wildcards) to ignore on loading String neverImport; // List of node names (with wildcards) to ignore on loading
String alwaysImportMesh; // List of mesh names (with wildcards) to import, even if in the neverImportMesh list String alwaysImportMesh; // List of mesh names (with wildcards) to import, even if in the neverImportMesh list
String neverImportMesh; // List of mesh names (with wildcards) to ignore on loading String neverImportMesh; // List of mesh names (with wildcards) to ignore on loading
String neverImportMat; // List of material names (with wildcards) to ignore on loading
bool ignoreNodeScale; // Ignore <scale> elements in <node>s bool ignoreNodeScale; // Ignore <scale> elements in <node>s
bool adjustCenter; // Translate model so origin is at the center bool adjustCenter; // Translate model so origin is at the center
bool adjustFloor; // Translate model so origin is at the bottom bool adjustFloor; // Translate model so origin is at the bottom
@ -109,9 +110,10 @@ namespace ColladaUtils
singleDetailSize = 2; singleDetailSize = 2;
matNamePrefix = ""; matNamePrefix = "";
alwaysImport = ""; alwaysImport = "";
neverImport = ""; neverImport = String(Con::getVariable("$TSShapeConstructor::neverImport"));
alwaysImportMesh = ""; alwaysImportMesh = "";
neverImportMesh = ""; neverImportMesh = String(Con::getVariable("$TSShapeConstructor::neverImportMesh"));
neverImportMat = String(Con::getVariable("$TSShapeConstructor::neverImportMat"));
ignoreNodeScale = false; ignoreNodeScale = false;
adjustCenter = false; adjustCenter = false;
adjustFloor = false; adjustFloor = false;
@ -632,7 +634,7 @@ public:
/// Most primitives can use these common implementations /// Most primitives can use these common implementations
const char* getElementName() { return primitive->getElementName(); } const char* getElementName() { return primitive->getElementName(); }
const char* getMaterial() { return primitive->getMaterial(); } const char* getMaterial() { return (FindMatch::isMatchMultipleExprs(ColladaUtils::getOptions().neverImportMat, primitive->getMaterial(), false)) ? NULL : primitive->getMaterial(); }
const domInputLocalOffset_Array& getInputs() { return primitive->getInput_array(); } const domInputLocalOffset_Array& getInputs() { return primitive->getInput_array(); }
S32 getStride() const { return stride; } S32 getStride() const { return stride; }

View file

@ -144,6 +144,7 @@ TSShapeConstructor::TSShapeConstructor()
mOptions.neverImport = String(Con::getVariable("$TSShapeConstructor::neverImport")); mOptions.neverImport = String(Con::getVariable("$TSShapeConstructor::neverImport"));
mOptions.alwaysImportMesh = ""; mOptions.alwaysImportMesh = "";
mOptions.neverImportMesh = String(Con::getVariable("$TSShapeConstructor::neverImportMesh")); mOptions.neverImportMesh = String(Con::getVariable("$TSShapeConstructor::neverImportMesh"));
mOptions.neverImportMat = String(Con::getVariable("$TSShapeConstructor::neverImportMat"));
mOptions.ignoreNodeScale = false; mOptions.ignoreNodeScale = false;
mOptions.adjustCenter = false; mOptions.adjustCenter = false;
mOptions.adjustFloor = false; mOptions.adjustFloor = false;
@ -266,6 +267,13 @@ void TSShapeConstructor::initPersistFields()
"not be imported (unless it matches the alwaysImportMesh list.\n" "not be imported (unless it matches the alwaysImportMesh list.\n"
"@see alwaysImportMesh" ); "@see alwaysImportMesh" );
addField("neverImportMat", TypeRealString, Offset(mOptions.neverImportMat, TSShapeConstructor),
"TAB separated patterns of materials to ignore on loading. No effect for DTS files.\n"
"Torque allows unwanted materials in COLLADA (.dae) files to to be ignored "
"during import. This field contains a TAB separated list of patterns to "
"match material names. Any material that matches one of the patterns in the list will "
"not be imported");
addField( "ignoreNodeScale", TypeBool, Offset(mOptions.ignoreNodeScale, TSShapeConstructor), addField( "ignoreNodeScale", TypeBool, Offset(mOptions.ignoreNodeScale, TSShapeConstructor),
"Ignore <scale> elements inside COLLADA <node>s. No effect for DTS files.\n" "Ignore <scale> elements inside COLLADA <node>s. No effect for DTS files.\n"
"This field is a workaround for certain exporters that generate bad node " "This field is a workaround for certain exporters that generate bad node "

View file

@ -35,7 +35,7 @@
HorizSizing = "center"; HorizSizing = "center";
VertSizing = "center"; VertSizing = "center";
position = "254 136"; position = "254 136";
Extent = "516 447"; Extent = "516 477";
MinExtent = "8 8"; MinExtent = "8 8";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
@ -51,7 +51,7 @@
HorizSizing = "width"; HorizSizing = "width";
VertSizing = "height"; VertSizing = "height";
position = "8 24"; position = "8 24";
Extent = "238 417"; Extent = "238 437";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
@ -127,7 +127,7 @@
HorizSizing = "width"; HorizSizing = "width";
VertSizing = "height"; VertSizing = "height";
position = "254 24"; position = "254 24";
Extent = "254 417"; Extent = "254 437";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
@ -426,7 +426,7 @@
HorizSizing = "right"; HorizSizing = "right";
VertSizing = "bottom"; VertSizing = "bottom";
position = "0 68"; position = "0 68";
Extent = "254 153"; Extent = "254 173";
MinExtent = "8 8"; MinExtent = "8 8";
canSave = "1"; canSave = "1";
Visible = "1"; Visible = "1";
@ -763,13 +763,63 @@
internalName = "neverImportMesh"; internalName = "neverImportMesh";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiTextCtrl() {
text = "Ignore Materials";
maxLength = "1024";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
isContainer = "0";
Profile = "ToolsGuiTextRightProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "13 150";
Extent = "72 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
new GuiTextEditCtrl() {
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
passwordMask = "*";
maxLength = "1024";
Margin = "0 0 0 0";
Padding = "0 0 0 0";
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
isContainer = "0";
Profile = "ToolsGuiTextEditProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "97 150";
Extent = "148 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
AltCommand = "ColladaImportTreeView.refresh(\"nodes\");";
tooltipprofile = "ToolsGuiToolTipProfile";
hovertime = "1000";
internalName = "neverImportMat";
canSaveDynamicFields = "0";
};
}; };
new GuiBitmapBorderCtrl() { new GuiBitmapBorderCtrl() {
isContainer = "1"; isContainer = "1";
Profile = "ToolsGuiGroupBorderProfile"; Profile = "ToolsGuiGroupBorderProfile";
HorizSizing = "right"; HorizSizing = "right";
VertSizing = "bottom"; VertSizing = "bottom";
position = "0 226"; position = "0 246";
Extent = "254 105"; Extent = "254 105";
MinExtent = "8 8"; MinExtent = "8 8";
canSave = "1"; canSave = "1";
@ -966,7 +1016,7 @@
Profile = "ToolsGuiGroupBorderProfile"; Profile = "ToolsGuiGroupBorderProfile";
HorizSizing = "right"; HorizSizing = "right";
VertSizing = "bottom"; VertSizing = "bottom";
position = "0 338"; position = "0 358";
Extent = "254 24"; Extent = "254 24";
MinExtent = "8 8"; MinExtent = "8 8";
canSave = "1"; canSave = "1";
@ -1006,7 +1056,7 @@
Profile = "ToolsGuiButtonProfile"; Profile = "ToolsGuiButtonProfile";
HorizSizing = "right"; HorizSizing = "right";
VertSizing = "bottom"; VertSizing = "bottom";
position = "11 368"; position = "11 388";
Extent = "86 22"; Extent = "86 22";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -1025,7 +1075,7 @@
Profile = "ToolsGuiButtonProfile"; Profile = "ToolsGuiButtonProfile";
HorizSizing = "right"; HorizSizing = "right";
VertSizing = "bottom"; VertSizing = "bottom";
position = "11 395"; position = "11 415";
Extent = "86 22"; Extent = "86 22";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -1044,7 +1094,7 @@
Profile = "ToolsGuiButtonProfile"; Profile = "ToolsGuiButtonProfile";
HorizSizing = "right"; HorizSizing = "right";
VertSizing = "bottom"; VertSizing = "bottom";
position = "159 368"; position = "159 388";
Extent = "86 22"; Extent = "86 22";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -1064,7 +1114,7 @@
Profile = "ToolsGuiButtonProfile"; Profile = "ToolsGuiButtonProfile";
HorizSizing = "right"; HorizSizing = "right";
VertSizing = "bottom"; VertSizing = "bottom";
position = "159 395"; position = "159 415";
Extent = "86 22"; Extent = "86 22";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -1276,6 +1326,7 @@ function ColladaImportDlg::showDialog(%this, %shapePath, %cmd)
%this-->neverImport.setText(strreplace(%this.constructor.neverImport, "\t", ";")); %this-->neverImport.setText(strreplace(%this.constructor.neverImport, "\t", ";"));
%this-->alwaysImportMesh.setText(strreplace(%this.constructor.alwaysImportMesh, "\t", ";")); %this-->alwaysImportMesh.setText(strreplace(%this.constructor.alwaysImportMesh, "\t", ";"));
%this-->neverImportMesh.setText(strreplace(%this.constructor.neverImportMesh, "\t", ";")); %this-->neverImportMesh.setText(strreplace(%this.constructor.neverImportMesh, "\t", ";"));
%this-->neverImportMat.setText(strreplace(%this.constructor.neverImportMat, "\t", ";"));
%this-->ignoreNodeScale.setStateOn(%this.constructor.ignoreNodeScale); %this-->ignoreNodeScale.setStateOn(%this.constructor.ignoreNodeScale);
%this-->adjustCenter.setStateOn(%this.constructor.adjustCenter); %this-->adjustCenter.setStateOn(%this.constructor.adjustCenter);
%this-->adjustFloor.setStateOn(%this.constructor.adjustFloor); %this-->adjustFloor.setStateOn(%this.constructor.adjustFloor);
@ -1285,13 +1336,14 @@ function ColladaImportDlg::showDialog(%this, %shapePath, %cmd)
else else
{ {
// Default settings // Default settings
%this-->lodType.setText("DetectDTS"); %this-->lodType.setText("TrailingNumber");
%this-->singleDetailSize.setText("2"); %this-->singleDetailSize.setText("2");
%this-->materialPrefix.setText(""); %this-->materialPrefix.setText("");
%this-->alwaysImport.setText(""); %this-->alwaysImport.setText("");
%this-->neverImport.setText(""); %this-->neverImport.setText($TSShapeConstructor::neverImport);
%this-->alwaysImportMesh.setText(""); %this-->alwaysImportMesh.setText("");
%this-->neverImportMesh.setText(""); %this-->neverImportMesh.setText($TSShapeConstructor::neverImportMesh);
%this-->neverImportMat.setText($TSShapeConstructor::neverImportMat);
%this-->ignoreNodeScale.setStateOn(0); %this-->ignoreNodeScale.setStateOn(0);
%this-->adjustCenter.setStateOn(0); %this-->adjustCenter.setStateOn(0);
%this-->adjustFloor.setStateOn(0); %this-->adjustFloor.setStateOn(0);
@ -1418,6 +1470,7 @@ function ColladaImportTreeView::refresh(%this, %what)
%this._neverImport = strreplace(ColladaImportDlg-->neverImport.getText(), ";", "\t"); %this._neverImport = strreplace(ColladaImportDlg-->neverImport.getText(), ";", "\t");
%this._alwaysImportMesh = strreplace(ColladaImportDlg-->alwaysImportMesh.getText(), ";", "\t"); %this._alwaysImportMesh = strreplace(ColladaImportDlg-->alwaysImportMesh.getText(), ";", "\t");
%this._neverImportMesh = strreplace(ColladaImportDlg-->neverImportMesh.getText(), ";", "\t"); %this._neverImportMesh = strreplace(ColladaImportDlg-->neverImportMesh.getText(), ";", "\t");
%this._neverImportMat = strreplace(ColladaImportDlg-->neverImportMat.getText(), ";", "\t");
%this.refreshNode(%this.getChild(%shapeRoot)); %this.refreshNode(%this.getChild(%shapeRoot));
} }
@ -1527,6 +1580,7 @@ function ColladaImportDlg::onOK(%this)
(%this-->neverImport.getText() !$= "") || (%this-->neverImport.getText() !$= "") ||
(%this-->alwaysImportMesh.getText() !$= "") || (%this-->alwaysImportMesh.getText() !$= "") ||
(%this-->neverImportMesh.getText() !$= "") || (%this-->neverImportMesh.getText() !$= "") ||
(%this-->neverImportMat.getText() !$= "") ||
(%this-->ignoreNodeScale.getValue() != 0) || (%this-->ignoreNodeScale.getValue() != 0) ||
(%this-->adjustCenter.getValue() != 0) || (%this-->adjustCenter.getValue() != 0) ||
(%this-->adjustFloor.getValue() != 0) || (%this-->adjustFloor.getValue() != 0) ||
@ -1560,6 +1614,7 @@ function ColladaImportDlg::onOK(%this)
%this.constructor.neverImport = strreplace(%this-->neverImport.getText(), ";", "\t"); %this.constructor.neverImport = strreplace(%this-->neverImport.getText(), ";", "\t");
%this.constructor.alwaysImportMesh = strreplace(%this-->alwaysImportMesh.getText(), ";", "\t"); %this.constructor.alwaysImportMesh = strreplace(%this-->alwaysImportMesh.getText(), ";", "\t");
%this.constructor.neverImportMesh = strreplace(%this-->neverImportMesh.getText(), ";", "\t"); %this.constructor.neverImportMesh = strreplace(%this-->neverImportMesh.getText(), ";", "\t");
%this.constructor.neverImportMat = strreplace(%this-->neverImportMat.getText(), ";", "\t");
%this.constructor.ignoreNodeScale = %this-->ignoreNodeScale.getValue(); %this.constructor.ignoreNodeScale = %this-->ignoreNodeScale.getValue();
%this.constructor.adjustCenter = %this-->adjustCenter.getValue(); %this.constructor.adjustCenter = %this-->adjustCenter.getValue();
%this.constructor.adjustFloor = %this-->adjustFloor.getValue(); %this.constructor.adjustFloor = %this-->adjustFloor.getValue();