From 388a700a53cf5f1747bcc551a1188148832da7bc Mon Sep 17 00:00:00 2001 From: Areloch Date: Sun, 1 Nov 2020 23:32:34 -0600 Subject: [PATCH] Implements material asset handling for GroundPlane object Adds handling for finding material asset akin to shape and image assets Updates the material asset inspector field to follow the current standard Updates prototyping material assets to correctly have materialDefinitionName assigned Fixed material asset import step to properly assign materialDefinitionName Fixed typo in material editor icon name Added logic to editAsset function call so it can also parse assetIds Changed DefaultEditorLevel to utilize FloorGray material Adds proper NoMaterial asset for fallback purposes --- Engine/source/T3D/assets/MaterialAsset.cpp | 206 ++++++++++-------- Engine/source/T3D/assets/MaterialAsset.h | 25 ++- Engine/source/T3D/assets/assetImporter.cpp | 2 + Engine/source/T3D/groundPlane.cpp | 114 ++++++++-- Engine/source/T3D/groundPlane.h | 12 + .../rendering/materials/NoMaterial.asset.taml | 6 + .../core/rendering/materials/NoMaterial.cs | 6 + .../Materials/DetailBlue.asset.taml | 1 + .../Materials/FloorGray.asset.taml | 1 + .../Materials/InteractiveRed.asset.taml | 1 + .../Materials/NatureBrown.asset.taml | 1 + .../Materials/NatureGreen.asset.taml | 1 + .../Prototyping/Materials/NullPink.asset.taml | 1 + .../Materials/TrimYellow.asset.taml | 1 + .../Materials/WallOrange.asset.taml | 1 + .../Materials/WaterBlue.asset.taml | 1 + .../Prototyping/shapes/kork_chan.asset.taml | 1 + .../scripts/assetTypes/material.cs | 2 +- .../tools/assetBrowser/scripts/editAsset.cs | 6 + .../levels/DefaultEditorLevel.asset.taml | 2 +- .../game/tools/levels/DefaultEditorLevel.mis | 11 +- .../game/tools/materialEditor/main.cs | 2 +- .../shapeEditor/gui/shapeEdPropWindow.ed.gui | 2 +- ...ial-editor_d.png => material-editor_d.png} | Bin ...ial-editor_h.png => material-editor_h.png} | Bin ...ial-editor_n.png => material-editor_n.png} | Bin 26 files changed, 279 insertions(+), 127 deletions(-) create mode 100644 Templates/BaseGame/game/core/rendering/materials/NoMaterial.asset.taml create mode 100644 Templates/BaseGame/game/core/rendering/materials/NoMaterial.cs rename Templates/BaseGame/game/tools/worldEditor/images/toolbar/{matterial-editor_d.png => material-editor_d.png} (100%) rename Templates/BaseGame/game/tools/worldEditor/images/toolbar/{matterial-editor_h.png => material-editor_h.png} (100%) rename Templates/BaseGame/game/tools/worldEditor/images/toolbar/{matterial-editor_n.png => material-editor_n.png} (100%) diff --git a/Engine/source/T3D/assets/MaterialAsset.cpp b/Engine/source/T3D/assets/MaterialAsset.cpp index 6b4203938..c44c53937 100644 --- a/Engine/source/T3D/assets/MaterialAsset.cpp +++ b/Engine/source/T3D/assets/MaterialAsset.cpp @@ -85,6 +85,35 @@ ConsoleSetType(TypeMaterialAssetPtr) Con::warnf("(TypeMaterialAssetPtr) - Cannot set multiple args to a single asset."); } + +ConsoleType(assetIdString, TypeMaterialAssetId, String, ASSET_ID_FIELD_PREFIX) + +ConsoleGetType(TypeMaterialAssetId) +{ + // Fetch asset Id. + return *((const char**)(dptr)); +} + +ConsoleSetType(TypeMaterialAssetId) +{ + // Was a single argument specified? + if (argc == 1) + { + // Yes, so fetch field value. + const char* pFieldValue = argv[0]; + + // Fetch asset Id. + StringTableEntry* assetId = (StringTableEntry*)(dptr); + + // Update asset value. + *assetId = StringTable->insert(pFieldValue); + + return; + } + + // Warn. + Con::warnf("(TypeMaterialAssetId) - Cannot set multiple args to a single asset."); +} //----------------------------------------------------------------------------- MaterialAsset::MaterialAsset() @@ -180,6 +209,51 @@ DefineEngineMethod(MaterialAsset, compileShader, void, (), , "Compiles the mater object->compileShader(); } +//------------------------------------------------------------------------------ +StringTableEntry MaterialAsset::getAssetIdByMaterialName(StringTableEntry matName) +{ + StringTableEntry materialAssetId = StringTable->EmptyString(); + + AssetQuery* query = new AssetQuery(); + U32 foundCount = AssetDatabase.findAssetType(query, "MaterialAsset"); + if (foundCount == 0) + { + //Didn't work, so have us fall back to a placeholder asset + materialAssetId = StringTable->insert("Core_Rendering:noMaterial"); + } + else + { + for (U32 i = 0; i < foundCount; i++) + { + MaterialAsset* matAsset = AssetDatabase.acquireAsset(query->mAssetList[i]); + if (matAsset && matAsset->getMaterialDefinitionName() == matName) + { + materialAssetId = matAsset->getAssetId(); + break; + } + } + } + + return materialAssetId; +} + +bool MaterialAsset::getAssetById(StringTableEntry assetId, AssetPtr* materialAsset) +{ + (*materialAsset) = assetId; + + if (!materialAsset->isNull()) + return true; + + //Didn't work, so have us fall back to a placeholder asset + StringTableEntry noImageId = StringTable->insert("Core_Rendering:noMaterial"); + materialAsset->setAssetId(noImageId); + + if (!materialAsset->isNull()) + return true; + + return false; +} + //----------------------------------------------------------------------------- // GuiInspectorTypeAssetId //----------------------------------------------------------------------------- @@ -187,7 +261,7 @@ DefineEngineMethod(MaterialAsset, compileShader, void, (), , "Compiles the mater IMPLEMENT_CONOBJECT(GuiInspectorTypeMaterialAssetPtr); ConsoleDocClass(GuiInspectorTypeMaterialAssetPtr, - "@brief Inspector field type for Material Asset Objects\n\n" + "@brief Inspector field type for Shapes\n\n" "Editor use only.\n\n" "@internal" ); @@ -202,70 +276,36 @@ void GuiInspectorTypeMaterialAssetPtr::consoleInit() GuiControl* GuiInspectorTypeMaterialAssetPtr::constructEditControl() { // Create base filename edit controls - mUseHeightOverride = true; - mHeightOverride = 100; - - mMatEdContainer = new GuiControl(); - mMatEdContainer->registerObject(); - - addObject(mMatEdContainer); - - // Create "Open in ShapeEditor" button - mMatPreviewButton = new GuiBitmapButtonCtrl(); - - const char* matAssetId = getData(); - - MaterialAsset* matAsset = AssetDatabase.acquireAsset< MaterialAsset>(matAssetId); - - Material* materialDef = nullptr; - - char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor"; - - StringTableEntry matDefName = matAsset ? matAsset->getMaterialDefinitionName() : matAssetId; - - if (!Sim::findObject(matDefName, materialDef)) - { - Con::errorf("GuiInspectorTypeMaterialAssetPtr::constructEditControl() - unable to find material in asset"); - } - else - { - mMatPreviewButton->setBitmap(materialDef->mDiffuseMapFilename[0]); - } - - mMatPreviewButton->setPosition(0, 0); - mMatPreviewButton->setExtent(100,100); + GuiControl* retCtrl = Parent::constructEditControl(); + if (retCtrl == NULL) + return retCtrl; // Change filespec char szBuffer[512]; - dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"MaterialAsset\", \"AssetBrowser.changeAsset\", %d, %s);", - mInspector->getComponentGroupTargetId(), mCaption); - mMatPreviewButton->setField("Command", szBuffer); + dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"MaterialAsset\", \"AssetBrowser.changeAsset\", %s, %s);", + mInspector->getInspectObject()->getIdString(), mCaption); + mBrowseButton->setField("Command", szBuffer); - mMatPreviewButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile"); - mMatPreviewButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile"); - mMatPreviewButton->setDataField(StringTable->insert("hovertime"), NULL, "1000"); + setDataField(StringTable->insert("targetObject"), NULL, mInspector->getInspectObject()->getIdString()); - StringBuilder strbld; - strbld.append(matDefName); - strbld.append("\n"); - strbld.append("Open this file in the Material Editor"); + // Create "Open in Editor" button + mEditButton = new GuiBitmapButtonCtrl(); - mMatPreviewButton->setDataField(StringTable->insert("tooltip"), NULL, strbld.data()); + dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.editAsset(%d.getText());", retCtrl->getId()); + mEditButton->setField("Command", szBuffer); - _registerEditControl(mMatPreviewButton); - //mMatPreviewButton->registerObject(); - mMatEdContainer->addObject(mMatPreviewButton); + char bitmapName[512] = "tools/worldEditor/images/toolbar/material-editor"; + mEditButton->setBitmap(bitmapName); - mMatAssetIdTxt = new GuiTextEditCtrl(); - mMatAssetIdTxt->registerObject(); - mMatAssetIdTxt->setActive(false); + mEditButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile"); + mEditButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile"); + mEditButton->setDataField(StringTable->insert("hovertime"), NULL, "1000"); + mEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the Material Editor"); - mMatAssetIdTxt->setText(matAssetId); + mEditButton->registerObject(); + addObject(mEditButton); - mMatAssetIdTxt->setBounds(100, 0, 150, 18); - mMatEdContainer->addObject(mMatAssetIdTxt); - - return mMatEdContainer; + return retCtrl; } bool GuiInspectorTypeMaterialAssetPtr::updateRects() @@ -279,54 +319,32 @@ bool GuiInspectorTypeMaterialAssetPtr::updateRects() mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y); bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent); - - if (mMatEdContainer != nullptr && mMatPreviewButton != nullptr) + if (mBrowseButton != NULL) { - mMatPreviewButton->resize(mEditCtrlRect.point, mEditCtrlRect.extent); + mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4); + resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent); } - if (mMatPreviewButton != nullptr) + if (mEditButton != NULL) { - mMatPreviewButton->resize(Point2I::Zero, Point2I(100, 100)); - } - - if (mMatAssetIdTxt != nullptr) - { - mMatAssetIdTxt->resize(Point2I(100, 0), Point2I(mEditCtrlRect.extent.x - 100, 18)); + RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4); + resized |= mEditButton->resize(shapeEdRect.point, shapeEdRect.extent); } return resized; } -bool GuiInspectorTypeMaterialAssetPtr::resize(const Point2I& newPosition, const Point2I& newExtent) +IMPLEMENT_CONOBJECT(GuiInspectorTypeMaterialAssetId); + +ConsoleDocClass(GuiInspectorTypeMaterialAssetId, + "@brief Inspector field type for Material Assets\n\n" + "Editor use only.\n\n" + "@internal" +); + +void GuiInspectorTypeMaterialAssetId::consoleInit() { - if (!Parent::resize(newPosition, newExtent)) - return false; + Parent::consoleInit(); - if (mMatEdContainer != NULL) - { - return updateRects(); - } - - return false; -} - -void GuiInspectorTypeMaterialAssetPtr::setMaterialAsset(String assetId) -{ - mTargetObject->setDataField(mCaption, "", assetId); - - //force a refresh - SimObject* obj = mInspector->getInspectObject(); - mInspector->inspectObject(obj); -} - -DefineEngineMethod(GuiInspectorTypeMaterialAssetPtr, setMaterialAsset, void, (String assetId), (""), - "Gets a particular shape animation asset for this shape.\n" - "@param animation asset index.\n" - "@return Shape Animation Asset.\n") -{ - if (assetId == String::EmptyString) - return; - - return object->setMaterialAsset(assetId); + ConsoleBaseType::getType(TypeMaterialAssetId)->setInspectorFieldType("GuiInspectorTypeMaterialAssetId"); } diff --git a/Engine/source/T3D/assets/MaterialAsset.h b/Engine/source/T3D/assets/MaterialAsset.h index b48a4486e..3eab28afb 100644 --- a/Engine/source/T3D/assets/MaterialAsset.h +++ b/Engine/source/T3D/assets/MaterialAsset.h @@ -42,9 +42,7 @@ #include "gfx/gfxDevice.h" #endif -#ifndef _GUI_INSPECTOR_TYPES_H_ #include "gui/editor/guiInspectorTypes.h" -#endif #include "materials/matTextureTarget.h" #include "materials/materialDefinition.h" @@ -77,6 +75,9 @@ public: inline StringTableEntry getScriptPath(void) const { return mScriptPath; }; + static StringTableEntry getAssetIdByMaterialName(StringTableEntry fileName); + static bool getAssetById(StringTableEntry assetId, AssetPtr* materialAsset); + /// Declare Console Object. DECLARE_CONOBJECT(MaterialAsset); @@ -89,26 +90,32 @@ protected: }; DefineConsoleType(TypeMaterialAssetPtr, MaterialAsset) +DefineConsoleType(TypeMaterialAssetId, String) //----------------------------------------------------------------------------- // TypeAssetId GuiInspectorField Class //----------------------------------------------------------------------------- -class GuiInspectorTypeMaterialAssetPtr : public GuiInspectorField +class GuiInspectorTypeMaterialAssetPtr : public GuiInspectorTypeFileName { - typedef GuiInspectorField Parent; + typedef GuiInspectorTypeFileName Parent; public: - GuiControl* mMatEdContainer; - GuiBitmapButtonCtrl *mMatPreviewButton; - GuiTextEditCtrl *mMatAssetIdTxt; + GuiBitmapButtonCtrl* mEditButton; DECLARE_CONOBJECT(GuiInspectorTypeMaterialAssetPtr); static void consoleInit(); virtual GuiControl* constructEditControl(); virtual bool updateRects(); - virtual bool resize(const Point2I& newPosition, const Point2I& newExtent); - void setMaterialAsset(String assetId); +}; + +class GuiInspectorTypeMaterialAssetId : public GuiInspectorTypeMaterialAssetPtr +{ + typedef GuiInspectorTypeMaterialAssetPtr Parent; +public: + + DECLARE_CONOBJECT(GuiInspectorTypeMaterialAssetId); + static void consoleInit(); }; #endif // _ASSET_BASE_H_ diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index 95b3d1248..ed533a6cd 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -2633,6 +2633,8 @@ Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem) newAsset->setAssetName(assetName); newAsset->setScriptFile(scriptName.c_str()); newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, qualifiedFromFile); + newAsset->setDataField(StringTable->insert("materialDefinitionName"), nullptr, assetName); + //iterate through and write out the material maps dependencies S32 dependencySlotId = 0; diff --git a/Engine/source/T3D/groundPlane.cpp b/Engine/source/T3D/groundPlane.cpp index 9e0065adb..65bcf56ba 100644 --- a/Engine/source/T3D/groundPlane.cpp +++ b/Engine/source/T3D/groundPlane.cpp @@ -85,6 +85,9 @@ GroundPlane::GroundPlane() mConvexList = new Convex; mTypeMask |= TerrainLikeObjectType; + + mMaterialAsset = StringTable->EmptyString(); + mMaterialAssetId = StringTable->EmptyString(); } GroundPlane::~GroundPlane() @@ -103,7 +106,14 @@ void GroundPlane::initPersistFields() addField( "squareSize", TypeF32, Offset( mSquareSize, GroundPlane ), "Square size in meters to which %GroundPlane subdivides its geometry." ); addField( "scaleU", TypeF32, Offset( mScaleU, GroundPlane ), "Scale of texture repeat in the U direction." ); addField( "scaleV", TypeF32, Offset( mScaleV, GroundPlane ), "Scale of texture repeat in the V direction." ); - addField( "material", TypeMaterialName, Offset( mMaterialName, GroundPlane ), "Name of Material used to render %GroundPlane's surface." ); + + addProtectedField("materialAsset", TypeMaterialAssetId, Offset(mMaterialAssetId, GroundPlane), + &GroundPlane::_setMaterialAsset, &defaultProtectedGetFn, + "The material asset."); + + addProtectedField("material", TypeMaterialName, Offset(mMaterialName, GroundPlane), + &GroundPlane::_setMaterialName, &defaultProtectedGetFn, + "The material name."); endGroup( "Plane" ); @@ -114,6 +124,72 @@ void GroundPlane::initPersistFields() removeField( "rotation" ); } +bool GroundPlane::_setMaterialAsset(void* obj, const char* index, const char* data) +{ + GroundPlane* gp = static_cast(obj);// ->setFile(FileName(data)); + + gp->mMaterialAssetId = StringTable->insert(data); + + return gp->setMaterialAsset(gp->mMaterialAssetId); +} + +bool GroundPlane::_setMaterialName(void* obj, const char* index, const char* data) +{ + GroundPlane* gp = static_cast(obj);// ->setFile(FileName(data)); + + StringTableEntry assetId = MaterialAsset::getAssetIdByMaterialName(StringTable->insert(data)); + if (assetId != StringTable->EmptyString()) + { + //Special exception case. If we've defaulted to the 'no shape' mesh, don't save it out, we'll retain the original ids/paths so it doesn't break + //the TSStatic + if (gp->setMaterialAsset(assetId)) + { + if (assetId == StringTable->insert("Core_Rendering:noMaterial")) + { + gp->mMaterialName = data; + gp->mMaterialAssetId = StringTable->EmptyString(); + + return true; + } + else + { + gp->mMaterialAssetId = assetId; + gp->mMaterialName = StringTable->EmptyString(); + + return false; + } + } + } + else + { + gp->mMaterialAsset = StringTable->EmptyString(); + gp->mMaterialName = data; + } + + return true; +} + +bool GroundPlane::setMaterialAsset(const StringTableEntry materialAssetId) +{ + if (MaterialAsset::getAssetById(materialAssetId, &mMaterialAsset)) + { + //Special exception case. If we've defaulted to the 'no shape' mesh, don't save it out, we'll retain the original ids/paths so it doesn't break + //the TSStatic + if (mMaterialAsset.getAssetId() != StringTable->insert("Core_Rendering:noMaterial")) + { + mMaterialName = StringTable->EmptyString(); + } + + _updateMaterial(); + + setMaskBits(-1); + + return true; + } + + return false; +} + bool GroundPlane::onAdd() { if( !Parent::onAdd() ) @@ -187,6 +263,7 @@ U32 GroundPlane::packUpdate( NetConnection* connection, U32 mask, BitStream* str stream->write( mSquareSize ); stream->write( mScaleU ); stream->write( mScaleV ); + stream->writeString( mMaterialAsset.getAssetId() ); stream->write( mMaterialName ); return retMask; @@ -199,6 +276,11 @@ void GroundPlane::unpackUpdate( NetConnection* connection, BitStream* stream ) stream->read( &mSquareSize ); stream->read( &mScaleU ); stream->read( &mScaleV ); + + char buffer[256]; + stream->readString(buffer); + setMaterialAsset(StringTable->insert(buffer)); + stream->read( &mMaterialName ); // If we're added then something possibly changed in @@ -213,23 +295,14 @@ void GroundPlane::unpackUpdate( NetConnection* connection, BitStream* stream ) void GroundPlane::_updateMaterial() { - if( mMaterialName.isEmpty() ) + if (!mMaterialAsset.isNull()) { - Con::warnf( "GroundPlane::_updateMaterial - no material set; defaulting to 'WarningMaterial'" ); - mMaterialName = "WarningMaterial"; + String matName = mMaterialAsset->getMaterialDefinitionName(); + + mMaterial = MATMGR->createMatInstance(matName, getGFXVertexFormat< VertexType >()); + if (!mMaterial) + Con::errorf("GroundPlane::_updateMaterial - no material called '%s'", matName.c_str()); } - - // If the material name matches then don't - // bother updating it. - if ( mMaterial && - mMaterialName.compare( mMaterial->getMaterial()->getName() ) == 0 ) - return; - - SAFE_DELETE( mMaterial ); - - mMaterial = MATMGR->createMatInstance( mMaterialName, getGFXVertexFormat< VertexType >() ); - if ( !mMaterial ) - Con::errorf( "GroundPlane::_updateMaterial - no material called '%s'", mMaterialName.c_str() ); } bool GroundPlane::castRay( const Point3F& start, const Point3F& end, RayInfo* info ) @@ -582,6 +655,13 @@ void GroundPlane::generateGrid( U32 width, U32 height, F32 squareSize, outPrimitives.unlock(); } +void GroundPlane::getUtilizedAssets(Vector* usedAssetsList) +{ + if (!mMaterialAsset.isNull() && mMaterialAsset->getAssetId() != StringTable->insert("Core_Rendering:noMaterial")) + usedAssetsList->push_back_unique(mMaterialAsset->getAssetId()); + +} + DefineEngineMethod( GroundPlane, postApply, void, (),, "Intended as a helper to developers and editor scripts.\n" "Force trigger an inspectPostApply. This will transmit " @@ -589,4 +669,4 @@ DefineEngineMethod( GroundPlane, postApply, void, (),, ) { object->inspectPostApply(); -} \ No newline at end of file +} diff --git a/Engine/source/T3D/groundPlane.h b/Engine/source/T3D/groundPlane.h index a634b4a84..829a3a1e2 100644 --- a/Engine/source/T3D/groundPlane.h +++ b/Engine/source/T3D/groundPlane.h @@ -33,6 +33,8 @@ #include "gfx/gfxPrimitiveBuffer.h" #endif +#include "T3D/assets/MaterialAsset.h" + class PhysicsBody; class BaseMatInstance; @@ -62,6 +64,9 @@ public: GroundPlane(); virtual ~GroundPlane(); + static bool _setMaterialAsset(void* obj, const char* index, const char* data); + static bool _setMaterialName(void* obj, const char* index, const char* data); + virtual bool onAdd(); virtual void onRemove(); virtual U32 packUpdate( NetConnection* connection, U32 mask, BitStream* stream ); @@ -76,6 +81,10 @@ public: static void initPersistFields(); + bool setMaterialAsset(const StringTableEntry materialAssetId); + + virtual void getUtilizedAssets(Vector* usedAssetsList); + protected: typedef GFXVertexPNTBT VertexType; @@ -103,6 +112,9 @@ private: String mMaterialName; ///< Object name of material to use. BaseMatInstance* mMaterial; ///< Instantiated material based on given material name. + AssetPtr mMaterialAsset; + StringTableEntry mMaterialAssetId; + PhysicsBody *mPhysicsRep; /// @name Rendering State diff --git a/Templates/BaseGame/game/core/rendering/materials/NoMaterial.asset.taml b/Templates/BaseGame/game/core/rendering/materials/NoMaterial.asset.taml new file mode 100644 index 000000000..bce32d434 --- /dev/null +++ b/Templates/BaseGame/game/core/rendering/materials/NoMaterial.asset.taml @@ -0,0 +1,6 @@ + diff --git a/Templates/BaseGame/game/core/rendering/materials/NoMaterial.cs b/Templates/BaseGame/game/core/rendering/materials/NoMaterial.cs new file mode 100644 index 000000000..7e19aa619 --- /dev/null +++ b/Templates/BaseGame/game/core/rendering/materials/NoMaterial.cs @@ -0,0 +1,6 @@ +//--- OBJECT WRITE BEGIN --- +singleton Material(NoMaterial) { + mapTo="NoMaterial"; + DiffuseMap = "core/rendering/images/warnMat"; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/DetailBlue.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/DetailBlue.asset.taml index a71da4b5a..1c03297eb 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/DetailBlue.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/DetailBlue.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="DetailBlue" scriptFile="@assetFile=DetailBlue.cs" + materialDefinitionName="DetailBlue" imageMap0="@Asset=Prototyping:DetailBlue_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/DetailBlue.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/FloorGray.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/FloorGray.asset.taml index f69435a38..0e1adc5b5 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/FloorGray.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/FloorGray.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="FloorGray" scriptFile="@assetFile=FloorGray.cs" + materialDefinitionName="FloorGray" imageMap0="@Asset=Prototyping:FloorGray_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/FloorGray.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/InteractiveRed.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/InteractiveRed.asset.taml index 86008f591..8fe893612 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/InteractiveRed.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/InteractiveRed.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="InteractiveRed" scriptFile="@assetFile=InteractiveRed.cs" + materialDefinitionName="InteractiveRed" imageMap0="@Asset=Prototyping:InteractiveRed_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/InteractiveRed.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/NatureBrown.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/NatureBrown.asset.taml index 1d86b24ce..330f0148f 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/NatureBrown.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/NatureBrown.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="NatureBrown" scriptFile="@assetFile=NatureBrown.cs" + materialDefinitionName="NatureBrown" imageMap0="@Asset=Prototyping:NatureBrown_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/NatureBrown.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/NatureGreen.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/NatureGreen.asset.taml index f8b1729e3..b1e709ee7 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/NatureGreen.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/NatureGreen.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="NatureGreen" scriptFile="@assetFile=NatureGreen.cs" + materialDefinitionName="NatureGreen" imageMap0="@Asset=Prototyping:NatureGreen_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/NatureGreen.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/NullPink.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/NullPink.asset.taml index 62bdc57c0..c8a7e8997 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/NullPink.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/NullPink.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="NullPink" scriptFile="@assetFile=NullPink.cs" + materialDefinitionName="NullPink" imageMap0="@Asset=Prototyping:NullPink_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/NullPink.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/TrimYellow.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/TrimYellow.asset.taml index 6469f6bcf..28563be8c 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/TrimYellow.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/TrimYellow.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="TrimYellow" scriptFile="@assetFile=TrimYellow.cs" + materialDefinitionName="TrimYellow" imageMap0="@Asset=Prototyping:TrimYellow_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/TrimYellow.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/WallOrange.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/WallOrange.asset.taml index af0aa6510..1ba7d09de 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/WallOrange.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/WallOrange.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="WallOrange" scriptFile="@assetFile=WallOrange.cs" + materialDefinitionName="WallOrange" imageMap0="@Asset=Prototyping:WallOrange_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/WallOrange.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/Materials/WaterBlue.asset.taml b/Templates/BaseGame/game/data/Prototyping/Materials/WaterBlue.asset.taml index 1349cb284..8c823bc2d 100644 --- a/Templates/BaseGame/game/data/Prototyping/Materials/WaterBlue.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/Materials/WaterBlue.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="WaterBlue" scriptFile="@assetFile=WaterBlue.cs" + materialDefinitionName="WaterBlue" imageMap0="@Asset=Prototyping:WaterBlue_ALBEDO" originalFilePath="D:/Gamedev/art/Blockout/WaterBlue.png" /> diff --git a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan.asset.taml b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan.asset.taml index b12b5ae46..431d66861 100644 --- a/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan.asset.taml +++ b/Templates/BaseGame/game/data/Prototyping/shapes/kork_chan.asset.taml @@ -3,5 +3,6 @@ canSaveDynamicFields="true" AssetName="kork_chan" scriptFile="@assetFile=kork_chan.cs" + materialDefinitionName="kork_chan" imageMap0="@Asset=Prototyping:kork_chan_ALBEDO" originalFilePath="D:/Gamedev/T3DMIT/Resources/Prototyping/Shapes" /> diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs index 57f143de1..97427d8ae 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs @@ -458,7 +458,7 @@ function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData) else if(%assetDef.materialDefinitionName.diffuseMapAsset[0] !$= "") { %imgAsset = AssetDatabase.acquireAsset(%assetDef.materialDefinitionName.diffuseMapAsset[0]); - %previewData.previewImage = %imgAsset.getImageFilename(); + %previewData.previewImage = %imgAsset.getImagePath(); } else %previewData.previewImage = "tools/assetBrowser/art/materialIcon"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs index cf01b0ae6..3a9f8d1e1 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.cs @@ -28,6 +28,12 @@ function AssetBrowser::editAsset(%this, %assetDef) } } } + else if(!isObject(%assetDef) && strchrpos(%assetDef, ":") != -1) + { + //Turns out we were passed an assetid, not an asset definition. + //Grab the asset def from that + %assetDef = AssetDatabase.acquireAsset(%assetDef); + } %assetType = %assetDef.getClassName(); diff --git a/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.asset.taml b/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.asset.taml index fc6aa0b1f..6f9c427a0 100644 --- a/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.asset.taml +++ b/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.asset.taml @@ -6,5 +6,5 @@ LevelName="DefaultEditorLevel" isSubScene="false" description="An empty room" - staticObjectAssetDependency0="@Asset=FPSGameplay:station01" + staticObjectAssetDependency0="@Asset=Prototyping:FloorGray" VersionId="1" /> diff --git a/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.mis b/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.mis index 95f017dfd..c08983fbe 100644 --- a/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.mis +++ b/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.mis @@ -5,6 +5,7 @@ new Scene(EditorTemplateLevel) { isSubScene = "0"; isEditing = "0"; isDirty = "0"; + EditPostEffects = "0"; cdTrack = "2"; CTF_scoreLimit = "5"; Enabled = "1"; @@ -35,6 +36,7 @@ new Scene(EditorTemplateLevel) { Material = "BlankSkyMat"; drawBottom = "0"; fogBandHeight = "0"; + dirtyGameObject = "0"; position = "0 0 0"; rotation = "1 0 0 0"; scale = "1 1 1"; @@ -48,8 +50,6 @@ new Scene(EditorTemplateLevel) { ambient = "0.337255 0.533333 0.619608 1"; brightness = "1"; castShadows = "1"; - staticRefreshFreq = "250"; - dynamicRefreshFreq = "8"; coronaEnabled = "1"; coronaScale = "0.5"; coronaTint = "1 1 1 1"; @@ -68,6 +68,7 @@ new Scene(EditorTemplateLevel) { representedInLightmap = "0"; shadowDarkenColor = "0 0 0 -1"; includeLightmappedGeometryInShadow = "0"; + dirtyGameObject = "0"; position = "0 0 0"; rotation = "1 0 0 0"; scale = "1 1 1"; @@ -75,6 +76,7 @@ new Scene(EditorTemplateLevel) { canSaveDynamicFields = "1"; bias = "0.1"; Blur = "1"; + dynamicRefreshFreq = "8"; Enabled = "1"; height = "1024"; lightBleedFactor = "0.8"; @@ -82,13 +84,15 @@ new Scene(EditorTemplateLevel) { pointShadowType = "PointShadowType_Paraboloid"; shadowBox = "-100 -100 -100 100 100 100"; splitFadeDistances = "1 1 1 1"; + staticRefreshFreq = "250"; width = "3072"; }; new GroundPlane() { squareSize = "128"; scaleU = "25"; scaleV = "25"; - Material = "Grid_512_Grey"; + MaterialAsset = "Prototyping:FloorGray"; + dirtyGameObject = "0"; canSave = "1"; canSaveDynamicFields = "1"; Enabled = "1"; @@ -99,6 +103,7 @@ new Scene(EditorTemplateLevel) { new Skylight() { Enabled = "1"; ReflectionMode = "Baked Cubemap"; + dirtyGameObject = "0"; position = "1.37009 -5.23561 46.5817"; rotation = "1 0 0 0"; canSave = "1"; diff --git a/Templates/BaseGame/game/tools/materialEditor/main.cs b/Templates/BaseGame/game/tools/materialEditor/main.cs index 7db49b8e7..f0c3d2366 100644 --- a/Templates/BaseGame/game/tools/materialEditor/main.cs +++ b/Templates/BaseGame/game/tools/materialEditor/main.cs @@ -64,7 +64,7 @@ function MaterialEditorPlugin::onWorldEditorStartup( %this ) // Add ourselves to the ToolsToolbar %tooltip = "Material Editor (" @ %accel @ ")"; - EditorGui.addToToolsToolbar( "MaterialEditorPlugin", "MaterialEditorPalette", expandFilename("tools/worldEditor/images/toolbar/matterial-editor"), %tooltip ); + EditorGui.addToToolsToolbar( "MaterialEditorPlugin", "MaterialEditorPalette", expandFilename("tools/worldEditor/images/toolbar/material-editor"), %tooltip ); //connect editor windows GuiWindowCtrl::attach( MaterialEditorPropertiesWindow, MaterialEditorPreviewWindow); diff --git a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPropWindow.ed.gui b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPropWindow.ed.gui index 5e9f9b128..52d581366 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPropWindow.ed.gui +++ b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPropWindow.ed.gui @@ -1353,7 +1353,7 @@ buttonType = "PushButton"; useMouseEvents = "0"; buttonMargin = "0 4"; - iconBitmap = "tools/worldEditor/images/toolbar/matterial-editor_n"; + iconBitmap = "tools/worldEditor/images/toolbar/material-editor_n"; textMargin = "25"; }; new GuiCheckBoxCtrl() { diff --git a/Templates/BaseGame/game/tools/worldEditor/images/toolbar/matterial-editor_d.png b/Templates/BaseGame/game/tools/worldEditor/images/toolbar/material-editor_d.png similarity index 100% rename from Templates/BaseGame/game/tools/worldEditor/images/toolbar/matterial-editor_d.png rename to Templates/BaseGame/game/tools/worldEditor/images/toolbar/material-editor_d.png diff --git a/Templates/BaseGame/game/tools/worldEditor/images/toolbar/matterial-editor_h.png b/Templates/BaseGame/game/tools/worldEditor/images/toolbar/material-editor_h.png similarity index 100% rename from Templates/BaseGame/game/tools/worldEditor/images/toolbar/matterial-editor_h.png rename to Templates/BaseGame/game/tools/worldEditor/images/toolbar/material-editor_h.png diff --git a/Templates/BaseGame/game/tools/worldEditor/images/toolbar/matterial-editor_n.png b/Templates/BaseGame/game/tools/worldEditor/images/toolbar/material-editor_n.png similarity index 100% rename from Templates/BaseGame/game/tools/worldEditor/images/toolbar/matterial-editor_n.png rename to Templates/BaseGame/game/tools/worldEditor/images/toolbar/material-editor_n.png