mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Merge branch 'development' into walkabout
Conflicts: Templates/Empty/game/tools/worldEditor/scripts/editors/creator.ed.cs Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs
This commit is contained in:
commit
7ab6731f51
1453 changed files with 95576 additions and 14818 deletions
|
|
@ -458,7 +458,7 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
}
|
||||
|
||||
// Add to the blend total.
|
||||
meta->addStatement( new GenOp( " @ = max( @, @ );\r\n", blendTotal, blendTotal, detailBlend ) );
|
||||
meta->addStatement( new GenOp( " @ += @;\r\n", blendTotal, detailBlend ) );
|
||||
|
||||
// If we had a parallax feature... then factor in the parallax
|
||||
// amount so that it fades out with the layer blending.
|
||||
|
|
|
|||
|
|
@ -30,15 +30,16 @@
|
|||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
#include "shaderGen/featureMgr.h"
|
||||
#include "shaderGen/shaderGen.h"
|
||||
#include "core/module.h"
|
||||
|
||||
|
||||
MODULE_BEGIN( TerrainFeatHLSL )
|
||||
|
||||
MODULE_INIT_AFTER( ShaderGenFeatureMgr )
|
||||
|
||||
MODULE_INIT
|
||||
namespace
|
||||
{
|
||||
void register_hlsl_shader_features_for_terrain(GFXAdapterType type)
|
||||
{
|
||||
if(type != Direct3D9 && type != Direct3D9_360)
|
||||
return;
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_TerrainBaseMap, new TerrainBaseMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainParallaxMap, new NamedFeatureHLSL( "Terrain Parallax Texture" ) );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainDetailMap, new TerrainDetailMapFeatHLSL );
|
||||
|
|
@ -49,6 +50,17 @@ MODULE_BEGIN( TerrainFeatHLSL )
|
|||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatHLSL );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MODULE_BEGIN( TerrainFeatHLSL )
|
||||
|
||||
MODULE_INIT_AFTER( ShaderGen )
|
||||
|
||||
MODULE_INIT
|
||||
{
|
||||
SHADERGEN->getFeatureInitSignal().notify(®ister_hlsl_shader_features_for_terrain);
|
||||
}
|
||||
|
||||
MODULE_END;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,27 @@ AFTER_MODULE_INIT( MaterialManager )
|
|||
|
||||
Vector<TerrainCellMaterial*> TerrainCellMaterial::smAllMaterials;
|
||||
|
||||
Vector<String> _initSamplerNames()
|
||||
{
|
||||
Vector<String> samplerNames;
|
||||
samplerNames.push_back("$baseTexMap");
|
||||
samplerNames.push_back("$layerTex");
|
||||
samplerNames.push_back("$macrolayerTex");
|
||||
samplerNames.push_back("$lightMapTex");
|
||||
samplerNames.push_back("$lightInfoBuffer");
|
||||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
samplerNames.push_back(avar("$normalMap%d",i));
|
||||
samplerNames.push_back(avar("$detailMap%d",i));
|
||||
samplerNames.push_back(avar("$macroMap%d",i));
|
||||
}
|
||||
|
||||
return samplerNames;
|
||||
}
|
||||
|
||||
|
||||
const Vector<String> TerrainCellMaterial::mSamplerNames = _initSamplerNames();
|
||||
|
||||
TerrainCellMaterial::TerrainCellMaterial()
|
||||
: mCurrPass( 0 ),
|
||||
mTerrain( NULL ),
|
||||
|
|
@ -460,7 +481,7 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
const bool logErrors = matCount == 1;
|
||||
GFXShader::setLogging( logErrors, true );
|
||||
|
||||
pass->shader = SHADERGEN->getShader( featureData, getGFXVertexFormat<TerrVertex>(), NULL );
|
||||
pass->shader = SHADERGEN->getShader( featureData, getGFXVertexFormat<TerrVertex>(), NULL, mSamplerNames );
|
||||
}
|
||||
|
||||
// If we got a shader then we can continue.
|
||||
|
|
@ -499,14 +520,7 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
pass->oneOverTerrainSize = pass->shader->getShaderConstHandle( "$oneOverTerrainSize" );
|
||||
pass->squareSize = pass->shader->getShaderConstHandle( "$squareSize" );
|
||||
|
||||
// NOTE: We're assuming rtParams0 here as we know its the only
|
||||
// render target we currently get in a terrain material and the
|
||||
// DeferredRTLightingFeatHLSL will always use 0.
|
||||
//
|
||||
// This could change in the future and we would need to fix
|
||||
// the ShaderFeature API to allow us to do this right.
|
||||
//
|
||||
pass->lightParamsConst = pass->shader->getShaderConstHandle( "$rtParams0" );
|
||||
pass->lightParamsConst = pass->shader->getShaderConstHandle( "$rtParamslightInfoBuffer" );
|
||||
|
||||
// Now prepare the basic stateblock.
|
||||
GFXStateBlockDesc desc;
|
||||
|
|
@ -528,10 +542,7 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
|
||||
// We write to the zbuffer if this is a prepass
|
||||
// material or if the prepass is disabled.
|
||||
// We also write the zbuffer if we're using OpenGL, because in OpenGL the prepass
|
||||
// cannot share the same zbuffer as the backbuffer.
|
||||
desc.setZReadWrite( true, !MATMGR->getPrePassEnabled() ||
|
||||
GFX->getAdapterType() == OpenGL ||
|
||||
prePassMat ||
|
||||
reflectMat );
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,8 @@ protected:
|
|||
|
||||
U32 mCurrPass;
|
||||
|
||||
static const Vector<String> mSamplerNames;
|
||||
|
||||
GFXTexHandle mBaseMapTexture;
|
||||
|
||||
GFXTexHandle mLayerMapTexture;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include "T3D/physics/physicsCollision.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#include "console/engineAPI.h"
|
||||
using namespace Torque;
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(TerrainBlock);
|
||||
|
|
@ -141,36 +142,28 @@ ConsoleDocFragment _getTerrainUnderWorldPoint2(
|
|||
"bool getTerrainUnderWorldPoint( F32 x, F32 y, F32 z);"
|
||||
);
|
||||
|
||||
ConsoleFunction(getTerrainUnderWorldPoint, S32, 2, 4, "(Point3F x/y/z) Gets the terrain block that is located under the given world point.\n"
|
||||
DefineConsoleFunction( getTerrainUnderWorldPoint, S32, (const char* ptOrX, const char* y, const char* z), ("", ""),
|
||||
"(Point3F x/y/z) Gets the terrain block that is located under the given world point.\n"
|
||||
"@param x/y/z The world coordinates (floating point values) you wish to query at. "
|
||||
"These can be formatted as either a string (\"x y z\") or separately as (x, y, z)\n"
|
||||
"@return Returns the ID of the requested terrain block (0 if not found).\n\n"
|
||||
"@hide")
|
||||
"@hide")
|
||||
{
|
||||
Point3F pos;
|
||||
if(argc == 2)
|
||||
dSscanf(argv[1], "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(argc == 4)
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z))
|
||||
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z))
|
||||
{
|
||||
pos.x = dAtof(argv[1]);
|
||||
pos.y = dAtof(argv[2]);
|
||||
pos.z = dAtof(argv[3]);
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
pos.z = dAtof(z);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Con::errorf("getTerrainUnderWorldPoint(Point3F): Invalid argument count! Valid arguments are either \"x y z\" or x,y,z\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
TerrainBlock* terrain = getTerrainUnderWorldPoint(pos);
|
||||
if(terrain != NULL)
|
||||
{
|
||||
return terrain->getId();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1326,32 +1319,31 @@ ConsoleDocFragment _getTerrainHeight2(
|
|||
"bool getTerrainHeight( F32 x, F32 y);"
|
||||
);
|
||||
|
||||
ConsoleFunction(getTerrainHeight, F32, 2, 3, "(Point2 pos) - gets the terrain height at the specified position."
|
||||
DefineConsoleFunction( getTerrainHeight, F32, (const char* ptOrX, const char* y), (""), "(Point2 pos) - gets the terrain height at the specified position."
|
||||
"@param pos The world space point, minus the z (height) value\n Can be formatted as either (\"x y\") or (x,y)\n"
|
||||
"@return Returns the terrain height at the given point as an F32 value.\n"
|
||||
"@hide")
|
||||
{
|
||||
Point2F pos;
|
||||
F32 height = 0.0f;
|
||||
F32 height = 0.0f;
|
||||
|
||||
if(argc == 2)
|
||||
dSscanf(argv[1],"%f %f",&pos.x,&pos.y);
|
||||
else if(argc == 3)
|
||||
{
|
||||
pos.x = dAtof(argv[1]);
|
||||
pos.y = dAtof(argv[2]);
|
||||
}
|
||||
Point2F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y))
|
||||
dSscanf(ptOrX, "%f %f", &pos.x, &pos.y);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y))
|
||||
{
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
}
|
||||
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(Point3F(pos.x, pos.y, 5000.0f));
|
||||
if(terrain)
|
||||
if(terrain->isServerObject())
|
||||
{
|
||||
Point3F offset;
|
||||
terrain->getTransform().getColumn(3, &offset);
|
||||
pos -= Point2F(offset.x, offset.y);
|
||||
terrain->getHeight(pos, &height);
|
||||
}
|
||||
return height;
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(Point3F(pos.x, pos.y, 5000.0f));
|
||||
if(terrain && terrain->isServerObject())
|
||||
{
|
||||
Point3F offset;
|
||||
terrain->getTransform().getColumn(3, &offset);
|
||||
pos -= Point2F(offset.x, offset.y);
|
||||
terrain->getHeight(pos, &height);
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
ConsoleDocFragment _getTerrainHeightBelowPosition1(
|
||||
|
|
@ -1372,28 +1364,23 @@ ConsoleDocFragment _getTerrainHeightBelowPosition2(
|
|||
"bool getTerrainHeightBelowPosition( F32 x, F32 y);"
|
||||
);
|
||||
|
||||
ConsoleFunction(getTerrainHeightBelowPosition, F32, 2, 4, "(Point3F pos) - gets the terrain height at the specified position."
|
||||
DefineConsoleFunction( getTerrainHeightBelowPosition, F32, (const char* ptOrX, const char* y, const char* z), ("", ""),
|
||||
"(Point3F pos) - gets the terrain height at the specified position."
|
||||
"@param pos The world space point. Can be formatted as either (\"x y z\") or (x,y,z)\n"
|
||||
"@note This function is useful if you simply want to grab the terrain height underneath an object.\n"
|
||||
"@return Returns the terrain height at the given point as an F32 value.\n"
|
||||
"@hide")
|
||||
{
|
||||
Point3F pos;
|
||||
F32 height = 0.0f;
|
||||
|
||||
if(argc == 2)
|
||||
dSscanf(argv[1], "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(argc == 4)
|
||||
Point3F pos;
|
||||
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(y) && dStrIsEmpty(z))
|
||||
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(y) && !dStrIsEmpty(z))
|
||||
{
|
||||
pos.x = dAtof(argv[1]);
|
||||
pos.y = dAtof(argv[2]);
|
||||
pos.z = dAtof(argv[3]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Con::errorf("getTerrainHeightBelowPosition(Point3F): Invalid argument count! Valid arguments are either \"x y z\" or x,y,z\n");
|
||||
return 0;
|
||||
pos.x = dAtof(ptOrX);
|
||||
pos.y = dAtof(y);
|
||||
pos.z = dAtof(z);
|
||||
}
|
||||
|
||||
TerrainBlock * terrain = getTerrainUnderWorldPoint(pos);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#include "gfx/bitmap/gBitmap.h"
|
||||
#include "terrain/terrMaterial.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#ifdef TORQUE_TOOLS
|
||||
|
||||
|
|
@ -136,26 +137,18 @@ bool TerrainBlock::exportLayerMaps( const UTF8 *filePrefix, const String &format
|
|||
return true;
|
||||
}
|
||||
|
||||
ConsoleMethod( TerrainBlock, exportHeightMap, bool, 3, 4, "(string filename, [string format]) - export the terrain block's heightmap to a bitmap file (default: png)" )
|
||||
DefineConsoleMethod( TerrainBlock, exportHeightMap, bool, (const char * fileNameStr, const char * format), ( "png"), "(string filename, [string format]) - export the terrain block's heightmap to a bitmap file (default: png)" )
|
||||
{
|
||||
UTF8 fileName[1024];
|
||||
String format = "png";
|
||||
if( argc > 3 )
|
||||
format = (const char*)argv[ 3 ];
|
||||
|
||||
Con::expandScriptFilename( fileName, sizeof( fileName ), argv[2] );
|
||||
Con::expandScriptFilename( fileName, sizeof( fileName ), fileNameStr );
|
||||
|
||||
return object->exportHeightMap( fileName, format );
|
||||
}
|
||||
|
||||
ConsoleMethod( TerrainBlock, exportLayerMaps, bool, 3, 4, "(string filePrefix, [string format]) - export the terrain block's layer maps to bitmap files (default: png)" )
|
||||
DefineConsoleMethod( TerrainBlock, exportLayerMaps, bool, (const char * filePrefixStr, const char * format), ( "png"), "(string filePrefix, [string format]) - export the terrain block's layer maps to bitmap files (default: png)" )
|
||||
{
|
||||
UTF8 filePrefix[1024];
|
||||
String format = "png";
|
||||
if( argc > 3 )
|
||||
format = (const char*)argv[3];
|
||||
|
||||
Con::expandScriptFilename( filePrefix, sizeof( filePrefix ), argv[2] );
|
||||
Con::expandScriptFilename( filePrefix, sizeof( filePrefix ), filePrefixStr );
|
||||
|
||||
return object->exportLayerMaps( filePrefix, format );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ void TerrainBlock::_updateLayerTexture()
|
|||
if ( mLayerTex.isNull() ||
|
||||
mLayerTex.getWidth() != layerSize ||
|
||||
mLayerTex.getHeight() != layerSize )
|
||||
mLayerTex.set( layerSize, layerSize, GFXFormatR8G8B8A8, &TerrainLayerTexProfile, "" );
|
||||
mLayerTex.set( layerSize, layerSize, GFXFormatB8G8R8A8, &TerrainLayerTexProfile, "" );
|
||||
|
||||
AssertFatal( mLayerTex.getWidth() == layerSize &&
|
||||
mLayerTex.getHeight() == layerSize,
|
||||
|
|
@ -207,17 +207,15 @@ void TerrainBlock::_updateBaseTexture(bool writeToCache)
|
|||
F32 copyOffsetX = 2.0f * GFX->getFillConventionOffset() / (F32)destSize.x;
|
||||
F32 copyOffsetY = 2.0f * GFX->getFillConventionOffset() / (F32)destSize.y;
|
||||
|
||||
const bool needsYFlip = GFX->getAdapterType() == OpenGL;
|
||||
|
||||
GFXVertexPT points[4];
|
||||
points[0].point = Point3F( -1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0 );
|
||||
points[0].texCoord = Point2F( 0.0, needsYFlip ? 0.0f : 1.0f );
|
||||
points[0].texCoord = Point2F( 0.0, 1.0f );
|
||||
points[1].point = Point3F( -1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0 );
|
||||
points[1].texCoord = Point2F( 0.0, needsYFlip ? 1.0f : 0.0f );
|
||||
points[1].texCoord = Point2F( 0.0, 0.0f );
|
||||
points[2].point = Point3F( 1.0 - copyOffsetX, 1.0 + copyOffsetY, 0.0 );
|
||||
points[2].texCoord = Point2F( 1.0, needsYFlip ? 1.0f : 0.0f );
|
||||
points[2].texCoord = Point2F( 1.0, 0.0f );
|
||||
points[3].point = Point3F( 1.0 - copyOffsetX, -1.0 + copyOffsetY, 0.0 );
|
||||
points[3].texCoord = Point2F( 1.0, needsYFlip ? 0.0f : 1.0f );
|
||||
points[3].texCoord = Point2F( 1.0, 1.0f );
|
||||
|
||||
vb.set( GFX, 4, GFXBufferTypeVolatile );
|
||||
GFXVertexPT *ptr = vb.lock();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue