mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-22 21:05:39 +00:00
Just the functional assimp lib rather than the entire assimp repository unnecessarily.
This commit is contained in:
parent
0f7641a282
commit
e9ea38eda3
1747 changed files with 9012 additions and 925008 deletions
|
|
@ -1,361 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Definition of the base class for all importer worker classes. */
|
||||
#ifndef INCLUDED_AI_BASEIMPORTER_H
|
||||
#define INCLUDED_AI_BASEIMPORTER_H
|
||||
|
||||
#include "Exceptional.h"
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/ProgressHandler.hpp>
|
||||
|
||||
struct aiScene;
|
||||
struct aiImporterDesc;
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
class Importer;
|
||||
class IOSystem;
|
||||
class BaseProcess;
|
||||
class SharedPostProcessInfo;
|
||||
class IOStream;
|
||||
|
||||
// utility to do char4 to uint32 in a portable manner
|
||||
#define AI_MAKE_MAGIC(string) ((uint32_t)((string[0] << 24) + \
|
||||
(string[1] << 16) + (string[2] << 8) + string[3]))
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** FOR IMPORTER PLUGINS ONLY: The BaseImporter defines a common interface
|
||||
* for all importer worker classes.
|
||||
*
|
||||
* The interface defines two functions: CanRead() is used to check if the
|
||||
* importer can handle the format of the given file. If an implementation of
|
||||
* this function returns true, the importer then calls ReadFile() which
|
||||
* imports the given file. ReadFile is not overridable, it just calls
|
||||
* InternReadFile() and catches any ImportErrorException that might occur.
|
||||
*/
|
||||
class ASSIMP_API BaseImporter {
|
||||
friend class Importer;
|
||||
|
||||
public:
|
||||
|
||||
/** Constructor to be privately used by #Importer */
|
||||
BaseImporter() AI_NO_EXCEPT;
|
||||
|
||||
/** Destructor, private as well */
|
||||
virtual ~BaseImporter();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns whether the class can handle the format of the given file.
|
||||
*
|
||||
* The implementation should be as quick as possible. A check for
|
||||
* the file extension is enough. If no suitable loader is found with
|
||||
* this strategy, CanRead() is called again, the 'checkSig' parameter
|
||||
* set to true this time. Now the implementation is expected to
|
||||
* perform a full check of the file structure, possibly searching the
|
||||
* first bytes of the file for magic identifiers or keywords.
|
||||
*
|
||||
* @param pFile Path and file name of the file to be examined.
|
||||
* @param pIOHandler The IO handler to use for accessing any file.
|
||||
* @param checkSig Set to true if this method is called a second time.
|
||||
* This time, the implementation may take more time to examine the
|
||||
* contents of the file to be loaded for magic bytes, keywords, etc
|
||||
* to be able to load files with unknown/not existent file extensions.
|
||||
* @return true if the class can read this file, false if not.
|
||||
*/
|
||||
virtual bool CanRead(
|
||||
const std::string& pFile,
|
||||
IOSystem* pIOHandler,
|
||||
bool checkSig
|
||||
) const = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Imports the given file and returns the imported data.
|
||||
* If the import succeeds, ownership of the data is transferred to
|
||||
* the caller. If the import fails, NULL is returned. The function
|
||||
* takes care that any partially constructed data is destroyed
|
||||
* beforehand.
|
||||
*
|
||||
* @param pImp #Importer object hosting this loader.
|
||||
* @param pFile Path of the file to be imported.
|
||||
* @param pIOHandler IO-Handler used to open this and possible other files.
|
||||
* @return The imported data or NULL if failed. If it failed a
|
||||
* human-readable error description can be retrieved by calling
|
||||
* GetErrorText()
|
||||
*
|
||||
* @note This function is not intended to be overridden. Implement
|
||||
* InternReadFile() to do the import. If an exception is thrown somewhere
|
||||
* in InternReadFile(), this function will catch it and transform it into
|
||||
* a suitable response to the caller.
|
||||
*/
|
||||
aiScene* ReadFile(
|
||||
const Importer* pImp,
|
||||
const std::string& pFile,
|
||||
IOSystem* pIOHandler
|
||||
);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns the error description of the last error that occurred.
|
||||
* @return A description of the last error that occurred. An empty
|
||||
* string if there was no error.
|
||||
*/
|
||||
const std::string& GetErrorText() const {
|
||||
return m_ErrorText;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called prior to ReadFile().
|
||||
* The function is a request to the importer to update its configuration
|
||||
* basing on the Importer's configuration property list.
|
||||
* @param pImp Importer instance
|
||||
*/
|
||||
virtual void SetupProperties(
|
||||
const Importer* pImp
|
||||
);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called by #Importer::GetImporterInfo to get a description of
|
||||
* some loader features. Importers must provide this information. */
|
||||
virtual const aiImporterDesc* GetInfo() const = 0;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Called by #Importer::GetExtensionList for each loaded importer.
|
||||
* Take the extension list contained in the structure returned by
|
||||
* #GetInfo and insert all file extensions into the given set.
|
||||
* @param extension set to collect file extensions in*/
|
||||
void GetExtensionList(std::set<std::string>& extensions);
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Imports the given file into the given scene structure. The
|
||||
* function is expected to throw an ImportErrorException if there is
|
||||
* an error. If it terminates normally, the data in aiScene is
|
||||
* expected to be correct. Override this function to implement the
|
||||
* actual importing.
|
||||
* <br>
|
||||
* The output scene must meet the following requirements:<br>
|
||||
* <ul>
|
||||
* <li>At least a root node must be there, even if its only purpose
|
||||
* is to reference one mesh.</li>
|
||||
* <li>aiMesh::mPrimitiveTypes may be 0. The types of primitives
|
||||
* in the mesh are determined automatically in this case.</li>
|
||||
* <li>the vertex data is stored in a pseudo-indexed "verbose" format.
|
||||
* In fact this means that every vertex that is referenced by
|
||||
* a face is unique. Or the other way round: a vertex index may
|
||||
* not occur twice in a single aiMesh.</li>
|
||||
* <li>aiAnimation::mDuration may be -1. Assimp determines the length
|
||||
* of the animation automatically in this case as the length of
|
||||
* the longest animation channel.</li>
|
||||
* <li>aiMesh::mBitangents may be NULL if tangents and normals are
|
||||
* given. In this case bitangents are computed as the cross product
|
||||
* between normal and tangent.</li>
|
||||
* <li>There needn't be a material. If none is there a default material
|
||||
* is generated. However, it is recommended practice for loaders
|
||||
* to generate a default material for yourself that matches the
|
||||
* default material setting for the file format better than Assimp's
|
||||
* generic default material. Note that default materials *should*
|
||||
* be named AI_DEFAULT_MATERIAL_NAME if they're just color-shaded
|
||||
* or AI_DEFAULT_TEXTURED_MATERIAL_NAME if they define a (dummy)
|
||||
* texture. </li>
|
||||
* </ul>
|
||||
* If the AI_SCENE_FLAGS_INCOMPLETE-Flag is <b>not</b> set:<ul>
|
||||
* <li> at least one mesh must be there</li>
|
||||
* <li> there may be no meshes with 0 vertices or faces</li>
|
||||
* </ul>
|
||||
* This won't be checked (except by the validation step): Assimp will
|
||||
* crash if one of the conditions is not met!
|
||||
*
|
||||
* @param pFile Path of the file to be imported.
|
||||
* @param pScene The scene object to hold the imported data.
|
||||
* NULL is not a valid parameter.
|
||||
* @param pIOHandler The IO handler to use for any file access.
|
||||
* NULL is not a valid parameter. */
|
||||
virtual void InternReadFile(
|
||||
const std::string& pFile,
|
||||
aiScene* pScene,
|
||||
IOSystem* pIOHandler
|
||||
) = 0;
|
||||
|
||||
public: // static utilities
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** A utility for CanRead().
|
||||
*
|
||||
* The function searches the header of a file for a specific token
|
||||
* and returns true if this token is found. This works for text
|
||||
* files only. There is a rudimentary handling of UNICODE files.
|
||||
* The comparison is case independent.
|
||||
*
|
||||
* @param pIOSystem IO System to work with
|
||||
* @param file File name of the file
|
||||
* @param tokens List of tokens to search for
|
||||
* @param numTokens Size of the token array
|
||||
* @param searchBytes Number of bytes to be searched for the tokens.
|
||||
*/
|
||||
static bool SearchFileHeaderForToken(
|
||||
IOSystem* pIOSystem,
|
||||
const std::string& file,
|
||||
const char** tokens,
|
||||
unsigned int numTokens,
|
||||
unsigned int searchBytes = 200,
|
||||
bool tokensSol = false,
|
||||
bool noAlphaBeforeTokens = false);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Check whether a file has a specific file extension
|
||||
* @param pFile Input file
|
||||
* @param ext0 Extension to check for. Lowercase characters only, no dot!
|
||||
* @param ext1 Optional second extension
|
||||
* @param ext2 Optional third extension
|
||||
* @note Case-insensitive
|
||||
*/
|
||||
static bool SimpleExtensionCheck (
|
||||
const std::string& pFile,
|
||||
const char* ext0,
|
||||
const char* ext1 = NULL,
|
||||
const char* ext2 = NULL);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Extract file extension from a string
|
||||
* @param pFile Input file
|
||||
* @return Extension without trailing dot, all lowercase
|
||||
*/
|
||||
static std::string GetExtension (
|
||||
const std::string& pFile);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Check whether a file starts with one or more magic tokens
|
||||
* @param pFile Input file
|
||||
* @param pIOHandler IO system to be used
|
||||
* @param magic n magic tokens
|
||||
* @params num Size of magic
|
||||
* @param offset Offset from file start where tokens are located
|
||||
* @param Size of one token, in bytes. Maximally 16 bytes.
|
||||
* @return true if one of the given tokens was found
|
||||
*
|
||||
* @note For convenience, the check is also performed for the
|
||||
* byte-swapped variant of all tokens (big endian). Only for
|
||||
* tokens of size 2,4.
|
||||
*/
|
||||
static bool CheckMagicToken(
|
||||
IOSystem* pIOHandler,
|
||||
const std::string& pFile,
|
||||
const void* magic,
|
||||
unsigned int num,
|
||||
unsigned int offset = 0,
|
||||
unsigned int size = 4);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** An utility for all text file loaders. It converts a file to our
|
||||
* UTF8 character set. Errors are reported, but ignored.
|
||||
*
|
||||
* @param data File buffer to be converted to UTF8 data. The buffer
|
||||
* is resized as appropriate. */
|
||||
static void ConvertToUTF8(
|
||||
std::vector<char>& data);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** An utility for all text file loaders. It converts a file from our
|
||||
* UTF8 character set back to ISO-8859-1. Errors are reported, but ignored.
|
||||
*
|
||||
* @param data File buffer to be converted from UTF8 to ISO-8859-1. The buffer
|
||||
* is resized as appropriate. */
|
||||
static void ConvertUTF8toISO8859_1(
|
||||
std::string& data);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/// @brief Enum to define, if empty files are ok or not.
|
||||
enum TextFileMode {
|
||||
ALLOW_EMPTY,
|
||||
FORBID_EMPTY
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Utility for text file loaders which copies the contents of the
|
||||
* file into a memory buffer and converts it to our UTF8
|
||||
* representation.
|
||||
* @param stream Stream to read from.
|
||||
* @param data Output buffer to be resized and filled with the
|
||||
* converted text file data. The buffer is terminated with
|
||||
* a binary 0.
|
||||
* @param mode Whether it is OK to load empty text files. */
|
||||
static void TextFileToBuffer(
|
||||
IOStream* stream,
|
||||
std::vector<char>& data,
|
||||
TextFileMode mode = FORBID_EMPTY);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Utility function to move a std::vector into a aiScene array
|
||||
* @param vec The vector to be moved
|
||||
* @param out The output pointer to the allocated array.
|
||||
* @param numOut The output count of elements copied. */
|
||||
template<typename T>
|
||||
AI_FORCE_INLINE
|
||||
static void CopyVector(
|
||||
std::vector<T>& vec,
|
||||
T*& out,
|
||||
unsigned int& outLength)
|
||||
{
|
||||
outLength = unsigned(vec.size());
|
||||
if (outLength) {
|
||||
out = new T[outLength];
|
||||
std::swap_ranges(vec.begin(), vec.end(), out);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Error description in case there was one.
|
||||
std::string m_ErrorText;
|
||||
/// Currently set progress handler.
|
||||
ProgressHandler* m_progress;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_BASEIMPORTER_H_INC
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Bitmap.h
|
||||
* @brief Defines bitmap format helper for textures
|
||||
*
|
||||
* Used for file formats which embed their textures into the model file.
|
||||
*/
|
||||
|
||||
#ifndef AI_BITMAP_H_INC
|
||||
#define AI_BITMAP_H_INC
|
||||
|
||||
#include "defs.h"
|
||||
#include <stdint.h>
|
||||
#include <cstddef>
|
||||
|
||||
struct aiTexture;
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
class IOStream;
|
||||
|
||||
class ASSIMP_API Bitmap {
|
||||
protected:
|
||||
|
||||
struct Header {
|
||||
uint16_t type;
|
||||
uint32_t size;
|
||||
uint16_t reserved1;
|
||||
uint16_t reserved2;
|
||||
uint32_t offset;
|
||||
|
||||
// We define the struct size because sizeof(Header) might return a wrong result because of structure padding.
|
||||
// Moreover, we must use this ugly and error prone syntax because Visual Studio neither support constexpr or sizeof(name_of_field).
|
||||
static const std::size_t header_size =
|
||||
sizeof(uint16_t) + // type
|
||||
sizeof(uint32_t) + // size
|
||||
sizeof(uint16_t) + // reserved1
|
||||
sizeof(uint16_t) + // reserved2
|
||||
sizeof(uint32_t); // offset
|
||||
};
|
||||
|
||||
struct DIB {
|
||||
uint32_t size;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
uint16_t planes;
|
||||
uint16_t bits_per_pixel;
|
||||
uint32_t compression;
|
||||
uint32_t image_size;
|
||||
int32_t x_resolution;
|
||||
int32_t y_resolution;
|
||||
uint32_t nb_colors;
|
||||
uint32_t nb_important_colors;
|
||||
|
||||
// We define the struct size because sizeof(DIB) might return a wrong result because of structure padding.
|
||||
// Moreover, we must use this ugly and error prone syntax because Visual Studio neither support constexpr or sizeof(name_of_field).
|
||||
static const std::size_t dib_size =
|
||||
sizeof(uint32_t) + // size
|
||||
sizeof(int32_t) + // width
|
||||
sizeof(int32_t) + // height
|
||||
sizeof(uint16_t) + // planes
|
||||
sizeof(uint16_t) + // bits_per_pixel
|
||||
sizeof(uint32_t) + // compression
|
||||
sizeof(uint32_t) + // image_size
|
||||
sizeof(int32_t) + // x_resolution
|
||||
sizeof(int32_t) + // y_resolution
|
||||
sizeof(uint32_t) + // nb_colors
|
||||
sizeof(uint32_t); // nb_important_colors
|
||||
};
|
||||
|
||||
static const std::size_t mBytesPerPixel = 4;
|
||||
|
||||
public:
|
||||
static void Save(aiTexture* texture, IOStream* file);
|
||||
|
||||
protected:
|
||||
static void WriteHeader(Header& header, IOStream* file);
|
||||
static void WriteDIB(DIB& dib, IOStream* file);
|
||||
static void WriteData(aiTexture* texture, IOStream* file);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // AI_BITMAP_H_INC
|
||||
|
|
@ -1,338 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Provides cheat implementations for IOSystem and IOStream to
|
||||
* redirect exporter output to a blob chain.*/
|
||||
|
||||
#ifndef AI_BLOBIOSYSTEM_H_INCLUDED
|
||||
#define AI_BLOBIOSYSTEM_H_INCLUDED
|
||||
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/cexport.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <stdint.h>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
class BlobIOSystem;
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/** Redirect IOStream to a blob */
|
||||
// --------------------------------------------------------------------------------------------
|
||||
class BlobIOStream : public IOStream
|
||||
{
|
||||
public:
|
||||
|
||||
BlobIOStream(BlobIOSystem* creator, const std::string& file, size_t initial = 4096)
|
||||
: buffer()
|
||||
, cur_size()
|
||||
, file_size()
|
||||
, cursor()
|
||||
, initial(initial)
|
||||
, file(file)
|
||||
, creator(creator)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual ~BlobIOStream();
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
aiExportDataBlob* GetBlob()
|
||||
{
|
||||
aiExportDataBlob* blob = new aiExportDataBlob();
|
||||
blob->size = file_size;
|
||||
blob->data = buffer;
|
||||
|
||||
buffer = NULL;
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Read( void *,
|
||||
size_t,
|
||||
size_t )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Write(const void* pvBuffer,
|
||||
size_t pSize,
|
||||
size_t pCount)
|
||||
{
|
||||
pSize *= pCount;
|
||||
if (cursor + pSize > cur_size) {
|
||||
Grow(cursor + pSize);
|
||||
}
|
||||
|
||||
memcpy(buffer+cursor, pvBuffer, pSize);
|
||||
cursor += pSize;
|
||||
|
||||
file_size = std::max(file_size,cursor);
|
||||
return pCount;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual aiReturn Seek(size_t pOffset,
|
||||
aiOrigin pOrigin)
|
||||
{
|
||||
switch(pOrigin)
|
||||
{
|
||||
case aiOrigin_CUR:
|
||||
cursor += pOffset;
|
||||
break;
|
||||
|
||||
case aiOrigin_END:
|
||||
cursor = file_size - pOffset;
|
||||
break;
|
||||
|
||||
case aiOrigin_SET:
|
||||
cursor = pOffset;
|
||||
break;
|
||||
|
||||
default:
|
||||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
if (cursor > file_size) {
|
||||
Grow(cursor);
|
||||
}
|
||||
|
||||
file_size = std::max(cursor,file_size);
|
||||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t Tell() const
|
||||
{
|
||||
return cursor;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual size_t FileSize() const
|
||||
{
|
||||
return file_size;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual void Flush()
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
void Grow(size_t need = 0)
|
||||
{
|
||||
// 1.5 and phi are very heap-friendly growth factors (the first
|
||||
// allows for frequent re-use of heap blocks, the second
|
||||
// forms a fibonacci sequence with similar characteristics -
|
||||
// since this heavily depends on the heap implementation
|
||||
// and other factors as well, i'll just go with 1.5 since
|
||||
// it is quicker to compute).
|
||||
size_t new_size = std::max(initial, std::max( need, cur_size+(cur_size>>1) ));
|
||||
|
||||
const uint8_t* const old = buffer;
|
||||
buffer = new uint8_t[new_size];
|
||||
|
||||
if (old) {
|
||||
memcpy(buffer,old,cur_size);
|
||||
delete[] old;
|
||||
}
|
||||
|
||||
cur_size = new_size;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint8_t* buffer;
|
||||
size_t cur_size,file_size, cursor, initial;
|
||||
|
||||
const std::string file;
|
||||
BlobIOSystem* const creator;
|
||||
};
|
||||
|
||||
|
||||
#define AI_BLOBIO_MAGIC "$blobfile"
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/** Redirect IOSystem to a blob */
|
||||
// --------------------------------------------------------------------------------------------
|
||||
class BlobIOSystem : public IOSystem
|
||||
{
|
||||
|
||||
friend class BlobIOStream;
|
||||
typedef std::pair<std::string, aiExportDataBlob*> BlobEntry;
|
||||
|
||||
public:
|
||||
|
||||
BlobIOSystem()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~BlobIOSystem()
|
||||
{
|
||||
for(BlobEntry& blobby : blobs) {
|
||||
delete blobby.second;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
const char* GetMagicFileName() const
|
||||
{
|
||||
return AI_BLOBIO_MAGIC;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
aiExportDataBlob* GetBlobChain()
|
||||
{
|
||||
// one must be the master
|
||||
aiExportDataBlob* master = NULL, *cur;
|
||||
for(const BlobEntry& blobby : blobs) {
|
||||
if (blobby.first == AI_BLOBIO_MAGIC) {
|
||||
master = blobby.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!master) {
|
||||
ASSIMP_LOG_ERROR("BlobIOSystem: no data written or master file was not closed properly.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
master->name.Set("");
|
||||
|
||||
cur = master;
|
||||
for(const BlobEntry& blobby : blobs) {
|
||||
if (blobby.second == master) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cur->next = blobby.second;
|
||||
cur = cur->next;
|
||||
|
||||
// extract the file extension from the file written
|
||||
const std::string::size_type s = blobby.first.find_first_of('.');
|
||||
cur->name.Set(s == std::string::npos ? blobby.first : blobby.first.substr(s+1));
|
||||
}
|
||||
|
||||
// give up blob ownership
|
||||
blobs.clear();
|
||||
return master;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual bool Exists( const char* pFile) const {
|
||||
return created.find(std::string(pFile)) != created.end();
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual char getOsSeparator() const {
|
||||
return '/';
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual IOStream* Open(const char* pFile,
|
||||
const char* pMode)
|
||||
{
|
||||
if (pMode[0] != 'w') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
created.insert(std::string(pFile));
|
||||
return new BlobIOStream(this,std::string(pFile));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
virtual void Close( IOStream* pFile)
|
||||
{
|
||||
delete pFile;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
void OnDestruct(const std::string& filename, BlobIOStream* child)
|
||||
{
|
||||
// we don't know in which the files are closed, so we
|
||||
// can't reliably say that the first must be the master
|
||||
// file ...
|
||||
blobs.push_back( BlobEntry(filename,child->GetBlob()) );
|
||||
}
|
||||
|
||||
private:
|
||||
std::set<std::string> created;
|
||||
std::vector< BlobEntry > blobs;
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
BlobIOStream :: ~BlobIOStream()
|
||||
{
|
||||
creator->OnDestruct(file,this);
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
|
||||
} // end Assimp
|
||||
|
||||
#endif
|
||||
|
|
@ -1,287 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Helper class tp perform various byte oder swappings
|
||||
(e.g. little to big endian) */
|
||||
#ifndef AI_BYTESWAPPER_H_INC
|
||||
#define AI_BYTESWAPPER_H_INC
|
||||
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
namespace Assimp {
|
||||
// --------------------------------------------------------------------------------------
|
||||
/** Defines some useful byte order swap routines.
|
||||
*
|
||||
* This is required to read big-endian model formats on little-endian machines,
|
||||
* and vice versa. Direct use of this class is DEPRECATED. Use #StreamReader instead. */
|
||||
// --------------------------------------------------------------------------------------
|
||||
class ByteSwap {
|
||||
ByteSwap() AI_NO_EXCEPT {}
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** Swap two bytes of data
|
||||
* @param[inout] _szOut A void* to save the reintcasts for the caller. */
|
||||
static inline void Swap2(void* _szOut)
|
||||
{
|
||||
ai_assert(_szOut);
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
uint16_t* const szOut = reinterpret_cast<uint16_t*>(_szOut);
|
||||
*szOut = _byteswap_ushort(*szOut);
|
||||
#else
|
||||
uint8_t* const szOut = reinterpret_cast<uint8_t*>(_szOut);
|
||||
std::swap(szOut[0],szOut[1]);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** Swap four bytes of data
|
||||
* @param[inout] _szOut A void* to save the reintcasts for the caller. */
|
||||
static inline void Swap4(void* _szOut)
|
||||
{
|
||||
ai_assert(_szOut);
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
uint32_t* const szOut = reinterpret_cast<uint32_t*>(_szOut);
|
||||
*szOut = _byteswap_ulong(*szOut);
|
||||
#else
|
||||
uint8_t* const szOut = reinterpret_cast<uint8_t*>(_szOut);
|
||||
std::swap(szOut[0],szOut[3]);
|
||||
std::swap(szOut[1],szOut[2]);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** Swap eight bytes of data
|
||||
* @param[inout] _szOut A void* to save the reintcasts for the caller. */
|
||||
static inline void Swap8(void* _szOut)
|
||||
{
|
||||
ai_assert(_szOut);
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
uint64_t* const szOut = reinterpret_cast<uint64_t*>(_szOut);
|
||||
*szOut = _byteswap_uint64(*szOut);
|
||||
#else
|
||||
uint8_t* const szOut = reinterpret_cast<uint8_t*>(_szOut);
|
||||
std::swap(szOut[0],szOut[7]);
|
||||
std::swap(szOut[1],szOut[6]);
|
||||
std::swap(szOut[2],szOut[5]);
|
||||
std::swap(szOut[3],szOut[4]);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** ByteSwap a float. Not a joke.
|
||||
* @param[inout] fOut ehm. .. */
|
||||
static inline void Swap(float* fOut) {
|
||||
Swap4(fOut);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** ByteSwap a double. Not a joke.
|
||||
* @param[inout] fOut ehm. .. */
|
||||
static inline void Swap(double* fOut) {
|
||||
Swap8(fOut);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** ByteSwap an int16t. Not a joke.
|
||||
* @param[inout] fOut ehm. .. */
|
||||
static inline void Swap(int16_t* fOut) {
|
||||
Swap2(fOut);
|
||||
}
|
||||
|
||||
static inline void Swap(uint16_t* fOut) {
|
||||
Swap2(fOut);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** ByteSwap an int32t. Not a joke.
|
||||
* @param[inout] fOut ehm. .. */
|
||||
static inline void Swap(int32_t* fOut){
|
||||
Swap4(fOut);
|
||||
}
|
||||
|
||||
static inline void Swap(uint32_t* fOut){
|
||||
Swap4(fOut);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** ByteSwap an int64t. Not a joke.
|
||||
* @param[inout] fOut ehm. .. */
|
||||
static inline void Swap(int64_t* fOut) {
|
||||
Swap8(fOut);
|
||||
}
|
||||
|
||||
static inline void Swap(uint64_t* fOut) {
|
||||
Swap8(fOut);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
//! Templatized ByteSwap
|
||||
//! \returns param tOut as swapped
|
||||
template<typename Type>
|
||||
static inline Type Swapped(Type tOut)
|
||||
{
|
||||
return _swapper<Type,sizeof(Type)>()(tOut);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
template <typename T, size_t size> struct _swapper;
|
||||
};
|
||||
|
||||
template <typename T> struct ByteSwap::_swapper<T,2> {
|
||||
T operator() (T tOut) {
|
||||
Swap2(&tOut);
|
||||
return tOut;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct ByteSwap::_swapper<T,4> {
|
||||
T operator() (T tOut) {
|
||||
Swap4(&tOut);
|
||||
return tOut;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct ByteSwap::_swapper<T,8> {
|
||||
T operator() (T tOut) {
|
||||
Swap8(&tOut);
|
||||
return tOut;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// ByteSwap macros for BigEndian/LittleEndian support
|
||||
// --------------------------------------------------------------------------------------
|
||||
#if (defined AI_BUILD_BIG_ENDIAN)
|
||||
# define AI_LE(t) (t)
|
||||
# define AI_BE(t) ByteSwap::Swapped(t)
|
||||
# define AI_LSWAP2(p)
|
||||
# define AI_LSWAP4(p)
|
||||
# define AI_LSWAP8(p)
|
||||
# define AI_LSWAP2P(p)
|
||||
# define AI_LSWAP4P(p)
|
||||
# define AI_LSWAP8P(p)
|
||||
# define LE_NCONST const
|
||||
# define AI_SWAP2(p) ByteSwap::Swap2(&(p))
|
||||
# define AI_SWAP4(p) ByteSwap::Swap4(&(p))
|
||||
# define AI_SWAP8(p) ByteSwap::Swap8(&(p))
|
||||
# define AI_SWAP2P(p) ByteSwap::Swap2((p))
|
||||
# define AI_SWAP4P(p) ByteSwap::Swap4((p))
|
||||
# define AI_SWAP8P(p) ByteSwap::Swap8((p))
|
||||
# define BE_NCONST
|
||||
#else
|
||||
# define AI_BE(t) (t)
|
||||
# define AI_LE(t) ByteSwap::Swapped(t)
|
||||
# define AI_SWAP2(p)
|
||||
# define AI_SWAP4(p)
|
||||
# define AI_SWAP8(p)
|
||||
# define AI_SWAP2P(p)
|
||||
# define AI_SWAP4P(p)
|
||||
# define AI_SWAP8P(p)
|
||||
# define BE_NCONST const
|
||||
# define AI_LSWAP2(p) ByteSwap::Swap2(&(p))
|
||||
# define AI_LSWAP4(p) ByteSwap::Swap4(&(p))
|
||||
# define AI_LSWAP8(p) ByteSwap::Swap8(&(p))
|
||||
# define AI_LSWAP2P(p) ByteSwap::Swap2((p))
|
||||
# define AI_LSWAP4P(p) ByteSwap::Swap4((p))
|
||||
# define AI_LSWAP8P(p) ByteSwap::Swap8((p))
|
||||
# define LE_NCONST
|
||||
#endif
|
||||
|
||||
|
||||
namespace Intern {
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template <typename T, bool doit>
|
||||
struct ByteSwapper {
|
||||
void operator() (T* inout) {
|
||||
ByteSwap::Swap(inout);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ByteSwapper<T,false> {
|
||||
void operator() (T*) {
|
||||
}
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template <bool SwapEndianess, typename T, bool RuntimeSwitch>
|
||||
struct Getter {
|
||||
void operator() (T* inout, bool le) {
|
||||
#ifdef AI_BUILD_BIG_ENDIAN
|
||||
le = le;
|
||||
#else
|
||||
le = !le;
|
||||
#endif
|
||||
if (le) {
|
||||
ByteSwapper<T,(sizeof(T)>1?true:false)> () (inout);
|
||||
}
|
||||
else ByteSwapper<T,false> () (inout);
|
||||
}
|
||||
};
|
||||
|
||||
template <bool SwapEndianess, typename T>
|
||||
struct Getter<SwapEndianess,T,false> {
|
||||
|
||||
void operator() (T* inout, bool /*le*/) {
|
||||
// static branch
|
||||
ByteSwapper<T,(SwapEndianess && sizeof(T)>1)> () (inout);
|
||||
}
|
||||
};
|
||||
} // end Intern
|
||||
} // end Assimp
|
||||
|
||||
#endif //!! AI_BYTESWAPPER_H_INC
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
|
||||
# pragma pack(push,1)
|
||||
# define PACK_STRUCT
|
||||
#elif defined( __GNUC__ ) || defined(__clang__)
|
||||
#elif defined( __GNUC__ )
|
||||
# if !defined(HOST_MINGW)
|
||||
# define PACK_STRUCT __attribute__((__packed__))
|
||||
# else
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file CreateAnimMesh.h
|
||||
* Create AnimMesh from Mesh
|
||||
*/
|
||||
#ifndef INCLUDED_AI_CREATE_ANIM_MESH_H
|
||||
#define INCLUDED_AI_CREATE_ANIM_MESH_H
|
||||
|
||||
#include <assimp/mesh.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
/** Create aiAnimMesh from aiMesh. */
|
||||
ASSIMP_API aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh);
|
||||
|
||||
} // end of namespace Assimp
|
||||
#endif // INCLUDED_AI_CREATE_ANIM_MESH_H
|
||||
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -69,7 +68,7 @@ class ASSIMP_API DefaultIOStream : public IOStream
|
|||
#endif // __ANDROID__
|
||||
|
||||
protected:
|
||||
DefaultIOStream() AI_NO_EXCEPT;
|
||||
DefaultIOStream();
|
||||
DefaultIOStream(FILE* pFile, const std::string &strFilename);
|
||||
|
||||
public:
|
||||
|
|
@ -111,25 +110,27 @@ private:
|
|||
FILE* mFile;
|
||||
// Filename
|
||||
std::string mFilename;
|
||||
|
||||
// Cached file size
|
||||
mutable size_t mCachedSize;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
DefaultIOStream::DefaultIOStream() AI_NO_EXCEPT
|
||||
: mFile(nullptr)
|
||||
, mFilename("")
|
||||
, mCachedSize(SIZE_MAX) {
|
||||
inline DefaultIOStream::DefaultIOStream () :
|
||||
mFile (NULL),
|
||||
mFilename (""),
|
||||
mCachedSize(SIZE_MAX)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
DefaultIOStream::DefaultIOStream (FILE* pFile, const std::string &strFilename)
|
||||
: mFile(pFile)
|
||||
, mFilename(strFilename)
|
||||
, mCachedSize(SIZE_MAX) {
|
||||
inline DefaultIOStream::DefaultIOStream (FILE* pFile,
|
||||
const std::string &strFilename) :
|
||||
mFile(pFile),
|
||||
mFilename(strFilename),
|
||||
mCachedSize(SIZE_MAX)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -50,8 +49,15 @@ namespace Assimp {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Default implementation of IOSystem using the standard C file functions */
|
||||
class ASSIMP_API DefaultIOSystem : public IOSystem {
|
||||
class ASSIMP_API DefaultIOSystem : public IOSystem
|
||||
{
|
||||
public:
|
||||
/** Constructor. */
|
||||
DefaultIOSystem();
|
||||
|
||||
/** Destructor. */
|
||||
~DefaultIOSystem();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Tests for the existence of a file at the given path. */
|
||||
bool Exists( const char* pFile) const;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -131,7 +130,9 @@ public:
|
|||
bool detatchStream(LogStream *pStream,
|
||||
unsigned int severity);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @briefPrivate construction for internal use by create().
|
||||
* @param severity Logging granularity */
|
||||
|
|
@ -141,6 +142,8 @@ private:
|
|||
/** @briefDestructor */
|
||||
~DefaultLogger();
|
||||
|
||||
private:
|
||||
|
||||
/** @brief Logs debug infos, only been written when severity level VERBOSE is set */
|
||||
void OnDebug(const char* message);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2008, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_EXCEPTIONAL_H
|
||||
#define INCLUDED_EXCEPTIONAL_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <assimp/DefaultIOStream.h>
|
||||
using std::runtime_error;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4275)
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** FOR IMPORTER PLUGINS ONLY: Simple exception class to be thrown if an
|
||||
* unrecoverable error occurs while importing. Loading APIs return
|
||||
* NULL instead of a valid aiScene then. */
|
||||
class DeadlyImportError
|
||||
: public runtime_error
|
||||
{
|
||||
public:
|
||||
/** Constructor with arguments */
|
||||
explicit DeadlyImportError( const std::string& errorText)
|
||||
: runtime_error(errorText)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
typedef DeadlyImportError DeadlyExportError;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(default : 4275)
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
struct ExceptionSwallower {
|
||||
T operator ()() const {
|
||||
return T();
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
struct ExceptionSwallower<T*> {
|
||||
T* operator ()() const {
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <>
|
||||
struct ExceptionSwallower<aiReturn> {
|
||||
aiReturn operator ()() const {
|
||||
try {
|
||||
throw;
|
||||
}
|
||||
catch (std::bad_alloc&) {
|
||||
return aiReturn_OUTOFMEMORY;
|
||||
}
|
||||
catch (...) {
|
||||
return aiReturn_FAILURE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template <>
|
||||
struct ExceptionSwallower<void> {
|
||||
void operator ()() const {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
#define ASSIMP_BEGIN_EXCEPTION_REGION()\
|
||||
{\
|
||||
try {
|
||||
|
||||
#define ASSIMP_END_EXCEPTION_REGION(type)\
|
||||
} catch(...) {\
|
||||
return ExceptionSwallower<type>()();\
|
||||
}\
|
||||
}
|
||||
|
||||
#endif // INCLUDED_EXCEPTIONAL_H
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -115,16 +114,12 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The class constructor.
|
||||
*/
|
||||
Exporter();
|
||||
|
||||
/**
|
||||
* @brief The class destructor.
|
||||
*/
|
||||
public:
|
||||
Exporter();
|
||||
~Exporter();
|
||||
|
||||
public:
|
||||
// -------------------------------------------------------------------
|
||||
/** Supplies a custom IO handler to the exporter to use to open and
|
||||
* access files.
|
||||
|
|
@ -176,10 +171,8 @@ public:
|
|||
* Any IO handlers set via #SetIOHandler are ignored here.
|
||||
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
||||
* imported scene. */
|
||||
const aiExportDataBlob* ExportToBlob(const aiScene* pScene, const char* pFormatId,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties* = nullptr);
|
||||
const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr);
|
||||
const aiExportDataBlob* ExportToBlob(const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* = NULL);
|
||||
const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Convenience function to export directly to a file. Use
|
||||
|
|
@ -214,10 +207,8 @@ public:
|
|||
* @return AI_SUCCESS if everything was fine.
|
||||
* @note Use aiCopyScene() to get a modifiable copy of a previously
|
||||
* imported scene.*/
|
||||
aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr);
|
||||
aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath,
|
||||
unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = nullptr);
|
||||
aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
|
||||
aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns an error description of an error that occurred in #Export
|
||||
|
|
|
|||
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef AI_GENERIC_PROPERTY_H_INCLUDED
|
||||
#define AI_GENERIC_PROPERTY_H_INCLUDED
|
||||
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include "Hash.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
inline
|
||||
bool SetGenericProperty(std::map< unsigned int, T >& list,
|
||||
const char* szName, const T& value) {
|
||||
ai_assert(nullptr != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
||||
if (it == list.end()) {
|
||||
list.insert(std::pair<unsigned int, T>( hash, value ));
|
||||
return false;
|
||||
}
|
||||
(*it).second = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
inline
|
||||
const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
||||
const char* szName, const T& errorReturn) {
|
||||
ai_assert(nullptr != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
||||
if (it == list.end()) {
|
||||
return errorReturn;
|
||||
}
|
||||
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Special version for pointer types - they will be deleted when replaced with another value
|
||||
// passing NULL removes the whole property
|
||||
template <class T>
|
||||
inline
|
||||
void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
||||
const char* szName, T* value, bool* bWasExisting = nullptr ) {
|
||||
ai_assert(nullptr != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename std::map<unsigned int, T*>::iterator it = list.find(hash);
|
||||
if (it == list.end()) {
|
||||
if (bWasExisting) {
|
||||
*bWasExisting = false;
|
||||
}
|
||||
|
||||
list.insert(std::pair<unsigned int,T*>( hash, value ));
|
||||
return;
|
||||
}
|
||||
if ((*it).second != value) {
|
||||
delete (*it).second;
|
||||
(*it).second = value;
|
||||
}
|
||||
if (!value) {
|
||||
list.erase(it);
|
||||
}
|
||||
if (bWasExisting) {
|
||||
*bWasExisting = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
inline
|
||||
bool HasGenericProperty(const std::map< unsigned int, T >& list,
|
||||
const char* szName) {
|
||||
ai_assert(nullptr != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
||||
if (it == list.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // !! AI_GENERIC_PROPERTY_H_INCLUDED
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef AI_HASH_H_INCLUDED
|
||||
#define AI_HASH_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Hashing function taken from
|
||||
// http://www.azillionmonkeys.com/qed/hash.html
|
||||
// (incremental version)
|
||||
//
|
||||
// This code is Copyright 2004-2008 by Paul Hsieh. It is used here in the belief that
|
||||
// Assimp's license is considered compatible with Pauls's derivative license as specified
|
||||
// on his web page.
|
||||
//
|
||||
// (stdint.h should have been been included here)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#undef get16bits
|
||||
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|
||||
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
|
||||
#define get16bits(d) (*((const uint16_t *) (d)))
|
||||
#endif
|
||||
|
||||
#if !defined (get16bits)
|
||||
#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
|
||||
+(uint32_t)(((const uint8_t *)(d))[0]) )
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
inline uint32_t SuperFastHash (const char * data, uint32_t len = 0, uint32_t hash = 0) {
|
||||
uint32_t tmp;
|
||||
int rem;
|
||||
|
||||
if (!data) return 0;
|
||||
if (!len)len = (uint32_t)::strlen(data);
|
||||
|
||||
rem = len & 3;
|
||||
len >>= 2;
|
||||
|
||||
/* Main loop */
|
||||
for (;len > 0; len--) {
|
||||
hash += get16bits (data);
|
||||
tmp = (get16bits (data+2) << 11) ^ hash;
|
||||
hash = (hash << 16) ^ tmp;
|
||||
data += 2*sizeof (uint16_t);
|
||||
hash += hash >> 11;
|
||||
}
|
||||
|
||||
/* Handle end cases */
|
||||
switch (rem) {
|
||||
case 3: hash += get16bits (data);
|
||||
hash ^= hash << 16;
|
||||
hash ^= data[sizeof (uint16_t)] << 18;
|
||||
hash += hash >> 11;
|
||||
break;
|
||||
case 2: hash += get16bits (data);
|
||||
hash ^= hash << 11;
|
||||
hash += hash >> 17;
|
||||
break;
|
||||
case 1: hash += *data;
|
||||
hash ^= hash << 10;
|
||||
hash += hash >> 1;
|
||||
}
|
||||
|
||||
/* Force "avalanching" of final 127 bits */
|
||||
hash ^= hash << 3;
|
||||
hash += hash >> 5;
|
||||
hash ^= hash << 4;
|
||||
hash += hash >> 17;
|
||||
hash ^= hash << 25;
|
||||
hash += hash >> 6;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
#endif // !! AI_HASH_H_INCLUDED
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -71,7 +70,7 @@ class ASSIMP_API IOStream
|
|||
{
|
||||
protected:
|
||||
/** Constructor protected, use IOSystem::Open() to create an instance. */
|
||||
IOStream() AI_NO_EXCEPT;
|
||||
IOStream(void);
|
||||
|
||||
public:
|
||||
// -------------------------------------------------------------------
|
||||
|
|
@ -125,18 +124,17 @@ public:
|
|||
}; //! class IOStream
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
IOStream::IOStream() AI_NO_EXCEPT {
|
||||
inline IOStream::IOStream()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
IOStream::~IOStream() {
|
||||
inline IOStream::~IOStream()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
} //!namespace Assimp
|
||||
|
||||
#endif //!!AI_IOSTREAM_H_INC
|
||||
|
|
|
|||
|
|
@ -1,352 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/IOStream.hpp>
|
||||
|
||||
#include "ParsingUtils.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/**
|
||||
* Implementation of a cached stream buffer.
|
||||
*/
|
||||
template<class T>
|
||||
class IOStreamBuffer {
|
||||
public:
|
||||
/// @brief The class constructor.
|
||||
IOStreamBuffer( size_t cache = 4096 * 4096 );
|
||||
|
||||
/// @brief The class destructor.
|
||||
~IOStreamBuffer();
|
||||
|
||||
/// @brief Will open the cached access for a given stream.
|
||||
/// @param stream The stream to cache.
|
||||
/// @return true if successful.
|
||||
bool open( IOStream *stream );
|
||||
|
||||
/// @brief Will close the cached access.
|
||||
/// @return true if successful.
|
||||
bool close();
|
||||
|
||||
/// @brief Returns the file-size.
|
||||
/// @return The file-size.
|
||||
size_t size() const;
|
||||
|
||||
/// @brief Returns the cache size.
|
||||
/// @return The cache size.
|
||||
size_t cacheSize() const;
|
||||
|
||||
/// @brief Will read the next block.
|
||||
/// @return true if successful.
|
||||
bool readNextBlock();
|
||||
|
||||
/// @brief Returns the number of blocks to read.
|
||||
/// @return The number of blocks.
|
||||
size_t getNumBlocks() const;
|
||||
|
||||
/// @brief Returns the current block index.
|
||||
/// @return The current block index.
|
||||
size_t getCurrentBlockIndex() const;
|
||||
|
||||
/// @brief Returns the current file pos.
|
||||
/// @return The current file pos.
|
||||
size_t getFilePos() const;
|
||||
|
||||
/// @brief Will read the next line.
|
||||
/// @param buffer The buffer for the next line.
|
||||
/// @return true if successful.
|
||||
bool getNextDataLine( std::vector<T> &buffer, T continuationToken );
|
||||
|
||||
/// @brief Will read the next line ascii or binary end line char.
|
||||
/// @param buffer The buffer for the next line.
|
||||
/// @return true if successful.
|
||||
bool getNextLine(std::vector<T> &buffer);
|
||||
|
||||
/// @brief Will read the next block.
|
||||
/// @param buffer The buffer for the next block.
|
||||
/// @return true if successful.
|
||||
bool getNextBlock( std::vector<T> &buffer );
|
||||
|
||||
private:
|
||||
IOStream *m_stream;
|
||||
size_t m_filesize;
|
||||
size_t m_cacheSize;
|
||||
size_t m_numBlocks;
|
||||
size_t m_blockIdx;
|
||||
std::vector<T> m_cache;
|
||||
size_t m_cachePos;
|
||||
size_t m_filePos;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
IOStreamBuffer<T>::IOStreamBuffer( size_t cache )
|
||||
: m_stream( nullptr )
|
||||
, m_filesize( 0 )
|
||||
, m_cacheSize( cache )
|
||||
, m_numBlocks( 0 )
|
||||
, m_blockIdx( 0 )
|
||||
, m_cachePos( 0 )
|
||||
, m_filePos( 0 ) {
|
||||
m_cache.resize( cache );
|
||||
std::fill( m_cache.begin(), m_cache.end(), '\n' );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
IOStreamBuffer<T>::~IOStreamBuffer() {
|
||||
// empty
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
bool IOStreamBuffer<T>::open( IOStream *stream ) {
|
||||
// file still opened!
|
||||
if ( nullptr != m_stream ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Invalid stream pointer
|
||||
if ( nullptr == stream ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_stream = stream;
|
||||
m_filesize = m_stream->FileSize();
|
||||
if ( m_filesize == 0 ) {
|
||||
return false;
|
||||
}
|
||||
if ( m_filesize < m_cacheSize ) {
|
||||
m_cacheSize = m_filesize;
|
||||
}
|
||||
|
||||
m_numBlocks = m_filesize / m_cacheSize;
|
||||
if ( ( m_filesize % m_cacheSize ) > 0 ) {
|
||||
m_numBlocks++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
bool IOStreamBuffer<T>::close() {
|
||||
if ( nullptr == m_stream ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// init counters and state vars
|
||||
m_stream = nullptr;
|
||||
m_filesize = 0;
|
||||
m_numBlocks = 0;
|
||||
m_blockIdx = 0;
|
||||
m_cachePos = 0;
|
||||
m_filePos = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
size_t IOStreamBuffer<T>::size() const {
|
||||
return m_filesize;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
size_t IOStreamBuffer<T>::cacheSize() const {
|
||||
return m_cacheSize;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
bool IOStreamBuffer<T>::readNextBlock() {
|
||||
m_stream->Seek( m_filePos, aiOrigin_SET );
|
||||
size_t readLen = m_stream->Read( &m_cache[ 0 ], sizeof( T ), m_cacheSize );
|
||||
if ( readLen == 0 ) {
|
||||
return false;
|
||||
}
|
||||
if ( readLen < m_cacheSize ) {
|
||||
m_cacheSize = readLen;
|
||||
}
|
||||
m_filePos += m_cacheSize;
|
||||
m_cachePos = 0;
|
||||
m_blockIdx++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
size_t IOStreamBuffer<T>::getNumBlocks() const {
|
||||
return m_numBlocks;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
size_t IOStreamBuffer<T>::getCurrentBlockIndex() const {
|
||||
return m_blockIdx;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
size_t IOStreamBuffer<T>::getFilePos() const {
|
||||
return m_filePos;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
bool IOStreamBuffer<T>::getNextDataLine( std::vector<T> &buffer, T continuationToken ) {
|
||||
buffer.resize( m_cacheSize );
|
||||
if ( m_cachePos == m_cacheSize || 0 == m_filePos ) {
|
||||
if ( !readNextBlock() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool continuationFound( false );
|
||||
size_t i = 0;
|
||||
for( ;; ) {
|
||||
if ( continuationToken == m_cache[ m_cachePos ] ) {
|
||||
continuationFound = true;
|
||||
++m_cachePos;
|
||||
}
|
||||
if ( IsLineEnd( m_cache[ m_cachePos ] ) ) {
|
||||
if ( !continuationFound ) {
|
||||
// the end of the data line
|
||||
break;
|
||||
} else {
|
||||
// skip line end
|
||||
while ( m_cache[m_cachePos] != '\n') {
|
||||
++m_cachePos;
|
||||
}
|
||||
++m_cachePos;
|
||||
continuationFound = false;
|
||||
}
|
||||
}
|
||||
|
||||
buffer[ i ] = m_cache[ m_cachePos ];
|
||||
++m_cachePos;
|
||||
++i;
|
||||
if ( m_cachePos >= m_cacheSize ) {
|
||||
if ( !readNextBlock() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buffer[ i ] = '\n';
|
||||
++m_cachePos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline
|
||||
bool isEndOfCache( size_t pos, size_t cacheSize ) {
|
||||
return ( pos == cacheSize );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
|
||||
buffer.resize(m_cacheSize);
|
||||
if ( isEndOfCache( m_cachePos, m_cacheSize ) || 0 == m_filePos) {
|
||||
if (!readNextBlock()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsLineEnd(m_cache[m_cachePos])) {
|
||||
// skip line end
|
||||
while (m_cache[m_cachePos] != '\n') {
|
||||
++m_cachePos;
|
||||
}
|
||||
++m_cachePos;
|
||||
if ( isEndOfCache( m_cachePos, m_cacheSize ) ) {
|
||||
if ( !readNextBlock() ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t i( 0 );
|
||||
while (!IsLineEnd(m_cache[ m_cachePos ])) {
|
||||
buffer[i] = m_cache[ m_cachePos ];
|
||||
++m_cachePos;
|
||||
++i;
|
||||
if (m_cachePos >= m_cacheSize) {
|
||||
if (!readNextBlock()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
buffer[i] = '\n';
|
||||
++m_cachePos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
bool IOStreamBuffer<T>::getNextBlock( std::vector<T> &buffer) {
|
||||
// Return the last block-value if getNextLine was used before
|
||||
if ( 0 != m_cachePos ) {
|
||||
buffer = std::vector<T>( m_cache.begin() + m_cachePos, m_cache.end() );
|
||||
m_cachePos = 0;
|
||||
} else {
|
||||
if ( !readNextBlock() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer = std::vector<T>(m_cache.begin(), m_cache.end());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // !ns Assimp
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -95,7 +94,7 @@ public:
|
|||
* Create an instance of your derived class and assign it to an
|
||||
* #Assimp::Importer instance by calling Importer::SetIOHandler().
|
||||
*/
|
||||
IOSystem() AI_NO_EXCEPT;
|
||||
IOSystem();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Virtual destructor.
|
||||
|
|
@ -105,6 +104,9 @@ public:
|
|||
*/
|
||||
virtual ~IOSystem();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief For backward compatibility
|
||||
* @see Exists(const char*)
|
||||
|
|
@ -230,7 +232,7 @@ private:
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
IOSystem::IOSystem() AI_NO_EXCEPT
|
||||
IOSystem::IOSystem()
|
||||
: m_pathStack() {
|
||||
// empty
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -137,12 +136,7 @@ public:
|
|||
* If this Importer owns a scene it won't be copied.
|
||||
* Call ReadFile() to start the import process.
|
||||
*/
|
||||
Importer(const Importer& other)=delete;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Assignment operator has been deleted
|
||||
*/
|
||||
Importer &operator=(const Importer &) = delete;
|
||||
Importer(const Importer& other);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Destructor. The object kept ownership of the imported data,
|
||||
|
|
|
|||
|
|
@ -1,285 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file LineSplitter.h
|
||||
* @brief LineSplitter, a helper class to iterate through all lines
|
||||
* of a file easily. Works with StreamReader.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef INCLUDED_LINE_SPLITTER_H
|
||||
#define INCLUDED_LINE_SPLITTER_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include "StreamReader.h"
|
||||
#include "ParsingUtils.h"
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** Usage:
|
||||
@code
|
||||
for(LineSplitter splitter(stream);splitter;++splitter) {
|
||||
|
||||
if (*splitter == "hi!") {
|
||||
...
|
||||
}
|
||||
else if (splitter->substr(0,5) == "hello") {
|
||||
...
|
||||
// access the third token in the line (tokens are space-separated)
|
||||
if (strtol(splitter[2]) > 5) { .. }
|
||||
}
|
||||
|
||||
std::cout << "Current line is: " << splitter.get_index() << std::endl;
|
||||
}
|
||||
@endcode
|
||||
*/
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class LineSplitter {
|
||||
public:
|
||||
typedef size_t line_idx;
|
||||
|
||||
// -----------------------------------------
|
||||
/** construct from existing stream reader
|
||||
note: trim is *always* assumed true if skyp_empty_lines==true
|
||||
*/
|
||||
LineSplitter(StreamReaderLE& stream, bool skip_empty_lines = true, bool trim = true);
|
||||
|
||||
~LineSplitter();
|
||||
|
||||
// -----------------------------------------
|
||||
/** pseudo-iterator increment */
|
||||
LineSplitter& operator++();
|
||||
|
||||
// -----------------------------------------
|
||||
LineSplitter& operator++(int);
|
||||
|
||||
// -----------------------------------------
|
||||
/** get a pointer to the beginning of a particular token */
|
||||
const char* operator[] (size_t idx) const;
|
||||
|
||||
// -----------------------------------------
|
||||
/** extract the start positions of N tokens from the current line*/
|
||||
template <size_t N>
|
||||
void get_tokens(const char* (&tokens)[N]) const;
|
||||
|
||||
// -----------------------------------------
|
||||
/** member access */
|
||||
const std::string* operator -> () const;
|
||||
|
||||
std::string operator* () const;
|
||||
|
||||
// -----------------------------------------
|
||||
/** boolean context */
|
||||
operator bool() const;
|
||||
|
||||
// -----------------------------------------
|
||||
/** line indices are zero-based, empty lines are included */
|
||||
operator line_idx() const;
|
||||
|
||||
line_idx get_index() const;
|
||||
|
||||
// -----------------------------------------
|
||||
/** access the underlying stream object */
|
||||
StreamReaderLE& get_stream();
|
||||
|
||||
// -----------------------------------------
|
||||
/** !strcmp((*this)->substr(0,strlen(check)),check) */
|
||||
bool match_start(const char* check);
|
||||
|
||||
// -----------------------------------------
|
||||
/** swallow the next call to ++, return the previous value. */
|
||||
void swallow_next_increment();
|
||||
|
||||
LineSplitter( const LineSplitter & ) = delete;
|
||||
LineSplitter(LineSplitter &&) = delete;
|
||||
LineSplitter &operator = ( const LineSplitter & ) = delete;
|
||||
|
||||
private:
|
||||
line_idx mIdx;
|
||||
std::string mCur;
|
||||
StreamReaderLE& mStream;
|
||||
bool mSwallow, mSkip_empty_lines, mTrim;
|
||||
};
|
||||
|
||||
inline
|
||||
LineSplitter::LineSplitter(StreamReaderLE& stream, bool skip_empty_lines, bool trim )
|
||||
: mIdx(0)
|
||||
, mCur()
|
||||
, mStream(stream)
|
||||
, mSwallow()
|
||||
, mSkip_empty_lines(skip_empty_lines)
|
||||
, mTrim(trim) {
|
||||
mCur.reserve(1024);
|
||||
operator++();
|
||||
mIdx = 0;
|
||||
}
|
||||
|
||||
inline
|
||||
LineSplitter::~LineSplitter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
LineSplitter& LineSplitter::operator++() {
|
||||
if (mSwallow) {
|
||||
mSwallow = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (!*this) {
|
||||
throw std::logic_error("End of file, no more lines to be retrieved.");
|
||||
}
|
||||
|
||||
char s;
|
||||
mCur.clear();
|
||||
while (mStream.GetRemainingSize() && (s = mStream.GetI1(), 1)) {
|
||||
if (s == '\n' || s == '\r') {
|
||||
if (mSkip_empty_lines) {
|
||||
while (mStream.GetRemainingSize() && ((s = mStream.GetI1()) == ' ' || s == '\r' || s == '\n'));
|
||||
if (mStream.GetRemainingSize()) {
|
||||
mStream.IncPtr(-1);
|
||||
}
|
||||
} else {
|
||||
// skip both potential line terminators but don't read past this line.
|
||||
if (mStream.GetRemainingSize() && (s == '\r' && mStream.GetI1() != '\n')) {
|
||||
mStream.IncPtr(-1);
|
||||
}
|
||||
if (mTrim) {
|
||||
while (mStream.GetRemainingSize() && ((s = mStream.GetI1()) == ' ' || s == '\t'));
|
||||
if (mStream.GetRemainingSize()) {
|
||||
mStream.IncPtr(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
mCur += s;
|
||||
}
|
||||
++mIdx;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
LineSplitter &LineSplitter::operator++(int) {
|
||||
return ++(*this);
|
||||
}
|
||||
|
||||
inline
|
||||
const char *LineSplitter::operator[] (size_t idx) const {
|
||||
const char* s = operator->()->c_str();
|
||||
|
||||
SkipSpaces(&s);
|
||||
for (size_t i = 0; i < idx; ++i) {
|
||||
|
||||
for (; !IsSpace(*s); ++s) {
|
||||
if (IsLineEnd(*s)) {
|
||||
throw std::range_error("Token index out of range, EOL reached");
|
||||
}
|
||||
}
|
||||
SkipSpaces(&s);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
inline
|
||||
void LineSplitter::get_tokens(const char* (&tokens)[N]) const {
|
||||
const char* s = operator->()->c_str();
|
||||
|
||||
SkipSpaces(&s);
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
if (IsLineEnd(*s)) {
|
||||
throw std::range_error("Token count out of range, EOL reached");
|
||||
}
|
||||
tokens[i] = s;
|
||||
|
||||
for (; *s && !IsSpace(*s); ++s);
|
||||
SkipSpaces(&s);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
const std::string* LineSplitter::operator -> () const {
|
||||
return &mCur;
|
||||
}
|
||||
|
||||
inline
|
||||
std::string LineSplitter::operator* () const {
|
||||
return mCur;
|
||||
}
|
||||
|
||||
inline
|
||||
LineSplitter::operator bool() const {
|
||||
return mStream.GetRemainingSize() > 0;
|
||||
}
|
||||
|
||||
inline
|
||||
LineSplitter::operator line_idx() const {
|
||||
return mIdx;
|
||||
}
|
||||
|
||||
inline
|
||||
LineSplitter::line_idx LineSplitter::get_index() const {
|
||||
return mIdx;
|
||||
}
|
||||
|
||||
inline
|
||||
StreamReaderLE &LineSplitter::get_stream() {
|
||||
return mStream;
|
||||
}
|
||||
|
||||
inline
|
||||
bool LineSplitter::match_start(const char* check) {
|
||||
const size_t len = ::strlen(check);
|
||||
|
||||
return len <= mCur.length() && std::equal(check, check + len, mCur.begin());
|
||||
}
|
||||
|
||||
inline
|
||||
void LineSplitter::swallow_next_increment() {
|
||||
mSwallow = true;
|
||||
}
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
#endif // INCLUDED_LINE_SPLITTER_H
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file LogAux.h
|
||||
* @brief Common logging usage patterns for importer implementations
|
||||
*/
|
||||
#ifndef INCLUDED_AI_LOGAUX_H
|
||||
#define INCLUDED_AI_LOGAUX_H
|
||||
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
template<class TDeriving>
|
||||
class LogFunctions {
|
||||
public:
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void ThrowException(const std::string& msg)
|
||||
{
|
||||
throw DeadlyImportError(Prefix()+msg);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogWarn(const Formatter::format& message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
ASSIMP_LOG_WARN(Prefix()+(std::string)message);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogError(const Formatter::format& message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
ASSIMP_LOG_ERROR(Prefix()+(std::string)message);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogInfo(const Formatter::format& message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
ASSIMP_LOG_INFO(Prefix()+(std::string)message);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogDebug(const Formatter::format& message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
ASSIMP_LOG_DEBUG(Prefix()+(std::string)message);
|
||||
}
|
||||
}
|
||||
|
||||
// https://sourceforge.net/tracker/?func=detail&atid=1067632&aid=3358562&group_id=226462
|
||||
#if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogWarn (const char* message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
LogWarn(Formatter::format(message));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogError (const char* message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
LogError(Formatter::format(message));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogInfo (const char* message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
LogInfo(Formatter::format(message));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void LogDebug (const char* message) {
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
LogDebug(Formatter::format(message));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
static const char* Prefix();
|
||||
|
||||
};
|
||||
} // ! Assimp
|
||||
|
||||
#endif
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ class ASSIMP_API LogStream
|
|||
{
|
||||
protected:
|
||||
/** @brief Default constructor */
|
||||
LogStream() AI_NO_EXCEPT;
|
||||
LogStream();
|
||||
|
||||
public:
|
||||
/** @brief Virtual destructor */
|
||||
|
|
@ -91,12 +90,12 @@ public:
|
|||
* @return New LogStream instance. */
|
||||
static LogStream* createDefaultStream(aiDefaultLogStream stream,
|
||||
const char* name = "AssimpLog.txt",
|
||||
IOSystem* io = nullptr );
|
||||
IOSystem* io = NULL);
|
||||
|
||||
}; // !class LogStream
|
||||
|
||||
inline
|
||||
LogStream::LogStream() AI_NO_EXCEPT {
|
||||
LogStream::LogStream() {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -46,8 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef INCLUDED_AI_LOGGER_H
|
||||
#define INCLUDED_AI_LOGGER_H
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/TinyFormatter.h>
|
||||
#include "types.h"
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
|
|
@ -60,7 +58,7 @@ class LogStream;
|
|||
/** @brief CPP-API: Abstract interface for logger implementations.
|
||||
* Assimp provides a default implementation and uses it for almost all
|
||||
* logging stuff ('DefaultLogger'). This class defines just basic logging
|
||||
* behavior and is not of interest for you. Instead, take a look at #DefaultLogger. */
|
||||
* behaviour and is not of interest for you. Instead, take a look at #DefaultLogger. */
|
||||
class ASSIMP_API Logger
|
||||
#ifndef SWIG
|
||||
: public Intern::AllocateFromAssimpHeap
|
||||
|
|
@ -72,7 +70,8 @@ public:
|
|||
/** @enum LogSeverity
|
||||
* @brief Log severity to describe the granularity of logging.
|
||||
*/
|
||||
enum LogSeverity {
|
||||
enum LogSeverity
|
||||
{
|
||||
NORMAL, //!< Normal granularity of logging
|
||||
VERBOSE //!< Debug infos will be logged, too
|
||||
};
|
||||
|
|
@ -85,7 +84,8 @@ public:
|
|||
* A LogStream doesn't receive any messages of a specific type
|
||||
* if it doesn't specify the corresponding ErrorSeverity flag.
|
||||
*/
|
||||
enum ErrorSeverity {
|
||||
enum ErrorSeverity
|
||||
{
|
||||
Debugging = 1, //!< Debug log message
|
||||
Info = 2, //!< Info log message
|
||||
Warn = 4, //!< Warn log message
|
||||
|
|
@ -101,25 +101,25 @@ public:
|
|||
/** @brief Writes a debug message
|
||||
* @param message Debug message*/
|
||||
void debug(const char* message);
|
||||
void debug(const std::string &message);
|
||||
inline void debug(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes a info message
|
||||
* @param message Info message*/
|
||||
void info(const char* message);
|
||||
void info(const std::string &message);
|
||||
inline void info(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes a warning message
|
||||
* @param message Warn message*/
|
||||
void warn(const char* message);
|
||||
void warn(const std::string &message);
|
||||
inline void warn(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Writes an error message
|
||||
* @param message Error message*/
|
||||
void error(const char* message);
|
||||
void error(const std::string &message);
|
||||
inline void error(const std::string &message);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/** @brief Set a new log severity.
|
||||
|
|
@ -158,19 +158,15 @@ public:
|
|||
unsigned int severity = Debugging | Err | Warn | Info) = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
Logger() AI_NO_EXCEPT;
|
||||
|
||||
/**
|
||||
* Construction with a given log severity
|
||||
*/
|
||||
/** Default constructor */
|
||||
Logger();
|
||||
|
||||
/** Construction with a given log severity */
|
||||
explicit Logger(LogSeverity severity);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Called as a request to write a specific debug message
|
||||
/** @brief Called as a request to write a specific debug message
|
||||
* @param message Debug message. Never longer than
|
||||
* MAX_LOG_MESSAGE_LENGTH characters (excluding the '0').
|
||||
* @note The message string is only valid until the scope of
|
||||
|
|
@ -179,8 +175,7 @@ protected:
|
|||
virtual void OnDebug(const char* message)= 0;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Called as a request to write a specific info message
|
||||
/** @brief Called as a request to write a specific info message
|
||||
* @param message Info message. Never longer than
|
||||
* MAX_LOG_MESSAGE_LENGTH characters (ecxluding the '0').
|
||||
* @note The message string is only valid until the scope of
|
||||
|
|
@ -189,8 +184,7 @@ protected:
|
|||
virtual void OnInfo(const char* message) = 0;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Called as a request to write a specific warn message
|
||||
/** @brief Called as a request to write a specific warn message
|
||||
* @param message Warn message. Never longer than
|
||||
* MAX_LOG_MESSAGE_LENGTH characters (exluding the '0').
|
||||
* @note The message string is only valid until the scope of
|
||||
|
|
@ -199,8 +193,7 @@ protected:
|
|||
virtual void OnWarn(const char* essage) = 0;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Called as a request to write a specific error message
|
||||
/** @brief Called as a request to write a specific error message
|
||||
* @param message Error message. Never longer than
|
||||
* MAX_LOG_MESSAGE_LENGTH characters (exluding the '0').
|
||||
* @note The message string is only valid until the scope of
|
||||
|
|
@ -209,96 +202,66 @@ protected:
|
|||
virtual void OnError(const char* message) = 0;
|
||||
|
||||
protected:
|
||||
|
||||
//! Logger severity
|
||||
LogSeverity m_Severity;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Default constructor
|
||||
inline
|
||||
Logger::Logger() AI_NO_EXCEPT
|
||||
: m_Severity(NORMAL) {
|
||||
// empty
|
||||
inline Logger::Logger() {
|
||||
setLogSeverity(NORMAL);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Virtual destructor
|
||||
inline
|
||||
Logger::~Logger() {
|
||||
// empty
|
||||
inline Logger::~Logger()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Construction with given logging severity
|
||||
inline
|
||||
Logger::Logger(LogSeverity severity)
|
||||
: m_Severity(severity) {
|
||||
// empty
|
||||
inline Logger::Logger(LogSeverity severity) {
|
||||
setLogSeverity(severity);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Log severity setter
|
||||
inline
|
||||
void Logger::setLogSeverity(LogSeverity log_severity){
|
||||
inline void Logger::setLogSeverity(LogSeverity log_severity){
|
||||
m_Severity = log_severity;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
// Log severity getter
|
||||
inline
|
||||
Logger::LogSeverity Logger::getLogSeverity() const {
|
||||
inline Logger::LogSeverity Logger::getLogSeverity() const {
|
||||
return m_Severity;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
void Logger::debug(const std::string &message) {
|
||||
inline void Logger::debug(const std::string &message)
|
||||
{
|
||||
return debug(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
void Logger::error(const std::string &message) {
|
||||
inline void Logger::error(const std::string &message)
|
||||
{
|
||||
return error(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
void Logger::warn(const std::string &message) {
|
||||
inline void Logger::warn(const std::string &message)
|
||||
{
|
||||
return warn(message.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
inline
|
||||
void Logger::info(const std::string &message) {
|
||||
inline void Logger::info(const std::string &message)
|
||||
{
|
||||
return info(message.c_str());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define ASSIMP_LOG_WARN_F(string,...)\
|
||||
DefaultLogger::get()->warn((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_ERROR_F(string,...)\
|
||||
DefaultLogger::get()->error((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_DEBUG_F(string,...)\
|
||||
DefaultLogger::get()->debug((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
#define ASSIMP_LOG_INFO_F(string,...)\
|
||||
DefaultLogger::get()->info((Formatter::format(string),__VA_ARGS__))
|
||||
|
||||
|
||||
#define ASSIMP_LOG_WARN(string)\
|
||||
DefaultLogger::get()->warn(string)
|
||||
|
||||
#define ASSIMP_LOG_ERROR(string)\
|
||||
DefaultLogger::get()->error(string)
|
||||
|
||||
#define ASSIMP_LOG_DEBUG(string)\
|
||||
DefaultLogger::get()->debug(string)
|
||||
|
||||
#define ASSIMP_LOG_INFO(string)\
|
||||
DefaultLogger::get()->info(string)
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Helper macro to set a pointer to NULL in debug builds
|
||||
*/
|
||||
#if (defined ASSIMP_BUILD_DEBUG)
|
||||
# define AI_DEBUG_INVALIDATE_PTR(x) x = NULL;
|
||||
#else
|
||||
# define AI_DEBUG_INVALIDATE_PTR(x)
|
||||
#endif
|
||||
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2016, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file MathFunctions.h
|
||||
* @brief Implementation of the math functions (gcd and lcm)
|
||||
*
|
||||
* Copied from BoostWorkaround/math
|
||||
*/
|
||||
|
||||
namespace Assimp {
|
||||
namespace Math {
|
||||
|
||||
// TODO: use binary GCD for unsigned integers ....
|
||||
template < typename IntegerType >
|
||||
IntegerType gcd( IntegerType a, IntegerType b )
|
||||
{
|
||||
const IntegerType zero = (IntegerType)0;
|
||||
while ( true )
|
||||
{
|
||||
if ( a == zero )
|
||||
return b;
|
||||
b %= a;
|
||||
|
||||
if ( b == zero )
|
||||
return a;
|
||||
a %= b;
|
||||
}
|
||||
}
|
||||
|
||||
template < typename IntegerType >
|
||||
IntegerType lcm( IntegerType a, IntegerType b )
|
||||
{
|
||||
const IntegerType t = gcd (a,b);
|
||||
if (!t)return t;
|
||||
return a / t * b;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file MemoryIOWrapper.h
|
||||
* Handy IOStream/IOSystem implemetation to read directly from a memory buffer */
|
||||
#ifndef AI_MEMORYIOSTREAM_H_INC
|
||||
#define AI_MEMORYIOSTREAM_H_INC
|
||||
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Assimp {
|
||||
#define AI_MEMORYIO_MAGIC_FILENAME "$$$___magic___$$$"
|
||||
#define AI_MEMORYIO_MAGIC_FILENAME_LENGTH 17
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
/** Implementation of IOStream to read directly from a memory buffer */
|
||||
// ----------------------------------------------------------------------------------
|
||||
class MemoryIOStream : public IOStream
|
||||
{
|
||||
//friend class MemoryIOSystem;
|
||||
public:
|
||||
MemoryIOStream (const uint8_t* buff, size_t len, bool own = false)
|
||||
: buffer (buff)
|
||||
, length(len)
|
||||
, pos((size_t)0)
|
||||
, own(own)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
~MemoryIOStream () {
|
||||
if(own) {
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Read from stream
|
||||
size_t Read(void* pvBuffer, size_t pSize, size_t pCount) {
|
||||
const size_t cnt = std::min(pCount,(length-pos)/pSize),ofs = pSize*cnt;
|
||||
|
||||
memcpy(pvBuffer,buffer+pos,ofs);
|
||||
pos += ofs;
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Write to stream
|
||||
size_t Write(const void* /*pvBuffer*/, size_t /*pSize*/,size_t /*pCount*/) {
|
||||
ai_assert(false); // won't be needed
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Seek specific position
|
||||
aiReturn Seek(size_t pOffset, aiOrigin pOrigin) {
|
||||
if (aiOrigin_SET == pOrigin) {
|
||||
if (pOffset > length) {
|
||||
return AI_FAILURE;
|
||||
}
|
||||
pos = pOffset;
|
||||
}
|
||||
else if (aiOrigin_END == pOrigin) {
|
||||
if (pOffset > length) {
|
||||
return AI_FAILURE;
|
||||
}
|
||||
pos = length-pOffset;
|
||||
}
|
||||
else {
|
||||
if (pOffset+pos > length) {
|
||||
return AI_FAILURE;
|
||||
}
|
||||
pos += pOffset;
|
||||
}
|
||||
return AI_SUCCESS;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Get current seek position
|
||||
size_t Tell() const {
|
||||
return pos;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Get size of file
|
||||
size_t FileSize() const {
|
||||
return length;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Flush file contents
|
||||
void Flush() {
|
||||
ai_assert(false); // won't be needed
|
||||
}
|
||||
|
||||
private:
|
||||
const uint8_t* buffer;
|
||||
size_t length,pos;
|
||||
bool own;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Dummy IO system to read from a memory buffer */
|
||||
class MemoryIOSystem : public IOSystem
|
||||
{
|
||||
public:
|
||||
/** Constructor. */
|
||||
MemoryIOSystem (const uint8_t* buff, size_t len)
|
||||
: buffer (buff), length(len) {
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
~MemoryIOSystem() {
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Tests for the existence of a file at the given path. */
|
||||
bool Exists( const char* pFile) const {
|
||||
return !strncmp(pFile,AI_MEMORYIO_MAGIC_FILENAME,AI_MEMORYIO_MAGIC_FILENAME_LENGTH);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns the directory separator. */
|
||||
char getOsSeparator() const {
|
||||
return '/'; // why not? it doesn't care
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Open a new file with a given path. */
|
||||
IOStream* Open( const char* pFile, const char* /*pMode*/ = "rb") {
|
||||
if (strncmp(pFile,AI_MEMORYIO_MAGIC_FILENAME,AI_MEMORYIO_MAGIC_FILENAME_LENGTH)) {
|
||||
return NULL;
|
||||
}
|
||||
return new MemoryIOStream(buffer,length);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Closes the given file and releases all resources associated with it. */
|
||||
void Close( IOStream* pFile) {
|
||||
delete pFile;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Compare two paths */
|
||||
bool ComparePaths (const char* /*one*/, const char* /*second*/) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
const uint8_t* buffer;
|
||||
size_t length;
|
||||
};
|
||||
} // end namespace Assimp
|
||||
|
||||
#endif
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,260 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/** @file ParsingUtils.h
|
||||
* @brief Defines helper functions for text parsing
|
||||
*/
|
||||
#ifndef AI_PARSING_UTILS_H_INC
|
||||
#define AI_PARSING_UTILS_H_INC
|
||||
|
||||
#include "StringComparison.h"
|
||||
#include "StringUtils.h"
|
||||
#include <assimp/defs.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// NOTE: the functions below are mostly intended as replacement for
|
||||
// std::upper, std::lower, std::isupper, std::islower, std::isspace.
|
||||
// we don't bother of locales. We don't want them. We want reliable
|
||||
// (i.e. identical) results across all locales.
|
||||
|
||||
// The functions below accept any character type, but know only
|
||||
// about ASCII. However, UTF-32 is the only safe ASCII superset to
|
||||
// use since it doesn't have multi-byte sequences.
|
||||
|
||||
static const unsigned int BufferSize = 4096;
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
char_t ToLower( char_t in ) {
|
||||
return (in >= (char_t)'A' && in <= (char_t)'Z') ? (char_t)(in+0x20) : in;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
char_t ToUpper( char_t in) {
|
||||
return (in >= (char_t)'a' && in <= (char_t)'z') ? (char_t)(in-0x20) : in;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool IsUpper( char_t in) {
|
||||
return (in >= (char_t)'A' && in <= (char_t)'Z');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool IsLower( char_t in) {
|
||||
return (in >= (char_t)'a' && in <= (char_t)'z');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool IsSpace( char_t in) {
|
||||
return (in == (char_t)' ' || in == (char_t)'\t');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool IsLineEnd( char_t in) {
|
||||
return (in==(char_t)'\r'||in==(char_t)'\n'||in==(char_t)'\0'||in==(char_t)'\f');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool IsSpaceOrNewLine( char_t in) {
|
||||
return IsSpace<char_t>(in) || IsLineEnd<char_t>(in);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool SkipSpaces( const char_t* in, const char_t** out) {
|
||||
while( *in == ( char_t )' ' || *in == ( char_t )'\t' ) {
|
||||
++in;
|
||||
}
|
||||
*out = in;
|
||||
return !IsLineEnd<char_t>(*in);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool SkipSpaces( const char_t** inout) {
|
||||
return SkipSpaces<char_t>(*inout,inout);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool SkipLine( const char_t* in, const char_t** out) {
|
||||
while( *in != ( char_t )'\r' && *in != ( char_t )'\n' && *in != ( char_t )'\0' ) {
|
||||
++in;
|
||||
}
|
||||
|
||||
// files are opened in binary mode. Ergo there are both NL and CR
|
||||
while( *in == ( char_t )'\r' || *in == ( char_t )'\n' ) {
|
||||
++in;
|
||||
}
|
||||
*out = in;
|
||||
return *in != (char_t)'\0';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool SkipLine( const char_t** inout) {
|
||||
return SkipLine<char_t>(*inout,inout);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool SkipSpacesAndLineEnd( const char_t* in, const char_t** out) {
|
||||
while( *in == ( char_t )' ' || *in == ( char_t )'\t' || *in == ( char_t )'\r' || *in == ( char_t )'\n' ) {
|
||||
++in;
|
||||
}
|
||||
*out = in;
|
||||
return *in != '\0';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool SkipSpacesAndLineEnd( const char_t** inout) {
|
||||
return SkipSpacesAndLineEnd<char_t>(*inout,inout);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool GetNextLine( const char_t*& buffer, char_t out[ BufferSize ] ) {
|
||||
if( ( char_t )'\0' == *buffer ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char* _out = out;
|
||||
char* const end = _out + BufferSize;
|
||||
while( !IsLineEnd( *buffer ) && _out < end ) {
|
||||
*_out++ = *buffer++;
|
||||
}
|
||||
*_out = (char_t)'\0';
|
||||
|
||||
while( IsLineEnd( *buffer ) && '\0' != *buffer ) {
|
||||
++buffer;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE bool IsNumeric( char_t in)
|
||||
{
|
||||
return ( in >= '0' && in <= '9' ) || '-' == in || '+' == in;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
template <class char_t>
|
||||
AI_FORCE_INLINE
|
||||
bool TokenMatch(char_t*& in, const char* token, unsigned int len)
|
||||
{
|
||||
if (!::strncmp(token,in,len) && IsSpaceOrNewLine(in[len])) {
|
||||
if (in[len] != '\0') {
|
||||
in += len+1;
|
||||
} else {
|
||||
// If EOF after the token make sure we don't go past end of buffer
|
||||
in += len;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// ---------------------------------------------------------------------------------
|
||||
/** @brief Case-ignoring version of TokenMatch
|
||||
* @param in Input
|
||||
* @param token Token to check for
|
||||
* @param len Number of characters to check
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
bool TokenMatchI(const char*& in, const char* token, unsigned int len) {
|
||||
if (!ASSIMP_strincmp(token,in,len) && IsSpaceOrNewLine(in[len])) {
|
||||
in += len+1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
void SkipToken(const char*& in) {
|
||||
SkipSpaces(&in);
|
||||
while ( !IsSpaceOrNewLine( *in ) ) {
|
||||
++in;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE
|
||||
std::string GetNextToken(const char*& in) {
|
||||
SkipSpacesAndLineEnd(&in);
|
||||
const char* cur = in;
|
||||
while ( !IsSpaceOrNewLine( *in ) ) {
|
||||
++in;
|
||||
}
|
||||
return std::string(cur,(size_t)(in-cur));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
} // ! namespace Assimp
|
||||
|
||||
#endif // ! AI_PARSING_UTILS_H_INC
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Profiler.h
|
||||
* @brief Utility to measure the respective runtime of each import step
|
||||
*/
|
||||
#ifndef INCLUDED_PROFILER_H
|
||||
#define INCLUDED_PROFILER_H
|
||||
|
||||
#include <chrono>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include "TinyFormatter.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Profiling {
|
||||
|
||||
using namespace Formatter;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** Simple wrapper around boost::timer to simplify reporting. Timings are automatically
|
||||
* dumped to the log file.
|
||||
*/
|
||||
class Profiler {
|
||||
public:
|
||||
Profiler() {
|
||||
// empty
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/** Start a named timer */
|
||||
void BeginRegion(const std::string& region) {
|
||||
regions[region] = std::chrono::system_clock::now();
|
||||
ASSIMP_LOG_DEBUG((format("START `"),region,"`"));
|
||||
}
|
||||
|
||||
|
||||
/** End a specific named timer and write its end time to the log */
|
||||
void EndRegion(const std::string& region) {
|
||||
RegionMap::const_iterator it = regions.find(region);
|
||||
if (it == regions.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::chrono::duration<double> elapsedSeconds = std::chrono::system_clock::now() - regions[region];
|
||||
ASSIMP_LOG_DEBUG((format("END `"),region,"`, dt= ", elapsedSeconds.count()," s"));
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::map<std::string,std::chrono::time_point<std::chrono::system_clock>> RegionMap;
|
||||
RegionMap regions;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -63,7 +62,7 @@ class ASSIMP_API ProgressHandler
|
|||
{
|
||||
protected:
|
||||
/** @brief Default constructor */
|
||||
ProgressHandler () AI_NO_EXCEPT {
|
||||
ProgressHandler () {
|
||||
}
|
||||
public:
|
||||
/** @brief Virtual destructor */
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Declares a helper class, "CommentRemover", which can be
|
||||
* used to remove comments (single and multi line) from a text file.
|
||||
*/
|
||||
#ifndef AI_REMOVE_COMMENTS_H_INC
|
||||
#define AI_REMOVE_COMMENTS_H_INC
|
||||
|
||||
|
||||
#include <assimp/defs.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Helper class to remove single and multi line comments from a file
|
||||
*
|
||||
* Some mesh formats like MD5 have comments that are quite similar
|
||||
* to those in C or C++ so this code has been moved to a separate
|
||||
* module.
|
||||
*/
|
||||
class ASSIMP_API CommentRemover
|
||||
{
|
||||
// class cannot be instanced
|
||||
CommentRemover() {}
|
||||
|
||||
public:
|
||||
|
||||
//! Remove single-line comments. The end of a line is
|
||||
//! expected to be either NL or CR or NLCR.
|
||||
//! \param szComment The start sequence of the comment, e.g. "//"
|
||||
//! \param szBuffer Buffer to work with
|
||||
//! \param chReplacement Character to be used as replacement
|
||||
//! for commented lines. By default this is ' '
|
||||
static void RemoveLineComments(const char* szComment,
|
||||
char* szBuffer, char chReplacement = ' ');
|
||||
|
||||
//! Remove multi-line comments. The end of a line is
|
||||
//! expected to be either NL or CR or NLCR. Multi-line comments
|
||||
//! may not be nested (as in C).
|
||||
//! \param szCommentStart The start sequence of the comment, e.g. "/*"
|
||||
//! \param szCommentEnd The end sequence of the comment, e.g. "*/"
|
||||
//! \param szBuffer Buffer to work with
|
||||
//! \param chReplacement Character to be used as replacement
|
||||
//! for commented lines. By default this is ' '
|
||||
static void RemoveMultiLineComments(const char* szCommentStart,
|
||||
const char* szCommentEnd,char* szBuffer,
|
||||
char chReplacement = ' ');
|
||||
};
|
||||
} // ! Assimp
|
||||
|
||||
#endif // !! AI_REMOVE_COMMENTS_H_INC
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** Small helper classes to optimize finding vertices close to a given location
|
||||
*/
|
||||
#ifndef AI_D3DSSPATIALSORT_H_INC
|
||||
#define AI_D3DSSPATIALSORT_H_INC
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
/** Specialized version of SpatialSort to support smoothing groups
|
||||
* This is used in by the 3DS, ASE and LWO loaders. 3DS and ASE share their
|
||||
* normal computation code in SmoothingGroups.inl, the LWO loader has its own
|
||||
* implementation to handle all details of its file format correctly.
|
||||
*/
|
||||
// ----------------------------------------------------------------------------------
|
||||
class ASSIMP_API SGSpatialSort
|
||||
{
|
||||
public:
|
||||
|
||||
SGSpatialSort();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Construction from a given face array, handling smoothing groups
|
||||
* properly
|
||||
*/
|
||||
explicit SGSpatialSort(const std::vector<aiVector3D>& vPositions);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Add a vertex to the spatial sort
|
||||
* @param vPosition Vertex position to be added
|
||||
* @param index Index of the vrtex
|
||||
* @param smoothingGroup SmoothingGroup for this vertex
|
||||
*/
|
||||
void Add(const aiVector3D& vPosition, unsigned int index,
|
||||
unsigned int smoothingGroup);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Prepare the spatial sorter for use. This step runs in O(logn)
|
||||
*/
|
||||
void Prepare();
|
||||
|
||||
/** Destructor */
|
||||
~SGSpatialSort();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Returns an iterator for all positions close to the given position.
|
||||
* @param pPosition The position to look for vertices.
|
||||
* @param pSG Only included vertices with at least one shared smooth group
|
||||
* @param pRadius Maximal distance from the position a vertex may have
|
||||
* to be counted in.
|
||||
* @param poResults The container to store the indices of the found
|
||||
* positions. Will be emptied by the call so it may contain anything.
|
||||
* @param exactMatch Specifies whether smoothing groups are bit masks
|
||||
* (false) or integral values (true). In the latter case, a vertex
|
||||
* cannot belong to more than one smoothing group.
|
||||
* @return An iterator to iterate over all vertices in the given area.
|
||||
*/
|
||||
// -------------------------------------------------------------------
|
||||
void FindPositions( const aiVector3D& pPosition, uint32_t pSG,
|
||||
float pRadius, std::vector<unsigned int>& poResults,
|
||||
bool exactMatch = false) const;
|
||||
|
||||
protected:
|
||||
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
||||
aiVector3D mPlaneNormal;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** An entry in a spatially sorted position array. Consists of a
|
||||
* vertex index, its position and its pre-calculated distance from
|
||||
* the reference plane */
|
||||
// -------------------------------------------------------------------
|
||||
struct Entry {
|
||||
unsigned int mIndex; ///< The vertex referred by this entry
|
||||
aiVector3D mPosition; ///< Position
|
||||
uint32_t mSmoothGroups;
|
||||
float mDistance; ///< Distance of this vertex to the sorting plane
|
||||
|
||||
Entry() AI_NO_EXCEPT
|
||||
: mIndex(0)
|
||||
, mPosition()
|
||||
, mSmoothGroups(0)
|
||||
, mDistance(0.0f) {
|
||||
// empty
|
||||
}
|
||||
|
||||
Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
|
||||
: mIndex( pIndex)
|
||||
, mPosition( pPosition)
|
||||
, mSmoothGroups(pSG)
|
||||
, mDistance( pDistance) {
|
||||
// empty
|
||||
}
|
||||
|
||||
bool operator < (const Entry& e) const {
|
||||
return mDistance < e.mDistance;
|
||||
}
|
||||
};
|
||||
|
||||
// all positions, sorted by distance to the sorting plane
|
||||
std::vector<Entry> mPositions;
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_SPATIALSORT_H_INC
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,125 +0,0 @@
|
|||
/** Helper class to construct a dummy mesh for file formats containing only motion data */
|
||||
|
||||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file SkeletonMeshBuilder.h
|
||||
* Declares SkeletonMeshBuilder, a tiny utility to build dummy meshes
|
||||
* for animation skeletons.
|
||||
*/
|
||||
|
||||
#ifndef AI_SKELETONMESHBUILDER_H_INC
|
||||
#define AI_SKELETONMESHBUILDER_H_INC
|
||||
|
||||
#include <vector>
|
||||
#include <assimp/mesh.h>
|
||||
|
||||
struct aiMaterial;
|
||||
struct aiScene;
|
||||
struct aiNode;
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/**
|
||||
* This little helper class constructs a dummy mesh for a given scene
|
||||
* the resembles the node hierarchy. This is useful for file formats
|
||||
* that don't carry any mesh data but only animation data.
|
||||
*/
|
||||
class ASSIMP_API SkeletonMeshBuilder
|
||||
{
|
||||
public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** The constructor processes the given scene and adds a mesh there.
|
||||
*
|
||||
* Does nothing if the scene already has mesh data.
|
||||
* @param pScene The scene for which a skeleton mesh should be constructed.
|
||||
* @param root The node to start with. NULL is the scene root
|
||||
* @param bKnobsOnly Set this to true if you don't want the connectors
|
||||
* between the knobs representing the nodes.
|
||||
*/
|
||||
SkeletonMeshBuilder( aiScene* pScene, aiNode* root = NULL,
|
||||
bool bKnobsOnly = false);
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Recursively builds a simple mesh representation for the given node
|
||||
* and also creates a joint for the node that affects this part of
|
||||
* the mesh.
|
||||
* @param pNode The node to build geometry for.
|
||||
*/
|
||||
void CreateGeometry( const aiNode* pNode);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Creates the mesh from the internally accumulated stuff and returns it.
|
||||
*/
|
||||
aiMesh* CreateMesh();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Creates a dummy material and returns it. */
|
||||
aiMaterial* CreateMaterial();
|
||||
|
||||
protected:
|
||||
/** space to assemble the mesh data: points */
|
||||
std::vector<aiVector3D> mVertices;
|
||||
|
||||
/** faces */
|
||||
struct Face
|
||||
{
|
||||
unsigned int mIndices[3];
|
||||
Face();
|
||||
Face( unsigned int p0, unsigned int p1, unsigned int p2)
|
||||
{ mIndices[0] = p0; mIndices[1] = p1; mIndices[2] = p2; }
|
||||
};
|
||||
std::vector<Face> mFaces;
|
||||
|
||||
/** bones */
|
||||
std::vector<aiBone*> mBones;
|
||||
|
||||
bool mKnobsOnly;
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_SKELETONMESHBUILDER_H_INC
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines the helper data structures for importing 3DS files.
|
||||
http://www.jalix.org/ressources/graphics/3DS/_unofficials/3ds-unofficial.txt */
|
||||
|
||||
#ifndef AI_SMOOTHINGGROUPS_H_INC
|
||||
#define AI_SMOOTHINGGROUPS_H_INC
|
||||
|
||||
#include <assimp/vector3.h>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Helper structure representing a face with smoothing groups assigned */
|
||||
struct FaceWithSmoothingGroup {
|
||||
FaceWithSmoothingGroup() AI_NO_EXCEPT
|
||||
: mIndices()
|
||||
, iSmoothGroup(0) {
|
||||
// in debug builds set all indices to a common magic value
|
||||
#ifdef ASSIMP_BUILD_DEBUG
|
||||
this->mIndices[0] = 0xffffffff;
|
||||
this->mIndices[1] = 0xffffffff;
|
||||
this->mIndices[2] = 0xffffffff;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//! Indices. .3ds is using uint16. However, after
|
||||
//! an unique vertex set has been generated,
|
||||
//! individual index values might exceed 2^16
|
||||
uint32_t mIndices[3];
|
||||
|
||||
//! specifies to which smoothing group the face belongs to
|
||||
uint32_t iSmoothGroup;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Helper structure representing a mesh whose faces have smoothing
|
||||
groups assigned. This allows us to reuse the code for normal computations
|
||||
from smoothings groups for several loaders (3DS, ASE). All of them
|
||||
use face structures which inherit from #FaceWithSmoothingGroup,
|
||||
but as they add extra members and need to be copied by value we
|
||||
need to use a template here.
|
||||
*/
|
||||
template <class T>
|
||||
struct MeshWithSmoothingGroups
|
||||
{
|
||||
//! Vertex positions
|
||||
std::vector<aiVector3D> mPositions;
|
||||
|
||||
//! Face lists
|
||||
std::vector<T> mFaces;
|
||||
|
||||
//! List of normal vectors
|
||||
std::vector<aiVector3D> mNormals;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Computes normal vectors for the mesh
|
||||
*/
|
||||
template <class T>
|
||||
void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups<T>& sMesh);
|
||||
|
||||
|
||||
// include implementations
|
||||
#include "SmoothingGroups.inl"
|
||||
|
||||
#endif // !! AI_SMOOTHINGGROUPS_H_INC
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2012, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Generation of normal vectors basing on smoothing groups */
|
||||
|
||||
#ifndef AI_SMOOTHINGGROUPS_INL_INCLUDED
|
||||
#define AI_SMOOTHINGGROUPS_INL_INCLUDED
|
||||
|
||||
// internal headers
|
||||
#include <assimp/SGSpatialSort.h>
|
||||
|
||||
// CRT header
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups<T>& sMesh)
|
||||
{
|
||||
// First generate face normals
|
||||
sMesh.mNormals.resize(sMesh.mPositions.size(),aiVector3D());
|
||||
for( unsigned int a = 0; a < sMesh.mFaces.size(); a++)
|
||||
{
|
||||
T& face = sMesh.mFaces[a];
|
||||
|
||||
aiVector3D* pV1 = &sMesh.mPositions[face.mIndices[0]];
|
||||
aiVector3D* pV2 = &sMesh.mPositions[face.mIndices[1]];
|
||||
aiVector3D* pV3 = &sMesh.mPositions[face.mIndices[2]];
|
||||
|
||||
aiVector3D pDelta1 = *pV2 - *pV1;
|
||||
aiVector3D pDelta2 = *pV3 - *pV1;
|
||||
aiVector3D vNor = pDelta1 ^ pDelta2;
|
||||
|
||||
for (unsigned int c = 0; c < 3;++c)
|
||||
sMesh.mNormals[face.mIndices[c]] = vNor;
|
||||
}
|
||||
|
||||
// calculate the position bounds so we have a reliable epsilon to check position differences against
|
||||
aiVector3D minVec( 1e10f, 1e10f, 1e10f), maxVec( -1e10f, -1e10f, -1e10f);
|
||||
for( unsigned int a = 0; a < sMesh.mPositions.size(); a++)
|
||||
{
|
||||
minVec.x = std::min( minVec.x, sMesh.mPositions[a].x);
|
||||
minVec.y = std::min( minVec.y, sMesh.mPositions[a].y);
|
||||
minVec.z = std::min( minVec.z, sMesh.mPositions[a].z);
|
||||
maxVec.x = std::max( maxVec.x, sMesh.mPositions[a].x);
|
||||
maxVec.y = std::max( maxVec.y, sMesh.mPositions[a].y);
|
||||
maxVec.z = std::max( maxVec.z, sMesh.mPositions[a].z);
|
||||
}
|
||||
const float posEpsilon = (maxVec - minVec).Length() * 1e-5f;
|
||||
std::vector<aiVector3D> avNormals;
|
||||
avNormals.resize(sMesh.mNormals.size());
|
||||
|
||||
// now generate the spatial sort tree
|
||||
SGSpatialSort sSort;
|
||||
for( typename std::vector<T>::iterator i = sMesh.mFaces.begin();
|
||||
i != sMesh.mFaces.end();++i)
|
||||
{
|
||||
for (unsigned int c = 0; c < 3;++c)
|
||||
sSort.Add(sMesh.mPositions[(*i).mIndices[c]],(*i).mIndices[c],(*i).iSmoothGroup);
|
||||
}
|
||||
sSort.Prepare();
|
||||
|
||||
std::vector<bool> vertexDone(sMesh.mPositions.size(),false);
|
||||
for( typename std::vector<T>::iterator i = sMesh.mFaces.begin();
|
||||
i != sMesh.mFaces.end();++i)
|
||||
{
|
||||
std::vector<unsigned int> poResult;
|
||||
for (unsigned int c = 0; c < 3;++c)
|
||||
{
|
||||
unsigned int idx = (*i).mIndices[c];
|
||||
if (vertexDone[idx])continue;
|
||||
|
||||
sSort.FindPositions(sMesh.mPositions[idx],(*i).iSmoothGroup,
|
||||
posEpsilon,poResult);
|
||||
|
||||
aiVector3D vNormals;
|
||||
for (std::vector<unsigned int>::const_iterator
|
||||
a = poResult.begin();
|
||||
a != poResult.end();++a)
|
||||
{
|
||||
vNormals += sMesh.mNormals[(*a)];
|
||||
}
|
||||
vNormals.NormalizeSafe();
|
||||
|
||||
// write back into all affected normals
|
||||
for (std::vector<unsigned int>::const_iterator
|
||||
a = poResult.begin();
|
||||
a != poResult.end();++a)
|
||||
{
|
||||
idx = *a;
|
||||
avNormals [idx] = vNormals;
|
||||
vertexDone[idx] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
sMesh.mNormals = avNormals;
|
||||
}
|
||||
|
||||
#endif // !! AI_SMOOTHINGGROUPS_INL_INCLUDED
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** Small helper classes to optimise finding vertizes close to a given location */
|
||||
#ifndef AI_SPATIALSORT_H_INC
|
||||
#define AI_SPATIALSORT_H_INC
|
||||
|
||||
#include <vector>
|
||||
#include <assimp/types.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** A little helper class to quickly find all vertices in the epsilon environment of a given
|
||||
* position. Construct an instance with an array of positions. The class stores the given positions
|
||||
* by their indices and sorts them by their distance to an arbitrary chosen plane.
|
||||
* You can then query the instance for all vertices close to a given position in an average O(log n)
|
||||
* time, with O(n) worst case complexity when all vertices lay on the plane. The plane is chosen
|
||||
* so that it avoids common planes in usual data sets. */
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class ASSIMP_API SpatialSort
|
||||
{
|
||||
public:
|
||||
|
||||
SpatialSort();
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Constructs a spatially sorted representation from the given position array.
|
||||
* Supply the positions in its layout in memory, the class will only refer to them
|
||||
* by index.
|
||||
* @param pPositions Pointer to the first position vector of the array.
|
||||
* @param pNumPositions Number of vectors to expect in that array.
|
||||
* @param pElementOffset Offset in bytes from the beginning of one vector in memory
|
||||
* to the beginning of the next vector. */
|
||||
SpatialSort( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset);
|
||||
|
||||
/** Destructor */
|
||||
~SpatialSort();
|
||||
|
||||
public:
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Sets the input data for the SpatialSort. This replaces existing data, if any.
|
||||
* The new data receives new indices in ascending order.
|
||||
*
|
||||
* @param pPositions Pointer to the first position vector of the array.
|
||||
* @param pNumPositions Number of vectors to expect in that array.
|
||||
* @param pElementOffset Offset in bytes from the beginning of one vector in memory
|
||||
* to the beginning of the next vector.
|
||||
* @param pFinalize Specifies whether the SpatialSort's internal representation
|
||||
* is finalized after the new data has been added. Finalization is
|
||||
* required in order to use #FindPosition() or #GenerateMappingTable().
|
||||
* If you don't finalize yet, you can use #Append() to add data from
|
||||
* other sources.*/
|
||||
void Fill( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Same as #Fill(), except the method appends to existing data in the #SpatialSort. */
|
||||
void Append( const aiVector3D* pPositions, unsigned int pNumPositions,
|
||||
unsigned int pElementOffset,
|
||||
bool pFinalize = true);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Finalize the spatial hash data structure. This can be useful after
|
||||
* multiple calls to #Append() with the pFinalize parameter set to false.
|
||||
* This is finally required before one of #FindPositions() and #GenerateMappingTable()
|
||||
* can be called to query the spatial sort.*/
|
||||
void Finalize();
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Returns an iterator for all positions close to the given position.
|
||||
* @param pPosition The position to look for vertices.
|
||||
* @param pRadius Maximal distance from the position a vertex may have to be counted in.
|
||||
* @param poResults The container to store the indices of the found positions.
|
||||
* Will be emptied by the call so it may contain anything.
|
||||
* @return An iterator to iterate over all vertices in the given area.*/
|
||||
void FindPositions( const aiVector3D& pPosition, ai_real pRadius,
|
||||
std::vector<unsigned int>& poResults) const;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Fills an array with indices of all positions identical to the given position. In
|
||||
* opposite to FindPositions(), not an epsilon is used but a (very low) tolerance of
|
||||
* four floating-point units.
|
||||
* @param pPosition The position to look for vertices.
|
||||
* @param poResults The container to store the indices of the found positions.
|
||||
* Will be emptied by the call so it may contain anything.*/
|
||||
void FindIdenticalPositions( const aiVector3D& pPosition,
|
||||
std::vector<unsigned int>& poResults) const;
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
/** Compute a table that maps each vertex ID referring to a spatially close
|
||||
* enough position to the same output ID. Output IDs are assigned in ascending order
|
||||
* from 0...n.
|
||||
* @param fill Will be filled with numPositions entries.
|
||||
* @param pRadius Maximal distance from the position a vertex may have to
|
||||
* be counted in.
|
||||
* @return Number of unique vertices (n). */
|
||||
unsigned int GenerateMappingTable(std::vector<unsigned int>& fill,
|
||||
ai_real pRadius) const;
|
||||
|
||||
protected:
|
||||
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
||||
aiVector3D mPlaneNormal;
|
||||
|
||||
/** An entry in a spatially sorted position array. Consists of a vertex index,
|
||||
* its position and its pre-calculated distance from the reference plane */
|
||||
struct Entry {
|
||||
unsigned int mIndex; ///< The vertex referred by this entry
|
||||
aiVector3D mPosition; ///< Position
|
||||
ai_real mDistance; ///< Distance of this vertex to the sorting plane
|
||||
|
||||
Entry() AI_NO_EXCEPT
|
||||
: mIndex( 999999999 ), mPosition(), mDistance( 99999. ) {
|
||||
// empty
|
||||
}
|
||||
Entry( unsigned int pIndex, const aiVector3D& pPosition, ai_real pDistance)
|
||||
: mIndex( pIndex), mPosition( pPosition), mDistance( pDistance) {
|
||||
// empty
|
||||
}
|
||||
|
||||
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
|
||||
};
|
||||
|
||||
// all positions, sorted by distance to the sorting plane
|
||||
std::vector<Entry> mPositions;
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // AI_SPATIALSORT_H_INC
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Declares a helper class, "StandardShapes" which generates
|
||||
* vertices for standard shapes, such as cylnders, cones, spheres ..
|
||||
*/
|
||||
#ifndef AI_STANDARD_SHAPES_H_INC
|
||||
#define AI_STANDARD_SHAPES_H_INC
|
||||
|
||||
#include <assimp/vector3.h>
|
||||
#include <vector>
|
||||
|
||||
struct aiMesh;
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** \brief Helper class to generate vertex buffers for standard geometric
|
||||
* shapes, such as cylinders, cones, boxes, spheres, elipsoids ... .
|
||||
*/
|
||||
class ASSIMP_API StandardShapes
|
||||
{
|
||||
// class cannot be instanced
|
||||
StandardShapes() {}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** Generates a mesh from an array of vertex positions.
|
||||
*
|
||||
* @param positions List of vertex positions
|
||||
* @param numIndices Number of indices per primitive
|
||||
* @return Output mesh
|
||||
*/
|
||||
static aiMesh* MakeMesh(const std::vector<aiVector3D>& positions,
|
||||
unsigned int numIndices);
|
||||
|
||||
|
||||
static aiMesh* MakeMesh ( unsigned int (*GenerateFunc)
|
||||
(std::vector<aiVector3D>&));
|
||||
|
||||
static aiMesh* MakeMesh ( unsigned int (*GenerateFunc)
|
||||
(std::vector<aiVector3D>&, bool));
|
||||
|
||||
static aiMesh* MakeMesh ( unsigned int n, void (*GenerateFunc)
|
||||
(unsigned int,std::vector<aiVector3D>&));
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** @brief Generates a hexahedron (cube)
|
||||
*
|
||||
* Hexahedrons can be scaled on all axes.
|
||||
* @param positions Receives output triangles.
|
||||
* @param polygons If you pass true here quads will be returned
|
||||
* @return Number of vertices per face
|
||||
*/
|
||||
static unsigned int MakeHexahedron(
|
||||
std::vector<aiVector3D>& positions,
|
||||
bool polygons = false);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** @brief Generates an icosahedron
|
||||
*
|
||||
* @param positions Receives output triangles.
|
||||
* @return Number of vertices per face
|
||||
*/
|
||||
static unsigned int MakeIcosahedron(
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** @brief Generates a dodecahedron
|
||||
*
|
||||
* @param positions Receives output triangles
|
||||
* @param polygons If you pass true here pentagons will be returned
|
||||
* @return Number of vertices per face
|
||||
*/
|
||||
static unsigned int MakeDodecahedron(
|
||||
std::vector<aiVector3D>& positions,
|
||||
bool polygons = false);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** @brief Generates an octahedron
|
||||
*
|
||||
* @param positions Receives output triangles.
|
||||
* @return Number of vertices per face
|
||||
*/
|
||||
static unsigned int MakeOctahedron(
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** @brief Generates a tetrahedron
|
||||
*
|
||||
* @param positions Receives output triangles.
|
||||
* @return Number of vertices per face
|
||||
*/
|
||||
static unsigned int MakeTetrahedron(
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** @brief Generates a sphere
|
||||
*
|
||||
* @param tess Number of subdivions - 0 generates a octahedron
|
||||
* @param positions Receives output triangles.
|
||||
*/
|
||||
static void MakeSphere(unsigned int tess,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** @brief Generates a cone or a cylinder, either open or closed.
|
||||
*
|
||||
* @code
|
||||
*
|
||||
* |-----| <- radius 1
|
||||
*
|
||||
* __x__ <- ] ^
|
||||
* / \ | height |
|
||||
* / \ | Y
|
||||
* / \ |
|
||||
* / \ |
|
||||
* /______x______\ <- ] <- end cap
|
||||
*
|
||||
* |-------------| <- radius 2
|
||||
*
|
||||
* @endcode
|
||||
*
|
||||
* @param height Height of the cone
|
||||
* @param radius1 First radius
|
||||
* @param radius2 Second radius
|
||||
* @param tess Number of triangles.
|
||||
* @param bOpened true for an open cone/cylinder. An open shape has
|
||||
* no 'end caps'
|
||||
* @param positions Receives output triangles
|
||||
*/
|
||||
static void MakeCone(ai_real height,ai_real radius1,
|
||||
ai_real radius2,unsigned int tess,
|
||||
std::vector<aiVector3D>& positions,bool bOpen= false);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
/** @brief Generates a flat circle
|
||||
*
|
||||
* The circle is constructed in the planned formed by the x,z
|
||||
* axes of the cartesian coordinate system.
|
||||
*
|
||||
* @param radius Radius of the circle
|
||||
* @param tess Number of segments.
|
||||
* @param positions Receives output triangles.
|
||||
*/
|
||||
static void MakeCircle(ai_real radius, unsigned int tess,
|
||||
std::vector<aiVector3D>& positions);
|
||||
|
||||
};
|
||||
} // ! Assimp
|
||||
|
||||
#endif // !! AI_STANDARD_SHAPES_H_INC
|
||||
|
|
@ -1,342 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines the StreamReader class which reads data from
|
||||
* a binary stream with a well-defined endianness.
|
||||
*/
|
||||
|
||||
#ifndef AI_STREAMREADER_H_INCLUDED
|
||||
#define AI_STREAMREADER_H_INCLUDED
|
||||
|
||||
#include "ByteSwapper.h"
|
||||
#include "Exceptional.h"
|
||||
#include <memory>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/Defines.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/** Wrapper class around IOStream to allow for consistent reading of binary data in both
|
||||
* little and big endian format. Don't attempt to instance the template directly. Use
|
||||
* StreamReaderLE to read from a little-endian stream and StreamReaderBE to read from a
|
||||
* BE stream. The class expects that the endianness of any input data is known at
|
||||
* compile-time, which should usually be true (#BaseImporter::ConvertToUTF8 implements
|
||||
* runtime endianness conversions for text files).
|
||||
*
|
||||
* XXX switch from unsigned int for size types to size_t? or ptrdiff_t?*/
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
||||
class StreamReader {
|
||||
public:
|
||||
// FIXME: use these data types throughout the whole library,
|
||||
// then change them to 64 bit values :-)
|
||||
using diff = int;
|
||||
using pos = unsigned int;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Construction from a given stream with a well-defined endianness.
|
||||
*
|
||||
* The StreamReader holds a permanent strong reference to the
|
||||
* stream, which is released upon destruction.
|
||||
* @param stream Input stream. The stream is not restarted if
|
||||
* its file pointer is not at 0. Instead, the stream reader
|
||||
* reads from the current position to the end of the stream.
|
||||
* @param le If @c RuntimeSwitch is true: specifies whether the
|
||||
* stream is in little endian byte order. Otherwise the
|
||||
* endianness information is contained in the @c SwapEndianess
|
||||
* template parameter and this parameter is meaningless. */
|
||||
StreamReader(std::shared_ptr<IOStream> stream, bool le = false)
|
||||
: stream(stream)
|
||||
, le(le)
|
||||
{
|
||||
ai_assert(stream);
|
||||
InternBegin();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
StreamReader(IOStream* stream, bool le = false)
|
||||
: stream(std::shared_ptr<IOStream>(stream))
|
||||
, le(le)
|
||||
{
|
||||
ai_assert(stream);
|
||||
InternBegin();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
~StreamReader() {
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
// deprecated, use overloaded operator>> instead
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a float from the stream */
|
||||
float GetF4()
|
||||
{
|
||||
return Get<float>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a double from the stream */
|
||||
double GetF8() {
|
||||
return Get<double>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a signed 16 bit integer from the stream */
|
||||
int16_t GetI2() {
|
||||
return Get<int16_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a signed 8 bit integer from the stream */
|
||||
int8_t GetI1() {
|
||||
return Get<int8_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read an signed 32 bit integer from the stream */
|
||||
int32_t GetI4() {
|
||||
return Get<int32_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a signed 64 bit integer from the stream */
|
||||
int64_t GetI8() {
|
||||
return Get<int64_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a unsigned 16 bit integer from the stream */
|
||||
uint16_t GetU2() {
|
||||
return Get<uint16_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a unsigned 8 bit integer from the stream */
|
||||
uint8_t GetU1() {
|
||||
return Get<uint8_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read an unsigned 32 bit integer from the stream */
|
||||
uint32_t GetU4() {
|
||||
return Get<uint32_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Read a unsigned 64 bit integer from the stream */
|
||||
uint64_t GetU8() {
|
||||
return Get<uint64_t>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the remaining stream size (to the end of the stream) */
|
||||
unsigned int GetRemainingSize() const {
|
||||
return (unsigned int)(end - current);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the remaining stream size (to the current read limit). The
|
||||
* return value is the remaining size of the stream if no custom
|
||||
* read limit has been set. */
|
||||
unsigned int GetRemainingSizeToLimit() const {
|
||||
return (unsigned int)(limit - current);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Increase the file pointer (relative seeking) */
|
||||
void IncPtr(intptr_t plus) {
|
||||
current += plus;
|
||||
if (current > limit) {
|
||||
throw DeadlyImportError("End of file or read limit was reached");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current file pointer */
|
||||
int8_t* GetPtr() const {
|
||||
return current;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Set current file pointer (Get it from #GetPtr). This is if you
|
||||
* prefer to do pointer arithmetics on your own or want to copy
|
||||
* large chunks of data at once.
|
||||
* @param p The new pointer, which is validated against the size
|
||||
* limit and buffer boundaries. */
|
||||
void SetPtr(int8_t* p) {
|
||||
current = p;
|
||||
if (current > limit || current < buffer) {
|
||||
throw DeadlyImportError("End of file or read limit was reached");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Copy n bytes to an external buffer
|
||||
* @param out Destination for copying
|
||||
* @param bytes Number of bytes to copy */
|
||||
void CopyAndAdvance(void* out, size_t bytes) {
|
||||
int8_t* ur = GetPtr();
|
||||
SetPtr(ur+bytes); // fire exception if eof
|
||||
|
||||
::memcpy(out,ur,bytes);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current offset from the beginning of the file */
|
||||
int GetCurrentPos() const {
|
||||
return (unsigned int)(current - buffer);
|
||||
}
|
||||
|
||||
void SetCurrentPos(size_t pos) {
|
||||
SetPtr(buffer + pos);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Setup a temporary read limit
|
||||
*
|
||||
* @param limit Maximum number of bytes to be read from
|
||||
* the beginning of the file. Specifying UINT_MAX
|
||||
* resets the limit to the original end of the stream.
|
||||
* Returns the previously set limit. */
|
||||
unsigned int SetReadLimit(unsigned int _limit) {
|
||||
unsigned int prev = GetReadLimit();
|
||||
if (UINT_MAX == _limit) {
|
||||
limit = end;
|
||||
return prev;
|
||||
}
|
||||
|
||||
limit = buffer + _limit;
|
||||
if (limit > end) {
|
||||
throw DeadlyImportError("StreamReader: Invalid read limit");
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Get the current read limit in bytes. Reading over this limit
|
||||
* accidentally raises an exception. */
|
||||
unsigned int GetReadLimit() const {
|
||||
return (unsigned int)(limit - buffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Skip to the read limit in bytes. Reading over this limit
|
||||
* accidentally raises an exception. */
|
||||
void SkipToReadLimit() {
|
||||
current = limit;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** overload operator>> and allow chaining of >> ops. */
|
||||
template <typename T>
|
||||
StreamReader& operator >> (T& f) {
|
||||
f = Get<T>();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Generic read method. ByteSwap::Swap(T*) *must* be defined */
|
||||
template <typename T>
|
||||
T Get() {
|
||||
if ( current + sizeof(T) > limit) {
|
||||
throw DeadlyImportError("End of file or stream limit was reached");
|
||||
}
|
||||
|
||||
T f;
|
||||
::memcpy (&f, current, sizeof(T));
|
||||
Intern::Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
|
||||
current += sizeof(T);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
private:
|
||||
// ---------------------------------------------------------------------
|
||||
void InternBegin() {
|
||||
if (!stream) {
|
||||
// in case someone wonders: StreamReader is frequently invoked with
|
||||
// no prior validation whether the input stream is valid. Since
|
||||
// no one bothers changing the error message, this message here
|
||||
// is passed down to the caller and 'unable to open file'
|
||||
// simply describes best what happened.
|
||||
throw DeadlyImportError("StreamReader: Unable to open file");
|
||||
}
|
||||
|
||||
const size_t s = stream->FileSize() - stream->Tell();
|
||||
if (!s) {
|
||||
throw DeadlyImportError("StreamReader: File is empty or EOF is already reached");
|
||||
}
|
||||
|
||||
current = buffer = new int8_t[s];
|
||||
const size_t read = stream->Read(current,1,s);
|
||||
// (read < s) can only happen if the stream was opened in text mode, in which case FileSize() is not reliable
|
||||
ai_assert(read <= s);
|
||||
end = limit = &buffer[read];
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<IOStream> stream;
|
||||
int8_t *buffer, *current, *end, *limit;
|
||||
bool le;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// `static` StreamReaders. Their byte order is fixed and they might be a little bit faster.
|
||||
#ifdef AI_BUILD_BIG_ENDIAN
|
||||
typedef StreamReader<true> StreamReaderLE;
|
||||
typedef StreamReader<false> StreamReaderBE;
|
||||
#else
|
||||
typedef StreamReader<true> StreamReaderBE;
|
||||
typedef StreamReader<false> StreamReaderLE;
|
||||
#endif
|
||||
|
||||
// `dynamic` StreamReader. The byte order of the input data is specified in the
|
||||
// c'tor. This involves runtime branching and might be a little bit slower.
|
||||
typedef StreamReader<true,true> StreamReaderAny;
|
||||
|
||||
} // end namespace Assimp
|
||||
|
||||
#endif // !! AI_STREAMREADER_H_INCLUDED
|
||||
|
|
@ -1,303 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines the StreamWriter class which writes data to
|
||||
* a binary stream with a well-defined endianness. */
|
||||
|
||||
#ifndef AI_STREAMWRITER_H_INCLUDED
|
||||
#define AI_STREAMWRITER_H_INCLUDED
|
||||
|
||||
#include "ByteSwapper.h"
|
||||
#include <assimp/IOStream.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
/** Wrapper class around IOStream to allow for consistent writing of binary data in both
|
||||
* little and big endian format. Don't attempt to instance the template directly. Use
|
||||
* StreamWriterLE to write to a little-endian stream and StreamWriterBE to write to a
|
||||
* BE stream. Alternatively, there is StreamWriterAny if the endianness of the output
|
||||
* stream is to be determined at runtime.
|
||||
*/
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template <bool SwapEndianess = false, bool RuntimeSwitch = false>
|
||||
class StreamWriter
|
||||
{
|
||||
enum {
|
||||
INITIAL_CAPACITY = 1024
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Construction from a given stream with a well-defined endianness.
|
||||
*
|
||||
* The StreamReader holds a permanent strong reference to the
|
||||
* stream, which is released upon destruction.
|
||||
* @param stream Input stream. The stream is not re-seeked and writing
|
||||
continues at the current position of the stream cursor.
|
||||
* @param le If @c RuntimeSwitch is true: specifies whether the
|
||||
* stream is in little endian byte order. Otherwise the
|
||||
* endianness information is defined by the @c SwapEndianess
|
||||
* template parameter and this parameter is meaningless. */
|
||||
StreamWriter(std::shared_ptr<IOStream> stream, bool le = false)
|
||||
: stream(stream)
|
||||
, le(le)
|
||||
, cursor()
|
||||
{
|
||||
ai_assert(stream);
|
||||
buffer.reserve(INITIAL_CAPACITY);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
StreamWriter(IOStream* stream, bool le = false)
|
||||
: stream(std::shared_ptr<IOStream>(stream))
|
||||
, le(le)
|
||||
, cursor()
|
||||
{
|
||||
ai_assert(stream);
|
||||
buffer.reserve(INITIAL_CAPACITY);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
~StreamWriter() {
|
||||
stream->Write(buffer.data(), 1, buffer.size());
|
||||
stream->Flush();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Flush the contents of the internal buffer, and the output IOStream */
|
||||
void Flush()
|
||||
{
|
||||
stream->Write(buffer.data(), 1, buffer.size());
|
||||
stream->Flush();
|
||||
buffer.clear();
|
||||
cursor = 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Seek to the given offset / origin in the output IOStream.
|
||||
*
|
||||
* Flushes the internal buffer and the output IOStream prior to seeking. */
|
||||
aiReturn Seek(size_t pOffset, aiOrigin pOrigin=aiOrigin_SET)
|
||||
{
|
||||
Flush();
|
||||
return stream->Seek(pOffset, pOrigin);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Tell the current position in the output IOStream.
|
||||
*
|
||||
* First flushes the internal buffer and the output IOStream. */
|
||||
size_t Tell()
|
||||
{
|
||||
Flush();
|
||||
return stream->Tell();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a float to the stream */
|
||||
void PutF4(float f)
|
||||
{
|
||||
Put(f);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a double to the stream */
|
||||
void PutF8(double d) {
|
||||
Put(d);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a signed 16 bit integer to the stream */
|
||||
void PutI2(int16_t n) {
|
||||
Put(n);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a signed 8 bit integer to the stream */
|
||||
void PutI1(int8_t n) {
|
||||
Put(n);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write an signed 32 bit integer to the stream */
|
||||
void PutI4(int32_t n) {
|
||||
Put(n);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a signed 64 bit integer to the stream */
|
||||
void PutI8(int64_t n) {
|
||||
Put(n);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a unsigned 16 bit integer to the stream */
|
||||
void PutU2(uint16_t n) {
|
||||
Put(n);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a unsigned 8 bit integer to the stream */
|
||||
void PutU1(uint8_t n) {
|
||||
Put(n);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write an unsigned 32 bit integer to the stream */
|
||||
void PutU4(uint32_t n) {
|
||||
Put(n);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a unsigned 64 bit integer to the stream */
|
||||
void PutU8(uint64_t n) {
|
||||
Put(n);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a single character to the stream */
|
||||
void PutChar(char c) {
|
||||
Put(c);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write an aiString to the stream */
|
||||
void PutString(const aiString& s)
|
||||
{
|
||||
// as Put(T f) below
|
||||
if (cursor + s.length >= buffer.size()) {
|
||||
buffer.resize(cursor + s.length);
|
||||
}
|
||||
void* dest = &buffer[cursor];
|
||||
::memcpy(dest, s.C_Str(), s.length);
|
||||
cursor += s.length;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Write a std::string to the stream */
|
||||
void PutString(const std::string& s)
|
||||
{
|
||||
// as Put(T f) below
|
||||
if (cursor + s.size() >= buffer.size()) {
|
||||
buffer.resize(cursor + s.size());
|
||||
}
|
||||
void* dest = &buffer[cursor];
|
||||
::memcpy(dest, s.c_str(), s.size());
|
||||
cursor += s.size();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** overload operator<< and allow chaining of MM ops. */
|
||||
template <typename T>
|
||||
StreamWriter& operator << (T f) {
|
||||
Put(f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
std::size_t GetCurrentPos() const {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
void SetCurrentPos(std::size_t new_cursor) {
|
||||
cursor = new_cursor;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
/** Generic write method. ByteSwap::Swap(T*) *must* be defined */
|
||||
template <typename T>
|
||||
void Put(T f) {
|
||||
Intern :: Getter<SwapEndianess,T,RuntimeSwitch>() (&f, le);
|
||||
|
||||
if (cursor + sizeof(T) >= buffer.size()) {
|
||||
buffer.resize(cursor + sizeof(T));
|
||||
}
|
||||
|
||||
void* dest = &buffer[cursor];
|
||||
|
||||
// reinterpret_cast + assignment breaks strict aliasing rules
|
||||
// and generally causes trouble on platforms such as ARM that
|
||||
// do not silently ignore alignment faults.
|
||||
::memcpy(dest, &f, sizeof(T));
|
||||
cursor += sizeof(T);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::shared_ptr<IOStream> stream;
|
||||
bool le;
|
||||
|
||||
std::vector<uint8_t> buffer;
|
||||
std::size_t cursor;
|
||||
};
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
// `static` StreamWriter. Their byte order is fixed and they might be a little bit faster.
|
||||
#ifdef AI_BUILD_BIG_ENDIAN
|
||||
typedef StreamWriter<true> StreamWriterLE;
|
||||
typedef StreamWriter<false> StreamWriterBE;
|
||||
#else
|
||||
typedef StreamWriter<true> StreamWriterBE;
|
||||
typedef StreamWriter<false> StreamWriterLE;
|
||||
#endif
|
||||
|
||||
// `dynamic` StreamWriter. The byte order of the input data is specified in the
|
||||
// c'tor. This involves runtime branching and might be a little bit slower.
|
||||
typedef StreamWriter<true,true> StreamWriterAny;
|
||||
|
||||
} // end namespace Assimp
|
||||
|
||||
#endif // !! AI_STREAMWriter_H_INCLUDED
|
||||
|
|
@ -1,233 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Definition of platform independent string workers:
|
||||
|
||||
ASSIMP_itoa10
|
||||
ASSIMP_stricmp
|
||||
ASSIMP_strincmp
|
||||
|
||||
These functions are not consistently available on all platforms,
|
||||
or the provided implementations behave too differently.
|
||||
*/
|
||||
#ifndef INCLUDED_AI_STRING_WORKERS_H
|
||||
#define INCLUDED_AI_STRING_WORKERS_H
|
||||
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <assimp/defs.h>
|
||||
#include "StringComparison.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief itoa with a fixed base 10
|
||||
* 'itoa' is not consistently available on all platforms so it is quite useful
|
||||
* to have a small replacement function here. No need to use a full sprintf()
|
||||
* if we just want to print a number ...
|
||||
* @param out Output buffer
|
||||
* @param max Maximum number of characters to be written, including '\0'.
|
||||
* This parameter may not be 0.
|
||||
* @param number Number to be written
|
||||
* @return Length of the output string, excluding the '\0'
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
unsigned int ASSIMP_itoa10( char* out, unsigned int max, int32_t number) {
|
||||
ai_assert(NULL != out);
|
||||
|
||||
// write the unary minus to indicate we have a negative number
|
||||
unsigned int written = 1u;
|
||||
if (number < 0 && written < max) {
|
||||
*out++ = '-';
|
||||
++written;
|
||||
number = -number;
|
||||
}
|
||||
|
||||
// We begin with the largest number that is not zero.
|
||||
int32_t cur = 1000000000; // 2147483648
|
||||
bool mustPrint = false;
|
||||
while (written < max) {
|
||||
|
||||
const unsigned int digit = number / cur;
|
||||
if (mustPrint || digit > 0 || 1 == cur) {
|
||||
// print all future zeroe's from now
|
||||
mustPrint = true;
|
||||
|
||||
*out++ = '0'+static_cast<char>(digit);
|
||||
|
||||
++written;
|
||||
number -= digit*cur;
|
||||
if (1 == cur) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
cur /= 10;
|
||||
}
|
||||
|
||||
// append a terminal zero
|
||||
*out++ = '\0';
|
||||
return written-1;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief itoa with a fixed base 10 (Secure template overload)
|
||||
* The compiler should choose this function if he or she is able to determine the
|
||||
* size of the array automatically.
|
||||
*/
|
||||
template <size_t length>
|
||||
AI_FORCE_INLINE
|
||||
unsigned int ASSIMP_itoa10( char(& out)[length], int32_t number) {
|
||||
return ASSIMP_itoa10(out,length,number);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief Helper function to do platform independent string comparison.
|
||||
*
|
||||
* This is required since stricmp() is not consistently available on
|
||||
* all platforms. Some platforms use the '_' prefix, others don't even
|
||||
* have such a function.
|
||||
*
|
||||
* @param s1 First input string
|
||||
* @param s2 Second input string
|
||||
* @return 0 if the given strings are identical
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_stricmp(const char *s1, const char *s2) {
|
||||
ai_assert( NULL != s1 );
|
||||
ai_assert( NULL != s2 );
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
|
||||
return ::_stricmp(s1,s2);
|
||||
#elif defined( __GNUC__ )
|
||||
|
||||
return ::strcasecmp(s1,s2);
|
||||
#else
|
||||
|
||||
char c1, c2;
|
||||
do {
|
||||
c1 = tolower(*s1++);
|
||||
c2 = tolower(*s2++);
|
||||
}
|
||||
while ( c1 && (c1 == c2) );
|
||||
return c1 - c2;
|
||||
#endif
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief Case independent comparison of two std::strings
|
||||
*
|
||||
* @param a First string
|
||||
* @param b Second string
|
||||
* @return 0 if a == b
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_stricmp(const std::string& a, const std::string& b) {
|
||||
int i = (int)b.length()-(int)a.length();
|
||||
return (i ? i : ASSIMP_stricmp(a.c_str(),b.c_str()));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief Helper function to do platform independent string comparison.
|
||||
*
|
||||
* This is required since strincmp() is not consistently available on
|
||||
* all platforms. Some platforms use the '_' prefix, others don't even
|
||||
* have such a function.
|
||||
*
|
||||
* @param s1 First input string
|
||||
* @param s2 Second input string
|
||||
* @param n Macimum number of characters to compare
|
||||
* @return 0 if the given strings are identical
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
int ASSIMP_strincmp(const char *s1, const char *s2, unsigned int n) {
|
||||
ai_assert( NULL != s1 );
|
||||
ai_assert( NULL != s2 );
|
||||
if ( !n ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
|
||||
return ::_strnicmp(s1,s2,n);
|
||||
|
||||
#elif defined( __GNUC__ )
|
||||
|
||||
return ::strncasecmp(s1,s2, n);
|
||||
|
||||
#else
|
||||
char c1, c2;
|
||||
unsigned int p = 0;
|
||||
do
|
||||
{
|
||||
if (p++ >= n)return 0;
|
||||
c1 = tolower(*s1++);
|
||||
c2 = tolower(*s2++);
|
||||
}
|
||||
while ( c1 && (c1 == c2) );
|
||||
|
||||
return c1 - c2;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
/** @brief Evaluates an integer power
|
||||
*
|
||||
* todo: move somewhere where it fits better in than here
|
||||
*/
|
||||
AI_FORCE_INLINE
|
||||
unsigned int integer_pow( unsigned int base, unsigned int power ) {
|
||||
unsigned int res = 1;
|
||||
for ( unsigned int i = 0; i < power; ++i ) {
|
||||
res *= base;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
#endif // ! AI_STRINGCOMPARISON_H_INC
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef INCLUDED_AI_STRINGUTILS_H
|
||||
#define INCLUDED_AI_STRINGUTILS_H
|
||||
|
||||
#include <assimp/defs.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include <cstdlib>
|
||||
|
||||
/// @fn ai_snprintf
|
||||
/// @brief The portable version of the function snprintf ( C99 standard ), which works on visual studio compilers 2013 and earlier.
|
||||
/// @param outBuf The buffer to write in
|
||||
/// @param size The buffer size
|
||||
/// @param format The format string
|
||||
/// @param ap The additional arguments.
|
||||
/// @return The number of written characters if the buffer size was big enough. If an encoding error occurs, a negative number is returned.
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
AI_FORCE_INLINE
|
||||
int c99_ai_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) {
|
||||
int count(-1);
|
||||
if (0 != size) {
|
||||
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
|
||||
}
|
||||
if (count == -1) {
|
||||
count = _vscprintf(format, ap);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
AI_FORCE_INLINE
|
||||
int ai_snprintf(char *outBuf, size_t size, const char *format, ...) {
|
||||
int count;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
count = c99_ai_vsnprintf(outBuf, size, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#else
|
||||
# define ai_snprintf snprintf
|
||||
#endif
|
||||
|
||||
/// @fn to_string
|
||||
/// @brief The portable version of to_string ( some gcc-versions on embedded devices are not supporting this).
|
||||
/// @param value The value to write into the std::string.
|
||||
/// @return The value as a std::string
|
||||
template <typename T>
|
||||
AI_FORCE_INLINE
|
||||
std::string to_string( T value ) {
|
||||
std::ostringstream os;
|
||||
os << value;
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
/// @fn ai_strtof
|
||||
/// @brief The portable version of strtof.
|
||||
/// @param begin The first character of the string.
|
||||
/// @param end The last character
|
||||
/// @return The float value, 0.0f in cas of an error.
|
||||
AI_FORCE_INLINE
|
||||
float ai_strtof( const char *begin, const char *end ) {
|
||||
if ( nullptr == begin ) {
|
||||
return 0.0f;
|
||||
}
|
||||
float val( 0.0f );
|
||||
if ( nullptr == end ) {
|
||||
val = static_cast< float >( ::atof( begin ) );
|
||||
} else {
|
||||
std::string::size_type len( end - begin );
|
||||
std::string token( begin, len );
|
||||
val = static_cast< float >( ::atof( token.c_str() ) );
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/// @fn DecimalToHexa
|
||||
/// @brief The portable to convert a decimal value into a hexadecimal string.
|
||||
/// @param toConvert Value to convert
|
||||
/// @return The hexadecimal string, is empty in case of an error.
|
||||
template<class T>
|
||||
AI_FORCE_INLINE
|
||||
std::string DecimalToHexa( T toConvert ) {
|
||||
std::string result;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << toConvert;
|
||||
ss >> result;
|
||||
|
||||
for ( size_t i = 0; i < result.size(); ++i ) {
|
||||
result[ i ] = toupper( result[ i ] );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // INCLUDED_AI_STRINGUTILS_H
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Defines a helper class to evaluate subdivision surfaces.*/
|
||||
#pragma once
|
||||
#ifndef AI_SUBDISIVION_H_INC
|
||||
#define AI_SUBDISIVION_H_INC
|
||||
|
||||
#include <cstddef>
|
||||
#include <assimp/types.h>
|
||||
|
||||
struct aiMesh;
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** Helper class to evaluate subdivision surfaces. Different algorithms
|
||||
* are provided for choice. */
|
||||
// ------------------------------------------------------------------------------
|
||||
class ASSIMP_API Subdivider {
|
||||
public:
|
||||
|
||||
/** Enumerates all supported subvidision algorithms */
|
||||
enum Algorithm {
|
||||
CATMULL_CLARKE = 0x1
|
||||
};
|
||||
|
||||
virtual ~Subdivider();
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/** Create a subdivider of a specific type
|
||||
*
|
||||
* @param algo Algorithm to be used for subdivision
|
||||
* @return Subdivider instance. */
|
||||
static Subdivider* Create (Algorithm algo);
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/** Subdivide a mesh using the selected algorithm
|
||||
*
|
||||
* @param mesh First mesh to be subdivided. Must be in verbose
|
||||
* format.
|
||||
* @param out Receives the output mesh, allocated by me.
|
||||
* @param num Number of subdivisions to perform.
|
||||
* @param discard_input If true is passed, the input mesh is
|
||||
* deleted after the subdivision is complete. This can
|
||||
* improve performance because it allows the optimization
|
||||
* to reuse the existing mesh for intermediate results.
|
||||
* @pre out!=mesh*/
|
||||
virtual void Subdivide ( aiMesh* mesh,
|
||||
aiMesh*& out, unsigned int num,
|
||||
bool discard_input = false) = 0;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/** Subdivide multiple meshes using the selected algorithm. This
|
||||
* avoids erroneous smoothing on objects consisting of multiple
|
||||
* per-material meshes. Usually, most 3d modellers smooth on a
|
||||
* per-object base, regardless the materials assigned to the
|
||||
* meshes.
|
||||
*
|
||||
* @param smesh Array of meshes to be subdivided. Must be in
|
||||
* verbose format.
|
||||
* @param nmesh Number of meshes in smesh.
|
||||
* @param out Receives the output meshes. The array must be
|
||||
* sufficiently large (at least @c nmesh elements) and may not
|
||||
* overlap the input array. Output meshes map one-to-one to
|
||||
* their corresponding input meshes. The meshes are allocated
|
||||
* by the function.
|
||||
* @param discard_input If true is passed, input meshes are
|
||||
* deleted after the subdivision is complete. This can
|
||||
* improve performance because it allows the optimization
|
||||
* of reusing existing meshes for intermediate results.
|
||||
* @param num Number of subdivisions to perform.
|
||||
* @pre nmesh != 0, smesh and out may not overlap*/
|
||||
virtual void Subdivide (
|
||||
aiMesh** smesh,
|
||||
size_t nmesh,
|
||||
aiMesh** out,
|
||||
unsigned int num,
|
||||
bool discard_input = false) = 0;
|
||||
|
||||
};
|
||||
|
||||
inline
|
||||
Subdivider::~Subdivider() {
|
||||
// empty
|
||||
}
|
||||
|
||||
} // end namespace Assimp
|
||||
|
||||
|
||||
#endif // !! AI_SUBDISIVION_H_INC
|
||||
|
||||
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file TinyFormatter.h
|
||||
* @brief Utility to format log messages more easily. Introduced
|
||||
* to get rid of the boost::format dependency. Much slinker,
|
||||
* basically just extends stringstream.
|
||||
*/
|
||||
#ifndef INCLUDED_TINY_FORMATTER_H
|
||||
#define INCLUDED_TINY_FORMATTER_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace Assimp {
|
||||
namespace Formatter {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** stringstream utility. Usage:
|
||||
* @code
|
||||
* void writelog(const std::string&s);
|
||||
* void writelog(const std::wstring&s);
|
||||
* ...
|
||||
* writelog(format()<< "hi! this is a number: " << 4);
|
||||
* writelog(wformat()<< L"hi! this is a number: " << 4);
|
||||
*
|
||||
* @endcode */
|
||||
template < typename T,
|
||||
typename CharTraits = std::char_traits<T>,
|
||||
typename Allocator = std::allocator<T>
|
||||
>
|
||||
class basic_formatter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef class std::basic_string<
|
||||
T,CharTraits,Allocator
|
||||
> string;
|
||||
|
||||
typedef class std::basic_ostringstream<
|
||||
T,CharTraits,Allocator
|
||||
> stringstream;
|
||||
|
||||
public:
|
||||
|
||||
basic_formatter() {}
|
||||
|
||||
/* Allow basic_formatter<T>'s to be used almost interchangeably
|
||||
* with std::(w)string or const (w)char* arguments because the
|
||||
* conversion c'tor is called implicitly. */
|
||||
template <typename TT>
|
||||
basic_formatter(const TT& sin) {
|
||||
underlying << sin;
|
||||
}
|
||||
|
||||
|
||||
// The problem described here:
|
||||
// https://sourceforge.net/tracker/?func=detail&atid=1067632&aid=3358562&group_id=226462
|
||||
// can also cause trouble here. Apparently, older gcc versions sometimes copy temporaries
|
||||
// being bound to const ref& function parameters. Copying streams is not permitted, though.
|
||||
// This workaround avoids this by manually specifying a copy ctor.
|
||||
#if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
explicit basic_formatter(const basic_formatter& other) {
|
||||
underlying << (string)other;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
|
||||
operator string () const {
|
||||
return underlying.str();
|
||||
}
|
||||
|
||||
|
||||
/* note - this is declared const because binding temporaries does only
|
||||
* work for const references, so many function prototypes will
|
||||
* include const basic_formatter<T>& s but might still want to
|
||||
* modify the formatted string without the need for a full copy.*/
|
||||
template <typename TToken>
|
||||
const basic_formatter& operator << (const TToken& s) const {
|
||||
underlying << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename TToken>
|
||||
basic_formatter& operator << (const TToken& s) {
|
||||
underlying << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// comma operator overloaded as well, choose your preferred way.
|
||||
template <typename TToken>
|
||||
const basic_formatter& operator, (const TToken& s) const {
|
||||
underlying << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename TToken>
|
||||
basic_formatter& operator, (const TToken& s) {
|
||||
underlying << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Fix for MSVC8
|
||||
// See https://sourceforge.net/projects/assimp/forums/forum/817654/topic/4372824
|
||||
template <typename TToken>
|
||||
basic_formatter& operator, (TToken& s) {
|
||||
underlying << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
mutable stringstream underlying;
|
||||
};
|
||||
|
||||
|
||||
typedef basic_formatter< char > format;
|
||||
typedef basic_formatter< wchar_t > wformat;
|
||||
|
||||
} // ! namespace Formatter
|
||||
|
||||
} // ! namespace Assimp
|
||||
|
||||
#endif
|
||||
|
|
@ -1,348 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
/** @file Defines a helper class to represent an interleaved vertex
|
||||
along with arithmetic operations to support vertex operations
|
||||
such as subdivision, smoothing etc.
|
||||
|
||||
While the code is kept as general as possible, arithmetic operations
|
||||
that are not currently well-defined (and would cause compile errors
|
||||
due to missing operators in the math library), are commented.
|
||||
*/
|
||||
#ifndef AI_VERTEX_H_INC
|
||||
#define AI_VERTEX_H_INC
|
||||
|
||||
#include <assimp/vector3.h>
|
||||
#include <assimp/mesh.h>
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <functional>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// std::plus-family operates on operands with identical types - we need to
|
||||
// support all the (vectype op float) combinations in vector maths.
|
||||
// Providing T(float) would open the way to endless implicit conversions.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
namespace Intern {
|
||||
template <typename T0, typename T1, typename TRES = T0> struct plus {
|
||||
TRES operator() (const T0& t0, const T1& t1) const {
|
||||
return t0+t1;
|
||||
}
|
||||
};
|
||||
template <typename T0, typename T1, typename TRES = T0> struct minus {
|
||||
TRES operator() (const T0& t0, const T1& t1) const {
|
||||
return t0-t1;
|
||||
}
|
||||
};
|
||||
template <typename T0, typename T1, typename TRES = T0> struct multiplies {
|
||||
TRES operator() (const T0& t0, const T1& t1) const {
|
||||
return t0*t1;
|
||||
}
|
||||
};
|
||||
template <typename T0, typename T1, typename TRES = T0> struct divides {
|
||||
TRES operator() (const T0& t0, const T1& t1) const {
|
||||
return t0/t1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/** Intermediate description a vertex with all possible components. Defines a full set of
|
||||
* operators, so you may use such a 'Vertex' in basic arithmetics. All operators are applied
|
||||
* to *all* vertex components equally. This is useful for stuff like interpolation
|
||||
* or subdivision, but won't work if special handling is required for some vertex components. */
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class Vertex
|
||||
{
|
||||
friend Vertex operator + (const Vertex&,const Vertex&);
|
||||
friend Vertex operator - (const Vertex&,const Vertex&);
|
||||
|
||||
// friend Vertex operator + (const Vertex&,ai_real);
|
||||
// friend Vertex operator - (const Vertex&,ai_real);
|
||||
friend Vertex operator * (const Vertex&,ai_real);
|
||||
friend Vertex operator / (const Vertex&,ai_real);
|
||||
|
||||
// friend Vertex operator + (ai_real, const Vertex&);
|
||||
// friend Vertex operator - (ai_real, const Vertex&);
|
||||
friend Vertex operator * (ai_real, const Vertex&);
|
||||
// friend Vertex operator / (ai_real, const Vertex&);
|
||||
|
||||
public:
|
||||
|
||||
Vertex() {}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Extract a particular vertex from a mesh and interleave all components */
|
||||
explicit Vertex(const aiMesh* msh, unsigned int idx) {
|
||||
ai_assert(idx < msh->mNumVertices);
|
||||
position = msh->mVertices[idx];
|
||||
|
||||
if (msh->HasNormals()) {
|
||||
normal = msh->mNormals[idx];
|
||||
}
|
||||
|
||||
if (msh->HasTangentsAndBitangents()) {
|
||||
tangent = msh->mTangents[idx];
|
||||
bitangent = msh->mBitangents[idx];
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; msh->HasTextureCoords(i); ++i) {
|
||||
texcoords[i] = msh->mTextureCoords[i][idx];
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; msh->HasVertexColors(i); ++i) {
|
||||
colors[i] = msh->mColors[i][idx];
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Extract a particular vertex from a anim mesh and interleave all components */
|
||||
explicit Vertex(const aiAnimMesh* msh, unsigned int idx) {
|
||||
ai_assert(idx < msh->mNumVertices);
|
||||
position = msh->mVertices[idx];
|
||||
|
||||
if (msh->HasNormals()) {
|
||||
normal = msh->mNormals[idx];
|
||||
}
|
||||
|
||||
if (msh->HasTangentsAndBitangents()) {
|
||||
tangent = msh->mTangents[idx];
|
||||
bitangent = msh->mBitangents[idx];
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; msh->HasTextureCoords(i); ++i) {
|
||||
texcoords[i] = msh->mTextureCoords[i][idx];
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; msh->HasVertexColors(i); ++i) {
|
||||
colors[i] = msh->mColors[i][idx];
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Vertex& operator += (const Vertex& v) {
|
||||
*this = *this+v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vertex& operator -= (const Vertex& v) {
|
||||
*this = *this-v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Vertex& operator += (ai_real v) {
|
||||
*this = *this+v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vertex& operator -= (ai_real v) {
|
||||
*this = *this-v;
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
Vertex& operator *= (ai_real v) {
|
||||
*this = *this*v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vertex& operator /= (ai_real v) {
|
||||
*this = *this/v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Convert back to non-interleaved storage */
|
||||
void SortBack(aiMesh* out, unsigned int idx) const {
|
||||
|
||||
ai_assert(idx<out->mNumVertices);
|
||||
out->mVertices[idx] = position;
|
||||
|
||||
if (out->HasNormals()) {
|
||||
out->mNormals[idx] = normal;
|
||||
}
|
||||
|
||||
if (out->HasTangentsAndBitangents()) {
|
||||
out->mTangents[idx] = tangent;
|
||||
out->mBitangents[idx] = bitangent;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; out->HasTextureCoords(i); ++i) {
|
||||
out->mTextureCoords[i][idx] = texcoords[i];
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; out->HasVertexColors(i); ++i) {
|
||||
out->mColors[i][idx] = colors[i];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Construct from two operands and a binary operation to combine them */
|
||||
template <template <typename t> class op> static Vertex BinaryOp(const Vertex& v0, const Vertex& v1) {
|
||||
// this is a heavy task for the compiler to optimize ... *pray*
|
||||
|
||||
Vertex res;
|
||||
res.position = op<aiVector3D>()(v0.position,v1.position);
|
||||
res.normal = op<aiVector3D>()(v0.normal,v1.normal);
|
||||
res.tangent = op<aiVector3D>()(v0.tangent,v1.tangent);
|
||||
res.bitangent = op<aiVector3D>()(v0.bitangent,v1.bitangent);
|
||||
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||
res.texcoords[i] = op<aiVector3D>()(v0.texcoords[i],v1.texcoords[i]);
|
||||
}
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
||||
res.colors[i] = op<aiColor4D>()(v0.colors[i],v1.colors[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This time binary arithmetics of v0 with a floating-point number */
|
||||
template <template <typename, typename, typename> class op> static Vertex BinaryOp(const Vertex& v0, ai_real f) {
|
||||
// this is a heavy task for the compiler to optimize ... *pray*
|
||||
|
||||
Vertex res;
|
||||
res.position = op<aiVector3D,ai_real,aiVector3D>()(v0.position,f);
|
||||
res.normal = op<aiVector3D,ai_real,aiVector3D>()(v0.normal,f);
|
||||
res.tangent = op<aiVector3D,ai_real,aiVector3D>()(v0.tangent,f);
|
||||
res.bitangent = op<aiVector3D,ai_real,aiVector3D>()(v0.bitangent,f);
|
||||
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||
res.texcoords[i] = op<aiVector3D,ai_real,aiVector3D>()(v0.texcoords[i],f);
|
||||
}
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
||||
res.colors[i] = op<aiColor4D,ai_real,aiColor4D>()(v0.colors[i],f);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This time binary arithmetics of v0 with a floating-point number */
|
||||
template <template <typename, typename, typename> class op> static Vertex BinaryOp(ai_real f, const Vertex& v0) {
|
||||
// this is a heavy task for the compiler to optimize ... *pray*
|
||||
|
||||
Vertex res;
|
||||
res.position = op<ai_real,aiVector3D,aiVector3D>()(f,v0.position);
|
||||
res.normal = op<ai_real,aiVector3D,aiVector3D>()(f,v0.normal);
|
||||
res.tangent = op<ai_real,aiVector3D,aiVector3D>()(f,v0.tangent);
|
||||
res.bitangent = op<ai_real,aiVector3D,aiVector3D>()(f,v0.bitangent);
|
||||
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||
res.texcoords[i] = op<ai_real,aiVector3D,aiVector3D>()(f,v0.texcoords[i]);
|
||||
}
|
||||
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
||||
res.colors[i] = op<ai_real,aiColor4D,aiColor4D>()(f,v0.colors[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
aiVector3D position;
|
||||
aiVector3D normal;
|
||||
aiVector3D tangent, bitangent;
|
||||
|
||||
aiVector3D texcoords[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||
aiColor4D colors[AI_MAX_NUMBER_OF_COLOR_SETS];
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE Vertex operator + (const Vertex& v0,const Vertex& v1) {
|
||||
return Vertex::BinaryOp<std::plus>(v0,v1);
|
||||
}
|
||||
|
||||
AI_FORCE_INLINE Vertex operator - (const Vertex& v0,const Vertex& v1) {
|
||||
return Vertex::BinaryOp<std::minus>(v0,v1);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
AI_FORCE_INLINE Vertex operator + (const Vertex& v0,ai_real f) {
|
||||
return Vertex::BinaryOp<Intern::plus>(v0,f);
|
||||
}
|
||||
|
||||
AI_FORCE_INLINE Vertex operator - (const Vertex& v0,ai_real f) {
|
||||
return Vertex::BinaryOp<Intern::minus>(v0,f);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
AI_FORCE_INLINE Vertex operator * (const Vertex& v0,ai_real f) {
|
||||
return Vertex::BinaryOp<Intern::multiplies>(v0,f);
|
||||
}
|
||||
|
||||
AI_FORCE_INLINE Vertex operator / (const Vertex& v0,ai_real f) {
|
||||
return Vertex::BinaryOp<Intern::multiplies>(v0,1.f/f);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
AI_FORCE_INLINE Vertex operator + (ai_real f,const Vertex& v0) {
|
||||
return Vertex::BinaryOp<Intern::plus>(f,v0);
|
||||
}
|
||||
|
||||
AI_FORCE_INLINE Vertex operator - (ai_real f,const Vertex& v0) {
|
||||
return Vertex::BinaryOp<Intern::minus>(f,v0);
|
||||
}
|
||||
*/
|
||||
|
||||
AI_FORCE_INLINE Vertex operator * (ai_real f,const Vertex& v0) {
|
||||
return Vertex::BinaryOp<Intern::multiplies>(f,v0);
|
||||
}
|
||||
|
||||
/*
|
||||
AI_FORCE_INLINE Vertex operator / (ai_real f,const Vertex& v0) {
|
||||
return Vertex::BinaryOp<Intern::divides>(f,v0);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_ASSIMP_XML_TOOLS_H
|
||||
#define INCLUDED_ASSIMP_XML_TOOLS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Assimp {
|
||||
// XML escape the 5 XML special characters (",',<,> and &) in |data|
|
||||
// Based on http://stackoverflow.com/questions/5665231
|
||||
std::string XMLEscape(const std::string& data) {
|
||||
std::string buffer;
|
||||
|
||||
const size_t size = data.size();
|
||||
buffer.reserve(size + size / 8);
|
||||
for(size_t i = 0; i < size; ++i) {
|
||||
const char c = data[i];
|
||||
switch(c) {
|
||||
case '&' :
|
||||
buffer.append("&");
|
||||
break;
|
||||
case '\"':
|
||||
buffer.append(""");
|
||||
break;
|
||||
case '\'':
|
||||
buffer.append("'");
|
||||
break;
|
||||
case '<' :
|
||||
buffer.append("<");
|
||||
break;
|
||||
case '>' :
|
||||
buffer.append(">");
|
||||
break;
|
||||
default:
|
||||
buffer.append(&c, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCLUDED_ASSIMP_XML_TOOLS_H
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -70,7 +69,7 @@ struct aiVectorKey
|
|||
#ifdef __cplusplus
|
||||
|
||||
/// @brief The default constructor.
|
||||
aiVectorKey() AI_NO_EXCEPT
|
||||
aiVectorKey()
|
||||
: mTime( 0.0 )
|
||||
, mValue() {
|
||||
// empty
|
||||
|
|
@ -79,27 +78,26 @@ struct aiVectorKey
|
|||
/// @brief Construction from a given time and key value.
|
||||
|
||||
aiVectorKey(double time, const aiVector3D& value)
|
||||
: mTime( time )
|
||||
, mValue( value ) {
|
||||
// empty
|
||||
}
|
||||
: mTime (time)
|
||||
, mValue (value)
|
||||
{}
|
||||
|
||||
typedef aiVector3D elem_type;
|
||||
|
||||
// Comparison operators. For use with std::find();
|
||||
bool operator == (const aiVectorKey& rhs) const {
|
||||
return rhs.mValue == this->mValue;
|
||||
bool operator == (const aiVectorKey& o) const {
|
||||
return o.mValue == this->mValue;
|
||||
}
|
||||
bool operator != (const aiVectorKey& rhs ) const {
|
||||
return rhs.mValue != this->mValue;
|
||||
bool operator != (const aiVectorKey& o) const {
|
||||
return o.mValue != this->mValue;
|
||||
}
|
||||
|
||||
// Relational operators. For use with std::sort();
|
||||
bool operator < (const aiVectorKey& rhs ) const {
|
||||
return mTime < rhs.mTime;
|
||||
bool operator < (const aiVectorKey& o) const {
|
||||
return mTime < o.mTime;
|
||||
}
|
||||
bool operator > (const aiVectorKey& rhs ) const {
|
||||
return mTime > rhs.mTime;
|
||||
bool operator > (const aiVectorKey& o) const {
|
||||
return mTime > o.mTime;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
|
@ -116,7 +114,7 @@ struct aiQuatKey
|
|||
C_STRUCT aiQuaternion mValue;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiQuatKey() AI_NO_EXCEPT
|
||||
aiQuatKey()
|
||||
: mTime( 0.0 )
|
||||
, mValue() {
|
||||
// empty
|
||||
|
|
@ -131,25 +129,25 @@ struct aiQuatKey
|
|||
typedef aiQuaternion elem_type;
|
||||
|
||||
// Comparison operators. For use with std::find();
|
||||
bool operator == (const aiQuatKey& rhs ) const {
|
||||
return rhs.mValue == this->mValue;
|
||||
bool operator == (const aiQuatKey& o) const {
|
||||
return o.mValue == this->mValue;
|
||||
}
|
||||
bool operator != (const aiQuatKey& rhs ) const {
|
||||
return rhs.mValue != this->mValue;
|
||||
bool operator != (const aiQuatKey& o) const {
|
||||
return o.mValue != this->mValue;
|
||||
}
|
||||
|
||||
// Relational operators. For use with std::sort();
|
||||
bool operator < (const aiQuatKey& rhs ) const {
|
||||
return mTime < rhs.mTime;
|
||||
bool operator < (const aiQuatKey& o) const {
|
||||
return mTime < o.mTime;
|
||||
}
|
||||
bool operator > (const aiQuatKey& rhs ) const {
|
||||
return mTime > rhs.mTime;
|
||||
bool operator > (const aiQuatKey& o) const {
|
||||
return mTime > o.mTime;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Binds a anim-mesh to a specific point in time. */
|
||||
/** Binds a anim mesh to a specific point in time. */
|
||||
struct aiMeshKey
|
||||
{
|
||||
/** The time of this key */
|
||||
|
|
@ -163,10 +161,7 @@ struct aiMeshKey
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiMeshKey() AI_NO_EXCEPT
|
||||
: mTime(0.0)
|
||||
, mValue(0)
|
||||
{
|
||||
aiMeshKey() {
|
||||
}
|
||||
|
||||
/** Construction from a given time and key value */
|
||||
|
|
@ -210,10 +205,10 @@ struct aiMeshMorphKey
|
|||
/** The number of values and weights */
|
||||
unsigned int mNumValuesAndWeights;
|
||||
#ifdef __cplusplus
|
||||
aiMeshMorphKey() AI_NO_EXCEPT
|
||||
aiMeshMorphKey()
|
||||
: mTime(0.0)
|
||||
, mValues(nullptr)
|
||||
, mWeights(nullptr)
|
||||
, mValues(NULL)
|
||||
, mWeights(NULL)
|
||||
, mNumValuesAndWeights(0)
|
||||
{
|
||||
|
||||
|
|
@ -324,13 +319,13 @@ struct aiNodeAnim {
|
|||
C_ENUM aiAnimBehaviour mPostState;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiNodeAnim() AI_NO_EXCEPT
|
||||
aiNodeAnim()
|
||||
: mNumPositionKeys( 0 )
|
||||
, mPositionKeys( nullptr )
|
||||
, mPositionKeys( NULL )
|
||||
, mNumRotationKeys( 0 )
|
||||
, mRotationKeys( nullptr )
|
||||
, mRotationKeys( NULL )
|
||||
, mNumScalingKeys( 0 )
|
||||
, mScalingKeys( nullptr )
|
||||
, mScalingKeys( NULL )
|
||||
, mPreState( aiAnimBehaviour_DEFAULT )
|
||||
, mPostState( aiAnimBehaviour_DEFAULT ) {
|
||||
// empty
|
||||
|
|
@ -366,7 +361,7 @@ struct aiMeshAnim
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiMeshAnim() AI_NO_EXCEPT
|
||||
aiMeshAnim()
|
||||
: mNumKeys()
|
||||
, mKeys()
|
||||
{}
|
||||
|
|
@ -397,7 +392,7 @@ struct aiMeshMorphAnim
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiMeshMorphAnim() AI_NO_EXCEPT
|
||||
aiMeshMorphAnim()
|
||||
: mNumKeys()
|
||||
, mKeys()
|
||||
{}
|
||||
|
|
@ -451,15 +446,15 @@ struct aiAnimation {
|
|||
C_STRUCT aiMeshMorphAnim **mMorphMeshChannels;
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiAnimation() AI_NO_EXCEPT
|
||||
aiAnimation()
|
||||
: mDuration(-1.)
|
||||
, mTicksPerSecond(0.)
|
||||
, mNumChannels(0)
|
||||
, mChannels(nullptr)
|
||||
, mChannels(NULL)
|
||||
, mNumMeshChannels(0)
|
||||
, mMeshChannels(nullptr)
|
||||
, mMeshChannels(NULL)
|
||||
, mNumMorphMeshChannels(0)
|
||||
, mMorphMeshChannels(nullptr) {
|
||||
, mMorphMeshChannels(NULL) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -174,7 +173,7 @@ struct aiCamera
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiCamera() AI_NO_EXCEPT
|
||||
aiCamera()
|
||||
: mUp (0.f,1.f,0.f)
|
||||
, mLookAt (0.f,0.f,1.f)
|
||||
, mHorizontalFOV (0.25f * (float)AI_MATH_PI)
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ struct aiExportFormatDesc
|
|||
*/
|
||||
ASSIMP_API size_t aiGetExportFormatCount(void);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Returns a description of the nth export file format. Use #aiGetExportFormatCount()
|
||||
* to learn how many export formats are supported. The description must be released by
|
||||
|
|
@ -185,6 +186,7 @@ ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene,
|
|||
C_STRUCT aiFileIO* pIO,
|
||||
unsigned int pPreprocessing );
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Describes a blob of exported scene data. Use #aiExportSceneToBlob() to create a blob containing an
|
||||
* exported scene. The memory referred by this structure is owned by Assimp.
|
||||
|
|
@ -243,8 +245,8 @@ private:
|
|||
* @param pPreprocessing Please see the documentation for #aiExportScene
|
||||
* @return the exported data or NULL in case of error
|
||||
*/
|
||||
ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT aiScene* pScene, const char* pFormatId,
|
||||
unsigned int pPreprocessing );
|
||||
ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing );
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
/** Releases the memory associated with the given exported data. Use this function to free a data blob
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -59,7 +58,7 @@ template <typename TReal>
|
|||
class aiColor4t
|
||||
{
|
||||
public:
|
||||
aiColor4t() AI_NO_EXCEPT : r(), g(), b(), a() {}
|
||||
aiColor4t () : r(), g(), b(), a() {}
|
||||
aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
|
||||
: r(_r), g(_g), b(_b), a(_a) {}
|
||||
explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2016, assimp team
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -55,8 +55,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
* #aiSetImportPropertyFloat,
|
||||
* #aiSetImportPropertyString
|
||||
*/
|
||||
#ifndef INCLUDED_AI_CONFIG_H
|
||||
#define INCLUDED_AI_CONFIG_H
|
||||
#pragma once
|
||||
#ifndef AI_CONFIG_H_INC
|
||||
#define AI_CONFIG_H_INC
|
||||
|
||||
|
||||
// ###########################################################################
|
||||
|
|
@ -265,6 +266,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define AI_CONFIG_PP_FD_REMOVE \
|
||||
"PP_FD_REMOVE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Configures the #aiProcess_FindDegenerates to check the area of a
|
||||
* trinagle to be greates than e-6. If this is not the case the triangle will
|
||||
* be removed if #AI_CONFIG_PP_FD_REMOVE is set to true.
|
||||
*/
|
||||
#define AI_CONFIG_PP_FD_CHECKAREA \
|
||||
"PP_FD_CHECKAREA"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the #aiProcess_OptimizeGraph step to preserve nodes
|
||||
* matching a name in a given list.
|
||||
|
|
@ -322,7 +332,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
/** @brief Set the maximum number of bones affecting a single vertex
|
||||
*
|
||||
* This is used by the #aiProcess_LimitBoneWeights PostProcess-Step.
|
||||
* @note The default value is AI_LBW_MAX_WEIGHTS
|
||||
* @note The default value is AI_LMW_MAX_WEIGHTS
|
||||
* Property type: integer.*/
|
||||
#define AI_CONFIG_PP_LBW_MAX_WEIGHTS \
|
||||
"PP_LBW_MAX_WEIGHTS"
|
||||
|
|
@ -631,8 +641,15 @@ enum aiComponent
|
|||
#define AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES \
|
||||
"IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES"
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will search for embedded loaded textures, where no embedded texture data is provided.
|
||||
*
|
||||
* The default value is false (0)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_SEARCH_EMBEDDED_TEXTURES \
|
||||
"IMPORT_FBX_SEARCH_EMBEDDED_TEXTURES"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the vertex animation keyframe to be imported
|
||||
*
|
||||
|
|
@ -843,14 +860,6 @@ enum aiComponent
|
|||
#define AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME \
|
||||
"IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME"
|
||||
|
||||
/** @brief Specifies whether the IFC loader skips over IfcSpace elements.
|
||||
*
|
||||
* IfcSpace elements (and their geometric representations) are used to
|
||||
* represent, well, free space in a building storey.<br>
|
||||
* Property type: Bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS "IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS"
|
||||
|
||||
/** @brief Specifies whether the Android JNI asset extraction is supported.
|
||||
*
|
||||
* Turn on this option if you want to manage assets in native
|
||||
|
|
@ -859,17 +868,14 @@ enum aiComponent
|
|||
*/
|
||||
#define AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT "AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the IFC loader skips over
|
||||
* shape representations of type 'Curve2D'.
|
||||
/** @brief Specifies whether the IFC loader skips over IfcSpace elements.
|
||||
*
|
||||
* A lot of files contain both a faceted mesh representation and a outline
|
||||
* with a presentation type of 'Curve2D'. Currently Assimp doesn't convert those,
|
||||
* so turning this option off just clutters the log with errors.<br>
|
||||
* IfcSpace elements (and their geometric representations) are used to
|
||||
* represent, well, free space in a building storey.<br>
|
||||
* Property type: Bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS "IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS"
|
||||
#define AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS "IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the IFC loader will use its own, custom triangulation
|
||||
|
|
@ -886,6 +892,38 @@ enum aiComponent
|
|||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the tessellation conic angle for IFC smoothing curves.
|
||||
*
|
||||
* This is used by the IFC importer to determine the tessellation parameter
|
||||
* for smoothing curves.
|
||||
* @note The default value is AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE and the
|
||||
* accepted values are in range [5.0, 120.0].
|
||||
* Property type: Float.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE "IMPORT_IFC_SMOOTHING_ANGLE"
|
||||
|
||||
// default value for AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE
|
||||
#if (!defined AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE)
|
||||
# define AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE 10.0f
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the tessellation for IFC cylindrical shapes.
|
||||
*
|
||||
* This is used by the IFC importer to determine the tessellation parameter
|
||||
* for cylindrical shapes, i.e. the number of segments used to approximate a circle.
|
||||
* @note The default value is AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION and the
|
||||
* accepted values are in range [3, 180].
|
||||
* Property type: Integer.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION "IMPORT_IFC_CYLINDRICAL_TESSELLATION"
|
||||
|
||||
// default value for AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION
|
||||
#if (!defined AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION)
|
||||
# define AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION 32
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the Collada loader will ignore the provided up direction.
|
||||
*
|
||||
|
|
@ -904,4 +942,22 @@ enum aiComponent
|
|||
|
||||
#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
|
||||
|
||||
/**
|
||||
* @brief Specifies a gobal key factor for scale, float value
|
||||
*/
|
||||
#define AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY "GLOBAL_SCALE_FACTOR"
|
||||
|
||||
#if (!defined AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT)
|
||||
# define AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT 1.0f
|
||||
#endif // !! AI_DEBONE_THRESHOLD
|
||||
|
||||
// ---------- All the Build/Compile-time defines ------------
|
||||
|
||||
/** @brief Specifies if double precision is supported inside assimp
|
||||
*
|
||||
* Property type: Bool. Default value: undefined.
|
||||
*/
|
||||
|
||||
/* #undef ASSIMP_DOUBLE_PRECISION */
|
||||
|
||||
#endif // !! AI_CONFIG_H_INC
|
||||
|
|
|
|||
|
|
@ -1,979 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file config.h
|
||||
* @brief Defines constants for configurable properties for the library
|
||||
*
|
||||
* Typically these properties are set via
|
||||
* #Assimp::Importer::SetPropertyFloat,
|
||||
* #Assimp::Importer::SetPropertyInteger or
|
||||
* #Assimp::Importer::SetPropertyString,
|
||||
* depending on the data type of a property. All properties have a
|
||||
* default value. See the doc for the mentioned methods for more details.
|
||||
*
|
||||
* <br><br>
|
||||
* The corresponding functions for use with the plain-c API are:
|
||||
* #aiSetImportPropertyInteger,
|
||||
* #aiSetImportPropertyFloat,
|
||||
* #aiSetImportPropertyString
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef AI_CONFIG_H_INC
|
||||
#define AI_CONFIG_H_INC
|
||||
|
||||
|
||||
// ###########################################################################
|
||||
// LIBRARY SETTINGS
|
||||
// General, global settings
|
||||
// ###########################################################################
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Enables time measurements.
|
||||
*
|
||||
* If enabled, measures the time needed for each part of the loading
|
||||
* process (i.e. IO time, importing, postprocessing, ..) and dumps
|
||||
* these timings to the DefaultLogger. See the @link perf Performance
|
||||
* Page@endlink for more information on this topic.
|
||||
*
|
||||
* Property type: bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_GLOB_MEASURE_TIME \
|
||||
"GLOB_MEASURE_TIME"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Global setting to disable generation of skeleton dummy meshes
|
||||
*
|
||||
* Skeleton dummy meshes are generated as a visualization aid in cases which
|
||||
* the input data contains no geometry, but only animation data.
|
||||
* Property data type: bool. Default value: false
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
#define AI_CONFIG_IMPORT_NO_SKELETON_MESHES \
|
||||
"IMPORT_NO_SKELETON_MESHES"
|
||||
|
||||
|
||||
|
||||
# if 0 // not implemented yet
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set Assimp's multithreading policy.
|
||||
*
|
||||
* This setting is ignored if Assimp was built without boost.thread
|
||||
* support (ASSIMP_BUILD_NO_THREADING, which is implied by ASSIMP_BUILD_BOOST_WORKAROUND).
|
||||
* Possible values are: -1 to let Assimp decide what to do, 0 to disable
|
||||
* multithreading entirely and any number larger than 0 to force a specific
|
||||
* number of threads. Assimp is always free to ignore this settings, which is
|
||||
* merely a hint. Usually, the default value (-1) will be fine. However, if
|
||||
* Assimp is used concurrently from multiple user threads, it might be useful
|
||||
* to limit each Importer instance to a specific number of cores.
|
||||
*
|
||||
* For more information, see the @link threading Threading page@endlink.
|
||||
* Property type: int, default value: -1.
|
||||
*/
|
||||
#define AI_CONFIG_GLOB_MULTITHREADING \
|
||||
"GLOB_MULTITHREADING"
|
||||
#endif
|
||||
|
||||
// ###########################################################################
|
||||
// POST PROCESSING SETTINGS
|
||||
// Various stuff to fine-tune the behavior of a specific post processing step.
|
||||
// ###########################################################################
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Maximum bone count per mesh for the SplitbyBoneCount step.
|
||||
*
|
||||
* Meshes are split until the maximum number of bones is reached. The default
|
||||
* value is AI_SBBC_DEFAULT_MAX_BONES, which may be altered at
|
||||
* compile-time.
|
||||
* Property data type: integer.
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
#define AI_CONFIG_PP_SBBC_MAX_BONES \
|
||||
"PP_SBBC_MAX_BONES"
|
||||
|
||||
|
||||
// default limit for bone count
|
||||
#if (!defined AI_SBBC_DEFAULT_MAX_BONES)
|
||||
# define AI_SBBC_DEFAULT_MAX_BONES 60
|
||||
#endif
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies the maximum angle that may be between two vertex tangents
|
||||
* that their tangents and bi-tangents are smoothed.
|
||||
*
|
||||
* This applies to the CalcTangentSpace-Step. The angle is specified
|
||||
* in degrees. The maximum value is 175.
|
||||
* Property type: float. Default value: 45 degrees
|
||||
*/
|
||||
#define AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE \
|
||||
"PP_CT_MAX_SMOOTHING_ANGLE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Source UV channel for tangent space computation.
|
||||
*
|
||||
* The specified channel must exist or an error will be raised.
|
||||
* Property type: integer. Default value: 0
|
||||
*/
|
||||
// ---------------------------------------------------------------------------
|
||||
#define AI_CONFIG_PP_CT_TEXTURE_CHANNEL_INDEX \
|
||||
"PP_CT_TEXTURE_CHANNEL_INDEX"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies the maximum angle that may be between two face normals
|
||||
* at the same vertex position that their are smoothed together.
|
||||
*
|
||||
* Sometimes referred to as 'crease angle'.
|
||||
* This applies to the GenSmoothNormals-Step. The angle is specified
|
||||
* in degrees, so 180 is PI. The default value is 175 degrees (all vertex
|
||||
* normals are smoothed). The maximum value is 175, too. Property type: float.
|
||||
* Warning: setting this option may cause a severe loss of performance. The
|
||||
* performance is unaffected if the #AI_CONFIG_FAVOUR_SPEED flag is set but
|
||||
* the output quality may be reduced.
|
||||
*/
|
||||
#define AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE \
|
||||
"PP_GSN_MAX_SMOOTHING_ANGLE"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Sets the colormap (= palette) to be used to decode embedded
|
||||
* textures in MDL (Quake or 3DGS) files.
|
||||
*
|
||||
* This must be a valid path to a file. The file is 768 (256*3) bytes
|
||||
* large and contains RGB triplets for each of the 256 palette entries.
|
||||
* The default value is colormap.lmp. If the file is not found,
|
||||
* a default palette (from Quake 1) is used.
|
||||
* Property type: string.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_MDL_COLORMAP \
|
||||
"IMPORT_MDL_COLORMAP"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the #aiProcess_RemoveRedundantMaterials step to
|
||||
* keep materials matching a name in a given list.
|
||||
*
|
||||
* This is a list of 1 to n strings, ' ' serves as delimiter character.
|
||||
* Identifiers containing whitespaces must be enclosed in *single*
|
||||
* quotation marks. For example:<tt>
|
||||
* "keep-me and_me_to anotherMaterialToBeKept \'name with whitespace\'"</tt>.
|
||||
* If a material matches on of these names, it will not be modified or
|
||||
* removed by the postprocessing step nor will other materials be replaced
|
||||
* by a reference to it. <br>
|
||||
* This option might be useful if you are using some magic material names
|
||||
* to pass additional semantics through the content pipeline. This ensures
|
||||
* they won't be optimized away, but a general optimization is still
|
||||
* performed for materials not contained in the list.
|
||||
* Property type: String. Default value: n/a
|
||||
* @note Linefeeds, tabs or carriage returns are treated as whitespace.
|
||||
* Material names are case sensitive.
|
||||
*/
|
||||
#define AI_CONFIG_PP_RRM_EXCLUDE_LIST \
|
||||
"PP_RRM_EXCLUDE_LIST"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the #aiProcess_PreTransformVertices step to
|
||||
* keep the scene hierarchy. Meshes are moved to worldspace, but
|
||||
* no optimization is performed (read: meshes with equal materials are not
|
||||
* joined. The total number of meshes won't change).
|
||||
*
|
||||
* This option could be of use for you if the scene hierarchy contains
|
||||
* important additional information which you intend to parse.
|
||||
* For rendering, you can still render all meshes in the scene without
|
||||
* any transformations.
|
||||
* Property type: bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_PP_PTV_KEEP_HIERARCHY \
|
||||
"PP_PTV_KEEP_HIERARCHY"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the #aiProcess_PreTransformVertices step to normalize
|
||||
* all vertex components into the [-1,1] range. That is, a bounding box
|
||||
* for the whole scene is computed, the maximum component is taken and all
|
||||
* meshes are scaled appropriately (uniformly of course!).
|
||||
* This might be useful if you don't know the spatial dimension of the input
|
||||
* data*/
|
||||
#define AI_CONFIG_PP_PTV_NORMALIZE \
|
||||
"PP_PTV_NORMALIZE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the #aiProcess_PreTransformVertices step to use
|
||||
* a users defined matrix as the scene root node transformation before
|
||||
* transforming vertices.
|
||||
* Property type: bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_PP_PTV_ADD_ROOT_TRANSFORMATION \
|
||||
"PP_PTV_ADD_ROOT_TRANSFORMATION"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the #aiProcess_PreTransformVertices step to use
|
||||
* a users defined matrix as the scene root node transformation before
|
||||
* transforming vertices. This property correspond to the 'a1' component
|
||||
* of the transformation matrix.
|
||||
* Property type: aiMatrix4x4.
|
||||
*/
|
||||
#define AI_CONFIG_PP_PTV_ROOT_TRANSFORMATION \
|
||||
"PP_PTV_ROOT_TRANSFORMATION"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the #aiProcess_FindDegenerates step to
|
||||
* remove degenerated primitives from the import - immediately.
|
||||
*
|
||||
* The default behaviour converts degenerated triangles to lines and
|
||||
* degenerated lines to points. See the documentation to the
|
||||
* #aiProcess_FindDegenerates step for a detailed example of the various ways
|
||||
* to get rid of these lines and points if you don't want them.
|
||||
* Property type: bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_PP_FD_REMOVE \
|
||||
"PP_FD_REMOVE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Configures the #aiProcess_FindDegenerates to check the area of a
|
||||
* trinagle to be greates than e-6. If this is not the case the triangle will
|
||||
* be removed if #AI_CONFIG_PP_FD_REMOVE is set to true.
|
||||
*/
|
||||
#define AI_CONFIG_PP_FD_CHECKAREA \
|
||||
"PP_FD_CHECKAREA"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the #aiProcess_OptimizeGraph step to preserve nodes
|
||||
* matching a name in a given list.
|
||||
*
|
||||
* This is a list of 1 to n strings, ' ' serves as delimiter character.
|
||||
* Identifiers containing whitespaces must be enclosed in *single*
|
||||
* quotation marks. For example:<tt>
|
||||
* "keep-me and_me_to anotherNodeToBeKept \'name with whitespace\'"</tt>.
|
||||
* If a node matches on of these names, it will not be modified or
|
||||
* removed by the postprocessing step.<br>
|
||||
* This option might be useful if you are using some magic node names
|
||||
* to pass additional semantics through the content pipeline. This ensures
|
||||
* they won't be optimized away, but a general optimization is still
|
||||
* performed for nodes not contained in the list.
|
||||
* Property type: String. Default value: n/a
|
||||
* @note Linefeeds, tabs or carriage returns are treated as whitespace.
|
||||
* Node names are case sensitive.
|
||||
*/
|
||||
#define AI_CONFIG_PP_OG_EXCLUDE_LIST \
|
||||
"PP_OG_EXCLUDE_LIST"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the maximum number of triangles in a mesh.
|
||||
*
|
||||
* This is used by the "SplitLargeMeshes" PostProcess-Step to determine
|
||||
* whether a mesh must be split or not.
|
||||
* @note The default value is AI_SLM_DEFAULT_MAX_TRIANGLES
|
||||
* Property type: integer.
|
||||
*/
|
||||
#define AI_CONFIG_PP_SLM_TRIANGLE_LIMIT \
|
||||
"PP_SLM_TRIANGLE_LIMIT"
|
||||
|
||||
// default value for AI_CONFIG_PP_SLM_TRIANGLE_LIMIT
|
||||
#if (!defined AI_SLM_DEFAULT_MAX_TRIANGLES)
|
||||
# define AI_SLM_DEFAULT_MAX_TRIANGLES 1000000
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the maximum number of vertices in a mesh.
|
||||
*
|
||||
* This is used by the "SplitLargeMeshes" PostProcess-Step to determine
|
||||
* whether a mesh must be split or not.
|
||||
* @note The default value is AI_SLM_DEFAULT_MAX_VERTICES
|
||||
* Property type: integer.
|
||||
*/
|
||||
#define AI_CONFIG_PP_SLM_VERTEX_LIMIT \
|
||||
"PP_SLM_VERTEX_LIMIT"
|
||||
|
||||
// default value for AI_CONFIG_PP_SLM_VERTEX_LIMIT
|
||||
#if (!defined AI_SLM_DEFAULT_MAX_VERTICES)
|
||||
# define AI_SLM_DEFAULT_MAX_VERTICES 1000000
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the maximum number of bones affecting a single vertex
|
||||
*
|
||||
* This is used by the #aiProcess_LimitBoneWeights PostProcess-Step.
|
||||
* @note The default value is AI_LMW_MAX_WEIGHTS
|
||||
* Property type: integer.*/
|
||||
#define AI_CONFIG_PP_LBW_MAX_WEIGHTS \
|
||||
"PP_LBW_MAX_WEIGHTS"
|
||||
|
||||
// default value for AI_CONFIG_PP_LBW_MAX_WEIGHTS
|
||||
#if (!defined AI_LMW_MAX_WEIGHTS)
|
||||
# define AI_LMW_MAX_WEIGHTS 0x4
|
||||
#endif // !! AI_LMW_MAX_WEIGHTS
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Lower the deboning threshold in order to remove more bones.
|
||||
*
|
||||
* This is used by the #aiProcess_Debone PostProcess-Step.
|
||||
* @note The default value is AI_DEBONE_THRESHOLD
|
||||
* Property type: float.*/
|
||||
#define AI_CONFIG_PP_DB_THRESHOLD \
|
||||
"PP_DB_THRESHOLD"
|
||||
|
||||
// default value for AI_CONFIG_PP_LBW_MAX_WEIGHTS
|
||||
#if (!defined AI_DEBONE_THRESHOLD)
|
||||
# define AI_DEBONE_THRESHOLD 1.0f
|
||||
#endif // !! AI_DEBONE_THRESHOLD
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Require all bones qualify for deboning before removing any
|
||||
*
|
||||
* This is used by the #aiProcess_Debone PostProcess-Step.
|
||||
* @note The default value is 0
|
||||
* Property type: bool.*/
|
||||
#define AI_CONFIG_PP_DB_ALL_OR_NONE \
|
||||
"PP_DB_ALL_OR_NONE"
|
||||
|
||||
/** @brief Default value for the #AI_CONFIG_PP_ICL_PTCACHE_SIZE property
|
||||
*/
|
||||
#ifndef PP_ICL_PTCACHE_SIZE
|
||||
# define PP_ICL_PTCACHE_SIZE 12
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the size of the post-transform vertex cache to optimize the
|
||||
* vertices for. This configures the #aiProcess_ImproveCacheLocality step.
|
||||
*
|
||||
* The size is given in vertices. Of course you can't know how the vertex
|
||||
* format will exactly look like after the import returns, but you can still
|
||||
* guess what your meshes will probably have.
|
||||
* @note The default value is #PP_ICL_PTCACHE_SIZE. That results in slight
|
||||
* performance improvements for most nVidia/AMD cards since 2002.
|
||||
* Property type: integer.
|
||||
*/
|
||||
#define AI_CONFIG_PP_ICL_PTCACHE_SIZE "PP_ICL_PTCACHE_SIZE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Enumerates components of the aiScene and aiMesh data structures
|
||||
* that can be excluded from the import using the #aiProcess_RemoveComponent step.
|
||||
*
|
||||
* See the documentation to #aiProcess_RemoveComponent for more details.
|
||||
*/
|
||||
enum aiComponent
|
||||
{
|
||||
/** Normal vectors */
|
||||
#ifdef SWIG
|
||||
aiComponent_NORMALS = 0x2,
|
||||
#else
|
||||
aiComponent_NORMALS = 0x2u,
|
||||
#endif
|
||||
|
||||
/** Tangents and bitangents go always together ... */
|
||||
#ifdef SWIG
|
||||
aiComponent_TANGENTS_AND_BITANGENTS = 0x4,
|
||||
#else
|
||||
aiComponent_TANGENTS_AND_BITANGENTS = 0x4u,
|
||||
#endif
|
||||
|
||||
/** ALL color sets
|
||||
* Use aiComponent_COLORn(N) to specify the N'th set */
|
||||
aiComponent_COLORS = 0x8,
|
||||
|
||||
/** ALL texture UV sets
|
||||
* aiComponent_TEXCOORDn(N) to specify the N'th set */
|
||||
aiComponent_TEXCOORDS = 0x10,
|
||||
|
||||
/** Removes all bone weights from all meshes.
|
||||
* The scenegraph nodes corresponding to the bones are NOT removed.
|
||||
* use the #aiProcess_OptimizeGraph step to do this */
|
||||
aiComponent_BONEWEIGHTS = 0x20,
|
||||
|
||||
/** Removes all node animations (aiScene::mAnimations).
|
||||
* The corresponding scenegraph nodes are NOT removed.
|
||||
* use the #aiProcess_OptimizeGraph step to do this */
|
||||
aiComponent_ANIMATIONS = 0x40,
|
||||
|
||||
/** Removes all embedded textures (aiScene::mTextures) */
|
||||
aiComponent_TEXTURES = 0x80,
|
||||
|
||||
/** Removes all light sources (aiScene::mLights).
|
||||
* The corresponding scenegraph nodes are NOT removed.
|
||||
* use the #aiProcess_OptimizeGraph step to do this */
|
||||
aiComponent_LIGHTS = 0x100,
|
||||
|
||||
/** Removes all cameras (aiScene::mCameras).
|
||||
* The corresponding scenegraph nodes are NOT removed.
|
||||
* use the #aiProcess_OptimizeGraph step to do this */
|
||||
aiComponent_CAMERAS = 0x200,
|
||||
|
||||
/** Removes all meshes (aiScene::mMeshes). */
|
||||
aiComponent_MESHES = 0x400,
|
||||
|
||||
/** Removes all materials. One default material will
|
||||
* be generated, so aiScene::mNumMaterials will be 1. */
|
||||
aiComponent_MATERIALS = 0x800,
|
||||
|
||||
|
||||
/** This value is not used. It is just there to force the
|
||||
* compiler to map this enum to a 32 Bit integer. */
|
||||
#ifndef SWIG
|
||||
_aiComponent_Force32Bit = 0x9fffffff
|
||||
#endif
|
||||
};
|
||||
|
||||
// Remove a specific color channel 'n'
|
||||
#define aiComponent_COLORSn(n) (1u << (n+20u))
|
||||
|
||||
// Remove a specific UV channel 'n'
|
||||
#define aiComponent_TEXCOORDSn(n) (1u << (n+25u))
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Input parameter to the #aiProcess_RemoveComponent step:
|
||||
* Specifies the parts of the data structure to be removed.
|
||||
*
|
||||
* See the documentation to this step for further details. The property
|
||||
* is expected to be an integer, a bitwise combination of the
|
||||
* #aiComponent flags defined above in this header. The default
|
||||
* value is 0. Important: if no valid mesh is remaining after the
|
||||
* step has been executed (e.g you thought it was funny to specify ALL
|
||||
* of the flags defined above) the import FAILS. Mainly because there is
|
||||
* no data to work on anymore ...
|
||||
*/
|
||||
#define AI_CONFIG_PP_RVC_FLAGS \
|
||||
"PP_RVC_FLAGS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Input parameter to the #aiProcess_SortByPType step:
|
||||
* Specifies which primitive types are removed by the step.
|
||||
*
|
||||
* This is a bitwise combination of the aiPrimitiveType flags.
|
||||
* Specifying all of them is illegal, of course. A typical use would
|
||||
* be to exclude all line and point meshes from the import. This
|
||||
* is an integer property, its default value is 0.
|
||||
*/
|
||||
#define AI_CONFIG_PP_SBP_REMOVE \
|
||||
"PP_SBP_REMOVE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Input parameter to the #aiProcess_FindInvalidData step:
|
||||
* Specifies the floating-point accuracy for animation values. The step
|
||||
* checks for animation tracks where all frame values are absolutely equal
|
||||
* and removes them. This tweakable controls the epsilon for floating-point
|
||||
* comparisons - two keys are considered equal if the invariant
|
||||
* abs(n0-n1)>epsilon holds true for all vector respectively quaternion
|
||||
* components. The default value is 0.f - comparisons are exact then.
|
||||
*/
|
||||
#define AI_CONFIG_PP_FID_ANIM_ACCURACY \
|
||||
"PP_FID_ANIM_ACCURACY"
|
||||
|
||||
|
||||
// TransformUVCoords evaluates UV scalings
|
||||
#define AI_UVTRAFO_SCALING 0x1
|
||||
|
||||
// TransformUVCoords evaluates UV rotations
|
||||
#define AI_UVTRAFO_ROTATION 0x2
|
||||
|
||||
// TransformUVCoords evaluates UV translation
|
||||
#define AI_UVTRAFO_TRANSLATION 0x4
|
||||
|
||||
// Everything baked together -> default value
|
||||
#define AI_UVTRAFO_ALL (AI_UVTRAFO_SCALING | AI_UVTRAFO_ROTATION | AI_UVTRAFO_TRANSLATION)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Input parameter to the #aiProcess_TransformUVCoords step:
|
||||
* Specifies which UV transformations are evaluated.
|
||||
*
|
||||
* This is a bitwise combination of the AI_UVTRAFO_XXX flags (integer
|
||||
* property, of course). By default all transformations are enabled
|
||||
* (AI_UVTRAFO_ALL).
|
||||
*/
|
||||
#define AI_CONFIG_PP_TUV_EVALUATE \
|
||||
"PP_TUV_EVALUATE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief A hint to assimp to favour speed against import quality.
|
||||
*
|
||||
* Enabling this option may result in faster loading, but it needn't.
|
||||
* It represents just a hint to loaders and post-processing steps to use
|
||||
* faster code paths, if possible.
|
||||
* This property is expected to be an integer, != 0 stands for true.
|
||||
* The default value is 0.
|
||||
*/
|
||||
#define AI_CONFIG_FAVOUR_SPEED \
|
||||
"FAVOUR_SPEED"
|
||||
|
||||
|
||||
// ###########################################################################
|
||||
// IMPORTER SETTINGS
|
||||
// Various stuff to fine-tune the behaviour of specific importer plugins.
|
||||
// ###########################################################################
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will merge all geometry layers present
|
||||
* in the source file or take only the first.
|
||||
*
|
||||
* The default value is true (1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_READ_ALL_GEOMETRY_LAYERS \
|
||||
"IMPORT_FBX_READ_ALL_GEOMETRY_LAYERS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will read all materials present in the
|
||||
* source file or take only the referenced materials.
|
||||
*
|
||||
* This is void unless IMPORT_FBX_READ_MATERIALS=1.
|
||||
*
|
||||
* The default value is false (0)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_READ_ALL_MATERIALS \
|
||||
"IMPORT_FBX_READ_ALL_MATERIALS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will read materials.
|
||||
*
|
||||
* The default value is true (1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_READ_MATERIALS \
|
||||
"IMPORT_FBX_READ_MATERIALS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will read embedded textures.
|
||||
*
|
||||
* The default value is true (1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_READ_TEXTURES \
|
||||
"IMPORT_FBX_READ_TEXTURES"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will read cameras.
|
||||
*
|
||||
* The default value is true (1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_READ_CAMERAS \
|
||||
"IMPORT_FBX_READ_CAMERAS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will read light sources.
|
||||
*
|
||||
* The default value is true (1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_READ_LIGHTS \
|
||||
"IMPORT_FBX_READ_LIGHTS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will read animations.
|
||||
*
|
||||
* The default value is true (1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_READ_ANIMATIONS \
|
||||
"IMPORT_FBX_READ_ANIMATIONS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will act in strict mode in which only
|
||||
* FBX 2013 is supported and any other sub formats are rejected. FBX 2013
|
||||
* is the primary target for the importer, so this format is best
|
||||
* supported and well-tested.
|
||||
*
|
||||
* The default value is false (0)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_STRICT_MODE \
|
||||
"IMPORT_FBX_STRICT_MODE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will preserve pivot points for
|
||||
* transformations (as extra nodes). If set to false, pivots and offsets
|
||||
* will be evaluated whenever possible.
|
||||
*
|
||||
* The default value is true (1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS \
|
||||
"IMPORT_FBX_PRESERVE_PIVOTS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the importer will drop empty animation curves or
|
||||
* animation curves which match the bind pose transformation over their
|
||||
* entire defined range.
|
||||
*
|
||||
* The default value is true (1)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES \
|
||||
"IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set whether the fbx importer will use the legacy embedded texture naming.
|
||||
*
|
||||
* The default value is false (0)
|
||||
* Property type: bool
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING \
|
||||
"AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the vertex animation keyframe to be imported
|
||||
*
|
||||
* ASSIMP does not support vertex keyframes (only bone animation is supported).
|
||||
* The library reads only one frame of models with vertex animations.
|
||||
* By default this is the first frame.
|
||||
* \note The default value is 0. This option applies to all importers.
|
||||
* However, it is also possible to override the global setting
|
||||
* for a specific loader. You can use the AI_CONFIG_IMPORT_XXX_KEYFRAME
|
||||
* options (where XXX is a placeholder for the file format for which you
|
||||
* want to override the global setting).
|
||||
* Property type: integer.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_GLOBAL_KEYFRAME "IMPORT_GLOBAL_KEYFRAME"
|
||||
|
||||
#define AI_CONFIG_IMPORT_MD3_KEYFRAME "IMPORT_MD3_KEYFRAME"
|
||||
#define AI_CONFIG_IMPORT_MD2_KEYFRAME "IMPORT_MD2_KEYFRAME"
|
||||
#define AI_CONFIG_IMPORT_MDL_KEYFRAME "IMPORT_MDL_KEYFRAME"
|
||||
#define AI_CONFIG_IMPORT_MDC_KEYFRAME "IMPORT_MDC_KEYFRAME"
|
||||
#define AI_CONFIG_IMPORT_SMD_KEYFRAME "IMPORT_SMD_KEYFRAME"
|
||||
#define AI_CONFIG_IMPORT_UNREAL_KEYFRAME "IMPORT_UNREAL_KEYFRAME"
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the AC loader to collect all surfaces which have the
|
||||
* "Backface cull" flag set in separate meshes.
|
||||
*
|
||||
* Property type: bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_AC_SEPARATE_BFCULL \
|
||||
"IMPORT_AC_SEPARATE_BFCULL"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures whether the AC loader evaluates subdivision surfaces (
|
||||
* indicated by the presence of the 'subdiv' attribute in the file). By
|
||||
* default, Assimp performs the subdivision using the standard
|
||||
* Catmull-Clark algorithm
|
||||
*
|
||||
* * Property type: bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_AC_EVAL_SUBDIVISION \
|
||||
"IMPORT_AC_EVAL_SUBDIVISION"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the UNREAL 3D loader to separate faces with different
|
||||
* surface flags (e.g. two-sided vs. single-sided).
|
||||
*
|
||||
* * Property type: bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS \
|
||||
"UNREAL_HANDLE_FLAGS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the terragen import plugin to compute uv's for
|
||||
* terrains, if not given. Furthermore a default texture is assigned.
|
||||
*
|
||||
* UV coordinates for terrains are so simple to compute that you'll usually
|
||||
* want to compute them on your own, if you need them. This option is intended
|
||||
* for model viewers which want to offer an easy way to apply textures to
|
||||
* terrains.
|
||||
* * Property type: bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_TER_MAKE_UVS \
|
||||
"IMPORT_TER_MAKE_UVS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the ASE loader to always reconstruct normal vectors
|
||||
* basing on the smoothing groups loaded from the file.
|
||||
*
|
||||
* Some ASE files have carry invalid normals, other don't.
|
||||
* * Property type: bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS \
|
||||
"IMPORT_ASE_RECONSTRUCT_NORMALS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the M3D loader to detect and process multi-part
|
||||
* Quake player models.
|
||||
*
|
||||
* These models usually consist of 3 files, lower.md3, upper.md3 and
|
||||
* head.md3. If this property is set to true, Assimp will try to load and
|
||||
* combine all three files if one of them is loaded.
|
||||
* Property type: bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART \
|
||||
"IMPORT_MD3_HANDLE_MULTIPART"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Tells the MD3 loader which skin files to load.
|
||||
*
|
||||
* When loading MD3 files, Assimp checks whether a file
|
||||
* [md3_file_name]_[skin_name].skin is existing. These files are used by
|
||||
* Quake III to be able to assign different skins (e.g. red and blue team)
|
||||
* to models. 'default', 'red', 'blue' are typical skin names.
|
||||
* Property type: String. Default value: "default".
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_MD3_SKIN_NAME \
|
||||
"IMPORT_MD3_SKIN_NAME"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specify the Quake 3 shader file to be used for a particular
|
||||
* MD3 file. This can also be a search path.
|
||||
*
|
||||
* By default Assimp's behaviour is as follows: If a MD3 file
|
||||
* <tt>any_path/models/any_q3_subdir/model_name/file_name.md3</tt> is
|
||||
* loaded, the library tries to locate the corresponding shader file in
|
||||
* <tt>any_path/scripts/model_name.shader</tt>. This property overrides this
|
||||
* behaviour. It can either specify a full path to the shader to be loaded
|
||||
* or alternatively the path (relative or absolute) to the directory where
|
||||
* the shaders for all MD3s to be loaded reside. Assimp attempts to open
|
||||
* <tt>IMPORT_MD3_SHADER_SRC/model_name.shader</tt> first, <tt>IMPORT_MD3_SHADER_SRC/file_name.shader</tt>
|
||||
* is the fallback file. Note that IMPORT_MD3_SHADER_SRC should have a terminal (back)slash.
|
||||
* Property type: String. Default value: n/a.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_MD3_SHADER_SRC \
|
||||
"IMPORT_MD3_SHADER_SRC"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the LWO loader to load just one layer from the model.
|
||||
*
|
||||
* LWO files consist of layers and in some cases it could be useful to load
|
||||
* only one of them. This property can be either a string - which specifies
|
||||
* the name of the layer - or an integer - the index of the layer. If the
|
||||
* property is not set the whole LWO model is loaded. Loading fails if the
|
||||
* requested layer is not available. The layer index is zero-based and the
|
||||
* layer name may not be empty.<br>
|
||||
* Property type: Integer. Default value: all layers are loaded.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_LWO_ONE_LAYER_ONLY \
|
||||
"IMPORT_LWO_ONE_LAYER_ONLY"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Configures the MD5 loader to not load the MD5ANIM file for
|
||||
* a MD5MESH file automatically.
|
||||
*
|
||||
* The default strategy is to look for a file with the same name but the
|
||||
* MD5ANIM extension in the same directory. If it is found, it is loaded
|
||||
* and combined with the MD5MESH file. This configuration option can be
|
||||
* used to disable this behaviour.
|
||||
*
|
||||
* * Property type: bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD \
|
||||
"IMPORT_MD5_NO_ANIM_AUTOLOAD"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Defines the begin of the time range for which the LWS loader
|
||||
* evaluates animations and computes aiNodeAnim's.
|
||||
*
|
||||
* Assimp provides full conversion of LightWave's envelope system, including
|
||||
* pre and post conditions. The loader computes linearly subsampled animation
|
||||
* chanels with the frame rate given in the LWS file. This property defines
|
||||
* the start time. Note: animation channels are only generated if a node
|
||||
* has at least one envelope with more tan one key assigned. This property.
|
||||
* is given in frames, '0' is the first frame. By default, if this property
|
||||
* is not set, the importer takes the animation start from the input LWS
|
||||
* file ('FirstFrame' line)<br>
|
||||
* Property type: Integer. Default value: taken from file.
|
||||
*
|
||||
* @see AI_CONFIG_IMPORT_LWS_ANIM_END - end of the imported time range
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_LWS_ANIM_START \
|
||||
"IMPORT_LWS_ANIM_START"
|
||||
#define AI_CONFIG_IMPORT_LWS_ANIM_END \
|
||||
"IMPORT_LWS_ANIM_END"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Defines the output frame rate of the IRR loader.
|
||||
*
|
||||
* IRR animations are difficult to convert for Assimp and there will
|
||||
* always be a loss of quality. This setting defines how many keys per second
|
||||
* are returned by the converter.<br>
|
||||
* Property type: integer. Default value: 100
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IRR_ANIM_FPS \
|
||||
"IMPORT_IRR_ANIM_FPS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Ogre Importer will try to find referenced materials from this file.
|
||||
*
|
||||
* Ogre meshes reference with material names, this does not tell Assimp the file
|
||||
* where it is located in. Assimp will try to find the source file in the following
|
||||
* order: <material-name>.material, <mesh-filename-base>.material and
|
||||
* lastly the material name defined by this config property.
|
||||
* <br>
|
||||
* Property type: String. Default value: Scene.material.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_OGRE_MATERIAL_FILE \
|
||||
"IMPORT_OGRE_MATERIAL_FILE"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Ogre Importer detect the texture usage from its filename.
|
||||
*
|
||||
* Ogre material texture units do not define texture type, the textures usage
|
||||
* depends on the used shader or Ogre's fixed pipeline. If this config property
|
||||
* is true Assimp will try to detect the type from the textures filename postfix:
|
||||
* _n, _nrm, _nrml, _normal, _normals and _normalmap for normal map, _s, _spec,
|
||||
* _specular and _specularmap for specular map, _l, _light, _lightmap, _occ
|
||||
* and _occlusion for light map, _disp and _displacement for displacement map.
|
||||
* The matching is case insensitive. Post fix is taken between the last
|
||||
* underscore and the last period.
|
||||
* Default behavior is to detect type from lower cased texture unit name by
|
||||
* matching against: normalmap, specularmap, lightmap and displacementmap.
|
||||
* For both cases if no match is found aiTextureType_DIFFUSE is used.
|
||||
* <br>
|
||||
* Property type: Bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME \
|
||||
"IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME"
|
||||
|
||||
/** @brief Specifies whether the Android JNI asset extraction is supported.
|
||||
*
|
||||
* Turn on this option if you want to manage assets in native
|
||||
* Android application without having to keep the internal directory and asset
|
||||
* manager pointer.
|
||||
*/
|
||||
#define AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT "AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the IFC loader skips over IfcSpace elements.
|
||||
*
|
||||
* IfcSpace elements (and their geometric representations) are used to
|
||||
* represent, well, free space in a building storey.<br>
|
||||
* Property type: Bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS "IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the IFC loader will use its own, custom triangulation
|
||||
* algorithm to triangulate wall and floor meshes.
|
||||
*
|
||||
* If this property is set to false, walls will be either triangulated by
|
||||
* #aiProcess_Triangulate or will be passed through as huge polygons with
|
||||
* faked holes (i.e. holes that are connected with the outer boundary using
|
||||
* a dummy edge). It is highly recommended to set this property to true
|
||||
* if you want triangulated data because #aiProcess_Triangulate is known to
|
||||
* have problems with the kind of polygons that the IFC loader spits out for
|
||||
* complicated meshes.
|
||||
* Property type: Bool. Default value: true.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the tessellation conic angle for IFC smoothing curves.
|
||||
*
|
||||
* This is used by the IFC importer to determine the tessellation parameter
|
||||
* for smoothing curves.
|
||||
* @note The default value is AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE and the
|
||||
* accepted values are in range [5.0, 120.0].
|
||||
* Property type: Float.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE "IMPORT_IFC_SMOOTHING_ANGLE"
|
||||
|
||||
// default value for AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE
|
||||
#if (!defined AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE)
|
||||
# define AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE 10.0f
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Set the tessellation for IFC cylindrical shapes.
|
||||
*
|
||||
* This is used by the IFC importer to determine the tessellation parameter
|
||||
* for cylindrical shapes, i.e. the number of segments used to approximate a circle.
|
||||
* @note The default value is AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION and the
|
||||
* accepted values are in range [3, 180].
|
||||
* Property type: Integer.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION "IMPORT_IFC_CYLINDRICAL_TESSELLATION"
|
||||
|
||||
// default value for AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION
|
||||
#if (!defined AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION)
|
||||
# define AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION 32
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the Collada loader will ignore the provided up direction.
|
||||
*
|
||||
* If this property is set to true, the up direction provided in the file header will
|
||||
* be ignored and the file will be loaded as is.
|
||||
* Property type: Bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Specifies whether the Collada loader should use Collada names as node names.
|
||||
*
|
||||
* If this property is set to true, the Collada names will be used as the
|
||||
* node name. The default is to use the id tag (resp. sid tag, if no id tag is present)
|
||||
* instead.
|
||||
* Property type: Bool. Default value: false.
|
||||
*/
|
||||
#define AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES "IMPORT_COLLADA_USE_COLLADA_NAMES"
|
||||
|
||||
// ---------- All the Export defines ------------
|
||||
|
||||
/** @brief Specifies the xfile use double for real values of float
|
||||
*
|
||||
* Property type: Bool. Default value: false.
|
||||
*/
|
||||
|
||||
#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
#define AI_CONFIG_EXPORT_POINT_CLOUDS "EXPORT_POINT_CLOUDS"
|
||||
|
||||
/**
|
||||
* @brief Specifies a gobal key factor for scale, float value
|
||||
*/
|
||||
#define AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY "GLOBAL_SCALE_FACTOR"
|
||||
|
||||
#if (!defined AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT)
|
||||
# define AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT 1.0f
|
||||
#endif // !! AI_DEBONE_THRESHOLD
|
||||
|
||||
// ---------- All the Build/Compile-time defines ------------
|
||||
|
||||
/** @brief Specifies if double precision is supported inside assimp
|
||||
*
|
||||
* Property type: Bool. Default value: undefined.
|
||||
*/
|
||||
|
||||
#cmakedefine ASSIMP_DOUBLE_PRECISION 1
|
||||
|
||||
#endif // !! AI_CONFIG_H_INC
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -52,26 +51,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <assimp/config.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/* Define ASSIMP_BUILD_NO_XX_IMPORTER to disable a specific
|
||||
* file format loader. The loader is be excluded from the
|
||||
* build in this case. 'XX' stands for the most common file
|
||||
* extension of the file format. E.g.:
|
||||
* ASSIMP_BUILD_NO_X_IMPORTER disables the X loader.
|
||||
*
|
||||
* If you're unsure about that, take a look at the implementation of the
|
||||
* import plugin you wish to disable. You'll find the right define in the
|
||||
* first lines of the corresponding unit.
|
||||
*
|
||||
* Other (mixed) configuration switches are listed here:
|
||||
* ASSIMP_BUILD_NO_COMPRESSED_X
|
||||
* - Disable support for compressed X files (zip)
|
||||
* ASSIMP_BUILD_NO_COMPRESSED_BLEND
|
||||
* - Disable support for compressed Blender files (zip)
|
||||
* ASSIMP_BUILD_NO_COMPRESSED_IFC
|
||||
* - Disable support for IFCZIP files (unzip)
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/* Define ASSIMP_BUILD_NO_XX_IMPORTER to disable a specific
|
||||
* file format loader. The loader is be excluded from the
|
||||
* build in this case. 'XX' stands for the most common file
|
||||
* extension of the file format. E.g.:
|
||||
* ASSIMP_BUILD_NO_X_IMPORTER disables the X loader.
|
||||
*
|
||||
* If you're unsure about that, take a look at the implementation of the
|
||||
* import plugin you wish to disable. You'll find the right define in the
|
||||
* first lines of the corresponding unit.
|
||||
*
|
||||
* Other (mixed) configuration switches are listed here:
|
||||
* ASSIMP_BUILD_NO_COMPRESSED_X
|
||||
* - Disable support for compressed X files (zip)
|
||||
* ASSIMP_BUILD_NO_COMPRESSED_BLEND
|
||||
* - Disable support for compressed Blender files (zip)
|
||||
* ASSIMP_BUILD_NO_COMPRESSED_IFC
|
||||
* - Disable support for IFCZIP files (unzip)
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_COMPRESSED_X
|
||||
# define ASSIMP_BUILD_NEED_Z_INFLATE
|
||||
|
|
@ -91,39 +90,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define ASSIMP_BUILD_NEED_UNZIP
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/* Define ASSIMP_BUILD_NO_XX_PROCESS to disable a specific
|
||||
* post processing step. This is the current list of process names ('XX'):
|
||||
* CALCTANGENTS
|
||||
* JOINVERTICES
|
||||
* TRIANGULATE
|
||||
* DROPFACENORMALS
|
||||
* GENFACENORMALS
|
||||
* GENVERTEXNORMALS
|
||||
* REMOVEVC
|
||||
* SPLITLARGEMESHES
|
||||
* PRETRANSFORMVERTICES
|
||||
* LIMITBONEWEIGHTS
|
||||
* VALIDATEDS
|
||||
* IMPROVECACHELOCALITY
|
||||
* FIXINFACINGNORMALS
|
||||
* REMOVE_REDUNDANTMATERIALS
|
||||
* OPTIMIZEGRAPH
|
||||
* SORTBYPTYPE
|
||||
* FINDINVALIDDATA
|
||||
* TRANSFORMTEXCOORDS
|
||||
* GENUVCOORDS
|
||||
* ENTITYMESHBUILDER
|
||||
* EMBEDTEXTURES
|
||||
* MAKELEFTHANDED
|
||||
* FLIPUVS
|
||||
* FLIPWINDINGORDER
|
||||
* OPTIMIZEMESHES
|
||||
* OPTIMIZEANIMS
|
||||
* OPTIMIZEGRAPH
|
||||
* GENENTITYMESHES
|
||||
* FIXTEXTUREPATHS */
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/* Define ASSIMP_BUILD_NO_XX_PROCESS to disable a specific
|
||||
* post processing step. This is the current list of process names ('XX'):
|
||||
* CALCTANGENTS
|
||||
* JOINVERTICES
|
||||
* TRIANGULATE
|
||||
* GENFACENORMALS
|
||||
* GENVERTEXNORMALS
|
||||
* REMOVEVC
|
||||
* SPLITLARGEMESHES
|
||||
* PRETRANSFORMVERTICES
|
||||
* LIMITBONEWEIGHTS
|
||||
* VALIDATEDS
|
||||
* IMPROVECACHELOCALITY
|
||||
* FIXINFACINGNORMALS
|
||||
* REMOVE_REDUNDANTMATERIALS
|
||||
* OPTIMIZEGRAPH
|
||||
* SORTBYPTYPE
|
||||
* FINDINVALIDDATA
|
||||
* TRANSFORMTEXCOORDS
|
||||
* GENUVCOORDS
|
||||
* ENTITYMESHBUILDER
|
||||
* MAKELEFTHANDED
|
||||
* FLIPUVS
|
||||
* FLIPWINDINGORDER
|
||||
* OPTIMIZEMESHES
|
||||
* OPTIMIZEANIMS
|
||||
* OPTIMIZEGRAPH
|
||||
* GENENTITYMESHES
|
||||
* FIXTEXTUREPATHS */
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# undef ASSIMP_API
|
||||
|
|
@ -290,14 +287,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# define AI_NO_EXCEPT noexcept
|
||||
#else
|
||||
# if (_MSC_VER == 1915 )
|
||||
# define AI_NO_EXCEPT noexcept
|
||||
# else
|
||||
# define AI_NO_EXCEPT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif // !! AI_DEFINES_H_INC
|
||||
|
|
|
|||
|
|
@ -1,373 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
// Copyright (C) 2002-2007 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 irrXML.h
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Original description: (Schrompf)
|
||||
// Adapted to the ASSIMP library because the builtin atof indeed takes AGES to parse a
|
||||
// float inside a large string. Before parsing, it does a strlen on the given point.
|
||||
// Changes:
|
||||
// 22nd October 08 (Aramis_acg): Added temporary cast to double, added strtoul10_64
|
||||
// to ensure long numbers are handled correctly
|
||||
// ------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef FAST_A_TO_F_H_INCLUDED
|
||||
#define FAST_A_TO_F_H_INCLUDED
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <stdint.h>
|
||||
#include <stdexcept>
|
||||
#include <assimp/defs.h>
|
||||
|
||||
#include "StringComparison.h"
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <stdint.h>
|
||||
#else
|
||||
# include <assimp/Compiler/pstdint.h>
|
||||
#endif
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
const double fast_atof_table[16] = { // we write [16] here instead of [] to work around a swig bug
|
||||
0.0,
|
||||
0.1,
|
||||
0.01,
|
||||
0.001,
|
||||
0.0001,
|
||||
0.00001,
|
||||
0.000001,
|
||||
0.0000001,
|
||||
0.00000001,
|
||||
0.000000001,
|
||||
0.0000000001,
|
||||
0.00000000001,
|
||||
0.000000000001,
|
||||
0.0000000000001,
|
||||
0.00000000000001,
|
||||
0.000000000000001
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Convert a string in decimal format to a number
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
unsigned int strtoul10( const char* in, const char** out=0) {
|
||||
unsigned int value = 0;
|
||||
|
||||
for ( ;; ) {
|
||||
if ( *in < '0' || *in > '9' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
value = ( value * 10 ) + ( *in - '0' );
|
||||
++in;
|
||||
}
|
||||
if ( out ) {
|
||||
*out = in;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Convert a string in octal format to a number
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
unsigned int strtoul8( const char* in, const char** out=0) {
|
||||
unsigned int value( 0 );
|
||||
for ( ;; ) {
|
||||
if ( *in < '0' || *in > '7' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
value = ( value << 3 ) + ( *in - '0' );
|
||||
++in;
|
||||
}
|
||||
if ( out ) {
|
||||
*out = in;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Convert a string in hex format to a number
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
unsigned int strtoul16( const char* in, const char** out=0) {
|
||||
unsigned int value( 0 );
|
||||
for ( ;; ) {
|
||||
if ( *in >= '0' && *in <= '9' ) {
|
||||
value = ( value << 4u ) + ( *in - '0' );
|
||||
} else if (*in >= 'A' && *in <= 'F') {
|
||||
value = ( value << 4u ) + ( *in - 'A' ) + 10;
|
||||
} else if (*in >= 'a' && *in <= 'f') {
|
||||
value = ( value << 4u ) + ( *in - 'a' ) + 10;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
++in;
|
||||
}
|
||||
if ( out ) {
|
||||
*out = in;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Convert just one hex digit
|
||||
// Return value is UINT_MAX if the input character is not a hex digit.
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
unsigned int HexDigitToDecimal(char in) {
|
||||
unsigned int out( UINT_MAX );
|
||||
if ( in >= '0' && in <= '9' ) {
|
||||
out = in - '0';
|
||||
} else if ( in >= 'a' && in <= 'f' ) {
|
||||
out = 10u + in - 'a';
|
||||
} else if ( in >= 'A' && in <= 'F' ) {
|
||||
out = 10u + in - 'A';
|
||||
}
|
||||
|
||||
// return value is UINT_MAX if the input is not a hex digit
|
||||
return out;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Convert a hex-encoded octet (2 characters, i.e. df or 1a).
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
uint8_t HexOctetToDecimal(const char* in) {
|
||||
return ((uint8_t)HexDigitToDecimal(in[0])<<4)+(uint8_t)HexDigitToDecimal(in[1]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// signed variant of strtoul10
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
int strtol10( const char* in, const char** out=0) {
|
||||
bool inv = (*in=='-');
|
||||
if ( inv || *in == '+' ) {
|
||||
++in;
|
||||
}
|
||||
|
||||
int value = strtoul10(in,out);
|
||||
if (inv) {
|
||||
value = -value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Parse a C++-like integer literal - hex and oct prefixes.
|
||||
// 0xNNNN - hex
|
||||
// 0NNN - oct
|
||||
// NNN - dec
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
unsigned int strtoul_cppstyle( const char* in, const char** out=0) {
|
||||
if ('0' == in[0]) {
|
||||
return 'x' == in[1] ? strtoul16(in+2,out) : strtoul8(in+1,out);
|
||||
}
|
||||
return strtoul10(in, out);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Special version of the function, providing higher accuracy and safety
|
||||
// It is mainly used by fast_atof to prevent ugly and unwanted integer overflows.
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_inout=0) {
|
||||
unsigned int cur = 0;
|
||||
uint64_t value = 0;
|
||||
|
||||
if ( *in < '0' || *in > '9' ) {
|
||||
throw std::invalid_argument( std::string( "The string \"" ) + in + "\" cannot be converted into a value." );
|
||||
}
|
||||
|
||||
for ( ;; ) {
|
||||
if ( *in < '0' || *in > '9' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
const uint64_t new_value = ( value * (uint64_t) 10 ) + ( (uint64_t) ( *in - '0' ) );
|
||||
|
||||
// numeric overflow, we rely on you
|
||||
if ( new_value < value ) {
|
||||
ASSIMP_LOG_WARN_F( "Converting the string \"", in, "\" into a value resulted in overflow." );
|
||||
return 0;
|
||||
}
|
||||
|
||||
value = new_value;
|
||||
|
||||
++in;
|
||||
++cur;
|
||||
|
||||
if (max_inout && *max_inout == cur) {
|
||||
if (out) { /* skip to end */
|
||||
while ( *in >= '0' && *in <= '9' ) {
|
||||
++in;
|
||||
}
|
||||
*out = in;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
if ( out ) {
|
||||
*out = in;
|
||||
}
|
||||
|
||||
if ( max_inout ) {
|
||||
*max_inout = cur;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// signed variant of strtoul10_64
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline
|
||||
int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* max_inout = 0) {
|
||||
bool inv = (*in == '-');
|
||||
if ( inv || *in == '+' ) {
|
||||
++in;
|
||||
}
|
||||
|
||||
int64_t value = strtoul10_64(in, out, max_inout);
|
||||
if (inv) {
|
||||
value = -value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// Number of relevant decimals for floating-point parsing.
|
||||
#define AI_FAST_ATOF_RELAVANT_DECIMALS 15
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
//! Provides a fast function for converting a string into a float,
|
||||
//! about 6 times faster than atof in win32.
|
||||
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||
// ------------------------------------------------------------------------------------
|
||||
template<typename Real>
|
||||
inline
|
||||
const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true) {
|
||||
Real f = 0;
|
||||
|
||||
bool inv = (*c == '-');
|
||||
if (inv || *c == '+') {
|
||||
++c;
|
||||
}
|
||||
|
||||
if ((c[0] == 'N' || c[0] == 'n') && ASSIMP_strincmp(c, "nan", 3) == 0) {
|
||||
out = std::numeric_limits<Real>::quiet_NaN();
|
||||
c += 3;
|
||||
return c;
|
||||
}
|
||||
|
||||
if ((c[0] == 'I' || c[0] == 'i') && ASSIMP_strincmp(c, "inf", 3) == 0) {
|
||||
out = std::numeric_limits<Real>::infinity();
|
||||
if (inv) {
|
||||
out = -out;
|
||||
}
|
||||
c += 3;
|
||||
if ((c[0] == 'I' || c[0] == 'i') && ASSIMP_strincmp(c, "inity", 5) == 0) {
|
||||
c += 5;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
if (!(c[0] >= '0' && c[0] <= '9') &&
|
||||
!((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')) {
|
||||
throw std::invalid_argument("Cannot parse string "
|
||||
"as real number: does not start with digit "
|
||||
"or decimal point followed by digit.");
|
||||
}
|
||||
|
||||
if (*c != '.' && (! check_comma || c[0] != ',')) {
|
||||
f = static_cast<Real>( strtoul10_64 ( c, &c) );
|
||||
}
|
||||
|
||||
if ((*c == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9') {
|
||||
++c;
|
||||
|
||||
// NOTE: The original implementation is highly inaccurate here. The precision of a single
|
||||
// IEEE 754 float is not high enough, everything behind the 6th digit tends to be more
|
||||
// inaccurate than it would need to be. Casting to double seems to solve the problem.
|
||||
// strtol_64 is used to prevent integer overflow.
|
||||
|
||||
// Another fix: this tends to become 0 for long numbers if we don't limit the maximum
|
||||
// number of digits to be read. AI_FAST_ATOF_RELAVANT_DECIMALS can be a value between
|
||||
// 1 and 15.
|
||||
unsigned int diff = AI_FAST_ATOF_RELAVANT_DECIMALS;
|
||||
double pl = static_cast<double>( strtoul10_64 ( c, &c, &diff ));
|
||||
|
||||
pl *= fast_atof_table[diff];
|
||||
f += static_cast<Real>( pl );
|
||||
}
|
||||
// For backwards compatibility: eat trailing dots, but not trailing commas.
|
||||
else if (*c == '.') {
|
||||
++c;
|
||||
}
|
||||
|
||||
// A major 'E' must be allowed. Necessary for proper reading of some DXF files.
|
||||
// Thanks to Zhao Lei to point out that this if() must be outside the if (*c == '.' ..)
|
||||
if (*c == 'e' || *c == 'E') {
|
||||
++c;
|
||||
const bool einv = (*c=='-');
|
||||
if (einv || *c=='+') {
|
||||
++c;
|
||||
}
|
||||
|
||||
// The reason float constants are used here is that we've seen cases where compilers
|
||||
// would perform such casts on compile-time constants at runtime, which would be
|
||||
// bad considering how frequently fast_atoreal_move<float> is called in Assimp.
|
||||
Real exp = static_cast<Real>( strtoul10_64(c, &c) );
|
||||
if (einv) {
|
||||
exp = -exp;
|
||||
}
|
||||
f *= std::pow(static_cast<Real>(10.0), exp);
|
||||
}
|
||||
|
||||
if (inv) {
|
||||
f = -f;
|
||||
}
|
||||
out = f;
|
||||
return c;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// The same but more human.
|
||||
inline
|
||||
ai_real fast_atof(const char* c) {
|
||||
ai_real ret(0.0);
|
||||
fast_atoreal_move<ai_real>(c, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline
|
||||
ai_real fast_atof( const char* c, const char** cout) {
|
||||
ai_real ret(0.0);
|
||||
*cout = fast_atoreal_move<ai_real>(c, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline
|
||||
ai_real fast_atof( const char** inout) {
|
||||
ai_real ret(0.0);
|
||||
*inout = fast_atoreal_move<ai_real>(*inout, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} //! namespace Assimp
|
||||
|
||||
#endif // FAST_A_TO_F_H_INCLUDED
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -1,144 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_AI_IRRXML_WRAPPER
|
||||
#define INCLUDED_AI_IRRXML_WRAPPER
|
||||
|
||||
// some long includes ....
|
||||
#include <irrXML.h>
|
||||
#include "IOStream.hpp"
|
||||
#include "BaseImporter.h"
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
/** @brief Utility class to make IrrXML work together with our custom IO system
|
||||
* See the IrrXML docs for more details.
|
||||
*
|
||||
* Construct IrrXML-Reader in BaseImporter::InternReadFile():
|
||||
* @code
|
||||
* // open the file
|
||||
* std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||
* if( file.get() == NULL) {
|
||||
* throw DeadlyImportError( "Failed to open file " + pFile + ".");
|
||||
* }
|
||||
*
|
||||
* // generate a XML reader for it
|
||||
* std::unique_ptr<CIrrXML_IOStreamReader> mIOWrapper( new CIrrXML_IOStreamReader( file.get()));
|
||||
* mReader = irr::io::createIrrXMLReader( mIOWrapper.get());
|
||||
* if( !mReader) {
|
||||
* ThrowException( "xxxx: Unable to open file.");
|
||||
* }
|
||||
* @endcode
|
||||
**/
|
||||
class CIrrXML_IOStreamReader : public irr::io::IFileReadCallBack {
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
//! Construction from an existing IOStream
|
||||
explicit CIrrXML_IOStreamReader(IOStream* _stream)
|
||||
: stream (_stream)
|
||||
, t (0)
|
||||
{
|
||||
|
||||
// Map the buffer into memory and convert it to UTF8. IrrXML provides its
|
||||
// own conversion, which is merely a cast from uintNN_t to uint8_t. Thus,
|
||||
// it is not suitable for our purposes and we have to do it BEFORE IrrXML
|
||||
// gets the buffer. Sadly, this forces us to map the whole file into
|
||||
// memory.
|
||||
|
||||
data.resize(stream->FileSize());
|
||||
stream->Read(&data[0],data.size(),1);
|
||||
|
||||
// Remove null characters from the input sequence otherwise the parsing will utterly fail
|
||||
unsigned int size = 0;
|
||||
unsigned int size_max = static_cast<unsigned int>(data.size());
|
||||
for(unsigned int i = 0; i < size_max; i++) {
|
||||
if(data[i] != '\0') {
|
||||
data[size++] = data[i];
|
||||
}
|
||||
}
|
||||
data.resize(size);
|
||||
|
||||
BaseImporter::ConvertToUTF8(data);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
//! Virtual destructor
|
||||
virtual ~CIrrXML_IOStreamReader() {}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
//! Reads an amount of bytes from the file.
|
||||
/** @param buffer: Pointer to output buffer.
|
||||
* @param sizeToRead: Amount of bytes to read
|
||||
* @return Returns how much bytes were read. */
|
||||
virtual int read(void* buffer, int sizeToRead) {
|
||||
if(sizeToRead<0) {
|
||||
return 0;
|
||||
}
|
||||
if(t+sizeToRead>data.size()) {
|
||||
sizeToRead = static_cast<int>(data.size()-t);
|
||||
}
|
||||
|
||||
memcpy(buffer,&data.front()+t,sizeToRead);
|
||||
|
||||
t += sizeToRead;
|
||||
return sizeToRead;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
//! Returns size of file in bytes
|
||||
virtual int getSize() {
|
||||
return (int)data.size();
|
||||
}
|
||||
|
||||
private:
|
||||
IOStream* stream;
|
||||
std::vector<char> data;
|
||||
size_t t;
|
||||
|
||||
}; // ! class CIrrXML_IOStreamReader
|
||||
|
||||
} // ! Assimp
|
||||
|
||||
#endif // !! INCLUDED_AI_IRRXML_WRAPPER
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -237,7 +236,7 @@ struct aiLight
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiLight() AI_NO_EXCEPT
|
||||
aiLight()
|
||||
: mType (aiLightSource_UNDEFINED)
|
||||
, mAttenuationConstant (0.f)
|
||||
, mAttenuationLinear (1.f)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -483,7 +482,7 @@ struct aiUVTransform
|
|||
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiUVTransform() AI_NO_EXCEPT
|
||||
aiUVTransform()
|
||||
: mTranslation (0.0,0.0)
|
||||
, mScaling (1.0,1.0)
|
||||
, mRotation (0.0)
|
||||
|
|
@ -492,7 +491,7 @@ struct aiUVTransform
|
|||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
} PACK_STRUCT;
|
||||
|
||||
#include "./Compiler/poppack1.h"
|
||||
|
||||
|
|
@ -607,18 +606,17 @@ struct aiMaterialProperty
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiMaterialProperty() AI_NO_EXCEPT
|
||||
: mSemantic( 0 )
|
||||
, mIndex( 0 )
|
||||
, mDataLength( 0 )
|
||||
, mType( aiPTI_Float )
|
||||
, mData(nullptr) {
|
||||
// empty
|
||||
aiMaterialProperty()
|
||||
: mSemantic( 0 )
|
||||
, mIndex( 0 )
|
||||
, mDataLength( 0 )
|
||||
, mType( aiPTI_Float )
|
||||
, mData( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
~aiMaterialProperty() {
|
||||
delete[] mData;
|
||||
mData = nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -652,14 +650,6 @@ public:
|
|||
aiMaterial();
|
||||
~aiMaterial();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns the name of the material.
|
||||
* @return The name of the material.
|
||||
*/
|
||||
// -------------------------------------------------------------------
|
||||
aiString GetName();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** @brief Retrieve an array of Type values with a specific key
|
||||
* from the material
|
||||
|
|
@ -1565,12 +1555,10 @@ C_ENUM aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
|
|||
unsigned int* flags /*= NULL*/);
|
||||
#endif // !#ifdef __cplusplus
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#include "material.inl"
|
||||
|
||||
#endif //!__cplusplus
|
||||
|
||||
#endif //!!AI_MATERIAL_H_INC
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -120,7 +119,7 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
const aiMaterialProperty* prop;
|
||||
const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx,
|
||||
(const aiMaterialProperty**)&prop);
|
||||
if ( AI_SUCCESS == ret ) {
|
||||
if ( AI_SUCCESS == ret ) {
|
||||
|
||||
if (prop->mDataLength < sizeof(Type)) {
|
||||
return AI_FAILURE;
|
||||
|
|
@ -130,7 +129,7 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
|
|||
return AI_FAILURE;
|
||||
}
|
||||
|
||||
::memcpy( &pOut, prop->mData, sizeof( Type ) );
|
||||
::memcpy(&pOut,prop->mData,sizeof(Type));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -69,7 +68,7 @@ class aiMatrix3x3t
|
|||
{
|
||||
public:
|
||||
|
||||
aiMatrix3x3t() AI_NO_EXCEPT :
|
||||
aiMatrix3x3t () :
|
||||
a1(static_cast<TReal>(1.0f)), a2(), a3(),
|
||||
b1(), b2(static_cast<TReal>(1.0f)), b3(),
|
||||
c1(), c2(), c3(static_cast<TReal>(1.0f)) {}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -313,16 +312,16 @@ inline aiMatrix3x3t<TReal>& aiMatrix3x3t<TReal>::FromToMatrix(const aiVector3t<T
|
|||
u.x = x.x - from.x; u.y = x.y - from.y; u.z = x.z - from.z;
|
||||
v.x = x.x - to.x; v.y = x.y - to.y; v.z = x.z - to.z;
|
||||
|
||||
const TReal c1_ = static_cast<TReal>(2.0) / (u * u);
|
||||
const TReal c2_ = static_cast<TReal>(2.0) / (v * v);
|
||||
const TReal c3_ = c1_ * c2_ * (u * v);
|
||||
const TReal c1 = static_cast<TReal>(2.0) / (u * u);
|
||||
const TReal c2 = static_cast<TReal>(2.0) / (v * v);
|
||||
const TReal c3 = c1 * c2 * (u * v);
|
||||
|
||||
for (unsigned int i = 0; i < 3; i++)
|
||||
{
|
||||
for (unsigned int j = 0; j < 3; j++)
|
||||
{
|
||||
mtx[i][j] = - c1_ * u[i] * u[j] - c2_ * v[i] * v[j]
|
||||
+ c3_ * v[i] * u[j];
|
||||
mtx[i][j] = - c1 * u[i] * u[j] - c2 * v[i] * v[j]
|
||||
+ c3 * v[i] * u[j];
|
||||
}
|
||||
mtx[i][i] += static_cast<TReal>(1.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -71,7 +70,7 @@ class aiMatrix4x4t
|
|||
public:
|
||||
|
||||
/** set to identity */
|
||||
aiMatrix4x4t() AI_NO_EXCEPT;
|
||||
aiMatrix4x4t ();
|
||||
|
||||
/** construction from single values */
|
||||
aiMatrix4x4t ( TReal _a1, TReal _a2, TReal _a3, TReal _a4,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -60,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
aiMatrix4x4t<TReal>::aiMatrix4x4t() AI_NO_EXCEPT :
|
||||
aiMatrix4x4t<TReal> ::aiMatrix4x4t () :
|
||||
a1(1.0f), a2(), a3(), a4(),
|
||||
b1(), b2(1.0f), b3(), b4(),
|
||||
c1(), c2(), c3(1.0f), c4(),
|
||||
|
|
@ -71,7 +70,7 @@ aiMatrix4x4t<TReal>::aiMatrix4x4t() AI_NO_EXCEPT :
|
|||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
aiMatrix4x4t<TReal>::aiMatrix4x4t (TReal _a1, TReal _a2, TReal _a3, TReal _a4,
|
||||
aiMatrix4x4t<TReal> ::aiMatrix4x4t (TReal _a1, TReal _a2, TReal _a3, TReal _a4,
|
||||
TReal _b1, TReal _b2, TReal _b3, TReal _b4,
|
||||
TReal _c1, TReal _c2, TReal _c3, TReal _c4,
|
||||
TReal _d1, TReal _d2, TReal _d3, TReal _d4) :
|
||||
|
|
@ -424,18 +423,12 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
|
|||
{
|
||||
ASSIMP_MATRIX4_4_DECOMPOSE_PART;
|
||||
|
||||
/*
|
||||
assuming a right-handed coordinate system
|
||||
and post-multiplication of column vectors,
|
||||
the rotation matrix for an euler XYZ rotation is M = Rz * Ry * Rx.
|
||||
combining gives:
|
||||
|
||||
| CE BDE-AF ADE+BF 0 |
|
||||
M = | CF BDF+AE ADF-BE 0 |
|
||||
| -D CB AC 0 |
|
||||
| 0 0 0 1 |
|
||||
/*
|
||||
| CE -CF D 0 |
|
||||
M = | BDE+AF -BDF+AE -BC 0 |
|
||||
| -ADE+BF -ADF+BE AC 0 |
|
||||
| 0 0 0 1 |
|
||||
|
||||
where
|
||||
A = cos(angle_x), B = sin(angle_x);
|
||||
C = cos(angle_y), D = sin(angle_y);
|
||||
E = cos(angle_z), F = sin(angle_z);
|
||||
|
|
@ -444,20 +437,20 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
|
|||
// Use a small epsilon to solve floating-point inaccuracies
|
||||
const TReal epsilon = 10e-3f;
|
||||
|
||||
pRotation.y = std::asin(-vCols[0].z);// D. Angle around oY.
|
||||
pRotation.y = std::asin(vCols[2].x);// D. Angle around oY.
|
||||
|
||||
TReal C = std::cos(pRotation.y);
|
||||
|
||||
if(std::fabs(C) > epsilon)
|
||||
{
|
||||
// Finding angle around oX.
|
||||
TReal tan_x = vCols[2].z / C;// A
|
||||
TReal tan_y = vCols[1].z / C;// B
|
||||
TReal tan_x = vCols[2].z / C;// A
|
||||
TReal tan_y = -vCols[2].y / C;// B
|
||||
|
||||
pRotation.x = std::atan2(tan_y, tan_x);
|
||||
// Finding angle around oZ.
|
||||
tan_x = vCols[0].x / C;// E
|
||||
tan_y = vCols[0].y / C;// F
|
||||
tan_x = vCols[0].x / C;// E
|
||||
tan_y = -vCols[1].x / C;// F
|
||||
pRotation.z = std::atan2(tan_y, tan_x);
|
||||
}
|
||||
else
|
||||
|
|
@ -465,8 +458,8 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
|
|||
pRotation.x = 0;// Set angle around oX to 0. => A == 1, B == 0, C == 0, D == 1.
|
||||
|
||||
// And finding angle around oZ.
|
||||
TReal tan_x = vCols[1].y;// BDF+AE => E
|
||||
TReal tan_y = -vCols[1].x;// BDE-AF => F
|
||||
TReal tan_x = vCols[1].y;// -BDF+AE => E
|
||||
TReal tan_y = vCols[0].y;// BDE+AF => F
|
||||
|
||||
pRotation.z = std::atan2(tan_y, tan_x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -136,10 +135,10 @@ struct aiFace
|
|||
#ifdef __cplusplus
|
||||
|
||||
//! Default constructor
|
||||
aiFace() AI_NO_EXCEPT
|
||||
: mNumIndices( 0 )
|
||||
, mIndices( nullptr ) {
|
||||
// empty
|
||||
aiFace()
|
||||
: mNumIndices( 0 )
|
||||
, mIndices( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
//! Default destructor. Delete the index array
|
||||
|
|
@ -150,56 +149,47 @@ struct aiFace
|
|||
|
||||
//! Copy constructor. Copy the index array
|
||||
aiFace( const aiFace& o)
|
||||
: mNumIndices(0)
|
||||
, mIndices( nullptr ) {
|
||||
: mIndices( NULL )
|
||||
{
|
||||
*this = o;
|
||||
}
|
||||
|
||||
//! Assignment operator. Copy the index array
|
||||
aiFace& operator = ( const aiFace& o) {
|
||||
if (&o == this) {
|
||||
aiFace& operator = ( const aiFace& o)
|
||||
{
|
||||
if (&o == this)
|
||||
return *this;
|
||||
}
|
||||
|
||||
delete[] mIndices;
|
||||
mNumIndices = o.mNumIndices;
|
||||
if (mNumIndices) {
|
||||
mIndices = new unsigned int[mNumIndices];
|
||||
::memcpy( mIndices, o.mIndices, mNumIndices * sizeof( unsigned int));
|
||||
} else {
|
||||
mIndices = nullptr;
|
||||
}
|
||||
|
||||
else {
|
||||
mIndices = NULL;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Comparison operator. Checks whether the index array
|
||||
//! of two faces is identical
|
||||
bool operator== (const aiFace& o) const {
|
||||
if (mIndices == o.mIndices) {
|
||||
bool operator== (const aiFace& o) const
|
||||
{
|
||||
if (mIndices == o.mIndices)return true;
|
||||
else if (mIndices && mNumIndices == o.mNumIndices)
|
||||
{
|
||||
for (unsigned int i = 0;i < this->mNumIndices;++i)
|
||||
if (mIndices[i] != o.mIndices[i])return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (nullptr != mIndices && mNumIndices != o.mNumIndices) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nullptr == mIndices) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < this->mNumIndices; ++i) {
|
||||
if (mIndices[i] != o.mIndices[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Inverse comparison operator. Checks whether the index
|
||||
//! array of two faces is NOT identical
|
||||
bool operator != (const aiFace& o) const {
|
||||
bool operator != (const aiFace& o) const
|
||||
{
|
||||
return !(*this == o);
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
|
@ -209,7 +199,8 @@ struct aiFace
|
|||
// ---------------------------------------------------------------------------
|
||||
/** @brief A single influence of a bone on a vertex.
|
||||
*/
|
||||
struct aiVertexWeight {
|
||||
struct aiVertexWeight
|
||||
{
|
||||
//! Index of the vertex which is influenced by the bone.
|
||||
unsigned int mVertexId;
|
||||
|
||||
|
|
@ -220,28 +211,14 @@ struct aiVertexWeight {
|
|||
#ifdef __cplusplus
|
||||
|
||||
//! Default constructor
|
||||
aiVertexWeight() AI_NO_EXCEPT
|
||||
: mVertexId(0)
|
||||
, mWeight(0.0f) {
|
||||
// empty
|
||||
}
|
||||
aiVertexWeight() { }
|
||||
|
||||
//! Initialization from a given index and vertex weight factor
|
||||
//! Initialisation from a given index and vertex weight factor
|
||||
//! \param pID ID
|
||||
//! \param pWeight Vertex weight factor
|
||||
aiVertexWeight( unsigned int pID, float pWeight )
|
||||
: mVertexId( pID )
|
||||
, mWeight( pWeight ) {
|
||||
// empty
|
||||
}
|
||||
|
||||
bool operator == ( const aiVertexWeight &rhs ) const {
|
||||
return ( mVertexId == rhs.mVertexId && mWeight == rhs.mWeight );
|
||||
}
|
||||
|
||||
bool operator != ( const aiVertexWeight &rhs ) const {
|
||||
return ( *this == rhs );
|
||||
}
|
||||
aiVertexWeight( unsigned int pID, float pWeight)
|
||||
: mVertexId( pID), mWeight( pWeight)
|
||||
{ /* nothing to do here */ }
|
||||
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
|
@ -252,95 +229,49 @@ struct aiVertexWeight {
|
|||
*
|
||||
* A bone has a name by which it can be found in the frame hierarchy and by
|
||||
* which it can be addressed by animations. In addition it has a number of
|
||||
* influences on vertices, and a matrix relating the mesh position to the
|
||||
* position of the bone at the time of binding.
|
||||
* influences on vertices.
|
||||
*/
|
||||
struct aiBone {
|
||||
struct aiBone
|
||||
{
|
||||
//! The name of the bone.
|
||||
C_STRUCT aiString mName;
|
||||
|
||||
//! The number of vertices affected by this bone.
|
||||
//! The number of vertices affected by this bone
|
||||
//! The maximum value for this member is #AI_MAX_BONE_WEIGHTS.
|
||||
unsigned int mNumWeights;
|
||||
|
||||
//! The influence weights of this bone, by vertex index.
|
||||
//! The vertices affected by this bone
|
||||
C_STRUCT aiVertexWeight* mWeights;
|
||||
|
||||
/** Matrix that transforms from bone space to mesh space in bind pose.
|
||||
*
|
||||
* This matrix describes the position of the mesh
|
||||
* in the local space of this bone when the skeleton was bound.
|
||||
* Thus it can be used directly to determine a desired vertex position,
|
||||
* given the world-space transform of the bone when animated,
|
||||
* and the position of the vertex in mesh space.
|
||||
*
|
||||
* It is sometimes called an inverse-bind matrix,
|
||||
* or inverse bind pose matrix.
|
||||
*/
|
||||
//! Matrix that transforms from mesh space to bone space in bind pose
|
||||
C_STRUCT aiMatrix4x4 mOffsetMatrix;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
//! Default constructor
|
||||
aiBone() AI_NO_EXCEPT
|
||||
: mName()
|
||||
, mNumWeights( 0 )
|
||||
, mWeights( nullptr )
|
||||
, mOffsetMatrix() {
|
||||
// empty
|
||||
aiBone()
|
||||
: mName()
|
||||
, mNumWeights( 0 )
|
||||
, mWeights( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
//! Copy constructor
|
||||
aiBone(const aiBone& other)
|
||||
: mName( other.mName )
|
||||
, mNumWeights( other.mNumWeights )
|
||||
, mWeights(nullptr)
|
||||
, mOffsetMatrix( other.mOffsetMatrix ) {
|
||||
if (other.mWeights && other.mNumWeights) {
|
||||
mWeights = new aiVertexWeight[mNumWeights];
|
||||
::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Assignment operator
|
||||
aiBone &operator=(const aiBone& other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
mName = other.mName;
|
||||
mNumWeights = other.mNumWeights;
|
||||
mOffsetMatrix = other.mOffsetMatrix;
|
||||
|
||||
: mName( other.mName )
|
||||
, mNumWeights( other.mNumWeights )
|
||||
, mOffsetMatrix( other.mOffsetMatrix )
|
||||
{
|
||||
if (other.mWeights && other.mNumWeights)
|
||||
{
|
||||
if (mWeights) {
|
||||
delete[] mWeights;
|
||||
}
|
||||
|
||||
mWeights = new aiVertexWeight[mNumWeights];
|
||||
::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator == ( const aiBone &rhs ) const {
|
||||
if ( mName != rhs.mName || mNumWeights != rhs.mNumWeights ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( size_t i = 0; i < mNumWeights; ++i ) {
|
||||
if ( mWeights[ i ] != rhs.mWeights[ i ] ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//! Destructor - deletes the array of vertex weights
|
||||
~aiBone() {
|
||||
~aiBone()
|
||||
{
|
||||
delete [] mWeights;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
|
@ -454,13 +385,11 @@ struct aiAnimMesh
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
aiAnimMesh() AI_NO_EXCEPT
|
||||
: mVertices( nullptr )
|
||||
, mNormals(nullptr)
|
||||
, mTangents(nullptr)
|
||||
, mBitangents(nullptr)
|
||||
, mColors()
|
||||
, mTextureCoords()
|
||||
aiAnimMesh()
|
||||
: mVertices( NULL )
|
||||
, mNormals( NULL )
|
||||
, mTangents( NULL )
|
||||
, mBitangents( NULL )
|
||||
, mNumVertices( 0 )
|
||||
, mWeight( 0.0f )
|
||||
{
|
||||
|
|
@ -715,36 +644,35 @@ struct aiMesh
|
|||
#ifdef __cplusplus
|
||||
|
||||
//! Default constructor. Initializes all members to 0
|
||||
aiMesh() AI_NO_EXCEPT
|
||||
: mPrimitiveTypes( 0 )
|
||||
, mNumVertices( 0 )
|
||||
, mNumFaces( 0 )
|
||||
, mVertices( nullptr )
|
||||
, mNormals(nullptr)
|
||||
, mTangents(nullptr)
|
||||
, mBitangents(nullptr)
|
||||
, mColors()
|
||||
, mTextureCoords()
|
||||
, mNumUVComponents()
|
||||
, mFaces(nullptr)
|
||||
, mNumBones( 0 )
|
||||
, mBones(nullptr)
|
||||
, mMaterialIndex( 0 )
|
||||
, mNumAnimMeshes( 0 )
|
||||
, mAnimMeshes(nullptr)
|
||||
, mMethod( 0 ) {
|
||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) {
|
||||
aiMesh()
|
||||
: mPrimitiveTypes( 0 )
|
||||
, mNumVertices( 0 )
|
||||
, mNumFaces( 0 )
|
||||
, mVertices( NULL )
|
||||
, mNormals( NULL )
|
||||
, mTangents( NULL )
|
||||
, mBitangents( NULL )
|
||||
, mFaces( NULL )
|
||||
, mNumBones( 0 )
|
||||
, mBones( NULL )
|
||||
, mMaterialIndex( 0 )
|
||||
, mNumAnimMeshes( 0 )
|
||||
, mAnimMeshes( NULL )
|
||||
, mMethod( 0 )
|
||||
{
|
||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++)
|
||||
{
|
||||
mNumUVComponents[a] = 0;
|
||||
mTextureCoords[a] = nullptr;
|
||||
mTextureCoords[a] = NULL;
|
||||
}
|
||||
|
||||
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) {
|
||||
mColors[a] = nullptr;
|
||||
}
|
||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
|
||||
mColors[a] = NULL;
|
||||
}
|
||||
|
||||
//! Deletes all storage allocated for the mesh
|
||||
~aiMesh() {
|
||||
~aiMesh()
|
||||
{
|
||||
delete [] mVertices;
|
||||
delete [] mNormals;
|
||||
delete [] mTangents;
|
||||
|
|
@ -777,67 +705,63 @@ struct aiMesh
|
|||
//! Check whether the mesh contains positions. Provided no special
|
||||
//! scene flags are set, this will always be true
|
||||
bool HasPositions() const
|
||||
{ return mVertices != nullptr && mNumVertices > 0; }
|
||||
{ return mVertices != NULL && mNumVertices > 0; }
|
||||
|
||||
//! Check whether the mesh contains faces. If no special scene flags
|
||||
//! are set this should always return true
|
||||
bool HasFaces() const
|
||||
{ return mFaces != nullptr && mNumFaces > 0; }
|
||||
{ return mFaces != NULL && mNumFaces > 0; }
|
||||
|
||||
//! Check whether the mesh contains normal vectors
|
||||
bool HasNormals() const
|
||||
{ return mNormals != nullptr && mNumVertices > 0; }
|
||||
{ return mNormals != NULL && mNumVertices > 0; }
|
||||
|
||||
//! Check whether the mesh contains tangent and bitangent vectors
|
||||
//! It is not possible that it contains tangents and no bitangents
|
||||
//! (or the other way round). The existence of one of them
|
||||
//! implies that the second is there, too.
|
||||
bool HasTangentsAndBitangents() const
|
||||
{ return mTangents != nullptr && mBitangents != nullptr && mNumVertices > 0; }
|
||||
{ return mTangents != NULL && mBitangents != NULL && mNumVertices > 0; }
|
||||
|
||||
//! Check whether the mesh contains a vertex color set
|
||||
//! \param pIndex Index of the vertex color set
|
||||
bool HasVertexColors( unsigned int pIndex) const {
|
||||
if (pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) {
|
||||
bool HasVertexColors( unsigned int pIndex) const
|
||||
{
|
||||
if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
|
||||
return false;
|
||||
} else {
|
||||
return mColors[pIndex] != nullptr && mNumVertices > 0;
|
||||
}
|
||||
else
|
||||
return mColors[pIndex] != NULL && mNumVertices > 0;
|
||||
}
|
||||
|
||||
//! Check whether the mesh contains a texture coordinate set
|
||||
//! \param pIndex Index of the texture coordinates set
|
||||
bool HasTextureCoords( unsigned int pIndex) const {
|
||||
if (pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||
bool HasTextureCoords( unsigned int pIndex) const
|
||||
{
|
||||
if( pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
||||
return false;
|
||||
} else {
|
||||
return mTextureCoords[pIndex] != nullptr && mNumVertices > 0;
|
||||
}
|
||||
else
|
||||
return mTextureCoords[pIndex] != NULL && mNumVertices > 0;
|
||||
}
|
||||
|
||||
//! Get the number of UV channels the mesh contains
|
||||
unsigned int GetNumUVChannels() const {
|
||||
unsigned int n( 0 );
|
||||
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n]) {
|
||||
++n;
|
||||
}
|
||||
|
||||
unsigned int GetNumUVChannels() const
|
||||
{
|
||||
unsigned int n = 0;
|
||||
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n])++n;
|
||||
return n;
|
||||
}
|
||||
|
||||
//! Get the number of vertex color channels the mesh contains
|
||||
unsigned int GetNumColorChannels() const {
|
||||
unsigned int n(0);
|
||||
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n]) {
|
||||
++n;
|
||||
}
|
||||
unsigned int GetNumColorChannels() const
|
||||
{
|
||||
unsigned int n = 0;
|
||||
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n])++n;
|
||||
return n;
|
||||
}
|
||||
|
||||
//! Check whether the mesh contains bones
|
||||
bool HasBones() const {
|
||||
return mBones != nullptr && mNumBones > 0;
|
||||
}
|
||||
inline bool HasBones() const
|
||||
{ return mBones != NULL && mNumBones > 0; }
|
||||
|
||||
#endif // __cplusplus
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -67,7 +66,6 @@ typedef enum aiMetadataType {
|
|||
AI_DOUBLE = 4,
|
||||
AI_AISTRING = 5,
|
||||
AI_AIVECTOR3D = 6,
|
||||
AI_META_MAX = 7,
|
||||
|
||||
#ifndef SWIG
|
||||
FORCE_32BIT = INT_MAX
|
||||
|
|
@ -129,106 +127,44 @@ struct aiMetadata {
|
|||
/**
|
||||
* @brief The default constructor, set all members to zero by default.
|
||||
*/
|
||||
aiMetadata() AI_NO_EXCEPT
|
||||
aiMetadata()
|
||||
: mNumProperties(0)
|
||||
, mKeys(nullptr)
|
||||
, mValues(nullptr) {
|
||||
, mKeys(NULL)
|
||||
, mValues(NULL) {
|
||||
// empty
|
||||
}
|
||||
|
||||
aiMetadata( const aiMetadata &rhs )
|
||||
: mNumProperties( rhs.mNumProperties )
|
||||
, mKeys( nullptr )
|
||||
, mValues( nullptr ) {
|
||||
mKeys = new aiString[ mNumProperties ];
|
||||
for ( size_t i = 0; i < static_cast<size_t>( mNumProperties ); ++i ) {
|
||||
mKeys[ i ] = rhs.mKeys[ i ];
|
||||
}
|
||||
mValues = new aiMetadataEntry[ mNumProperties ];
|
||||
for ( size_t i = 0; i < static_cast<size_t>(mNumProperties); ++i ) {
|
||||
mValues[ i ].mType = rhs.mValues[ i ].mType;
|
||||
switch ( rhs.mValues[ i ].mType ) {
|
||||
case AI_BOOL:
|
||||
mValues[ i ].mData = new bool;
|
||||
::memcpy( mValues[ i ].mData, rhs.mValues[ i ].mData, sizeof(bool) );
|
||||
break;
|
||||
case AI_INT32: {
|
||||
int32_t v;
|
||||
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( int32_t ) );
|
||||
mValues[ i ].mData = new int32_t( v );
|
||||
}
|
||||
break;
|
||||
case AI_UINT64: {
|
||||
uint64_t v;
|
||||
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( uint64_t ) );
|
||||
mValues[ i ].mData = new uint64_t( v );
|
||||
}
|
||||
break;
|
||||
case AI_FLOAT: {
|
||||
float v;
|
||||
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( float ) );
|
||||
mValues[ i ].mData = new float( v );
|
||||
}
|
||||
break;
|
||||
case AI_DOUBLE: {
|
||||
double v;
|
||||
::memcpy( &v, rhs.mValues[ i ].mData, sizeof( double ) );
|
||||
mValues[ i ].mData = new double( v );
|
||||
}
|
||||
break;
|
||||
case AI_AISTRING: {
|
||||
aiString v;
|
||||
rhs.Get<aiString>( mKeys[ i ], v );
|
||||
mValues[ i ].mData = new aiString( v );
|
||||
}
|
||||
break;
|
||||
case AI_AIVECTOR3D: {
|
||||
aiVector3D v;
|
||||
rhs.Get<aiVector3D>( mKeys[ i ], v );
|
||||
mValues[ i ].mData = new aiVector3D( v );
|
||||
}
|
||||
break;
|
||||
#ifndef SWIG
|
||||
case FORCE_32BIT:
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The destructor.
|
||||
*/
|
||||
~aiMetadata() {
|
||||
delete [] mKeys;
|
||||
mKeys = nullptr;
|
||||
mKeys = NULL;
|
||||
if (mValues) {
|
||||
// Delete each metadata entry
|
||||
for (unsigned i=0; i<mNumProperties; ++i) {
|
||||
void* data = mValues[i].mData;
|
||||
switch (mValues[i].mType) {
|
||||
case AI_BOOL:
|
||||
delete static_cast< bool* >( data );
|
||||
delete static_cast<bool*>(data);
|
||||
break;
|
||||
case AI_INT32:
|
||||
delete static_cast< int32_t* >( data );
|
||||
delete static_cast<int32_t*>(data);
|
||||
break;
|
||||
case AI_UINT64:
|
||||
delete static_cast< uint64_t* >( data );
|
||||
delete static_cast<uint64_t*>(data);
|
||||
break;
|
||||
case AI_FLOAT:
|
||||
delete static_cast< float* >( data );
|
||||
delete static_cast<float*>(data);
|
||||
break;
|
||||
case AI_DOUBLE:
|
||||
delete static_cast< double* >( data );
|
||||
delete static_cast<double*>(data);
|
||||
break;
|
||||
case AI_AISTRING:
|
||||
delete static_cast< aiString* >( data );
|
||||
delete static_cast<aiString*>(data);
|
||||
break;
|
||||
case AI_AIVECTOR3D:
|
||||
delete static_cast< aiVector3D* >( data );
|
||||
delete static_cast<aiVector3D*>(data);
|
||||
break;
|
||||
#ifndef SWIG
|
||||
case FORCE_32BIT:
|
||||
|
|
@ -240,7 +176,7 @@ struct aiMetadata {
|
|||
|
||||
// Delete the metadata array
|
||||
delete [] mValues;
|
||||
mValues = nullptr;
|
||||
mValues = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -271,8 +207,8 @@ struct aiMetadata {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline
|
||||
void Add(const std::string& key, const T& value) {
|
||||
inline void Add(const std::string& key, const T& value)
|
||||
{
|
||||
aiString* new_keys = new aiString[mNumProperties + 1];
|
||||
aiMetadataEntry* new_values = new aiMetadataEntry[mNumProperties + 1];
|
||||
|
||||
|
|
@ -319,7 +255,7 @@ struct aiMetadata {
|
|||
|
||||
template<typename T>
|
||||
inline
|
||||
bool Get( unsigned index, T& value ) const {
|
||||
bool Get( unsigned index, T& value ) {
|
||||
// In range assertion
|
||||
if ( index >= mNumProperties ) {
|
||||
return false;
|
||||
|
|
@ -340,7 +276,7 @@ struct aiMetadata {
|
|||
|
||||
template<typename T>
|
||||
inline
|
||||
bool Get( const aiString& key, T& value ) const {
|
||||
bool Get( const aiString& key, T& value ) {
|
||||
// Search for the given key
|
||||
for ( unsigned int i = 0; i < mNumProperties; ++i ) {
|
||||
if ( mKeys[ i ] == key ) {
|
||||
|
|
@ -351,8 +287,7 @@ struct aiMetadata {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
inline
|
||||
bool Get( const std::string& key, T& value ) const {
|
||||
inline bool Get( const std::string& key, T& value ) {
|
||||
return Get(aiString(key), value);
|
||||
}
|
||||
|
||||
|
|
@ -361,8 +296,7 @@ struct aiMetadata {
|
|||
/// \param [out] pKey - pointer to the key value.
|
||||
/// \param [out] pEntry - pointer to the entry: type and value.
|
||||
/// \return false - if pIndex is out of range, else - true.
|
||||
inline
|
||||
bool Get(size_t index, const aiString*& key, const aiMetadataEntry*& entry) const {
|
||||
inline bool Get(size_t index, const aiString*& key, const aiMetadataEntry*& entry) {
|
||||
if ( index >= mNumProperties ) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file pbrmaterial.h
|
||||
* @brief Defines the material system of the library
|
||||
*/
|
||||
#ifndef AI_PBRMATERIAL_H_INC
|
||||
#define AI_PBRMATERIAL_H_INC
|
||||
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_FACTOR "$mat.gltf.pbrMetallicRoughness.baseColorFactor", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLIC_FACTOR "$mat.gltf.pbrMetallicRoughness.metallicFactor", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_ROUGHNESS_FACTOR "$mat.gltf.pbrMetallicRoughness.roughnessFactor", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_BASE_COLOR_TEXTURE aiTextureType_DIFFUSE, 1
|
||||
#define AI_MATKEY_GLTF_PBRMETALLICROUGHNESS_METALLICROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 0
|
||||
#define AI_MATKEY_GLTF_ALPHAMODE "$mat.gltf.alphaMode", 0, 0
|
||||
#define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0
|
||||
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0
|
||||
#define AI_MATKEY_GLTF_UNLIT "$mat.gltf.unlit", 0, 0
|
||||
|
||||
#define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord"
|
||||
#define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname"
|
||||
#define _AI_MATKEY_GLTF_MAPPINGID_BASE "$tex.mappingid"
|
||||
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE "$tex.mappingfiltermag"
|
||||
#define _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE "$tex.mappingfiltermin"
|
||||
#define _AI_MATKEY_GLTF_SCALE_BASE "$tex.scale"
|
||||
#define _AI_MATKEY_GLTF_STRENGTH_BASE "$tex.strength"
|
||||
|
||||
#define AI_MATKEY_GLTF_TEXTURE_TEXCOORD(type, N) _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_MAPPINGNAME(type, N) _AI_MATKEY_GLTF_MAPPINGNAME_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_MAPPINGID(type, N) _AI_MATKEY_GLTF_MAPPINGID_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_MAPPINGFILTER_MAG(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MAG_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_MAPPINGFILTER_MIN(type, N) _AI_MATKEY_GLTF_MAPPINGFILTER_MIN_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_TEXTURE_SCALE(type, N) _AI_MATKEY_GLTF_SCALE_BASE, type, N
|
||||
#define AI_MATKEY_GLTF_TEXTURE_STRENGTH(type, N) _AI_MATKEY_GLTF_STRENGTH_BASE, type, N
|
||||
|
||||
#endif //!!AI_PBRMATERIAL_H_INC
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2016, assimp 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 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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file Android implementation of IOSystem using the standard C file functions.
|
||||
* Aimed to ease the access to android assets */
|
||||
|
||||
#if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
|
||||
#ifndef AI_ANDROIDJNIIOSYSTEM_H_INC
|
||||
#define AI_ANDROIDJNIIOSYSTEM_H_INC
|
||||
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
#include <android/asset_manager.h>
|
||||
#include <android/asset_manager_jni.h>
|
||||
#include <android/native_activity.h>
|
||||
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Android extension to DefaultIOSystem using the standard C file functions */
|
||||
class ASSIMP_API AndroidJNIIOSystem : public DefaultIOSystem
|
||||
{
|
||||
public:
|
||||
|
||||
/** Initialize android activity data */
|
||||
std::string mApkWorkspacePath;
|
||||
AAssetManager* mApkAssetManager;
|
||||
|
||||
/** Constructor. */
|
||||
AndroidJNIIOSystem(ANativeActivity* activity);
|
||||
|
||||
/** Destructor. */
|
||||
~AndroidJNIIOSystem();
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Tests for the existence of a file at the given path. */
|
||||
bool Exists( const char* pFile) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Opens a file at the given path, with given mode */
|
||||
IOStream* Open( const char* strFile, const char* strMode);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Inits Android extractor
|
||||
void AndroidActivityInit(ANativeActivity* activity);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Extracts android asset
|
||||
bool AndroidExtractAsset(std::string name);
|
||||
|
||||
};
|
||||
|
||||
} //!ns Assimp
|
||||
|
||||
#endif //AI_ANDROIDJNIIOSYSTEM_H_INC
|
||||
#endif //__ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -361,11 +360,6 @@ enum aiPostProcessSteps
|
|||
* and line meshes from the scene.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* This step also removes very small triangles with a surface area smaller
|
||||
* than 10^-6. If you rely on having these small triangles, or notice holes
|
||||
* in your model, set the property <tt>#AI_CONFIG_PP_FD_CHECKAREA</tt> to
|
||||
* false.
|
||||
* @note Degenerate polygons are not necessarily evil and that's why
|
||||
* they're not removed by default. There are several file formats which
|
||||
* don't support lines or points, and some exporters bypass the
|
||||
|
|
@ -537,43 +531,15 @@ enum aiPostProcessSteps
|
|||
/** <hr>This step will perform a global scale of the model.
|
||||
*
|
||||
* Some importers are providing a mechanism to define a scaling unit for the
|
||||
* model. This post processing step can be used to do so. You need to get the
|
||||
* global scaling from your importer settings like in FBX. Use the flag
|
||||
* AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY from the global property table to configure this.
|
||||
* model. This post processing step can be used to do so.
|
||||
*
|
||||
* Use <tt>#AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY</tt> to setup the global scaing factor.
|
||||
* Use <tt>#AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY</tt> to control this.
|
||||
*/
|
||||
aiProcess_GlobalScale = 0x8000000,
|
||||
aiProcess_GlobalScale = 0x8000000
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/** <hr>A postprocessing step to embed of textures.
|
||||
*
|
||||
* This will remove external data dependencies for textures.
|
||||
* If a texture's file does not exist at the specified path
|
||||
* (due, for instance, to an absolute path generated on another system),
|
||||
* it will check if a file with the same name exists at the root folder
|
||||
* of the imported model. And if so, it uses that.
|
||||
*/
|
||||
aiProcess_EmbedTextures = 0x10000000,
|
||||
|
||||
// aiProcess_GenEntityMeshes = 0x100000,
|
||||
// aiProcess_OptimizeAnimations = 0x200000
|
||||
// aiProcess_FixTexturePaths = 0x200000
|
||||
|
||||
|
||||
aiProcess_ForceGenNormals = 0x20000000,
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/** <hr>Drops normals for all faces of all meshes.
|
||||
*
|
||||
* This is ignored if no normals are present.
|
||||
* Face normals are shared between all points of a single face,
|
||||
* so a single point can have multiple normals, which
|
||||
* forces the library to duplicate vertices in some cases.
|
||||
* #aiProcess_JoinIdenticalVertices is *senseless* then.
|
||||
* This process gives sense back to aiProcess_JoinIdenticalVertices
|
||||
*/
|
||||
aiProcess_DropNormals = 0x40000000,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,165 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp 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 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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** @file qnan.h
|
||||
* @brief Some utilities for our dealings with qnans.
|
||||
*
|
||||
* @note Some loaders use qnans to mark invalid values tempoarily, also
|
||||
* Assimp explicitly enforces undefined normals to be set to qnan.
|
||||
* qnan utilities are available in standard libraries (C99 for example)
|
||||
* but last time I checked compiler coverage was so bad that I decided
|
||||
* to reinvent the wheel.
|
||||
*/
|
||||
|
||||
#ifndef AI_QNAN_H_INCLUDED
|
||||
#define AI_QNAN_H_INCLUDED
|
||||
|
||||
#include <assimp/defs.h>
|
||||
#include <limits>
|
||||
#include <stdint.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Data structure to represent the bit pattern of a 32 Bit
|
||||
* IEEE 754 floating-point number. */
|
||||
union _IEEESingle
|
||||
{
|
||||
float Float;
|
||||
struct
|
||||
{
|
||||
uint32_t Frac : 23;
|
||||
uint32_t Exp : 8;
|
||||
uint32_t Sign : 1;
|
||||
} IEEE;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Data structure to represent the bit pattern of a 64 Bit
|
||||
* IEEE 754 floating-point number. */
|
||||
union _IEEEDouble
|
||||
{
|
||||
double Double;
|
||||
struct
|
||||
{
|
||||
uint64_t Frac : 52;
|
||||
uint64_t Exp : 11;
|
||||
uint64_t Sign : 1;
|
||||
} IEEE;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Check whether a given float is qNaN.
|
||||
* @param in Input value */
|
||||
AI_FORCE_INLINE bool is_qnan(float in)
|
||||
{
|
||||
// the straightforward solution does not work:
|
||||
// return (in != in);
|
||||
// compiler generates code like this
|
||||
// load <in> to <register-with-different-width>
|
||||
// compare <register-with-different-width> against <in>
|
||||
|
||||
// FIXME: Use <float> stuff instead? I think fpclassify needs C99
|
||||
_IEEESingle temp;
|
||||
memcpy(&temp, &in, sizeof(float));
|
||||
return (temp.IEEE.Exp == (1u << 8)-1 &&
|
||||
temp.IEEE.Frac);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Check whether a given double is qNaN.
|
||||
* @param in Input value */
|
||||
AI_FORCE_INLINE bool is_qnan(double in)
|
||||
{
|
||||
// the straightforward solution does not work:
|
||||
// return (in != in);
|
||||
// compiler generates code like this
|
||||
// load <in> to <register-with-different-width>
|
||||
// compare <register-with-different-width> against <in>
|
||||
|
||||
// FIXME: Use <float> stuff instead? I think fpclassify needs C99
|
||||
_IEEEDouble temp;
|
||||
memcpy(&temp, &in, sizeof(in));
|
||||
return (temp.IEEE.Exp == (1u << 11)-1 &&
|
||||
temp.IEEE.Frac);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief check whether a float is either NaN or (+/-) INF.
|
||||
*
|
||||
* Denorms return false, they're treated like normal values.
|
||||
* @param in Input value */
|
||||
AI_FORCE_INLINE bool is_special_float(float in)
|
||||
{
|
||||
_IEEESingle temp;
|
||||
memcpy(&temp, &in, sizeof(float));
|
||||
return (temp.IEEE.Exp == (1u << 8)-1);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief check whether a double is either NaN or (+/-) INF.
|
||||
*
|
||||
* Denorms return false, they're treated like normal values.
|
||||
* @param in Input value */
|
||||
AI_FORCE_INLINE bool is_special_float(double in)
|
||||
{
|
||||
_IEEESingle temp;
|
||||
memcpy(&temp, &in, sizeof(float));
|
||||
return (temp.IEEE.Exp == (1u << 11)-1);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** Check whether a float is NOT qNaN.
|
||||
* @param in Input value */
|
||||
template<class TReal>
|
||||
AI_FORCE_INLINE bool is_not_qnan(TReal in)
|
||||
{
|
||||
return !is_qnan(in);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Get a fresh qnan. */
|
||||
AI_FORCE_INLINE ai_real get_qnan()
|
||||
{
|
||||
return std::numeric_limits<ai_real>::quiet_NaN();
|
||||
}
|
||||
|
||||
#endif // !! AI_QNAN_H_INCLUDED
|
||||
|
|
@ -2,8 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -60,7 +59,7 @@ template <typename TReal>
|
|||
class aiQuaterniont
|
||||
{
|
||||
public:
|
||||
aiQuaterniont() AI_NO_EXCEPT : w(1.0), x(), y(), z() {}
|
||||
aiQuaterniont() : w(1.0), x(), y(), z() {}
|
||||
aiQuaterniont(TReal pw, TReal px, TReal py, TReal pz)
|
||||
: w(pw), x(px), y(py), z(pz) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -327,16 +326,6 @@ struct aiScene
|
|||
*/
|
||||
C_STRUCT aiCamera** mCameras;
|
||||
|
||||
/**
|
||||
* @brief The global metadata assigned to the scene itself.
|
||||
*
|
||||
* This data contains global metadata which belongs to the scene like
|
||||
* unit-conversions, versions, vendors or other model-specific data. This
|
||||
* can be used to store format-specific metadata as well.
|
||||
*/
|
||||
C_STRUCT aiMetadata* mMetaData;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
//! Default constructor - set everything to 0/NULL
|
||||
|
|
@ -377,27 +366,6 @@ struct aiScene
|
|||
return mAnimations != NULL && mNumAnimations > 0;
|
||||
}
|
||||
|
||||
//! Returns a short filename from a full path
|
||||
static const char* GetShortFilename(const char* filename) {
|
||||
const char* lastSlash = strrchr(filename, '/');
|
||||
if (lastSlash == nullptr) {
|
||||
lastSlash = strrchr(filename, '\\');
|
||||
}
|
||||
const char* shortFilename = lastSlash != nullptr ? lastSlash + 1 : filename;
|
||||
return shortFilename;
|
||||
}
|
||||
|
||||
//! Returns an embedded texture
|
||||
const aiTexture* GetEmbeddedTexture(const char* filename) const {
|
||||
const char* shortFilename = GetShortFilename(filename);
|
||||
for (unsigned int i = 0; i < mNumTextures; i++) {
|
||||
const char* shortTextureFilename = GetShortFilename(mTextures[i]->mFilename.C_Str());
|
||||
if (strcmp(shortTextureFilename, shortFilename) == 0) {
|
||||
return mTextures[i];
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
/** Internal data, do not touch */
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -131,7 +130,8 @@ struct aiTexel
|
|||
* as the texture paths (a single asterisk character followed by the
|
||||
* zero-based index of the texture in the aiScene::mTextures array).
|
||||
*/
|
||||
struct aiTexture {
|
||||
struct aiTexture
|
||||
{
|
||||
/** Width of the texture, in pixels
|
||||
*
|
||||
* If mHeight is zero the texture is compressed in a format
|
||||
|
|
@ -179,12 +179,6 @@ struct aiTexture {
|
|||
*/
|
||||
C_STRUCT aiTexel* pcData;
|
||||
|
||||
/** Texture original filename
|
||||
*
|
||||
* Used to get the texture reference
|
||||
*/
|
||||
C_STRUCT aiString mFilename;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
//! For compressed textures (mHeight == 0): compare the
|
||||
|
|
@ -192,26 +186,24 @@ struct aiTexture {
|
|||
//! @param s Input string. 3 characters are maximally processed.
|
||||
//! Example values: "jpg", "png"
|
||||
//! @return true if the given string matches the format hint
|
||||
bool CheckFormat(const char* s) const {
|
||||
if (nullptr == s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckFormat(const char* s) const
|
||||
{
|
||||
return (0 == ::strncmp(achFormatHint, s, sizeof(achFormatHint)));
|
||||
}
|
||||
|
||||
// Construction
|
||||
aiTexture() AI_NO_EXCEPT
|
||||
: mWidth(0)
|
||||
, mHeight(0)
|
||||
, pcData(nullptr)
|
||||
, mFilename() {
|
||||
aiTexture ()
|
||||
: mWidth (0)
|
||||
, mHeight (0)
|
||||
, pcData (NULL)
|
||||
{
|
||||
achFormatHint[0] = achFormatHint[1] = 0;
|
||||
achFormatHint[2] = achFormatHint[3] = 0;
|
||||
}
|
||||
|
||||
// Destruction
|
||||
~aiTexture () {
|
||||
~aiTexture ()
|
||||
{
|
||||
delete[] pcData;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -111,7 +110,8 @@ extern "C" {
|
|||
|
||||
/** Maximum dimension for strings, ASSIMP strings are zero terminated. */
|
||||
#ifdef __cplusplus
|
||||
static const size_t MAXLEN = 1024;
|
||||
static
|
||||
const size_t MAXLEN = 1024;
|
||||
#else
|
||||
# define MAXLEN 1024
|
||||
#endif
|
||||
|
|
@ -119,9 +119,10 @@ extern "C" {
|
|||
// ----------------------------------------------------------------------------------
|
||||
/** Represents a plane in a three-dimensional, euclidean space
|
||||
*/
|
||||
struct aiPlane {
|
||||
struct aiPlane
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiPlane () AI_NO_EXCEPT : a(0.f), b(0.f), c(0.f), d(0.f) {}
|
||||
aiPlane () : a(0.f), b(0.f), c(0.f), d(0.f) {}
|
||||
aiPlane (ai_real _a, ai_real _b, ai_real _c, ai_real _d)
|
||||
: a(_a), b(_b), c(_c), d(_d) {}
|
||||
|
||||
|
|
@ -136,9 +137,10 @@ struct aiPlane {
|
|||
// ----------------------------------------------------------------------------------
|
||||
/** Represents a ray
|
||||
*/
|
||||
struct aiRay {
|
||||
struct aiRay
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiRay () AI_NO_EXCEPT {}
|
||||
aiRay () {}
|
||||
aiRay (const aiVector3D& _pos, const aiVector3D& _dir)
|
||||
: pos(_pos), dir(_dir) {}
|
||||
|
||||
|
|
@ -156,7 +158,7 @@ struct aiRay {
|
|||
struct aiColor3D
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
aiColor3D () AI_NO_EXCEPT : r(0.0f), g(0.0f), b(0.0f) {}
|
||||
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
|
||||
aiColor3D (ai_real _r, ai_real _g, ai_real _b) : r(_r), g(_g), b(_b) {}
|
||||
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
|
||||
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
|
||||
|
|
@ -251,8 +253,9 @@ struct aiString
|
|||
{
|
||||
#ifdef __cplusplus
|
||||
/** Default constructor, the string is set to have zero length */
|
||||
aiString() AI_NO_EXCEPT
|
||||
: length( 0 ) {
|
||||
aiString() :
|
||||
length(0)
|
||||
{
|
||||
data[0] = '\0';
|
||||
|
||||
#ifdef ASSIMP_BUILD_DEBUG
|
||||
|
|
@ -301,20 +304,6 @@ struct aiString
|
|||
data[len] = 0;
|
||||
}
|
||||
|
||||
|
||||
/** Assignment operator */
|
||||
aiString& operator = (const aiString &rOther) {
|
||||
if (this == &rOther) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
length = rOther.length;;
|
||||
memcpy( data, rOther.data, length);
|
||||
data[length] = '\0';
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/** Assign a const char* to the string */
|
||||
aiString& operator = (const char* sz) {
|
||||
Set(sz);
|
||||
|
|
@ -370,7 +359,7 @@ struct aiString
|
|||
#endif // !__cplusplus
|
||||
|
||||
/** Binary length of the string excluding the terminal 0. This is NOT the
|
||||
* logical length of strings containing UTF-8 multi-byte sequences! It's
|
||||
* logical length of strings containing UTF-8 multibyte sequences! It's
|
||||
* the number of bytes from the beginning of the string to its end.*/
|
||||
size_t length;
|
||||
|
||||
|
|
@ -476,7 +465,7 @@ struct aiMemoryInfo
|
|||
#ifdef __cplusplus
|
||||
|
||||
/** Default constructor */
|
||||
aiMemoryInfo() AI_NO_EXCEPT
|
||||
aiMemoryInfo()
|
||||
: textures (0)
|
||||
, materials (0)
|
||||
, meshes (0)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -86,6 +85,7 @@ public:
|
|||
const aiVector2t& operator /= (TReal f);
|
||||
|
||||
TReal operator[](unsigned int i) const;
|
||||
TReal& operator[](unsigned int i);
|
||||
|
||||
bool operator== (const aiVector2t& other) const;
|
||||
bool operator!= (const aiVector2t& other) const;
|
||||
|
|
@ -99,7 +99,7 @@ public:
|
|||
operator aiVector2t<TOther> () const;
|
||||
|
||||
TReal x, y;
|
||||
};
|
||||
} PACK_STRUCT;
|
||||
|
||||
typedef aiVector2t<ai_real> aiVector2D;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -61,28 +60,24 @@ aiVector2t<TReal>::operator aiVector2t<TOther> () const {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
void aiVector2t<TReal>::Set( TReal pX, TReal pY) {
|
||||
x = pX; y = pY;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
TReal aiVector2t<TReal>::SquareLength() const {
|
||||
return x*x + y*y;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
TReal aiVector2t<TReal>::Length() const {
|
||||
return std::sqrt( SquareLength());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal>& aiVector2t<TReal>::Normalize() {
|
||||
*this /= Length();
|
||||
return *this;
|
||||
|
|
@ -90,7 +85,6 @@ aiVector2t<TReal>& aiVector2t<TReal>::Normalize() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
const aiVector2t<TReal>& aiVector2t<TReal>::operator += (const aiVector2t& o) {
|
||||
x += o.x; y += o.y;
|
||||
return *this;
|
||||
|
|
@ -98,7 +92,6 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator += (const aiVector2t& o) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
const aiVector2t<TReal>& aiVector2t<TReal>::operator -= (const aiVector2t& o) {
|
||||
x -= o.x; y -= o.y;
|
||||
return *this;
|
||||
|
|
@ -106,7 +99,6 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator -= (const aiVector2t& o) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
const aiVector2t<TReal>& aiVector2t<TReal>::operator *= (TReal f) {
|
||||
x *= f; y *= f;
|
||||
return *this;
|
||||
|
|
@ -114,7 +106,6 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator *= (TReal f) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
const aiVector2t<TReal>& aiVector2t<TReal>::operator /= (TReal f) {
|
||||
x /= f; y /= f;
|
||||
return *this;
|
||||
|
|
@ -122,37 +113,30 @@ const aiVector2t<TReal>& aiVector2t<TReal>::operator /= (TReal f) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
TReal aiVector2t<TReal>::operator[](unsigned int i) const {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return x;
|
||||
return *(&x + i);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
TReal& aiVector2t<TReal>::operator[](unsigned int i) {
|
||||
return *(&x + i);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
bool aiVector2t<TReal>::operator== (const aiVector2t& other) const {
|
||||
return x == other.x && y == other.y;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
bool aiVector2t<TReal>::operator!= (const aiVector2t& other) const {
|
||||
return x != other.x || y != other.y;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
template<typename TReal>
|
||||
inline
|
||||
bool aiVector2t<TReal>::Equal(const aiVector2t& other, TReal epsilon) const {
|
||||
return
|
||||
std::abs(x - other.x) <= epsilon &&
|
||||
|
|
@ -161,7 +145,6 @@ bool aiVector2t<TReal>::Equal(const aiVector2t& other, TReal epsilon) const {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal>& aiVector2t<TReal>::operator= (TReal f) {
|
||||
x = y = f;
|
||||
return *this;
|
||||
|
|
@ -169,7 +152,6 @@ aiVector2t<TReal>& aiVector2t<TReal>::operator= (TReal f) {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
inline
|
||||
const aiVector2t<TReal> aiVector2t<TReal>::SymMul(const aiVector2t& o) {
|
||||
return aiVector2t(x*o.x,y*o.y);
|
||||
}
|
||||
|
|
@ -178,64 +160,65 @@ const aiVector2t<TReal> aiVector2t<TReal>::SymMul(const aiVector2t& o) {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// symmetric addition
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal> operator + (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) {
|
||||
inline aiVector2t<TReal> operator + (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2)
|
||||
{
|
||||
return aiVector2t<TReal>( v1.x + v2.x, v1.y + v2.y);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// symmetric subtraction
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal> operator - (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) {
|
||||
inline aiVector2t<TReal> operator - (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2)
|
||||
{
|
||||
return aiVector2t<TReal>( v1.x - v2.x, v1.y - v2.y);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar product
|
||||
template <typename TReal>
|
||||
inline
|
||||
TReal operator * (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2) {
|
||||
inline TReal operator * (const aiVector2t<TReal>& v1, const aiVector2t<TReal>& v2)
|
||||
{
|
||||
return v1.x*v2.x + v1.y*v2.y;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar multiplication
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal> operator * ( TReal f, const aiVector2t<TReal>& v) {
|
||||
inline aiVector2t<TReal> operator * ( TReal f, const aiVector2t<TReal>& v)
|
||||
{
|
||||
return aiVector2t<TReal>( f*v.x, f*v.y);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// and the other way around
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal> operator * ( const aiVector2t<TReal>& v, TReal f) {
|
||||
inline aiVector2t<TReal> operator * ( const aiVector2t<TReal>& v, TReal f)
|
||||
{
|
||||
return aiVector2t<TReal>( f*v.x, f*v.y);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar division
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal> operator / ( const aiVector2t<TReal>& v, TReal f) {
|
||||
inline aiVector2t<TReal> operator / ( const aiVector2t<TReal>& v, TReal f)
|
||||
{
|
||||
|
||||
return v * (1/f);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// vector division
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal> operator / ( const aiVector2t<TReal>& v, const aiVector2t<TReal>& v2) {
|
||||
inline aiVector2t<TReal> operator / ( const aiVector2t<TReal>& v, const aiVector2t<TReal>& v2)
|
||||
{
|
||||
return aiVector2t<TReal>(v.x / v2.x,v.y / v2.y);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// vector negation
|
||||
template <typename TReal>
|
||||
inline
|
||||
aiVector2t<TReal> operator - ( const aiVector2t<TReal>& v) {
|
||||
inline aiVector2t<TReal> operator - ( const aiVector2t<TReal>& v)
|
||||
{
|
||||
return aiVector2t<TReal>( -v.x, -v.y);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -66,7 +65,7 @@ template <typename TReal>
|
|||
class aiVector3t
|
||||
{
|
||||
public:
|
||||
aiVector3t() AI_NO_EXCEPT : x(), y(), z() {}
|
||||
aiVector3t() : x(), y(), z() {}
|
||||
aiVector3t(TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {}
|
||||
explicit aiVector3t (TReal _xyz ) : x(_xyz), y(_xyz), z(_xyz) {}
|
||||
aiVector3t( const aiVector3t& o ) : x(o.x), y(o.y), z(o.z) {}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -56,8 +55,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
/** Transformation of a vector by a 3x3 matrix */
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
inline aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector3t<TReal>& pVector)
|
||||
{
|
||||
aiVector3t<TReal> res;
|
||||
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z;
|
||||
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z;
|
||||
|
|
@ -68,8 +67,8 @@ aiVector3t<TReal> operator * (const aiMatrix3x3t<TReal>& pMatrix, const aiVector
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
/** Transformation of a vector by a 4x4 matrix */
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector) {
|
||||
inline aiVector3t<TReal> operator * (const aiMatrix4x4t<TReal>& pMatrix, const aiVector3t<TReal>& pVector)
|
||||
{
|
||||
aiVector3t<TReal> res;
|
||||
res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4;
|
||||
res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4;
|
||||
|
|
@ -84,115 +83,65 @@ aiVector3t<TReal>::operator aiVector3t<TOther> () const {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
|
||||
x = pX;
|
||||
y = pY;
|
||||
z = pZ;
|
||||
AI_FORCE_INLINE void aiVector3t<TReal>::Set( TReal pX, TReal pY, TReal pZ) {
|
||||
x = pX; y = pY; z = pZ;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::SquareLength() const {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const {
|
||||
return x*x + y*y + z*z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::Length() const {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const {
|
||||
return std::sqrt( SquareLength());
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
|
||||
*this /= Length();
|
||||
|
||||
return *this;
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::Normalize() {
|
||||
*this /= Length(); return *this;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::NormalizeSafe() {
|
||||
TReal len = Length();
|
||||
if ( len > static_cast< TReal >( 0 ) ) {
|
||||
if (len > static_cast<TReal>(0))
|
||||
*this /= len;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
|
||||
x += o.x;
|
||||
y += o.y;
|
||||
z += o.z;
|
||||
|
||||
return *this;
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator += (const aiVector3t<TReal>& o) {
|
||||
x += o.x; y += o.y; z += o.z; return *this;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
|
||||
x -= o.x;
|
||||
y -= o.y;
|
||||
z -= o.z;
|
||||
|
||||
return *this;
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator -= (const aiVector3t<TReal>& o) {
|
||||
x -= o.x; y -= o.y; z -= o.z; return *this;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
|
||||
x *= f;
|
||||
y *= f;
|
||||
z *= f;
|
||||
|
||||
return *this;
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator *= (TReal f) {
|
||||
x *= f; y *= f; z *= f; return *this;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
|
||||
const TReal invF = (TReal) 1.0 / f;
|
||||
x *= invF;
|
||||
y *= invF;
|
||||
z *= invF;
|
||||
|
||||
return *this;
|
||||
AI_FORCE_INLINE const aiVector3t<TReal>& aiVector3t<TReal>::operator /= (TReal f) {
|
||||
x /= f; y /= f; z /= f; return *this;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
|
||||
return (*this = mat * (*this));
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix3x3t<TReal>& mat){
|
||||
return(*this = mat * (*this));
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
|
||||
return (*this = mat * (*this));
|
||||
AI_FORCE_INLINE aiVector3t<TReal>& aiVector3t<TReal>::operator *= (const aiMatrix4x4t<TReal>& mat){
|
||||
return(*this = mat * (*this));
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal aiVector3t<TReal>::operator[](unsigned int i) const {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
return z;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
||||
AI_FORCE_INLINE TReal aiVector3t<TReal>::operator[](unsigned int i) const {
|
||||
// return *(&x + i);
|
||||
switch (i) {
|
||||
case 0:
|
||||
|
|
@ -208,20 +157,33 @@ TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE TReal& aiVector3t<TReal>::operator[](unsigned int i) {
|
||||
// return *(&x + i);
|
||||
switch (i) {
|
||||
case 0:
|
||||
return x;
|
||||
case 1:
|
||||
return y;
|
||||
case 2:
|
||||
return z;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator== (const aiVector3t<TReal>& other) const {
|
||||
return x == other.x && y == other.y && z == other.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& other) const {
|
||||
return x != other.x || y != other.y || z != other.z;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) const {
|
||||
return
|
||||
std::abs(x - other.x) <= epsilon &&
|
||||
std::abs(y - other.y) <= epsilon &&
|
||||
|
|
@ -229,77 +191,66 @@ bool aiVector3t<TReal>::Equal(const aiVector3t<TReal>& other, TReal epsilon) con
|
|||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
|
||||
AI_FORCE_INLINE bool aiVector3t<TReal>::operator < (const aiVector3t<TReal>& other) const {
|
||||
return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
|
||||
AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
|
||||
return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// symmetric addition
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator + (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// symmetric subtraction
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator - (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar product
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE TReal operator * (const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar multiplication
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * ( TReal f, const aiVector3t<TReal>& v) {
|
||||
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// and the other way around
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator * ( const aiVector3t<TReal>& v, TReal f) {
|
||||
return aiVector3t<TReal>( f*v.x, f*v.y, f*v.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scalar division
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, TReal f) {
|
||||
return v * (1/f);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// vector division
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator / ( const aiVector3t<TReal>& v, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>(v.x / v2.x,v.y / v2.y,v.z / v2.z);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// cross product
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator ^ ( const aiVector3t<TReal>& v1, const aiVector3t<TReal>& v2) {
|
||||
return aiVector3t<TReal>( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// vector negation
|
||||
template<typename TReal>
|
||||
AI_FORCE_INLINE
|
||||
aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
|
||||
template <typename TReal>
|
||||
AI_FORCE_INLINE aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
|
||||
return aiVector3t<TReal>( -v.x, -v.y, -v.z);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2018, assimp team
|
||||
|
||||
Copyright (c) 2006-2017, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
|
@ -83,12 +82,6 @@ ASSIMP_API unsigned int aiGetVersionMajor (void);
|
|||
*/
|
||||
ASSIMP_API unsigned int aiGetVersionRevision (void);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @brief Returns the branchname of the Assimp runtime.
|
||||
* @return The current branch name.
|
||||
*/
|
||||
ASSIMP_API const char *aiGetBranchName();
|
||||
|
||||
//! Assimp was compiled as a shared object (Windows: DLL)
|
||||
#define ASSIMP_CFLAGS_SHARED 0x1
|
||||
//! Assimp was compiled against STLport
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue