mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Assetifies MeshRoad, Decal Road, and the material slot of GroundCover
Creates a networked and non-networked variant of DECLARE_MATERIALASSET macro
This commit is contained in:
parent
a0ba345095
commit
bf5b26f734
17 changed files with 301 additions and 117 deletions
|
|
@ -96,10 +96,10 @@ GuiMeshRoadEditorCtrl::GuiMeshRoadEditorCtrl()
|
|||
mSelectedSplineColor( 0,255,0,255 ),
|
||||
mHoverNodeColor( 255,255,255,255 ),
|
||||
mHasCopied( false )
|
||||
{
|
||||
mMaterialName[Top] = StringTable->insert("DefaultRoadMaterialTop");
|
||||
mMaterialName[Bottom] = StringTable->insert("DefaultRoadMaterialOther");
|
||||
mMaterialName[Side] = StringTable->insert("DefaultRoadMaterialOther");
|
||||
{
|
||||
mTopMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultTopMaterialAsset");
|
||||
mBottomMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultBottomMaterialAsset");
|
||||
mSideMaterialAssetId = Con::getVariable("$MeshRoadEditor::defaultSideMaterialAsset");
|
||||
}
|
||||
|
||||
GuiMeshRoadEditorCtrl::~GuiMeshRoadEditorCtrl()
|
||||
|
|
@ -205,6 +205,10 @@ bool GuiMeshRoadEditorCtrl::onAdd()
|
|||
desc.zEnable = true;
|
||||
mZEnableSB = GFX->createStateBlock(desc);
|
||||
|
||||
bindMaterialAsset(TopMaterial);
|
||||
bindMaterialAsset(BottomMaterial);
|
||||
bindMaterialAsset(SideMaterial);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -217,12 +221,11 @@ void GuiMeshRoadEditorCtrl::initPersistFields()
|
|||
addField( "SelectedSplineColor", TypeColorI, Offset( mSelectedSplineColor, GuiMeshRoadEditorCtrl ) );
|
||||
addField( "HoverNodeColor", TypeColorI, Offset( mHoverNodeColor, GuiMeshRoadEditorCtrl ) );
|
||||
addField( "isDirty", TypeBool, Offset( mIsDirty, GuiMeshRoadEditorCtrl ) );
|
||||
addField( "topMaterialName", TypeString, Offset( mMaterialName[Top], GuiMeshRoadEditorCtrl ),
|
||||
"Default Material used by the Mesh Road Editor on upper surface road creation." );
|
||||
addField( "bottomMaterialName", TypeString, Offset( mMaterialName[Bottom], GuiMeshRoadEditorCtrl ),
|
||||
"Default Material used by the Mesh Road Editor on bottom surface road creation." );
|
||||
addField( "sideMaterialName", TypeString, Offset( mMaterialName[Side], GuiMeshRoadEditorCtrl ),
|
||||
"Default Material used by the Mesh Road Editor on side surface road creation." );
|
||||
|
||||
addField("topMaterial", TypeMaterialAssetId, Offset(mTopMaterialAssetId, GuiMeshRoadEditorCtrl), "Default Material used by the Mesh Road Editor on upper surface road creation.");
|
||||
addField("bottomMaterial", TypeMaterialAssetId, Offset(mBottomMaterialAssetId, GuiMeshRoadEditorCtrl), "Default Material used by the Mesh Road Editor on bottom surface road creation.");
|
||||
addField("sideMaterial", TypeMaterialAssetId, Offset(mSideMaterialAssetId, GuiMeshRoadEditorCtrl), "Default Material used by the Mesh Road Editor on side surface road creation.");
|
||||
|
||||
//addField( "MoveNodeCursor", TYPEID< SimObject >(), Offset( mMoveNodeCursor, GuiMeshRoadEditorCtrl) );
|
||||
//addField( "AddNodeCursor", TYPEID< SimObject >(), Offset( mAddNodeCursor, GuiMeshRoadEditorCtrl) );
|
||||
//addField( "InsertNodeCursor", TYPEID< SimObject >(), Offset( mInsertNodeCursor, GuiMeshRoadEditorCtrl) );
|
||||
|
|
@ -622,10 +625,13 @@ void GuiMeshRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
|
|||
}
|
||||
|
||||
MeshRoad *newRoad = new MeshRoad;
|
||||
|
||||
newRoad->mMaterialName[Top] = mMaterialName[Top];
|
||||
newRoad->mMaterialName[Bottom] = mMaterialName[Bottom];
|
||||
newRoad->mMaterialName[Side] = mMaterialName[Side];
|
||||
|
||||
if(mTopMaterialAsset.notNull())
|
||||
newRoad->setTopMaterialAssetId(mTopMaterialAssetId);
|
||||
if (mBottomMaterialAsset.notNull())
|
||||
newRoad->setBottomMaterialAssetId(mBottomMaterialAssetId);
|
||||
if (mSideMaterialAsset.notNull())
|
||||
newRoad->setSideMaterialAssetId(mSideMaterialAssetId);
|
||||
|
||||
newRoad->registerObject();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@
|
|||
#include "environment/meshRoad.h"
|
||||
#endif
|
||||
|
||||
#include "T3D/assets/MaterialAsset.h"
|
||||
|
||||
class GameBase;
|
||||
|
||||
class GuiMeshRoadEditorCtrl : public EditTSCtrl
|
||||
|
|
@ -156,8 +158,14 @@ class GuiMeshRoadEditorCtrl : public EditTSCtrl
|
|||
|
||||
bool mHasCopied;
|
||||
public:
|
||||
|
||||
StringTableEntry mMaterialName[SurfaceCount];
|
||||
|
||||
StringTableEntry mTopMaterialAssetId;
|
||||
StringTableEntry mBottomMaterialAssetId;
|
||||
StringTableEntry mSideMaterialAssetId;
|
||||
|
||||
AssetPtr<MaterialAsset> mTopMaterialAsset;
|
||||
AssetPtr<MaterialAsset> mBottomMaterialAsset;
|
||||
AssetPtr<MaterialAsset> mSideMaterialAsset;
|
||||
};
|
||||
|
||||
class GuiMeshRoadEditorUndoAction : public UndoAction
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ GuiRoadEditorCtrl::GuiRoadEditorCtrl()
|
|||
mSavedDrag = false;
|
||||
mIsDirty = false;
|
||||
|
||||
mMaterialName = StringTable->insert("DefaultDecalRoadMaterial");
|
||||
mMaterialAssetId = Con::getVariable("$DecalRoadEditor::defaultMaterialAsset");
|
||||
}
|
||||
|
||||
GuiRoadEditorCtrl::~GuiRoadEditorCtrl()
|
||||
|
|
@ -100,7 +100,7 @@ void GuiRoadEditorUndoAction::undo()
|
|||
return;
|
||||
|
||||
// Temporarily save the roads current data.
|
||||
String materialName = road->mMaterialName;
|
||||
String materialAssetId = road->mMaterialAssetId;
|
||||
F32 textureLength = road->mTextureLength;
|
||||
F32 breakAngle = road->mBreakAngle;
|
||||
F32 segmentsPerBatch = road->mSegmentsPerBatch;
|
||||
|
|
@ -108,7 +108,7 @@ void GuiRoadEditorUndoAction::undo()
|
|||
nodes.merge( road->mNodes );
|
||||
|
||||
// Restore the Road properties saved in the UndoAction
|
||||
road->mMaterialName = materialName;
|
||||
road->setMaterialAssetId(materialAssetId);
|
||||
road->mBreakAngle = breakAngle;
|
||||
road->mSegmentsPerBatch = segmentsPerBatch;
|
||||
road->mTextureLength = textureLength;
|
||||
|
|
@ -130,7 +130,7 @@ void GuiRoadEditorUndoAction::undo()
|
|||
|
||||
// Now save the previous Road data in this UndoAction
|
||||
// since an undo action must become a redo action and vice-versa
|
||||
mMaterialName = materialName;
|
||||
mMaterialAssetId = materialAssetId;
|
||||
mBreakAngle = breakAngle;
|
||||
mSegmentsPerBatch = segmentsPerBatch;
|
||||
mTextureLength = textureLength;
|
||||
|
|
@ -153,6 +153,8 @@ bool GuiRoadEditorCtrl::onAdd()
|
|||
|
||||
mZDisableSB = GFX->createStateBlock(desc);
|
||||
|
||||
bindMaterialAsset(Material);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -163,8 +165,9 @@ void GuiRoadEditorCtrl::initPersistFields()
|
|||
addField( "SelectedSplineColor", TypeColorI, Offset( mSelectedSplineColor, GuiRoadEditorCtrl ) );
|
||||
addField( "HoverNodeColor", TypeColorI, Offset( mHoverNodeColor, GuiRoadEditorCtrl ) );
|
||||
addField( "isDirty", TypeBool, Offset( mIsDirty, GuiRoadEditorCtrl ) );
|
||||
addField( "materialName", TypeString, Offset( mMaterialName, GuiRoadEditorCtrl ),
|
||||
"Default Material used by the Road Editor on road creation." );
|
||||
|
||||
addField("material", TypeMaterialAssetId, Offset(mMaterialAssetId, GuiRoadEditorCtrl), "Default Material used by the Road Editor on road creation.");
|
||||
|
||||
//addField( "MoveNodeCursor", TYPEID< SimObject >(), Offset( mMoveNodeCursor, GuiRoadEditorCtrl) );
|
||||
//addField( "AddNodeCursor", TYPEID< SimObject >(), Offset( mAddNodeCursor, GuiRoadEditorCtrl) );
|
||||
//addField( "InsertNodeCursor", TYPEID< SimObject >(), Offset( mInsertNodeCursor, GuiRoadEditorCtrl) );
|
||||
|
|
@ -405,8 +408,8 @@ void GuiRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
|
|||
|
||||
DecalRoad *newRoad = new DecalRoad;
|
||||
|
||||
|
||||
newRoad->mMaterialName = mMaterialName;
|
||||
if (mMaterialAsset.notNull())
|
||||
newRoad->setMaterialAssetId(mMaterialAssetId);
|
||||
|
||||
newRoad->registerObject();
|
||||
|
||||
|
|
@ -1027,7 +1030,7 @@ void GuiRoadEditorCtrl::submitUndo( const UTF8 *name )
|
|||
|
||||
action->mObjId = mSelRoad->getId();
|
||||
action->mBreakAngle = mSelRoad->mBreakAngle;
|
||||
action->mMaterialName = mSelRoad->mMaterialName;
|
||||
action->mMaterialAssetId = mSelRoad->mMaterialAssetId;
|
||||
action->mSegmentsPerBatch = mSelRoad->mSegmentsPerBatch;
|
||||
action->mTextureLength = mSelRoad->mTextureLength;
|
||||
action->mRoadEditor = this;
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ class GuiRoadEditorCtrl : public EditTSCtrl
|
|||
|
||||
public:
|
||||
|
||||
StringTableEntry mMaterialName;
|
||||
StringTableEntry mMaterialAssetId;
|
||||
AssetPtr<MaterialAsset> mMaterialAsset;
|
||||
protected:
|
||||
|
||||
void _drawRoadSpline( DecalRoad *road, const ColorI &color );
|
||||
|
|
@ -158,7 +159,7 @@ class GuiRoadEditorUndoAction : public UndoAction
|
|||
Vector<RoadNode> mNodes;
|
||||
|
||||
SimObjectId mObjId;
|
||||
String mMaterialName;
|
||||
StringTableEntry mMaterialAssetId;
|
||||
F32 mBreakAngle;
|
||||
U32 mSegmentsPerBatch;
|
||||
F32 mTextureLength;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue