remove step prototype: does not work this way.
parent
9f03397f32
commit
a1bcca2c99
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
|
||||
|
|
@ -1,69 +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.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER
|
||||
|
||||
#include <assimp/BaseImporter.h>
|
||||
|
||||
namespace Assimp {
|
||||
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
|
File diff suppressed because it is too large
Load Diff
|
@ -47,8 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace Assimp {
|
||||
|
||||
CIOStreamWrapper::~CIOStreamWrapper(void)
|
||||
{
|
||||
CIOStreamWrapper::~CIOStreamWrapper(void) {
|
||||
/* Various places depend on this destructor to close the file */
|
||||
if (mFile) {
|
||||
mIO->mFileSystem->CloseProc(mIO->mFileSystem, mFile);
|
||||
|
@ -59,8 +58,7 @@ CIOStreamWrapper::~CIOStreamWrapper(void)
|
|||
// ...................................................................
|
||||
size_t CIOStreamWrapper::Read(void *pvBuffer,
|
||||
size_t pSize,
|
||||
size_t pCount
|
||||
){
|
||||
size_t pCount) {
|
||||
// need to typecast here as C has no void*
|
||||
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 pSize,
|
||||
size_t pCount
|
||||
){
|
||||
size_t pCount) {
|
||||
// need to typecast here as C has no void*
|
||||
return mFile->WriteProc(mFile, (const char *)pvBuffer, pSize, pCount);
|
||||
}
|
||||
|
||||
// ...................................................................
|
||||
aiReturn CIOStreamWrapper::Seek(size_t pOffset,
|
||||
aiOrigin pOrigin
|
||||
){
|
||||
aiOrigin pOrigin) {
|
||||
return mFile->SeekProc(mFile, pOffset, pOrigin);
|
||||
}
|
||||
|
||||
|
@ -133,4 +129,4 @@ void CIOSystemWrapper::Close( IOStream* pFile) {
|
|||
delete pFile;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Assimp
|
||||
|
|
|
@ -5,8 +5,6 @@ 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,
|
||||
|
@ -56,13 +54,11 @@ class CIOSystemWrapper;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Custom IOStream implementation for the C-API
|
||||
class CIOStreamWrapper : public IOStream
|
||||
{
|
||||
class CIOStreamWrapper : public IOStream {
|
||||
public:
|
||||
explicit CIOStreamWrapper(aiFile* pFile, CIOSystemWrapper* io)
|
||||
: mFile(pFile),
|
||||
mIO(io)
|
||||
{}
|
||||
explicit CIOStreamWrapper(aiFile *pFile, CIOSystemWrapper *io) :
|
||||
mFile(pFile),
|
||||
mIO(io) {}
|
||||
~CIOStreamWrapper(void);
|
||||
|
||||
size_t Read(void *pvBuffer, size_t pSize, size_t pCount);
|
||||
|
@ -77,23 +73,22 @@ private:
|
|||
CIOSystemWrapper *mIO;
|
||||
};
|
||||
|
||||
class CIOSystemWrapper : public IOSystem
|
||||
{
|
||||
class CIOSystemWrapper : public IOSystem {
|
||||
friend class CIOStreamWrapper;
|
||||
|
||||
public:
|
||||
explicit CIOSystemWrapper(aiFileIO* pFile)
|
||||
: mFileSystem(pFile)
|
||||
{}
|
||||
explicit CIOSystemWrapper(aiFileIO *pFile) :
|
||||
mFileSystem(pFile) {}
|
||||
|
||||
bool Exists(const char *pFile) const;
|
||||
char getOsSeparator() const;
|
||||
IOStream *Open(const char *pFile, const char *pMode = "rb");
|
||||
void Close(IOStream *pFile);
|
||||
|
||||
private:
|
||||
aiFileIO *mFileSystem;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Assimp
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,9 +47,10 @@ using namespace AssimpView;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor on a given animation.
|
||||
AnimEvaluator::AnimEvaluator( const aiAnimation *pAnim )
|
||||
: mAnim(pAnim)
|
||||
, mLastTime(0.0) {
|
||||
AnimEvaluator::AnimEvaluator(const aiAnimation *pAnim) :
|
||||
mAnim(pAnim),
|
||||
mLastTime(0.0) {
|
||||
ai_assert(nullptr != pAnim);
|
||||
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
|
||||
aiMatrix4x4 &mat = mTransforms[a];
|
||||
mat = aiMatrix4x4(presentRotation.GetMatrix());
|
||||
mat.a1 *= presentScaling.x; mat.b1 *= presentScaling.x; mat.c1 *= presentScaling.x;
|
||||
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;
|
||||
mat.a1 *= presentScaling.x;
|
||||
mat.b1 *= presentScaling.x;
|
||||
mat.c1 *= presentScaling.x;
|
||||
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;
|
||||
|
|
|
@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#if (!defined 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
|
||||
*/
|
||||
//-------------------------------------------------------------------------------
|
||||
class AssetHelper
|
||||
{
|
||||
class AssetHelper {
|
||||
public:
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
// the original normal set will be used
|
||||
ORIGINAL = 0x0u,
|
||||
|
||||
|
@ -73,9 +70,8 @@ namespace AssimpView {
|
|||
};
|
||||
|
||||
// default constructor
|
||||
AssetHelper()
|
||||
: iNormalSet( ORIGINAL )
|
||||
{
|
||||
AssetHelper() :
|
||||
iNormalSet(ORIGINAL) {
|
||||
mAnimator = NULL;
|
||||
apcMeshes = NULL;
|
||||
pcScene = NULL;
|
||||
|
@ -86,8 +82,7 @@ namespace AssimpView {
|
|||
// (even if tangents, bitangents or normals aren't
|
||||
// required by the shader they will be committed to the GPU)
|
||||
//---------------------------------------------------------------
|
||||
struct Vertex
|
||||
{
|
||||
struct Vertex {
|
||||
aiVector3D vPosition;
|
||||
aiVector3D vNormal;
|
||||
|
||||
|
@ -100,10 +95,8 @@ namespace AssimpView {
|
|||
unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
|
||||
|
||||
/** Returns the vertex declaration elements to create a declaration from. */
|
||||
static D3DVERTEXELEMENT9* GetDeclarationElements()
|
||||
{
|
||||
static D3DVERTEXELEMENT9 decl[] =
|
||||
{
|
||||
static D3DVERTEXELEMENT9 *GetDeclarationElements() {
|
||||
static D3DVERTEXELEMENT9 decl[] = {
|
||||
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
||||
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
|
||||
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
||||
|
@ -123,14 +116,12 @@ namespace AssimpView {
|
|||
//---------------------------------------------------------------
|
||||
// FVF vertex structure used for normals
|
||||
//---------------------------------------------------------------
|
||||
struct LineVertex
|
||||
{
|
||||
struct LineVertex {
|
||||
aiVector3D vPosition;
|
||||
DWORD dColorDiffuse;
|
||||
|
||||
// retrieves the FVF code of the vertex type
|
||||
static DWORD GetFVF()
|
||||
{
|
||||
static DWORD GetFVF() {
|
||||
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
|
||||
}
|
||||
};
|
||||
|
@ -139,12 +130,9 @@ namespace AssimpView {
|
|||
// Helper class to store GPU related resources created for
|
||||
// a given aiMesh
|
||||
//---------------------------------------------------------------
|
||||
class MeshHelper
|
||||
{
|
||||
class MeshHelper {
|
||||
public:
|
||||
|
||||
MeshHelper()
|
||||
:
|
||||
MeshHelper() :
|
||||
eShadingMode(),
|
||||
piVB(NULL),
|
||||
piIB(NULL),
|
||||
|
@ -163,11 +151,9 @@ namespace AssimpView {
|
|||
fShininess(),
|
||||
fSpecularStrength(),
|
||||
twosided(false),
|
||||
pvOriginalNormals( NULL )
|
||||
{}
|
||||
pvOriginalNormals(NULL) {}
|
||||
|
||||
~MeshHelper()
|
||||
{
|
||||
~MeshHelper() {
|
||||
// NOTE: This is done in DeleteAssetData()
|
||||
// TODO: Make this a proper d'tor
|
||||
}
|
||||
|
@ -245,6 +231,6 @@ namespace AssimpView {
|
|||
void FlipNormals();
|
||||
void FlipNormalsInt();
|
||||
};
|
||||
}
|
||||
} // namespace AssimpView
|
||||
|
||||
#endif // !! IG
|
||||
|
|
|
@ -118,8 +118,9 @@ CBackgroundPainter CBackgroundPainter::s_cInstance;
|
|||
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::SetColor(D3DCOLOR p_clrNew) {
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
if (TEXTURE_CUBE == eMode) {
|
||||
RemoveSBDeps();
|
||||
}
|
||||
|
||||
clrColor = p_clrNew;
|
||||
eMode = SIMPLE_COLOR;
|
||||
|
|
|
@ -45,22 +45,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "AssetHelper.h"
|
||||
|
||||
namespace AssimpView
|
||||
{
|
||||
namespace AssimpView {
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
/* Helper class to create, access and destroy materials
|
||||
*/
|
||||
//-------------------------------------------------------------------------------
|
||||
class CMaterialManager
|
||||
{
|
||||
class CMaterialManager {
|
||||
private:
|
||||
|
||||
friend class CDisplay;
|
||||
|
||||
// default constructor
|
||||
CMaterialManager()
|
||||
: m_iShaderCount( 0 ), sDefaultTexture() {}
|
||||
CMaterialManager() :
|
||||
m_iShaderCount(0), sDefaultTexture() {}
|
||||
|
||||
~CMaterialManager() {
|
||||
if (sDefaultTexture) {
|
||||
|
@ -70,12 +67,10 @@ namespace AssimpView
|
|||
}
|
||||
|
||||
public:
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Singleton accessors
|
||||
static CMaterialManager s_cInstance;
|
||||
inline static CMaterialManager& Instance()
|
||||
{
|
||||
inline static CMaterialManager &Instance() {
|
||||
return s_cInstance;
|
||||
}
|
||||
|
||||
|
@ -137,20 +132,17 @@ namespace AssimpView
|
|||
// The function tries to find a valid path for a texture
|
||||
int LoadTexture(IDirect3DTexture9 **p_ppiOut, aiString *szPath);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Getter for m_iShaderCount
|
||||
//
|
||||
inline unsigned int GetShaderCount()
|
||||
{
|
||||
inline unsigned int GetShaderCount() {
|
||||
return this->m_iShaderCount;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Reset the state of the class
|
||||
// Called whenever a new asset is loaded
|
||||
inline void Reset()
|
||||
{
|
||||
inline void Reset() {
|
||||
this->m_iShaderCount = 0;
|
||||
for (TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it) {
|
||||
(*it).second->Release();
|
||||
|
@ -159,7 +151,6 @@ namespace AssimpView
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// find a valid path to a texture file
|
||||
//
|
||||
|
@ -192,7 +183,6 @@ namespace AssimpView
|
|||
bool HasAlphaPixels(IDirect3DTexture9 *piTexture);
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// Specifies the number of different shaders generated for
|
||||
// the current asset. This number is incremented by CreateMaterial()
|
||||
|
@ -205,4 +195,4 @@ namespace AssimpView
|
|||
TextureCache sCachedTextures;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AssimpView
|
||||
|
|
|
@ -71,24 +71,14 @@ struct SceneAnimNode {
|
|||
int mChannelIndex;
|
||||
|
||||
//! Default construction
|
||||
SceneAnimNode()
|
||||
: mName()
|
||||
, mParent(nullptr)
|
||||
, mChildren()
|
||||
, mLocalTransform()
|
||||
, mGlobalTransform()
|
||||
, mChannelIndex(-1) {
|
||||
SceneAnimNode() :
|
||||
mName(), mParent(nullptr), mChildren(), mLocalTransform(), mGlobalTransform(), mChannelIndex(-1) {
|
||||
// empty
|
||||
}
|
||||
|
||||
//! Construction from a given name
|
||||
SceneAnimNode( const std::string& pName)
|
||||
: mName( pName)
|
||||
, mParent(nullptr)
|
||||
, mChildren()
|
||||
, mLocalTransform()
|
||||
, mGlobalTransform()
|
||||
, mChannelIndex(-1) {
|
||||
SceneAnimNode(const std::string &pName) :
|
||||
mName(pName), mParent(nullptr), mChildren(), mLocalTransform(), mGlobalTransform(), mChannelIndex(-1) {
|
||||
// empty
|
||||
}
|
||||
|
||||
|
@ -112,7 +102,6 @@ struct SceneAnimNode {
|
|||
*/
|
||||
class SceneAnimator {
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Constructor for a given scene.
|
||||
*
|
||||
|
@ -205,7 +194,6 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
|
||||
/** Recursively creates an internal node structure matching the
|
||||
* current scene and animation.
|
||||
*/
|
||||
|
|
|
@ -5,8 +5,6 @@ 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,
|
||||
|
@ -41,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "assimp_view.h"
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <map>
|
||||
|
@ -113,11 +110,9 @@ aiMatrix4x4 g_mWorldRotate;
|
|||
aiVector3D g_vRotateSpeed = aiVector3D(0.5f, 0.5f, 0.5f);
|
||||
|
||||
// NOTE: The second light direction is now computed from the first
|
||||
aiVector3D g_avLightDirs[1] =
|
||||
{ aiVector3D(-0.5f,0.6f,0.2f) };
|
||||
aiVector3D g_avLightDirs[1] = { 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, 0x00, 0x00),
|
||||
D3DCOLOR_ARGB(0xFF, 0x05, 0x05, 0x05),
|
||||
|
@ -145,14 +140,12 @@ unsigned char* g_szImageMask = nullptr;
|
|||
|
||||
float g_fLoadTime = 0.0f;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Entry point for the loader thread
|
||||
// The loader thread loads the asset while the progress dialog displays the
|
||||
// smart progress bar
|
||||
//-------------------------------------------------------------------------------
|
||||
DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
||||
{
|
||||
DWORD WINAPI LoadThreadProc(LPVOID lpParameter) {
|
||||
UNREFERENCED_PARAMETER(lpParameter);
|
||||
|
||||
// get current time
|
||||
|
@ -186,8 +179,7 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
|||
g_bLoadingFinished = true;
|
||||
|
||||
// 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:",
|
||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||
|
||||
|
@ -204,8 +196,7 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter)
|
|||
// load the current asset
|
||||
// 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
|
||||
g_mWorldRotate = aiMatrix4x4();
|
||||
g_mWorld = aiMatrix4x4();
|
||||
|
@ -225,8 +216,7 @@ int LoadAsset()
|
|||
g_pcAsset = new AssetHelper();
|
||||
g_hThreadHandle = CreateThread(nullptr, 0, &LoadThreadProc, nullptr, 0, &dwID);
|
||||
|
||||
if (!g_hThreadHandle)
|
||||
{
|
||||
if (!g_hThreadHandle) {
|
||||
CLogDisplay::Instance().AddEntry(
|
||||
"[ERROR] Unable to create helper thread for loading",
|
||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||
|
@ -243,10 +233,8 @@ int LoadAsset()
|
|||
|
||||
// now we should have loaded the asset. Check this ...
|
||||
g_bLoadingFinished = false;
|
||||
if (!g_pcAsset || !g_pcAsset->pcScene)
|
||||
{
|
||||
if (g_pcAsset)
|
||||
{
|
||||
if (!g_pcAsset || !g_pcAsset->pcScene) {
|
||||
if (g_pcAsset) {
|
||||
delete g_pcAsset;
|
||||
g_pcAsset = nullptr;
|
||||
}
|
||||
|
@ -259,7 +247,6 @@ int LoadAsset()
|
|||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i)
|
||||
g_pcAsset->apcMeshes[i] = new AssetHelper::MeshHelper();
|
||||
|
||||
|
||||
// create animator
|
||||
g_pcAsset->mAnimator = new SceneAnimator(g_pcAsset->pcScene);
|
||||
|
||||
|
@ -285,8 +272,7 @@ int LoadAsset()
|
|||
if (!g_pcAsset->pcScene->HasAnimations()) {
|
||||
EnableWindow(GetDlgItem(g_hDlg, IDC_PLAY), FALSE);
|
||||
EnableWindow(GetDlgItem(g_hDlg, IDC_SLIDERANIM), FALSE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EnableWindow(GetDlgItem(g_hDlg, IDC_PLAY), TRUE);
|
||||
EnableWindow(GetDlgItem(g_hDlg, IDC_SLIDERANIM), TRUE);
|
||||
}
|
||||
|
@ -305,7 +291,6 @@ int LoadAsset()
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Delete the loaded asset
|
||||
// The function does nothing is no asset is loaded
|
||||
|
@ -320,8 +305,7 @@ int DeleteAsset(void) {
|
|||
|
||||
// delete everything
|
||||
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];
|
||||
}
|
||||
aiReleaseImport(g_pcAsset->pcScene);
|
||||
|
@ -342,7 +326,6 @@ int DeleteAsset(void) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Calculate the boundaries of a given node and all of its children
|
||||
// The boundaries are in Worldspace (AABB)
|
||||
|
@ -358,11 +341,8 @@ int CalculateBounds(aiNode* piNode, aiVector3D* p_avOut, const aiMatrix4x4& piMa
|
|||
mTemp.Transpose();
|
||||
aiMatrix4x4 aiMe = mTemp * piMatrix;
|
||||
|
||||
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 i = 0; i < piNode->mNumMeshes; ++i) {
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
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
|
||||
// global world transformation matrix according to the aset AABB
|
||||
//-------------------------------------------------------------------------------
|
||||
int ScaleAsset(void)
|
||||
{
|
||||
int ScaleAsset(void) {
|
||||
aiVector3D aiVecs[2] = { aiVector3D(1e10f, 1e10f, 1e10f),
|
||||
aiVector3D(-1e10f, -1e10f, -1e10f) };
|
||||
|
||||
if (g_pcAsset->pcScene->mRootNode)
|
||||
{
|
||||
if (g_pcAsset->pcScene->mRootNode) {
|
||||
aiMatrix4x4 m;
|
||||
CalculateBounds(g_pcAsset->pcScene->mRootNode, aiVecs, m);
|
||||
}
|
||||
|
@ -422,8 +399,7 @@ int ScaleAsset(void)
|
|||
// pcMesh Input mesh
|
||||
// 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 != pcSource);
|
||||
|
||||
|
@ -434,8 +410,7 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo
|
|||
pcSource->mNumVertices * 2,
|
||||
D3DUSAGE_WRITEONLY,
|
||||
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",
|
||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||
return 2;
|
||||
|
@ -444,8 +419,7 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo
|
|||
// now fill the vertex buffer with data
|
||||
AssetHelper::LineVertex *pbData2;
|
||||
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;
|
||||
|
@ -472,16 +446,14 @@ int GenerateNormalsAsLineList(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSo
|
|||
// Create the native D3D representation of the asset: vertex buffers,
|
||||
// index buffers, materials ...
|
||||
//-------------------------------------------------------------------------------
|
||||
int CreateAssetData()
|
||||
{
|
||||
int CreateAssetData() {
|
||||
if (!g_pcAsset) return 0;
|
||||
|
||||
// reset all subsystems
|
||||
CMaterialManager::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];
|
||||
|
||||
// create the material for the mesh
|
||||
|
@ -534,8 +506,7 @@ int CreateAssetData()
|
|||
D3DFMT_INDEX32,
|
||||
D3DPOOL_DEFAULT,
|
||||
&g_pcAsset->apcMeshes[i]->piIB,
|
||||
nullptr)))
|
||||
{
|
||||
nullptr))) {
|
||||
MessageBox(g_hDlg, "Failed to create 32 Bit index buffer",
|
||||
"ASSIMP Viewer Utility", MB_OK);
|
||||
return 2;
|
||||
|
@ -544,15 +515,12 @@ int CreateAssetData()
|
|||
// now fill the index buffer
|
||||
unsigned int *pbData;
|
||||
g_pcAsset->apcMeshes[i]->piIB->Lock(0, 0, (void **)&pbData, 0);
|
||||
for (unsigned int x = 0; x < mesh->mNumFaces;++x)
|
||||
{
|
||||
for (unsigned int a = 0; a < nidx;++a)
|
||||
{
|
||||
for (unsigned int x = 0; x < mesh->mNumFaces; ++x) {
|
||||
for (unsigned int a = 0; a < nidx; ++a) {
|
||||
*pbData++ = mesh->mFaces[x].mIndices[a];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// create 16 bit index buffer
|
||||
if (FAILED(g_piDevice->CreateIndexBuffer(2 *
|
||||
numIndices,
|
||||
|
@ -560,8 +528,7 @@ int CreateAssetData()
|
|||
D3DFMT_INDEX16,
|
||||
D3DPOOL_DEFAULT,
|
||||
&g_pcAsset->apcMeshes[i]->piIB,
|
||||
nullptr)))
|
||||
{
|
||||
nullptr))) {
|
||||
MessageBox(g_hDlg, "Failed to create 16 Bit index buffer",
|
||||
"ASSIMP Viewer Utility", MB_OK);
|
||||
return 2;
|
||||
|
@ -570,10 +537,8 @@ int CreateAssetData()
|
|||
// now fill the index buffer
|
||||
uint16_t *pbData;
|
||||
g_pcAsset->apcMeshes[i]->piIB->Lock(0, 0, (void **)&pbData, 0);
|
||||
for (unsigned int x = 0; x < mesh->mNumFaces;++x)
|
||||
{
|
||||
for (unsigned int a = 0; a < nidx;++a)
|
||||
{
|
||||
for (unsigned int x = 0; x < mesh->mNumFaces; ++x) {
|
||||
for (unsigned int a = 0; a < nidx; ++a) {
|
||||
*pbData++ = (uint16_t)mesh->mFaces[x].mIndices[a];
|
||||
}
|
||||
}
|
||||
|
@ -591,19 +556,18 @@ int CreateAssetData()
|
|||
// now fill the vertex buffer
|
||||
AssetHelper::Vertex *pbData2;
|
||||
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];
|
||||
|
||||
if (nullptr == mesh->mNormals)
|
||||
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) {
|
||||
pbData2->vTangent = aiVector3D(0.0f, 0.0f, 0.0f);
|
||||
pbData2->vBitangent = aiVector3D(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pbData2->vTangent = mesh->mTangents[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].g * 255.0f, 255.0f), 0.0f)),
|
||||
((unsigned char)max(min(mesh->mColors[0][x].b * 255.0f, 255.0f), 0.0f)));
|
||||
}
|
||||
else pbData2->dColorDiffuse = D3DCOLOR_ARGB(0xFF,0xff,0xff,0xff);
|
||||
} else
|
||||
pbData2->dColorDiffuse = D3DCOLOR_ARGB(0xFF, 0xff, 0xff, 0xff);
|
||||
|
||||
// ignore a third texture coordinate component
|
||||
if (mesh->HasTextureCoords(0)) {
|
||||
pbData2->vTextureUV = aiVector2D(
|
||||
mesh->mTextureCoords[0][x].x,
|
||||
mesh->mTextureCoords[0][x].y);
|
||||
}
|
||||
else pbData2->vTextureUV = aiVector2D(0.5f,0.5f);
|
||||
} else
|
||||
pbData2->vTextureUV = aiVector2D(0.5f, 0.5f);
|
||||
|
||||
if (mesh->HasTextureCoords(1)) {
|
||||
pbData2->vTextureUV2 = aiVector2D(
|
||||
mesh->mTextureCoords[1][x].x,
|
||||
mesh->mTextureCoords[1][x].y);
|
||||
}
|
||||
else pbData2->vTextureUV2 = aiVector2D(0.5f,0.5f);
|
||||
} else
|
||||
pbData2->vTextureUV2 = aiVector2D(0.5f, 0.5f);
|
||||
|
||||
// Bone indices and weights
|
||||
if (mesh->HasBones()) {
|
||||
unsigned char boneIndices[4] = { 0, 0, 0, 0 };
|
||||
unsigned char boneWeights[4] = { 0, 0, 0, 0 };
|
||||
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);
|
||||
boneWeights[a] = (unsigned char)(weightsPerVertex[x][a].mWeight * 255.0f);
|
||||
}
|
||||
|
||||
memcpy(pbData2->mBoneIndices, boneIndices, sizeof(boneIndices));
|
||||
memcpy(pbData2->mBoneWeights, boneWeights, sizeof(boneWeights));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
memset(pbData2->mBoneIndices, 0, sizeof(pbData2->mBoneIndices));
|
||||
memset(pbData2->mBoneWeights, 0, sizeof(pbData2->mBoneWeights));
|
||||
}
|
||||
|
@ -667,25 +629,20 @@ int CreateAssetData()
|
|||
// Delete all effects, textures, vertex buffers ... associated with
|
||||
// an asset
|
||||
//-------------------------------------------------------------------------------
|
||||
int DeleteAssetData(bool bNoMaterials)
|
||||
{
|
||||
int DeleteAssetData(bool bNoMaterials) {
|
||||
if (!g_pcAsset) return 0;
|
||||
|
||||
// TODO: Move this to a proper destructor
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if(g_pcAsset->apcMeshes[i]->piVB)
|
||||
{
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i) {
|
||||
if (g_pcAsset->apcMeshes[i]->piVB) {
|
||||
g_pcAsset->apcMeshes[i]->piVB->Release();
|
||||
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 = nullptr;
|
||||
}
|
||||
if(g_pcAsset->apcMeshes[i]->piIB)
|
||||
{
|
||||
if (g_pcAsset->apcMeshes[i]->piIB) {
|
||||
g_pcAsset->apcMeshes[i]->piIB->Release();
|
||||
g_pcAsset->apcMeshes[i]->piIB = nullptr;
|
||||
}
|
||||
|
@ -698,45 +655,36 @@ int DeleteAssetData(bool bNoMaterials)
|
|||
// delete[] g_pcAsset->apcMeshes[i]->pvOriginalNormals;
|
||||
//}
|
||||
|
||||
if (!bNoMaterials)
|
||||
{
|
||||
if(g_pcAsset->apcMeshes[i]->piEffect)
|
||||
{
|
||||
if (!bNoMaterials) {
|
||||
if (g_pcAsset->apcMeshes[i]->piEffect) {
|
||||
g_pcAsset->apcMeshes[i]->piEffect->Release();
|
||||
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 = nullptr;
|
||||
}
|
||||
if(g_pcAsset->apcMeshes[i]->piNormalTexture)
|
||||
{
|
||||
if (g_pcAsset->apcMeshes[i]->piNormalTexture) {
|
||||
g_pcAsset->apcMeshes[i]->piNormalTexture->Release();
|
||||
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 = nullptr;
|
||||
}
|
||||
if(g_pcAsset->apcMeshes[i]->piAmbientTexture)
|
||||
{
|
||||
if (g_pcAsset->apcMeshes[i]->piAmbientTexture) {
|
||||
g_pcAsset->apcMeshes[i]->piAmbientTexture->Release();
|
||||
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 = nullptr;
|
||||
}
|
||||
if(g_pcAsset->apcMeshes[i]->piOpacityTexture)
|
||||
{
|
||||
if (g_pcAsset->apcMeshes[i]->piOpacityTexture) {
|
||||
g_pcAsset->apcMeshes[i]->piOpacityTexture->Release();
|
||||
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 = nullptr;
|
||||
}
|
||||
|
@ -745,22 +693,17 @@ int DeleteAssetData(bool bNoMaterials)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Switch between zoom/rotate view and the standard FPS view
|
||||
// g_bFPSView specifies the view mode to setup
|
||||
//-------------------------------------------------------------------------------
|
||||
int SetupFPSView()
|
||||
{
|
||||
if (!g_bFPSView)
|
||||
{
|
||||
int SetupFPSView() {
|
||||
if (!g_bFPSView) {
|
||||
g_sCamera.vPos = aiVector3D(0.0f, 0.0f, g_fWheelPos);
|
||||
g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f);
|
||||
g_sCamera.vUp = 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_sCamera.vPos = aiVector3D(0.0f, 0.0f, -10.0f);
|
||||
g_sCamera.vLookAt = aiVector3D(0.0f, 0.0f, 1.0f);
|
||||
|
@ -774,26 +717,21 @@ int SetupFPSView()
|
|||
// Initialize the IDIrect3D interface
|
||||
// Called by the WinMain
|
||||
//-------------------------------------------------------------------------------
|
||||
int InitD3D(void)
|
||||
{
|
||||
if (nullptr == g_piD3D)
|
||||
{
|
||||
int InitD3D(void) {
|
||||
if (nullptr == g_piD3D) {
|
||||
g_piD3D = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
if (nullptr == g_piD3D) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Release the IDirect3D interface.
|
||||
// NOTE: Assumes that the device has already been deleted
|
||||
//-------------------------------------------------------------------------------
|
||||
int ShutdownD3D(void)
|
||||
{
|
||||
int ShutdownD3D(void) {
|
||||
ShutdownDevice();
|
||||
if (nullptr != g_piD3D)
|
||||
{
|
||||
if (nullptr != g_piD3D) {
|
||||
g_piD3D->Release();
|
||||
g_piD3D = nullptr;
|
||||
}
|
||||
|
@ -801,8 +739,7 @@ int ShutdownD3D(void)
|
|||
}
|
||||
|
||||
template <class TComPtr>
|
||||
inline
|
||||
void SafeRelease(TComPtr *&ptr) {
|
||||
inline void SafeRelease(TComPtr *&ptr) {
|
||||
if (nullptr != ptr) {
|
||||
ptr->Release();
|
||||
ptr = nullptr;
|
||||
|
@ -813,8 +750,7 @@ void SafeRelease(TComPtr *&ptr) {
|
|||
// Shutdown the D3D device object and all resources associated with it
|
||||
// NOTE: Assumes that the asset has already been deleted
|
||||
//-------------------------------------------------------------------------------
|
||||
int ShutdownDevice(void)
|
||||
{
|
||||
int ShutdownDevice(void) {
|
||||
// release other subsystems
|
||||
CBackgroundPainter::Instance().ReleaseNativeResource();
|
||||
CLogDisplay::Instance().ReleaseNativeResource();
|
||||
|
@ -837,11 +773,9 @@ int ShutdownDevice(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
int CreateHUDTexture()
|
||||
{
|
||||
int CreateHUDTexture() {
|
||||
// lock the memory resource ourselves
|
||||
HRSRC res = FindResource(nullptr, MAKEINTRESOURCE(IDR_HUD), RT_RCDATA);
|
||||
HGLOBAL hg = LoadResource(nullptr, res);
|
||||
|
@ -860,8 +794,7 @@ int CreateHUDTexture()
|
|||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&g_pcTexture)))
|
||||
{
|
||||
&g_pcTexture))) {
|
||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load HUD texture",
|
||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||
|
||||
|
@ -877,7 +810,6 @@ int CreateHUDTexture()
|
|||
D3DSURFACE_DESC sDesc;
|
||||
g_pcTexture->GetLevelDesc(0, &sDesc);
|
||||
|
||||
|
||||
// lock the memory resource ourselves
|
||||
res = FindResource(nullptr, MAKEINTRESOURCE(IDR_HUDMASK), RT_RCDATA);
|
||||
hg = LoadResource(nullptr, res);
|
||||
|
@ -897,8 +829,7 @@ int CreateHUDTexture()
|
|||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&pcTex)))
|
||||
{
|
||||
&pcTex))) {
|
||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to load HUD mask texture",
|
||||
D3DCOLOR_ARGB(0xFF, 0xFF, 0, 0));
|
||||
g_szImageMask = nullptr;
|
||||
|
@ -917,8 +848,7 @@ int CreateHUDTexture()
|
|||
unsigned char *_szOut = szOut;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
// 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
|
||||
if (SUCCEEDED(g_piD3D->CheckDepthStencilMatch(0, eType,
|
||||
D3DFMT_X8R8G8B8,D3DFMT_X8R8G8B8,D3DFMT_D32)))
|
||||
{
|
||||
D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_D32))) {
|
||||
sParams.AutoDepthStencilFormat = D3DFMT_D32;
|
||||
}
|
||||
else sParams.AutoDepthStencilFormat = D3DFMT_D24X8;
|
||||
} else
|
||||
sParams.AutoDepthStencilFormat = D3DFMT_D24X8;
|
||||
|
||||
// find the highest multisample type available on this device
|
||||
D3DMULTISAMPLE_TYPE sMS = D3DMULTISAMPLE_2_SAMPLES;
|
||||
D3DMULTISAMPLE_TYPE sMSOut = D3DMULTISAMPLE_NONE;
|
||||
DWORD dwQuality = 0;
|
||||
if (p_bMultiSample)
|
||||
{
|
||||
if (p_bMultiSample) {
|
||||
while ((D3DMULTISAMPLE_TYPE)(D3DMULTISAMPLE_16_SAMPLES + 1) !=
|
||||
(sMS = (D3DMULTISAMPLE_TYPE)(sMS + 1)))
|
||||
{
|
||||
(sMS = (D3DMULTISAMPLE_TYPE)(sMS + 1))) {
|
||||
if (SUCCEEDED(g_piD3D->CheckDeviceMultiSampleType(0, eType,
|
||||
sMode.Format,TRUE,sMS,&dwQuality)))
|
||||
{
|
||||
sMode.Format, TRUE, sMS, &dwQuality))) {
|
||||
sMSOut = sMS;
|
||||
}
|
||||
}
|
||||
if (0 != dwQuality) dwQuality -= 1;
|
||||
|
||||
|
||||
sParams.MultiSampleQuality = dwQuality;
|
||||
sParams.MultiSampleType = sMSOut;
|
||||
}
|
||||
|
@ -999,8 +923,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
|||
creationFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||
|
||||
// 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 (bHW) return CreateDevice(p_bMultiSample, p_bSuperSample, false);
|
||||
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
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1017,8 +939,7 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
|||
|
||||
// get the capabilities of the device object
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1031,17 +952,14 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
|
|||
nullptr,
|
||||
AI_SHADER_COMPILE_FLAGS,
|
||||
nullptr,
|
||||
&g_piDefaultEffect,&piBuffer)))
|
||||
{
|
||||
if( piBuffer)
|
||||
{
|
||||
&g_piDefaultEffect, &piBuffer))) {
|
||||
if (piBuffer) {
|
||||
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
||||
piBuffer->Release();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if( piBuffer)
|
||||
{
|
||||
if (piBuffer) {
|
||||
piBuffer->Release();
|
||||
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
|
||||
if (FAILED(D3DXCreateEffect(g_piDevice,
|
||||
g_szPassThroughShader.c_str(), (UINT)g_szPassThroughShader.length(),
|
||||
nullptr,nullptr,AI_SHADER_COMPILE_FLAGS,nullptr,&g_piPassThroughEffect,&piBuffer)))
|
||||
{
|
||||
if( piBuffer)
|
||||
{
|
||||
nullptr, nullptr, AI_SHADER_COMPILE_FLAGS, nullptr, &g_piPassThroughEffect, &piBuffer))) {
|
||||
if (piBuffer) {
|
||||
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
||||
piBuffer->Release();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if( piBuffer)
|
||||
{
|
||||
if (piBuffer) {
|
||||
piBuffer->Release();
|
||||
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
|
||||
if (FAILED(D3DXCreateEffect(g_piDevice,
|
||||
g_szNormalsShader.c_str(), (UINT)g_szNormalsShader.length(),
|
||||
nullptr,nullptr,AI_SHADER_COMPILE_FLAGS,nullptr,&g_piNormalsEffect, &piBuffer)))
|
||||
{
|
||||
if( piBuffer)
|
||||
{
|
||||
nullptr, nullptr, AI_SHADER_COMPILE_FLAGS, nullptr, &g_piNormalsEffect, &piBuffer))) {
|
||||
if (piBuffer) {
|
||||
MessageBox(g_hDlg, (LPCSTR)piBuffer->GetBufferPointer(), "HLSL", MB_OK);
|
||||
piBuffer->Release();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if( piBuffer)
|
||||
{
|
||||
if (piBuffer) {
|
||||
piBuffer->Release();
|
||||
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,
|
||||
g_sOptions.bSuperSample);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int GetProjectionMatrix (aiMatrix4x4& p_mOut)
|
||||
{
|
||||
int GetProjectionMatrix(aiMatrix4x4 &p_mOut) {
|
||||
const float fFarPlane = 100.0f;
|
||||
const float fNearPlane = 0.1f;
|
||||
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;
|
||||
D3DXMatrixIdentity(&view);
|
||||
|
||||
|
@ -1175,4 +1084,4 @@ aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut)
|
|||
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 <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#include <time.h>
|
||||
|
||||
// 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/cfileio.h>
|
||||
#include <assimp/cimport.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/IOSystem.hpp>
|
||||
#include <assimp/IOStream.hpp>
|
||||
#include <assimp/LogStream.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 <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
|
||||
|
||||
#include "AssetHelper.h"
|
||||
#include "Camera.h"
|
||||
#include "RenderOptions.h"
|
||||
#include "Shaders.h"
|
||||
#include "Background.h"
|
||||
#include "Camera.h"
|
||||
#include "Display.h"
|
||||
#include "LogDisplay.h"
|
||||
#include "LogWindow.h"
|
||||
#include "Display.h"
|
||||
#include "MeshRenderer.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
|
||||
#include "AnimEvaluator.h"
|
||||
#include "SceneAnimator.h"
|
||||
|
||||
namespace AssimpView
|
||||
{
|
||||
namespace AssimpView {
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
|
@ -125,7 +123,6 @@ void HandleMouseInputSkyBox( void );
|
|||
void HandleKeyboardInputTextureView(void);
|
||||
void HandleMouseInputTextureView(void);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//
|
||||
// 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,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Handle command line parameters
|
||||
//
|
||||
|
@ -170,22 +166,18 @@ INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
|||
//-------------------------------------------------------------------------------
|
||||
void HandleCommandLine(char *p_szCommand);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
template <class type, class intype>
|
||||
type clamp(intype in)
|
||||
{
|
||||
type clamp(intype in) {
|
||||
// for unsigned types only ...
|
||||
intype mask = (0x1u << (sizeof(type) * 8)) - 1;
|
||||
return (type)std::max((intype)0, std::min(in, mask));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// 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)
|
||||
EClickPos_Circle,
|
||||
// The click was inside one of the vertical snap-ins
|
||||
|
@ -232,8 +224,8 @@ enum EClickPos
|
|||
|
||||
extern aiVector3D g_avLightDirs[1] /* =
|
||||
{ aiVector3D(-0.5f,0.6f,0.2f) ,
|
||||
aiVector3D(-0.5f,0.5f,0.5f)} */;
|
||||
|
||||
aiVector3D(-0.5f,0.5f,0.5f)} */
|
||||
;
|
||||
|
||||
extern POINT g_mousePos /*= {0,0};*/;
|
||||
extern POINT g_LastmousePos /*= {0,0}*/;
|
||||
|
@ -254,7 +246,6 @@ enum EClickPos
|
|||
extern Camera g_sCamera;
|
||||
extern AssetHelper *g_pcAsset /*= NULL*/;
|
||||
|
||||
|
||||
//
|
||||
// Contains the mask image for the HUD
|
||||
// (used to determine the position of a click)
|
||||
|
@ -264,7 +255,6 @@ enum EClickPos
|
|||
//
|
||||
extern unsigned char *g_szImageMask /*= NULL*/;
|
||||
|
||||
|
||||
extern float g_fACMR /*= 3.0f*/;
|
||||
extern IDirect3DQuery9 *g_piQuery;
|
||||
|
||||
|
@ -275,6 +265,6 @@ enum EClickPos
|
|||
|
||||
extern unsigned int ppsteps, ppstepsdefault;
|
||||
extern bool nopointslines;
|
||||
}
|
||||
} // namespace AssimpView
|
||||
|
||||
#endif // !! AV_MAIN_H_INCLUDED
|
||||
|
|
Loading…
Reference in New Issue