2008-05-09 17:24:28 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
2008-05-22 10:20:31 +00:00
|
|
|
Open Asset Import Library (ASSIMP)
|
2008-05-09 17:24:28 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
|
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the following
|
|
|
|
conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the ASSIMP team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the ASSIMP Development Team.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
/** @file 3DSLoader.cpp
|
|
|
|
* @brief Implementation of the 3ds importer class
|
|
|
|
*
|
|
|
|
* http://www.the-labs.com/Blender/3DS-details.html
|
|
|
|
*/
|
2008-06-22 10:09:26 +00:00
|
|
|
|
2008-10-13 16:45:48 +00:00
|
|
|
#include "AssimpPCH.h"
|
2009-01-18 23:48:25 +00:00
|
|
|
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
|
2008-10-13 16:45:48 +00:00
|
|
|
|
2008-06-22 10:09:26 +00:00
|
|
|
// internal headers
|
2008-05-05 12:36:31 +00:00
|
|
|
#include "3DSLoader.h"
|
|
|
|
|
|
|
|
using namespace Assimp;
|
2008-08-28 17:35:36 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Begins a new parsing block
|
|
|
|
// - Reads the current chunk and validates it
|
|
|
|
// - computes its length
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
#define ASSIMP_3DS_BEGIN_CHUNK() \
|
2009-06-23 12:25:35 +00:00
|
|
|
while (true) { \
|
|
|
|
if (stream->GetRemainingSizeToLimit() < sizeof(Discreet3DS::Chunk)){ \
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return; \
|
2009-06-23 12:25:35 +00:00
|
|
|
} \
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
Discreet3DS::Chunk chunk; \
|
|
|
|
ReadChunk(&chunk); \
|
|
|
|
int chunkSize = chunk.Size-sizeof(Discreet3DS::Chunk); \
|
|
|
|
const int oldReadLimit = stream->GetReadLimit(); \
|
2009-06-23 12:25:35 +00:00
|
|
|
stream->SetReadLimit(stream->GetCurrentPos() + chunkSize); \
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// End a parsing block
|
2009-01-18 23:48:25 +00:00
|
|
|
// Must follow at the end of each parsing block, reset chunk end marker to previous value
|
|
|
|
#define ASSIMP_3DS_END_CHUNK() \
|
|
|
|
stream->SkipToReadLimit(); \
|
|
|
|
stream->SetReadLimit(oldReadLimit); \
|
|
|
|
if (stream->GetRemainingSizeToLimit() == 0) \
|
2009-06-23 12:25:35 +00:00
|
|
|
return; \
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Constructor to be privately used by Importer
|
2008-10-31 19:32:00 +00:00
|
|
|
Discreet3DSImporter::Discreet3DSImporter()
|
2009-01-18 23:48:25 +00:00
|
|
|
{}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Destructor, private as well
|
2008-10-31 19:32:00 +00:00
|
|
|
Discreet3DSImporter::~Discreet3DSImporter()
|
2009-01-18 23:48:25 +00:00
|
|
|
{}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Returns whether the class can handle the format of the given file.
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
bool Discreet3DSImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
std::string extension = GetExtension(pFile);
|
|
|
|
if(extension == "3ds" || extension == "prj" ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!extension.length() || checkSig) {
|
|
|
|
uint16_t token[3];
|
|
|
|
token[0] = 0x4d4d;
|
|
|
|
token[1] = 0x3dc2;
|
|
|
|
//token[2] = 0x3daa;
|
|
|
|
return CheckMagicToken(pIOHandler,pFile,token,2,0,2);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Get list of all extension supported by this loader
|
|
|
|
void Discreet3DSImporter::GetExtensionList(std::string& append)
|
|
|
|
{
|
|
|
|
append.append("*.3ds;*.prj");
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-08-09 22:39:57 +00:00
|
|
|
// Setup configuration properties
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::SetupProperties(const Importer* pImp)
|
2008-08-09 22:39:57 +00:00
|
|
|
{
|
2008-11-16 21:56:45 +00:00
|
|
|
// nothing to be done for the moment
|
2008-08-09 22:39:57 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-08-09 22:39:57 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-05-05 12:36:31 +00:00
|
|
|
// Imports the given file into the given scene structure.
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
|
|
|
aiScene* pScene, IOSystem* pIOHandler)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
StreamReaderLE stream(pIOHandler->Open(pFile,"rb"));
|
|
|
|
this->stream = &stream;
|
|
|
|
|
|
|
|
// We should have at least one chunk
|
|
|
|
if (stream.GetRemainingSize() < 16)
|
|
|
|
throw new ImportErrorException("3DS file is either empty or corrupt: " + pFile);
|
|
|
|
|
|
|
|
// Allocate our temporary 3DS representation
|
|
|
|
mScene = new D3DS::Scene();
|
|
|
|
|
|
|
|
// Initialize members
|
|
|
|
mLastNodeIndex = -1;
|
|
|
|
mCurrentNode = new D3DS::Node();
|
|
|
|
mRootNode = mCurrentNode;
|
|
|
|
mRootNode->mHierarchyPos = -1;
|
|
|
|
mRootNode->mHierarchyIndex = -1;
|
|
|
|
mRootNode->mParent = NULL;
|
|
|
|
mMasterScale = 1.0f;
|
|
|
|
mBackgroundImage = "";
|
|
|
|
bHasBG = false;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
bIsPrj = false;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// Parse the file
|
|
|
|
ParseMainChunk();
|
|
|
|
|
|
|
|
// Process all meshes in the file. First check whether all
|
|
|
|
// face indices haev valid values. The generate our
|
|
|
|
// internal verbose representation. Finally compute normal
|
|
|
|
// vectors from the smoothing groups we read from the
|
|
|
|
// file.
|
2008-11-16 21:56:45 +00:00
|
|
|
for (std::vector<D3DS::Mesh>::iterator i = mScene->mMeshes.begin(),
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
end = mScene->mMeshes.end(); i != end;++i) {
|
2008-10-31 19:32:00 +00:00
|
|
|
CheckIndices(*i);
|
|
|
|
MakeUnique (*i);
|
|
|
|
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(*i);
|
2008-08-13 15:45:57 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Replace all occurences of the default material with a
|
|
|
|
// valid material. Generate it if no material containing
|
|
|
|
// DEFAULT in its name has been found in the file
|
|
|
|
ReplaceDefaultMaterial();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Convert the scene from our internal representation to an
|
|
|
|
// aiScene object. This involves copying all meshes, lights
|
|
|
|
// and cameras to the scene
|
|
|
|
ConvertScene(pScene);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-08-13 15:45:57 +00:00
|
|
|
// Generate the node graph for the scene. This is a little bit
|
|
|
|
// tricky since we'll need to split some meshes into submeshes
|
2008-10-31 19:32:00 +00:00
|
|
|
GenerateNodeGraph(pScene);
|
2008-08-09 22:39:57 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Now apply the master scaling factor to the scene
|
|
|
|
ApplyMasterScale(pScene);
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Delete our internal scene representation and the root
|
|
|
|
// node, so the whole hierarchy will follow
|
|
|
|
delete mRootNode;
|
|
|
|
delete mScene;
|
|
|
|
|
|
|
|
AI_DEBUG_INVALIDATE_PTR(mRootNode);
|
|
|
|
AI_DEBUG_INVALIDATE_PTR(mScene);
|
|
|
|
AI_DEBUG_INVALIDATE_PTR(this->stream);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Applies a master-scaling factor to the imported scene
|
|
|
|
void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
// There are some 3DS files with a zero scaling factor
|
|
|
|
if (!mMasterScale)mMasterScale = 1.0f;
|
|
|
|
else mMasterScale = 1.0f / mMasterScale;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Construct an uniform scaling matrix and multiply with it
|
2008-05-05 12:36:31 +00:00
|
|
|
pScene->mRootNode->mTransformation *= aiMatrix4x4(
|
2008-10-31 19:32:00 +00:00
|
|
|
mMasterScale,0.0f, 0.0f, 0.0f,
|
|
|
|
0.0f, mMasterScale,0.0f, 0.0f,
|
|
|
|
0.0f, 0.0f, mMasterScale,0.0f,
|
2008-05-05 12:36:31 +00:00
|
|
|
0.0f, 0.0f, 0.0f, 1.0f);
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
|
|
|
// Check whether a scaling track is assigned to the root node.
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Reads a new chunk from the file
|
|
|
|
void Discreet3DSImporter::ReadChunk(Discreet3DS::Chunk* pcOut)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
ai_assert(pcOut != NULL);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
pcOut->Flag = stream->GetI2();
|
|
|
|
pcOut->Size = stream->GetI4();
|
2008-08-28 17:35:36 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize())
|
|
|
|
throw new ImportErrorException("Chunk is too large");
|
|
|
|
|
|
|
|
if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit())
|
|
|
|
DefaultLogger::get()->error("3DS: Chunk overflow");
|
|
|
|
}
|
2008-08-28 17:35:36 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Skip a chunk
|
|
|
|
void Discreet3DSImporter::SkipChunk()
|
|
|
|
{
|
|
|
|
Discreet3DS::Chunk psChunk;
|
|
|
|
ReadChunk(&psChunk);
|
|
|
|
|
|
|
|
stream->IncPtr(psChunk.Size-sizeof(Discreet3DS::Chunk));
|
2008-05-05 12:36:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Process the primary chunk of the file
|
|
|
|
void Discreet3DSImporter::ParseMainChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// get chunk type
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_PRJ:
|
|
|
|
bIsPrj = true;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAIN:
|
|
|
|
ParseEditorChunk();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
};
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-10-31 19:32:00 +00:00
|
|
|
// recursively continue processing this hierarchy level
|
|
|
|
return ParseMainChunk();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseEditorChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// get chunk type
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_OBJMESH:
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
ParseObjectChunk();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// NOTE: In several documentations in the internet this
|
|
|
|
// chunk appears at different locations
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_KEYFRAMER:
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
ParseKeyframeChunk();
|
2008-07-10 16:49:01 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_VERSION:
|
2008-07-10 16:49:01 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
// print the version number
|
|
|
|
char buff[10];
|
2009-01-12 22:06:54 +00:00
|
|
|
ASSIMP_itoa10(buff,stream->GetI2());
|
2008-10-31 19:32:00 +00:00
|
|
|
DefaultLogger::get()->info(std::string("3DS file format version: ") + buff);
|
2008-07-10 16:49:01 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
};
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseObjectChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// get chunk type
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_OBJBLOCK:
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
unsigned int cnt = 0;
|
|
|
|
const char* sz = (const char*)stream->GetPtr();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Get the name of the geometry object
|
|
|
|
while (stream->GetI1())++cnt;
|
|
|
|
ParseChunk(sz,cnt);
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_MATERIAL:
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Add a new material to the list
|
|
|
|
mScene->mMaterials.push_back(D3DS::Material());
|
|
|
|
ParseMaterialChunk();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_AMBCOLOR:
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// This is the ambient base color of the scene.
|
|
|
|
// We add it to the ambient color of all materials
|
2008-10-31 19:32:00 +00:00
|
|
|
ParseColorChunk(&mClrAmbient,true);
|
|
|
|
if (is_qnan(mClrAmbient.r))
|
|
|
|
{
|
|
|
|
// We failed to read the ambient base color.
|
2008-11-30 22:27:20 +00:00
|
|
|
DefaultLogger::get()->error("3DS: Failed to read ambient base color");
|
|
|
|
mClrAmbient.r = mClrAmbient.g = mClrAmbient.b = 0.0f;
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_BIT_MAP:
|
|
|
|
{
|
2008-11-30 22:27:20 +00:00
|
|
|
// Specifies the background image. The string should already be
|
|
|
|
// properly 0 terminated but we need to be sure
|
2008-10-31 19:32:00 +00:00
|
|
|
unsigned int cnt = 0;
|
|
|
|
const char* sz = (const char*)stream->GetPtr();
|
|
|
|
while (stream->GetI1())++cnt;
|
|
|
|
mBackgroundImage = std::string(sz,cnt);
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_BIT_MAP_EXISTS:
|
2008-05-05 12:36:31 +00:00
|
|
|
bHasBG = true;
|
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MASTER_SCALE:
|
|
|
|
// Scene master scaling factor
|
|
|
|
mMasterScale = stream->GetF4();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
};
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
// IMPLEMENTATION NOTE;
|
|
|
|
// Cameras or lights define their transformation in their parent node and in the
|
|
|
|
// corresponding light or camera chunks. However, we read and process the latter
|
|
|
|
// to to be able to return valid cameras/lights even if no scenegraph is given.
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// get chunk type
|
|
|
|
switch (chunk.Flag)
|
|
|
|
{
|
|
|
|
case Discreet3DS::CHUNK_TRIMESH:
|
|
|
|
{
|
|
|
|
// this starts a new triangle mesh
|
|
|
|
mScene->mMeshes.push_back(D3DS::Mesh());
|
|
|
|
D3DS::Mesh& m = mScene->mMeshes.back();
|
|
|
|
|
|
|
|
// Setup the name of the mesh
|
|
|
|
m.mName = std::string(name, num);
|
|
|
|
|
|
|
|
// Read mesh chunks
|
|
|
|
ParseMeshChunk();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
case Discreet3DS::CHUNK_LIGHT:
|
2008-10-31 19:32:00 +00:00
|
|
|
{
|
|
|
|
// This starts a new light
|
|
|
|
aiLight* light = new aiLight();
|
|
|
|
mScene->mLights.push_back(light);
|
|
|
|
|
|
|
|
light->mName.Set(std::string(name, num));
|
|
|
|
|
|
|
|
// First read the position of the light
|
|
|
|
light->mPosition.x = stream->GetF4();
|
|
|
|
light->mPosition.y = stream->GetF4();
|
|
|
|
light->mPosition.z = stream->GetF4();
|
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
light->mColorDiffuse = aiColor3D(1.f,1.f,1.f);
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
// Now check for further subchunks
|
|
|
|
if (!bIsPrj) /* fixme */
|
|
|
|
ParseLightChunk();
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2009-04-06 17:09:32 +00:00
|
|
|
// The specular light color is identical the the diffuse light color. The ambient light color
|
|
|
|
// is equal to the ambient base color of the whole scene.
|
2008-10-31 19:32:00 +00:00
|
|
|
light->mColorSpecular = light->mColorDiffuse;
|
|
|
|
light->mColorAmbient = mClrAmbient;
|
|
|
|
|
|
|
|
if (light->mType == aiLightSource_UNDEFINED)
|
|
|
|
{
|
|
|
|
// It must be a point light
|
|
|
|
light->mType = aiLightSource_POINT;
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_CAMERA:
|
|
|
|
{
|
|
|
|
// This starts a new camera
|
|
|
|
aiCamera* camera = new aiCamera();
|
|
|
|
mScene->mCameras.push_back(camera);
|
|
|
|
camera->mName.Set(std::string(name, num));
|
|
|
|
|
|
|
|
// First read the position of the camera
|
|
|
|
camera->mPosition.x = stream->GetF4();
|
|
|
|
camera->mPosition.y = stream->GetF4();
|
|
|
|
camera->mPosition.z = stream->GetF4();
|
|
|
|
|
|
|
|
// Then the camera target
|
|
|
|
camera->mLookAt.x = stream->GetF4() - camera->mPosition.x;
|
|
|
|
camera->mLookAt.y = stream->GetF4() - camera->mPosition.y;
|
|
|
|
camera->mLookAt.z = stream->GetF4() - camera->mPosition.z;
|
2009-04-06 17:09:32 +00:00
|
|
|
float len = camera->mLookAt.Length();
|
|
|
|
if (len < 1e-5f) {
|
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
// There are some files with lookat == position. Don't know why or whether it's ok or not.
|
2009-04-06 17:09:32 +00:00
|
|
|
DefaultLogger::get()->error("3DS: Unable to read proper camera look-at vector");
|
|
|
|
camera->mLookAt = aiVector3D(0.f,1.f,0.f);
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2009-04-06 17:09:32 +00:00
|
|
|
}
|
|
|
|
else camera->mLookAt /= len;
|
|
|
|
|
|
|
|
// And finally - the camera rotation angle, in counter clockwise direction
|
2009-01-20 21:41:17 +00:00
|
|
|
const float angle = AI_DEG_TO_RAD( stream->GetF4() );
|
2008-10-31 19:32:00 +00:00
|
|
|
aiQuaternion quat(camera->mLookAt,angle);
|
|
|
|
camera->mUp = quat.GetMatrix() * aiVector3D(0.f,1.f,0.f);
|
|
|
|
|
|
|
|
// Read the lense angle
|
|
|
|
camera->mHorizontalFOV = AI_DEG_TO_RAD ( stream->GetF4() );
|
2009-06-23 12:25:35 +00:00
|
|
|
if (camera->mHorizontalFOV < 0.001f) {
|
2008-11-30 22:27:20 +00:00
|
|
|
camera->mHorizontalFOV = AI_DEG_TO_RAD(45.f);
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
|
|
|
// Now check for further subchunks
|
2009-06-23 12:25:35 +00:00
|
|
|
if (!bIsPrj) /* fixme */ {
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
ParseCameraChunk();
|
2009-06-23 12:25:35 +00:00
|
|
|
}}
|
2008-10-31 19:32:00 +00:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseLightChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-10-31 19:32:00 +00:00
|
|
|
aiLight* light = mScene->mLights.back();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// get chunk type
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
case Discreet3DS::CHUNK_DL_SPOTLIGHT:
|
2008-11-30 22:27:20 +00:00
|
|
|
// Now we can be sure that the light is a spot light
|
|
|
|
light->mType = aiLightSource_SPOT;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// We wouldn't need to normalize here, but we do it
|
|
|
|
light->mDirection.x = stream->GetF4() - light->mPosition.x;
|
|
|
|
light->mDirection.y = stream->GetF4() - light->mPosition.y;
|
|
|
|
light->mDirection.z = stream->GetF4() - light->mPosition.z;
|
|
|
|
light->mDirection.Normalize();
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// Now the hotspot and falloff angles - in degrees
|
|
|
|
light->mAngleInnerCone = AI_DEG_TO_RAD( stream->GetF4() );
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// FIX: the falloff angle is just an offset
|
|
|
|
light->mAngleOuterCone = light->mAngleInnerCone+AI_DEG_TO_RAD( stream->GetF4() );
|
2008-10-31 19:32:00 +00:00
|
|
|
break;
|
2008-11-30 22:27:20 +00:00
|
|
|
|
|
|
|
// intensity multiplier
|
|
|
|
case Discreet3DS::CHUNK_DL_MULTIPLIER:
|
|
|
|
light->mColorDiffuse = light->mColorDiffuse * stream->GetF4();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// light color
|
|
|
|
case Discreet3DS::CHUNK_RGBF:
|
|
|
|
case Discreet3DS::CHUNK_LINRGBF:
|
|
|
|
light->mColorDiffuse.r *= stream->GetF4();
|
|
|
|
light->mColorDiffuse.g *= stream->GetF4();
|
|
|
|
light->mColorDiffuse.b *= stream->GetF4();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// light attenuation
|
|
|
|
case Discreet3DS::CHUNK_DL_ATTENUATE:
|
|
|
|
light->mAttenuationLinear = stream->GetF4();
|
|
|
|
break;
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void Discreet3DSImporter::ParseCameraChunk()
|
|
|
|
{
|
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
|
|
|
aiCamera* camera = mScene->mCameras.back();
|
|
|
|
|
|
|
|
// get chunk type
|
|
|
|
switch (chunk.Flag)
|
|
|
|
{
|
|
|
|
// near and far clip plane
|
|
|
|
case Discreet3DS::CHUNK_CAM_RANGES:
|
|
|
|
camera->mClipPlaneNear = stream->GetF4();
|
|
|
|
camera->mClipPlaneFar = stream->GetF4();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSIMP_3DS_END_CHUNK();
|
|
|
|
}
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseKeyframeChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// get chunk type
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKCAMTGT:
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKSPOTL:
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKCAMERA:
|
|
|
|
case Discreet3DS::CHUNK_TRACKINFO:
|
|
|
|
case Discreet3DS::CHUNK_TRACKLIGHT:
|
|
|
|
case Discreet3DS::CHUNK_TRACKLIGTGT:
|
|
|
|
|
|
|
|
// this starts a new mesh hierarchy chunk
|
|
|
|
ParseHierarchyChunk(chunk.Flag);
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
};
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Little helper function for ParseHierarchyChunk
|
|
|
|
void Discreet3DSImporter::InverseNodeSearch(D3DS::Node* pcNode,D3DS::Node* pcCurrent)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2009-04-09 21:37:49 +00:00
|
|
|
if (!pcCurrent) {
|
2008-10-31 19:32:00 +00:00
|
|
|
mRootNode->push_back(pcNode);
|
2008-05-05 12:36:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-04-09 21:37:49 +00:00
|
|
|
|
|
|
|
if (pcCurrent->mHierarchyPos == pcNode->mHierarchyPos) {
|
2009-06-23 12:25:35 +00:00
|
|
|
if(pcCurrent->mParent) {
|
2009-04-09 21:37:49 +00:00
|
|
|
pcCurrent->mParent->push_back(pcNode);
|
2009-06-23 12:25:35 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
else pcCurrent->push_back(pcNode);
|
|
|
|
return;
|
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
return InverseNodeSearch(pcNode,pcCurrent->mParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Find a node with a specific name in the import hierarchy
|
2008-10-31 19:32:00 +00:00
|
|
|
D3DS::Node* FindNode(D3DS::Node* root, const std::string& name)
|
|
|
|
{
|
2009-04-09 21:37:49 +00:00
|
|
|
if (root->mName == name)
|
|
|
|
return root;
|
|
|
|
for (std::vector<D3DS::Node*>::iterator it = root->mChildren.begin();it != root->mChildren.end(); ++it) {
|
2008-10-31 19:32:00 +00:00
|
|
|
D3DS::Node* nd;
|
2009-04-09 21:37:49 +00:00
|
|
|
if (( nd = FindNode(*it,name)))
|
|
|
|
return nd;
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Binary predicate for std::unique()
|
|
|
|
template <class T>
|
|
|
|
bool KeyUniqueCompare(const T& first, const T& second)
|
|
|
|
{
|
|
|
|
return first.mTime == second.mTime;
|
|
|
|
}
|
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Skip some additional import data.
|
2008-11-30 22:27:20 +00:00
|
|
|
void Discreet3DSImporter::SkipTCBInfo()
|
|
|
|
{
|
|
|
|
unsigned int flags = stream->GetI2();
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
if (!flags) {
|
2008-11-30 22:27:20 +00:00
|
|
|
// Currently we can't do anything with these values. They occur
|
|
|
|
// quite rare, so it wouldn't be worth the effort implementing
|
|
|
|
// them. 3DS ist not really suitable for complex animations,
|
|
|
|
// so full support is not required.
|
|
|
|
DefaultLogger::get()->warn("3DS: Skipping TCB animation info");
|
|
|
|
}
|
|
|
|
|
2009-06-23 12:25:35 +00:00
|
|
|
if (flags & Discreet3DS::KEY_USE_TENS) {
|
2008-11-30 22:27:20 +00:00
|
|
|
stream->IncPtr(4);
|
2009-06-23 12:25:35 +00:00
|
|
|
}
|
|
|
|
if (flags & Discreet3DS::KEY_USE_BIAS) {
|
2008-11-30 22:27:20 +00:00
|
|
|
stream->IncPtr(4);
|
2009-06-23 12:25:35 +00:00
|
|
|
}
|
|
|
|
if (flags & Discreet3DS::KEY_USE_CONT) {
|
2008-11-30 22:27:20 +00:00
|
|
|
stream->IncPtr(4);
|
2009-06-23 12:25:35 +00:00
|
|
|
}
|
|
|
|
if (flags & Discreet3DS::KEY_USE_EASE_FROM) {
|
2008-11-30 22:27:20 +00:00
|
|
|
stream->IncPtr(4);
|
2009-06-23 12:25:35 +00:00
|
|
|
}
|
|
|
|
if (flags & Discreet3DS::KEY_USE_EASE_TO) {
|
2008-11-30 22:27:20 +00:00
|
|
|
stream->IncPtr(4);
|
2009-06-23 12:25:35 +00:00
|
|
|
}
|
2008-11-30 22:27:20 +00:00
|
|
|
}
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Read hierarchy and keyframe info
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseHierarchyChunk(uint16_t parent)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// get chunk type
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKOBJNAME:
|
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
// This is the name of the object to which the track applies. The chunk also
|
|
|
|
// defines the position of this object in the hierarchy.
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// First of all: get the name of the object
|
|
|
|
unsigned int cnt = 0;
|
|
|
|
const char* sz = (const char*)stream->GetPtr();
|
|
|
|
|
|
|
|
while (stream->GetI1())++cnt;
|
|
|
|
std::string name = std::string(sz,cnt);
|
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
// Now find out whether we have this node already (target animation channels
|
|
|
|
// are stored with a separate object ID)
|
2008-10-31 19:32:00 +00:00
|
|
|
D3DS::Node* pcNode = FindNode(mRootNode,name);
|
2008-11-04 20:41:11 +00:00
|
|
|
if (pcNode)
|
2008-10-31 19:32:00 +00:00
|
|
|
{
|
2008-11-04 20:41:11 +00:00
|
|
|
// Make this node the current node
|
|
|
|
mCurrentNode = pcNode;
|
|
|
|
break;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-11-04 20:41:11 +00:00
|
|
|
pcNode = new D3DS::Node();
|
|
|
|
pcNode->mName = name;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// There are two unknown values which we can safely ignore
|
|
|
|
stream->IncPtr(4);
|
|
|
|
|
|
|
|
// Now read the hierarchy position of the object
|
|
|
|
uint16_t hierarchy = stream->GetI2() + 1;
|
|
|
|
pcNode->mHierarchyPos = hierarchy;
|
|
|
|
pcNode->mHierarchyIndex = mLastNodeIndex;
|
|
|
|
|
|
|
|
// And find a proper position in the graph for it
|
2009-06-23 12:25:35 +00:00
|
|
|
if (mCurrentNode && mCurrentNode->mHierarchyPos == hierarchy) {
|
|
|
|
|
2008-05-25 22:29:05 +00:00
|
|
|
// add to the parent of the last touched node
|
2008-10-31 19:32:00 +00:00
|
|
|
mCurrentNode->mParent->push_back(pcNode);
|
|
|
|
mLastNodeIndex++;
|
2008-05-25 22:29:05 +00:00
|
|
|
}
|
2009-06-23 12:25:35 +00:00
|
|
|
else if(hierarchy >= mLastNodeIndex) {
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// place it at the current position in the hierarchy
|
2008-10-31 19:32:00 +00:00
|
|
|
mCurrentNode->push_back(pcNode);
|
|
|
|
mLastNodeIndex = hierarchy;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2009-06-23 12:25:35 +00:00
|
|
|
else {
|
2008-05-05 12:36:31 +00:00
|
|
|
// need to go back to the specified position in the hierarchy.
|
2008-10-31 19:32:00 +00:00
|
|
|
InverseNodeSearch(pcNode,mCurrentNode);
|
|
|
|
mLastNodeIndex++;
|
|
|
|
}
|
|
|
|
// Make this node the current node
|
|
|
|
mCurrentNode = pcNode;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKDUMMYOBJNAME:
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// This is the "real" name of a $$$DUMMY object
|
|
|
|
{
|
2009-02-15 20:29:07 +00:00
|
|
|
const char* sz = (const char*) stream->GetPtr();
|
|
|
|
while (stream->GetI1());
|
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
// If object name is DUMMY, take this one instead
|
2009-02-15 20:29:07 +00:00
|
|
|
if (mCurrentNode->mName == "$$$DUMMY") {
|
|
|
|
//DefaultLogger::get()->warn("3DS: Skipping dummy object name for non-dummy object");
|
|
|
|
mCurrentNode->mName = std::string(sz);
|
2008-10-31 19:32:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKPIVOT:
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
if ( Discreet3DS::CHUNK_TRACKINFO != parent)
|
|
|
|
{
|
|
|
|
DefaultLogger::get()->warn("3DS: Skipping pivot subchunk for non usual object");
|
|
|
|
break;
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Pivot = origin of rotation and scaling
|
|
|
|
mCurrentNode->vPivot.x = stream->GetF4();
|
|
|
|
mCurrentNode->vPivot.y = stream->GetF4();
|
|
|
|
mCurrentNode->vPivot.z = stream->GetF4();
|
|
|
|
break;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// ////////////////////////////////////////////////////////////////////
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// POSITION KEYFRAME
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKPOS:
|
|
|
|
{
|
|
|
|
stream->IncPtr(10);
|
2008-11-30 22:27:20 +00:00
|
|
|
const unsigned int numFrames = stream->GetI4();
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
bool sortKeys = false;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// This could also be meant as the target position for
|
|
|
|
// (targeted) lights and cameras
|
|
|
|
std::vector<aiVectorKey>* l;
|
2009-06-23 12:25:35 +00:00
|
|
|
if ( Discreet3DS::CHUNK_TRACKCAMTGT == parent || Discreet3DS::CHUNK_TRACKLIGTGT == parent) {
|
2008-10-31 19:32:00 +00:00
|
|
|
l = & mCurrentNode->aTargetPositionKeys;
|
|
|
|
}
|
|
|
|
else l = & mCurrentNode->aPositionKeys;
|
2008-07-10 16:49:01 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
l->reserve(numFrames);
|
2009-06-23 12:25:35 +00:00
|
|
|
for (unsigned int i = 0; i < numFrames;++i) {
|
2008-11-30 22:27:20 +00:00
|
|
|
const unsigned int fidx = stream->GetI4();
|
2008-07-10 16:49:01 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Setup a new position key
|
|
|
|
aiVectorKey v;
|
|
|
|
v.mTime = (double)fidx;
|
2008-07-10 16:49:01 +00:00
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
SkipTCBInfo();
|
2008-10-31 19:32:00 +00:00
|
|
|
v.mValue.x = stream->GetF4();
|
|
|
|
v.mValue.y = stream->GetF4();
|
|
|
|
v.mValue.z = stream->GetF4();
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// check whether we'll need to sort the keys
|
|
|
|
if (!l->empty() && v.mTime <= l->back().mTime)
|
|
|
|
sortKeys = true;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Add the new keyframe to the list
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
l->push_back(v);
|
|
|
|
}
|
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// Sort all keys with ascending time values and remove duplicates?
|
2009-06-23 12:25:35 +00:00
|
|
|
if (sortKeys) {
|
2008-11-30 22:27:20 +00:00
|
|
|
std::stable_sort(l->begin(),l->end());
|
|
|
|
l->erase ( std::unique (l->begin(),l->end(),&KeyUniqueCompare<aiVectorKey>), l->end() );
|
2008-10-31 19:32:00 +00:00
|
|
|
}}
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
break;
|
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// ////////////////////////////////////////////////////////////////////
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// CAMERA ROLL KEYFRAME
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKROLL:
|
|
|
|
{
|
|
|
|
// roll keys are accepted for cameras only
|
2009-06-23 12:25:35 +00:00
|
|
|
if (parent != Discreet3DS::CHUNK_TRACKCAMERA) {
|
2008-10-31 19:32:00 +00:00
|
|
|
DefaultLogger::get()->warn("3DS: Ignoring roll track for non-camera object");
|
|
|
|
break;
|
2008-07-10 16:49:01 +00:00
|
|
|
}
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
bool sortKeys = false;
|
|
|
|
std::vector<aiFloatKey>* l = &mCurrentNode->aCameraRollKeys;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
stream->IncPtr(10);
|
2008-11-30 22:27:20 +00:00
|
|
|
const unsigned int numFrames = stream->GetI4();
|
2008-11-16 21:56:45 +00:00
|
|
|
l->reserve(numFrames);
|
2009-06-23 12:25:35 +00:00
|
|
|
for (unsigned int i = 0; i < numFrames;++i) {
|
2008-11-30 22:27:20 +00:00
|
|
|
const unsigned int fidx = stream->GetI4();
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// Setup a new position key
|
|
|
|
aiFloatKey v;
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
v.mTime = (double)fidx;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// This is just a single float
|
2008-11-30 22:27:20 +00:00
|
|
|
SkipTCBInfo();
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
v.mValue = stream->GetF4();
|
|
|
|
|
|
|
|
// Check whether we'll need to sort the keys
|
|
|
|
if (!l->empty() && v.mTime <= l->back().mTime)
|
|
|
|
sortKeys = true;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// Add the new keyframe to the list
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
l->push_back(v);
|
|
|
|
}
|
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// Sort all keys with ascending time values and remove duplicates?
|
2009-06-23 12:25:35 +00:00
|
|
|
if (sortKeys) {
|
2008-11-30 22:27:20 +00:00
|
|
|
std::stable_sort(l->begin(),l->end());
|
|
|
|
l->erase ( std::unique (l->begin(),l->end(),&KeyUniqueCompare<aiFloatKey>), l->end() );
|
2008-10-31 19:32:00 +00:00
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// ////////////////////////////////////////////////////////////////////
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// CAMERA FOV KEYFRAME
|
|
|
|
case Discreet3DS::CHUNK_TRACKFOV:
|
|
|
|
{
|
|
|
|
DefaultLogger::get()->error("3DS: Skipping FOV animation track. "
|
|
|
|
"This is not supported");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// ////////////////////////////////////////////////////////////////////
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// ROTATION KEYFRAME
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKROTATE:
|
2008-07-10 16:49:01 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
stream->IncPtr(10);
|
2008-11-30 22:27:20 +00:00
|
|
|
const unsigned int numFrames = stream->GetI4();
|
2008-07-10 16:49:01 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
bool sortKeys = false;
|
|
|
|
std::vector<aiQuatKey>* l = &mCurrentNode->aRotationKeys;
|
2008-11-16 21:56:45 +00:00
|
|
|
l->reserve(numFrames);
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
2009-06-23 12:25:35 +00:00
|
|
|
for (unsigned int i = 0; i < numFrames;++i) {
|
2008-11-30 22:27:20 +00:00
|
|
|
const unsigned int fidx = stream->GetI4();
|
|
|
|
SkipTCBInfo();
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
aiQuatKey v;
|
|
|
|
v.mTime = (double)fidx;
|
2008-07-10 16:49:01 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// The rotation keyframe is given as an axis-angle pair
|
2008-11-30 22:27:20 +00:00
|
|
|
const float rad = stream->GetF4();
|
2008-10-31 19:32:00 +00:00
|
|
|
aiVector3D axis;
|
|
|
|
axis.x = stream->GetF4();
|
|
|
|
axis.y = stream->GetF4();
|
|
|
|
axis.z = stream->GetF4();
|
2008-07-10 16:49:01 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
if (!axis.x && !axis.y && !axis.z)
|
|
|
|
axis.y = 1.f;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Construct a rotation quaternion from the axis-angle pair
|
|
|
|
v.mValue = aiQuaternion(axis,rad);
|
2008-07-10 16:49:01 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// Check whether we'll need to sort the keys
|
|
|
|
if (!l->empty() && v.mTime <= l->back().mTime)
|
|
|
|
sortKeys = true;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// add the new keyframe to the list
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
l->push_back(v);
|
|
|
|
}
|
2008-11-30 22:27:20 +00:00
|
|
|
// Sort all keys with ascending time values and remove duplicates?
|
2009-06-23 12:25:35 +00:00
|
|
|
if (sortKeys) {
|
2008-11-30 22:27:20 +00:00
|
|
|
std::stable_sort(l->begin(),l->end());
|
|
|
|
l->erase ( std::unique (l->begin(),l->end(),&KeyUniqueCompare<aiQuatKey>), l->end() );
|
2008-10-31 19:32:00 +00:00
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2009-01-20 21:41:17 +00:00
|
|
|
// ////////////////////////////////////////////////////////////////////
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// SCALING KEYFRAME
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRACKSCALE:
|
2008-07-10 16:49:01 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
stream->IncPtr(10);
|
2008-11-30 22:27:20 +00:00
|
|
|
const unsigned int numFrames = stream->GetI2();
|
2008-10-31 19:32:00 +00:00
|
|
|
stream->IncPtr(2);
|
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
bool sortKeys = false;
|
|
|
|
std::vector<aiVectorKey>* l = &mCurrentNode->aScalingKeys;
|
2008-11-16 21:56:45 +00:00
|
|
|
l->reserve(numFrames);
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
|
2009-06-23 12:25:35 +00:00
|
|
|
for (unsigned int i = 0; i < numFrames;++i) {
|
2008-11-30 22:27:20 +00:00
|
|
|
const unsigned int fidx = stream->GetI4();
|
|
|
|
SkipTCBInfo();
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// Setup a new key
|
2008-07-10 16:49:01 +00:00
|
|
|
aiVectorKey v;
|
2008-10-31 19:32:00 +00:00
|
|
|
v.mTime = (double)fidx;
|
2008-07-10 16:49:01 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// ... and read its value
|
|
|
|
v.mValue.x = stream->GetF4();
|
|
|
|
v.mValue.y = stream->GetF4();
|
|
|
|
v.mValue.z = stream->GetF4();
|
2008-07-10 16:49:01 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
// check whether we'll need to sort the keys
|
|
|
|
if (!l->empty() && v.mTime <= l->back().mTime)
|
|
|
|
sortKeys = true;
|
|
|
|
|
2009-06-23 12:25:35 +00:00
|
|
|
// Remove zero-scalings on singular axes - they've been reported to be there erroneously in some strange files
|
|
|
|
if (!v.mValue.x) v.mValue.x = 1.f;
|
|
|
|
if (!v.mValue.y) v.mValue.y = 1.f;
|
|
|
|
if (!v.mValue.z) v.mValue.z = 1.f;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
ASE: Added WIP support for *SMOOTHSKINMESH elements in ASE/ASC files. Fixes in the ASE loader. Fixed animation parsing. Temporary implementation of target lights and cameras, including animations.
3DS: Fixed transformation problems (Pivot points), added WIP animation support. No target animation yet (cameras, spot lights). Not yet fully tested, but static models that worked before should still work now, except all look correct now :-) (some problems with very large models remaining)
Further work on the IRR and IRRMESH loaders. IRR still WIP, IRRMESH more stable now.
Work on the LWo loader. Added support for the "one-layer-only" mode. Hierarchy bug still unfixed, UV coords bug still unfixed.
Further work on the FindInvalidDataprocess. Improved validation for normals, no false positives anymore.
Further work on the MDR loader, still WIP.
Moved DeterminePType-Step to ScenePreprocessor.
aiAnimation::mDuration is optional now, ScenePreprocessor computes it automatically if set to -1.
Fixes in the SMD loader. Still crashes on some files.
Updated animation documentation.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@236 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2008-11-09 23:17:19 +00:00
|
|
|
l->push_back(v);
|
2008-07-10 16:49:01 +00:00
|
|
|
}
|
2008-11-30 22:27:20 +00:00
|
|
|
// Sort all keys with ascending time values and remove duplicates?
|
2009-06-23 12:25:35 +00:00
|
|
|
if (sortKeys) {
|
2008-11-30 22:27:20 +00:00
|
|
|
std::stable_sort(l->begin(),l->end());
|
|
|
|
l->erase ( std::unique (l->begin(),l->end(),&KeyUniqueCompare<aiVectorKey>), l->end() );
|
2008-10-31 19:32:00 +00:00
|
|
|
}}
|
2008-07-10 16:49:01 +00:00
|
|
|
break;
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2009-01-18 23:48:25 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Read a face chunk - it contains smoothing groups and material assignments
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseFaceChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Get the mesh we're currently working on
|
|
|
|
D3DS::Mesh& mMesh = mScene->mMeshes.back();
|
|
|
|
|
|
|
|
// Get chunk type
|
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_SMOOLIST:
|
|
|
|
{
|
2009-04-09 21:37:49 +00:00
|
|
|
// This is the list of smoothing groups - a bitfield for every face.
|
|
|
|
// Up to 32 smoothing groups assigned to a single face.
|
2008-10-31 19:32:00 +00:00
|
|
|
unsigned int num = chunkSize/4, m = 0;
|
2009-04-09 21:37:49 +00:00
|
|
|
for (std::vector<D3DS::Face>::iterator i = mMesh.mFaces.begin(); m != num;++i, ++m) {
|
2008-05-05 12:36:31 +00:00
|
|
|
// nth bit is set for nth smoothing group
|
2008-10-31 19:32:00 +00:00
|
|
|
(*i).iSmoothGroup = stream->GetI4();
|
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_FACEMAT:
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
// at fist an asciiz with the material name
|
|
|
|
const char* sz = (const char*)stream->GetPtr();
|
|
|
|
while (stream->GetI1());
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// find the index of the material
|
2008-10-31 19:32:00 +00:00
|
|
|
unsigned int idx = 0xcdcdcdcd, cnt = 0;
|
2009-04-09 21:37:49 +00:00
|
|
|
for (std::vector<D3DS::Material>::const_iterator i = mScene->mMaterials.begin();i != mScene->mMaterials.end();++i,++cnt) {
|
|
|
|
// use case independent comparisons. hopefully it will work.
|
|
|
|
if ((*i).mName.length() && !ASSIMP_stricmp(sz, (*i).mName.c_str())) {
|
2008-10-31 19:32:00 +00:00
|
|
|
idx = cnt;
|
|
|
|
break;
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-09 21:37:49 +00:00
|
|
|
if (0xcdcdcdcd == idx) {
|
2008-10-31 19:32:00 +00:00
|
|
|
DefaultLogger::get()->error(std::string("3DS: Unknown material: ") + sz);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Now continue and read all material indices
|
2008-11-16 21:56:45 +00:00
|
|
|
cnt = (uint16_t)stream->GetI2();
|
2009-01-20 21:41:17 +00:00
|
|
|
for (unsigned int i = 0; i < cnt;++i) {
|
2008-10-31 19:32:00 +00:00
|
|
|
unsigned int fidx = (uint16_t)stream->GetI2();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// check range
|
2009-01-20 21:41:17 +00:00
|
|
|
if (fidx >= mMesh.mFaceMaterials.size()) {
|
2008-10-31 19:32:00 +00:00
|
|
|
DefaultLogger::get()->error("3DS: Invalid face index in face material list");
|
2008-06-22 10:09:26 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
else mMesh.mFaceMaterials[fidx] = idx;
|
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
};
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2009-01-18 23:48:25 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Read a mesh chunk. Here's the actual mesh data
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseMeshChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
// Get the mesh we're currently working on
|
|
|
|
D3DS::Mesh& mMesh = mScene->mMeshes.back();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// get chunk type
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_VERTLIST:
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
// This is the list of all vertices in the current mesh
|
2008-11-16 21:56:45 +00:00
|
|
|
int num = (int)(uint16_t)stream->GetI2();
|
|
|
|
mMesh.mPositions.reserve(num);
|
2009-04-09 21:37:49 +00:00
|
|
|
while (num-- > 0) {
|
2008-10-31 19:32:00 +00:00
|
|
|
aiVector3D v;
|
|
|
|
v.x = stream->GetF4();
|
|
|
|
v.y = stream->GetF4();
|
|
|
|
v.z = stream->GetF4();
|
|
|
|
mMesh.mPositions.push_back(v);
|
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_TRMATRIX:
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2009-04-09 21:37:49 +00:00
|
|
|
// This is the RLEATIVE transformation matrix of the current mesh. Vertices are
|
|
|
|
// pretransformed by this matrix wonder.
|
2008-10-31 19:32:00 +00:00
|
|
|
mMesh.mMat.a1 = stream->GetF4();
|
|
|
|
mMesh.mMat.b1 = stream->GetF4();
|
|
|
|
mMesh.mMat.c1 = stream->GetF4();
|
|
|
|
mMesh.mMat.a2 = stream->GetF4();
|
|
|
|
mMesh.mMat.b2 = stream->GetF4();
|
|
|
|
mMesh.mMat.c2 = stream->GetF4();
|
|
|
|
mMesh.mMat.a3 = stream->GetF4();
|
|
|
|
mMesh.mMat.b3 = stream->GetF4();
|
|
|
|
mMesh.mMat.c3 = stream->GetF4();
|
|
|
|
mMesh.mMat.a4 = stream->GetF4();
|
|
|
|
mMesh.mMat.b4 = stream->GetF4();
|
|
|
|
mMesh.mMat.c4 = stream->GetF4();
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAPLIST:
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
// This is the list of all UV coords in the current mesh
|
2008-11-16 21:56:45 +00:00
|
|
|
int num = (int)(uint16_t)stream->GetI2();
|
|
|
|
mMesh.mTexCoords.reserve(num);
|
2009-04-09 21:37:49 +00:00
|
|
|
while (num-- > 0) {
|
2008-11-16 21:56:45 +00:00
|
|
|
aiVector3D v;
|
2008-10-31 19:32:00 +00:00
|
|
|
v.x = stream->GetF4();
|
|
|
|
v.y = stream->GetF4();
|
|
|
|
mMesh.mTexCoords.push_back(v);
|
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_FACELIST:
|
|
|
|
{
|
|
|
|
// This is the list of all faces in the current mesh
|
2008-11-16 21:56:45 +00:00
|
|
|
int num = (int)(uint16_t)stream->GetI2();
|
|
|
|
mMesh.mFaces.reserve(num);
|
2009-04-09 21:37:49 +00:00
|
|
|
while (num-- > 0) {
|
2008-10-31 19:32:00 +00:00
|
|
|
// 3DS faces are ALWAYS triangles
|
|
|
|
mMesh.mFaces.push_back(D3DS::Face());
|
|
|
|
D3DS::Face& sFace = mMesh.mFaces.back();
|
|
|
|
|
|
|
|
sFace.mIndices[0] = (uint16_t)stream->GetI2();
|
|
|
|
sFace.mIndices[1] = (uint16_t)stream->GetI2();
|
|
|
|
sFace.mIndices[2] = (uint16_t)stream->GetI2();
|
|
|
|
|
|
|
|
stream->IncPtr(2); // skip edge visibility flag
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
// Resize the material array (0xcdcdcdcd marks the default material; so if a face is
|
|
|
|
// not referenced by a material, $$DEFAULT will be assigned to it)
|
2008-05-05 12:36:31 +00:00
|
|
|
mMesh.mFaceMaterials.resize(mMesh.mFaces.size(),0xcdcdcdcd);
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Larger 3DS files could have multiple FACE chunks here
|
|
|
|
chunkSize = stream->GetRemainingSizeToLimit();
|
2009-12-24 11:40:16 +00:00
|
|
|
if ( chunkSize > (int) sizeof(Discreet3DS::Chunk ) )
|
2008-10-31 19:32:00 +00:00
|
|
|
ParseFaceChunk();
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
};
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Read a 3DS material chunk
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseMaterialChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_MATNAME:
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
{
|
2009-04-09 21:37:49 +00:00
|
|
|
// The material name string is already zero-terminated, but we need to be sure ...
|
2008-10-31 19:32:00 +00:00
|
|
|
const char* sz = (const char*)stream->GetPtr();
|
|
|
|
unsigned int cnt = 0;
|
2009-04-09 21:37:49 +00:00
|
|
|
while (stream->GetI1())
|
|
|
|
++cnt;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
if (!cnt) {
|
2008-10-31 19:32:00 +00:00
|
|
|
// This may not be, we use the default name instead
|
|
|
|
DefaultLogger::get()->error("3DS: Empty material name");
|
|
|
|
}
|
|
|
|
else mScene->mMaterials.back().mName = std::string(sz,cnt);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_DIFFUSE:
|
|
|
|
{
|
|
|
|
// This is the diffuse material color
|
|
|
|
aiColor3D* pc = &mScene->mMaterials.back().mDiffuse;
|
|
|
|
ParseColorChunk(pc);
|
2009-02-11 20:56:05 +00:00
|
|
|
if (is_qnan(pc->r)) {
|
2008-05-05 12:36:31 +00:00
|
|
|
// color chunk is invalid. Simply ignore it
|
2008-11-30 22:27:20 +00:00
|
|
|
DefaultLogger::get()->error("3DS: Unable to read DIFFUSE chunk");
|
2008-05-05 12:36:31 +00:00
|
|
|
pc->r = pc->g = pc->b = 1.0f;
|
2008-10-31 19:32:00 +00:00
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_SPECULAR:
|
|
|
|
{
|
|
|
|
// This is the specular material color
|
|
|
|
aiColor3D* pc = &mScene->mMaterials.back().mSpecular;
|
|
|
|
ParseColorChunk(pc);
|
2009-02-11 20:56:05 +00:00
|
|
|
if (is_qnan(pc->r)) {
|
2008-05-05 12:36:31 +00:00
|
|
|
// color chunk is invalid. Simply ignore it
|
2008-11-30 22:27:20 +00:00
|
|
|
DefaultLogger::get()->error("3DS: Unable to read SPECULAR chunk");
|
2008-05-05 12:36:31 +00:00
|
|
|
pc->r = pc->g = pc->b = 1.0f;
|
2008-10-31 19:32:00 +00:00
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_AMBIENT:
|
|
|
|
{
|
|
|
|
// This is the ambient material color
|
|
|
|
aiColor3D* pc = &mScene->mMaterials.back().mAmbient;
|
|
|
|
ParseColorChunk(pc);
|
2009-02-11 20:56:05 +00:00
|
|
|
if (is_qnan(pc->r)) {
|
2008-05-05 12:36:31 +00:00
|
|
|
// color chunk is invalid. Simply ignore it
|
2008-11-30 22:27:20 +00:00
|
|
|
DefaultLogger::get()->error("3DS: Unable to read AMBIENT chunk");
|
2008-10-31 19:32:00 +00:00
|
|
|
pc->r = pc->g = pc->b = 0.0f;
|
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_SELF_ILLUM:
|
|
|
|
{
|
|
|
|
// This is the emissive material color
|
|
|
|
aiColor3D* pc = &mScene->mMaterials.back().mEmissive;
|
|
|
|
ParseColorChunk(pc);
|
2009-02-11 20:56:05 +00:00
|
|
|
if (is_qnan(pc->r)) {
|
2008-05-05 12:36:31 +00:00
|
|
|
// color chunk is invalid. Simply ignore it
|
2008-11-30 22:27:20 +00:00
|
|
|
DefaultLogger::get()->error("3DS: Unable to read EMISSIVE chunk");
|
2008-05-05 12:36:31 +00:00
|
|
|
pc->r = pc->g = pc->b = 0.0f;
|
2008-10-31 19:32:00 +00:00
|
|
|
}}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_TRANSPARENCY:
|
|
|
|
{
|
|
|
|
// This is the material's transparency
|
|
|
|
float* pcf = &mScene->mMaterials.back().mTransparency;
|
|
|
|
*pcf = ParsePercentageChunk();
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// NOTE: transparency, not opacity
|
2009-04-09 21:37:49 +00:00
|
|
|
if (is_qnan(*pcf))
|
|
|
|
*pcf = 1.0f;
|
2008-05-30 23:01:25 +00:00
|
|
|
else *pcf = 1.0f - *pcf * (float)0xFFFF / 100.0f;
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_SHADING:
|
|
|
|
// This is the material shading mode
|
|
|
|
mScene->mMaterials.back().mShading = (D3DS::Discreet3DS::shadetype3ds)stream->GetI2();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_TWO_SIDE:
|
|
|
|
// This is the two-sided flag
|
|
|
|
mScene->mMaterials.back().mTwoSided = true;
|
2008-06-03 21:50:53 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_SHININESS:
|
|
|
|
{ // This is the shininess of the material
|
|
|
|
float* pcf = &mScene->mMaterials.back().mSpecularExponent;
|
|
|
|
*pcf = ParsePercentageChunk();
|
2009-04-09 21:37:49 +00:00
|
|
|
if (is_qnan(*pcf))
|
|
|
|
*pcf = 0.0f;
|
2008-05-05 12:36:31 +00:00
|
|
|
else *pcf *= (float)0xFFFF;
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_SHININESS_PERCENT:
|
|
|
|
{ // This is the shininess strength of the material
|
|
|
|
float* pcf = &mScene->mMaterials.back().mShininessStrength;
|
|
|
|
*pcf = ParsePercentageChunk();
|
2009-04-09 21:37:49 +00:00
|
|
|
if (is_qnan(*pcf))
|
|
|
|
*pcf = 0.0f;
|
2008-05-25 22:29:05 +00:00
|
|
|
else *pcf *= (float)0xffff / 100.0f;
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
2008-05-25 22:29:05 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_SELF_ILPCT:
|
|
|
|
{ // This is the self illumination strength of the material
|
2008-11-30 22:27:20 +00:00
|
|
|
float f = ParsePercentageChunk();
|
2009-04-09 21:37:49 +00:00
|
|
|
if (is_qnan(f))
|
|
|
|
f = 0.0f;
|
2008-11-30 22:27:20 +00:00
|
|
|
else f *= (float)0xFFFF / 100.0f;
|
|
|
|
mScene->mMaterials.back().mEmissive = aiColor3D(f,f,f);
|
2008-10-31 19:32:00 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Parse texture chunks
|
|
|
|
case Discreet3DS::CHUNK_MAT_TEXTURE:
|
|
|
|
// Diffuse texture
|
|
|
|
ParseTextureChunk(&mScene->mMaterials.back().sTexDiffuse);
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_BUMPMAP:
|
|
|
|
// Height map
|
|
|
|
ParseTextureChunk(&mScene->mMaterials.back().sTexBump);
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_OPACMAP:
|
|
|
|
// Opacity texture
|
|
|
|
ParseTextureChunk(&mScene->mMaterials.back().sTexOpacity);
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_MAT_SHINMAP:
|
|
|
|
// Shininess map
|
|
|
|
ParseTextureChunk(&mScene->mMaterials.back().sTexShininess);
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_SPECMAP:
|
|
|
|
// Specular map
|
|
|
|
ParseTextureChunk(&mScene->mMaterials.back().sTexSpecular);
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_SELFIMAP:
|
|
|
|
// Self-illumination (emissive) map
|
|
|
|
ParseTextureChunk(&mScene->mMaterials.back().sTexEmissive);
|
|
|
|
break;
|
|
|
|
case Discreet3DS::CHUNK_MAT_REFLMAP:
|
2009-02-11 20:56:05 +00:00
|
|
|
// Reflection map
|
|
|
|
ParseTextureChunk(&mScene->mMaterials.back().sTexReflective);
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
};
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-11-16 21:56:45 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_BEGIN_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// get chunk type
|
2008-10-31 19:32:00 +00:00
|
|
|
switch (chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAPFILE:
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2009-04-09 21:37:49 +00:00
|
|
|
// The material name string is already zero-terminated, but we need to be sure ...
|
2008-10-31 19:32:00 +00:00
|
|
|
const char* sz = (const char*)stream->GetPtr();
|
|
|
|
unsigned int cnt = 0;
|
2009-04-09 21:37:49 +00:00
|
|
|
while (stream->GetI1())
|
|
|
|
++cnt;
|
2008-10-31 19:32:00 +00:00
|
|
|
pcOut->mMapName = std::string(sz,cnt);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_PERCENTF:
|
|
|
|
// Manually parse the blend factor
|
|
|
|
pcOut->mTextureBlend = stream->GetF4();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_PERCENTW:
|
|
|
|
// Manually parse the blend factor
|
|
|
|
pcOut->mTextureBlend = (float)((uint16_t)stream->GetI2()) / 100.0f;
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_MAP_USCALE:
|
|
|
|
// Texture coordinate scaling in the U direction
|
|
|
|
pcOut->mScaleU = stream->GetF4();
|
2008-06-01 12:46:17 +00:00
|
|
|
if (0.0f == pcOut->mScaleU)
|
|
|
|
{
|
2009-04-09 21:37:49 +00:00
|
|
|
DefaultLogger::get()->warn("Texture coordinate scaling in the x direction is zero. Assuming 1.");
|
2008-06-01 12:46:17 +00:00
|
|
|
pcOut->mScaleU = 1.0f;
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_MAT_MAP_VSCALE:
|
|
|
|
// Texture coordinate scaling in the V direction
|
|
|
|
pcOut->mScaleV = stream->GetF4();
|
2008-06-01 12:46:17 +00:00
|
|
|
if (0.0f == pcOut->mScaleV)
|
|
|
|
{
|
2009-04-09 21:37:49 +00:00
|
|
|
DefaultLogger::get()->warn("Texture coordinate scaling in the y direction is zero. Assuming 1.");
|
2008-06-01 12:46:17 +00:00
|
|
|
pcOut->mScaleV = 1.0f;
|
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_MAP_UOFFSET:
|
|
|
|
// Texture coordinate offset in the U direction
|
2008-11-16 21:56:45 +00:00
|
|
|
pcOut->mOffsetU = -stream->GetF4();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_MAP_VOFFSET:
|
|
|
|
// Texture coordinate offset in the V direction
|
|
|
|
pcOut->mOffsetV = stream->GetF4();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_MAP_ANG:
|
2008-11-16 21:56:45 +00:00
|
|
|
// Texture coordinate rotation, CCW in DEGREES
|
|
|
|
pcOut->mRotation = -AI_DEG_TO_RAD( stream->GetF4() );
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_MAT_MAP_TILING:
|
|
|
|
{
|
2008-11-30 22:27:20 +00:00
|
|
|
const uint16_t iFlags = stream->GetI2();
|
2008-06-03 21:50:53 +00:00
|
|
|
|
2008-11-16 21:56:45 +00:00
|
|
|
// Get the mapping mode (for both axes)
|
2008-06-03 21:50:53 +00:00
|
|
|
if (iFlags & 0x2u)
|
|
|
|
pcOut->mMapMode = aiTextureMapMode_Mirror;
|
2008-11-16 21:56:45 +00:00
|
|
|
|
|
|
|
else if (iFlags & 0x10u)
|
|
|
|
pcOut->mMapMode = aiTextureMapMode_Decal;
|
|
|
|
|
|
|
|
// wrapping in all remaining cases
|
|
|
|
else pcOut->mMapMode = aiTextureMapMode_Wrap;
|
2008-06-03 21:50:53 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|
|
|
|
|
2008-08-28 17:35:36 +00:00
|
|
|
ASSIMP_3DS_END_CHUNK();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-10-31 19:32:00 +00:00
|
|
|
// Read a percentage chunk
|
|
|
|
float Discreet3DSImporter::ParsePercentageChunk()
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
Discreet3DS::Chunk chunk;
|
|
|
|
ReadChunk(&chunk);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag)
|
|
|
|
return stream->GetF4();
|
|
|
|
else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag)
|
|
|
|
return (float)((uint16_t)stream->GetI2()) / (float)0xFFFF;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return get_qnan();
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
2008-10-31 19:32:00 +00:00
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-11-30 22:27:20 +00:00
|
|
|
// Read a color chunk. If a percentage chunk is found instead it is read as a grayscale color
|
|
|
|
void Discreet3DSImporter::ParseColorChunk(aiColor3D* out,
|
|
|
|
bool acceptPercent)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-11-30 22:27:20 +00:00
|
|
|
ai_assert(out != NULL);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
// error return value
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
const float qnan = get_qnan();
|
2008-11-30 22:27:20 +00:00
|
|
|
static const aiColor3D clrError = aiColor3D(qnan,qnan,qnan);
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
Discreet3DS::Chunk chunk;
|
|
|
|
ReadChunk(&chunk);
|
|
|
|
const unsigned int diff = chunk.Size - sizeof(Discreet3DS::Chunk);
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
bool bGamma = false;
|
2008-09-27 16:46:05 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
// Get the type of the chunk
|
|
|
|
switch(chunk.Flag)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_LINRGBF:
|
2008-05-05 12:36:31 +00:00
|
|
|
bGamma = true;
|
2008-09-27 16:46:05 +00:00
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_RGBF:
|
2009-06-23 12:25:35 +00:00
|
|
|
if (sizeof(float) * 3 > diff) {
|
2008-11-30 22:27:20 +00:00
|
|
|
*out = clrError;
|
2008-05-05 12:36:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-11-30 22:27:20 +00:00
|
|
|
out->r = stream->GetF4();
|
|
|
|
out->g = stream->GetF4();
|
|
|
|
out->b = stream->GetF4();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_LINRGBB:
|
2008-05-05 12:36:31 +00:00
|
|
|
bGamma = true;
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_RGBB:
|
2009-06-23 12:25:35 +00:00
|
|
|
if (sizeof(char) * 3 > diff) {
|
2008-11-30 22:27:20 +00:00
|
|
|
*out = clrError;
|
2008-05-05 12:36:31 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-11-30 22:27:20 +00:00
|
|
|
out->r = (float)(uint8_t)stream->GetI1() / 255.0f;
|
|
|
|
out->g = (float)(uint8_t)stream->GetI1() / 255.0f;
|
|
|
|
out->b = (float)(uint8_t)stream->GetI1() / 255.0f;
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
|
2008-11-30 22:27:20 +00:00
|
|
|
// Percentage chunks are accepted, too.
|
2008-10-31 19:32:00 +00:00
|
|
|
case Discreet3DS::CHUNK_PERCENTF:
|
2009-06-23 12:25:35 +00:00
|
|
|
if (acceptPercent && 4 <= diff) {
|
2008-11-30 22:27:20 +00:00
|
|
|
out->g = out->b = out->r = stream->GetF4();
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-30 22:27:20 +00:00
|
|
|
*out = clrError;
|
2008-05-05 12:36:31 +00:00
|
|
|
return;
|
2008-10-31 19:32:00 +00:00
|
|
|
|
|
|
|
case Discreet3DS::CHUNK_PERCENTW:
|
2009-06-23 12:25:35 +00:00
|
|
|
if (acceptPercent && 1 <= diff) {
|
2008-11-30 22:27:20 +00:00
|
|
|
out->g = out->b = out->r = (float)(uint8_t)stream->GetI1() / 255.0f;
|
2008-05-05 12:36:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-30 22:27:20 +00:00
|
|
|
*out = clrError;
|
2008-05-05 12:36:31 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2008-11-30 22:27:20 +00:00
|
|
|
stream->IncPtr(diff);
|
|
|
|
// Skip unknown chunks, hope this won't cause any problems.
|
|
|
|
return ParseColorChunk(out,acceptPercent);
|
2008-05-05 12:36:31 +00:00
|
|
|
};
|
|
|
|
}
|
2009-01-18 23:48:25 +00:00
|
|
|
|
|
|
|
#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER
|