2008-08-28 17:35:36 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
Open Asset Import Library (ASSIMP)
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2010-04-10 15:30:22 +00:00
|
|
|
Copyright (c) 2006-2010, ASSIMP Development Team
|
2008-08-28 17:35:36 +00:00
|
|
|
|
|
|
|
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 DXFLoader.cpp
|
|
|
|
* @brief Implementation of the DXF importer class
|
|
|
|
*/
|
2008-10-13 16:45:48 +00:00
|
|
|
|
|
|
|
#include "AssimpPCH.h"
|
2009-01-18 23:48:25 +00:00
|
|
|
#ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
|
2008-10-13 16:45:48 +00:00
|
|
|
|
2008-08-28 17:35:36 +00:00
|
|
|
#include "DXFLoader.h"
|
2008-09-05 13:21:01 +00:00
|
|
|
#include "ParsingUtils.h"
|
2009-04-02 15:16:01 +00:00
|
|
|
#include "ConvertToLHProcess.h"
|
2008-09-05 13:21:01 +00:00
|
|
|
#include "fast_atof.h"
|
2008-08-28 17:35:36 +00:00
|
|
|
|
|
|
|
using namespace Assimp;
|
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
// AutoCAD Binary DXF<CR><LF><SUB><NULL>
|
|
|
|
#define AI_DXF_BINARY_IDENT ("AutoCAD Binary DXF\r\n\x1a\0")
|
|
|
|
#define AI_DXF_BINARY_IDENT_LEN (24)
|
|
|
|
|
2008-09-20 15:55:51 +00:00
|
|
|
// color indices for DXF - 16 are supported
|
|
|
|
static aiColor4D g_aclrDxfIndexColors[] =
|
|
|
|
{
|
|
|
|
aiColor4D (0.6f, 0.6f, 0.6f, 1.0f),
|
|
|
|
aiColor4D (1.0f, 0.0f, 0.0f, 1.0f), // red
|
|
|
|
aiColor4D (0.0f, 1.0f, 0.0f, 1.0f), // green
|
|
|
|
aiColor4D (0.0f, 0.0f, 1.0f, 1.0f), // blue
|
|
|
|
aiColor4D (0.3f, 1.0f, 0.3f, 1.0f), // light green
|
|
|
|
aiColor4D (0.3f, 0.3f, 1.0f, 1.0f), // light blue
|
|
|
|
aiColor4D (1.0f, 0.3f, 0.3f, 1.0f), // light red
|
|
|
|
aiColor4D (1.0f, 0.0f, 1.0f, 1.0f), // pink
|
|
|
|
aiColor4D (1.0f, 0.6f, 0.0f, 1.0f), // orange
|
|
|
|
aiColor4D (0.6f, 0.3f, 0.0f, 1.0f), // dark orange
|
|
|
|
aiColor4D (1.0f, 1.0f, 0.0f, 1.0f), // yellow
|
|
|
|
aiColor4D (0.3f, 0.3f, 0.3f, 1.0f), // dark gray
|
|
|
|
aiColor4D (0.8f, 0.8f, 0.8f, 1.0f), // light gray
|
|
|
|
aiColor4D (0.0f, 00.f, 0.0f, 1.0f), // black
|
|
|
|
aiColor4D (1.0f, 1.0f, 1.0f, 1.0f), // white
|
|
|
|
aiColor4D (0.6f, 0.0f, 1.0f, 1.0f) // violet
|
|
|
|
};
|
|
|
|
#define AI_DXF_NUM_INDEX_COLORS (sizeof(g_aclrDxfIndexColors)/sizeof(g_aclrDxfIndexColors[0]))
|
|
|
|
|
|
|
|
// invalid/unassigned color 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
|
|
|
aiColor4D g_clrInvalid = aiColor4D(get_qnan(),0.f,0.f,1.f);
|
2008-09-20 15:55:51 +00:00
|
|
|
|
2008-08-28 17:35:36 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Constructor to be privately used by Importer
|
|
|
|
DXFImporter::DXFImporter()
|
2009-03-15 00:40:30 +00:00
|
|
|
{}
|
2008-08-28 17:35:36 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Destructor, private as well
|
|
|
|
DXFImporter::~DXFImporter()
|
2009-03-15 00:40:30 +00:00
|
|
|
{}
|
2008-08-28 17:35:36 +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 DXFImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
2008-08-28 17:35:36 +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
|
|
|
return SimpleExtensionCheck(pFile,"dxf");
|
|
|
|
}
|
2008-08-28 17:35:36 +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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-03-15 00:40:30 +00:00
|
|
|
// Get a list of all supported file extensions
|
2010-03-02 17:38:01 +00:00
|
|
|
void DXFImporter::GetExtensionList(std::set<std::string>& extensions)
|
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
|
|
|
{
|
2010-03-02 17:38:01 +00:00
|
|
|
extensions.insert("dxf");
|
2008-08-28 17:35:36 +00:00
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Get a copy of the next data line, skip strange data
|
2008-09-05 13:21:01 +00:00
|
|
|
bool DXFImporter::GetNextLine()
|
|
|
|
{
|
2008-09-27 16:46:05 +00:00
|
|
|
if(!SkipLine(&buffer))
|
|
|
|
return false;
|
2009-04-09 21:37:49 +00:00
|
|
|
if(!SkipSpaces(&buffer))
|
|
|
|
return GetNextLine();
|
2009-03-15 00:40:30 +00:00
|
|
|
else if (*buffer == '{') {
|
2008-10-31 19:32:00 +00:00
|
|
|
// some strange meta data ...
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
if(!SkipLine(&buffer))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(SkipSpaces(&buffer) && *buffer == '}')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return GetNextLine();
|
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2009-01-18 23:48:25 +00:00
|
|
|
// Get the next token in the file
|
2008-09-05 13:21:01 +00:00
|
|
|
bool DXFImporter::GetNextToken()
|
|
|
|
{
|
2009-03-15 00:40:30 +00:00
|
|
|
if (bRepeat) {
|
2008-09-16 16:17:32 +00:00
|
|
|
bRepeat = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-09-07 16:51:05 +00:00
|
|
|
SkipSpaces(&buffer);
|
2008-09-05 13:21:01 +00:00
|
|
|
groupCode = strtol10s(buffer,&buffer);
|
2009-04-09 21:37:49 +00:00
|
|
|
if(!GetNextLine())
|
|
|
|
return false;
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
// copy the data line to a separate buffer
|
2008-09-07 16:51:05 +00:00
|
|
|
char* m = cursor, *end = &cursor[4096];
|
2009-04-09 21:37:49 +00:00
|
|
|
while (!IsSpaceOrNewLine( *buffer ) && m < end)
|
2008-09-05 13:21:01 +00:00
|
|
|
*m++ = *buffer++;
|
|
|
|
|
|
|
|
*m = '\0';
|
|
|
|
GetNextLine();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-08-28 17:35:36 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
// Imports the given file into the given scene structure.
|
|
|
|
void DXFImporter::InternReadFile( const std::string& pFile,
|
|
|
|
aiScene* pScene, IOSystem* pIOHandler)
|
|
|
|
{
|
|
|
|
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile));
|
|
|
|
|
|
|
|
// Check whether we can read from the file
|
2009-08-21 22:49:58 +00:00
|
|
|
if( file.get() == NULL) {
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError( "Failed to open DXF file " + pFile + "");
|
2009-08-21 22:49:58 +00:00
|
|
|
}
|
2008-08-28 17:35:36 +00:00
|
|
|
|
2008-09-05 13:21:01 +00:00
|
|
|
// read the contents of the file in a buffer
|
2009-08-21 22:49:58 +00:00
|
|
|
std::vector<char> buffer2;
|
|
|
|
TextFileToBuffer(file.get(),buffer2);
|
2008-09-05 13:21:01 +00:00
|
|
|
buffer = &buffer2[0];
|
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
bRepeat = false;
|
2008-09-05 13:21:01 +00:00
|
|
|
mDefaultLayer = NULL;
|
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
// check whether this is a binaray DXF file - we can't read binary DXF files :-(
|
|
|
|
if (!strncmp(AI_DXF_BINARY_IDENT,buffer,AI_DXF_BINARY_IDENT_LEN))
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError("DXF: Binary files are not supported at the moment");
|
2008-09-16 16:17:32 +00:00
|
|
|
|
2008-09-05 13:21:01 +00:00
|
|
|
// now get all lines of the file
|
2009-03-15 00:40:30 +00:00
|
|
|
while (GetNextToken()) {
|
|
|
|
|
|
|
|
if (2 == groupCode) {
|
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
// ENTITIES and BLOCKS sections - skip the whole rest, no need to waste our time with them
|
2009-04-09 21:37:49 +00:00
|
|
|
if (!::strcmp(cursor,"ENTITIES") || !::strcmp(cursor,"BLOCKS")) {
|
|
|
|
if (!ParseEntities())
|
|
|
|
break;
|
|
|
|
else bRepeat = true;
|
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
// other sections - skip them to make sure there will be no name conflicts
|
2009-03-15 00:40:30 +00:00
|
|
|
else {
|
2009-04-09 21:37:49 +00:00
|
|
|
while ( GetNextToken()) {
|
|
|
|
if (!::strcmp(cursor,"ENDSEC"))
|
|
|
|
break;
|
2008-09-05 13:21:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// print comment strings
|
2009-03-15 00:40:30 +00:00
|
|
|
else if (999 == groupCode) {
|
2008-09-05 13:21:01 +00:00
|
|
|
DefaultLogger::get()->info(std::string( cursor ));
|
|
|
|
}
|
|
|
|
else if (!groupCode && !::strcmp(cursor,"EOF"))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
// find out how many valud layers we have
|
2009-03-15 00:40:30 +00:00
|
|
|
for (std::vector<LayerInfo>::const_iterator it = mLayers.begin(),end = mLayers.end(); it != end;++it) {
|
2009-04-09 21:37:49 +00:00
|
|
|
if (!(*it).vPositions.empty())
|
|
|
|
++pScene->mNumMeshes;
|
2008-09-16 16:17:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pScene->mNumMeshes)
|
2010-03-18 17:00:12 +00:00
|
|
|
throw DeadlyImportError("DXF: this file contains no 3d data");
|
2008-09-05 13:21:01 +00:00
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
|
2009-08-21 22:49:58 +00:00
|
|
|
unsigned int m = 0;
|
2009-03-15 00:40:30 +00:00
|
|
|
for (std::vector<LayerInfo>::const_iterator it = mLayers.begin(),end = mLayers.end();it != end;++it) {
|
|
|
|
if ((*it).vPositions.empty()) {
|
|
|
|
continue;
|
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
// generate the output mesh
|
|
|
|
aiMesh* pMesh = pScene->mMeshes[m++] = new aiMesh();
|
|
|
|
const std::vector<aiVector3D>& vPositions = (*it).vPositions;
|
2008-09-20 15:55:51 +00:00
|
|
|
const std::vector<aiColor4D>& vColors = (*it).vColors;
|
|
|
|
|
|
|
|
// check whether we need vertex colors here
|
2009-01-08 22:15:05 +00:00
|
|
|
aiColor4D* clrOut = NULL;
|
2008-09-20 15:55:51 +00:00
|
|
|
const aiColor4D* clr = NULL;
|
2009-03-15 00:40:30 +00:00
|
|
|
for (std::vector<aiColor4D>::const_iterator it2 = (*it).vColors.begin(), end2 = (*it).vColors.end();it2 != end2; ++it2) {
|
|
|
|
|
|
|
|
if ((*it2).r == (*it2).r) /* qnan? */ {
|
2008-09-20 15:55:51 +00:00
|
|
|
clrOut = pMesh->mColors[0] = new aiColor4D[vPositions.size()];
|
2008-09-27 16:46:05 +00:00
|
|
|
for (unsigned int i = 0; i < vPositions.size();++i)
|
|
|
|
clrOut[i] = aiColor4D(0.6f,0.6f,0.6f,1.0f);
|
|
|
|
|
2008-09-20 15:55:51 +00:00
|
|
|
clr = &vColors[0];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
pMesh->mNumFaces = (unsigned int)vPositions.size() / 4u;
|
|
|
|
pMesh->mFaces = new aiFace[pMesh->mNumFaces];
|
|
|
|
|
|
|
|
aiVector3D* vpOut = pMesh->mVertices = new aiVector3D[vPositions.size()];
|
|
|
|
const aiVector3D* vp = &vPositions[0];
|
|
|
|
|
2009-03-15 00:40:30 +00:00
|
|
|
for (unsigned int i = 0; i < pMesh->mNumFaces;++i) {
|
2008-09-05 13:21:01 +00:00
|
|
|
aiFace& face = pMesh->mFaces[i];
|
|
|
|
|
2008-10-24 20:37:54 +00:00
|
|
|
// check whether we need four, three or two indices here
|
2009-03-15 00:40:30 +00:00
|
|
|
if (vp[1] == vp[2]) {
|
2008-10-19 11:32:33 +00:00
|
|
|
face.mNumIndices = 2;
|
2008-09-05 13:21:01 +00:00
|
|
|
}
|
2009-03-15 00:40:30 +00:00
|
|
|
else if (vp[3] == vp[2]) {
|
2008-10-19 11:32:33 +00:00
|
|
|
face.mNumIndices = 3;
|
|
|
|
}
|
|
|
|
else face.mNumIndices = 4;
|
2008-09-05 13:21:01 +00:00
|
|
|
face.mIndices = new unsigned int[face.mNumIndices];
|
|
|
|
|
2009-03-15 00:40:30 +00:00
|
|
|
for (unsigned int a = 0; a < face.mNumIndices;++a) {
|
2008-09-05 13:21:01 +00:00
|
|
|
*vpOut++ = vp[a];
|
2009-03-15 00:40:30 +00:00
|
|
|
if (clr) {
|
|
|
|
if (is_not_qnan( clr[a].r )) {
|
2008-09-27 16:46:05 +00:00
|
|
|
*clrOut = clr[a];
|
2009-03-15 00:40:30 +00:00
|
|
|
}
|
2008-09-27 16:46:05 +00:00
|
|
|
++clrOut;
|
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
face.mIndices[a] = pMesh->mNumVertices++;
|
|
|
|
}
|
|
|
|
vp += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// generate the output scene graph
|
|
|
|
pScene->mRootNode = new aiNode();
|
|
|
|
pScene->mRootNode->mName.Set("<DXF_ROOT>");
|
|
|
|
|
2009-03-15 00:40:30 +00:00
|
|
|
if (1 == pScene->mNumMeshes) {
|
2008-09-05 13:21:01 +00:00
|
|
|
pScene->mRootNode->mMeshes = new unsigned int[ pScene->mRootNode->mNumMeshes = 1 ];
|
|
|
|
pScene->mRootNode->mMeshes[0] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pScene->mRootNode->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren = pScene->mNumMeshes ];
|
2009-03-15 00:40:30 +00:00
|
|
|
for (m = 0; m < pScene->mRootNode->mNumChildren;++m) {
|
2008-09-05 13:21:01 +00:00
|
|
|
aiNode* p = pScene->mRootNode->mChildren[m] = new aiNode();
|
|
|
|
p->mName.length = ::strlen( mLayers[m].name );
|
2009-08-21 22:49:58 +00:00
|
|
|
strcpy(p->mName.data, mLayers[m].name);
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
p->mMeshes = new unsigned int[p->mNumMeshes = 1];
|
|
|
|
p->mMeshes[0] = m;
|
|
|
|
p->mParent = pScene->mRootNode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// generate a default material
|
|
|
|
MaterialHelper* pcMat = new MaterialHelper();
|
|
|
|
aiString s;
|
|
|
|
s.Set(AI_DEFAULT_MATERIAL_NAME);
|
|
|
|
pcMat->AddProperty(&s, AI_MATKEY_NAME);
|
|
|
|
|
|
|
|
aiColor4D clrDiffuse(0.6f,0.6f,0.6f,1.0f);
|
|
|
|
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_DIFFUSE);
|
|
|
|
|
|
|
|
clrDiffuse = aiColor4D(1.0f,1.0f,1.0f,1.0f);
|
|
|
|
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_SPECULAR);
|
|
|
|
|
|
|
|
clrDiffuse = aiColor4D(0.05f,0.05f,0.05f,1.0f);
|
|
|
|
pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_AMBIENT);
|
|
|
|
|
|
|
|
pScene->mNumMaterials = 1;
|
|
|
|
pScene->mMaterials = new aiMaterial*[1];
|
|
|
|
pScene->mMaterials[0] = pcMat;
|
|
|
|
|
2009-04-02 15:16:01 +00:00
|
|
|
// flip winding order to be ccw
|
|
|
|
FlipWindingOrderProcess flipper;
|
|
|
|
flipper.Execute(pScene);
|
|
|
|
|
2008-09-05 13:21:01 +00:00
|
|
|
// --- everything destructs automatically ---
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool DXFImporter::ParseEntities()
|
|
|
|
{
|
2009-03-15 00:40:30 +00:00
|
|
|
while (GetNextToken()) {
|
|
|
|
if (!groupCode) {
|
2010-02-06 23:52:41 +00:00
|
|
|
if (!::strcmp(cursor,"3DFACE") || !::strcmp(cursor,"LINE") || !::strcmp(cursor,"3DLINE")){
|
2010-03-15 23:45:19 +00:00
|
|
|
//http://sourceforge.net/tracker/index.php?func=detail&aid=2970566&group_id=226462&atid=1067632
|
|
|
|
Parse3DFace();
|
|
|
|
bRepeat = true;
|
2010-02-06 23:52:41 +00:00
|
|
|
}
|
|
|
|
if (!::strcmp(cursor,"POLYLINE") || !::strcmp(cursor,"LWPOLYLINE")){
|
2010-03-15 23:45:19 +00:00
|
|
|
ParsePolyLine();
|
|
|
|
bRepeat = true;
|
2010-02-06 23:52:41 +00:00
|
|
|
}
|
|
|
|
if (!::strcmp(cursor,"ENDSEC")) {
|
2008-09-05 13:21:01 +00:00
|
|
|
return true;
|
2010-02-06 23:52:41 +00:00
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-09-16 16:17:32 +00:00
|
|
|
void DXFImporter::SetLayer(LayerInfo*& out)
|
|
|
|
{
|
2009-03-15 00:40:30 +00:00
|
|
|
for (std::vector<LayerInfo>::iterator it = mLayers.begin(),end = mLayers.end();it != end;++it) {
|
|
|
|
if (!::strcmp( (*it).name, cursor )) {
|
2008-09-16 16:17:32 +00:00
|
|
|
out = &(*it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-03-15 00:40:30 +00:00
|
|
|
if (!out) {
|
2008-09-16 16:17:32 +00:00
|
|
|
// we don't have this layer yet
|
|
|
|
mLayers.push_back(LayerInfo());
|
|
|
|
out = &mLayers.back();
|
|
|
|
::strcpy(out->name,cursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void DXFImporter::SetDefaultLayer(LayerInfo*& out)
|
|
|
|
{
|
2009-03-15 00:40:30 +00:00
|
|
|
if (!mDefaultLayer) {
|
2008-09-16 16:17:32 +00:00
|
|
|
mLayers.push_back(LayerInfo());
|
|
|
|
mDefaultLayer = &mLayers.back();
|
|
|
|
}
|
|
|
|
out = mDefaultLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool DXFImporter::ParsePolyLine()
|
2008-09-05 13:21:01 +00:00
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
LayerInfo* out = NULL;
|
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
std::vector<aiVector3D> positions;
|
2008-09-20 15:55:51 +00:00
|
|
|
std::vector<aiColor4D> colors;
|
2008-09-16 16:17:32 +00:00
|
|
|
std::vector<unsigned int> indices;
|
|
|
|
unsigned int flags = 0;
|
|
|
|
|
2009-03-15 00:40:30 +00:00
|
|
|
while (GetNextToken()) {
|
2008-09-05 13:21:01 +00:00
|
|
|
switch (groupCode)
|
|
|
|
{
|
2008-09-16 16:17:32 +00:00
|
|
|
case 0:
|
2008-09-05 13:21:01 +00:00
|
|
|
{
|
2009-03-15 00:40:30 +00:00
|
|
|
if (!::strcmp(cursor,"VERTEX")) {
|
2008-09-20 15:55:51 +00:00
|
|
|
aiVector3D v;aiColor4D clr(g_clrInvalid);
|
2008-09-16 16:17:32 +00:00
|
|
|
unsigned int idx[4] = {0xffffffff,0xffffffff,0xffffffff,0xffffffff};
|
2008-09-20 15:55:51 +00:00
|
|
|
ParsePolyLineVertex(v, clr, idx);
|
2009-03-15 00:40:30 +00:00
|
|
|
if (0xffffffff == idx[0]) {
|
2008-09-20 15:55:51 +00:00
|
|
|
positions.push_back(v);
|
|
|
|
colors.push_back(clr);
|
|
|
|
}
|
2009-03-15 00:40:30 +00:00
|
|
|
else {
|
2008-09-16 16:17:32 +00:00
|
|
|
// check whether we have a fourth coordinate
|
2009-03-15 00:40:30 +00:00
|
|
|
if (0xffffffff == idx[3]) {
|
2008-09-16 16:17:32 +00:00
|
|
|
idx[3] = idx[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
indices.reserve(indices.size()+4);
|
|
|
|
for (unsigned int m = 0; m < 4;++m)
|
|
|
|
indices.push_back(idx[m]);
|
2008-09-05 13:21:01 +00:00
|
|
|
}
|
2008-09-16 16:17:32 +00:00
|
|
|
bRepeat = true;
|
2008-09-05 13:21:01 +00:00
|
|
|
}
|
2009-03-15 00:40:30 +00:00
|
|
|
else if (!::strcmp(cursor,"ENDSEQ")) {
|
2008-09-16 16:17:32 +00:00
|
|
|
ret = true;
|
2008-09-05 13:21:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
// flags --- important that we know whether it is a polyface mesh
|
|
|
|
case 70:
|
|
|
|
{
|
2009-03-15 00:40:30 +00:00
|
|
|
if (!flags) {
|
2008-10-31 19:32:00 +00:00
|
|
|
flags = strtol10(cursor);
|
|
|
|
}
|
2008-09-16 16:17:32 +00:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
// optional number of vertices
|
|
|
|
case 71:
|
|
|
|
{
|
2008-10-22 20:06:16 +00:00
|
|
|
positions.reserve(strtol10(cursor));
|
2008-09-16 16:17:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// optional number of faces
|
|
|
|
case 72:
|
|
|
|
{
|
2008-10-24 20:37:54 +00:00
|
|
|
indices.reserve(strtol10(cursor));
|
2008-09-16 16:17:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 8 specifies the layer
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
SetLayer(out);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-15 00:40:30 +00:00
|
|
|
if (!(flags & 64)) {
|
2008-09-16 16:17:32 +00:00
|
|
|
DefaultLogger::get()->warn("DXF: Only polyface meshes are currently supported");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-03-15 00:40:30 +00:00
|
|
|
if (positions.size() < 3 || indices.size() < 3) {
|
2008-09-16 16:17:32 +00:00
|
|
|
DefaultLogger::get()->warn("DXF: Unable to parse POLYLINE element - not enough vertices");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// use a default layer if necessary
|
2009-03-15 00:40:30 +00:00
|
|
|
if (!out) {
|
|
|
|
SetDefaultLayer(out);
|
|
|
|
}
|
2008-09-16 16:17:32 +00:00
|
|
|
|
2008-09-20 15:55:51 +00:00
|
|
|
flags = (unsigned int)(out->vPositions.size()+indices.size());
|
|
|
|
out->vPositions.reserve(flags);
|
|
|
|
out->vColors.reserve(flags);
|
|
|
|
|
2008-09-16 16:17:32 +00:00
|
|
|
// generate unique vertices
|
2009-03-15 00:40:30 +00:00
|
|
|
for (std::vector<unsigned int>::const_iterator it = indices.begin(), end = indices.end();it != end; ++it) {
|
2008-09-16 16:17:32 +00:00
|
|
|
unsigned int idx = *it;
|
2009-03-15 00:40:30 +00:00
|
|
|
if (idx > positions.size() || !idx) {
|
2008-09-16 16:17:32 +00:00
|
|
|
DefaultLogger::get()->error("DXF: Polyface mesh index os out of range");
|
|
|
|
idx = (unsigned int) positions.size();
|
|
|
|
}
|
|
|
|
out->vPositions.push_back(positions[idx-1]); // indices are one-based.
|
2008-09-20 15:55:51 +00:00
|
|
|
out->vColors.push_back(colors[idx-1]); // indices are one-based.
|
2008-09-16 16:17:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-09-20 15:55:51 +00:00
|
|
|
bool DXFImporter::ParsePolyLineVertex(aiVector3D& out,aiColor4D& clr, unsigned int* outIdx)
|
2008-09-16 16:17:32 +00:00
|
|
|
{
|
|
|
|
bool ret = false;
|
2009-03-15 00:40:30 +00:00
|
|
|
while (GetNextToken()) {
|
2008-09-16 16:17:32 +00:00
|
|
|
switch (groupCode)
|
|
|
|
{
|
2009-03-15 00:40:30 +00:00
|
|
|
case 0: ret = true;
|
|
|
|
break;
|
2008-09-16 16:17:32 +00:00
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
// todo - handle the correct layer for the vertex. At the moment it is assumed that all vertices of
|
2008-10-22 20:06:16 +00:00
|
|
|
// a polyline are placed on the same global layer.
|
2008-09-16 16:17:32 +00:00
|
|
|
|
|
|
|
// x position of the first corner
|
|
|
|
case 10: out.x = fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// y position of the first corner
|
|
|
|
case 20: out.y = -fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// z position of the first corner
|
|
|
|
case 30: out.z = fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// POLYFACE vertex indices
|
|
|
|
case 71: outIdx[0] = strtol10(cursor);break;
|
|
|
|
case 72: outIdx[1] = strtol10(cursor);break;
|
|
|
|
case 73: outIdx[2] = strtol10(cursor);break;
|
2008-10-31 19:32:00 +00:00
|
|
|
// case 74: outIdx[3] = strtol10(cursor);break;
|
2008-09-20 15:55:51 +00:00
|
|
|
|
|
|
|
// color
|
|
|
|
case 62: clr = g_aclrDxfIndexColors[strtol10(cursor) % AI_DXF_NUM_INDEX_COLORS]; break;
|
2008-09-16 16:17:32 +00:00
|
|
|
};
|
2009-03-15 00:40:30 +00:00
|
|
|
if (ret) {
|
|
|
|
break;
|
|
|
|
}
|
2008-09-16 16:17:32 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool DXFImporter::Parse3DFace()
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
LayerInfo* out = NULL;
|
|
|
|
|
|
|
|
aiVector3D vip[4]; // -- vectors are initialized to zero
|
2008-09-20 15:55:51 +00:00
|
|
|
aiColor4D clr(g_clrInvalid);
|
2008-10-19 11:32:33 +00:00
|
|
|
|
|
|
|
// this is also used for for parsing line entities
|
|
|
|
bool bThird = false;
|
|
|
|
|
2009-03-15 00:40:30 +00:00
|
|
|
while (GetNextToken()) {
|
|
|
|
switch (groupCode) {
|
2009-04-09 21:37:49 +00:00
|
|
|
case 0:
|
|
|
|
ret = true;
|
|
|
|
break;
|
2008-09-16 16:17:32 +00:00
|
|
|
|
|
|
|
// 8 specifies the layer
|
2009-03-15 00:40:30 +00:00
|
|
|
case 8: {
|
2008-09-16 16:17:32 +00:00
|
|
|
SetLayer(out);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-09-05 13:21:01 +00:00
|
|
|
// x position of the first corner
|
|
|
|
case 10: vip[0].x = fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// y position of the first corner
|
|
|
|
case 20: vip[0].y = -fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// z position of the first corner
|
|
|
|
case 30: vip[0].z = fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// x position of the second corner
|
|
|
|
case 11: vip[1].x = fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// y position of the second corner
|
|
|
|
case 21: vip[1].y = -fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// z position of the second corner
|
|
|
|
case 31: vip[1].z = fast_atof(cursor);break;
|
|
|
|
|
|
|
|
// x position of the third corner
|
2008-10-19 11:32:33 +00:00
|
|
|
case 12: vip[2].x = fast_atof(cursor);
|
|
|
|
bThird = true;break;
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
// y position of the third corner
|
2008-10-19 11:32:33 +00:00
|
|
|
case 22: vip[2].y = -fast_atof(cursor);
|
|
|
|
bThird = true;break;
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
// z position of the third corner
|
2008-10-19 11:32:33 +00:00
|
|
|
case 32: vip[2].z = fast_atof(cursor);
|
|
|
|
bThird = true;break;
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
// x position of the fourth corner
|
2008-10-19 11:32:33 +00:00
|
|
|
case 13: vip[3].x = fast_atof(cursor);
|
|
|
|
bThird = true;break;
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
// y position of the fourth corner
|
2008-10-19 11:32:33 +00:00
|
|
|
case 23: vip[3].y = -fast_atof(cursor);
|
|
|
|
bThird = true;break;
|
2008-09-05 13:21:01 +00:00
|
|
|
|
|
|
|
// z position of the fourth corner
|
2008-10-19 11:32:33 +00:00
|
|
|
case 33: vip[3].z = fast_atof(cursor);
|
|
|
|
bThird = true;break;
|
2008-09-20 15:55:51 +00:00
|
|
|
|
|
|
|
// color
|
|
|
|
case 62: clr = g_aclrDxfIndexColors[strtol10(cursor) % AI_DXF_NUM_INDEX_COLORS]; break;
|
2008-09-05 13:21:01 +00:00
|
|
|
};
|
2009-04-09 21:37:49 +00:00
|
|
|
if (ret)
|
|
|
|
break;
|
2008-09-05 13:21:01 +00:00
|
|
|
}
|
|
|
|
|
2009-04-09 21:37:49 +00:00
|
|
|
if (!bThird)
|
|
|
|
vip[2] = vip[1];
|
2008-10-19 11:32:33 +00:00
|
|
|
|
2008-09-05 13:21:01 +00:00
|
|
|
// use a default layer if necessary
|
2009-03-15 00:40:30 +00:00
|
|
|
if (!out) {
|
|
|
|
SetDefaultLayer(out);
|
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
// add the faces to the face list for this layer
|
|
|
|
out->vPositions.push_back(vip[0]);
|
|
|
|
out->vPositions.push_back(vip[1]);
|
|
|
|
out->vPositions.push_back(vip[2]);
|
2008-09-16 16:17:32 +00:00
|
|
|
out->vPositions.push_back(vip[3]); // might be equal to the third
|
2008-09-20 15:55:51 +00:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < 4;++i)
|
|
|
|
out->vColors.push_back(clr);
|
2008-09-05 13:21:01 +00:00
|
|
|
return ret;
|
2008-08-28 17:35:36 +00:00
|
|
|
}
|
2008-10-19 11:32:33 +00:00
|
|
|
|
2009-01-18 23:48:25 +00:00
|
|
|
#endif // !! ASSIMP_BUILD_NO_DXF_IMPORTER
|
2008-10-19 11:32:33 +00:00
|
|
|
|