Merge branch 'ModernEditorLayoutWIP' of https://github.com/Areloch/Torque3D into development

This commit is contained in:
Areloch 2019-05-13 00:28:23 -05:00
commit 3697737498
148 changed files with 3463 additions and 547 deletions

View file

@ -680,10 +680,30 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
rdata.setAccuTex(mAccuTex); rdata.setAccuTex(mAccuTex);
//Various arbitrary shader render bits to add //Various arbitrary shader render bits to add
CustomShaderBindingData strudelCSB; if (mCustomShaderBinds.empty())
strudelCSB.setFloat4(StringTable->insert("overrideColor"), mOverrideColor); {
CustomShaderBindingData minBnds;
minBnds.setFloat3(StringTable->insert("objectBoundsMin"), getWorldBox().minExtents);
mCustomShaderBinds.push_back(minBnds);
rdata.addCustomShaderBinding(strudelCSB); CustomShaderBindingData maxBnds;
maxBnds.setFloat3(StringTable->insert("objectBoundsMax"), getWorldBox().maxExtents);
mCustomShaderBinds.push_back(maxBnds);
CustomShaderBindingData colorMin;
colorMin.setFloat3(StringTable->insert("colorMin"), Point3F(1,0,0));
mCustomShaderBinds.push_back(colorMin);
CustomShaderBindingData colorMax;
colorMax.setFloat3(StringTable->insert("colorMax"), Point3F(0, 1, 0));
mCustomShaderBinds.push_back(colorMax);
}
if (!mCustomShaderBinds.empty())
{
for(U32 i=0; i < mCustomShaderBinds.size(); i++)
rdata.addCustomShaderBinding(mCustomShaderBinds[i]);
}
// If we have submesh culling enabled then prepare // If we have submesh culling enabled then prepare
// the object space frustum to pass to the shape. // the object space frustum to pass to the shape.

View file

@ -203,6 +203,8 @@ protected:
F32 mRenderNormalScalar; F32 mRenderNormalScalar;
S32 mForceDetail; S32 mForceDetail;
Vector<CustomShaderBindingData> mCustomShaderBinds;
public: public:
TSStatic(); TSStatic();

View file

@ -832,6 +832,8 @@ GuiTreeViewCtrl::GuiTreeViewCtrl()
mTexSelected = NULL; mTexSelected = NULL;
mRenderTooltipDelegate.bind( this, &GuiTreeViewCtrl::renderTooltip ); mRenderTooltipDelegate.bind( this, &GuiTreeViewCtrl::renderTooltip );
mDoFilterChildren = true;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1122,7 +1124,7 @@ void GuiTreeViewCtrl::_expandObjectHierarchy( SimGroup* group )
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdate ) void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdate, bool skipFlter )
{ {
if (!item || !mActive || !isVisible() || !mProfile ) if (!item || !mActive || !isVisible() || !mProfile )
return; return;
@ -1145,7 +1147,7 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
// If we have a filter pattern, sync the item's filtering status to it. // If we have a filter pattern, sync the item's filtering status to it.
if( !getFilterText().isEmpty() ) if( !getFilterText().isEmpty() && !skipFlter)
{ {
// Determine the filtering status by looking for the filter // Determine the filtering status by looking for the filter
// text in the item's display text. // text in the item's display text.
@ -1154,7 +1156,11 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
item->getDisplayText( sizeof( displayText ), displayText ); item->getDisplayText( sizeof( displayText ), displayText );
if( !dStristr( displayText, mFilterText ) ) if( !dStristr( displayText, mFilterText ) )
{ {
item->mState.set( Item::Filtered ); //Last check, see if we special-exception this item
if (!mItemFilterExceptionList.contains(item->mId))
item->mState.set(Item::Filtered);
else
item->mState.clear(Item::Filtered);
// If it's not a parent, we're done. Otherwise, there may be children // If it's not a parent, we're done. Otherwise, there may be children
// that are not filtered so we need to process them first. // that are not filtered so we need to process them first.
@ -1163,7 +1169,9 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
return; return;
} }
else else
item->mState.clear( Item::Filtered ); {
item->mState.clear(Item::Filtered);
}
} }
else else
item->mState.clear( Item::Filtered ); item->mState.clear( Item::Filtered );
@ -1217,7 +1225,10 @@ void GuiTreeViewCtrl::_buildItem( Item* item, U32 tabLevel, bool bForceFullUpdat
Item *pChildTemp = child; Item *pChildTemp = child;
child = child->mNext; child = child->mNext;
_buildItem( pChildTemp, tabLevel + 1, bForceFullUpdate ); if (!mItemFilterExceptionList.contains(item->mId) && !mDoFilterChildren && !item->isFiltered())
_buildItem( pChildTemp, tabLevel + 1, bForceFullUpdate, true );
else
_buildItem(pChildTemp, tabLevel + 1, bForceFullUpdate, false);
} }
} }
} }
@ -4775,6 +4786,18 @@ void GuiTreeViewCtrl::setFilterText( const String& text )
mFlags.set( RebuildVisible ); mFlags.set( RebuildVisible );
} }
void GuiTreeViewCtrl::setItemFilterException(U32 item, bool isExempted)
{
if (isExempted)
{
mItemFilterExceptionList.push_back(item);
}
else
{
mItemFilterExceptionList.remove(item);
}
}
//============================================================================= //=============================================================================
// Console Methods. // Console Methods.
//============================================================================= //=============================================================================
@ -5574,6 +5597,25 @@ DefineEngineMethod( GuiTreeViewCtrl, setFilterText, void, ( const char* pattern
object->setFilterText( pattern ); object->setFilterText( pattern );
} }
DefineEngineMethod(GuiTreeViewCtrl, setFilterChildren, void, (bool doFilterChildren), (true),
"Set the pattern by which to filter items in the tree. Only items in the tree whose text "
"matches this pattern are displayed.\n\n"
"@param pattern New pattern based on which visible items in the tree should be filtered. If empty, all items become visible.\n\n"
"@see getFilterText\n"
"@see clearFilterText")
{
object->setFilterChildren(doFilterChildren);
}
DefineEngineMethod(GuiTreeViewCtrl, setItemFilterException, void, (U32 item, bool isExempt), (0, true),
"Set the pattern by which to filter items in the tree. Only items in the tree whose text "
"matches this pattern are displayed.\n\n"
"@param pattern New pattern based on which visible items in the tree should be filtered. If empty, all items become visible.\n\n"
"@see getFilterText\n"
"@see clearFilterText")
{
object->setItemFilterException(item, isExempt);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
DefineEngineMethod( GuiTreeViewCtrl, clearFilterText, void, (),, DefineEngineMethod( GuiTreeViewCtrl, clearFilterText, void, (),,

View file

@ -356,6 +356,11 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
/// Current filter that determines which items in the tree are displayed and which are hidden. /// Current filter that determines which items in the tree are displayed and which are hidden.
String mFilterText; String mFilterText;
/// If true, all items are filtered. If false, then children of items that successfully pass filter are not filtered
bool mDoFilterChildren;
Vector<U32> mItemFilterExceptionList;
/// If true, a trace of actions taken by the control is logged to the console. Can /// If true, a trace of actions taken by the control is logged to the console. Can
/// be turned on with the setDebug() script method. /// be turned on with the setDebug() script method.
bool mDebug; bool mDebug;
@ -431,7 +436,7 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
void _deleteItem(Item* item); void _deleteItem(Item* item);
void _buildItem(Item* item, U32 tabLevel, bool bForceFullUpdate = false); void _buildItem(Item* item, U32 tabLevel, bool bForceFullUpdate = false, bool skipFlter = false);
Item* _findItemByAmbiguousId( S32 itemOrObjectId, bool buildVirtual = true ); Item* _findItemByAmbiguousId( S32 itemOrObjectId, bool buildVirtual = true );
@ -569,6 +574,9 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
/// matches this pattern are displayed. /// matches this pattern are displayed.
void setFilterText( const String& text ); void setFilterText( const String& text );
void setFilterChildren(bool doFilter) { mDoFilterChildren = doFilter; }
void setItemFilterException(U32 item, bool isExempt);
/// Clear the current item filtering pattern. /// Clear the current item filtering pattern.
void clearFilterText() { setFilterText( String::EmptyString ); } void clearFilterText() { setFilterText( String::EmptyString ); }

View file

@ -66,6 +66,7 @@ struct GFXStateBlockDesc;
class GFXVertexFormat; class GFXVertexFormat;
class MatrixSet; class MatrixSet;
class ProcessedMaterial; class ProcessedMaterial;
class GuiTreeViewCtrl;
/// ///
class BaseMatInstance class BaseMatInstance
@ -225,6 +226,7 @@ public:
virtual const GFXVertexFormat* getVertexFormat() const = 0; virtual const GFXVertexFormat* getVertexFormat() const = 0;
virtual void dumpShaderInfo() const = 0; virtual void dumpShaderInfo() const = 0;
virtual void getShaderInfo(GuiTreeViewCtrl* tree, U32 item) const = 0;
/// Fast test for use of normal maps in this material. /// Fast test for use of normal maps in this material.
bool hasNormalMap() const { return mHasNormalMaps; } bool hasNormalMap() const { return mHasNormalMaps; }

View file

@ -77,6 +77,14 @@ public:
} }
Point4F getFloat4() { return mFloat4; } Point4F getFloat4() { return mFloat4; }
void setTexture2D(StringTableEntry shaderConstName, GFXTexHandle f)
{
targetedUniformName = shaderConstName;
texture = f;
type = Texture2D;
}
GFXTexHandle getTexture2D() { return texture; }
StringTableEntry getHandleName() { StringTableEntry getHandleName() {
return targetedUniformName; return targetedUniformName;
} }
@ -86,4 +94,4 @@ public:
} }
}; };
#endif #endif

View file

@ -37,6 +37,8 @@
#include "core/util/safeDelete.h" #include "core/util/safeDelete.h"
#include "ts/tsShape.h" #include "ts/tsShape.h"
#include "gui/controls/guiTreeViewCtrl.h"
class MatInstParameters; class MatInstParameters;
class MatInstanceParameterHandle : public MaterialParameterHandle class MatInstanceParameterHandle : public MaterialParameterHandle
@ -598,3 +600,35 @@ void MatInstance::dumpShaderInfo() const
mProcessedMaterial->dumpMaterialInfo(); mProcessedMaterial->dumpMaterialInfo();
} }
void MatInstance::getShaderInfo(GuiTreeViewCtrl* tree, U32 item) const
{
if (mMaterial == NULL)
{
Con::errorf("Trying to get Material information on an invalid MatInstance");
return;
}
if (mProcessedMaterial == NULL)
{
Con::printf(" [no processed material!]");
return;
}
const FeatureSet features = mProcessedMaterial->getFeatures();
String featureDesc = "";
for (U32 i = 0; i < features.getCount(); i++)
{
const FeatureType& ft = features.getAt(i);
featureDesc += ft.getName();
if(i+1 < features.getCount())
featureDesc += ", ";
}
U32 newItem = tree->insertItem(item, featureDesc);
mProcessedMaterial->getMaterialInfo(tree, newItem);
}

View file

@ -44,7 +44,7 @@ class ShaderFeature;
class MatInstanceParameterHandle; class MatInstanceParameterHandle;
class MatInstParameters; class MatInstParameters;
class ProcessedMaterial; class ProcessedMaterial;
class GuiTreeViewCtrl;
/// ///
class MatInstance : public BaseMatInstance class MatInstance : public BaseMatInstance
@ -87,6 +87,7 @@ public:
virtual const FeatureSet& getFeatures() const; virtual const FeatureSet& getFeatures() const;
virtual const FeatureSet& getRequestedFeatures() const { return mFeatureList; } virtual const FeatureSet& getRequestedFeatures() const { return mFeatureList; }
virtual void dumpShaderInfo() const; virtual void dumpShaderInfo() const;
virtual void getShaderInfo(GuiTreeViewCtrl* tree, U32 item) const;
ProcessedMaterial *getProcessedMaterial() const { return mProcessedMaterial; } ProcessedMaterial *getProcessedMaterial() const { return mProcessedMaterial; }

View file

@ -36,7 +36,7 @@
#include "sfx/sfxTypes.h" #include "sfx/sfxTypes.h"
#include "core/util/safeDelete.h" #include "core/util/safeDelete.h"
#include "T3D/accumulationVolume.h" #include "T3D/accumulationVolume.h"
#include "gui/controls/guiTreeViewCtrl.h"
IMPLEMENT_CONOBJECT( Material ); IMPLEMENT_CONOBJECT( Material );
@ -709,6 +709,12 @@ DefineEngineMethod( Material, dumpInstances, void, (),,
MATMGR->dumpMaterialInstances( object ); MATMGR->dumpMaterialInstances( object );
} }
DefineEngineMethod(Material, getMaterialInstances, void, (GuiTreeViewCtrl* matTree), (nullAsType< GuiTreeViewCtrl*>()),
"Dumps a formatted list of the currently allocated material instances for this material to the console.")
{
MATMGR->getMaterialInstances(object, matTree);
}
DefineEngineMethod( Material, getAnimFlags, const char*, (U32 id), , "" ) DefineEngineMethod( Material, getAnimFlags, const char*, (U32 id), , "" )
{ {
char * animFlags = Con::getReturnBuffer(512); char * animFlags = Con::getReturnBuffer(512);

View file

@ -32,6 +32,7 @@
#include "console/consoleTypes.h" #include "console/consoleTypes.h"
#include "console/engineAPI.h" #include "console/engineAPI.h"
#include "gui/controls/guiTreeViewCtrl.h"
MODULE_BEGIN( MaterialManager ) MODULE_BEGIN( MaterialManager )
@ -397,6 +398,36 @@ void MaterialManager::dumpMaterialInstances( BaseMaterialDefinition *target ) co
Con::printf( "---------------------- Dump complete ----------------------"); Con::printf( "---------------------- Dump complete ----------------------");
} }
void MaterialManager::getMaterialInstances(BaseMaterialDefinition* target, GuiTreeViewCtrl* materailInstanceTree)
{
if (!mMatInstanceList.size())
return;
if (!target)
{
Con::errorf("Can't form a list without a specific MaterialDefinition");
return;
}
if (!materailInstanceTree)
{
Con::errorf("Requires a valid GuiTreeViewCtrl object to populate data into!");
return;
}
U32 matItem = materailInstanceTree->insertItem(0, target->getName());
for (U32 i = 0; i < mMatInstanceList.size(); i++)
{
BaseMatInstance* inst = mMatInstanceList[i];
if (target && inst->getMaterial() != target)
continue;
inst->getShaderInfo(materailInstanceTree, matItem);
}
}
void MaterialManager::_track( MatInstance *matInstance ) void MaterialManager::_track( MatInstance *matInstance )
{ {
mMatInstanceList.push_back( matInstance ); mMatInstanceList.push_back( matInstance );
@ -480,6 +511,16 @@ DefineEngineFunction( dumpMaterialInstances, void, (), ,
MATMGR->dumpMaterialInstances(); MATMGR->dumpMaterialInstances();
} }
DefineEngineFunction(getMaterialInstances, void, (BaseMaterialDefinition* target, GuiTreeViewCtrl* tree), (nullAsType<BaseMaterialDefinition*>(), nullAsType<GuiTreeViewCtrl*>()),
"@brief Dumps a formatted list of currently allocated material instances to the console.\n\n"
"@ingroup Materials")
{
if (target == nullptr || tree == nullptr)
return;
MATMGR->getMaterialInstances(target, tree);
}
DefineEngineFunction( getMapEntry, const char*, (const char * texName), , DefineEngineFunction( getMapEntry, const char*, (const char * texName), ,
"@hide") "@hide")
{ {

View file

@ -37,6 +37,7 @@
class SimSet; class SimSet;
class MatInstance; class MatInstance;
class GuiTreeViewCtrl;
class MaterialManager : public ManagedSingleton<MaterialManager> class MaterialManager : public ManagedSingleton<MaterialManager>
{ {
@ -97,6 +98,8 @@ public:
void dumpMaterialInstances( BaseMaterialDefinition *target = NULL ) const; void dumpMaterialInstances( BaseMaterialDefinition *target = NULL ) const;
void getMaterialInstances(BaseMaterialDefinition* target, GuiTreeViewCtrl* tree);
void updateTime(); void updateTime();
F32 getTotalTime() const { return mAccumTime; } F32 getTotalTime() const { return mAccumTime; }
F32 getDeltaTime() const { return mDt; } F32 getDeltaTime() const { return mDt; }

View file

@ -50,6 +50,7 @@ class SceneRenderState;
class GFXVertexBufferHandleBase; class GFXVertexBufferHandleBase;
class GFXPrimitiveBufferHandle; class GFXPrimitiveBufferHandle;
class MatrixSet; class MatrixSet;
class GuiTreeViewCtrl;
/// This contains the common data needed to render a pass. /// This contains the common data needed to render a pass.
struct RenderPassData struct RenderPassData
@ -226,6 +227,8 @@ public:
/// Dump shader info, or FF texture info? /// Dump shader info, or FF texture info?
virtual void dumpMaterialInfo() { } virtual void dumpMaterialInfo() { }
virtual void getMaterialInfo(GuiTreeViewCtrl* tree, U32 item) {}
/// Returns the source material. /// Returns the source material.
Material* getMaterial() const { return mMaterial; } Material* getMaterial() const { return mMaterial; }

View file

@ -48,7 +48,7 @@
// We need to include customMaterialDefinition for ShaderConstHandles::init // We need to include customMaterialDefinition for ShaderConstHandles::init
#include "materials/customMaterialDefinition.h" #include "materials/customMaterialDefinition.h"
#include "gui/controls/guiTreeViewCtrl.h"
#include "ts/tsShape.h" #include "ts/tsShape.h"
/// ///
@ -1534,3 +1534,26 @@ void ProcessedShaderMaterial::dumpMaterialInfo()
Con::printf( " [%i] %s", i, shader->describeSelf().c_str() ); Con::printf( " [%i] %s", i, shader->describeSelf().c_str() );
} }
} }
void ProcessedShaderMaterial::getMaterialInfo(GuiTreeViewCtrl* tree, U32 item)
{
for (U32 i = 0; i < getNumPasses(); i++)
{
const ShaderRenderPassData* passData = _getRPD(i);
if (passData == NULL)
continue;
char passStr[64];
dSprintf(passStr, 64, "Pass Number: %i", i);
U32 passItem = tree->insertItem(item, passStr);
const GFXShader * shader = passData->shader;
if (shader == NULL)
tree->insertItem(passItem, "[NULL shader]");
else
tree->insertItem(passItem, shader->describeSelf().c_str());
}
}

View file

@ -149,6 +149,7 @@ public:
virtual void setBuffers(GFXVertexBufferHandleBase* vertBuffer, GFXPrimitiveBufferHandle* primBuffer); virtual void setBuffers(GFXVertexBufferHandleBase* vertBuffer, GFXPrimitiveBufferHandle* primBuffer);
virtual bool stepInstance(); virtual bool stepInstance();
virtual void dumpMaterialInfo(); virtual void dumpMaterialInfo();
virtual void getMaterialInfo(GuiTreeViewCtrl* tree, U32 item);
virtual MaterialParameters* allocMaterialParameters(); virtual MaterialParameters* allocMaterialParameters();
virtual MaterialParameters* getDefaultMaterialParameters() { return mDefaultParameters; } virtual MaterialParameters* getDefaultMaterialParameters() { return mDefaultParameters; }
virtual MaterialParameterHandle* getMaterialParameterHandle(const String& name); virtual MaterialParameterHandle* getMaterialParameterHandle(const String& name);

View file

@ -424,12 +424,11 @@ void RenderDeferredMgr::render( SceneRenderState *state )
mat->setNodeTransforms(passRI->mNodeTransforms, passRI->mNodeTransformCount); mat->setNodeTransforms(passRI->mNodeTransforms, passRI->mNodeTransformCount);
} }
//-JR //push along any overriden fields that are instance-specific as well
//push along any overriden fields that are instance-specific as well if (passRI->mCustomShaderData.size() > 0)
if (passRI->mCustomShaderData.size() > 0) {
{ mat->setCustomShaderData(passRI->mCustomShaderData);
mat->setCustomShaderData(passRI->mCustomShaderData); }
}
// If we're instanced then don't render yet. // If we're instanced then don't render yet.
if ( mat->isInstanced() ) if ( mat->isInstanced() )

View file

@ -0,0 +1,350 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "customFeatureGLSL.h"
#include "shaderGen/shaderFeature.h"
#include "shaderGen/shaderOp.h"
#include "shaderGen/featureMgr.h"
//#include "materials/materialFeatureTypes.h"
//#include "gfx/gfxDevice.h"
//#include "materials/processedMaterial.h"
//****************************************************************************
// Accu Texture
//****************************************************************************
void CustomFeatureGLSL::processVert(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData& fd)
{
meta = new MultiLine;
mFeatureData = fd;
mComponentList = componentList;
mOutputState = VertexOutput;
if (mOwner->isMethod("processVertGLSL"))
Con::executef(mOwner, "processVertGLSL");
output = meta;
}
void CustomFeatureGLSL::processPix(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData& fd)
{
meta = new MultiLine;
mFeatureData = fd;
mComponentList = componentList;
mOutputState = PixelOutput;
if (mOwner->isMethod("processPixelGLSL"))
Con::executef(mOwner, "processPixelGLSL");
output = meta;
}
void CustomFeatureGLSL::setTexData(Material::StageData& stageDat,
const MaterialFeatureData& fd,
RenderPassData& passData,
U32& texIndex)
{
if (mOwner->isMethod("setTextureData"))
Con::executef(mOwner, "setTextureData");
}
void CustomFeatureGLSL::addUniform(String name, String type, String defaultValue, U32 arraySize)
{
//do the var/arg fetching here
Var* newVar = (Var*)LangElement::find(name.c_str());
if (!newVar)
{
VarHolder newVarHolder(name, type, "");
newVarHolder.arraySize = arraySize;
newVarHolder.sampler = false;
newVarHolder.uniform = true;
newVarHolder.constSortPos = cspPotentialPrimitive;
mVars.push_back(newVarHolder);
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
}
}
void CustomFeatureGLSL::addSampler(String name, String type, U32 arraySize)
{
//do the var/arg fetching here
Var* newVar = (Var*)LangElement::find(name.c_str());
if (!newVar)
{
//As far as I know, it's always SamplerState regardless of the texture's type
VarHolder newVarHolder(name, "SamplerState", "");
newVarHolder.arraySize = arraySize;
newVarHolder.sampler = true;
newVarHolder.uniform = true;
newVarHolder.constNum = Var::getTexUnitNum(); // used as texture unit num here
mVars.push_back(newVarHolder);
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
}
}
void CustomFeatureGLSL::addTexture(String name, String type, String samplerState, U32 arraySize)
{
//do the var/arg fetching here
Var* newVar = (Var*)LangElement::find(name.c_str());
if (!newVar)
{
//go find our sampler state var
U32 constNum = 0;
Var* samplerStateVar = (Var*)LangElement::find(samplerState.c_str());
if (!samplerStateVar)
{
//check our holder vars
bool foundHolder = false;
for (U32 v = 0; v < mVars.size(); v++)
{
if (mVars[v].varName == samplerState)
{
constNum = mVars[v].constNum;
foundHolder = true;
break;
}
}
if (!foundHolder)
{
Con::errorf("CustomShaderFeature::addTexture: Unable to find texture's sampler state!");
return;
}
}
else
{
constNum = samplerStateVar->constNum;
}
VarHolder newVarHolder(name, type, "");
newVarHolder.arraySize = arraySize;
newVarHolder.texture = true;
newVarHolder.uniform = true;
newVarHolder.constNum = constNum; // used as texture unit num here
mVars.push_back(newVarHolder);
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
}
}
void CustomFeatureGLSL::addVariable(String name, String type, String defaultValue)
{
//do the var/arg fetching here
Var* newVar = (Var*)LangElement::find(name.c_str());
if (!newVar)
{
if (!defaultValue.isEmpty())
{
char declareStatement[128];
dSprintf(declareStatement, 128, " @ = %s;\n", defaultValue.c_str());
newVar = new Var(name, type);
LangElement* newVarDecl = new DecOp(newVar);
meta->addStatement(new GenOp(declareStatement, newVarDecl));
}
else
{
VarHolder newVarHolder(name, type, defaultValue);
mVars.push_back(newVarHolder);
}
}
}
void CustomFeatureGLSL::addConnector(String name, String type, String elementName)
{
// grab connector texcoord register
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(mComponentList[C_CONNECTOR]);
//Get element
S32 element = -1;
if (elementName == String("RT_POSITION"))
element = RT_POSITION;
else if (elementName == String("RT_NORMAL"))
element = RT_NORMAL;
else if (elementName == String("RT_BINORMAL"))
element = RT_BINORMAL;
else if (elementName == String("RT_TANGENT"))
element = RT_TANGENT;
else if (elementName == String("RT_TANGENTW"))
element = RT_TANGENTW;
else if (elementName == String("RT_COLOR"))
element = RT_COLOR;
else if (elementName == String("RT_TEXCOORD"))
element = RT_TEXCOORD;
else if (elementName == String("RT_VPOS"))
element = RT_VPOS;
else if (elementName == String("RT_SVPOSITION"))
element = RT_SVPOSITION;
else if (elementName == String("RT_BLENDINDICES"))
element = RT_BLENDINDICES;
else if (elementName == String("RT_BLENDWEIGHT"))
element = RT_BLENDWEIGHT;
if (element == -1)
{
Con::errorf("CustomShaderFeatureHLSL::addConnector - Invalid element type %s", elementName.c_str());
return;
}
VarHolder newVarHolder(name, type, "");
newVarHolder.elementId = element;
if (mOutputState == VertexOutput)
newVarHolder.structName = "OUT";
else if (mOutputState == PixelOutput)
newVarHolder.structName = "IN";
mVars.push_back(newVarHolder);
}
void CustomFeatureGLSL::addVertTexCoord(String name)
{
VarHolder newVarHolder(name, "", "");
newVarHolder.texCoord = true;
mVars.push_back(newVarHolder);
}
void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValueRef * argv)
{
//do the var/arg fetching here
Vector<Var*> varList;
bool declarationStatement = false;
for (U32 i = 0; i < argc; i++)
{
String varName = argv[i].getStringValue();
Var* newVar = (Var*)LangElement::find(varName.c_str());
if (!newVar)
{
//ok, check our existing var holders, see if we just haven't utilized it yet
for (U32 v = 0; v < mVars.size(); v++)
{
if (mVars[v].varName == varName)
{
if (!mVars[v].texCoord)
{
if (mVars[v].elementId != -1)
{
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(mComponentList[C_CONNECTOR]);
Var* newDeclVar = connectComp->getElement((RegisterType)mVars[v].elementId);
newDeclVar->setName(mVars[v].varName);
newDeclVar->setStructName(mVars[v].structName);
newDeclVar->setType(mVars[v].type);
newVar = newDeclVar;
}
else
{
Var* newDeclVar = new Var(mVars[v].varName, mVars[v].type);
newDeclVar->arraySize = mVars[v].arraySize;
newDeclVar->uniform = mVars[v].uniform;
newDeclVar->sampler = mVars[v].sampler;
newDeclVar->texture = mVars[v].texture;
newDeclVar->constNum = mVars[v].constNum;
newDeclVar->constSortPos = mVars[v].constSortPos;
if (!newDeclVar->uniform)
{
LangElement* newVarDecl = new DecOp(newDeclVar);
newVar = (Var*)newVarDecl;
declarationStatement = true;
}
else
{
newVar = newDeclVar;
}
}
}
else
{
newVar = getVertTexCoord(mVars[v].varName);
}
mVars.erase(v);
break;
}
}
if (!newVar)
{
//couldn't find that variable, bail out
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue());
return;
}
}
varList.push_back(newVar);
}
//not happy about it, but do a trampoline here to pass along the args
switch (varList.size())
{
case 0:
meta->addStatement(new GenOp(format + "\n"));
break;
case 1:
meta->addStatement(new GenOp(format + "\n", varList[0]));
break;
case 2:
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1]));
break;
case 3:
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2]));
break;
case 4:
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3]));
break;
case 5:
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3], varList[4]));
break;
}
}
bool CustomFeatureGLSL::hasFeature(String name)
{
for (U32 i = 0; i < mFeatureData.materialFeatures.getCount(); i++)
{
String featureName = mFeatureData.materialFeatures.getAt(i).getName();
if (name == featureName)
return true;
}
return false;
}

View file

@ -0,0 +1,132 @@
#ifndef _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_
#include "shaderGen/GLSL/shaderFeatureGLSL.h"
#endif
#ifndef _LANG_ELEMENT_H_
#include "shaderGen/langElement.h"
#endif
#ifndef _GFXDEVICE_H_
#include "gfx/gfxDevice.h"
#endif
#ifndef _FEATUREMGR_H_
#include "shaderGen/featureMgr.h"
#endif
#ifndef _MATERIALFEATURETYPES_H_
#include "materials/materialFeatureTypes.h"
#endif
#ifndef _MATERIALFEATUREDATA_H_
#include "materials/materialFeatureData.h"
#endif
#ifndef CUSTOMSHADERFEATURE_H
#include "shaderGen/customShaderFeature.h"
#endif
class CustomShaderFeatureData;
class CustomFeatureGLSL : public ShaderFeatureGLSL
{
friend class CustomShaderFeatureData;
struct VarHolder
{
String varName;
String type;
String defaultValue;
S32 elementId;
bool uniform;
bool sampler;
bool texture;
bool texCoord;
U32 constNum;
U32 arraySize;
String structName;
ConstantSortPosition constSortPos;
VarHolder() :
varName(""),
type(""),
defaultValue(""),
elementId(-1),
uniform(false),
sampler(false),
texture(false),
texCoord(false),
constNum(0),
arraySize(0),
structName(""),
constSortPos(cspUninit)
{
}
VarHolder(String _varName, String _type, String _defaultValue) :
elementId(-1), uniform(false), sampler(false), texture(false), texCoord(false), constNum(0), arraySize(0), structName(""), constSortPos(cspUninit)
{
varName = _varName;
type = _type;
defaultValue = _defaultValue;
}
};
Vector<VarHolder> mVars;
Vector<VarHolder> mConnectorVars;
enum outputState
{
NoOutput,
VertexOutput,
PixelOutput
};
outputState mOutputState;
public:
CustomShaderFeatureData* mOwner;
Vector<ShaderComponent*> mComponentList;
MaterialFeatureData mFeatureData;
protected:
MultiLine* meta;
public:
//****************************************************************************
// Accu Texture
//****************************************************************************
virtual void processVert(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData& fd);
virtual void processPix(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData& fd);
virtual Material::BlendOp getBlendOp() { return Material::LerpAlpha; }
virtual Resources getResources(const MaterialFeatureData& fd)
{
Resources res;
res.numTex = 1;
res.numTexReg = 1;
return res;
}
virtual void setTexData(Material::StageData& stageDat,
const MaterialFeatureData& fd,
RenderPassData& passData,
U32& texIndex);
virtual String getName()
{
return mOwner->getName();
}
bool hasFeature(String name);
void addUniform(String name, String type, String defaultValue, U32 arraySize = 0);
void addVariable(String name, String type, String defaultValue);
void addSampler(String name, String type, U32 arraySize = 0);
void addTexture(String name, String type, String samplerState, U32 arraySize);
void addConnector(String name, String type, String elementName);
void addVertTexCoord(String name);
void writeLine(String format, S32 argc, ConsoleValueRef* argv);
};

View file

@ -31,438 +31,467 @@
//**************************************************************************** //****************************************************************************
// Accu Texture // Accu Texture
//**************************************************************************** //****************************************************************************
void CustomFeatureHLSL::processVert(Vector<ShaderComponent*> &componentList, void CustomFeatureHLSL::processVert(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData &fd) const MaterialFeatureData& fd)
{ {
/*MultiLine *meta = new MultiLine; /*MultiLine *meta = new MultiLine;
getOutTexCoord( "texCoord", getOutTexCoord( "texCoord",
"float2", "float2",
false, false,
meta, meta,
componentList ); componentList );
getOutObjToTangentSpace( componentList, meta, fd ); getOutObjToTangentSpace( componentList, meta, fd );
output = meta;*/ output = meta;*/
meta = new MultiLine; meta = new MultiLine;
mFeatureData = fd; mFeatureData = fd;
mComponentList = componentList; mComponentList = componentList;
mOutputState = VertexOutput; mOutputState = VertexOutput;
if (mOwner->isMethod("processVertHLSL")) if (mOwner->isMethod("processVertHLSL"))
Con::executef(mOwner, "processVertHLSL"); Con::executef(mOwner, "processVertHLSL");
output = meta; output = meta;
} }
void CustomFeatureHLSL::processPix(Vector<ShaderComponent*> &componentList, void CustomFeatureHLSL::processPix(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData &fd) const MaterialFeatureData& fd)
{ {
meta = new MultiLine; meta = new MultiLine;
mFeatureData = fd; mFeatureData = fd;
mComponentList = componentList; mComponentList = componentList;
mOutputState = PixelOutput; mOutputState = PixelOutput;
/*MultiLine *meta = new MultiLine;
output = meta; /*MultiLine *meta = new MultiLine;
// OUT.col output = meta;
Var *color = (Var*) LangElement::find( "col1" );
if (!color)
{
output = new GenOp(" //NULL COLOR!");
return;
}
// accu map // OUT.col
Var *accuMap = new Var; Var *color = (Var*) LangElement::find( "col1" );
accuMap->setType("SamplerState"); if (!color)
{
output = new GenOp(" //NULL COLOR!");
return;
}
accuMap->setName( "accuMap" ); // accu map
accuMap->uniform = true; Var *accuMap = new Var;
accuMap->sampler = true; accuMap->setType("SamplerState");
accuMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
// accuColor var accuMap->setName( "accuMap" );
Var *accuColor = new Var; accuMap->uniform = true;
accuColor->setType( "float4" ); accuMap->sampler = true;
accuColor->setName( "accuColor" ); accuMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
LangElement *colorAccuDecl = new DecOp( accuColor );
// plc (placement) // accuColor var
Var *accuPlc = new Var; Var *accuColor = new Var;
accuPlc->setType( "float4" ); accuColor->setType( "float4" );
accuPlc->setName( "plc" ); accuColor->setName( "accuColor" );
LangElement *plcAccu = new DecOp( accuPlc ); LangElement *colorAccuDecl = new DecOp( accuColor );
// accu constants // plc (placement)
Var *accuScale = (Var*)LangElement::find( "accuScale" ); Var *accuPlc = new Var;
if ( !accuScale ) accuPlc->setType( "float4" );
{ accuPlc->setName( "plc" );
accuScale = new Var; LangElement *plcAccu = new DecOp( accuPlc );
accuScale->setType( "float" );
accuScale->setName( "accuScale" );
accuScale->uniform = true;
accuScale->sampler = false;
accuScale->constSortPos = cspPotentialPrimitive;
}
Var *accuDirection = (Var*)LangElement::find( "accuDirection" );
if ( !accuDirection )
{
accuDirection = new Var;
accuDirection->setType( "float" );
accuDirection->setName( "accuDirection" );
accuDirection->uniform = true;
accuDirection->sampler = false;
accuDirection->constSortPos = cspPotentialPrimitive;
}
Var *accuStrength = (Var*)LangElement::find( "accuStrength" );
if ( !accuStrength )
{
accuStrength = new Var;
accuStrength->setType( "float" );
accuStrength->setName( "accuStrength" );
accuStrength->uniform = true;
accuStrength->sampler = false;
accuStrength->constSortPos = cspPotentialPrimitive;
}
Var *accuCoverage = (Var*)LangElement::find( "accuCoverage" );
if ( !accuCoverage )
{
accuCoverage = new Var;
accuCoverage->setType( "float" );
accuCoverage->setName( "accuCoverage" );
accuCoverage->uniform = true;
accuCoverage->sampler = false;
accuCoverage->constSortPos = cspPotentialPrimitive;
}
Var *accuSpecular = (Var*)LangElement::find( "accuSpecular" );
if ( !accuSpecular )
{
accuSpecular = new Var;
accuSpecular->setType( "float" );
accuSpecular->setName( "accuSpecular" );
accuSpecular->uniform = true;
accuSpecular->sampler = false;
accuSpecular->constSortPos = cspPotentialPrimitive;
}
Var *inTex = getInTexCoord( "texCoord", "float2", componentList ); // accu constants
Var *accuVec = getInTexCoord( "accuVec", "float3", componentList ); Var *accuScale = (Var*)LangElement::find( "accuScale" );
Var *bumpNorm = (Var *)LangElement::find( "bumpSample" ); if ( !accuScale )
if( bumpNorm == NULL ) {
{ accuScale = new Var;
bumpNorm = (Var *)LangElement::find( "bumpNormal" ); accuScale->setType( "float" );
if (!bumpNorm) accuScale->setName( "accuScale" );
return; accuScale->uniform = true;
} accuScale->sampler = false;
accuScale->constSortPos = cspPotentialPrimitive;
}
Var *accuDirection = (Var*)LangElement::find( "accuDirection" );
if ( !accuDirection )
{
accuDirection = new Var;
accuDirection->setType( "float" );
accuDirection->setName( "accuDirection" );
accuDirection->uniform = true;
accuDirection->sampler = false;
accuDirection->constSortPos = cspPotentialPrimitive;
}
Var *accuStrength = (Var*)LangElement::find( "accuStrength" );
if ( !accuStrength )
{
accuStrength = new Var;
accuStrength->setType( "float" );
accuStrength->setName( "accuStrength" );
accuStrength->uniform = true;
accuStrength->sampler = false;
accuStrength->constSortPos = cspPotentialPrimitive;
}
Var *accuCoverage = (Var*)LangElement::find( "accuCoverage" );
if ( !accuCoverage )
{
accuCoverage = new Var;
accuCoverage->setType( "float" );
accuCoverage->setName( "accuCoverage" );
accuCoverage->uniform = true;
accuCoverage->sampler = false;
accuCoverage->constSortPos = cspPotentialPrimitive;
}
Var *accuSpecular = (Var*)LangElement::find( "accuSpecular" );
if ( !accuSpecular )
{
accuSpecular = new Var;
accuSpecular->setType( "float" );
accuSpecular->setName( "accuSpecular" );
accuSpecular->uniform = true;
accuSpecular->sampler = false;
accuSpecular->constSortPos = cspPotentialPrimitive;
}
// get the accu pixel color Var *inTex = getInTexCoord( "texCoord", "float2", componentList );
Var *accuVec = getInTexCoord( "accuVec", "float3", componentList );
Var *bumpNorm = (Var *)LangElement::find( "bumpSample" );
if( bumpNorm == NULL )
{
bumpNorm = (Var *)LangElement::find( "bumpNormal" );
if (!bumpNorm)
return;
}
Var *accuMapTex = new Var; // get the accu pixel color
accuMapTex->setType("Texture2D");
accuMapTex->setName("accuMapTex");
accuMapTex->uniform = true;
accuMapTex->texture = true;
accuMapTex->constNum = accuMap->constNum;
meta->addStatement(new GenOp(" @ = @.Sample(@, @ * @);\r\n", colorAccuDecl, accuMapTex, accuMap, inTex, accuScale));
// scale up normals Var *accuMapTex = new Var;
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) ); accuMapTex->setType("Texture2D");
accuMapTex->setName("accuMapTex");
accuMapTex->uniform = true;
accuMapTex->texture = true;
accuMapTex->constNum = accuMap->constNum;
meta->addStatement(new GenOp(" @ = @.Sample(@, @ * @);\r\n", colorAccuDecl, accuMapTex, accuMap, inTex, accuScale));
// assign direction // scale up normals
meta->addStatement( new GenOp( " @.z *= @*2.0;\r\n", accuVec, accuDirection ) ); meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
// saturate based on strength // assign direction
meta->addStatement( new GenOp( " @ = saturate( dot( @.xyz, @.xyz * pow(@, 5) ) );\r\n", plcAccu, bumpNorm, accuVec, accuStrength ) ); meta->addStatement( new GenOp( " @.z *= @*2.0;\r\n", accuVec, accuDirection ) );
// add coverage // saturate based on strength
meta->addStatement( new GenOp( " @.a += (2 * pow(@/2, 5)) - 0.5;\r\n", accuPlc, accuCoverage ) ); meta->addStatement( new GenOp( " @ = saturate( dot( @.xyz, @.xyz * pow(@, 5) ) );\r\n", plcAccu, bumpNorm, accuVec, accuStrength ) );
// clamp to a sensible value // add coverage
meta->addStatement( new GenOp( " @.a = clamp(@.a, 0, 1);\r\n", accuPlc, accuPlc ) ); meta->addStatement( new GenOp( " @.a += (2 * pow(@/2, 5)) - 0.5;\r\n", accuPlc, accuCoverage ) );
// light // clamp to a sensible value
Var *lightColor = (Var*) LangElement::find( "d_lightcolor" ); meta->addStatement( new GenOp( " @.a = clamp(@.a, 0, 1);\r\n", accuPlc, accuPlc ) );
if(lightColor != NULL)
meta->addStatement( new GenOp( " @ *= float4(@, 1.0);\r\n\r\n", accuColor, lightColor ) );
// lerp with current pixel - use the accu alpha as well // light
meta->addStatement( new GenOp( " @ = lerp( @, @, @.a * @.a);\r\n", color, color, accuColor, accuPlc, accuColor ) ); Var *lightColor = (Var*) LangElement::find( "d_lightcolor" );
if(lightColor != NULL)
meta->addStatement( new GenOp( " @ *= float4(@, 1.0);\r\n\r\n", accuColor, lightColor ) );
// the result should always be opaque // lerp with current pixel - use the accu alpha as well
meta->addStatement( new GenOp( " @.a = 1.0;\r\n", color ) );*/ meta->addStatement( new GenOp( " @ = lerp( @, @, @.a * @.a);\r\n", color, color, accuColor, accuPlc, accuColor ) );
if (mOwner->isMethod("processPixelHLSL"))
Con::executef(mOwner, "processPixelHLSL");
output = meta; // the result should always be opaque
meta->addStatement( new GenOp( " @.a = 1.0;\r\n", color ) );*/
if (mOwner->isMethod("processPixelHLSL"))
Con::executef(mOwner, "processPixelHLSL");
output = meta;
} }
void CustomFeatureHLSL::setTexData(Material::StageData &stageDat, void CustomFeatureHLSL::setTexData(Material::StageData& stageDat,
const MaterialFeatureData &fd, const MaterialFeatureData& fd,
RenderPassData &passData, RenderPassData& passData,
U32 &texIndex) U32& texIndex)
{ {
//GFXTextureObject *tex = stageDat.getTex( MFT_AccuMap ); //GFXTextureObject *tex = stageDat.getTex( MFT_AccuMap );
//if ( tex ) //if ( tex )
//{ //{
//passData.mSamplerNames[ texIndex ] = "AccuMap"; //passData.mSamplerNames[ texIndex ] = "AccuMap";
//passData.mTexType[ texIndex++ ] = Material::AccuMap; //passData.mTexType[ texIndex++ ] = Material::AccuMap;
//} //}
if (mOwner->isMethod("setTextureData")) if (mOwner->isMethod("setTextureData"))
Con::executef(mOwner, "setTextureData"); Con::executef(mOwner, "setTextureData");
} }
void CustomFeatureHLSL::addUniform(String name, String type, String defaultValue, U32 arraySize) void CustomFeatureHLSL::addUniform(String name, String type, String defaultValue, U32 arraySize)
{ {
//do the var/arg fetching here //do the var/arg fetching here
Var *newVar = (Var*)LangElement::find(name.c_str()); Var* newVar = (Var*)LangElement::find(name.c_str());
if (!newVar) if (!newVar)
{ {
VarHolder newVarHolder(name, type, ""); VarHolder newVarHolder(name, type, "");
newVarHolder.arraySize = arraySize; newVarHolder.arraySize = arraySize;
newVarHolder.sampler = false; newVarHolder.sampler = false;
newVarHolder.uniform = true; newVarHolder.uniform = true;
newVarHolder.constSortPos = cspPotentialPrimitive; newVarHolder.constSortPos = cspPotentialPrimitive;
mVars.push_back(newVarHolder); mVars.push_back(newVarHolder);
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str())); mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
} }
} }
void CustomFeatureHLSL::addSampler(String name, String type, U32 arraySize) void CustomFeatureHLSL::addSampler(String name, String type, U32 arraySize)
{ {
//do the var/arg fetching here //do the var/arg fetching here
Var *newVar = (Var*)LangElement::find(name.c_str()); Var* newVar = (Var*)LangElement::find(name.c_str());
if (!newVar) if (!newVar)
{ {
//As far as I know, it's always SamplerState regardless of the texture's type //As far as I know, it's always SamplerState regardless of the texture's type
VarHolder newVarHolder(name, "SamplerState", ""); VarHolder newVarHolder(name, "SamplerState", "");
newVarHolder.arraySize = arraySize; newVarHolder.arraySize = arraySize;
newVarHolder.sampler = true; newVarHolder.sampler = true;
newVarHolder.uniform = true; newVarHolder.uniform = true;
newVarHolder.constNum = Var::getTexUnitNum(); // used as texture unit num here newVarHolder.constNum = Var::getTexUnitNum(); // used as texture unit num here
mVars.push_back(newVarHolder); mVars.push_back(newVarHolder);
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str())); mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
} }
} }
void CustomFeatureHLSL::addTexture(String name, String type, String samplerState, U32 arraySize) void CustomFeatureHLSL::addTexture(String name, String type, String samplerState, U32 arraySize)
{ {
//do the var/arg fetching here //do the var/arg fetching here
Var *newVar = (Var*)LangElement::find(name.c_str()); Var* newVar = (Var*)LangElement::find(name.c_str());
if (!newVar) if (!newVar)
{ {
//go find our sampler state var //go find our sampler state var
U32 constNum = 0; U32 constNum = 0;
Var *samplerStateVar = (Var*)LangElement::find(samplerState.c_str()); Var* samplerStateVar = (Var*)LangElement::find(samplerState.c_str());
if (!samplerStateVar) if (!samplerStateVar)
{ {
//check our holder vars //check our holder vars
bool foundHolder = false; bool foundHolder = false;
for (U32 v = 0; v < mVars.size(); v++) for (U32 v = 0; v < mVars.size(); v++)
{ {
if (mVars[v].varName == samplerState) if (mVars[v].varName == samplerState)
{ {
constNum = mVars[v].constNum; constNum = mVars[v].constNum;
foundHolder = true; foundHolder = true;
break; break;
} }
} }
if (!foundHolder) if (!foundHolder)
{ {
Con::errorf("CustomShaderFeature::addTexture: Unable to find texture's sampler state!"); Con::errorf("CustomShaderFeature::addTexture: Unable to find texture's sampler state!");
return; return;
} }
} }
else else
{ {
constNum = samplerStateVar->constNum; constNum = samplerStateVar->constNum;
} }
VarHolder newVarHolder(name, type, ""); VarHolder newVarHolder(name, type, "");
newVarHolder.arraySize = arraySize; newVarHolder.arraySize = arraySize;
newVarHolder.texture = true; newVarHolder.texture = true;
newVarHolder.uniform = true; newVarHolder.uniform = true;
newVarHolder.constNum = constNum; // used as texture unit num here newVarHolder.constNum = constNum; // used as texture unit num here
mVars.push_back(newVarHolder); mVars.push_back(newVarHolder);
mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str())); mOwner->mAddedShaderConstants.push_back(StringTable->insert(name.c_str()));
} }
} }
void CustomFeatureHLSL::addVariable(String name, String type, String defaultValue) void CustomFeatureHLSL::addVariable(String name, String type, String defaultValue)
{ {
//do the var/arg fetching here //do the var/arg fetching here
Var *newVar = (Var*)LangElement::find(name.c_str()); Var* newVar = (Var*)LangElement::find(name.c_str());
if (!newVar) if (!newVar)
{ {
if (!defaultValue.isEmpty()) if (!defaultValue.isEmpty())
{ {
char declareStatement[128]; char declareStatement[128];
dSprintf(declareStatement, 128, " @ = %s;\n", defaultValue.c_str()); dSprintf(declareStatement, 128, " @ = %s;\n", defaultValue.c_str());
newVar = new Var(name, type); newVar = new Var(name, type);
LangElement *newVarDecl = new DecOp(newVar); LangElement* newVarDecl = new DecOp(newVar);
meta->addStatement(new GenOp(declareStatement, newVarDecl)); meta->addStatement(new GenOp(declareStatement, newVarDecl));
} }
else else
{ {
VarHolder newVarHolder(name, type, defaultValue); VarHolder newVarHolder(name, type, defaultValue);
mVars.push_back(newVarHolder); mVars.push_back(newVarHolder);
} }
} }
} }
void CustomFeatureHLSL::addConnector(String name, String elementName, String type) void CustomFeatureHLSL::addConnector(String name, String type, String elementName)
{ {
// grab connector texcoord register // grab connector texcoord register
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>(mComponentList[C_CONNECTOR]); ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(mComponentList[C_CONNECTOR]);
//Get element //Get element
S32 element = -1; S32 element = -1;
if (elementName == String("RT_POSITION")) if (elementName == String("RT_POSITION"))
element = RT_POSITION; element = RT_POSITION;
else if (elementName == String("RT_NORMAL")) else if (elementName == String("RT_NORMAL"))
element = RT_NORMAL; element = RT_NORMAL;
else if (elementName == String("RT_BINORMAL")) else if (elementName == String("RT_BINORMAL"))
element = RT_BINORMAL; element = RT_BINORMAL;
else if (elementName == String("RT_TANGENT")) else if (elementName == String("RT_TANGENT"))
element = RT_TANGENT; element = RT_TANGENT;
else if (elementName == String("RT_TANGENTW")) else if (elementName == String("RT_TANGENTW"))
element = RT_TANGENTW; element = RT_TANGENTW;
else if (elementName == String("RT_COLOR")) else if (elementName == String("RT_COLOR"))
element = RT_COLOR; element = RT_COLOR;
else if (elementName == String("RT_TEXCOORD")) else if (elementName == String("RT_TEXCOORD"))
element = RT_TEXCOORD; element = RT_TEXCOORD;
else if (elementName == String("RT_VPOS")) else if (elementName == String("RT_VPOS"))
element = RT_VPOS; element = RT_VPOS;
else if (elementName == String("RT_SVPOSITION")) else if (elementName == String("RT_SVPOSITION"))
element = RT_SVPOSITION; element = RT_SVPOSITION;
else if (elementName == String("RT_BLENDINDICES")) else if (elementName == String("RT_BLENDINDICES"))
element = RT_BLENDINDICES; element = RT_BLENDINDICES;
else if (elementName == String("RT_BLENDWEIGHT")) else if (elementName == String("RT_BLENDWEIGHT"))
element = RT_BLENDWEIGHT; element = RT_BLENDWEIGHT;
if (element == -1) if (element == -1)
{ {
Con::errorf("CustomShaderFeatureHLSL::addConnector - Invalid element type %s", elementName.c_str()); Con::errorf("CustomShaderFeatureHLSL::addConnector - Invalid element type %s", elementName.c_str());
return; return;
} }
Var *connector = connectComp->getElement((RegisterType)element); VarHolder newVarHolder(name, type, "");
connector->setName(name);
if (mOutputState == VertexOutput) newVarHolder.elementId = element;
connector->setStructName("OUT");
else if(mOutputState == PixelOutput)
connector->setStructName("IN");
connector->setType(type); if (mOutputState == VertexOutput)
newVarHolder.structName = "OUT";
else if (mOutputState == PixelOutput)
newVarHolder.structName = "IN";
mVars.push_back(newVarHolder);
} }
void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef *argv) void CustomFeatureHLSL::addVertTexCoord(String name)
{ {
//do the var/arg fetching here VarHolder newVarHolder(name, "", "");
Vector<Var*> varList; newVarHolder.texCoord = true;
bool declarationStatement = false;
for (U32 i = 0; i < argc; i++) mVars.push_back(newVarHolder);
{ }
String varName = argv[i].getStringValue();
Var *newVar = (Var*)LangElement::find(varName.c_str());
if (!newVar)
{
//ok, check our existing var holders, see if we just haven't utilized it yet
for (U32 v = 0; v < mVars.size(); v++)
{
if (mVars[v].varName == varName)
{
Var* newDeclVar = new Var(mVars[v].varName, mVars[v].type);
newDeclVar->arraySize = mVars[v].arraySize; void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef * argv)
newDeclVar->uniform = mVars[v].uniform; {
newDeclVar->sampler = mVars[v].sampler; //do the var/arg fetching here
newDeclVar->texture = mVars[v].texture; Vector<Var*> varList;
newDeclVar->constNum = mVars[v].constNum; bool declarationStatement = false;
newDeclVar->constSortPos = mVars[v].constSortPos;
if (!newDeclVar->uniform) for (U32 i = 0; i < argc; i++)
{ {
LangElement *newVarDecl = new DecOp(newDeclVar); String varName = argv[i].getStringValue();
newVar = (Var*)newVarDecl; Var* newVar = (Var*)LangElement::find(varName.c_str());
if (!newVar)
{
//ok, check our existing var holders, see if we just haven't utilized it yet
for (U32 v = 0; v < mVars.size(); v++)
{
if (mVars[v].varName == varName)
{
if (!mVars[v].texCoord)
{
if (mVars[v].elementId != -1)
{
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(mComponentList[C_CONNECTOR]);
Var* newDeclVar = connectComp->getElement((RegisterType)mVars[v].elementId);
newDeclVar->setName(mVars[v].varName);
newDeclVar->setStructName(mVars[v].structName);
newDeclVar->setType(mVars[v].type);
declarationStatement = true; newVar = newDeclVar;
} }
else else
{ {
newVar = newDeclVar; Var* newDeclVar = new Var(mVars[v].varName, mVars[v].type);
}
mVars.erase(v); newDeclVar->arraySize = mVars[v].arraySize;
break; newDeclVar->uniform = mVars[v].uniform;
} newDeclVar->sampler = mVars[v].sampler;
} newDeclVar->texture = mVars[v].texture;
newDeclVar->constNum = mVars[v].constNum;
newDeclVar->constSortPos = mVars[v].constSortPos;
if (!newVar) if (!newDeclVar->uniform)
{ {
//couldn't find that variable, bail out LangElement* newVarDecl = new DecOp(newDeclVar);
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue()); newVar = (Var*)newVarDecl;
return;
}
}
varList.push_back(newVar); declarationStatement = true;
} }
else
{
newVar = newDeclVar;
}
}
}
else
{
newVar = getVertTexCoord(mVars[v].varName);
}
//not happy about it, but do a trampoline here to pass along the args mVars.erase(v);
break;
}
}
switch (varList.size()) if (!newVar)
{ {
case 0: //couldn't find that variable, bail out
meta->addStatement(new GenOp(format + "\n")); Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue());
break; return;
case 1: }
meta->addStatement(new GenOp(format + "\n", varList[0])); }
break;
case 2: varList.push_back(newVar);
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1])); }
break;
case 3: //not happy about it, but do a trampoline here to pass along the args
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2]));
break; switch (varList.size())
case 4: {
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3])); case 0:
break; meta->addStatement(new GenOp(format + "\n"));
case 5: break;
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3], varList[4])); case 1:
break; meta->addStatement(new GenOp(format + "\n", varList[0]));
} break;
case 2:
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1]));
break;
case 3:
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2]));
break;
case 4:
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3]));
break;
case 5:
meta->addStatement(new GenOp(format + "\n", varList[0], varList[1], varList[2], varList[3], varList[4]));
break;
}
} }
bool CustomFeatureHLSL::hasFeature(String name) bool CustomFeatureHLSL::hasFeature(String name)
{ {
for (U32 i = 0; i < mFeatureData.materialFeatures.getCount(); i++) for (U32 i = 0; i < mFeatureData.materialFeatures.getCount(); i++)
{ {
String featureName = mFeatureData.materialFeatures.getAt(i).getName(); String featureName = mFeatureData.materialFeatures.getAt(i).getName();
if (name == featureName) if (name == featureName)
return true; return true;
} }
return false; return false;
} }

View file

@ -25,99 +25,108 @@ class CustomShaderFeatureData;
class CustomFeatureHLSL : public ShaderFeatureHLSL class CustomFeatureHLSL : public ShaderFeatureHLSL
{ {
friend class CustomShaderFeatureData; friend class CustomShaderFeatureData;
struct VarHolder struct VarHolder
{ {
String varName; String varName;
String defaultValue; String type;
String type; String defaultValue;
bool uniform; S32 elementId;
bool sampler; bool uniform;
bool texture; bool sampler;
U32 constNum; bool texture;
ConstantSortPosition constSortPos; bool texCoord;
U32 arraySize; U32 constNum;
U32 arraySize;
String structName;
ConstantSortPosition constSortPos;
VarHolder() : VarHolder() :
varName(""), varName(""),
type(""), type(""),
defaultValue(""), defaultValue(""),
uniform(false), elementId(-1),
sampler(false), uniform(false),
texture(false), sampler(false),
constNum(0), texture(false),
arraySize(0), texCoord(false),
constSortPos(cspUninit) constNum(0),
{ arraySize(0),
} structName(""),
constSortPos(cspUninit)
{
}
VarHolder(String _varName,String _type, String _defaultValue) : VarHolder(String _varName, String _type, String _defaultValue) :
uniform(false), sampler(false), texture(false), constNum(0), arraySize(0), constSortPos(cspUninit) elementId(-1), uniform(false), sampler(false), texture(false), texCoord(false), constNum(0), arraySize(0), structName(""), constSortPos(cspUninit)
{ {
varName = _varName; varName = _varName;
type = _type; type = _type;
defaultValue = _defaultValue; defaultValue = _defaultValue;
} }
}; };
Vector<VarHolder> mVars; Vector<VarHolder> mVars;
enum outputState Vector<VarHolder> mConnectorVars;
{
NoOutput,
VertexOutput,
PixelOutput
};
outputState mOutputState; enum outputState
{
NoOutput,
VertexOutput,
PixelOutput
};
outputState mOutputState;
public: public:
CustomShaderFeatureData* mOwner; CustomShaderFeatureData* mOwner;
Vector<ShaderComponent*> mComponentList; Vector<ShaderComponent*> mComponentList;
MaterialFeatureData mFeatureData; MaterialFeatureData mFeatureData;
protected: protected:
MultiLine *meta; MultiLine* meta;
public: public:
//**************************************************************************** //****************************************************************************
// Accu Texture // Accu Texture
//**************************************************************************** //****************************************************************************
virtual void processVert(Vector<ShaderComponent*> &componentList, virtual void processVert(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData &fd); const MaterialFeatureData& fd);
virtual void processPix(Vector<ShaderComponent*> &componentList, virtual void processPix(Vector<ShaderComponent*>& componentList,
const MaterialFeatureData &fd); const MaterialFeatureData& fd);
virtual Material::BlendOp getBlendOp() { return Material::LerpAlpha; } virtual Material::BlendOp getBlendOp() { return Material::LerpAlpha; }
virtual Resources getResources(const MaterialFeatureData &fd) virtual Resources getResources(const MaterialFeatureData& fd)
{ {
Resources res; Resources res;
res.numTex = 1; res.numTex = 1;
res.numTexReg = 1; res.numTexReg = 1;
return res; return res;
} }
virtual void setTexData(Material::StageData &stageDat, virtual void setTexData(Material::StageData& stageDat,
const MaterialFeatureData &fd, const MaterialFeatureData& fd,
RenderPassData &passData, RenderPassData& passData,
U32 &texIndex); U32& texIndex);
virtual String getName() virtual String getName()
{ {
return mOwner->getName(); return mOwner->getName();
} }
bool hasFeature(String name); bool hasFeature(String name);
void addUniform(String name, String type, String defaultValue, U32 arraySize = 0); void addUniform(String name, String type, String defaultValue, U32 arraySize = 0);
void addVariable(String name, String type, String defaultValue); void addVariable(String name, String type, String defaultValue);
void addSampler(String name, String type, U32 arraySize = 0); void addSampler(String name, String type, U32 arraySize = 0);
void addTexture(String name, String type, String samplerState, U32 arraySize); void addTexture(String name, String type, String samplerState, U32 arraySize);
void addConnector(String name, String elementName, String type); void addConnector(String name, String type, String elementName);
void writeLine(String format, S32 argc, ConsoleValueRef *argv); void addVertTexCoord(String name);
}; void writeLine(String format, S32 argc, ConsoleValueRef* argv);
};

View file

@ -22,6 +22,7 @@
#include "shadergen/CustomShaderFeature.h" #include "shadergen/CustomShaderFeature.h"
#include "shaderGen/HLSL/customFeatureHLSL.h" #include "shaderGen/HLSL/customFeatureHLSL.h"
#include "shaderGen/GLSL/customFeatureGLSL.h"
#include "math/mathIO.h" #include "math/mathIO.h"
#include "scene/sceneRenderState.h" #include "scene/sceneRenderState.h"
@ -35,17 +36,17 @@
IMPLEMENT_CONOBJECT(CustomShaderFeatureData); IMPLEMENT_CONOBJECT(CustomShaderFeatureData);
ConsoleDocClass(CustomShaderFeatureData, ConsoleDocClass(CustomShaderFeatureData,
"@brief An example scene object which renders using a callback.\n\n" "@brief An example scene object which renders using a callback.\n\n"
"This class implements a basic SceneObject that can exist in the world at a " "This class implements a basic SceneObject that can exist in the world at a "
"3D position and render itself. Note that CustomShaderFeatureData handles its own " "3D position and render itself. Note that CustomShaderFeatureData handles its own "
"rendering by submitting itself as an ObjectRenderInst (see " "rendering by submitting itself as an ObjectRenderInst (see "
"renderInstance\renderPassmanager.h) along with a delegate for its render() " "renderInstance\renderPassmanager.h) along with a delegate for its render() "
"function. However, the preffered rendering method in the engine is to submit " "function. However, the preffered rendering method in the engine is to submit "
"a MeshRenderInst along with a Material, vertex buffer, primitive buffer, and " "a MeshRenderInst along with a Material, vertex buffer, primitive buffer, and "
"transform and allow the RenderMeshMgr handle the actual rendering. You can " "transform and allow the RenderMeshMgr handle the actual rendering. You can "
"see this implemented in RenderMeshExample.\n\n" "see this implemented in RenderMeshExample.\n\n"
"See the C++ code for implementation details.\n\n" "See the C++ code for implementation details.\n\n"
"@ingroup Examples\n"); "@ingroup Examples\n");
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Object setup and teardown // Object setup and teardown
@ -63,128 +64,138 @@ CustomShaderFeatureData::~CustomShaderFeatureData()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CustomShaderFeatureData::initPersistFields() void CustomShaderFeatureData::initPersistFields()
{ {
// SceneObject already handles exposing the transform // SceneObject already handles exposing the transform
Parent::initPersistFields(); Parent::initPersistFields();
} }
bool CustomShaderFeatureData::onAdd() bool CustomShaderFeatureData::onAdd()
{ {
if (!Parent::onAdd()) if (!Parent::onAdd())
return false; return false;
mFeatureHLSL = new CustomFeatureHLSL(); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
mFeatureHLSL->mOwner = this; {
mFeatureHLSL = new CustomFeatureHLSL();
mFeatureHLSL->mOwner = this;
}
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
{
mFeatureGLSL = new CustomFeatureGLSL();
mFeatureGLSL->mOwner = this;
}
return true; return true;
} }
void CustomShaderFeatureData::onRemove() void CustomShaderFeatureData::onRemove()
{ {
Parent::onRemove(); Parent::onRemove();
} }
//Shadergen setup functions //Shadergen setup functions
void CustomShaderFeatureData::addVariable(String name, String type, String defaultValue) void CustomShaderFeatureData::addVariable(String name, String type, String defaultValue)
{ {
mFeatureHLSL->addVariable(name, type, defaultValue); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
mFeatureHLSL->addVariable(name, type, defaultValue);
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
mFeatureGLSL->addVariable(name, type, defaultValue);
} }
void CustomShaderFeatureData::addUniform(String name, String type, String defaultValue, U32 arraySize) void CustomShaderFeatureData::addUniform(String name, String type, String defaultValue, U32 arraySize)
{ {
mFeatureHLSL->addUniform(name, type, defaultValue, arraySize); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
mFeatureHLSL->addUniform(name, type, defaultValue, arraySize);
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
mFeatureGLSL->addUniform(name, type, defaultValue, arraySize);
} }
void CustomShaderFeatureData::addSampler(String name, String type, U32 arraySize) void CustomShaderFeatureData::addSampler(String name, String type, U32 arraySize)
{ {
mFeatureHLSL->addSampler(name, type, arraySize); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
mFeatureHLSL->addSampler(name, type, arraySize);
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
mFeatureGLSL->addSampler(name, type, arraySize);
} }
void CustomShaderFeatureData::addTexture(String name, String type, String samplerState, U32 arraySize) void CustomShaderFeatureData::addTexture(String name, String type, String samplerState, U32 arraySize)
{ {
mFeatureHLSL->addTexture(name, type, samplerState, arraySize); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
mFeatureHLSL->addTexture(name, type, samplerState, arraySize);
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
mFeatureGLSL->addTexture(name, type, samplerState, arraySize);
} }
void CustomShaderFeatureData::addConnector(String name, String elementName, String type) void CustomShaderFeatureData::addConnector(String name, String type, String elementName)
{ {
mFeatureHLSL->addConnector(name, elementName, type); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
mFeatureHLSL->addConnector(name, type, elementName);
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
mFeatureGLSL->addConnector(name, type, elementName);
}
void CustomShaderFeatureData::addVertTexCoord(String name)
{
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
mFeatureHLSL->addVertTexCoord(name);
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
mFeatureGLSL->addVertTexCoord(name);
} }
bool CustomShaderFeatureData::hasFeature(String name) bool CustomShaderFeatureData::hasFeature(String name)
{ {
return mFeatureHLSL->hasFeature(name); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
return mFeatureHLSL->hasFeature(name);
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
return mFeatureGLSL->hasFeature(name);
} }
void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValueRef *argv) void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValueRef* argv)
{ {
/*mOnObject = onObject; if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
mArgc = argc; mFeatureHLSL->writeLine(format, argc, argv);
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
mArgv = new ConsoleValueRef[argc]; mFeatureGLSL->writeLine(format, argc, argv);
for (int i = 0; i<argc; i++)
{
mArgv[i].value = new ConsoleValue();
mArgv[i].value->type = ConsoleValue::TypeInternalString;
mArgv[i].value->init();
if (argv)
{
mArgv[i].value->setStringValue((const char*)argv[i]);
}
}*/
mFeatureHLSL->writeLine(format, argc, argv);
} }
/*//Actual shader processing DefineEngineMethod(CustomShaderFeatureData, addVariable, void, (String name, String type, String defaultValue), ("", "", ""), "")
void CustomShaderFeatureData::processVert(Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd)
{ {
mFeatureHLSL.processVert(componentList, fd); object->addVariable(name, type, defaultValue);
}
void CustomShaderFeatureData::processPix(Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd)
{
mFeatureHLSL.processPix(componentList, fd);
}
void CustomShaderFeatureData::setTexData(Material::StageData &stageDat,
const MaterialFeatureData &fd,
RenderPassData &passData,
U32 &texIndex)
{
mFeatureHLSL.setTexData(stageDat, fd, passData, texIndex);
}*/
DefineEngineMethod(CustomShaderFeatureData, addVariable, void, (String name, String type, String defaultValue), ("", "", ""), "")
{
object->addVariable(name, type, defaultValue);
} }
DefineEngineMethod(CustomShaderFeatureData, addUniform, void, (String name, String type, String defaultValue, U32 arraySize), ("", "", "", 0), "") DefineEngineMethod(CustomShaderFeatureData, addUniform, void, (String name, String type, String defaultValue, U32 arraySize), ("", "", "", 0), "")
{ {
object->addUniform(name, type, defaultValue, arraySize); object->addUniform(name, type, defaultValue, arraySize);
} }
DefineEngineMethod(CustomShaderFeatureData, addSampler, void, (String name, U32 arraySize), ("", 0), "") DefineEngineMethod(CustomShaderFeatureData, addSampler, void, (String name, U32 arraySize), ("", 0), "")
{ {
object->addSampler(name, "", arraySize); object->addSampler(name, "", arraySize);
} }
DefineEngineMethod(CustomShaderFeatureData, addTexture, void, (String name, String type, String samplerState, U32 arraySize), ("", "", 0), "") DefineEngineMethod(CustomShaderFeatureData, addTexture, void, (String name, String type, String samplerState, U32 arraySize), ("", "", 0), "")
{ {
object->addTexture(name, type, samplerState, arraySize); object->addTexture(name, type, samplerState, arraySize);
} }
ConsoleMethod(CustomShaderFeatureData, writeLine, void, 3, 0, "( string format, string args... ) Dynamically call a method on an object.\n" DefineEngineMethod(CustomShaderFeatureData, addConnector, void, (String name, String type, String elementName), ("", "", ""), "")
"@param method Name of method to call.\n"
"@param args Zero or more arguments for the method.\n"
"@return The result of the method call.")
{ {
object->writeLine(argv[2], argc - 3, argv + 3); object->addConnector(name, type, elementName);
}
DefineEngineMethod(CustomShaderFeatureData, addVertTexCoord, void, (String name), (""), "")
{
object->addVertTexCoord(name);
}
DefineEngineStringlyVariadicMethod(CustomShaderFeatureData, writeLine, void, 3, 0, "( string format, string args... ) Dynamically call a method on an object.\n"
"@param method Name of method to call.\n"
"@param args Zero or more arguments for the method.\n"
"@return The result of the method call.")
{
object->writeLine(argv[2], argc - 3, argv + 3);
} }
DefineEngineMethod(CustomShaderFeatureData, hasFeature, bool, (String name), (""), "") DefineEngineMethod(CustomShaderFeatureData, hasFeature, bool, (String name), (""), "")
{ {
return object->hasFeature(name); return object->hasFeature(name);
} }

View file

@ -28,6 +28,7 @@
#endif #endif
class CustomFeatureHLSL; class CustomFeatureHLSL;
class CustomFeatureGLSL;
class CustomShaderFeatureData : public SimObject class CustomShaderFeatureData : public SimObject
{ {
@ -35,6 +36,7 @@ class CustomShaderFeatureData : public SimObject
public: public:
CustomFeatureHLSL* mFeatureHLSL; CustomFeatureHLSL* mFeatureHLSL;
CustomFeatureGLSL* mFeatureGLSL;
Vector<StringTableEntry> mAddedShaderConstants; Vector<StringTableEntry> mAddedShaderConstants;
@ -64,8 +66,8 @@ public:
void addUniform(String name, String type, String defaultValue, U32 arraySize); void addUniform(String name, String type, String defaultValue, U32 arraySize);
void addSampler(String name, String type, U32 arraySize); void addSampler(String name, String type, U32 arraySize);
void addTexture(String name, String type, String samplerState, U32 arraySize); void addTexture(String name, String type, String samplerState, U32 arraySize);
void addConnector(String name, String elementName, String type); void addConnector(String name, String type, String elementName);
void addVertTexCoord(String name);
bool hasFeature(String name); bool hasFeature(String name);
void writeLine(String format, S32 argc, ConsoleValueRef *argv); void writeLine(String format, S32 argc, ConsoleValueRef *argv);
@ -81,4 +83,4 @@ public:
U32 &texIndex);*/ U32 &texIndex);*/
}; };
#endif #endif

View file

@ -32,6 +32,7 @@
#include "core/module.h" #include "core/module.h"
#include "shaderGen/HLSL/customFeatureHLSL.h" #include "shaderGen/HLSL/customFeatureHLSL.h"
#include "shaderGen/GLSL/customFeatureGLSL.h"
MODULE_BEGIN( ShaderGen ) MODULE_BEGIN( ShaderGen )
@ -290,23 +291,32 @@ void ShaderGen::_processVertFeatures( Vector<GFXShaderMacro> &macros, bool macro
{ {
for (U32 i = 0; i < mCustomFeaturesData.size(); ++i) for (U32 i = 0; i < mCustomFeaturesData.size(); ++i)
{ {
mCustomFeaturesData[i]->mFeatureHLSL->processVert(mComponents, mFeatureData); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
{
mCustomFeaturesData[i]->mFeatureHLSL->processVert(mComponents, mFeatureData);
String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str()); String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str());
mOutput->addStatement(new GenOp(line)); mOutput->addStatement(new GenOp(line));
if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput()) if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput())
mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput()); mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput());
//ShaderFeatureHLSL feature = mCustomFeaturesData[i]->mHLSLFeature;
//feature->setProcessIndex(index);
/*feature->processPixMacros(macros, mFeatureData); mCustomFeaturesData[i]->mFeatureHLSL->reset();
mOutput->addStatement(new GenOp(" \r\n"));
}
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
{
mCustomFeaturesData[i]->mFeatureGLSL->processVert(mComponents, mFeatureData);
feature->setInstancingFormat(&mInstancingFormat); String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureGLSL->getName().c_str());
feature->processPix(mComponents, mFeatureData);*/ mOutput->addStatement(new GenOp(line));
mCustomFeaturesData[i]->mFeatureHLSL->reset(); if (mCustomFeaturesData[i]->mFeatureGLSL->getOutput())
mOutput->addStatement(new GenOp(" \r\n")); mOutput->addStatement(mCustomFeaturesData[i]->mFeatureGLSL->getOutput());
mCustomFeaturesData[i]->mFeatureGLSL->reset();
mOutput->addStatement(new GenOp(" \r\n"));
}
} }
} }
@ -355,23 +365,32 @@ void ShaderGen::_processPixFeatures( Vector<GFXShaderMacro> &macros, bool macros
{ {
for (U32 i = 0; i < mCustomFeaturesData.size(); ++i) for (U32 i = 0; i < mCustomFeaturesData.size(); ++i)
{ {
mCustomFeaturesData[i]->mFeatureHLSL->processPix(mComponents, mFeatureData); if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
{
mCustomFeaturesData[i]->mFeatureHLSL->processPix(mComponents, mFeatureData);
String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str()); String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str());
mOutput->addStatement(new GenOp(line)); mOutput->addStatement(new GenOp(line));
if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput()) if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput())
mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput()); mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput());
//ShaderFeatureHLSL feature = mCustomFeaturesData[i]->mHLSLFeature;
//feature->setProcessIndex(index);
/*feature->processPixMacros(macros, mFeatureData); mCustomFeaturesData[i]->mFeatureHLSL->reset();
mOutput->addStatement(new GenOp(" \r\n"));
}
else if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
{
mCustomFeaturesData[i]->mFeatureGLSL->processPix(mComponents, mFeatureData);
feature->setInstancingFormat(&mInstancingFormat); String line = String::ToString(" // %s\r\n", mCustomFeaturesData[i]->mFeatureGLSL->getName().c_str());
feature->processPix(mComponents, mFeatureData);*/ mOutput->addStatement(new GenOp(line));
mCustomFeaturesData[i]->mFeatureHLSL->reset(); if (mCustomFeaturesData[i]->mFeatureGLSL->getOutput())
mOutput->addStatement(new GenOp(" \r\n")); mOutput->addStatement(mCustomFeaturesData[i]->mFeatureGLSL->getOutput());
mCustomFeaturesData[i]->mFeatureGLSL->reset();
mOutput->addStatement(new GenOp(" \r\n"));
}
} }
} }

View file

@ -0,0 +1,207 @@
function MainEditor::onCreate( %this )
{
echo("\n--------- Initializing MainEditor ---------");
//exec("tools/gui/profiles.ed.cs");
//exec("./scripts/GuiProfiles.cs");
exec("./guis/MainEditorWindow.gui");
//exec("./scripts/newEditorGui.cs");
$UsePanelLayout = false;
$AssetBrowserPanelState = true;
$AssetBrowserPanelSplit = 0;
$InspectorPanelState = true;
$InspectorPanelSplit = 0;
$ToolsPanelState = true;
$ToolsPanelSplit = 0;
}
function MainEditor::onDestroy( %this )
{
}
function NewEditorGui::addNewEditorTab(%this, %editorName)
{
%editorTab = new GuiTabPageCtrl()
{
Profile = "ToolsGuiEditorTabPage";
position = "0 0";
extent = Editor_MainViewTabBook.extent;
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
horizSizing = "width";
vertSizing = "height";
text = %editorName;
};
Editor_MainViewTabBook.add(%editorTab);
return %editorTab;
}
function togglePanelLayout()
{
$UsePanelLayout = !$UsePanelLayout;
if($UsePanelLayout)
{
EditorGui.add(NewEditorGui);
//Nudge us down so we show the toolbar
NewEditorGui.resize(0, EditorGuiToolbar.extent.y, EditorGui.extent.x, EditorGui.extent.y - EditorGuiToolbar.extent.y - EditorGuiStatusBar.extent.y);
%mainEditViewTitle = "Level - " @ getScene(0).getName();
%mainEditViewCtrl = NewEditorGui.addNewEditorTab(%mainEditViewTitle);
%mainEditViewCtrl.add(EWorldEditor);
EWorldEditor.position = "0 24";
EWorldEditor.extent = %mainEditViewCtrl.extent.x SPC %mainEditViewCtrl.extent.y - 24;
Editor_AssetBrowserPanel.add(AssetBrowser);
AssetBrowser.resize(0,0, Editor_AssetBrowserPanel.extent.x, Editor_AssetBrowserPanel.extent.y);
AssetBrowser.horizSizing = "width";
AssetBrowser.vertSizing = "height";
AssetBrowserWindow.resize(0,0, AssetBrowser.extent.x, AssetBrowser.extent.y);
AssetBrowserWindow.horizSizing = "width";
AssetBrowserWindow.vertSizing = "height";
AssetBrowserWindow.canClose = false;
AssetBrowserWindow.canCollapse = false;
AssetBrowserWindow.canMaximize = false;
AssetBrowserWindow.canMinimize = false;
AssetBrowserWindow.canMove = false;
AssetBrowserWindow.resizeWidth = false;
AssetBrowserWindow.resizeHeight = false;
//Prep it
AssetBrowser.loadFilters();
Editor_SceneTreePanel.add(EWTreeWindow);
EWTreeWindow.resize(0,0, Editor_SceneTreePanel.extent.x, Editor_SceneTreePanel.extent.y);
EWTreeWindow.horizSizing = "width";
EWTreeWindow.vertSizing = "height";
EWTreeWindow.canClose = false;
EWTreeWindow.canCollapse = false;
EWTreeWindow.canMaximize = false;
EWTreeWindow.canMinimize = false;
EWTreeWindow.canMove = false;
EWTreeWindow.resizeWidth = false;
EWTreeWindow.resizeHeight = false;
if(!isObject(Scenes))
{
$scenesRootGroup = new SimGroup(Scenes);
$scenesRootGroup.add(getScene(0));
}
EditorTree.open($scenesRootGroup,true);
Editor_PropertiesPanel.add(EWInspectorWindow);
EWInspectorWindow.resize(0,0, Editor_PropertiesPanel.extent.x, Editor_PropertiesPanel.extent.y);
EWInspectorWindow.horizSizing = "width";
EWInspectorWindow.vertSizing = "height";
EWInspectorWindow.canClose = false;
EWInspectorWindow.canCollapse = false;
EWInspectorWindow.canMaximize = false;
EWInspectorWindow.canMinimize = false;
EWInspectorWindow.canMove = false;
EWInspectorWindow.resizeWidth = false;
EWInspectorWindow.resizeHeight = false;
}
else
{
EditorGui.remove(NewEditorGui);
EditorGui.add(EWorldEditor);
EditorGui.add(AssetBrowser);
AssetBrowserWindow.canClose = false;
AssetBrowserWindow.canCollapse = false;
AssetBrowserWindow.canMaximize = false;
AssetBrowserWindow.canMinimize = false;
AssetBrowserWindow.canMove = false;
EditorGui.add(EWTreeWindow);
EditorGui.add(EWInspectorWindow);
}
}
function Editor_AssetBrowserButton::onClick(%this)
{
$AssetBrowserPanelState = !$AssetBrowserPanelState;
//If we're collapsing
if(!$AssetBrowserPanelState)
{
//Store the original
$AssetBrowserPanelSplit = Editor_MainViewSplit.splitPoint.y;
//collapse it
Editor_MainViewSplit.setSplitPoint(Editor_MainViewSplit.splitPoint.x SPC Editor_MainViewSplit.extent.y - Editor_MainViewSplit.splitterSize);
}
else
{
//restore the original
Editor_MainViewSplit.setSplitPoint(Editor_MainViewSplit.splitPoint.x SPC $AssetBrowserPanelSplit);
}
}
function Editor_InspectorSidebarButton::onClick(%this)
{
$InspectorPanelState = !$InspectorPanelState;
//If we're collapsing
if(!$InspectorPanelState)
{
//Store the original
$InspectorPanelSplit = NewEditorGuiLayout.splitPoint.x;
//collapse it
NewEditorGuiLayout.setSplitPoint(NewEditorGui.extent.x - NewEditorGuiLayout.splitterSize SPC NewEditorGuiLayout.splitPoint.y);
}
else
{
//restore the original
NewEditorGuiLayout.setSplitPoint($InspectorPanelSplit SPC NewEditorGuiLayout.splitPoint.y);
}
}
function Editor_ToolsSidebarButton::onClick(%this)
{
$ToolsPanelState = !$ToolsPanelState;
//If we're collapsing
if(!$ToolsPanelState)
{
//Store the original
$ToolsPanelSplit = Editor_ToolsMainSplit.splitPoint.x;
//collapse it
Editor_ToolsMainSplit.setSplitPoint(Editor_ToolsMainSplit.splitterSize SPC Editor_ToolsMainSplit.splitPoint.y);
}
else
{
//restore the original
Editor_ToolsMainSplit.setSplitPoint($ToolsPanelSplit SPC Editor_ToolsMainSplit.splitPoint.y);
}
}
function Editor_VisibilityOptionsButton::onClick(%this)
{
if ( EVisibility.visible )
{
EVisibility.setVisible(false);
//visibilityToggleBtn.setStateOn(0);
}
else
{
EVisibility.setVisible(true);
//visibilityToggleBtn.setStateOn(1);
EVisibility.setExtent("200 540");
}
}

View file

@ -0,0 +1,9 @@
<ModuleDefinition
ModuleId="MainEditor"
VersionId="1"
Description="Tool that can be used to view/edit an object."
ScriptFile="MainEditor.cs"
CreateFunction="onCreate"
DestroyFunction="onDestroy"
Group="Tools">
</ModuleDefinition>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1,485 @@
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiContainer(NewEditorGui) {
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1920 1080";
minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "ToolsGuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1";
enabled = "1";
new GuiSplitContainer(NewEditorGuiLayout) {
orientation = "Vertical";
splitterSize = "2";
splitPoint = "1661 100";
fixedPanel = "None";
useMinExtent="0";
fixedSize = "260";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1921 1081";
minExtent = "64 64";
horizSizing = "width";
vertSizing = "height";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiPanel() {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1659 1081";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "Panel1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiSplitContainer(Editor_ToolsMainSplit) {
orientation = "Vertical";
splitterSize = "2";
splitPoint = "230 100";
fixedPanel = "None";
useMinExtent="0";
fixedSize = "1429";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1659 1081";
minExtent = "64 64";
horizSizing = "width";
vertSizing = "height";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiPanel(Editor_ToolSidebarPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "228 1081";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "Panel1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiWindowCtrl(Editor_ToolsSidebarWindow) {
text = "Tool Settings";
resizeWidth = "0";
resizeHeight = "0";
canMove = "0";
canClose = "0";
canMinimize = "0";
canMaximize = "0";
canCollapse = "0";
edgeSnap = "1";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "228 1081";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "height";
profile = "GuiWindowProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiPanel(Editor_MainWindowPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "232 0";
extent = "1427 1081";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "panel2";
canSave = "1";
canSaveDynamicFields = "0";
new GuiSplitContainer(Editor_MainViewSplit) {
orientation = "Horizontal";
splitterSize = "2";
splitPoint = "182 745";
fixedPanel = "None";
useMinExtent="0";
fixedSize = "273";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1427 1081";
minExtent = "64 64";
horizSizing = "width";
vertSizing = "height";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiPanel(Editor_MainViewPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1427 743";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "Panel1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiTabBookCtrl(Editor_MainViewTabBook) {
tabPosition = "Top";
tabMargin = "7";
minTabWidth = "64";
tabHeight = "20";
allowReorder = "0";
defaultPage = "-1";
selectedPage = "-1";
frontTabPadding = "0";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1427 743";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "height";
profile = "ToolsGuiTabBookProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiBitmapButtonCtrl(Editor_InspectorSidebarButton) {
bitmap = "tools/gui/images/iconAdd.png";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
masked = "0";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "1411 61";
extent = "15 15";
minExtent = "8 2";
horizSizing = "left";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiBitmapButtonCtrl(Editor_ToolsSidebarButton) {
bitmap = "tools/gui/images/iconAdd.png";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
masked = "0";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "0 61";
extent = "15 15";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiBitmapButtonCtrl(Editor_AssetBrowserButton) {
bitmap = "tools/gui/images/iconAdd.png";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
masked = "0";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "1411 725";
extent = "15 15";
minExtent = "8 2";
horizSizing = "left";
vertSizing = "top";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiBitmapButtonCtrl(Editor_VisibilityOptionsButton) {
bitmap = "tools/gui/images/visible";
bitmapMode = "Stretched";
autoFitExtents = "0";
useModifiers = "0";
useStates = "1";
masked = "0";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
position = "16 30";
extent = "18 18";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
};
};
new GuiPanel(Editor_AssetBrowserPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 747";
extent = "1427 334";
minExtent = "16 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "panel2";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
};
};
new GuiPanel(Editor_InspectorPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "1663 0";
extent = "258 1081";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "panel2";
canSave = "1";
canSaveDynamicFields = "0";
new GuiSplitContainer() {
orientation = "Horizontal";
splitterSize = "2";
splitPoint = "182 556";
fixedPanel = "None";
useMinExtent="0";
fixedSize = "100";
docking = "None";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "258 1081";
minExtent = "64 64";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiPanel(Editor_SceneTreePanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "258 554";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "Panel1";
canSave = "1";
canSaveDynamicFields = "0";
};
new GuiPanel(Editor_PropertiesPanel) {
docking = "Client";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 558";
extent = "258 523";
minExtent = "0 0";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "panel2";
canSave = "1";
canSaveDynamicFields = "0";
};
};
};
};
};
//--- OBJECT WRITE END ---

View file

@ -0,0 +1,213 @@
//-----------------------------------------------------------------------------
// Verve
// Copyright (C) - Violent Tulip
//-----------------------------------------------------------------------------
singleton GuiControlProfile( VEditorDefaultProfile )
{
opaque = true;
fillColor = "70 70 70";
fillColorHL = "90 90 90";
fillColorNA = "70 70 70";
border = 1;
borderColor = "120 120 120";
borderColorHL = "100 100 100";
borderColorNA = "240 240 240";
fontType = "Arial";
fontSize = 12;
fontCharset = ANSI;
fontColor = "255 255 255";
fontColorHL = "255 255 255";
fontColorNA = "255 255 255";
fontColorSEL = "255 255 255";
};
singleton GuiControlProfile( VEditorTestProfile )
{
opaque = true;
fillColor = "255 255 0";
fillColorHL = "255 255 0";
fillColorNA = "255 255 0";
};
singleton GuiControlProfile( VEditorNoFillProfile : VEditorDefaultProfile )
{
opaque = false;
};
singleton GuiControlProfile( VEditorNoBorderProfile : VEditorDefaultProfile )
{
border = false;
};
singleton GuiControlProfile( VEditorTransparentProfile : VEditorDefaultProfile )
{
opaque = false;
border = false;
};
//-----------------------------------------------------------------------------
singleton GuiControlProfile( VEditorTextProfile : VEditorDefaultProfile )
{
border = false;
opaque = false;
fontType = "Arial Bold";
};
singleton GuiControlProfile( VEditorTextEditProfile : VEditorDefaultProfile )
{
fillColor = "70 70 70";
fillColorHL = "90 90 90";
fillColorSEL = "0 0 0";
fillColorNA = "70 70 70";
fontColor = "255 255 255";
fontColorHL = "0 0 0";
fontColorSEL = "128 128 128";
fontColorNA = "128 128 128";
textOffset = "4 2";
autoSizeWidth = false;
autoSizeHeight = false;
justify = "left";
tab = true;
canKeyFocus = true;
};
singleton GuiControlProfile( VEditorPopupMenuProfile : GuiPopUpMenuProfile )
{
FillColorHL = "90 90 90";
FillColorSEL = "0 0 0";
FontColorHL = "255 255 255";
};
singleton GuiControlProfile ( VEditorBitmapButtonProfile : VEditorDefaultProfile )
{
justify = "center";
hasBitmapArray = true;
bitmap = "./Images/Button";
};
//-----------------------------------------------------------------------------
singleton GuiControlProfile( VEditorGroupHeaderProfile : VEditorDefaultProfile )
{
CanKeyFocus = true;
TextOffset = "23 0";
fontColor = "70 70 70";
};
singleton GuiControlProfile( VEditorGroupHeaderErrorProfile : VEditorGroupHeaderProfile )
{
fontColor = "255 70 70";
};
singleton GuiControlProfile( VEditorGroupTrackProfile : VEditorTransparentProfile )
{
CanKeyFocus = true;
};
singleton GuiControlProfile( VEditorTrackProfile : VEditorDefaultProfile )
{
CanKeyFocus = true;
TextOffset = "33 0";
opaque = true;
fillColor = "255 255 255 15";
fillColorHL = "151 166 191 60";
borderColor = "100 100 100";
};
singleton GuiControlProfile( VEditorTrackErrorProfile : VEditorTrackProfile )
{
fontColor = "255 70 70";
};
singleton GuiControlProfile( VEditorEventProfile : VEditorDefaultProfile )
{
CanKeyFocus = true;
Justify = "left";
TextOffset = "6 1";
fillColor = "81 81 81";
fillColorHL = "102 102 102";
borderColor = "255 255 255";
borderColorHL = "255 255 255";
borderColorNA = "100 100 100";
};
singleton GuiControlProfile( VEditorTimeLineProfile : VEditorDefaultProfile )
{
CanKeyFocus = true;
opaque = false;
fillColorHL = "255 255 255 15";
border = false;
borderColor = "100 100 100";
};
singleton GuiControlProfile( VEditorPropertyProfile : VEditorDefaultProfile )
{
fillColor = "102 102 102";
};
//-----------------------------------------------------------------------------
singleton GuiControlProfile ( VEditorScrollProfile : VEditorDefaultProfile )
{
opaque = false;
border = false;
hasBitmapArray = true;
bitmap = "./Images/ScrollBar";
};
singleton GuiControlProfile ( VEditorCheckBoxProfile : GuiCheckBoxProfile )
{
// Void.
};
//-----------------------------------------------------------------------------
singleton GuiControlProfile( VEditorPropertyRolloutProfile : GuiRolloutProfile )
{
border = 0;
hasBitmapArray = true;
bitmap = "./Images/PropertyRollout";
fontType = "Arial";
fontSize = 12;
fontCharset = ANSI;
fontColor = "255 255 255";
fontColorHL = "255 255 255";
fontColorNA = "255 255 255";
fontColorSEL = "255 255 255";
};
singleton GuiControlProfile( VEditorPropertyLabelProfile : VEditorTextProfile )
{
border = "1";
justify = "center";
};
//-----------------------------------------------------------------------------
singleton GuiControlProfile( VEditorPreferenceLabelProfile : GuiTextProfile )
{
opaque = true;
fillColor = "242 241 240";
fillColorHL = "242 241 240";
fillColorNA = "242 241 240";
};

View file

@ -0,0 +1,103 @@
function NewEditorGui::AddWindow(%this)
{
%page = new GuiTabPageCtrl()
{
fitBook = "1";
text = "Object Viewer";
maxLength = "1024";
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "1024 768";
minExtent = "8 2";
horizSizing = "width";
vertSizing = "height";
profile = "GuiTabPageProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1";
};
%page.add(ObjectViewer);
MainEditorBasePanel.add(%page);
//Ensure the sidebar is spaced sanely
%pos = MainEditorBasePanel.extent.x * 0.8;
ObjectViewer-->splitContainer.splitPoint.x = MainEditorBasePanel.extent.x * 0.8;
}
function AssetBrowserWindow::onMouseDragged(%this)
{
%payload = new GuiBitmapButtonCtrl();
%payload.assignFieldsFrom( %this );
%payload.className = "AssetPreviewControl";
%payload.position = "0 0";
%payload.dragSourceControl = %this;
%payload.bitmap = %this.icon;
%payload.extent.x /= 2;
%payload.extent.y /= 2;
%xOffset = getWord( %payload.extent, 0 ) / 2;
%yOffset = getWord( %payload.extent, 1 ) / 2;
// Compute the initial position of the GuiDragAndDrop control on the cavas based on the current
// mouse cursor position.
%cursorpos = Canvas.getCursorPos();
%xPos = getWord( %cursorpos, 0 ) - %xOffset;
%yPos = getWord( %cursorpos, 1 ) - %yOffset;
if(!isObject(EditorDragAndDropLayer))
{
new GuiControl(EditorDragAndDropLayer)
{
position = "0 0";
extent = Canvas.extent;
};
}
// Create the drag control.
%ctrl = new GuiDragAndDropControl()
{
canSaveDynamicFields = "0";
Profile = "GuiSolidDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = %xPos SPC %yPos;
extent = %payload.extent;
MinExtent = "4 4";
canSave = "1";
Visible = "1";
hovertime = "1000";
// Let the GuiDragAndDropControl delete itself on mouse-up. When the drag is aborted,
// this not only deletes the drag control but also our payload.
deleteOnMouseUp = true;
useWholeCanvas = true;
// To differentiate drags, use the namespace hierarchy to classify them.
// This will allow a color swatch drag to tell itself apart from a file drag, for example.
class = "AssetPreviewControlType_AssetDrop";
};
// Add the temporary color swatch to the drag control as the payload.
%ctrl.add( %payload );
// Start drag by adding the drag control to the canvas and then calling startDragging().
//Canvas.getContent().add( %ctrl );
EditorDragAndDropLayer.add(%ctrl);
Canvas.pushDialog(EditorDragAndDropLayer);
%ctrl.startDragging( %xOffset, %yOffset );
}

View file

@ -0,0 +1,26 @@
function ToolsModule::onCreate(%this)
{
// ----------------------------------------------------------------------------
// Initialize core sub system functionality such as audio, the Canvas, PostFX,
// rendermanager, light managers, etc.
//
// Note that not all of these need to be initialized before the client, although
// the audio should and the canvas definitely needs to be. I've put things here
// to distinguish between the purpose and functionality of the various client
// scripts. Game specific script isn't needed until we reach the shell menus
// and start a game or connect to a server. We get the various subsystems ready
// to go, and then use initClient() to handle the rest of the startup sequence.
//
// If this is too convoluted we can reduce this complexity after futher testing
// to find exactly which subsystems should be readied before kicking things off.
// ----------------------------------------------------------------------------
ModuleDatabase.LoadExplicit( "MainEditor" );
ModuleDatabase.LoadExplicit( "Tools_ObjectViewer" );
}
function ToolsModule::onDestroy(%this)
{
}

View file

@ -0,0 +1,8 @@
<ModuleDefinition
ModuleId="ToolsModule"
VersionId="1"
Description="Module that implements the tools and editor suite."
ScriptFile="Tools.cs"
CreateFunction="onCreate"
DestroyFunction="onDestroy"
Group="Tools"/>

View file

@ -1077,6 +1077,10 @@ singleton GuiControlProfile( GuiMenuBarProfile )
fillcolorHL = "42 42 42"; fillcolorHL = "42 42 42";
borderColor = "30 30 30 255"; borderColor = "30 30 30 255";
borderColorHL = "30 30 30 255"; borderColorHL = "30 30 30 255";
fontColor = "215 215 215";
fontColorSEL = "43 107 206";
fontColorHL = "244 244 244";
fontColorNA = "100 100 100";
border = 0; border = 0;
borderThickness = 1; borderThickness = 1;
opaque = true; opaque = true;

View file

@ -142,6 +142,13 @@ package Tools
// resources can override, redefine, or add functionality. // resources can override, redefine, or add functionality.
Tools::LoadResources( $Tools::resourcePath ); Tools::LoadResources( $Tools::resourcePath );
//Now, go through and load any tool-group modules
ModuleDatabase.setModuleExtension("module");
//Any common tool modules
ModuleDatabase.scanModules( "tools", false );
ModuleDatabase.LoadGroup( "Tools" );
//Now that we're done loading, we can set the instant group back //Now that we're done loading, we can set the instant group back
popInstantGroup(); popInstantGroup();
$instantGroup = MissionCleanup; $instantGroup = MissionCleanup;

View file

@ -4476,7 +4476,7 @@
isContainer = "0"; isContainer = "0";
HorizSizing = "left"; HorizSizing = "left";
VertSizing = "bottom"; VertSizing = "bottom";
position = "86 1"; position = "66 1";
Extent = "16 16"; Extent = "16 16";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -4497,7 +4497,7 @@
Profile = "ToolsGuiDefaultProfile"; Profile = "ToolsGuiDefaultProfile";
HorizSizing = "left"; HorizSizing = "left";
VertSizing = "bottom"; VertSizing = "bottom";
position = "106 1"; position = "86 1";
Extent = "16 16"; Extent = "16 16";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -4519,7 +4519,7 @@
Profile = "ToolsGuiDefaultProfile"; Profile = "ToolsGuiDefaultProfile";
HorizSizing = "left"; HorizSizing = "left";
VertSizing = "bottom"; VertSizing = "bottom";
position = "123 1"; position = "106 1";
Extent = "16 16"; Extent = "16 16";
MinExtent = "8 2"; MinExtent = "8 2";
canSave = "1"; canSave = "1";
@ -4533,6 +4533,27 @@
useMouseEvents = "0"; useMouseEvents = "0";
bitmap = "tools/gui/images/save-icon"; bitmap = "tools/gui/images/save-icon";
}; };
new GuiBitmapButtonCtrl() {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiDefaultProfile";
HorizSizing = "left";
VertSizing = "bottom";
position = "126 1";
Extent = "16 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.lookupMaterialInstances();";
hovertime = "1000";
groupNum = "-1";
text ="";
tooltip = "Lookup Material Instances";
buttonType = "PushButton";
useMouseEvents = "0";
bitmap = "tools/gui/images/visible";
};
new GuiBitmapCtrl(){ new GuiBitmapCtrl(){
position = "147 1"; position = "147 1";
Extent = "2 16"; Extent = "2 16";

View file

@ -32,9 +32,13 @@ function initializeMaterialEditor()
// Load Properties Window // Load Properties Window
exec("~/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui"); exec("~/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui");
//Material Instance viewer
exec("~/materialEditor/gui/materialInstancesView.ed.gui");
// Load Client Scripts. // Load Client Scripts.
exec("./scripts/materialEditor.ed.cs"); exec("./scripts/materialEditor.ed.cs");
exec("./scripts/materialEditorUndo.ed.cs"); exec("./scripts/materialEditorUndo.ed.cs");
exec("./scripts/materialInstanceView.ed.cs");
//exec("./gui/profiles.ed.cs"); //exec("./gui/profiles.ed.cs");
MaterialEditorPreviewWindow.setVisible( false ); MaterialEditorPreviewWindow.setVisible( false );

View file

@ -2278,6 +2278,32 @@ function MaterialEditorGui::refreshMaterial(%this)
MaterialEditorGui.setMaterialNotDirty(); MaterialEditorGui.setMaterialNotDirty();
} }
//==============================================================================
// Looking up material instances/getting mat info
function MaterialEditorGui::lookupMaterialInstances( %this )
{
if( MaterialEditorGui.currentMaterial.getName() $= "" )
{
MessageBoxOK("Cannot perform operation", "Unable to look up a material with a blank name" );
return;
}
MaterialInstanceViewTree.clear();
MaterialInstanceViewTree.setFilterChildren(false);
MaterialInstanceViewTree.setItemFilterException(1, true);
MaterialEditorGui.currentMaterial.getMaterialInstances(MaterialInstanceViewTree);
if(MaterialInstanceFilter.Text !$= "\c2Filter...")
{
MaterialInstanceViewTree.setFilterText(MaterialInstanceFilter.Text);
}
MaterialInstanceViewTree.buildVisibleTree(true);
Canvas.pushDialog(MaterialInstanceViewCtrl);
}
//============================================================================== //==============================================================================
// Switching and Changing Materials // Switching and Changing Materials

View file

@ -0,0 +1,207 @@
function MainEditor::onCreate( %this )
{
echo("\n--------- Initializing MainEditor ---------");
//exec("tools/gui/profiles.ed.cs");
//exec("./scripts/GuiProfiles.cs");
exec("./guis/MainEditorWindow.gui");
//exec("./scripts/newEditorGui.cs");
$UsePanelLayout = false;
$AssetBrowserPanelState = true;
$AssetBrowserPanelSplit = 0;
$InspectorPanelState = true;
$InspectorPanelSplit = 0;
$ToolsPanelState = true;
$ToolsPanelSplit = 0;
}
function MainEditor::onDestroy( %this )
{
}
function NewEditorGui::addNewEditorTab(%this, %editorName)
{
%editorTab = new GuiTabPageCtrl()
{
Profile = "ToolsGuiEditorTabPage";
position = "0 0";
extent = Editor_MainViewTabBook.extent;
AnchorTop = "1";
AnchorBottom = "0";
AnchorLeft = "1";
AnchorRight = "0";
horizSizing = "width";
vertSizing = "height";
text = %editorName;
};
Editor_MainViewTabBook.add(%editorTab);
return %editorTab;
}
function togglePanelLayout()
{
$UsePanelLayout = !$UsePanelLayout;
if($UsePanelLayout)
{
EditorGui.add(NewEditorGui);
//Nudge us down so we show the toolbar
NewEditorGui.resize(0, EditorGuiToolbar.extent.y, EditorGui.extent.x, EditorGui.extent.y - EditorGuiToolbar.extent.y - EditorGuiStatusBar.extent.y);
%mainEditViewTitle = "Level - " @ getScene(0).getName();
%mainEditViewCtrl = NewEditorGui.addNewEditorTab(%mainEditViewTitle);
%mainEditViewCtrl.add(EWorldEditor);
EWorldEditor.position = "0 24";
EWorldEditor.extent = %mainEditViewCtrl.extent.x SPC %mainEditViewCtrl.extent.y - 24;
Editor_AssetBrowserPanel.add(AssetBrowser);
AssetBrowser.resize(0,0, Editor_AssetBrowserPanel.extent.x, Editor_AssetBrowserPanel.extent.y);
AssetBrowser.horizSizing = "width";
AssetBrowser.vertSizing = "height";
AssetBrowserWindow.resize(0,0, AssetBrowser.extent.x, AssetBrowser.extent.y);
AssetBrowserWindow.horizSizing = "width";
AssetBrowserWindow.vertSizing = "height";
AssetBrowserWindow.canClose = false;
AssetBrowserWindow.canCollapse = false;
AssetBrowserWindow.canMaximize = false;
AssetBrowserWindow.canMinimize = false;
AssetBrowserWindow.canMove = false;
AssetBrowserWindow.resizeWidth = false;
AssetBrowserWindow.resizeHeight = false;
//Prep it
AssetBrowser.loadFilters();
Editor_SceneTreePanel.add(EWTreeWindow);
EWTreeWindow.resize(0,0, Editor_SceneTreePanel.extent.x, Editor_SceneTreePanel.extent.y);
EWTreeWindow.horizSizing = "width";
EWTreeWindow.vertSizing = "height";
EWTreeWindow.canClose = false;
EWTreeWindow.canCollapse = false;
EWTreeWindow.canMaximize = false;
EWTreeWindow.canMinimize = false;
EWTreeWindow.canMove = false;
EWTreeWindow.resizeWidth = false;
EWTreeWindow.resizeHeight = false;
if(!isObject(Scenes))
{
$scenesRootGroup = new SimGroup(Scenes);
$scenesRootGroup.add(getScene(0));
}
EditorTree.open($scenesRootGroup,true);
Editor_PropertiesPanel.add(EWInspectorWindow);
EWInspectorWindow.resize(0,0, Editor_PropertiesPanel.extent.x, Editor_PropertiesPanel.extent.y);
EWInspectorWindow.horizSizing = "width";
EWInspectorWindow.vertSizing = "height";
EWInspectorWindow.canClose = false;
EWInspectorWindow.canCollapse = false;
EWInspectorWindow.canMaximize = false;
EWInspectorWindow.canMinimize = false;
EWInspectorWindow.canMove = false;
EWInspectorWindow.resizeWidth = false;
EWInspectorWindow.resizeHeight = false;
}
else
{
EditorGui.remove(NewEditorGui);
EditorGui.add(EWorldEditor);
EditorGui.add(AssetBrowser);
AssetBrowserWindow.canClose = false;
AssetBrowserWindow.canCollapse = false;
AssetBrowserWindow.canMaximize = false;
AssetBrowserWindow.canMinimize = false;
AssetBrowserWindow.canMove = false;
EditorGui.add(EWTreeWindow);
EditorGui.add(EWInspectorWindow);
}
}
function Editor_AssetBrowserButton::onClick(%this)
{
$AssetBrowserPanelState = !$AssetBrowserPanelState;
//If we're collapsing
if(!$AssetBrowserPanelState)
{
//Store the original
$AssetBrowserPanelSplit = Editor_MainViewSplit.splitPoint.y;
//collapse it
Editor_MainViewSplit.setSplitPoint(Editor_MainViewSplit.splitPoint.x SPC Editor_MainViewSplit.extent.y - Editor_MainViewSplit.splitterSize);
}
else
{
//restore the original
Editor_MainViewSplit.setSplitPoint(Editor_MainViewSplit.splitPoint.x SPC $AssetBrowserPanelSplit);
}
}
function Editor_InspectorSidebarButton::onClick(%this)
{
$InspectorPanelState = !$InspectorPanelState;
//If we're collapsing
if(!$InspectorPanelState)
{
//Store the original
$InspectorPanelSplit = NewEditorGuiLayout.splitPoint.x;
//collapse it
NewEditorGuiLayout.setSplitPoint(NewEditorGui.extent.x - NewEditorGuiLayout.splitterSize SPC NewEditorGuiLayout.splitPoint.y);
}
else
{
//restore the original
NewEditorGuiLayout.setSplitPoint($InspectorPanelSplit SPC NewEditorGuiLayout.splitPoint.y);
}
}
function Editor_ToolsSidebarButton::onClick(%this)
{
$ToolsPanelState = !$ToolsPanelState;
//If we're collapsing
if(!$ToolsPanelState)
{
//Store the original
$ToolsPanelSplit = Editor_ToolsMainSplit.splitPoint.x;
//collapse it
Editor_ToolsMainSplit.setSplitPoint(Editor_ToolsMainSplit.splitterSize SPC Editor_ToolsMainSplit.splitPoint.y);
}
else
{
//restore the original
Editor_ToolsMainSplit.setSplitPoint($ToolsPanelSplit SPC Editor_ToolsMainSplit.splitPoint.y);
}
}
function Editor_VisibilityOptionsButton::onClick(%this)
{
if ( EVisibility.visible )
{
EVisibility.setVisible(false);
//visibilityToggleBtn.setStateOn(0);
}
else
{
EVisibility.setVisible(true);
//visibilityToggleBtn.setStateOn(1);
EVisibility.setExtent("200 540");
}
}

View file

@ -0,0 +1,9 @@
<ModuleDefinition
ModuleId="MainEditor"
VersionId="1"
Description="Tool that can be used to view/edit an object."
ScriptFile="MainEditor.cs"
CreateFunction="onCreate"
DestroyFunction="onDestroy"
Group="Tools">
</ModuleDefinition>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Some files were not shown because too many files have changed in this diff Show more