mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-20 23:23:47 +00:00
Reworks the terrain loader code to work with the assets.
Fixes the terrain asset creation, makes the loading logic go through the asset auto-import behavior when a filename or assetid is bound that is not found. Corrects terrain material binding to properly save and load Makes the terrain asset inspector fields work as expected.
This commit is contained in:
parent
3e1795ba1d
commit
4ce558f042
15 changed files with 500 additions and 283 deletions
|
|
@ -46,14 +46,14 @@ DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32
|
|||
// We create terrains based on level name. If the user wants to rename the terrain names; they have to
|
||||
// rename it themselves in their file browser. The main reason for this is so we can easily increment for ourselves;
|
||||
// and because its too easy to rename the terrain object and forget to take care of the terrain filename afterwards.
|
||||
FileName terrFileName( Con::getVariable("$Client::MissionFile") );
|
||||
|
||||
String terrainDirectory( Con::getVariable( "$pref::Directories::Terrain" ) );
|
||||
if ( terrainDirectory.isEmpty() )
|
||||
{
|
||||
terrainDirectory = "art/terrains/";
|
||||
terrainDirectory = "data/terrains/";
|
||||
}
|
||||
terrFileName.replace("tools/levels/", terrainDirectory);
|
||||
terrFileName.replace("levels/", terrainDirectory);
|
||||
|
||||
String terrFileName = terrainDirectory + "/" + terrainName + ".ter";
|
||||
|
||||
TerrainFile::create( &terrFileName, resolution, materials );
|
||||
|
||||
|
|
@ -273,18 +273,32 @@ bool TerrainBlock::import( const GBitmap &heightMap,
|
|||
{
|
||||
// Get a unique file name for the terrain.
|
||||
String fileName( getName() );
|
||||
if ( fileName.isEmpty() )
|
||||
fileName = "terrain";
|
||||
mTerrFileName = FS::MakeUniquePath( "levels", fileName, "ter" );
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
fileName = Torque::Path(Con::getVariable("$Client::MissionFile")).getFileName();
|
||||
|
||||
// TODO: We have to save and reload the file to get
|
||||
if (fileName.isEmpty())
|
||||
fileName = "terrain";
|
||||
}
|
||||
String terrainFileName = FS::MakeUniquePath( "levels", fileName, "ter" );
|
||||
|
||||
if (!TerrainAsset::getAssetByFilename(terrainFileName, &mTerrainAsset))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mFile = mTerrainAsset->getTerrainResource();
|
||||
}
|
||||
|
||||
/*// TODO: We have to save and reload the file to get
|
||||
// it into the resource system. This creates lots
|
||||
// of temporary unused files when the terrain is
|
||||
// discarded because of undo or quit.
|
||||
TerrainFile *file = new TerrainFile;
|
||||
file->save( mTerrFileName );
|
||||
delete file;
|
||||
mFile = ResourceManager::get().load( mTerrFileName );
|
||||
mFile = ResourceManager::get().load( mTerrFileName );*/
|
||||
}
|
||||
|
||||
// The file does a bunch of the work.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue