Fixed normal vector handling in the ASE loader. Improved animation & camera & light support - as for the 3DS Loader, still in the works.
Fixed AC - Loader. It is now able to load models with complex hierarchies correctly. Added a small workaround for Quick3D, which writes invalid AC files.
DXF-Loader skips {...} blocks produced by 3DS Max & AutoCad correctly now.
DefaultLogger doesn't repeat identical log messages now.
FindInvalidData-Process removes empty or dummy animation tracks now.
LWO-Loader recognizes complex shaders (such as Fresnel) correctly now. Other LLWO bugs still unsolved.
Fixed bugs in the Ply parser, causing non-triangular faces to crash.
Added some additional helperutilities to StreamReader.
Fixed a bug in ProcessHelper.h causing SPlitLargeMeses and SortBxPType to crash for meshes containing many bones.
Changed OB default material from black to gray.
Added additional test fils: ply (bugfix), ase (animation), QUick3D & Irr (in the works), STL (export from 3DS Max)
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@210 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
153 lines
3.4 KiB
C++
153 lines
3.4 KiB
C++
// Copyright (C) 2002-2005 Nikolaus Gebhardt
|
|
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h and/or irrXML.h
|
|
|
|
// Need to include Assimp, too. We're using Assimp's version of fast_atof
|
|
// so we need stdint.h
|
|
|
|
#include "./../AssimpPCH.h"
|
|
|
|
#include "irrXML.h"
|
|
#include "irrString.h"
|
|
#include "irrArray.h"
|
|
#include "./../fast_atof.h"
|
|
#include "CXMLReaderImpl.h"
|
|
|
|
namespace irr
|
|
{
|
|
namespace io
|
|
{
|
|
|
|
//! Implementation of the file read callback for ordinary files
|
|
class CFileReadCallBack : public IFileReadCallBack
|
|
{
|
|
public:
|
|
|
|
//! construct from filename
|
|
CFileReadCallBack(const char* filename)
|
|
: File(0), Size(0), Close(true)
|
|
{
|
|
// open file
|
|
File = fopen(filename, "rb");
|
|
|
|
if (File)
|
|
getFileSize();
|
|
}
|
|
|
|
//! construct from FILE pointer
|
|
CFileReadCallBack(FILE* file)
|
|
: File(file), Size(0), Close(false)
|
|
{
|
|
if (File)
|
|
getFileSize();
|
|
}
|
|
|
|
//! destructor
|
|
virtual ~CFileReadCallBack()
|
|
{
|
|
if (Close && File)
|
|
fclose(File);
|
|
}
|
|
|
|
//! Reads an amount of bytes from the file.
|
|
virtual int read(void* buffer, int sizeToRead)
|
|
{
|
|
if (!File)
|
|
return 0;
|
|
|
|
return (int)fread(buffer, 1, sizeToRead, File);
|
|
}
|
|
|
|
//! Returns size of file in bytes
|
|
virtual int getSize()
|
|
{
|
|
return Size;
|
|
}
|
|
|
|
private:
|
|
|
|
//! retrieves the file size of the open file
|
|
void getFileSize()
|
|
{
|
|
fseek(File, 0, SEEK_END);
|
|
Size = ftell(File);
|
|
fseek(File, 0, SEEK_SET);
|
|
}
|
|
|
|
FILE* File;
|
|
int Size;
|
|
bool Close;
|
|
|
|
}; // end class CFileReadCallBack
|
|
|
|
|
|
|
|
// FACTORY FUNCTIONS:
|
|
|
|
|
|
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
|
IrrXMLReader* createIrrXMLReader(const char* filename)
|
|
{
|
|
return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(filename));
|
|
}
|
|
|
|
|
|
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
|
IrrXMLReader* createIrrXMLReader(FILE* file)
|
|
{
|
|
return new CXMLReaderImpl<char, IXMLBase>(new CFileReadCallBack(file));
|
|
}
|
|
|
|
|
|
//! Creates an instance of an UFT-8 or ASCII character xml parser.
|
|
IrrXMLReader* createIrrXMLReader(IFileReadCallBack* callback)
|
|
{
|
|
return new CXMLReaderImpl<char, IXMLBase>(callback, false);
|
|
}
|
|
|
|
|
|
//! Creates an instance of an UTF-16 xml parser.
|
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(const char* filename)
|
|
{
|
|
return new CXMLReaderImpl<char16, IXMLBase>(new CFileReadCallBack(filename));
|
|
}
|
|
|
|
|
|
//! Creates an instance of an UTF-16 xml parser.
|
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(FILE* file)
|
|
{
|
|
return new CXMLReaderImpl<char16, IXMLBase>(new CFileReadCallBack(file));
|
|
}
|
|
|
|
|
|
//! Creates an instance of an UTF-16 xml parser.
|
|
IrrXMLReaderUTF16* createIrrXMLReaderUTF16(IFileReadCallBack* callback)
|
|
{
|
|
return new CXMLReaderImpl<char16, IXMLBase>(callback, false);
|
|
}
|
|
|
|
|
|
//! Creates an instance of an UTF-32 xml parser.
|
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(const char* filename)
|
|
{
|
|
return new CXMLReaderImpl<char32, IXMLBase>(new CFileReadCallBack(filename));
|
|
}
|
|
|
|
|
|
//! Creates an instance of an UTF-32 xml parser.
|
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(FILE* file)
|
|
{
|
|
return new CXMLReaderImpl<char32, IXMLBase>(new CFileReadCallBack(file));
|
|
}
|
|
|
|
|
|
//! Creates an instance of an UTF-32 xml parser.
|
|
IrrXMLReaderUTF32* createIrrXMLReaderUTF32(IFileReadCallBack* callback)
|
|
{
|
|
return new CXMLReaderImpl<char32, IXMLBase>(callback, false);
|
|
}
|
|
|
|
|
|
} // end namespace io
|
|
} // end namespace irr
|