Merge branch 'master' into bug-3177-dae-geo-id

pull/3188/head
Kim Kulling 2020-05-13 20:24:53 +02:00 committed by GitHub
commit 2571b47a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
137 changed files with 1142 additions and 19715 deletions

View File

@ -1,4 +1,4 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@ -3315,6 +3315,7 @@ void FBXConverter::InterpolateKeys(aiQuatKey *valOut, const KeyTimeList &keys, c
// http://www.3dkingdoms.com/weekly/weekly.php?a=36 // http://www.3dkingdoms.com/weekly/weekly.php?a=36
if (quat.x * lastq.x + quat.y * lastq.y + quat.z * lastq.z + quat.w * lastq.w < 0) { if (quat.x * lastq.x + quat.y * lastq.y + quat.z * lastq.z + quat.w * lastq.w < 0) {
quat.Conjugate(); quat.Conjugate();
quat.w = -quat.w;
} }
lastq = quat; lastq = quat;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,114 +0,0 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2020, 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 ASSIMP_BUILD_NO_STEP_IMPORTER
#include "StepFileImporter.h"
#include "../../Importer/STEPParser/STEPFileReader.h"
#include <assimp/importerdesc.h>
#include <assimp/DefaultIOSystem.h>
namespace Assimp {
namespace StepFile {
using namespace STEP;
static const aiImporterDesc desc = { "StepFile Importer",
"",
"",
"",
0,
0,
0,
0,
0,
"stp" };
StepFileImporter::StepFileImporter()
: BaseImporter() {
}
StepFileImporter::~StepFileImporter() {
}
bool StepFileImporter::CanRead(const std::string& file, IOSystem* pIOHandler, bool checkSig) const {
const std::string &extension = GetExtension(file);
if ( extension == "stp" || extension == "step" ) {
return true;
} else if ((!extension.length() || checkSig) && pIOHandler) {
const char* tokens[] = { "ISO-10303-21" };
const bool found(SearchFileHeaderForToken(pIOHandler, file, tokens, 1));
return found;
}
return false;
}
const aiImporterDesc *StepFileImporter::GetInfo() const {
return &desc;
}
static const std::string mode = "rb";
static const std::string StepFileSchema = "CONFIG_CONTROL_DESIGN";
void StepFileImporter::InternReadFile(const std::string &file, aiScene*, IOSystem* pIOHandler) {
// Read file into memory
std::shared_ptr<IOStream> fileStream(pIOHandler->Open(file, mode));
if (!fileStream.get()) {
throw DeadlyImportError("Failed to open file " + file + ".");
}
std::unique_ptr<STEP::DB> db(STEP::ReadFileHeader(fileStream));
const STEP::HeaderInfo& head = static_cast<const STEP::DB&>(*db).GetHeader();
if (!head.fileSchema.size() || head.fileSchema != StepFileSchema) {
DeadlyImportError("Unrecognized file schema: " + head.fileSchema);
}
}
} // Namespace StepFile
} // Namespace Assimp
#endif // ASSIMP_BUILD_NO_STEP_IMPORTER

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------

View File

@ -1002,7 +1002,7 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
// Valid attribute semantics include POSITION, NORMAL, TANGENT // Valid attribute semantics include POSITION, NORMAL, TANGENT
int undPos = 0; int undPos = 0;
Mesh::AccessorList *vec = 0; Mesh::AccessorList *vec = 0;
if (GetAttribTargetVector(prim, i, attr, vec, undPos)) { if (GetAttribTargetVector(prim, j, attr, vec, undPos)) {
size_t idx = (attr[undPos] == '_') ? atoi(attr + undPos + 1) : 0; size_t idx = (attr[undPos] == '_') ? atoi(attr + undPos + 1) : 0;
if ((*vec).size() <= idx) { if ((*vec).size() <= idx) {
(*vec).resize(idx + 1); (*vec).resize(idx + 1);

View File

@ -1,4 +1,4 @@
/* /*
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
---------------------------------------------------------------------- ----------------------------------------------------------------------

View File

@ -45,10 +45,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "CInterfaceIOWrapper.h" #include "CInterfaceIOWrapper.h"
namespace Assimp { namespace Assimp {
CIOStreamWrapper::~CIOStreamWrapper(void) CIOStreamWrapper::~CIOStreamWrapper(void) {
{
/* Various places depend on this destructor to close the file */ /* Various places depend on this destructor to close the file */
if (mFile) { if (mFile) {
mIO->mFileSystem->CloseProc(mIO->mFileSystem, mFile); mIO->mFileSystem->CloseProc(mIO->mFileSystem, mFile);
@ -57,28 +56,25 @@ CIOStreamWrapper::~CIOStreamWrapper(void)
} }
// ................................................................... // ...................................................................
size_t CIOStreamWrapper::Read(void* pvBuffer, size_t CIOStreamWrapper::Read(void *pvBuffer,
size_t pSize, size_t pSize,
size_t pCount size_t pCount) {
){
// need to typecast here as C has no void* // need to typecast here as C has no void*
return mFile->ReadProc(mFile,(char*)pvBuffer,pSize,pCount); return mFile->ReadProc(mFile, (char *)pvBuffer, pSize, pCount);
} }
// ................................................................... // ...................................................................
size_t CIOStreamWrapper::Write(const void* pvBuffer, size_t CIOStreamWrapper::Write(const void *pvBuffer,
size_t pSize, size_t pSize,
size_t pCount size_t pCount) {
){
// need to typecast here as C has no void* // need to typecast here as C has no void*
return mFile->WriteProc(mFile,(const char*)pvBuffer,pSize,pCount); return mFile->WriteProc(mFile, (const char *)pvBuffer, pSize, pCount);
} }
// ................................................................... // ...................................................................
aiReturn CIOStreamWrapper::Seek(size_t pOffset, aiReturn CIOStreamWrapper::Seek(size_t pOffset,
aiOrigin pOrigin aiOrigin pOrigin) {
){ return mFile->SeekProc(mFile, pOffset, pOrigin);
return mFile->SeekProc(mFile,pOffset,pOrigin);
} }
// ................................................................... // ...................................................................
@ -92,16 +88,16 @@ size_t CIOStreamWrapper::FileSize() const {
} }
// ................................................................... // ...................................................................
void CIOStreamWrapper::Flush () { void CIOStreamWrapper::Flush() {
return mFile->FlushProc(mFile); return mFile->FlushProc(mFile);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Custom IOStream implementation for the C-API // Custom IOStream implementation for the C-API
bool CIOSystemWrapper::Exists( const char* pFile) const { bool CIOSystemWrapper::Exists(const char *pFile) const {
aiFile* p = mFileSystem->OpenProc(mFileSystem,pFile,"rb"); aiFile *p = mFileSystem->OpenProc(mFileSystem, pFile, "rb");
if (p){ if (p) {
mFileSystem->CloseProc(mFileSystem,p); mFileSystem->CloseProc(mFileSystem, p);
return true; return true;
} }
return false; return false;
@ -117,8 +113,8 @@ char CIOSystemWrapper::getOsSeparator() const {
} }
// ................................................................... // ...................................................................
IOStream* CIOSystemWrapper::Open(const char* pFile,const char* pMode) { IOStream *CIOSystemWrapper::Open(const char *pFile, const char *pMode) {
aiFile* p = mFileSystem->OpenProc(mFileSystem,pFile,pMode); aiFile *p = mFileSystem->OpenProc(mFileSystem, pFile, pMode);
if (!p) { if (!p) {
return NULL; return NULL;
} }
@ -126,11 +122,11 @@ IOStream* CIOSystemWrapper::Open(const char* pFile,const char* pMode) {
} }
// ................................................................... // ...................................................................
void CIOSystemWrapper::Close( IOStream* pFile) { void CIOSystemWrapper::Close(IOStream *pFile) {
if (!pFile) { if (!pFile) {
return; return;
} }
delete pFile; delete pFile;
} }
} } // namespace Assimp

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -50,50 +48,47 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOStream.hpp> #include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
namespace Assimp { namespace Assimp {
class CIOSystemWrapper; class CIOSystemWrapper;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Custom IOStream implementation for the C-API // Custom IOStream implementation for the C-API
class CIOStreamWrapper : public IOStream class CIOStreamWrapper : public IOStream {
{
public: public:
explicit CIOStreamWrapper(aiFile* pFile, CIOSystemWrapper* io) explicit CIOStreamWrapper(aiFile *pFile, CIOSystemWrapper *io) :
: mFile(pFile), mFile(pFile),
mIO(io) mIO(io) {}
{}
~CIOStreamWrapper(void); ~CIOStreamWrapper(void);
size_t Read(void* pvBuffer, size_t pSize, size_t pCount); size_t Read(void *pvBuffer, size_t pSize, size_t pCount);
size_t Write(const void* pvBuffer, size_t pSize, size_t pCount); size_t Write(const void *pvBuffer, size_t pSize, size_t pCount);
aiReturn Seek(size_t pOffset, aiOrigin pOrigin); aiReturn Seek(size_t pOffset, aiOrigin pOrigin);
size_t Tell(void) const; size_t Tell(void) const;
size_t FileSize() const; size_t FileSize() const;
void Flush(); void Flush();
private: private:
aiFile* mFile; aiFile *mFile;
CIOSystemWrapper* mIO; CIOSystemWrapper *mIO;
}; };
class CIOSystemWrapper : public IOSystem class CIOSystemWrapper : public IOSystem {
{
friend class CIOStreamWrapper; friend class CIOStreamWrapper;
public:
explicit CIOSystemWrapper(aiFileIO* pFile)
: mFileSystem(pFile)
{}
bool Exists( const char* pFile) const; public:
explicit CIOSystemWrapper(aiFileIO *pFile) :
mFileSystem(pFile) {}
bool Exists(const char *pFile) const;
char getOsSeparator() const; char getOsSeparator() const;
IOStream* Open(const char* pFile,const char* pMode = "rb"); IOStream *Open(const char *pFile, const char *pMode = "rb");
void Close( IOStream* pFile); void Close(IOStream *pFile);
private: private:
aiFileIO* mFileSystem; aiFileIO *mFileSystem;
}; };
} } // namespace Assimp
#endif #endif

View File

@ -1233,7 +1233,7 @@ if (APPLE)
# add ./Compiler/*.h to assimp.framework via copy command # add ./Compiler/*.h to assimp.framework via copy command
ADD_CUSTOM_COMMAND(TARGET assimp POST_BUILD ADD_CUSTOM_COMMAND(TARGET assimp POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_directory COMMAND "${CMAKE_COMMAND}" -E copy_directory
"../${HEADER_PATH}/Compiler" "${HEADER_PATH}/Compiler"
assimp.framework/Headers/Compiler assimp.framework/Headers/Compiler
COMMENT "Copying public ./Compiler/ header files to framework bundle's Headers/Compiler/") COMMENT "Copying public ./Compiler/ header files to framework bundle's Headers/Compiler/")
ENDIF() ENDIF()

View File

@ -1,4 +1,4 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <limits> #include <limits>
#include <assimp/TinyFormatter.h> #include <assimp/TinyFormatter.h>
#include <assimp/Exceptional.h> #include <assimp/Exceptional.h>
#include <set>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Formatter; using namespace Assimp::Formatter;
@ -172,7 +173,15 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
const aiBone* bone = pMesh->mBones[a]; const aiBone* bone = pMesh->mBones[a];
for( unsigned int b = 0; b < bone->mNumWeights; ++b) for( unsigned int b = 0; b < bone->mNumWeights; ++b)
{ {
vertexBones[ bone->mWeights[b].mVertexId ].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); if (bone->mWeights[b].mWeight > 0.0f)
{
int vertexId = bone->mWeights[b].mVertexId;
vertexBones[vertexId].push_back( BoneWeight( a, bone->mWeights[b].mWeight));
if (vertexBones[vertexId].size() > mMaxBoneCount)
{
throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!");
}
}
} }
} }
@ -188,9 +197,6 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
subMeshFaces.reserve( pMesh->mNumFaces); subMeshFaces.reserve( pMesh->mNumFaces);
// accumulated vertex count of all the faces in this submesh // accumulated vertex count of all the faces in this submesh
unsigned int numSubMeshVertices = 0; unsigned int numSubMeshVertices = 0;
// a small local array of new bones for the current face. State of all used bones for that face
// can only be updated AFTER the face is completely analysed. Thanks to imre for the fix.
std::vector<unsigned int> newBonesAtCurrentFace;
// add faces to the new submesh as long as all bones affecting the faces' vertices fit in the limit // add faces to the new submesh as long as all bones affecting the faces' vertices fit in the limit
for( unsigned int a = 0; a < pMesh->mNumFaces; ++a) for( unsigned int a = 0; a < pMesh->mNumFaces; ++a)
@ -200,33 +206,25 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
{ {
continue; continue;
} }
// a small local set of new bones for the current face. State of all used bones for that face
// can only be updated AFTER the face is completely analysed. Thanks to imre for the fix.
std::set<unsigned int> newBonesAtCurrentFace;
const aiFace& face = pMesh->mFaces[a]; const aiFace& face = pMesh->mFaces[a];
// check every vertex if its bones would still fit into the current submesh // check every vertex if its bones would still fit into the current submesh
for( unsigned int b = 0; b < face.mNumIndices; ++b ) for( unsigned int b = 0; b < face.mNumIndices; ++b )
{ {
const std::vector<BoneWeight>& vb = vertexBones[face.mIndices[b]]; const std::vector<BoneWeight>& vb = vertexBones[face.mIndices[b]];
for( unsigned int c = 0; c < vb.size(); ++c) for( unsigned int c = 0; c < vb.size(); ++c)
{
unsigned int boneIndex = vb[c].first;
if( !isBoneUsed[boneIndex] )
{ {
unsigned int boneIndex = vb[c].first; newBonesAtCurrentFace.insert(boneIndex);
// if the bone is already used in this submesh, it's ok
if( isBoneUsed[boneIndex] )
{
continue;
}
// if it's not used, yet, we would need to add it. Store its bone index
if( std::find( newBonesAtCurrentFace.begin(), newBonesAtCurrentFace.end(), boneIndex) == newBonesAtCurrentFace.end() )
{
newBonesAtCurrentFace.push_back( boneIndex);
}
} }
}
} }
if (newBonesAtCurrentFace.size() > mMaxBoneCount)
{
throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!");
}
// leave out the face if the new bones required for this face don't fit the bone count limit anymore // leave out the face if the new bones required for this face don't fit the bone count limit anymore
if( numBones + newBonesAtCurrentFace.size() > mMaxBoneCount ) if( numBones + newBonesAtCurrentFace.size() > mMaxBoneCount )
{ {
@ -234,17 +232,13 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
} }
// mark all new bones as necessary // mark all new bones as necessary
while( !newBonesAtCurrentFace.empty() ) for (std::set<unsigned int>::iterator it = newBonesAtCurrentFace.begin(); it != newBonesAtCurrentFace.end(); ++it)
{ {
unsigned int newIndex = newBonesAtCurrentFace.back(); if (!isBoneUsed[*it])
newBonesAtCurrentFace.pop_back(); // this also avoids the deallocation which comes with a clear() {
if( isBoneUsed[newIndex] ) isBoneUsed[*it] = true;
{
continue;
}
isBoneUsed[newIndex] = true;
numBones++; numBones++;
}
} }
// store the face index and the vertex count // store the face index and the vertex count

View File

@ -1,4 +1,4 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/* /*
Copyright (c) 2013 Khaled Mammou - Advanced Micro Devices, Inc. Copyright (c) 2013 Khaled Mammou - Advanced Micro Devices, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy

View File

@ -1,4 +1,4 @@
================== ==================
INSTALLATION GUIDE INSTALLATION GUIDE
================== ==================

View File

@ -196,10 +196,7 @@ if(MINGW)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW) endif(MINGW)
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set_target_properties(zlib PROPERTIES SOVERSION 1)
INSTALL( TARGETS zlibstatic INSTALL( TARGETS zlibstatic
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -40,30 +38,19 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#pragma once extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataSize) {
aiLogStream stream = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL);
aiAttachLogStream(&stream);
#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER Importer importer;
const aiScene *sc = importer.ReadFileFromMemory(data, dataSize,
aiProcessPreset_TargetRealtime_Quality, nullptr );
#include <assimp/BaseImporter.h> aiDetachLogStream(&stream);
namespace Assimp { return 0;
namespace StepFile { }
class StepFileImporter : public BaseImporter {
public:
StepFileImporter();
~StepFileImporter();
bool CanRead(const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const override;
const aiImporterDesc* GetInfo() const override;
protected:
void InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler ) override;
private:
};
} // Namespace StepFile
} // Namespace Assimp
#endif // ASSIMP_BUILD_NO_STEP_IMPORTER

View File

@ -1,4 +1,4 @@
/* /*
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Open Asset Import Library (assimp) Open Asset Import Library (assimp)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@ -4,5 +4,3 @@ http://assimp.sourceforge.net
Sourceforge.net project page: Sourceforge.net project page:
http://www.sourceforge.net/projects/assimp http://www.sourceforge.net/projects/assimp

View File

@ -1,4 +1,4 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Simple Assimp Directx11 Sample // Simple Assimp Directx11 Sample
// This is a very basic sample and only reads diffuse texture // This is a very basic sample and only reads diffuse texture
// but this can load both embedded textures in fbx and non-embedded textures // but this can load both embedded textures in fbx and non-embedded textures

View File

@ -65,8 +65,7 @@ void TriangulateProcessTest::SetUp() {
pcMesh->mFaces = new aiFace[1000]; pcMesh->mFaces = new aiFace[1000];
pcMesh->mVertices = new aiVector3D[10000]; pcMesh->mVertices = new aiVector3D[10000];
pcMesh->mPrimitiveTypes = aiPrimitiveType_POINT | aiPrimitiveType_LINE | pcMesh->mPrimitiveTypes = aiPrimitiveType_POINT | aiPrimitiveType_LINE | aiPrimitiveType_POLYGON;
aiPrimitiveType_LINE | aiPrimitiveType_POLYGON;
for (unsigned int m = 0, t = 0, q = 4; m < 1000; ++m) { for (unsigned int m = 0, t = 0, q = 4; m < 1000; ++m) {
++t; ++t;

View File

@ -47,10 +47,11 @@ using namespace AssimpView;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor on a given animation. // Constructor on a given animation.
AnimEvaluator::AnimEvaluator( const aiAnimation *pAnim ) AnimEvaluator::AnimEvaluator(const aiAnimation *pAnim) :
: mAnim(pAnim) mAnim(pAnim),
, mLastTime(0.0) { mLastTime(0.0) {
mLastPositions.resize( pAnim->mNumChannels, std::make_tuple( 0, 0, 0)); ai_assert(nullptr != pAnim);
mLastPositions.resize(pAnim->mNumChannels, std::make_tuple(0, 0, 0));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -61,7 +62,7 @@ AnimEvaluator::~AnimEvaluator() {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Evaluates the animation tracks for a given time stamp. // Evaluates the animation tracks for a given time stamp.
void AnimEvaluator::Evaluate( double pTime ) { void AnimEvaluator::Evaluate(double pTime) {
// extract ticks per second. Assume default value if not given // extract ticks per second. Assume default value if not given
double ticksPerSecond = mAnim->mTicksPerSecond != 0.0 ? mAnim->mTicksPerSecond : 25.0; double ticksPerSecond = mAnim->mTicksPerSecond != 0.0 ? mAnim->mTicksPerSecond : 25.0;
// every following time calculation happens in ticks // every following time calculation happens in ticks
@ -78,16 +79,16 @@ void AnimEvaluator::Evaluate( double pTime ) {
} }
// calculate the transformations for each animation channel // calculate the transformations for each animation channel
for( unsigned int a = 0; a < mAnim->mNumChannels; ++a ) { for (unsigned int a = 0; a < mAnim->mNumChannels; ++a) {
const aiNodeAnim* channel = mAnim->mChannels[a]; const aiNodeAnim *channel = mAnim->mChannels[a];
// ******** Position ***** // ******** Position *****
aiVector3D presentPosition( 0, 0, 0); aiVector3D presentPosition(0, 0, 0);
if( channel->mNumPositionKeys > 0) { if (channel->mNumPositionKeys > 0) {
// Look for present frame number. Search from last position if time is after the last time, else from beginning // Look for present frame number. Search from last position if time is after the last time, else from beginning
// Should be much quicker than always looking from start for the average use case. // Should be much quicker than always looking from start for the average use case.
unsigned int frame = (time >= mLastTime) ? std::get<0>(mLastPositions[a]) : 0; unsigned int frame = (time >= mLastTime) ? std::get<0>(mLastPositions[a]) : 0;
while( frame < channel->mNumPositionKeys - 1) { while (frame < channel->mNumPositionKeys - 1) {
if (time < channel->mPositionKeys[frame + 1].mTime) { if (time < channel->mPositionKeys[frame + 1].mTime) {
break; break;
} }
@ -96,14 +97,14 @@ void AnimEvaluator::Evaluate( double pTime ) {
// interpolate between this frame's value and next frame's value // interpolate between this frame's value and next frame's value
unsigned int nextFrame = (frame + 1) % channel->mNumPositionKeys; unsigned int nextFrame = (frame + 1) % channel->mNumPositionKeys;
const aiVectorKey& key = channel->mPositionKeys[frame]; const aiVectorKey &key = channel->mPositionKeys[frame];
const aiVectorKey& nextKey = channel->mPositionKeys[nextFrame]; const aiVectorKey &nextKey = channel->mPositionKeys[nextFrame];
double diffTime = nextKey.mTime - key.mTime; double diffTime = nextKey.mTime - key.mTime;
if (diffTime < 0.0) { if (diffTime < 0.0) {
diffTime += mAnim->mDuration; diffTime += mAnim->mDuration;
} }
if( diffTime > 0) { if (diffTime > 0) {
float factor = float( (time - key.mTime) / diffTime); float factor = float((time - key.mTime) / diffTime);
presentPosition = key.mValue + (nextKey.mValue - key.mValue) * factor; presentPosition = key.mValue + (nextKey.mValue - key.mValue) * factor;
} else { } else {
presentPosition = key.mValue; presentPosition = key.mValue;
@ -113,10 +114,10 @@ void AnimEvaluator::Evaluate( double pTime ) {
} }
// ******** Rotation ********* // ******** Rotation *********
aiQuaternion presentRotation( 1, 0, 0, 0); aiQuaternion presentRotation(1, 0, 0, 0);
if( channel->mNumRotationKeys > 0) { if (channel->mNumRotationKeys > 0) {
unsigned int frame = (time >= mLastTime) ? std::get<1>(mLastPositions[a]) : 0; unsigned int frame = (time >= mLastTime) ? std::get<1>(mLastPositions[a]) : 0;
while( frame < channel->mNumRotationKeys - 1) { while (frame < channel->mNumRotationKeys - 1) {
if (time < channel->mRotationKeys[frame + 1].mTime) { if (time < channel->mRotationKeys[frame + 1].mTime) {
break; break;
} }
@ -125,15 +126,15 @@ void AnimEvaluator::Evaluate( double pTime ) {
// interpolate between this frame's value and next frame's value // interpolate between this frame's value and next frame's value
unsigned int nextFrame = (frame + 1) % channel->mNumRotationKeys; unsigned int nextFrame = (frame + 1) % channel->mNumRotationKeys;
const aiQuatKey& key = channel->mRotationKeys[frame]; const aiQuatKey &key = channel->mRotationKeys[frame];
const aiQuatKey& nextKey = channel->mRotationKeys[nextFrame]; const aiQuatKey &nextKey = channel->mRotationKeys[nextFrame];
double diffTime = nextKey.mTime - key.mTime; double diffTime = nextKey.mTime - key.mTime;
if (diffTime < 0.0) { if (diffTime < 0.0) {
diffTime += mAnim->mDuration; diffTime += mAnim->mDuration;
} }
if( diffTime > 0) { if (diffTime > 0) {
float factor = float( (time - key.mTime) / diffTime); float factor = float((time - key.mTime) / diffTime);
aiQuaternion::Interpolate( presentRotation, key.mValue, nextKey.mValue, factor); aiQuaternion::Interpolate(presentRotation, key.mValue, nextKey.mValue, factor);
} else { } else {
presentRotation = key.mValue; presentRotation = key.mValue;
} }
@ -142,10 +143,10 @@ void AnimEvaluator::Evaluate( double pTime ) {
} }
// ******** Scaling ********** // ******** Scaling **********
aiVector3D presentScaling( 1, 1, 1); aiVector3D presentScaling(1, 1, 1);
if( channel->mNumScalingKeys > 0) { if (channel->mNumScalingKeys > 0) {
unsigned int frame = (time >= mLastTime) ? std::get<2>(mLastPositions[a]) : 0; unsigned int frame = (time >= mLastTime) ? std::get<2>(mLastPositions[a]) : 0;
while( frame < channel->mNumScalingKeys - 1) { while (frame < channel->mNumScalingKeys - 1) {
if (time < channel->mScalingKeys[frame + 1].mTime) { if (time < channel->mScalingKeys[frame + 1].mTime) {
break; break;
} }
@ -158,12 +159,20 @@ void AnimEvaluator::Evaluate( double pTime ) {
} }
// build a transformation matrix from it // build a transformation matrix from it
aiMatrix4x4& mat = mTransforms[a]; aiMatrix4x4 &mat = mTransforms[a];
mat = aiMatrix4x4( presentRotation.GetMatrix()); mat = aiMatrix4x4(presentRotation.GetMatrix());
mat.a1 *= presentScaling.x; mat.b1 *= presentScaling.x; mat.c1 *= presentScaling.x; mat.a1 *= presentScaling.x;
mat.a2 *= presentScaling.y; mat.b2 *= presentScaling.y; mat.c2 *= presentScaling.y; mat.b1 *= presentScaling.x;
mat.a3 *= presentScaling.z; mat.b3 *= presentScaling.z; mat.c3 *= presentScaling.z; mat.c1 *= presentScaling.x;
mat.a4 = presentPosition.x; mat.b4 = presentPosition.y; mat.c4 = presentPosition.z; mat.a2 *= presentScaling.y;
mat.b2 *= presentScaling.y;
mat.c2 *= presentScaling.y;
mat.a3 *= presentScaling.z;
mat.b3 *= presentScaling.z;
mat.c3 *= presentScaling.z;
mat.a4 = presentPosition.x;
mat.b4 = presentPosition.y;
mat.c4 = presentPosition.z;
} }
mLastTime = time; mLastTime = time;

View File

@ -58,7 +58,7 @@ public:
/// the object. /// the object.
/// @param pAnim The animation to calculate poses for. Ownership of the animation object stays /// @param pAnim The animation to calculate poses for. Ownership of the animation object stays
/// at the caller, the evaluator just keeps a reference to it as long as it persists. /// at the caller, the evaluator just keeps a reference to it as long as it persists.
AnimEvaluator( const aiAnimation* pAnim); AnimEvaluator(const aiAnimation *pAnim);
/// @brief The class destructor. /// @brief The class destructor.
~AnimEvaluator(); ~AnimEvaluator();
@ -68,16 +68,16 @@ public:
* @param pTime The time for which you want to evaluate the animation, in seconds. Will be mapped into the animation cycle, so * @param pTime The time for which you want to evaluate the animation, in seconds. Will be mapped into the animation cycle, so
* it can be an arbitrary value. Best use with ever-increasing time stamps. * it can be an arbitrary value. Best use with ever-increasing time stamps.
*/ */
void Evaluate( double pTime); void Evaluate(double pTime);
/** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of /** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of
* the aiAnimation. */ * the aiAnimation. */
const std::vector<aiMatrix4x4>& GetTransformations() const { return mTransforms; } const std::vector<aiMatrix4x4> &GetTransformations() const { return mTransforms; }
protected: protected:
const aiAnimation* mAnim; const aiAnimation *mAnim;
double mLastTime; double mLastTime;
std::vector<std::tuple<unsigned int, unsigned int, unsigned int> > mLastPositions; std::vector<std::tuple<unsigned int, unsigned int, unsigned int>> mLastPositions;
std::vector<aiMatrix4x4> mTransforms; std::vector<aiMatrix4x4> mTransforms;
}; };

View File

@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
#if (!defined AV_ASSET_HELPER_H_INCLUDED) #if (!defined AV_ASSET_HELPER_H_INCLUDED)
#define AV_ASSET_HELPER_H_INCLUDED #define AV_ASSET_HELPER_H_INCLUDED
@ -51,200 +50,187 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace AssimpView { namespace AssimpView {
class SceneAnimator; class SceneAnimator;
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
/** \brief Class to wrap ASSIMP's asset output structures /** \brief Class to wrap ASSIMP's asset output structures
*/ */
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
class AssetHelper class AssetHelper {
{ public:
public: enum {
enum // the original normal set will be used
{ ORIGINAL = 0x0u,
// the original normal set will be used
ORIGINAL = 0x0u,
// a smoothed normal set will be used // a smoothed normal set will be used
SMOOTH = 0x1u, SMOOTH = 0x1u,
// a hard normal set will be used // a hard normal set will be used
HARD = 0x2u, HARD = 0x2u,
}; };
// default constructor // default constructor
AssetHelper() AssetHelper() :
: iNormalSet( ORIGINAL ) iNormalSet(ORIGINAL) {
{ mAnimator = NULL;
mAnimator = NULL; apcMeshes = NULL;
apcMeshes = NULL; pcScene = NULL;
pcScene = NULL; }
//---------------------------------------------------------------
// default vertex data structure
// (even if tangents, bitangents or normals aren't
// required by the shader they will be committed to the GPU)
//---------------------------------------------------------------
struct Vertex {
aiVector3D vPosition;
aiVector3D vNormal;
D3DCOLOR dColorDiffuse;
aiVector3D vTangent;
aiVector3D vBitangent;
aiVector2D vTextureUV;
aiVector2D vTextureUV2;
unsigned char mBoneIndices[4];
unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
/** Returns the vertex declaration elements to create a declaration from. */
static D3DVERTEXELEMENT9 *GetDeclarationElements() {
static D3DVERTEXELEMENT9 decl[] = {
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
D3DDECL_END()
};
return decl;
} }
};
//--------------------------------------------------------------- //---------------------------------------------------------------
// default vertex data structure // FVF vertex structure used for normals
// (even if tangents, bitangents or normals aren't //---------------------------------------------------------------
// required by the shader they will be committed to the GPU) struct LineVertex {
//--------------------------------------------------------------- aiVector3D vPosition;
struct Vertex DWORD dColorDiffuse;
{
aiVector3D vPosition;
aiVector3D vNormal;
D3DCOLOR dColorDiffuse; // retrieves the FVF code of the vertex type
aiVector3D vTangent; static DWORD GetFVF() {
aiVector3D vBitangent; return D3DFVF_DIFFUSE | D3DFVF_XYZ;
aiVector2D vTextureUV; }
aiVector2D vTextureUV2; };
unsigned char mBoneIndices[ 4 ];
unsigned char mBoneWeights[ 4 ]; // last Weight not used, calculated inside the vertex shader
/** Returns the vertex declaration elements to create a declaration from. */ //---------------------------------------------------------------
static D3DVERTEXELEMENT9* GetDeclarationElements() // Helper class to store GPU related resources created for
{ // a given aiMesh
static D3DVERTEXELEMENT9 decl[] = //---------------------------------------------------------------
{ class MeshHelper {
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, public:
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, MeshHelper() :
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
D3DDECL_END()
};
return decl;
}
};
//---------------------------------------------------------------
// FVF vertex structure used for normals
//---------------------------------------------------------------
struct LineVertex
{
aiVector3D vPosition;
DWORD dColorDiffuse;
// retrieves the FVF code of the vertex type
static DWORD GetFVF()
{
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
}
};
//---------------------------------------------------------------
// Helper class to store GPU related resources created for
// a given aiMesh
//---------------------------------------------------------------
class MeshHelper
{
public:
MeshHelper()
:
eShadingMode(), eShadingMode(),
piVB( NULL ), piVB(NULL),
piIB( NULL ), piIB(NULL),
piVBNormals( NULL ), piVBNormals(NULL),
piEffect( NULL ), piEffect(NULL),
bSharedFX( false ), bSharedFX(false),
piDiffuseTexture( NULL ), piDiffuseTexture(NULL),
piSpecularTexture( NULL ), piSpecularTexture(NULL),
piAmbientTexture( NULL ), piAmbientTexture(NULL),
piEmissiveTexture( NULL ), piEmissiveTexture(NULL),
piNormalTexture( NULL ), piNormalTexture(NULL),
piOpacityTexture( NULL ), piOpacityTexture(NULL),
piShininessTexture( NULL ), piShininessTexture(NULL),
piLightmapTexture( NULL ), piLightmapTexture(NULL),
fOpacity(), fOpacity(),
fShininess(), fShininess(),
fSpecularStrength(), fSpecularStrength(),
twosided( false ), twosided(false),
pvOriginalNormals( NULL ) pvOriginalNormals(NULL) {}
{}
~MeshHelper() ~MeshHelper() {
{ // NOTE: This is done in DeleteAssetData()
// NOTE: This is done in DeleteAssetData() // TODO: Make this a proper d'tor
// TODO: Make this a proper d'tor }
}
// shading mode to use. Either Lambert or otherwise phong // shading mode to use. Either Lambert or otherwise phong
// will be used in every case // will be used in every case
aiShadingMode eShadingMode; aiShadingMode eShadingMode;
// vertex buffer // vertex buffer
IDirect3DVertexBuffer9* piVB; IDirect3DVertexBuffer9 *piVB;
// index buffer. For partially transparent meshes // index buffer. For partially transparent meshes
// created with dynamic usage to be able to update // created with dynamic usage to be able to update
// the buffer contents quickly // the buffer contents quickly
IDirect3DIndexBuffer9* piIB; IDirect3DIndexBuffer9 *piIB;
// vertex buffer to be used to draw vertex normals // vertex buffer to be used to draw vertex normals
// (vertex normals are generated in every case) // (vertex normals are generated in every case)
IDirect3DVertexBuffer9* piVBNormals; IDirect3DVertexBuffer9 *piVBNormals;
// shader to be used // shader to be used
ID3DXEffect* piEffect; ID3DXEffect *piEffect;
bool bSharedFX; bool bSharedFX;
// material textures // material textures
IDirect3DTexture9* piDiffuseTexture; IDirect3DTexture9 *piDiffuseTexture;
IDirect3DTexture9* piSpecularTexture; IDirect3DTexture9 *piSpecularTexture;
IDirect3DTexture9* piAmbientTexture; IDirect3DTexture9 *piAmbientTexture;
IDirect3DTexture9* piEmissiveTexture; IDirect3DTexture9 *piEmissiveTexture;
IDirect3DTexture9* piNormalTexture; IDirect3DTexture9 *piNormalTexture;
IDirect3DTexture9* piOpacityTexture; IDirect3DTexture9 *piOpacityTexture;
IDirect3DTexture9* piShininessTexture; IDirect3DTexture9 *piShininessTexture;
IDirect3DTexture9* piLightmapTexture; IDirect3DTexture9 *piLightmapTexture;
// material colors // material colors
D3DXVECTOR4 vDiffuseColor; D3DXVECTOR4 vDiffuseColor;
D3DXVECTOR4 vSpecularColor; D3DXVECTOR4 vSpecularColor;
D3DXVECTOR4 vAmbientColor; D3DXVECTOR4 vAmbientColor;
D3DXVECTOR4 vEmissiveColor; D3DXVECTOR4 vEmissiveColor;
// opacity for the material // opacity for the material
float fOpacity; float fOpacity;
// shininess for the material // shininess for the material
float fShininess; float fShininess;
// strength of the specular highlight // strength of the specular highlight
float fSpecularStrength; float fSpecularStrength;
// two-sided? // two-sided?
bool twosided; bool twosided;
// Stores a pointer to the original normal set of the asset // Stores a pointer to the original normal set of the asset
aiVector3D* pvOriginalNormals; aiVector3D *pvOriginalNormals;
};
// One instance per aiMesh in the globally loaded asset
MeshHelper** apcMeshes;
// Scene wrapper instance
aiScene* pcScene;
// Animation player to animate the scene if necessary
SceneAnimator* mAnimator;
// Specifies the normal set to be used
unsigned int iNormalSet;
// ------------------------------------------------------------------
// set the normal set to be used
void SetNormalSet( unsigned int iSet );
// ------------------------------------------------------------------
// flip all normal vectors
void FlipNormals();
void FlipNormalsInt();
}; };
}
// One instance per aiMesh in the globally loaded asset
MeshHelper **apcMeshes;
// Scene wrapper instance
aiScene *pcScene;
// Animation player to animate the scene if necessary
SceneAnimator *mAnimator;
// Specifies the normal set to be used
unsigned int iNormalSet;
// ------------------------------------------------------------------
// set the normal set to be used
void SetNormalSet(unsigned int iSet);
// ------------------------------------------------------------------
// flip all normal vectors
void FlipNormals();
void FlipNormalsInt();
};
} // namespace AssimpView
#endif // !! IG #endif // !! IG

View File

@ -118,8 +118,9 @@ CBackgroundPainter CBackgroundPainter::s_cInstance;
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
void CBackgroundPainter::SetColor(D3DCOLOR p_clrNew) { void CBackgroundPainter::SetColor(D3DCOLOR p_clrNew) {
if (TEXTURE_CUBE == eMode) if (TEXTURE_CUBE == eMode) {
RemoveSBDeps(); RemoveSBDeps();
}
clrColor = p_clrNew; clrColor = p_clrNew;
eMode = SIMPLE_COLOR; eMode = SIMPLE_COLOR;

View File

@ -45,164 +45,154 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AssetHelper.h" #include "AssetHelper.h"
namespace AssimpView namespace AssimpView {
{
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
/* Helper class to create, access and destroy materials /* Helper class to create, access and destroy materials
*/ */
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
class CMaterialManager class CMaterialManager {
{ private:
private: friend class CDisplay;
friend class CDisplay; // default constructor
CMaterialManager() :
m_iShaderCount(0), sDefaultTexture() {}
// default constructor ~CMaterialManager() {
CMaterialManager() if (sDefaultTexture) {
: m_iShaderCount( 0 ), sDefaultTexture() {} sDefaultTexture->Release();
~CMaterialManager() {
if( sDefaultTexture ) {
sDefaultTexture->Release();
}
Reset();
} }
Reset();
}
public: public:
//------------------------------------------------------------------
// Singleton accessors
static CMaterialManager s_cInstance;
inline static CMaterialManager &Instance() {
return s_cInstance;
}
//------------------------------------------------------------------ //------------------------------------------------------------------
// Singleton accessors // Delete all resources of a given material
static CMaterialManager s_cInstance; //
inline static CMaterialManager& Instance() // Must be called before CreateMaterial() to prevent memory leaking
{ void DeleteMaterial(AssetHelper::MeshHelper *pcIn);
return s_cInstance;
//------------------------------------------------------------------
// Create the material for a mesh.
//
// The function checks whether an identical shader is already in use.
// A shader is considered to be identical if it has the same input
// signature and takes the same number of texture channels.
int CreateMaterial(AssetHelper::MeshHelper *pcMesh,
const aiMesh *pcSource);
//------------------------------------------------------------------
// Setup the material for a given mesh
// pcMesh Mesh to be rendered
// pcProj Projection matrix
// aiMe Current world matrix
// pcCam Camera matrix
// vPos Position of the camera
// TODO: Extract camera position from matrix ...
//
int SetupMaterial(AssetHelper::MeshHelper *pcMesh,
const aiMatrix4x4 &pcProj,
const aiMatrix4x4 &aiMe,
const aiMatrix4x4 &pcCam,
const aiVector3D &vPos);
//------------------------------------------------------------------
// End the material for a given mesh
// Called after mesh rendering is complete
// pcMesh Mesh object
int EndMaterial(AssetHelper::MeshHelper *pcMesh);
//------------------------------------------------------------------
// Recreate all specular materials depending on the current
// specularity settings
//
// Diffuse-only materials are ignored.
// Must be called after specular highlights have been toggled
int UpdateSpecularMaterials();
//------------------------------------------------------------------
// find a valid path to a texture file
//
// Handle 8.3 syntax correctly, search the environment of the
// executable and the asset for a texture with a name very similar
// to a given one
int FindValidPath(aiString *p_szString);
//------------------------------------------------------------------
// Load a texture into memory and create a native D3D texture resource
//
// The function tries to find a valid path for a texture
int LoadTexture(IDirect3DTexture9 **p_ppiOut, aiString *szPath);
//------------------------------------------------------------------
// Getter for m_iShaderCount
//
inline unsigned int GetShaderCount() {
return this->m_iShaderCount;
}
//------------------------------------------------------------------
// Reset the state of the class
// Called whenever a new asset is loaded
inline void Reset() {
this->m_iShaderCount = 0;
for (TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it) {
(*it).second->Release();
} }
sCachedTextures.clear();
}
//------------------------------------------------------------------ private:
// Delete all resources of a given material //------------------------------------------------------------------
// // find a valid path to a texture file
// Must be called before CreateMaterial() to prevent memory leaking //
void DeleteMaterial( AssetHelper::MeshHelper* pcIn ); // Handle 8.3 syntax correctly, search the environment of the
// executable and the asset for a texture with a name very similar
// to a given one
bool TryLongerPath(char *szTemp, aiString *p_szString);
//------------------------------------------------------------------ //------------------------------------------------------------------
// Create the material for a mesh. // Setup the default texture for a texture channel
// //
// The function checks whether an identical shader is already in use. // Generates a default checker pattern for a texture
// A shader is considered to be identical if it has the same input int SetDefaultTexture(IDirect3DTexture9 **p_ppiOut);
// signature and takes the same number of texture channels.
int CreateMaterial( AssetHelper::MeshHelper* pcMesh,
const aiMesh* pcSource );
//------------------------------------------------------------------ //------------------------------------------------------------------
// Setup the material for a given mesh // Convert a height map to a normal map if necessary
// pcMesh Mesh to be rendered //
// pcProj Projection matrix // The function tries to detect the type of a texture automatically.
// aiMe Current world matrix // However, this won't work in every case.
// pcCam Camera matrix void HMtoNMIfNecessary(IDirect3DTexture9 *piTexture,
// vPos Position of the camera IDirect3DTexture9 **piTextureOut,
// TODO: Extract camera position from matrix ... bool bWasOriginallyHM = true);
//
int SetupMaterial( AssetHelper::MeshHelper* pcMesh,
const aiMatrix4x4& pcProj,
const aiMatrix4x4& aiMe,
const aiMatrix4x4& pcCam,
const aiVector3D& vPos );
//------------------------------------------------------------------ //------------------------------------------------------------------
// End the material for a given mesh // Search for non-opaque pixels in a texture
// Called after mesh rendering is complete //
// pcMesh Mesh object // A pixel is considered to be non-opaque if its alpha value is
int EndMaterial( AssetHelper::MeshHelper* pcMesh ); // less than 255
//------------------------------------------------------------------
bool HasAlphaPixels(IDirect3DTexture9 *piTexture);
//------------------------------------------------------------------ private:
// Recreate all specular materials depending on the current //
// specularity settings // Specifies the number of different shaders generated for
// // the current asset. This number is incremented by CreateMaterial()
// Diffuse-only materials are ignored. // each time a shader isn't found in cache and needs to be created
// Must be called after specular highlights have been toggled //
int UpdateSpecularMaterials(); unsigned int m_iShaderCount;
IDirect3DTexture9 *sDefaultTexture;
//------------------------------------------------------------------ typedef std::map<std::string, IDirect3DTexture9 *> TextureCache;
// find a valid path to a texture file TextureCache sCachedTextures;
// };
// Handle 8.3 syntax correctly, search the environment of the
// executable and the asset for a texture with a name very similar
// to a given one
int FindValidPath( aiString* p_szString );
//------------------------------------------------------------------ } // namespace AssimpView
// Load a texture into memory and create a native D3D texture resource
//
// The function tries to find a valid path for a texture
int LoadTexture( IDirect3DTexture9** p_ppiOut, aiString* szPath );
//------------------------------------------------------------------
// Getter for m_iShaderCount
//
inline unsigned int GetShaderCount()
{
return this->m_iShaderCount;
}
//------------------------------------------------------------------
// Reset the state of the class
// Called whenever a new asset is loaded
inline void Reset()
{
this->m_iShaderCount = 0;
for( TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it ) {
( *it ).second->Release();
}
sCachedTextures.clear();
}
private:
//------------------------------------------------------------------
// find a valid path to a texture file
//
// Handle 8.3 syntax correctly, search the environment of the
// executable and the asset for a texture with a name very similar
// to a given one
bool TryLongerPath( char* szTemp, aiString* p_szString );
//------------------------------------------------------------------
// Setup the default texture for a texture channel
//
// Generates a default checker pattern for a texture
int SetDefaultTexture( IDirect3DTexture9** p_ppiOut );
//------------------------------------------------------------------
// Convert a height map to a normal map if necessary
//
// The function tries to detect the type of a texture automatically.
// However, this won't work in every case.
void HMtoNMIfNecessary( IDirect3DTexture9* piTexture,
IDirect3DTexture9** piTextureOut,
bool bWasOriginallyHM = true );
//------------------------------------------------------------------
// Search for non-opaque pixels in a texture
//
// A pixel is considered to be non-opaque if its alpha value is
// less than 255
//------------------------------------------------------------------
bool HasAlphaPixels( IDirect3DTexture9* piTexture );
private:
//
// Specifies the number of different shaders generated for
// the current asset. This number is incremented by CreateMaterial()
// each time a shader isn't found in cache and needs to be created
//
unsigned int m_iShaderCount;
IDirect3DTexture9* sDefaultTexture;
typedef std::map<std::string, IDirect3DTexture9*> TextureCache;
TextureCache sCachedTextures;
};
}

View File

@ -58,8 +58,8 @@ namespace AssimpView {
*/ */
struct SceneAnimNode { struct SceneAnimNode {
std::string mName; std::string mName;
SceneAnimNode* mParent; SceneAnimNode *mParent;
std::vector<SceneAnimNode*> mChildren; std::vector<SceneAnimNode *> mChildren;
//! most recently calculated local transform //! most recently calculated local transform
aiMatrix4x4 mLocalTransform; aiMatrix4x4 mLocalTransform;
@ -71,30 +71,20 @@ struct SceneAnimNode {
int mChannelIndex; int mChannelIndex;
//! Default construction //! Default construction
SceneAnimNode() SceneAnimNode() :
: mName() mName(), mParent(nullptr), mChildren(), mLocalTransform(), mGlobalTransform(), mChannelIndex(-1) {
, mParent(nullptr)
, mChildren()
, mLocalTransform()
, mGlobalTransform()
, mChannelIndex(-1) {
// empty // empty
} }
//! Construction from a given name //! Construction from a given name
SceneAnimNode( const std::string& pName) SceneAnimNode(const std::string &pName) :
: mName( pName) mName(pName), mParent(nullptr), mChildren(), mLocalTransform(), mGlobalTransform(), mChannelIndex(-1) {
, mParent(nullptr)
, mChildren()
, mLocalTransform()
, mGlobalTransform()
, mChannelIndex(-1) {
// empty // empty
} }
//! Destruct all children recursively //! Destruct all children recursively
~SceneAnimNode() { ~SceneAnimNode() {
for (std::vector<SceneAnimNode*>::iterator it = mChildren.begin(); it != mChildren.end(); ++it) { for (std::vector<SceneAnimNode *>::iterator it = mChildren.begin(); it != mChildren.end(); ++it) {
delete *it; delete *it;
} }
} }
@ -112,7 +102,6 @@ struct SceneAnimNode {
*/ */
class SceneAnimator { class SceneAnimator {
public: public:
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Constructor for a given scene. /** Constructor for a given scene.
* *
@ -122,7 +111,7 @@ public:
* @param pAnimIndex [optional] Index of the animation to play. Assumed to * @param pAnimIndex [optional] Index of the animation to play. Assumed to
* be 0 if not given. * be 0 if not given.
*/ */
SceneAnimator( const aiScene* pScene, size_t pAnimIndex = 0); SceneAnimator(const aiScene *pScene, size_t pAnimIndex = 0);
/** Destructor */ /** Destructor */
~SceneAnimator(); ~SceneAnimator();
@ -132,14 +121,14 @@ public:
* mapping structures, which might take a few cycles. * mapping structures, which might take a few cycles.
* @param pAnimIndex Index of the animation in the scene's animation array * @param pAnimIndex Index of the animation in the scene's animation array
*/ */
void SetAnimIndex( size_t pAnimIndex); void SetAnimIndex(size_t pAnimIndex);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Calculates the node transformations for the scene. Call this to get /** Calculates the node transformations for the scene. Call this to get
* uptodate results before calling one of the getters. * uptodate results before calling one of the getters.
* @param pTime Current time. Can be an arbitrary range. * @param pTime Current time. Can be an arbitrary range.
*/ */
void Calculate( double pTime); void Calculate(double pTime);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Retrieves the most recent local transformation matrix for the given node. /** Retrieves the most recent local transformation matrix for the given node.
@ -154,7 +143,7 @@ public:
* @return A reference to the node's most recently calculated local * @return A reference to the node's most recently calculated local
* transformation matrix. * transformation matrix.
*/ */
const aiMatrix4x4& GetLocalTransform( const aiNode* node) const; const aiMatrix4x4 &GetLocalTransform(const aiNode *node) const;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Retrieves the most recent global transformation matrix for the given node. /** Retrieves the most recent global transformation matrix for the given node.
@ -169,7 +158,7 @@ public:
* @return A reference to the node's most recently calculated global * @return A reference to the node's most recently calculated global
* transformation matrix. * transformation matrix.
*/ */
const aiMatrix4x4& GetGlobalTransform( const aiNode* node) const; const aiMatrix4x4 &GetGlobalTransform(const aiNode *node) const;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Calculates the bone matrices for the given mesh. /** Calculates the bone matrices for the given mesh.
@ -187,8 +176,8 @@ public:
* @return A reference to a vector of bone matrices. Stays stable till the * @return A reference to a vector of bone matrices. Stays stable till the
* next call to GetBoneMatrices(); * next call to GetBoneMatrices();
*/ */
const std::vector<aiMatrix4x4>& GetBoneMatrices( const aiNode* pNode, const std::vector<aiMatrix4x4> &GetBoneMatrices(const aiNode *pNode,
size_t pMeshIndex = 0); size_t pMeshIndex = 0);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** @brief Get the current animation index /** @brief Get the current animation index
@ -200,44 +189,43 @@ public:
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** @brief Get the current animation or NULL /** @brief Get the current animation or NULL
*/ */
aiAnimation* CurrentAnim() const { aiAnimation *CurrentAnim() const {
return static_cast<unsigned int>( mCurrentAnimIndex ) < mScene->mNumAnimations ? mScene->mAnimations[ mCurrentAnimIndex ] : NULL; return static_cast<unsigned int>(mCurrentAnimIndex) < mScene->mNumAnimations ? mScene->mAnimations[mCurrentAnimIndex] : NULL;
} }
protected: protected:
/** Recursively creates an internal node structure matching the /** Recursively creates an internal node structure matching the
* current scene and animation. * current scene and animation.
*/ */
SceneAnimNode* CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent); SceneAnimNode *CreateNodeTree(aiNode *pNode, SceneAnimNode *pParent);
/** Recursively updates the internal node transformations from the /** Recursively updates the internal node transformations from the
* given matrix array * given matrix array
*/ */
void UpdateTransforms( SceneAnimNode* pNode, const std::vector<aiMatrix4x4>& pTransforms); void UpdateTransforms(SceneAnimNode *pNode, const std::vector<aiMatrix4x4> &pTransforms);
/** Calculates the global transformation matrix for the given internal node */ /** Calculates the global transformation matrix for the given internal node */
void CalculateGlobalTransform( SceneAnimNode* pInternalNode); void CalculateGlobalTransform(SceneAnimNode *pInternalNode);
protected: protected:
/** The scene we're operating on */ /** The scene we're operating on */
const aiScene* mScene; const aiScene *mScene;
/** Current animation index */ /** Current animation index */
int mCurrentAnimIndex; int mCurrentAnimIndex;
/** The AnimEvaluator we use to calculate the current pose for the current animation */ /** The AnimEvaluator we use to calculate the current pose for the current animation */
AnimEvaluator* mAnimEvaluator; AnimEvaluator *mAnimEvaluator;
/** Root node of the internal scene structure */ /** Root node of the internal scene structure */
SceneAnimNode* mRootNode; SceneAnimNode *mRootNode;
/** Name to node map to quickly find nodes by their name */ /** Name to node map to quickly find nodes by their name */
typedef std::map<const aiNode*, SceneAnimNode*> NodeMap; typedef std::map<const aiNode *, SceneAnimNode *> NodeMap;
NodeMap mNodesByName; NodeMap mNodesByName;
/** Name to node map to quickly find nodes for given bones by their name */ /** Name to node map to quickly find nodes for given bones by their name */
typedef std::map<const char*, const aiNode*> BoneMap; typedef std::map<const char *, const aiNode *> BoneMap;
BoneMap mBoneNodesByName; BoneMap mBoneNodesByName;
/** Array to return transformations results inside. */ /** Array to return transformations results inside. */

View File

@ -1394,4 +1394,4 @@ std::string g_szCheckerBackgroundShader = std::string(
"VertexShader = compile vs_3_0 DefaultVShader();\n" "VertexShader = compile vs_3_0 DefaultVShader();\n"
"}\n" "}\n"
"};\n"); "};\n");
}; // namespace AssimpView } // namespace AssimpView

File diff suppressed because it is too large Load Diff

View File

@ -51,27 +51,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "resource.h" #include "resource.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <memory.h> #include <memory.h>
#include <tchar.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#include <time.h> #include <time.h>
// Include ASSIMP headers (XXX: do we really need all of them?) // Include ASSIMP headers (XXX: do we really need all of them?)
#include <assimp/cimport.h>
#include <assimp/Importer.hpp>
#include <assimp/ai_assert.h> #include <assimp/ai_assert.h>
#include <assimp/cfileio.h> #include <assimp/cfileio.h>
#include <assimp/cimport.h>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/IOSystem.hpp>
#include <assimp/IOStream.hpp>
#include <assimp/LogStream.hpp>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/IOStream.hpp>
#include <assimp/IOSystem.hpp>
#include <assimp/Importer.hpp>
#include <assimp/LogStream.hpp>
#include "Material/MaterialSystem.h" // aiMaterial class #include "Material/MaterialSystem.h" // aiMaterial class
#include <assimp/StringComparison.h> // ASSIMP_stricmp and ASSIMP_strincmp #include <assimp/StringComparison.h> // ASSIMP_stricmp and ASSIMP_strincmp
#include <time.h> #include <time.h>
@ -79,33 +79,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MOVE_SPEED 3.f #define MOVE_SPEED 3.f
#include "AssetHelper.h" #include "AssetHelper.h"
#include "Camera.h"
#include "RenderOptions.h"
#include "Shaders.h"
#include "Background.h" #include "Background.h"
#include "Camera.h"
#include "Display.h"
#include "LogDisplay.h" #include "LogDisplay.h"
#include "LogWindow.h" #include "LogWindow.h"
#include "Display.h"
#include "MeshRenderer.h"
#include "MaterialManager.h" #include "MaterialManager.h"
#include "MeshRenderer.h"
#include "RenderOptions.h"
#include "Shaders.h"
// outside of namespace, to help Intellisense and solve boost::metatype_stuff_miracle // outside of namespace, to help Intellisense and solve boost::metatype_stuff_miracle
#include "AnimEvaluator.h" #include "AnimEvaluator.h"
#include "SceneAnimator.h" #include "SceneAnimator.h"
namespace AssimpView namespace AssimpView {
{
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// Function prototypes // Function prototypes
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
int InitD3D(void); int InitD3D(void);
int ShutdownD3D(void); int ShutdownD3D(void);
int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true); int CreateDevice(bool p_bMultiSample, bool p_bSuperSample, bool bHW = true);
int CreateDevice (void); int CreateDevice(void);
int ShutdownDevice(void); int ShutdownDevice(void);
int GetProjectionMatrix (aiMatrix4x4& p_mOut); int GetProjectionMatrix(aiMatrix4x4 &p_mOut);
int LoadAsset(void); int LoadAsset(void);
int CreateAssetData(void); int CreateAssetData(void);
int DeleteAssetData(bool bNoMaterials = false); int DeleteAssetData(bool bNoMaterials = false);
@ -113,26 +111,25 @@ int ScaleAsset(void);
int DeleteAsset(void); int DeleteAsset(void);
int SetupFPSView(); int SetupFPSView();
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut); aiVector3D GetCameraMatrix(aiMatrix4x4 &p_mOut);
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource); int CreateMaterial(AssetHelper::MeshHelper *pcMesh, const aiMesh *pcSource);
void HandleMouseInputFPS( void );
void HandleMouseInputLightRotate( void );
void HandleMouseInputLocal( void );
void HandleKeyboardInputFPS( void );
void HandleMouseInputLightIntensityAndColor( void );
void HandleMouseInputSkyBox( void );
void HandleKeyboardInputTextureView( void );
void HandleMouseInputTextureView( void );
void HandleMouseInputFPS(void);
void HandleMouseInputLightRotate(void);
void HandleMouseInputLocal(void);
void HandleKeyboardInputFPS(void);
void HandleMouseInputLightIntensityAndColor(void);
void HandleMouseInputSkyBox(void);
void HandleKeyboardInputTextureView(void);
void HandleMouseInputTextureView(void);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// //
// Dialog procedure for the progress bar window // Dialog procedure for the progress bar window
// //
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg, INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,LPARAM lParam); WPARAM wParam, LPARAM lParam);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// Main message procedure of the application // Main message procedure of the application
@ -142,25 +139,24 @@ INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg,
// NOTE: Due to the impossibility to process WM_CHAR messages in dialogs // NOTE: Due to the impossibility to process WM_CHAR messages in dialogs
// properly the code for all hotkeys has been moved to the WndMain // properly the code for all hotkeys has been moved to the WndMain
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg, INT_PTR CALLBACK MessageProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,LPARAM lParam); WPARAM wParam, LPARAM lParam);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// //
// Dialog procedure for the about dialog // Dialog procedure for the about dialog
// //
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg, INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,LPARAM lParam); WPARAM wParam, LPARAM lParam);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// //
// Dialog procedure for the help dialog // Dialog procedure for the help dialog
// //
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg, INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg, UINT uMsg,
WPARAM wParam,LPARAM lParam); WPARAM wParam, LPARAM lParam);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// Handle command line parameters // Handle command line parameters
@ -168,24 +164,20 @@ INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
// The function loads an asset specified on the command line as first argument // The function loads an asset specified on the command line as first argument
// Other command line parameters are not handled // Other command line parameters are not handled
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
void HandleCommandLine(char* p_szCommand); void HandleCommandLine(char *p_szCommand);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
template <class type, class intype> template <class type, class intype>
type clamp(intype in) type clamp(intype in) {
{
// for unsigned types only ... // for unsigned types only ...
intype mask = (0x1u << (sizeof(type)*8))-1; intype mask = (0x1u << (sizeof(type) * 8)) - 1;
return (type)std::max((intype)0,std::min(in,mask)); return (type)std::max((intype)0, std::min(in, mask));
} }
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// Position of the cursor relative to the 3ds max' like control circle // Position of the cursor relative to the 3ds max' like control circle
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
enum EClickPos enum EClickPos {
{
// The click was inside the inner circle (x,y axis) // The click was inside the inner circle (x,y axis)
EClickPos_Circle, EClickPos_Circle,
// The click was inside one of the vertical snap-ins // The click was inside one of the vertical snap-ins
@ -197,84 +189,82 @@ enum EClickPos
}; };
#if (!defined AI_VIEW_CAPTION_BASE) #if (!defined AI_VIEW_CAPTION_BASE)
# define AI_VIEW_CAPTION_BASE "Open Asset Import Library : Viewer " #define AI_VIEW_CAPTION_BASE "Open Asset Import Library : Viewer "
#endif // !! AI_VIEW_CAPTION_BASE #endif // !! AI_VIEW_CAPTION_BASE
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// Evil globals // Evil globals
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
extern HINSTANCE g_hInstance /*= NULL*/; extern HINSTANCE g_hInstance /*= NULL*/;
extern HWND g_hDlg /*= NULL*/; extern HWND g_hDlg /*= NULL*/;
extern IDirect3D9* g_piD3D /*= NULL*/; extern IDirect3D9 *g_piD3D /*= NULL*/;
extern IDirect3DDevice9* g_piDevice /*= NULL*/; extern IDirect3DDevice9 *g_piDevice /*= NULL*/;
extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/; extern IDirect3DVertexDeclaration9 *gDefaultVertexDecl /*= NULL*/;
extern double g_fFPS /*= 0.0f*/; extern double g_fFPS /*= 0.0f*/;
extern char g_szFileName[MAX_PATH]; extern char g_szFileName[MAX_PATH];
extern ID3DXEffect* g_piDefaultEffect /*= NULL*/; extern ID3DXEffect *g_piDefaultEffect /*= NULL*/;
extern ID3DXEffect* g_piNormalsEffect /*= NULL*/; extern ID3DXEffect *g_piNormalsEffect /*= NULL*/;
extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/; extern ID3DXEffect *g_piPassThroughEffect /*= NULL*/;
extern ID3DXEffect* g_piPatternEffect /*= NULL*/; extern ID3DXEffect *g_piPatternEffect /*= NULL*/;
extern bool g_bMousePressed /*= false*/; extern bool g_bMousePressed /*= false*/;
extern bool g_bMousePressedR /*= false*/; extern bool g_bMousePressedR /*= false*/;
extern bool g_bMousePressedM /*= false*/; extern bool g_bMousePressedM /*= false*/;
extern bool g_bMousePressedBoth /*= false*/; extern bool g_bMousePressedBoth /*= false*/;
extern float g_fElpasedTime /*= 0.0f*/; extern float g_fElpasedTime /*= 0.0f*/;
extern D3DCAPS9 g_sCaps; extern D3DCAPS9 g_sCaps;
extern bool g_bLoadingFinished /*= false*/; extern bool g_bLoadingFinished /*= false*/;
extern HANDLE g_hThreadHandle /*= NULL*/; extern HANDLE g_hThreadHandle /*= NULL*/;
extern float g_fWheelPos /*= -10.0f*/; extern float g_fWheelPos /*= -10.0f*/;
extern bool g_bLoadingCanceled /*= false*/; extern bool g_bLoadingCanceled /*= false*/;
extern IDirect3DTexture9* g_pcTexture /*= NULL*/; extern IDirect3DTexture9 *g_pcTexture /*= NULL*/;
extern aiMatrix4x4 g_mWorld; extern aiMatrix4x4 g_mWorld;
extern aiMatrix4x4 g_mWorldRotate; extern aiMatrix4x4 g_mWorldRotate;
extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/; extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/;
extern aiVector3D g_avLightDirs[1] /* = extern aiVector3D g_avLightDirs[1] /* =
{ aiVector3D(-0.5f,0.6f,0.2f) , { aiVector3D(-0.5f,0.6f,0.2f) ,
aiVector3D(-0.5f,0.5f,0.5f)} */; aiVector3D(-0.5f,0.5f,0.5f)} */
;
extern POINT g_mousePos /*= {0,0};*/;
extern POINT g_LastmousePos /*= {0,0}*/;
extern bool g_bFPSView /*= false*/;
extern bool g_bInvert /*= false*/;
extern EClickPos g_eClick;
extern unsigned int g_iCurrentColor /*= 0*/;
extern POINT g_mousePos /*= {0,0};*/; // NOTE: The light intensity is separated from the color, it can
extern POINT g_LastmousePos /*= {0,0}*/; // directly be manipulated using the middle mouse button.
extern bool g_bFPSView /*= false*/; // When the user chooses a color from the palette the intensity
extern bool g_bInvert /*= false*/; // is reset to 1.0
extern EClickPos g_eClick; // index[2] is the ambient color
extern unsigned int g_iCurrentColor /*= 0*/; extern float g_fLightIntensity /*=0.0f*/;
extern D3DCOLOR g_avLightColors[3];
// NOTE: The light intensity is separated from the color, it can extern RenderOptions g_sOptions;
// directly be manipulated using the middle mouse button. extern Camera g_sCamera;
// When the user chooses a color from the palette the intensity extern AssetHelper *g_pcAsset /*= NULL*/;
// is reset to 1.0
// index[2] is the ambient color
extern float g_fLightIntensity /*=0.0f*/;
extern D3DCOLOR g_avLightColors[3];
extern RenderOptions g_sOptions; //
extern Camera g_sCamera; // Contains the mask image for the HUD
extern AssetHelper *g_pcAsset /*= NULL*/; // (used to determine the position of a click)
//
// The size of the image is identical to the size of the main
// HUD texture
//
extern unsigned char *g_szImageMask /*= NULL*/;
extern float g_fACMR /*= 3.0f*/;
extern IDirect3DQuery9 *g_piQuery;
// extern bool g_bPlay /*= false*/;
// Contains the mask image for the HUD
// (used to determine the position of a click)
//
// The size of the image is identical to the size of the main
// HUD texture
//
extern unsigned char* g_szImageMask /*= NULL*/;
extern double g_dCurrent;
extern float g_smoothAngle /*= 80.f*/;
extern float g_fACMR /*= 3.0f*/; extern unsigned int ppsteps, ppstepsdefault;
extern IDirect3DQuery9* g_piQuery; extern bool nopointslines;
} // namespace AssimpView
extern bool g_bPlay /*= false*/;
extern double g_dCurrent;
extern float g_smoothAngle /*= 80.f*/;
extern unsigned int ppsteps,ppstepsdefault;
extern bool nopointslines;
}
#endif // !! AV_MAIN_H_INCLUDED #endif // !! AV_MAIN_H_INCLUDED