Merge branch 'master' into bug-3177-dae-geo-id
commit
2571b47a28
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
|
@ -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
|
@ -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
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
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);
|
||||||
|
@ -59,8 +58,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -68,16 +66,14 @@ size_t CIOStreamWrapper::Read(void* pvBuffer,
|
||||||
// ...................................................................
|
// ...................................................................
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,4 +129,4 @@ void CIOSystemWrapper::Close( IOStream* pFile) {
|
||||||
delete pFile;
|
delete pFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace Assimp
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -56,13 +54,11 @@ 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);
|
||||||
|
@ -77,23 +73,22 @@ private:
|
||||||
CIOSystemWrapper *mIO;
|
CIOSystemWrapper *mIO;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIOSystemWrapper : public IOSystem
|
class CIOSystemWrapper : public IOSystem {
|
||||||
{
|
|
||||||
friend class CIOStreamWrapper;
|
friend class CIOStreamWrapper;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CIOSystemWrapper(aiFileIO* pFile)
|
explicit CIOSystemWrapper(aiFileIO *pFile) :
|
||||||
: mFileSystem(pFile)
|
mFileSystem(pFile) {}
|
||||||
{}
|
|
||||||
|
|
||||||
bool Exists(const char *pFile) const;
|
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
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
|
@ -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,6 +206,9 @@ 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
|
||||||
|
@ -209,24 +218,13 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
for( unsigned int c = 0; c < vb.size(); ++c)
|
for( unsigned int c = 0; c < vb.size(); ++c)
|
||||||
{
|
{
|
||||||
unsigned int boneIndex = vb[c].first;
|
unsigned int boneIndex = vb[c].first;
|
||||||
// if the bone is already used in this submesh, it's ok
|
if( !isBoneUsed[boneIndex] )
|
||||||
if( isBoneUsed[boneIndex] )
|
|
||||||
{
|
{
|
||||||
continue;
|
newBonesAtCurrentFace.insert(boneIndex);
|
||||||
}
|
|
||||||
|
|
||||||
// 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,18 +232,14 @@ 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] )
|
|
||||||
{
|
{
|
||||||
continue;
|
isBoneUsed[*it] = true;
|
||||||
}
|
|
||||||
|
|
||||||
isBoneUsed[newIndex] = true;
|
|
||||||
numBones++;
|
numBones++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// store the face index and the vertex count
|
// store the face index and the vertex count
|
||||||
subMeshFaces.push_back( a);
|
subMeshFaces.push_back( a);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
==================
|
==================
|
||||||
INSTALLATION GUIDE
|
INSTALLATION GUIDE
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
|
|
@ -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}
|
||||||
|
|
|
@ -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
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -47,9 +47,10 @@ 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) {
|
||||||
|
ai_assert(nullptr != pAnim);
|
||||||
mLastPositions.resize(pAnim->mNumChannels, std::make_tuple(0, 0, 0));
|
mLastPositions.resize(pAnim->mNumChannels, std::make_tuple(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,10 +161,18 @@ 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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -57,11 +56,9 @@ namespace AssimpView {
|
||||||
/** \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
|
// the original normal set will be used
|
||||||
ORIGINAL = 0x0u,
|
ORIGINAL = 0x0u,
|
||||||
|
|
||||||
|
@ -73,9 +70,8 @@ namespace AssimpView {
|
||||||
};
|
};
|
||||||
|
|
||||||
// default constructor
|
// default constructor
|
||||||
AssetHelper()
|
AssetHelper() :
|
||||||
: iNormalSet( ORIGINAL )
|
iNormalSet(ORIGINAL) {
|
||||||
{
|
|
||||||
mAnimator = NULL;
|
mAnimator = NULL;
|
||||||
apcMeshes = NULL;
|
apcMeshes = NULL;
|
||||||
pcScene = NULL;
|
pcScene = NULL;
|
||||||
|
@ -86,8 +82,7 @@ namespace AssimpView {
|
||||||
// (even if tangents, bitangents or normals aren't
|
// (even if tangents, bitangents or normals aren't
|
||||||
// required by the shader they will be committed to the GPU)
|
// required by the shader they will be committed to the GPU)
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
struct Vertex
|
struct Vertex {
|
||||||
{
|
|
||||||
aiVector3D vPosition;
|
aiVector3D vPosition;
|
||||||
aiVector3D vNormal;
|
aiVector3D vNormal;
|
||||||
|
|
||||||
|
@ -100,10 +95,8 @@ namespace AssimpView {
|
||||||
unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
|
unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
|
||||||
|
|
||||||
/** Returns the vertex declaration elements to create a declaration from. */
|
/** Returns the vertex declaration elements to create a declaration from. */
|
||||||
static D3DVERTEXELEMENT9* GetDeclarationElements()
|
static D3DVERTEXELEMENT9 *GetDeclarationElements() {
|
||||||
{
|
static D3DVERTEXELEMENT9 decl[] = {
|
||||||
static D3DVERTEXELEMENT9 decl[] =
|
|
||||||
{
|
|
||||||
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
||||||
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
|
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
|
||||||
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
||||||
|
@ -123,14 +116,12 @@ namespace AssimpView {
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// FVF vertex structure used for normals
|
// FVF vertex structure used for normals
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
struct LineVertex
|
struct LineVertex {
|
||||||
{
|
|
||||||
aiVector3D vPosition;
|
aiVector3D vPosition;
|
||||||
DWORD dColorDiffuse;
|
DWORD dColorDiffuse;
|
||||||
|
|
||||||
// retrieves the FVF code of the vertex type
|
// retrieves the FVF code of the vertex type
|
||||||
static DWORD GetFVF()
|
static DWORD GetFVF() {
|
||||||
{
|
|
||||||
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
|
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -139,12 +130,9 @@ namespace AssimpView {
|
||||||
// Helper class to store GPU related resources created for
|
// Helper class to store GPU related resources created for
|
||||||
// a given aiMesh
|
// a given aiMesh
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
class MeshHelper
|
class MeshHelper {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
MeshHelper() :
|
||||||
MeshHelper()
|
|
||||||
:
|
|
||||||
eShadingMode(),
|
eShadingMode(),
|
||||||
piVB(NULL),
|
piVB(NULL),
|
||||||
piIB(NULL),
|
piIB(NULL),
|
||||||
|
@ -163,11 +151,9 @@ namespace AssimpView {
|
||||||
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
|
||||||
}
|
}
|
||||||
|
@ -245,6 +231,6 @@ namespace AssimpView {
|
||||||
void FlipNormals();
|
void FlipNormals();
|
||||||
void FlipNormalsInt();
|
void FlipNormalsInt();
|
||||||
};
|
};
|
||||||
}
|
} // namespace AssimpView
|
||||||
|
|
||||||
#endif // !! IG
|
#endif // !! IG
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -45,22 +45,19 @@ 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
|
// default constructor
|
||||||
CMaterialManager()
|
CMaterialManager() :
|
||||||
: m_iShaderCount( 0 ), sDefaultTexture() {}
|
m_iShaderCount(0), sDefaultTexture() {}
|
||||||
|
|
||||||
~CMaterialManager() {
|
~CMaterialManager() {
|
||||||
if (sDefaultTexture) {
|
if (sDefaultTexture) {
|
||||||
|
@ -70,12 +67,10 @@ namespace AssimpView
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Singleton accessors
|
// Singleton accessors
|
||||||
static CMaterialManager s_cInstance;
|
static CMaterialManager s_cInstance;
|
||||||
inline static CMaterialManager& Instance()
|
inline static CMaterialManager &Instance() {
|
||||||
{
|
|
||||||
return s_cInstance;
|
return s_cInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,20 +132,17 @@ namespace AssimpView
|
||||||
// The function tries to find a valid path for a texture
|
// The function tries to find a valid path for a texture
|
||||||
int LoadTexture(IDirect3DTexture9 **p_ppiOut, aiString *szPath);
|
int LoadTexture(IDirect3DTexture9 **p_ppiOut, aiString *szPath);
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Getter for m_iShaderCount
|
// Getter for m_iShaderCount
|
||||||
//
|
//
|
||||||
inline unsigned int GetShaderCount()
|
inline unsigned int GetShaderCount() {
|
||||||
{
|
|
||||||
return this->m_iShaderCount;
|
return this->m_iShaderCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Reset the state of the class
|
// Reset the state of the class
|
||||||
// Called whenever a new asset is loaded
|
// Called whenever a new asset is loaded
|
||||||
inline void Reset()
|
inline void Reset() {
|
||||||
{
|
|
||||||
this->m_iShaderCount = 0;
|
this->m_iShaderCount = 0;
|
||||||
for (TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it) {
|
for (TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it) {
|
||||||
(*it).second->Release();
|
(*it).second->Release();
|
||||||
|
@ -159,7 +151,6 @@ namespace AssimpView
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// find a valid path to a texture file
|
// find a valid path to a texture file
|
||||||
//
|
//
|
||||||
|
@ -192,7 +183,6 @@ namespace AssimpView
|
||||||
bool HasAlphaPixels(IDirect3DTexture9 *piTexture);
|
bool HasAlphaPixels(IDirect3DTexture9 *piTexture);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Specifies the number of different shaders generated for
|
// Specifies the number of different shaders generated for
|
||||||
// the current asset. This number is incremented by CreateMaterial()
|
// the current asset. This number is incremented by CreateMaterial()
|
||||||
|
@ -205,4 +195,4 @@ namespace AssimpView
|
||||||
TextureCache sCachedTextures;
|
TextureCache sCachedTextures;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace AssimpView
|
||||||
|
|
|
@ -71,24 +71,14 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +102,6 @@ struct SceneAnimNode {
|
||||||
*/
|
*/
|
||||||
class SceneAnimator {
|
class SceneAnimator {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Constructor for a given scene.
|
/** Constructor for a given scene.
|
||||||
*
|
*
|
||||||
|
@ -205,7 +194,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -41,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
#include <assimp/StringUtils.h>
|
#include <assimp/StringUtils.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -113,11 +110,9 @@ aiMatrix4x4 g_mWorldRotate;
|
||||||
aiVector3D g_vRotateSpeed = aiVector3D(0.5f, 0.5f, 0.5f);
|
aiVector3D g_vRotateSpeed = aiVector3D(0.5f, 0.5f, 0.5f);
|
||||||
|
|
||||||
// NOTE: The second light direction is now computed from the first
|
// NOTE: The second light direction is now computed from the first
|
||||||
aiVector3D g_avLightDirs[1] =
|
aiVector3D g_avLightDirs[1] = { aiVector3D(-0.5f, 0.6f, 0.2f) };
|
||||||
{ aiVector3D(-0.5f,0.6f,0.2f) };
|
|
||||||
|
|
||||||
D3DCOLOR g_avLightColors[3] =
|
D3DCOLOR g_avLightColors[3] = {
|
||||||
{
|
|
||||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0xFF, 0xFF),
|
D3DCOLOR_ARGB(0xFF, 0xFF, 0xFF, 0xFF),
|
||||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00),
|
D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00),
|
||||||
D3DCOLOR_ARGB(0xFF, 0x05, 0x05, 0x05),
|
D3DCOLOR_ARGB(0xFF, 0x05, 0x05, 0x05),
|
||||||
|
@ -145,14 +140,12 @@ unsigned char* g_szImageMask = nullptr;
|
||||||
|
|
||||||
float g_fLoadTime = 0.0f;
|
float g_fLoadTime = 0.0f;
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Entry point for the loader thread
|
// Entry point for the loader thread
|
||||||
// The loader thread loads the asset while the progress dialog displays the
|
// The loader thread loads the asset while the progress dialog displays the
|
||||||
// smart progress bar
|
// smart progress bar
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
DWORD WINAPI LoadThreadProc(LPVOID lpParameter) {
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(lpParameter);
|
UNREFERENCED_PARAMETER(lpParameter);
|
||||||
|
|
||||||
// get current time
|
// get current time
|
||||||
|
@ -186,8 +179,7 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
||||||
g_bLoadingFinished = true;
|
g_bLoadingFinished = true;
|
||||||
|
|
||||||
// check whether the loading process has failed ...
|
// check whether the loading process has failed ...
|
||||||
if (nullptr == g_pcAsset->pcScene)
|
if (nullptr == g_pcAsset->pcScene) {
|
||||||
{
|
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load this asset:",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load this asset:",
|
||||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||||
|
|
||||||
|
@ -204,8 +196,7 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
||||||
// load the current asset
|
// load the current asset
|
||||||
// THe path to the asset is specified in the global path variable
|
// THe path to the asset is specified in the global path variable
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int LoadAsset()
|
int LoadAsset() {
|
||||||
{
|
|
||||||
// set the world and world rotation matrices to the identity
|
// set the world and world rotation matrices to the identity
|
||||||
g_mWorldRotate = aiMatrix4x4();
|
g_mWorldRotate = aiMatrix4x4();
|
||||||
g_mWorld = aiMatrix4x4();
|
g_mWorld = aiMatrix4x4();
|
||||||
|
@ -225,8 +216,7 @@ int LoadAsset()
|
||||||
g_pcAsset = new AssetHelper();
|
g_pcAsset = new AssetHelper();
|
||||||
g_hThreadHandle = CreateThread(nullptr, 0, &LoadThreadProc, nullptr, 0, &dwID);
|
g_hThreadHandle = CreateThread(nullptr, 0, &LoadThreadProc, nullptr, 0, &dwID);
|
||||||
|
|
||||||
if (!g_hThreadHandle)
|
if (!g_hThreadHandle) {
|
||||||
{
|
|
||||||
CLogDisplay::Instance().AddEntry(
|
CLogDisplay::Instance().AddEntry(
|
||||||
"[ERROR] Unable to create helper thread for loading",
|
"[ERROR] Unable to create helper thread for loading",
|
||||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||||
|
@ -243,10 +233,8 @@ int LoadAsset()
|
||||||
|
|
||||||
// now we should have loaded the asset. Check this ...
|
// now we should have loaded the asset. Check this ...
|
||||||
g_bLoadingFinished = false;
|
g_bLoadingFinished = false;
|
||||||
if (!g_pcAsset || !g_pcAsset->pcScene)
|
if (!g_pcAsset || !g_pcAsset->pcScene) {
|
||||||
{
|
if (g_pcAsset) {
|
||||||
if (g_pcAsset)
|
|
||||||
{
|
|
||||||
delete g_pcAsset;
|
delete g_pcAsset;
|
||||||
g_pcAsset = nullptr;
|
g_pcAsset = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +247,6 @@ int LoadAsset()
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i)
|
||||||
g_pcAsset->apcMeshes[i] = new AssetHelper::MeshHelper();
|
g_pcAsset->apcMeshes[i] = new AssetHelper::MeshHelper();
|
||||||
|
|
||||||
|
|
||||||
// create animator
|
// create animator
|
||||||
g_pcAsset->mAnimator = new SceneAnimator(g_pcAsset->pcScene);
|
g_pcAsset->mAnimator = new SceneAnimator(g_pcAsset->pcScene);
|
||||||
|
|
||||||
|
@ -285,8 +272,7 @@ int LoadAsset()
|
||||||
if (!g_pcAsset->pcScene->HasAnimations()) {
|
if (!g_pcAsset->pcScene->HasAnimations()) {
|
||||||
EnableWindow(GetDlgItem(g_hDlg, IDC_PLAY), FALSE);
|
EnableWindow(GetDlgItem(g_hDlg, IDC_PLAY), FALSE);
|
||||||
EnableWindow(GetDlgItem(g_hDlg, IDC_SLIDERANIM), FALSE);
|
EnableWindow(GetDlgItem(g_hDlg, IDC_SLIDERANIM), FALSE);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
EnableWindow(GetDlgItem(g_hDlg, IDC_PLAY), TRUE);
|
EnableWindow(GetDlgItem(g_hDlg, IDC_PLAY), TRUE);
|
||||||
EnableWindow(GetDlgItem(g_hDlg, IDC_SLIDERANIM), TRUE);
|
EnableWindow(GetDlgItem(g_hDlg, IDC_SLIDERANIM), TRUE);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +291,6 @@ int LoadAsset()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Delete the loaded asset
|
// Delete the loaded asset
|
||||||
// The function does nothing is no asset is loaded
|
// The function does nothing is no asset is loaded
|
||||||
|
@ -320,8 +305,7 @@ int DeleteAsset(void) {
|
||||||
|
|
||||||
// delete everything
|
// delete everything
|
||||||
DeleteAssetData();
|
DeleteAssetData();
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i) {
|
||||||
{
|
|
||||||
delete g_pcAsset->apcMeshes[i];
|
delete g_pcAsset->apcMeshes[i];
|
||||||
}
|
}
|
||||||
aiReleaseImport(g_pcAsset->pcScene);
|
aiReleaseImport(g_pcAsset->pcScene);
|
||||||
|
@ -342,7 +326,6 @@ int DeleteAsset(void) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Calculate the boundaries of a given node and all of its children
|
// Calculate the boundaries of a given node and all of its children
|
||||||
// The boundaries are in Worldspace (AABB)
|
// The boundaries are in Worldspace (AABB)
|
||||||
|
@ -358,11 +341,8 @@ int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, const aiMatrix4x4& piMa
|
||||||
mTemp.Transpose();
|
mTemp.Transpose();
|
||||||
aiMatrix4x4 aiMe = mTemp * piMatrix;
|
aiMatrix4x4 aiMe = mTemp * piMatrix;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < piNode->mNumMeshes;++i)
|
for (unsigned int i = 0; i < piNode->mNumMeshes; ++i) {
|
||||||
{
|
for (unsigned int a = 0; a < g_pcAsset->pcScene->mMeshes[piNode->mMeshes[i]]->mNumVertices; ++a) {
|
||||||
for( unsigned int a = 0; a < g_pcAsset->pcScene->mMeshes[
|
|
||||||
piNode->mMeshes[i]]->mNumVertices;++a)
|
|
||||||
{
|
|
||||||
aiVector3D pc = g_pcAsset->pcScene->mMeshes[piNode->mMeshes[i]]->mVertices[a];
|
aiVector3D pc = g_pcAsset->pcScene->mMeshes[piNode->mMeshes[i]]->mVertices[a];
|
||||||
|
|
||||||
aiVector3D pc1;
|
aiVector3D pc1;
|
||||||
|
@ -377,8 +357,7 @@ int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, const aiMatrix4x4& piMa
|
||||||
p_avOut[1].z = max(p_avOut[1].z, pc1.z);
|
p_avOut[1].z = max(p_avOut[1].z, pc1.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < piNode->mNumChildren;++i)
|
for (unsigned int i = 0; i < piNode->mNumChildren; ++i) {
|
||||||
{
|
|
||||||
CalculateBounds(piNode->mChildren[i], p_avOut, aiMe);
|
CalculateBounds(piNode->mChildren[i], p_avOut, aiMe);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -388,13 +367,11 @@ int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, const aiMatrix4x4& piMa
|
||||||
// The function calculates the boundaries of the mesh and modifies the
|
// The function calculates the boundaries of the mesh and modifies the
|
||||||
// global world transformation matrix according to the aset AABB
|
// global world transformation matrix according to the aset AABB
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int ScaleAsset(void)
|
int ScaleAsset(void) {
|
||||||
{
|
|
||||||
aiVector3D aiVecs[2] = { aiVector3D(1e10f, 1e10f, 1e10f),
|
aiVector3D aiVecs[2] = { aiVector3D(1e10f, 1e10f, 1e10f),
|
||||||
aiVector3D(-1e10f, -1e10f, -1e10f) };
|
aiVector3D(-1e10f, -1e10f, -1e10f) };
|
||||||
|
|
||||||
if (g_pcAsset->pcScene->mRootNode)
|
if (g_pcAsset->pcScene->mRootNode) {
|
||||||
{
|
|
||||||
aiMatrix4x4 m;
|
aiMatrix4x4 m;
|
||||||
CalculateBounds(g_pcAsset->pcScene->mRootNode, aiVecs, m);
|
CalculateBounds(g_pcAsset->pcScene->mRootNode, aiVecs, m);
|
||||||
}
|
}
|
||||||
|
@ -422,8 +399,7 @@ int ScaleAsset(void)
|
||||||
// pcMesh Input mesh
|
// pcMesh Input mesh
|
||||||
// pcSource Source mesh from ASSIMP
|
// pcSource Source mesh from ASSIMP
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource)
|
int GenerateNormalsAsLineList(AssetHelper::MeshHelper *pcMesh, const aiMesh *pcSource) {
|
||||||
{
|
|
||||||
ai_assert(nullptr != pcMesh);
|
ai_assert(nullptr != pcMesh);
|
||||||
ai_assert(nullptr != pcSource);
|
ai_assert(nullptr != pcSource);
|
||||||
|
|
||||||
|
@ -434,8 +410,7 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo
|
||||||
pcSource->mNumVertices * 2,
|
pcSource->mNumVertices * 2,
|
||||||
D3DUSAGE_WRITEONLY,
|
D3DUSAGE_WRITEONLY,
|
||||||
AssetHelper::LineVertex::GetFVF(),
|
AssetHelper::LineVertex::GetFVF(),
|
||||||
D3DPOOL_DEFAULT, &pcMesh->piVBNormals,nullptr)))
|
D3DPOOL_DEFAULT, &pcMesh->piVBNormals, nullptr))) {
|
||||||
{
|
|
||||||
CLogDisplay::Instance().AddEntry("Failed to create vertex buffer for the normal list",
|
CLogDisplay::Instance().AddEntry("Failed to create vertex buffer for the normal list",
|
||||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -444,8 +419,7 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo
|
||||||
// now fill the vertex buffer with data
|
// now fill the vertex buffer with data
|
||||||
AssetHelper::LineVertex *pbData2;
|
AssetHelper::LineVertex *pbData2;
|
||||||
pcMesh->piVBNormals->Lock(0, 0, (void **)&pbData2, 0);
|
pcMesh->piVBNormals->Lock(0, 0, (void **)&pbData2, 0);
|
||||||
for (unsigned int x = 0; x < pcSource->mNumVertices;++x)
|
for (unsigned int x = 0; x < pcSource->mNumVertices; ++x) {
|
||||||
{
|
|
||||||
pbData2->vPosition = pcSource->mVertices[x];
|
pbData2->vPosition = pcSource->mVertices[x];
|
||||||
|
|
||||||
++pbData2;
|
++pbData2;
|
||||||
|
@ -472,16 +446,14 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo
|
||||||
// Create the native D3D representation of the asset: vertex buffers,
|
// Create the native D3D representation of the asset: vertex buffers,
|
||||||
// index buffers, materials ...
|
// index buffers, materials ...
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CreateAssetData()
|
int CreateAssetData() {
|
||||||
{
|
|
||||||
if (!g_pcAsset) return 0;
|
if (!g_pcAsset) return 0;
|
||||||
|
|
||||||
// reset all subsystems
|
// reset all subsystems
|
||||||
CMaterialManager::Instance().Reset();
|
CMaterialManager::Instance().Reset();
|
||||||
CDisplay::Instance().Reset();
|
CDisplay::Instance().Reset();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i) {
|
||||||
{
|
|
||||||
const aiMesh *mesh = g_pcAsset->pcScene->mMeshes[i];
|
const aiMesh *mesh = g_pcAsset->pcScene->mMeshes[i];
|
||||||
|
|
||||||
// create the material for the mesh
|
// create the material for the mesh
|
||||||
|
@ -534,8 +506,7 @@ int CreateAssetData()
|
||||||
D3DFMT_INDEX32,
|
D3DFMT_INDEX32,
|
||||||
D3DPOOL_DEFAULT,
|
D3DPOOL_DEFAULT,
|
||||||
&g_pcAsset->apcMeshes[i]->piIB,
|
&g_pcAsset->apcMeshes[i]->piIB,
|
||||||
nullptr)))
|
nullptr))) {
|
||||||
{
|
|
||||||
MessageBox(g_hDlg, "Failed to create 32 Bit index buffer",
|
MessageBox(g_hDlg, "Failed to create 32 Bit index buffer",
|
||||||
"ASSIMP Viewer Utility", MB_OK);
|
"ASSIMP Viewer Utility", MB_OK);
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -544,15 +515,12 @@ int CreateAssetData()
|
||||||
// now fill the index buffer
|
// now fill the index buffer
|
||||||
unsigned int *pbData;
|
unsigned int *pbData;
|
||||||
g_pcAsset->apcMeshes[i]->piIB->Lock(0, 0, (void **)&pbData, 0);
|
g_pcAsset->apcMeshes[i]->piIB->Lock(0, 0, (void **)&pbData, 0);
|
||||||
for (unsigned int x = 0; x < mesh->mNumFaces;++x)
|
for (unsigned int x = 0; x < mesh->mNumFaces; ++x) {
|
||||||
{
|
for (unsigned int a = 0; a < nidx; ++a) {
|
||||||
for (unsigned int a = 0; a < nidx;++a)
|
|
||||||
{
|
|
||||||
*pbData++ = mesh->mFaces[x].mIndices[a];
|
*pbData++ = mesh->mFaces[x].mIndices[a];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// create 16 bit index buffer
|
// create 16 bit index buffer
|
||||||
if (FAILED(g_piDevice->CreateIndexBuffer(2 *
|
if (FAILED(g_piDevice->CreateIndexBuffer(2 *
|
||||||
numIndices,
|
numIndices,
|
||||||
|
@ -560,8 +528,7 @@ int CreateAssetData()
|
||||||
D3DFMT_INDEX16,
|
D3DFMT_INDEX16,
|
||||||
D3DPOOL_DEFAULT,
|
D3DPOOL_DEFAULT,
|
||||||
&g_pcAsset->apcMeshes[i]->piIB,
|
&g_pcAsset->apcMeshes[i]->piIB,
|
||||||
nullptr)))
|
nullptr))) {
|
||||||
{
|
|
||||||
MessageBox(g_hDlg, "Failed to create 16 Bit index buffer",
|
MessageBox(g_hDlg, "Failed to create 16 Bit index buffer",
|
||||||
"ASSIMP Viewer Utility", MB_OK);
|
"ASSIMP Viewer Utility", MB_OK);
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -570,10 +537,8 @@ int CreateAssetData()
|
||||||
// now fill the index buffer
|
// now fill the index buffer
|
||||||
uint16_t *pbData;
|
uint16_t *pbData;
|
||||||
g_pcAsset->apcMeshes[i]->piIB->Lock(0, 0, (void **)&pbData, 0);
|
g_pcAsset->apcMeshes[i]->piIB->Lock(0, 0, (void **)&pbData, 0);
|
||||||
for (unsigned int x = 0; x < mesh->mNumFaces;++x)
|
for (unsigned int x = 0; x < mesh->mNumFaces; ++x) {
|
||||||
{
|
for (unsigned int a = 0; a < nidx; ++a) {
|
||||||
for (unsigned int a = 0; a < nidx;++a)
|
|
||||||
{
|
|
||||||
*pbData++ = (uint16_t)mesh->mFaces[x].mIndices[a];
|
*pbData++ = (uint16_t)mesh->mFaces[x].mIndices[a];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,19 +556,18 @@ int CreateAssetData()
|
||||||
// now fill the vertex buffer
|
// now fill the vertex buffer
|
||||||
AssetHelper::Vertex *pbData2;
|
AssetHelper::Vertex *pbData2;
|
||||||
g_pcAsset->apcMeshes[i]->piVB->Lock(0, 0, (void **)&pbData2, 0);
|
g_pcAsset->apcMeshes[i]->piVB->Lock(0, 0, (void **)&pbData2, 0);
|
||||||
for (unsigned int x = 0; x < mesh->mNumVertices;++x)
|
for (unsigned int x = 0; x < mesh->mNumVertices; ++x) {
|
||||||
{
|
|
||||||
pbData2->vPosition = mesh->mVertices[x];
|
pbData2->vPosition = mesh->mVertices[x];
|
||||||
|
|
||||||
if (nullptr == mesh->mNormals)
|
if (nullptr == mesh->mNormals)
|
||||||
pbData2->vNormal = aiVector3D(0.0f, 0.0f, 0.0f);
|
pbData2->vNormal = aiVector3D(0.0f, 0.0f, 0.0f);
|
||||||
else pbData2->vNormal = mesh->mNormals[x];
|
else
|
||||||
|
pbData2->vNormal = mesh->mNormals[x];
|
||||||
|
|
||||||
if (nullptr == mesh->mTangents) {
|
if (nullptr == mesh->mTangents) {
|
||||||
pbData2->vTangent = aiVector3D(0.0f, 0.0f, 0.0f);
|
pbData2->vTangent = aiVector3D(0.0f, 0.0f, 0.0f);
|
||||||
pbData2->vBitangent = aiVector3D(0.0f, 0.0f, 0.0f);
|
pbData2->vBitangent = aiVector3D(0.0f, 0.0f, 0.0f);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
pbData2->vTangent = mesh->mTangents[x];
|
pbData2->vTangent = mesh->mTangents[x];
|
||||||
pbData2->vBitangent = mesh->mBitangents[x];
|
pbData2->vBitangent = mesh->mBitangents[x];
|
||||||
}
|
}
|
||||||
|
@ -614,39 +578,37 @@ int CreateAssetData()
|
||||||
((unsigned char)max(min(mesh->mColors[0][x].r * 255.0f, 255.0f), 0.0f)),
|
((unsigned char)max(min(mesh->mColors[0][x].r * 255.0f, 255.0f), 0.0f)),
|
||||||
((unsigned char)max(min(mesh->mColors[0][x].g * 255.0f, 255.0f), 0.0f)),
|
((unsigned char)max(min(mesh->mColors[0][x].g * 255.0f, 255.0f), 0.0f)),
|
||||||
((unsigned char)max(min(mesh->mColors[0][x].b * 255.0f, 255.0f), 0.0f)));
|
((unsigned char)max(min(mesh->mColors[0][x].b * 255.0f, 255.0f), 0.0f)));
|
||||||
}
|
} else
|
||||||
else pbData2->dColorDiffuse = D3DCOLOR_ARGB(0xFF,0xff,0xff,0xff);
|
pbData2->dColorDiffuse = D3DCOLOR_ARGB(0xFF, 0xff, 0xff, 0xff);
|
||||||
|
|
||||||
// ignore a third texture coordinate component
|
// ignore a third texture coordinate component
|
||||||
if (mesh->HasTextureCoords(0)) {
|
if (mesh->HasTextureCoords(0)) {
|
||||||
pbData2->vTextureUV = aiVector2D(
|
pbData2->vTextureUV = aiVector2D(
|
||||||
mesh->mTextureCoords[0][x].x,
|
mesh->mTextureCoords[0][x].x,
|
||||||
mesh->mTextureCoords[0][x].y);
|
mesh->mTextureCoords[0][x].y);
|
||||||
}
|
} else
|
||||||
else pbData2->vTextureUV = aiVector2D(0.5f,0.5f);
|
pbData2->vTextureUV = aiVector2D(0.5f, 0.5f);
|
||||||
|
|
||||||
if (mesh->HasTextureCoords(1)) {
|
if (mesh->HasTextureCoords(1)) {
|
||||||
pbData2->vTextureUV2 = aiVector2D(
|
pbData2->vTextureUV2 = aiVector2D(
|
||||||
mesh->mTextureCoords[1][x].x,
|
mesh->mTextureCoords[1][x].x,
|
||||||
mesh->mTextureCoords[1][x].y);
|
mesh->mTextureCoords[1][x].y);
|
||||||
}
|
} else
|
||||||
else pbData2->vTextureUV2 = aiVector2D(0.5f,0.5f);
|
pbData2->vTextureUV2 = aiVector2D(0.5f, 0.5f);
|
||||||
|
|
||||||
// Bone indices and weights
|
// Bone indices and weights
|
||||||
if (mesh->HasBones()) {
|
if (mesh->HasBones()) {
|
||||||
unsigned char boneIndices[4] = { 0, 0, 0, 0 };
|
unsigned char boneIndices[4] = { 0, 0, 0, 0 };
|
||||||
unsigned char boneWeights[4] = { 0, 0, 0, 0 };
|
unsigned char boneWeights[4] = { 0, 0, 0, 0 };
|
||||||
ai_assert(weightsPerVertex[x].size() <= 4);
|
ai_assert(weightsPerVertex[x].size() <= 4);
|
||||||
for( unsigned int a = 0; a < weightsPerVertex[x].size(); a++)
|
for (unsigned int a = 0; a < weightsPerVertex[x].size(); a++) {
|
||||||
{
|
|
||||||
boneIndices[a] = static_cast<unsigned char>(weightsPerVertex[x][a].mVertexId);
|
boneIndices[a] = static_cast<unsigned char>(weightsPerVertex[x][a].mVertexId);
|
||||||
boneWeights[a] = (unsigned char)(weightsPerVertex[x][a].mWeight * 255.0f);
|
boneWeights[a] = (unsigned char)(weightsPerVertex[x][a].mWeight * 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pbData2->mBoneIndices, boneIndices, sizeof(boneIndices));
|
memcpy(pbData2->mBoneIndices, boneIndices, sizeof(boneIndices));
|
||||||
memcpy(pbData2->mBoneWeights, boneWeights, sizeof(boneWeights));
|
memcpy(pbData2->mBoneWeights, boneWeights, sizeof(boneWeights));
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
memset(pbData2->mBoneIndices, 0, sizeof(pbData2->mBoneIndices));
|
memset(pbData2->mBoneIndices, 0, sizeof(pbData2->mBoneIndices));
|
||||||
memset(pbData2->mBoneWeights, 0, sizeof(pbData2->mBoneWeights));
|
memset(pbData2->mBoneWeights, 0, sizeof(pbData2->mBoneWeights));
|
||||||
}
|
}
|
||||||
|
@ -667,25 +629,20 @@ int CreateAssetData()
|
||||||
// Delete all effects, textures, vertex buffers ... associated with
|
// Delete all effects, textures, vertex buffers ... associated with
|
||||||
// an asset
|
// an asset
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int DeleteAssetData(bool bNoMaterials)
|
int DeleteAssetData(bool bNoMaterials) {
|
||||||
{
|
|
||||||
if (!g_pcAsset) return 0;
|
if (!g_pcAsset) return 0;
|
||||||
|
|
||||||
// TODO: Move this to a proper destructor
|
// TODO: Move this to a proper destructor
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i) {
|
||||||
{
|
if (g_pcAsset->apcMeshes[i]->piVB) {
|
||||||
if(g_pcAsset->apcMeshes[i]->piVB)
|
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piVB->Release();
|
g_pcAsset->apcMeshes[i]->piVB->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piVB = nullptr;
|
g_pcAsset->apcMeshes[i]->piVB = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piVBNormals)
|
if (g_pcAsset->apcMeshes[i]->piVBNormals) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piVBNormals->Release();
|
g_pcAsset->apcMeshes[i]->piVBNormals->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piVBNormals = nullptr;
|
g_pcAsset->apcMeshes[i]->piVBNormals = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piIB)
|
if (g_pcAsset->apcMeshes[i]->piIB) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piIB->Release();
|
g_pcAsset->apcMeshes[i]->piIB->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piIB = nullptr;
|
g_pcAsset->apcMeshes[i]->piIB = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -698,45 +655,36 @@ int DeleteAssetData(bool bNoMaterials)
|
||||||
// delete[] g_pcAsset->apcMeshes[i]->pvOriginalNormals;
|
// delete[] g_pcAsset->apcMeshes[i]->pvOriginalNormals;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (!bNoMaterials)
|
if (!bNoMaterials) {
|
||||||
{
|
if (g_pcAsset->apcMeshes[i]->piEffect) {
|
||||||
if(g_pcAsset->apcMeshes[i]->piEffect)
|
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piEffect->Release();
|
g_pcAsset->apcMeshes[i]->piEffect->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piEffect = nullptr;
|
g_pcAsset->apcMeshes[i]->piEffect = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piDiffuseTexture)
|
if (g_pcAsset->apcMeshes[i]->piDiffuseTexture) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piDiffuseTexture->Release();
|
g_pcAsset->apcMeshes[i]->piDiffuseTexture->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piDiffuseTexture = nullptr;
|
g_pcAsset->apcMeshes[i]->piDiffuseTexture = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piNormalTexture)
|
if (g_pcAsset->apcMeshes[i]->piNormalTexture) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piNormalTexture->Release();
|
g_pcAsset->apcMeshes[i]->piNormalTexture->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piNormalTexture = nullptr;
|
g_pcAsset->apcMeshes[i]->piNormalTexture = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piSpecularTexture)
|
if (g_pcAsset->apcMeshes[i]->piSpecularTexture) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piSpecularTexture->Release();
|
g_pcAsset->apcMeshes[i]->piSpecularTexture->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piSpecularTexture = nullptr;
|
g_pcAsset->apcMeshes[i]->piSpecularTexture = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piAmbientTexture)
|
if (g_pcAsset->apcMeshes[i]->piAmbientTexture) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piAmbientTexture->Release();
|
g_pcAsset->apcMeshes[i]->piAmbientTexture->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piAmbientTexture = nullptr;
|
g_pcAsset->apcMeshes[i]->piAmbientTexture = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piEmissiveTexture)
|
if (g_pcAsset->apcMeshes[i]->piEmissiveTexture) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piEmissiveTexture->Release();
|
g_pcAsset->apcMeshes[i]->piEmissiveTexture->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piEmissiveTexture = nullptr;
|
g_pcAsset->apcMeshes[i]->piEmissiveTexture = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piOpacityTexture)
|
if (g_pcAsset->apcMeshes[i]->piOpacityTexture) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piOpacityTexture->Release();
|
g_pcAsset->apcMeshes[i]->piOpacityTexture->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piOpacityTexture = nullptr;
|
g_pcAsset->apcMeshes[i]->piOpacityTexture = nullptr;
|
||||||
}
|
}
|
||||||
if(g_pcAsset->apcMeshes[i]->piShininessTexture)
|
if (g_pcAsset->apcMeshes[i]->piShininessTexture) {
|
||||||
{
|
|
||||||
g_pcAsset->apcMeshes[i]->piShininessTexture->Release();
|
g_pcAsset->apcMeshes[i]->piShininessTexture->Release();
|
||||||
g_pcAsset->apcMeshes[i]->piShininessTexture = nullptr;
|
g_pcAsset->apcMeshes[i]->piShininessTexture = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -745,22 +693,17 @@ int DeleteAssetData(bool bNoMaterials)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Switch between zoom/rotate view and the standard FPS view
|
// Switch between zoom/rotate view and the standard FPS view
|
||||||
// g_bFPSView specifies the view mode to setup
|
// g_bFPSView specifies the view mode to setup
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int SetupFPSView()
|
int SetupFPSView() {
|
||||||
{
|
if (!g_bFPSView) {
|
||||||
if (!g_bFPSView)
|
|
||||||
{
|
|
||||||
g_sCamera.vPos = aiVector3D(0.0f, 0.0f, g_fWheelPos);
|
g_sCamera.vPos = aiVector3D(0.0f, 0.0f, g_fWheelPos);
|
||||||
g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f);
|
g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f);
|
||||||
g_sCamera.vUp = aiVector3D(0.0f, 1.0f, 0.0f);
|
g_sCamera.vUp = aiVector3D(0.0f, 1.0f, 0.0f);
|
||||||
g_sCamera.vRight = aiVector3D(0.0f, 1.0f, 0.0f);
|
g_sCamera.vRight = aiVector3D(0.0f, 1.0f, 0.0f);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
g_fWheelPos = g_sCamera.vPos.z;
|
g_fWheelPos = g_sCamera.vPos.z;
|
||||||
g_sCamera.vPos = aiVector3D(0.0f, 0.0f, -10.0f);
|
g_sCamera.vPos = aiVector3D(0.0f, 0.0f, -10.0f);
|
||||||
g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f);
|
g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f);
|
||||||
|
@ -774,26 +717,21 @@ int SetupFPSView()
|
||||||
// Initialize the IDIrect3D interface
|
// Initialize the IDIrect3D interface
|
||||||
// Called by the WinMain
|
// Called by the WinMain
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int InitD3D(void)
|
int InitD3D(void) {
|
||||||
{
|
if (nullptr == g_piD3D) {
|
||||||
if (nullptr == g_piD3D)
|
|
||||||
{
|
|
||||||
g_piD3D = Direct3DCreate9(D3D_SDK_VERSION);
|
g_piD3D = Direct3DCreate9(D3D_SDK_VERSION);
|
||||||
if (nullptr == g_piD3D) return 0;
|
if (nullptr == g_piD3D) return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Release the IDirect3D interface.
|
// Release the IDirect3D interface.
|
||||||
// NOTE: Assumes that the device has already been deleted
|
// NOTE: Assumes that the device has already been deleted
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int ShutdownD3D(void)
|
int ShutdownD3D(void) {
|
||||||
{
|
|
||||||
ShutdownDevice();
|
ShutdownDevice();
|
||||||
if (nullptr != g_piD3D)
|
if (nullptr != g_piD3D) {
|
||||||
{
|
|
||||||
g_piD3D->Release();
|
g_piD3D->Release();
|
||||||
g_piD3D = nullptr;
|
g_piD3D = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -801,8 +739,7 @@ int ShutdownD3D(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TComPtr>
|
template <class TComPtr>
|
||||||
inline
|
inline void SafeRelease(TComPtr *&ptr) {
|
||||||
void SafeRelease(TComPtr *&ptr) {
|
|
||||||
if (nullptr != ptr) {
|
if (nullptr != ptr) {
|
||||||
ptr->Release();
|
ptr->Release();
|
||||||
ptr = nullptr;
|
ptr = nullptr;
|
||||||
|
@ -813,8 +750,7 @@ void SafeRelease(TComPtr *&ptr) {
|
||||||
// Shutdown the D3D device object and all resources associated with it
|
// Shutdown the D3D device object and all resources associated with it
|
||||||
// NOTE: Assumes that the asset has already been deleted
|
// NOTE: Assumes that the asset has already been deleted
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int ShutdownDevice(void)
|
int ShutdownDevice(void) {
|
||||||
{
|
|
||||||
// release other subsystems
|
// release other subsystems
|
||||||
CBackgroundPainter::Instance().ReleaseNativeResource();
|
CBackgroundPainter::Instance().ReleaseNativeResource();
|
||||||
CLogDisplay::Instance().ReleaseNativeResource();
|
CLogDisplay::Instance().ReleaseNativeResource();
|
||||||
|
@ -837,11 +773,9 @@ int ShutdownDevice(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CreateHUDTexture()
|
int CreateHUDTexture() {
|
||||||
{
|
|
||||||
// lock the memory resource ourselves
|
// lock the memory resource ourselves
|
||||||
HRSRC res = FindResource(nullptr, MAKEINTRESOURCE(IDR_HUD), RT_RCDATA);
|
HRSRC res = FindResource(nullptr, MAKEINTRESOURCE(IDR_HUD), RT_RCDATA);
|
||||||
HGLOBAL hg = LoadResource(nullptr, res);
|
HGLOBAL hg = LoadResource(nullptr, res);
|
||||||
|
@ -860,8 +794,7 @@ int CreateHUDTexture()
|
||||||
0,
|
0,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
&g_pcTexture)))
|
&g_pcTexture))) {
|
||||||
{
|
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load HUD texture",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load HUD texture",
|
||||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||||
|
|
||||||
|
@ -877,7 +810,6 @@ int CreateHUDTexture()
|
||||||
D3DSURFACE_DESC sDesc;
|
D3DSURFACE_DESC sDesc;
|
||||||
g_pcTexture->GetLevelDesc(0, &sDesc);
|
g_pcTexture->GetLevelDesc(0, &sDesc);
|
||||||
|
|
||||||
|
|
||||||
// lock the memory resource ourselves
|
// lock the memory resource ourselves
|
||||||
res = FindResource(nullptr, MAKEINTRESOURCE(IDR_HUDMASK), RT_RCDATA);
|
res = FindResource(nullptr, MAKEINTRESOURCE(IDR_HUDMASK), RT_RCDATA);
|
||||||
hg = LoadResource(nullptr, res);
|
hg = LoadResource(nullptr, res);
|
||||||
|
@ -897,8 +829,7 @@ int CreateHUDTexture()
|
||||||
0,
|
0,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
&pcTex)))
|
&pcTex))) {
|
||||||
{
|
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load HUD mask texture",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load HUD mask texture",
|
||||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||||
g_szImageMask = nullptr;
|
g_szImageMask = nullptr;
|
||||||
|
@ -917,8 +848,7 @@ int CreateHUDTexture()
|
||||||
unsigned char *_szOut = szOut;
|
unsigned char *_szOut = szOut;
|
||||||
|
|
||||||
unsigned char *szCur = (unsigned char *)sRect.pBits;
|
unsigned char *szCur = (unsigned char *)sRect.pBits;
|
||||||
for (unsigned int y = 0; y < sDesc.Height;++y)
|
for (unsigned int y = 0; y < sDesc.Height; ++y) {
|
||||||
{
|
|
||||||
memcpy(_szOut, szCur, sDesc.Width);
|
memcpy(_szOut, szCur, sDesc.Width);
|
||||||
|
|
||||||
szCur += sRect.Pitch;
|
szCur += sRect.Pitch;
|
||||||
|
@ -933,8 +863,7 @@ int CreateHUDTexture()
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
int CreateDevice(bool p_bMultiSample, bool p_bSuperSample, bool bHW /*= true*/) {
|
||||||
{
|
|
||||||
D3DDEVTYPE eType = bHW ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF;
|
D3DDEVTYPE eType = bHW ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF;
|
||||||
|
|
||||||
// get the client rectangle of the window.
|
// get the client rectangle of the window.
|
||||||
|
@ -962,30 +891,25 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
|
|
||||||
// check whether we can use a D32 depth buffer format
|
// check whether we can use a D32 depth buffer format
|
||||||
if (SUCCEEDED(g_piD3D->CheckDepthStencilMatch(0, eType,
|
if (SUCCEEDED(g_piD3D->CheckDepthStencilMatch(0, eType,
|
||||||
D3DFMT_X8R8G8B8,D3DFMT_X8R8G8B8,D3DFMT_D32)))
|
D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_D32))) {
|
||||||
{
|
|
||||||
sParams.AutoDepthStencilFormat = D3DFMT_D32;
|
sParams.AutoDepthStencilFormat = D3DFMT_D32;
|
||||||
}
|
} else
|
||||||
else sParams.AutoDepthStencilFormat = D3DFMT_D24X8;
|
sParams.AutoDepthStencilFormat = D3DFMT_D24X8;
|
||||||
|
|
||||||
// find the highest multisample type available on this device
|
// find the highest multisample type available on this device
|
||||||
D3DMULTISAMPLE_TYPE sMS = D3DMULTISAMPLE_2_SAMPLES;
|
D3DMULTISAMPLE_TYPE sMS = D3DMULTISAMPLE_2_SAMPLES;
|
||||||
D3DMULTISAMPLE_TYPE sMSOut = D3DMULTISAMPLE_NONE;
|
D3DMULTISAMPLE_TYPE sMSOut = D3DMULTISAMPLE_NONE;
|
||||||
DWORD dwQuality = 0;
|
DWORD dwQuality = 0;
|
||||||
if (p_bMultiSample)
|
if (p_bMultiSample) {
|
||||||
{
|
|
||||||
while ((D3DMULTISAMPLE_TYPE)(D3DMULTISAMPLE_16_SAMPLES + 1) !=
|
while ((D3DMULTISAMPLE_TYPE)(D3DMULTISAMPLE_16_SAMPLES + 1) !=
|
||||||
(sMS = (D3DMULTISAMPLE_TYPE)(sMS + 1)))
|
(sMS = (D3DMULTISAMPLE_TYPE)(sMS + 1))) {
|
||||||
{
|
|
||||||
if (SUCCEEDED(g_piD3D->CheckDeviceMultiSampleType(0, eType,
|
if (SUCCEEDED(g_piD3D->CheckDeviceMultiSampleType(0, eType,
|
||||||
sMode.Format,TRUE,sMS,&dwQuality)))
|
sMode.Format, TRUE, sMS, &dwQuality))) {
|
||||||
{
|
|
||||||
sMSOut = sMS;
|
sMSOut = sMS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 != dwQuality) dwQuality -= 1;
|
if (0 != dwQuality) dwQuality -= 1;
|
||||||
|
|
||||||
|
|
||||||
sParams.MultiSampleQuality = dwQuality;
|
sParams.MultiSampleQuality = dwQuality;
|
||||||
sParams.MultiSampleType = sMSOut;
|
sParams.MultiSampleType = sMSOut;
|
||||||
}
|
}
|
||||||
|
@ -999,8 +923,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
creationFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
creationFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||||
|
|
||||||
// create the D3D9 device object. with software-vertexprocessing if VS2.0 isn`t supported in hardware
|
// create the D3D9 device object. with software-vertexprocessing if VS2.0 isn`t supported in hardware
|
||||||
if(FAILED(g_piD3D->CreateDevice(0,eType, g_hDlg, creationFlags ,&sParams,&g_piDevice)))
|
if (FAILED(g_piD3D->CreateDevice(0, eType, g_hDlg, creationFlags, &sParams, &g_piDevice))) {
|
||||||
{
|
|
||||||
// if hardware fails use software rendering instead
|
// if hardware fails use software rendering instead
|
||||||
if (bHW) return CreateDevice(p_bMultiSample, p_bSuperSample, false);
|
if (bHW) return CreateDevice(p_bMultiSample, p_bSuperSample, false);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1008,8 +931,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
|
|
||||||
// create a vertex declaration to match the vertex
|
// create a vertex declaration to match the vertex
|
||||||
D3DVERTEXELEMENT9 *vdecl = AssetHelper::Vertex::GetDeclarationElements();
|
D3DVERTEXELEMENT9 *vdecl = AssetHelper::Vertex::GetDeclarationElements();
|
||||||
if( FAILED( g_piDevice->CreateVertexDeclaration( vdecl, &gDefaultVertexDecl)))
|
if (FAILED(g_piDevice->CreateVertexDeclaration(vdecl, &gDefaultVertexDecl))) {
|
||||||
{
|
|
||||||
MessageBox(g_hDlg, "Failed to create vertex declaration", "Init", MB_OK);
|
MessageBox(g_hDlg, "Failed to create vertex declaration", "Init", MB_OK);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1017,8 +939,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
|
|
||||||
// get the capabilities of the device object
|
// get the capabilities of the device object
|
||||||
g_piDevice->GetDeviceCaps(&g_sCaps);
|
g_piDevice->GetDeviceCaps(&g_sCaps);
|
||||||
if(g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0))
|
if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(3, 0)) {
|
||||||
{
|
|
||||||
EnableWindow(GetDlgItem(g_hDlg, IDC_LOWQUALITY), FALSE);
|
EnableWindow(GetDlgItem(g_hDlg, IDC_LOWQUALITY), FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,17 +952,14 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
nullptr,
|
nullptr,
|
||||||
AI_SHADER_COMPILE_FLAGS,
|
AI_SHADER_COMPILE_FLAGS,
|
||||||
nullptr,
|
nullptr,
|
||||||
&g_piDefaultEffect,&piBuffer)))
|
&g_piDefaultEffect, &piBuffer))) {
|
||||||
{
|
if (piBuffer) {
|
||||||
if( piBuffer)
|
|
||||||
{
|
|
||||||
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if( piBuffer)
|
if (piBuffer) {
|
||||||
{
|
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
piBuffer = nullptr;
|
piBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1053,17 +971,14 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
// create the shader used to draw the HUD
|
// create the shader used to draw the HUD
|
||||||
if (FAILED(D3DXCreateEffect(g_piDevice,
|
if (FAILED(D3DXCreateEffect(g_piDevice,
|
||||||
g_szPassThroughShader.c_str(), (UINT)g_szPassThroughShader.length(),
|
g_szPassThroughShader.c_str(), (UINT)g_szPassThroughShader.length(),
|
||||||
nullptr,nullptr,AI_SHADER_COMPILE_FLAGS,nullptr,&g_piPassThroughEffect,&piBuffer)))
|
nullptr, nullptr, AI_SHADER_COMPILE_FLAGS, nullptr, &g_piPassThroughEffect, &piBuffer))) {
|
||||||
{
|
if (piBuffer) {
|
||||||
if( piBuffer)
|
|
||||||
{
|
|
||||||
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if( piBuffer)
|
if (piBuffer) {
|
||||||
{
|
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
piBuffer = nullptr;
|
piBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1075,17 +990,14 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
// create the shader used to visualize normal vectors
|
// create the shader used to visualize normal vectors
|
||||||
if (FAILED(D3DXCreateEffect(g_piDevice,
|
if (FAILED(D3DXCreateEffect(g_piDevice,
|
||||||
g_szNormalsShader.c_str(), (UINT)g_szNormalsShader.length(),
|
g_szNormalsShader.c_str(), (UINT)g_szNormalsShader.length(),
|
||||||
nullptr,nullptr,AI_SHADER_COMPILE_FLAGS,nullptr,&g_piNormalsEffect, &piBuffer)))
|
nullptr, nullptr, AI_SHADER_COMPILE_FLAGS, nullptr, &g_piNormalsEffect, &piBuffer))) {
|
||||||
{
|
if (piBuffer) {
|
||||||
if( piBuffer)
|
|
||||||
{
|
|
||||||
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if( piBuffer)
|
if (piBuffer) {
|
||||||
{
|
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
piBuffer = nullptr;
|
piBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1108,15 +1020,13 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CreateDevice()
|
int CreateDevice() {
|
||||||
{
|
|
||||||
return CreateDevice(g_sOptions.bMultiSample,
|
return CreateDevice(g_sOptions.bMultiSample,
|
||||||
g_sOptions.bSuperSample);
|
g_sOptions.bSuperSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int GetProjectionMatrix (aiMatrix4x4& p_mOut)
|
int GetProjectionMatrix(aiMatrix4x4 &p_mOut) {
|
||||||
{
|
|
||||||
const float fFarPlane = 100.0f;
|
const float fFarPlane = 100.0f;
|
||||||
const float fNearPlane = 0.1f;
|
const float fNearPlane = 0.1f;
|
||||||
const float fFOV = (float)(45.0 * 0.0174532925);
|
const float fFOV = (float)(45.0 * 0.0174532925);
|
||||||
|
@ -1139,8 +1049,7 @@ int GetProjectionMatrix (aiMatrix4x4& p_mOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut)
|
aiVector3D GetCameraMatrix(aiMatrix4x4 &p_mOut) {
|
||||||
{
|
|
||||||
D3DXMATRIX view;
|
D3DXMATRIX view;
|
||||||
D3DXMatrixIdentity(&view);
|
D3DXMatrixIdentity(&view);
|
||||||
|
|
||||||
|
@ -1175,4 +1084,4 @@ aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut)
|
||||||
return g_sCamera.vPos;
|
return g_sCamera.vPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace AssimpView
|
||||||
|
|
|
@ -51,24 +51,24 @@ 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
|
||||||
|
@ -79,23 +79,21 @@ 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
|
||||||
|
@ -125,7 +123,6 @@ void HandleMouseInputSkyBox( void );
|
||||||
void HandleKeyboardInputTextureView(void);
|
void HandleKeyboardInputTextureView(void);
|
||||||
void HandleMouseInputTextureView(void);
|
void HandleMouseInputTextureView(void);
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Dialog procedure for the progress bar window
|
// Dialog procedure for the progress bar window
|
||||||
|
@ -161,7 +158,6 @@ INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
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
|
||||||
//
|
//
|
||||||
|
@ -170,22 +166,18 @@ INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
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
|
||||||
|
@ -232,8 +224,8 @@ enum EClickPos
|
||||||
|
|
||||||
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_mousePos /*= {0,0};*/;
|
||||||
extern POINT g_LastmousePos /*= {0,0}*/;
|
extern POINT g_LastmousePos /*= {0,0}*/;
|
||||||
|
@ -254,7 +246,6 @@ enum EClickPos
|
||||||
extern Camera g_sCamera;
|
extern Camera g_sCamera;
|
||||||
extern AssetHelper *g_pcAsset /*= NULL*/;
|
extern AssetHelper *g_pcAsset /*= NULL*/;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Contains the mask image for the HUD
|
// Contains the mask image for the HUD
|
||||||
// (used to determine the position of a click)
|
// (used to determine the position of a click)
|
||||||
|
@ -264,7 +255,6 @@ enum EClickPos
|
||||||
//
|
//
|
||||||
extern unsigned char *g_szImageMask /*= NULL*/;
|
extern unsigned char *g_szImageMask /*= NULL*/;
|
||||||
|
|
||||||
|
|
||||||
extern float g_fACMR /*= 3.0f*/;
|
extern float g_fACMR /*= 3.0f*/;
|
||||||
extern IDirect3DQuery9 *g_piQuery;
|
extern IDirect3DQuery9 *g_piQuery;
|
||||||
|
|
||||||
|
@ -275,6 +265,6 @@ enum EClickPos
|
||||||
|
|
||||||
extern unsigned int ppsteps, ppstepsdefault;
|
extern unsigned int ppsteps, ppstepsdefault;
|
||||||
extern bool nopointslines;
|
extern bool nopointslines;
|
||||||
}
|
} // namespace AssimpView
|
||||||
|
|
||||||
#endif // !! AV_MAIN_H_INCLUDED
|
#endif // !! AV_MAIN_H_INCLUDED
|
Loading…
Reference in New Issue