mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Adjusted creation of various assets to utilize template files.
This commit is contained in:
parent
98f50a4453
commit
ff7e580d28
12 changed files with 426 additions and 166 deletions
|
|
@ -53,6 +53,8 @@ function AssetBrowser::onWake(%this)
|
|||
%this.onlyShowModulesWithAssets = false;
|
||||
%this.treeFilterMode = "list";
|
||||
|
||||
%this.templateFilesPath = "tools/assetBrowser/scripts/templateFiles/";
|
||||
|
||||
//First, build our our list of active modules
|
||||
%modulesList = ModuleDatabase.findModules(true);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,24 +23,31 @@ function AssetBrowser::createComponentAsset(%this)
|
|||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%scriptPath))
|
||||
{
|
||||
//TODO: enable ability to auto-embed a header for copyright or whatnot
|
||||
%file.writeline("//onAdd is called when the component is created and then added to it's owner entity.\n");
|
||||
%file.writeline("//You would also add any script-defined component fields via addComponentField().\n");
|
||||
%file.writeline("function " @ %assetName @ "::onAdd(%this)\n{\n\n}\n");
|
||||
%file.writeline("//onAdd is called when the component is removed and deleted from it's owner entity.");
|
||||
%file.writeline("function " @ %assetName @ "::onRemove(%this)\n{\n\n}\n");
|
||||
%file.writeline("//onClientConnect is called any time a new client connects to the server.");
|
||||
%file.writeline("function " @ %assetName @ "::onClientConnect(%this, %client)\n{\n\n}\n");
|
||||
%file.writeline("//onClientDisconnect is called any time a client disconnects from the server.");
|
||||
%file.writeline("function " @ %assetName @ "::onClientDisonnect(%this, %client)\n{\n\n}\n");
|
||||
%file.writeline("//update is called when the component does an update tick.\n");
|
||||
%file.writeline("function " @ %assetName @ "::Update(%this)\n{\n\n}\n");
|
||||
|
||||
%file.close();
|
||||
}
|
||||
%templateCodeFilePath = %this.templateFilesPath @ "componentFile.cs.template";
|
||||
|
||||
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%templateCodeFilePath))
|
||||
{
|
||||
while( !%templateFile.isEOF() )
|
||||
{
|
||||
%line = %templateFile.readline();
|
||||
%line = strreplace( %line, "@@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateComponentAsset - Something went wrong and we couldn't write the Component script file!");
|
||||
}
|
||||
|
||||
Canvas.popDialog(AssetBrowser_newComponentAsset);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,15 +41,13 @@ function AssetBrowser::createCppAsset(%this)
|
|||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
%templateFilesPath = "tools/assetBrowser/scripts/templateFiles/";
|
||||
|
||||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
if(%assetType $= "CppStaticClassAsset")
|
||||
{
|
||||
%cppTemplateCodeFilePath = %templateFilesPath @ "CppStaticClassFile.cpp";
|
||||
%cppTemplateHeaderFilePath = %templateFilesPath @ "CppStaticClassFile.h";
|
||||
%cppTemplateCodeFilePath = %this.templateFilesPath @ "CppStaticClassFile.cpp";
|
||||
%cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppStaticClassFile.h";
|
||||
}
|
||||
|
||||
if(%file.openForWrite(%codePath) && %templateFile.openForRead(%cppTemplateCodeFilePath))
|
||||
|
|
@ -103,7 +101,7 @@ function AssetBrowser::createCppAsset(%this)
|
|||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%cppModuleFilePath) && %templateFile.openForRead(%templateFilesPath @ "CppModuleFile.cpp"))
|
||||
if(%file.openForWrite(%cppModuleFilePath) && %templateFile.openForRead(%this.templateFilesPath @ "CppModuleFile.cpp"))
|
||||
{
|
||||
while( !%templateFile.isEOF() )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,27 +20,56 @@ function AssetBrowser::createGUIAsset(%this)
|
|||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
%guiTemplateCodeFilePath = %this.templateFilesPath @ "guiFile.gui.template";
|
||||
|
||||
if(%file.openForWrite(%guipath) && %templateFile.openForRead(%guiTemplateCodeFilePath))
|
||||
{
|
||||
while( !%templateFile.isEOF() )
|
||||
{
|
||||
%line = %templateFile.readline();
|
||||
%line = strreplace( %line, "@@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateGUIAsset - Something went wrong and we couldn't write the GUI file!");
|
||||
}
|
||||
|
||||
%scriptTemplateCodeFilePath = %this.templateFilesPath @ "guiFile.cs.template";
|
||||
|
||||
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%scriptTemplateCodeFilePath))
|
||||
{
|
||||
while( !%templateFile.isEOF() )
|
||||
{
|
||||
%line = %templateFile.readline();
|
||||
%line = strreplace( %line, "@@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateGUIAsset - Something went wrong and we couldn't write the GUI script file!");
|
||||
}
|
||||
|
||||
if(%file.openForWrite(%guipath))
|
||||
{
|
||||
%file.writeline("//--- OBJECT WRITE BEGIN ---");
|
||||
%file.writeline("%guiContent = new GuiControl(" @ %assetName @ ") {");
|
||||
%file.writeline(" position = \"0 0\";");
|
||||
%file.writeline(" extent = \"100 100\";");
|
||||
%file.writeline("};");
|
||||
%file.writeline("//--- OBJECT WRITE END ---");
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
if(%file.openForWrite(%scriptPath))
|
||||
{
|
||||
%file.writeline("function " @ %assetName @ "::onWake(%this)\n{\n\n}\n");
|
||||
%file.writeline("function " @ %assetName @ "::onSleep(%this)\n{\n\n}\n");
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
//load the gui
|
||||
exec(%guipath);
|
||||
exec(%scriptPath);
|
||||
|
|
|
|||
|
|
@ -27,12 +27,32 @@ function AssetBrowser::createPostEffectAsset(%this)
|
|||
|
||||
AssetBrowserFilterTree.onSelect(%smItem);
|
||||
|
||||
%file = new FileObject();
|
||||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
%postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFile.cs.template";
|
||||
|
||||
if(%file.openForWrite(%scriptPath))
|
||||
{
|
||||
%file.close();
|
||||
}
|
||||
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
|
||||
{
|
||||
while( !%templateFile.isEOF() )
|
||||
{
|
||||
%line = %templateFile.readline();
|
||||
%line = strreplace( %line, "@@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreatePostFXAsset - Something went wrong and we couldn't write the PostFX script file!");
|
||||
}
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
//onAdd is called when the component is created and then added to it's owner entity.
|
||||
//You would also add any script-defined component fields via addComponentField().
|
||||
function @@::onAdd(%this)
|
||||
{
|
||||
|
||||
}
|
||||
//onAdd is called when the component is removed and deleted from it's owner entity.
|
||||
function @@::onRemove(%this)
|
||||
{
|
||||
|
||||
}
|
||||
//onClientConnect is called any time a new client connects to the server.
|
||||
function @@::onClientConnect(%this, %client)
|
||||
{
|
||||
|
||||
}
|
||||
//onClientDisconnect is called any time a client disconnects from the server.
|
||||
%function @@::onClientDisonnect(%this, %client)
|
||||
{
|
||||
|
||||
}
|
||||
//update is called when the component does an update tick.
|
||||
function @@::Update(%this)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
function @@::onWake(%this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function @@::onSleep(%this)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
//--- OBJECT WRITE BEGIN ---
|
||||
%guiContent = new GuiControl(@@)
|
||||
{
|
||||
position = "0 0";
|
||||
extent = "100 100";
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton ShaderData( @@_Shader )
|
||||
{
|
||||
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
|
||||
DXPixelShaderFile = $Core:modulePath @ "@@P.hlsl";
|
||||
OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = $Core:modulePath @ "@@P.glsl";
|
||||
|
||||
samplerNames[0] = "$inputTex";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
singleton GFXStateBlockData( @@_StateBlock )
|
||||
{
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampLinear;
|
||||
samplerStates[1] = SamplerClampLinear;
|
||||
samplerStates[2] = SamplerClampLinear;
|
||||
samplerStates[3] = SamplerClampLinear;
|
||||
|
||||
blendDefined = true;
|
||||
blendDest = GFXBlendOne;
|
||||
blendSrc = GFXBlendZero;
|
||||
|
||||
zDefined = true;
|
||||
zEnable = false;
|
||||
zWriteEnable = false;
|
||||
|
||||
cullDefined = true;
|
||||
cullMode = GFXCullNone;
|
||||
};
|
||||
|
||||
|
||||
function @@::setShaderConsts( %this )
|
||||
{
|
||||
}
|
||||
|
||||
function @@::preProcess( %this )
|
||||
{
|
||||
}
|
||||
|
||||
function @@::onEnabled( %this )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function @@::onDisabled( %this )
|
||||
{
|
||||
}
|
||||
|
||||
singleton PostEffect( @@ )
|
||||
{
|
||||
isEnabled = false;
|
||||
allowReflectPass = false;
|
||||
|
||||
// Resolve the HDR before we render any editor stuff
|
||||
// and before we resolve the scene to the backbuffer.
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "EditorBin";
|
||||
renderPriority = 9999;
|
||||
|
||||
// The bright pass generates a bloomed version of
|
||||
// the scene for pixels which are brighter than a
|
||||
// fixed threshold value.
|
||||
//
|
||||
// This is then used in the final HDR combine pass
|
||||
// at the end of this post effect chain.
|
||||
shader = @@_Shader;
|
||||
stateBlock = @@_StateBlock;
|
||||
texture[0] = "$backBuffer";
|
||||
target = "$outTex";
|
||||
targetFormat = "GFXFormatR16G16B16A16F";
|
||||
targetScale = "1 1";
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "core/rendering/shaders/gl/torque.glsl"
|
||||
#include "core/rendering/shaders/gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "core/rendering/shaders/postFX/gl/postFX.glsl"
|
||||
|
||||
uniform sampler2D inputTex;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_col = hdrEncode( vec4(1,1,1,1) );
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "core/rendering/shaders/postFX/postFx.hlsl"
|
||||
#include "core/rendering/shaders/torque.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
|
||||
|
||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
return hdrEncode( float4(1,1,1,1) );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue