Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/dae2dts tool #340

Open
wants to merge 4 commits into
base: Preview4_0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Engine/source/ts/loader/tsShapeLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,11 @@ void TSShapeLoader::install()
shape->mRadius = (shape->mBounds.maxExtents - shape->center).len();
shape->tubeRadius = shape->mRadius;

shape->init();
shape->finalizeEditable();
if (TSShape::smInitOnRead)
{
shape->init();
shape->finalizeEditable();
}
}

void TSShapeLoader::computeBounds(Box3F& bounds)
Expand Down
92 changes: 50 additions & 42 deletions Tools/dae2dts/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ S32 TorqueMain( S32 argc, const char **argv )
{
Con::errorf( "Error: no DAE file specified.\n" );
printUsage();

// Clean everything up.
StandardMainLoop::shutdown();

return -1;
}

Expand Down Expand Up @@ -152,67 +156,71 @@ S32 TorqueMain( S32 argc, const char **argv )
if ( verbose )
Con::printf( "Reading dae file...\n" );

TSShape::smInitOnRead = false;

// Attempt to load the DAE file
Resource<TSShape> shape = ResourceManager::get().load( srcPath );
if ( !shape )
{
Con::errorf( "Failed to convert DAE file: %s\n", srcPath.getFullPath() );
failed = 1;
}
else
{
if ( compatMode && !shape->canWriteOldFormat() )
Resource<TSShape> shape = ResourceManager::get().load( srcPath );
if ( !shape )
{
Con::errorf( "Warning: Attempting to save to DTS v24 but the shape "
"contains v26 features. Resulting DTS file may not be valid." );
Con::errorf( "Failed to convert DAE file: %s\n", srcPath.getFullPath() );
failed = 1;
}
else
{
if ( compatMode && !shape->canWriteOldFormat() )
{
Con::errorf( "Warning: Attempting to save to DTS v24 but the shape "
"contains v26 features. Resulting DTS file may not be valid." );
}

FileStream outStream;
FileStream outStream;

if ( saveDSQ )
{
Torque::Path dsqPath( destPath );
dsqPath.setExtension( "dsq" );
if ( saveDSQ )
{
Torque::Path dsqPath( destPath );
dsqPath.setExtension( "dsq" );

for ( S32 i = 0; i < shape->sequences.size(); i++ )
for ( S32 i = 0; i < shape->sequences.size(); i++ )
{
const String& seqName = shape->getName( shape->sequences[i].nameIndex );
if ( verbose )
Con::printf( "Writing DSQ file for sequence '%s'...\n", seqName.c_str() );

dsqPath.setFileName( destPath.getFileName() + "_" + seqName );

if ( outStream.open( dsqPath, Torque::FS::File::Write ) )
{
shape->exportSequence( &outStream, shape->sequences[i], compatMode );
outStream.close();
}
else
{
Con::errorf( "Failed to save sequence to %s\n", dsqPath.getFullPath().c_str() );
failed = 1;
}
}
}
if ( saveDTS )
{
const String& seqName = shape->getName( shape->sequences[i].nameIndex );
if ( verbose )
Con::printf( "Writing DSQ file for sequence '%s'...\n", seqName.c_str() );

dsqPath.setFileName( destPath.getFileName() + "_" + seqName );
Con::printf( "Writing DTS file...\n" );

if ( outStream.open( dsqPath, Torque::FS::File::Write ) )
if ( outStream.open( destPath, Torque::FS::File::Write ) )
{
shape->exportSequence( &outStream, shape->sequences[i], compatMode );
if ( saveDSQ )
shape->sequences.setSize(0);

shape->write( &outStream, compatMode );
outStream.close();
}
else
{
Con::errorf( "Failed to save sequence to %s\n", dsqPath.getFullPath().c_str() );
Con::errorf( "Failed to save shape to %s\n", destPath.getFullPath().c_str() );
failed = 1;
}
}
}
if ( saveDTS )
{
if ( verbose )
Con::printf( "Writing DTS file...\n" );

if ( outStream.open( destPath, Torque::FS::File::Write ) )
{
if ( saveDSQ )
shape->sequences.setSize(0);

shape->write( &outStream, compatMode );
outStream.close();
}
else
{
Con::errorf( "Failed to save shape to %s\n", destPath.getFullPath().c_str() );
failed = 1;
}
}
}

// Clean everything up.
Expand Down