Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
eb218095
Commit
eb218095
authored
Jun 26, 2019
by
chili
Browse files
update assimp version
parent
1da10a89
Changes
83
Hide whitespace changes
Inline
Side-by-side
hw3d/assimp-vc140-mt.dll
View file @
eb218095
No preview for this file type
hw3d/assimp/bin/x64/assimp-vc140-mt.lib
View file @
eb218095
No preview for this file type
hw3d/assimp/include/assimp/.editorconfig
0 → 100644
View file @
eb218095
# See <http://EditorConfig.org> for details
[*.{h,hpp,inl}]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = space
hw3d/assimp/include/assimp/BaseImporter.h
0 → 100644
View file @
eb218095
/*
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
();
/** Destructor, private as well */
virtual
~
BaseImporter
();
public:
// -------------------------------------------------------------------
/** 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
);
// -------------------------------------------------------------------
/** @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
hw3d/assimp/include/assimp/Bitmap.h
0 → 100644
View file @
eb218095
/*
---------------------------------------------------------------------------
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
hw3d/assimp/include/assimp/BlobIOSystem.h
0 → 100644
View file @
eb218095
/*
---------------------------------------------------------------------------
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
hw3d/assimp/include/assimp/ByteSwapper.h
0 → 100644
View file @
eb218095
/*
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
()
{}
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
hw3d/assimp/include/assimp/CreateAnimMesh.h
0 → 100644
View file @
eb218095
/*
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
hw3d/assimp/include/assimp/DefaultIOStream.h
View file @
eb218095
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
Open Asset Import Library (assimp)
Open Asset Import Library (assimp)
----------------------------------------------------------------------
----------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2018, assimp team
All rights reserved.
All rights reserved.
...
...
hw3d/assimp/include/assimp/DefaultIOSystem.h
View file @
eb218095
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
Open Asset Import Library (assimp)
Open Asset Import Library (assimp)
----------------------------------------------------------------------
----------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2018, assimp team
All rights reserved.
All rights reserved.
...
@@ -52,12 +53,6 @@ namespace Assimp {
...
@@ -52,12 +53,6 @@ namespace Assimp {
class
ASSIMP_API
DefaultIOSystem
:
public
IOSystem
class
ASSIMP_API
DefaultIOSystem
:
public
IOSystem
{
{
public:
public:
/** Constructor. */
DefaultIOSystem
();
/** Destructor. */
~
DefaultIOSystem
();
// -------------------------------------------------------------------
// -------------------------------------------------------------------
/** Tests for the existence of a file at the given path. */
/** Tests for the existence of a file at the given path. */
bool
Exists
(
const
char
*
pFile
)
const
;
bool
Exists
(
const
char
*
pFile
)
const
;
...
...
hw3d/assimp/include/assimp/DefaultLogger.hpp
View file @
eb218095
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
Open Asset Import Library (assimp)
Open Asset Import Library (assimp)
----------------------------------------------------------------------
----------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2018, assimp team
All rights reserved.
All rights reserved.
...
@@ -130,9 +131,7 @@ public:
...
@@ -130,9 +131,7 @@ public:
bool
detatchStream
(
LogStream
*
pStream
,
bool
detatchStream
(
LogStream
*
pStream
,
unsigned
int
severity
);
unsigned
int
severity
);
private:
private:
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/** @briefPrivate construction for internal use by create().
/** @briefPrivate construction for internal use by create().
* @param severity Logging granularity */
* @param severity Logging granularity */
...
@@ -142,8 +141,6 @@ private:
...
@@ -142,8 +141,6 @@ private:
/** @briefDestructor */
/** @briefDestructor */
~
DefaultLogger
();
~
DefaultLogger
();
private:
/** @brief Logs debug infos, only been written when severity level VERBOSE is set */
/** @brief Logs debug infos, only been written when severity level VERBOSE is set */
void
OnDebug
(
const
char
*
message
);
void
OnDebug
(
const
char
*
message
);
...
...
hw3d/assimp/include/assimp/Exceptional.h
0 → 100644
View file @
eb218095
/*
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
hw3d/assimp/include/assimp/Exporter.hpp
View file @
eb218095
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
Open Asset Import Library (assimp)
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2018, assimp team
All rights reserved.
All rights reserved.
...
@@ -114,12 +115,16 @@ public:
...
@@ -114,12 +115,16 @@ public:
}
}
};
};
/**
public:
* @brief The class constructor.
*/
Exporter
();
Exporter
();
/**
* @brief The class destructor.
*/
~
Exporter
();
~
Exporter
();
public:
// -------------------------------------------------------------------
// -------------------------------------------------------------------
/** Supplies a custom IO handler to the exporter to use to open and
/** Supplies a custom IO handler to the exporter to use to open and
* access files.
* access files.
...
@@ -171,8 +176,10 @@ public:
...
@@ -171,8 +176,10 @@ public:
* Any IO handlers set via #SetIOHandler are ignored here.
* Any IO handlers set via #SetIOHandler are ignored here.
* @note Use aiCopyScene() to get a modifiable copy of a previously
* @note Use aiCopyScene() to get a modifiable copy of a previously
* imported scene. */
* imported scene. */
const
aiExportDataBlob
*
ExportToBlob
(
const
aiScene
*
pScene
,
const
char
*
pFormatId
,
unsigned
int
pPreprocessing
=
0u
,
const
ExportProperties
*
=
NULL
);
const
aiExportDataBlob
*
ExportToBlob
(
const
aiScene
*
pScene
,
const
char
*
pFormatId
,
const
aiExportDataBlob
*
ExportToBlob
(
const
aiScene
*
pScene
,
const
std
::
string
&
pFormatId
,
unsigned
int
pPreprocessing
=
0u
,
const
ExportProperties
*
pProperties
=
NULL
);
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
);
// -------------------------------------------------------------------
// -------------------------------------------------------------------
/** Convenience function to export directly to a file. Use
/** Convenience function to export directly to a file. Use
...
@@ -207,8 +214,10 @@ public:
...
@@ -207,8 +214,10 @@ public:
* @return AI_SUCCESS if everything was fine.
* @return AI_SUCCESS if everything was fine.
* @note Use aiCopyScene() to get a modifiable copy of a previously
* @note Use aiCopyScene() to get a modifiable copy of a previously
* imported scene.*/
* imported scene.*/
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
char
*
pFormatId
,
const
char
*
pPath
,
aiReturn
Export
(
const
aiScene
*
pScene
,
const
std
::
string
&
pFormatId
,
const
std
::
string
&
pPath
,
unsigned
int
pPreprocessing
=
0u
,
const
ExportProperties
*
pProperties
=
NULL
);
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
);
// -------------------------------------------------------------------
// -------------------------------------------------------------------
/** Returns an error description of an error that occurred in #Export
/** Returns an error description of an error that occurred in #Export
...
...
hw3d/assimp/include/assimp/GenericProperty.h
0 → 100644
View file @
eb218095
/*
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
hw3d/assimp/include/assimp/Hash.h
0 → 100644
View file @
eb218095
/*
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
hw3d/assimp/include/assimp/IOStream.hpp
View file @
eb218095
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
Open Asset Import Library (assimp)
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2018, assimp team
All rights reserved.
All rights reserved.
...
@@ -70,7 +71,7 @@ class ASSIMP_API IOStream
...
@@ -70,7 +71,7 @@ class ASSIMP_API IOStream
{
{
protected:
protected:
/** Constructor protected, use IOSystem::Open() to create an instance. */
/** Constructor protected, use IOSystem::Open() to create an instance. */
IOStream
(
void
);
IOStream
();
public:
public:
// -------------------------------------------------------------------
// -------------------------------------------------------------------
...
@@ -124,17 +125,18 @@ public:
...
@@ -124,17 +125,18 @@ public:
};
//! class IOStream
};
//! class IOStream
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
inline
IOStream
::
IOStream
()
inline
{
IOStream
::
IOStream
()
{
// empty
// empty
}
}
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
inline
IOStream
::~
IOStream
()
inline
{
IOStream
::~
IOStream
()
{
// empty
// empty
}
}
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
}
//!namespace Assimp
}
//!namespace Assimp
#endif //!!AI_IOSTREAM_H_INC
#endif //!!AI_IOSTREAM_H_INC
hw3d/assimp/include/assimp/IOStreamBuffer.h
0 → 100644
View file @
eb218095
#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
hw3d/assimp/include/assimp/IOSystem.hpp
View file @
eb218095
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
Open Asset Import Library (assimp)
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2018, assimp team
All rights reserved.
All rights reserved.
...
...
hw3d/assimp/include/assimp/Importer.hpp
View file @
eb218095
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
Open Asset Import Library (assimp)
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2018, assimp team
All rights reserved.
All rights reserved.
...
@@ -136,7 +137,12 @@ public:
...
@@ -136,7 +137,12 @@ public:
* If this Importer owns a scene it won't be copied.
* If this Importer owns a scene it won't be copied.
* Call ReadFile() to start the import process.
* Call ReadFile() to start the import process.
*/
*/
Importer
(
const
Importer
&
other
);
Importer
(
const
Importer
&
other
)
=
delete
;
// -------------------------------------------------------------------
/** Assignment operator has been deleted
*/
Importer
&
operator
=
(
const
Importer
&
)
=
delete
;
// -------------------------------------------------------------------
// -------------------------------------------------------------------
/** Destructor. The object kept ownership of the imported data,
/** Destructor. The object kept ownership of the imported data,
...
...
hw3d/assimp/include/assimp/LineSplitter.h
0 → 100644
View file @
eb218095
/*
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.
*/
#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
)
:
idx
(
0
)
,
stream
(
stream
)
,
swallow
()
,
skip_empty_lines
(
skip_empty_lines
)
,
trim
(
trim
)
{
cur
.
reserve
(
1024
);
operator
++
();
idx
=
0
;
}
~
LineSplitter
()
{
// empty
}
public:
// -----------------------------------------
/** pseudo-iterator increment */
LineSplitter
&
operator
++
()
{
if
(
swallow
)
{
swallow
=
false
;
return
*
this
;
}
if
(
!*
this
)
{
throw
std
::
logic_error
(
"End of file, no more lines to be retrieved."
);
}
char
s
;
cur
.
clear
();
while
(
stream
.
GetRemainingSize
()
&&
(
s
=
stream
.
GetI1
(),
1
))
{
if
(
s
==
'\n'
||
s
==
'\r'
)
{
if
(
skip_empty_lines
)
{
while
(
stream
.
GetRemainingSize
()
&&
((
s
=
stream
.
GetI1
())
==
' '
||
s
==
'\r'
||
s
==
'\n'
));
if
(
stream
.
GetRemainingSize
())
{
stream
.
IncPtr
(
-
1
);
}
}
else
{
// skip both potential line terminators but don't read past this line.
if
(
stream
.
GetRemainingSize
()
&&
(
s
==
'\r'
&&
stream
.
GetI1
()
!=
'\n'
))
{
stream
.
IncPtr
(
-
1
);
}
if
(
trim
)
{
while
(
stream
.
GetRemainingSize
()
&&
((
s
=
stream
.
GetI1
())
==
' '
||
s
==
'\t'
));
if
(
stream
.
GetRemainingSize
())
{
stream
.
IncPtr
(
-
1
);
}
}
}
break
;
}
cur
+=
s
;
}
++
idx
;
return
*
this
;
}
// -----------------------------------------
LineSplitter
&
operator
++
(
int
)
{
return
++
(
*
this
);
}
// -----------------------------------------
/** get a pointer to the beginning of a particular token */
const
char
*
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
;
}
// -----------------------------------------
/** extract the start positions of N tokens from the current line*/
template
<
size_t
N
>
void
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
);
}
}
// -----------------------------------------
/** member access */
const
std
::
string
*
operator
->
()
const
{
return
&
cur
;
}
std
::
string
operator
*
()
const
{
return
cur
;
}
// -----------------------------------------
/** boolean context */
operator
bool
()
const
{
return
stream
.
GetRemainingSize
()
>
0
;
}
// -----------------------------------------
/** line indices are zero-based, empty lines are included */
operator
line_idx
()
const
{
return
idx
;
}
line_idx
get_index
()
const
{
return
idx
;
}
// -----------------------------------------
/** access the underlying stream object */
StreamReaderLE
&
get_stream
()
{
return
stream
;
}
// -----------------------------------------
/** !strcmp((*this)->substr(0,strlen(check)),check) */
bool
match_start
(
const
char
*
check
)
{
const
size_t
len
=
strlen
(
check
);
return
len
<=
cur
.
length
()
&&
std
::
equal
(
check
,
check
+
len
,
cur
.
begin
());
}
// -----------------------------------------
/** swallow the next call to ++, return the previous value. */
void
swallow_next_increment
()
{
swallow
=
true
;
}
private:
LineSplitter
(
const
LineSplitter
&
);
LineSplitter
&
operator
=
(
const
LineSplitter
&
);
private:
line_idx
idx
;
std
::
string
cur
;
StreamReaderLE
&
stream
;
bool
swallow
,
skip_empty_lines
,
trim
;
};
}
#endif // INCLUDED_LINE_SPLITTER_H
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment