Merge branch 'master' of https://github.com/assimp/assimp
commit
1851bf3acc
|
@ -58,3 +58,4 @@ test/gtest/src/gtest-stamp/gtest-gitinfo.txt
|
||||||
test/gtest/src/gtest-stamp/gtest-gitclone-lastrun.txt
|
test/gtest/src/gtest-stamp/gtest-gitclone-lastrun.txt
|
||||||
Assimp.opensdf
|
Assimp.opensdf
|
||||||
contrib/zlib/CTestTestfile.cmake
|
contrib/zlib/CTestTestfile.cmake
|
||||||
|
ipch/assimp_viewer-44bbbcd1/assimp_viewerd-ccc45335.ipch
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
|
||||||
cmake_minimum_required( VERSION 2.8 )
|
cmake_minimum_required( VERSION 2.8 )
|
||||||
PROJECT( Assimp )
|
PROJECT( Assimp )
|
||||||
|
|
||||||
|
@ -61,9 +62,9 @@ if( CMAKE_COMPILER_IS_MINGW )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW)
|
if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW)
|
||||||
add_definitions(-fPIC) # this is a very important switch and some libraries seem now to have it....
|
set(CMAKE_CXX_FLAGS "-fPIC") # this is a very important switch and some libraries seem now to have it....
|
||||||
# hide all not-exported symbols
|
# hide all not-exported symbols
|
||||||
add_definitions( -fvisibility=hidden -Wall )
|
set(CMAKE_CXX_FLAGS "-fvisibility=hidden -Wall" )
|
||||||
elseif(MSVC)
|
elseif(MSVC)
|
||||||
# enable multi-core compilation with MSVC
|
# enable multi-core compilation with MSVC
|
||||||
add_definitions(/MP)
|
add_definitions(/MP)
|
||||||
|
|
|
@ -42,11 +42,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @brief Implementation of the Plain-C API
|
* @brief Implementation of the Plain-C API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../include/assimp/cimport.h"
|
#include <assimp/cimport.h>
|
||||||
#include "../include/assimp/LogStream.hpp"
|
#include <assimp/LogStream.hpp>
|
||||||
#include "../include/assimp/DefaultLogger.hpp"
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include "../include/assimp/importerdesc.h"
|
#include <assimp/Importer.hpp>
|
||||||
#include "../include/assimp/scene.h"
|
#include <assimp/importerdesc.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
#include "GenericProperty.h"
|
#include "GenericProperty.h"
|
||||||
#include "CInterfaceIOWrapper.h"
|
#include "CInterfaceIOWrapper.h"
|
||||||
|
@ -489,7 +490,7 @@ ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szNam
|
||||||
{
|
{
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||||
SetGenericProperty<int>(pp->ints,szName,value,NULL);
|
SetGenericProperty<int>(pp->ints,szName,value);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +500,7 @@ ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName,
|
||||||
{
|
{
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||||
SetGenericProperty<float>(pp->floats,szName,value,NULL);
|
SetGenericProperty<float>(pp->floats,szName,value);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +514,7 @@ ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName
|
||||||
}
|
}
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||||
SetGenericProperty<std::string>(pp->strings,szName,std::string(st->C_Str()),NULL);
|
SetGenericProperty<std::string>(pp->strings,szName,std::string(st->C_Str()));
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,7 +528,7 @@ ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName
|
||||||
}
|
}
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||||
SetGenericProperty<aiMatrix4x4>(pp->matrices,szName,*mat,NULL);
|
SetGenericProperty<aiMatrix4x4>(pp->matrices,szName,*mat);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "FileSystemFilter.h"
|
#include "FileSystemFilter.h"
|
||||||
#include "Importer.h"
|
#include "Importer.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include "../include/assimp/scene.h"
|
#include "../include/assimp/scene.h"
|
||||||
#include "../include/assimp/Importer.hpp"
|
#include "../include/assimp/Importer.hpp"
|
||||||
#include "../include/assimp/postprocess.h"
|
#include "../include/assimp/postprocess.h"
|
||||||
|
|
|
@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "Bitmap.h"
|
#include "Bitmap.h"
|
||||||
#include "../include/assimp/texture.h"
|
#include "../include/assimp/texture.h"
|
||||||
#include "../include/assimp/IOStream.hpp"
|
#include "../include/assimp/IOStream.hpp"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Helper class tp perform various byte oder swappings
|
/** @file Helper class tp perform various byte oder swappings
|
||||||
(e.g. little to big endian) */
|
(e.g. little to big endian) */
|
||||||
#ifndef AI_BYTESWAP_H_INC
|
#ifndef AI_BYTESWAPPER_H_INC
|
||||||
#define AI_BYTESWAP_H_INC
|
#define AI_BYTESWAPPER_H_INC
|
||||||
|
|
||||||
#include "../include/assimp/ai_assert.h"
|
#include "../include/assimp/ai_assert.h"
|
||||||
#include "../include/assimp/types.h"
|
#include "../include/assimp/types.h"
|
||||||
|
@ -283,4 +283,4 @@ struct Getter<SwapEndianess,T,false> {
|
||||||
} // end Intern
|
} // end Intern
|
||||||
} // end Assimp
|
} // end Assimp
|
||||||
|
|
||||||
#endif //!! AI_BYTESWAP_H_INC
|
#endif //!! AI_BYTESWAPPER_H_INC
|
|
@ -98,7 +98,7 @@ SET( Common_SRCS
|
||||||
ScenePrivate.h
|
ScenePrivate.h
|
||||||
PostStepRegistry.cpp
|
PostStepRegistry.cpp
|
||||||
ImporterRegistry.cpp
|
ImporterRegistry.cpp
|
||||||
ByteSwap.h
|
ByteSwapper.h
|
||||||
DefaultProgressHandler.h
|
DefaultProgressHandler.h
|
||||||
DefaultIOStream.cpp
|
DefaultIOStream.cpp
|
||||||
DefaultIOStream.h
|
DefaultIOStream.h
|
||||||
|
@ -784,7 +784,7 @@ if( MSVC )
|
||||||
else()
|
else()
|
||||||
set(MSVC_PREFIX "vc130")
|
set(MSVC_PREFIX "vc130")
|
||||||
endif()
|
endif()
|
||||||
set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" FORCE)
|
set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
SET_TARGET_PROPERTIES( assimp PROPERTIES
|
||||||
|
|
|
@ -513,6 +513,8 @@ struct Effect
|
||||||
// Scalar factory
|
// Scalar factory
|
||||||
float mShininess, mRefractIndex, mReflectivity;
|
float mShininess, mRefractIndex, mReflectivity;
|
||||||
float mTransparency;
|
float mTransparency;
|
||||||
|
bool mHasTransparency;
|
||||||
|
bool mRGBTransparency;
|
||||||
|
|
||||||
// local params referring to each other by their SID
|
// local params referring to each other by their SID
|
||||||
typedef std::map<std::string, Collada::EffectParam> ParamLibrary;
|
typedef std::map<std::string, Collada::EffectParam> ParamLibrary;
|
||||||
|
@ -533,7 +535,9 @@ struct Effect
|
||||||
, mShininess (10.0f)
|
, mShininess (10.0f)
|
||||||
, mRefractIndex (1.f)
|
, mRefractIndex (1.f)
|
||||||
, mReflectivity (1.f)
|
, mReflectivity (1.f)
|
||||||
, mTransparency (0.f)
|
, mTransparency (1.f)
|
||||||
|
, mHasTransparency (false)
|
||||||
|
, mRGBTransparency(false)
|
||||||
, mDoubleSided (false)
|
, mDoubleSided (false)
|
||||||
, mWireframe (false)
|
, mWireframe (false)
|
||||||
, mFaceted (false)
|
, mFaceted (false)
|
||||||
|
|
|
@ -117,6 +117,7 @@ void ColladaLoader::SetupProperties(const Importer* pImp)
|
||||||
{
|
{
|
||||||
noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0;
|
noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0;
|
||||||
ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION,0) != 0;
|
ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION,0) != 0;
|
||||||
|
invertTransparency = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_INVERT_TRANSPARENCY,0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1338,11 +1339,25 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pSce
|
||||||
mat.AddProperty( &effect.mRefractIndex, 1, AI_MATKEY_REFRACTI);
|
mat.AddProperty( &effect.mRefractIndex, 1, AI_MATKEY_REFRACTI);
|
||||||
|
|
||||||
// transparency, a very hard one. seemingly not all files are following the
|
// transparency, a very hard one. seemingly not all files are following the
|
||||||
// specification here .. but we can trick.
|
// specification here (1.0 transparency => completly opaque)...
|
||||||
if (effect.mTransparency >= 0.f && effect.mTransparency < 1.f) {
|
// therefore, we let the opportunity for the user to manually invert
|
||||||
effect.mTransparency = 1.f- effect.mTransparency;
|
// the transparency if necessary and we add preliminary support for RGB_ZERO mode
|
||||||
mat.AddProperty( &effect.mTransparency, 1, AI_MATKEY_OPACITY );
|
if(effect.mTransparency >= 0.f && effect.mTransparency <= 1.f) {
|
||||||
mat.AddProperty( &effect.mTransparent, 1, AI_MATKEY_COLOR_TRANSPARENT );
|
// Trying some support for RGB_ZERO mode
|
||||||
|
if(effect.mRGBTransparency) {
|
||||||
|
effect.mTransparency = 1.f - effect.mTransparent.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Global option
|
||||||
|
if(invertTransparency) {
|
||||||
|
effect.mTransparency = 1.f - effect.mTransparency;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is the material finally transparent ?
|
||||||
|
if (effect.mHasTransparency || effect.mTransparency < 1.f) {
|
||||||
|
mat.AddProperty( &effect.mTransparency, 1, AI_MATKEY_OPACITY );
|
||||||
|
mat.AddProperty( &effect.mTransparent, 1, AI_MATKEY_COLOR_TRANSPARENT );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add textures, if given
|
// add textures, if given
|
||||||
|
|
|
@ -241,6 +241,7 @@ protected:
|
||||||
|
|
||||||
bool noSkeletonMesh;
|
bool noSkeletonMesh;
|
||||||
bool ignoreUpDirection;
|
bool ignoreUpDirection;
|
||||||
|
bool invertTransparency;
|
||||||
|
|
||||||
/** Used by FindNameForNode() to generate unique node names */
|
/** Used by FindNameForNode() to generate unique node names */
|
||||||
unsigned int mNodeNameCounter;
|
unsigned int mNodeNameCounter;
|
||||||
|
|
|
@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
#include "ColladaParser.h"
|
#include "ColladaParser.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
#include "ParsingUtils.h"
|
#include "ParsingUtils.h"
|
||||||
|
@ -1230,6 +1231,14 @@ void ColladaParser::ReadEffectProfileCommon( Collada::Effect& pEffect)
|
||||||
ReadEffectColor( pEffect.mReflective, pEffect.mTexReflective);
|
ReadEffectColor( pEffect.mReflective, pEffect.mTexReflective);
|
||||||
}
|
}
|
||||||
else if( IsElement( "transparent")) {
|
else if( IsElement( "transparent")) {
|
||||||
|
pEffect.mHasTransparency = true;
|
||||||
|
|
||||||
|
// In RGB_ZERO mode, the transparency is interpreted in reverse, go figure...
|
||||||
|
if(::strcmp(mReader->getAttributeValueSafe("opaque"), "RGB_ZERO") == 0) {
|
||||||
|
// TODO: handle RGB_ZERO mode completely
|
||||||
|
pEffect.mRGBTransparency = true;
|
||||||
|
}
|
||||||
|
|
||||||
ReadEffectColor( pEffect.mTransparent,pEffect.mTexTransparent);
|
ReadEffectColor( pEffect.mTransparent,pEffect.mTexTransparent);
|
||||||
}
|
}
|
||||||
else if( IsElement( "shininess"))
|
else if( IsElement( "shininess"))
|
||||||
|
|
|
@ -513,34 +513,30 @@ ExportProperties::ExportProperties(const ExportProperties &other)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void ExportProperties :: SetPropertyInteger(const char* szName, int iValue,
|
bool ExportProperties :: SetPropertyInteger(const char* szName, int iValue)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
SetGenericProperty<int>(mIntProperties, szName,iValue,bWasExisting);
|
return SetGenericProperty<int>(mIntProperties, szName,iValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void ExportProperties :: SetPropertyFloat(const char* szName, float iValue,
|
bool ExportProperties :: SetPropertyFloat(const char* szName, float iValue)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
SetGenericProperty<float>(mFloatProperties, szName,iValue,bWasExisting);
|
return SetGenericProperty<float>(mFloatProperties, szName,iValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void ExportProperties :: SetPropertyString(const char* szName, const std::string& value,
|
bool ExportProperties :: SetPropertyString(const char* szName, const std::string& value)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
SetGenericProperty<std::string>(mStringProperties, szName,value,bWasExisting);
|
return SetGenericProperty<std::string>(mStringProperties, szName,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value,
|
bool ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
SetGenericProperty<aiMatrix4x4>(mMatrixProperties, szName,value,bWasExisting);
|
return SetGenericProperty<aiMatrix4x4>(mMatrixProperties, szName,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "../include/assimp/defs.h"
|
#include "../include/assimp/defs.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace FBX {
|
namespace FBX {
|
||||||
|
|
|
@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "ParsingUtils.h"
|
#include "ParsingUtils.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace Assimp::FBX;
|
using namespace Assimp::FBX;
|
||||||
|
@ -1316,4 +1316,3 @@ int64_t ParseTokenAsInt64(const Token& t)
|
||||||
} // !Assimp
|
} // !Assimp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -49,22 +49,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void SetGenericProperty(std::map< unsigned int, T >& list,
|
inline bool SetGenericProperty(std::map< unsigned int, T >& list,
|
||||||
const char* szName, const T& value, bool* bWasExisting = NULL)
|
const char* szName, const T& value)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != szName);
|
ai_assert(NULL != szName);
|
||||||
const uint32_t hash = SuperFastHash(szName);
|
const uint32_t hash = SuperFastHash(szName);
|
||||||
|
|
||||||
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
||||||
if (it == list.end()) {
|
if (it == list.end()) {
|
||||||
if (bWasExisting)
|
|
||||||
*bWasExisting = false;
|
|
||||||
list.insert(std::pair<unsigned int, T>( hash, value ));
|
list.insert(std::pair<unsigned int, T>( hash, value ));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
(*it).second = value;
|
(*it).second = value;
|
||||||
if (bWasExisting)
|
return true;
|
||||||
*bWasExisting = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
// Definitions for the Interchange File Format (IFF)
|
// Definitions for the Interchange File Format (IFF)
|
||||||
// Alexander Gessler, 2006
|
// Alexander Gessler, 2006
|
||||||
// Adapted to Assimp August 2008
|
// Adapted to Assimp August 2008
|
||||||
|
@ -7,7 +5,7 @@
|
||||||
#ifndef AI_IFF_H_INCLUDED
|
#ifndef AI_IFF_H_INCLUDED
|
||||||
#define AI_IFF_H_INCLUDED
|
#define AI_IFF_H_INCLUDED
|
||||||
|
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
namespace IFF {
|
namespace IFF {
|
||||||
|
|
|
@ -925,42 +925,46 @@ void Importer::GetExtensionList(aiString& szOut) const
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void Importer::SetPropertyInteger(const char* szName, int iValue,
|
bool Importer::SetPropertyInteger(const char* szName, int iValue)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
|
bool existing;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue,bWasExisting);
|
existing = SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void Importer::SetPropertyFloat(const char* szName, float iValue,
|
bool Importer::SetPropertyFloat(const char* szName, float iValue)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
|
bool exising;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
SetGenericProperty<float>(pimpl->mFloatProperties, szName,iValue,bWasExisting);
|
exising = SetGenericProperty<float>(pimpl->mFloatProperties, szName,iValue);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
return exising;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void Importer::SetPropertyString(const char* szName, const std::string& value,
|
bool Importer::SetPropertyString(const char* szName, const std::string& value)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
|
bool exising;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value,bWasExisting);
|
exising = SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
return exising;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Set a configuration property
|
// Set a configuration property
|
||||||
void Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value,
|
bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
|
||||||
bool* bWasExisting /*= NULL*/)
|
|
||||||
{
|
{
|
||||||
|
bool exising;
|
||||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||||
SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value,bWasExisting);
|
exising = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);
|
||||||
ASSIMP_END_EXCEPTION_REGION(void);
|
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||||
|
return exising;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "LWOLoader.h"
|
#include "LWOLoader.h"
|
||||||
#include "StringComparison.h"
|
#include "StringComparison.h"
|
||||||
#include "SGSpatialSort.h"
|
#include "SGSpatialSort.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include "ProcessHelper.h"
|
#include "ProcessHelper.h"
|
||||||
#include "ConvertToLHProcess.h"
|
#include "ConvertToLHProcess.h"
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
|
@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// internal headers
|
// internal headers
|
||||||
#include "LWOLoader.h"
|
#include "LWOLoader.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Implementation of the MD2 importer class */
|
/** @file Implementation of the MD2 importer class */
|
||||||
#include "MD2Loader.h"
|
#include "MD2Loader.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include "MD2NormalTable.h" // shouldn't be included by other units
|
#include "MD2NormalTable.h" // shouldn't be included by other units
|
||||||
#include "../include/assimp/DefaultLogger.hpp"
|
#include "../include/assimp/DefaultLogger.hpp"
|
||||||
#include "../include/assimp/Importer.hpp"
|
#include "../include/assimp/Importer.hpp"
|
||||||
|
|
|
@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "../include/assimp/types.h"
|
#include "../include/assimp/types.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
|
|
||||||
#include "MD2FileData.h"
|
#include "MD2FileData.h"
|
||||||
struct aiNode;
|
struct aiNode;
|
||||||
|
|
|
@ -52,7 +52,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_MD3_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_MD3_IMPORTER
|
||||||
|
|
||||||
#include "MD3Loader.h"
|
#include "MD3Loader.h"
|
||||||
#include "ByteSwap.h"
|
|
||||||
#include "SceneCombiner.h"
|
#include "SceneCombiner.h"
|
||||||
#include "GenericProperty.h"
|
#include "GenericProperty.h"
|
||||||
#include "RemoveComments.h"
|
#include "RemoveComments.h"
|
||||||
|
@ -564,7 +563,7 @@ bool MD3Importer::ReadMultipartFile()
|
||||||
|
|
||||||
// ensure we won't try to load ourselves recursively
|
// ensure we won't try to load ourselves recursively
|
||||||
BatchLoader::PropertyMap props;
|
BatchLoader::PropertyMap props;
|
||||||
SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0, NULL);
|
SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0);
|
||||||
|
|
||||||
// now read these three files
|
// now read these three files
|
||||||
BatchLoader batch(mIOHandler);
|
BatchLoader batch(mIOHandler);
|
||||||
|
|
|
@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_MD3LOADER_H_INCLUDED
|
#define AI_MD3LOADER_H_INCLUDED
|
||||||
|
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include "MD3FileData.h"
|
#include "MD3FileData.h"
|
||||||
#include "StringComparison.h"
|
#include "StringComparison.h"
|
||||||
#include "../include/assimp/types.h"
|
#include "../include/assimp/types.h"
|
||||||
|
|
|
@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "MDCFileData.h"
|
#include "MDCFileData.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
using namespace MDC;
|
using namespace MDC;
|
||||||
|
@ -125,4 +125,3 @@ protected:
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
#endif // AI_3DSIMPORTER_H_INC
|
#endif // AI_3DSIMPORTER_H_INC
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_MDLFILEHELPER_H_INC
|
#ifndef AI_MDLFILEHELPER_H_INC
|
||||||
#define AI_MDLFILEHELPER_H_INC
|
#define AI_MDLFILEHELPER_H_INC
|
||||||
|
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include "./../include/assimp/anim.h"
|
#include "./../include/assimp/anim.h"
|
||||||
#include "./../include/assimp/mesh.h"
|
#include "./../include/assimp/mesh.h"
|
||||||
#include "./../include/assimp/Compiler/pushpack1.h"
|
#include "./../include/assimp/Compiler/pushpack1.h"
|
||||||
|
|
|
@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include "ObjFileMtlImporter.h"
|
#include "ObjFileMtlImporter.h"
|
||||||
#include "ObjTools.h"
|
#include "ObjTools.h"
|
||||||
#include "ObjFileData.h"
|
#include "ObjFileData.h"
|
||||||
|
@ -85,146 +86,146 @@ static const std::string TypeOption = "-type";
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Constructor
|
// Constructor
|
||||||
ObjFileMtlImporter::ObjFileMtlImporter( std::vector<char> &buffer,
|
ObjFileMtlImporter::ObjFileMtlImporter( std::vector<char> &buffer,
|
||||||
const std::string & /*strAbsPath*/,
|
const std::string & /*strAbsPath*/,
|
||||||
ObjFile::Model *pModel ) :
|
ObjFile::Model *pModel ) :
|
||||||
m_DataIt( buffer.begin() ),
|
m_DataIt( buffer.begin() ),
|
||||||
m_DataItEnd( buffer.end() ),
|
m_DataItEnd( buffer.end() ),
|
||||||
m_pModel( pModel ),
|
m_pModel( pModel ),
|
||||||
m_uiLine( 0 )
|
m_uiLine( 0 )
|
||||||
{
|
{
|
||||||
ai_assert( NULL != m_pModel );
|
ai_assert( NULL != m_pModel );
|
||||||
if ( NULL == m_pModel->m_pDefaultMaterial )
|
if ( NULL == m_pModel->m_pDefaultMaterial )
|
||||||
{
|
{
|
||||||
m_pModel->m_pDefaultMaterial = new ObjFile::Material;
|
m_pModel->m_pDefaultMaterial = new ObjFile::Material;
|
||||||
m_pModel->m_pDefaultMaterial->MaterialName.Set( "default" );
|
m_pModel->m_pDefaultMaterial->MaterialName.Set( "default" );
|
||||||
}
|
}
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Destructor
|
// Destructor
|
||||||
ObjFileMtlImporter::~ObjFileMtlImporter()
|
ObjFileMtlImporter::~ObjFileMtlImporter()
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Private copy constructor
|
// Private copy constructor
|
||||||
ObjFileMtlImporter::ObjFileMtlImporter(const ObjFileMtlImporter & /* rOther */ )
|
ObjFileMtlImporter::ObjFileMtlImporter(const ObjFileMtlImporter & /* rOther */ )
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Private copy constructor
|
// Private copy constructor
|
||||||
ObjFileMtlImporter &ObjFileMtlImporter::operator = ( const ObjFileMtlImporter & /*rOther */ )
|
ObjFileMtlImporter &ObjFileMtlImporter::operator = ( const ObjFileMtlImporter & /*rOther */ )
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Loads the material description
|
// Loads the material description
|
||||||
void ObjFileMtlImporter::load()
|
void ObjFileMtlImporter::load()
|
||||||
{
|
{
|
||||||
if ( m_DataIt == m_DataItEnd )
|
if ( m_DataIt == m_DataItEnd )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while ( m_DataIt != m_DataItEnd )
|
while ( m_DataIt != m_DataItEnd )
|
||||||
{
|
{
|
||||||
switch (*m_DataIt)
|
switch (*m_DataIt)
|
||||||
{
|
{
|
||||||
case 'k':
|
case 'k':
|
||||||
case 'K':
|
case 'K':
|
||||||
{
|
{
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
if (*m_DataIt == 'a') // Ambient color
|
if (*m_DataIt == 'a') // Ambient color
|
||||||
{
|
{
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
getColorRGBA( &m_pModel->m_pCurrentMaterial->ambient );
|
getColorRGBA( &m_pModel->m_pCurrentMaterial->ambient );
|
||||||
}
|
}
|
||||||
else if (*m_DataIt == 'd') // Diffuse color
|
else if (*m_DataIt == 'd') // Diffuse color
|
||||||
{
|
{
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
getColorRGBA( &m_pModel->m_pCurrentMaterial->diffuse );
|
getColorRGBA( &m_pModel->m_pCurrentMaterial->diffuse );
|
||||||
}
|
}
|
||||||
else if (*m_DataIt == 's')
|
else if (*m_DataIt == 's')
|
||||||
{
|
{
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
getColorRGBA( &m_pModel->m_pCurrentMaterial->specular );
|
getColorRGBA( &m_pModel->m_pCurrentMaterial->specular );
|
||||||
}
|
}
|
||||||
else if (*m_DataIt == 'e')
|
else if (*m_DataIt == 'e')
|
||||||
{
|
{
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
getColorRGBA( &m_pModel->m_pCurrentMaterial->emissive );
|
getColorRGBA( &m_pModel->m_pCurrentMaterial->emissive );
|
||||||
}
|
}
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd': // Alpha value
|
case 'd': // Alpha value
|
||||||
{
|
{
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
getFloatValue( m_pModel->m_pCurrentMaterial->alpha );
|
getFloatValue( m_pModel->m_pCurrentMaterial->alpha );
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
case 'n':
|
case 'n':
|
||||||
{
|
{
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
switch(*m_DataIt)
|
switch(*m_DataIt)
|
||||||
{
|
{
|
||||||
case 's': // Specular exponent
|
case 's': // Specular exponent
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
getFloatValue(m_pModel->m_pCurrentMaterial->shineness);
|
getFloatValue(m_pModel->m_pCurrentMaterial->shineness);
|
||||||
break;
|
break;
|
||||||
case 'i': // Index Of refraction
|
case 'i': // Index Of refraction
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
getFloatValue(m_pModel->m_pCurrentMaterial->ior);
|
getFloatValue(m_pModel->m_pCurrentMaterial->ior);
|
||||||
break;
|
break;
|
||||||
case 'e': // New material
|
case 'e': // New material
|
||||||
createMaterial();
|
createMaterial();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm': // Texture
|
case 'm': // Texture
|
||||||
case 'b': // quick'n'dirty - for 'bump' sections
|
case 'b': // quick'n'dirty - for 'bump' sections
|
||||||
{
|
{
|
||||||
getTexture();
|
getTexture();
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i': // Illumination model
|
case 'i': // Illumination model
|
||||||
{
|
{
|
||||||
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
||||||
getIlluminationModel( m_pModel->m_pCurrentMaterial->illumination_model );
|
getIlluminationModel( m_pModel->m_pCurrentMaterial->illumination_model );
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Loads a color definition
|
// Loads a color definition
|
||||||
void ObjFileMtlImporter::getColorRGBA( aiColor3D *pColor )
|
void ObjFileMtlImporter::getColorRGBA( aiColor3D *pColor )
|
||||||
{
|
{
|
||||||
ai_assert( NULL != pColor );
|
ai_assert( NULL != pColor );
|
||||||
|
|
||||||
float r( 0.0f ), g( 0.0f ), b( 0.0f );
|
float r( 0.0f ), g( 0.0f ), b( 0.0f );
|
||||||
m_DataIt = getFloat<DataArrayIt>( m_DataIt, m_DataItEnd, r );
|
m_DataIt = getFloat<DataArrayIt>( m_DataIt, m_DataItEnd, r );
|
||||||
pColor->r = r;
|
pColor->r = r;
|
||||||
|
|
||||||
// we have to check if color is default 0 with only one token
|
// we have to check if color is default 0 with only one token
|
||||||
if( !IsLineEnd( *m_DataIt ) ) {
|
if( !IsLineEnd( *m_DataIt ) ) {
|
||||||
|
@ -239,107 +240,107 @@ void ObjFileMtlImporter::getColorRGBA( aiColor3D *pColor )
|
||||||
// Loads the kind of illumination model.
|
// Loads the kind of illumination model.
|
||||||
void ObjFileMtlImporter::getIlluminationModel( int &illum_model )
|
void ObjFileMtlImporter::getIlluminationModel( int &illum_model )
|
||||||
{
|
{
|
||||||
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
||||||
illum_model = atoi(m_buffer);
|
illum_model = atoi(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Loads a single float value.
|
// Loads a single float value.
|
||||||
void ObjFileMtlImporter::getFloatValue( float &value )
|
void ObjFileMtlImporter::getFloatValue( float &value )
|
||||||
{
|
{
|
||||||
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
|
||||||
value = (float) fast_atof(m_buffer);
|
value = (float) fast_atof(m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Creates a material from loaded data.
|
// Creates a material from loaded data.
|
||||||
void ObjFileMtlImporter::createMaterial()
|
void ObjFileMtlImporter::createMaterial()
|
||||||
{
|
{
|
||||||
std::string line( "" );
|
std::string line( "" );
|
||||||
while( !IsLineEnd( *m_DataIt ) ) {
|
while( !IsLineEnd( *m_DataIt ) ) {
|
||||||
line += *m_DataIt;
|
line += *m_DataIt;
|
||||||
++m_DataIt;
|
++m_DataIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> token;
|
std::vector<std::string> token;
|
||||||
const unsigned int numToken = tokenize<std::string>( line, token, " " );
|
const unsigned int numToken = tokenize<std::string>( line, token, " " );
|
||||||
std::string name( "" );
|
std::string name( "" );
|
||||||
if ( numToken == 1 ) {
|
if ( numToken == 1 ) {
|
||||||
name = AI_DEFAULT_MATERIAL_NAME;
|
name = AI_DEFAULT_MATERIAL_NAME;
|
||||||
} else {
|
} else {
|
||||||
name = token[ 1 ];
|
name = token[ 1 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
|
std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
|
||||||
if ( m_pModel->m_MaterialMap.end() == it) {
|
if ( m_pModel->m_MaterialMap.end() == it) {
|
||||||
// New Material created
|
// New Material created
|
||||||
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
m_pModel->m_pCurrentMaterial = new ObjFile::Material();
|
||||||
m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
|
m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
|
||||||
m_pModel->m_MaterialLib.push_back( name );
|
m_pModel->m_MaterialLib.push_back( name );
|
||||||
m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
|
m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
|
||||||
} else {
|
} else {
|
||||||
// Use older material
|
// Use older material
|
||||||
m_pModel->m_pCurrentMaterial = (*it).second;
|
m_pModel->m_pCurrentMaterial = (*it).second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Gets a texture name from data.
|
// Gets a texture name from data.
|
||||||
void ObjFileMtlImporter::getTexture() {
|
void ObjFileMtlImporter::getTexture() {
|
||||||
aiString *out( NULL );
|
aiString *out( NULL );
|
||||||
int clampIndex = -1;
|
int clampIndex = -1;
|
||||||
|
|
||||||
const char *pPtr( &(*m_DataIt) );
|
const char *pPtr( &(*m_DataIt) );
|
||||||
if ( !ASSIMP_strincmp( pPtr, DiffuseTexture.c_str(), DiffuseTexture.size() ) ) {
|
if ( !ASSIMP_strincmp( pPtr, DiffuseTexture.c_str(), DiffuseTexture.size() ) ) {
|
||||||
// Diffuse texture
|
// Diffuse texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->texture;
|
out = & m_pModel->m_pCurrentMaterial->texture;
|
||||||
clampIndex = ObjFile::Material::TextureDiffuseType;
|
clampIndex = ObjFile::Material::TextureDiffuseType;
|
||||||
} else if ( !ASSIMP_strincmp( pPtr,AmbientTexture.c_str(),AmbientTexture.size() ) ) {
|
} else if ( !ASSIMP_strincmp( pPtr,AmbientTexture.c_str(),AmbientTexture.size() ) ) {
|
||||||
// Ambient texture
|
// Ambient texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureAmbient;
|
out = & m_pModel->m_pCurrentMaterial->textureAmbient;
|
||||||
clampIndex = ObjFile::Material::TextureAmbientType;
|
clampIndex = ObjFile::Material::TextureAmbientType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr, SpecularTexture.c_str(), SpecularTexture.size())) {
|
} else if (!ASSIMP_strincmp( pPtr, SpecularTexture.c_str(), SpecularTexture.size())) {
|
||||||
// Specular texture
|
// Specular texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureSpecular;
|
out = & m_pModel->m_pCurrentMaterial->textureSpecular;
|
||||||
clampIndex = ObjFile::Material::TextureSpecularType;
|
clampIndex = ObjFile::Material::TextureSpecularType;
|
||||||
} else if ( !ASSIMP_strincmp( pPtr, OpacityTexture.c_str(), OpacityTexture.size() ) ) {
|
} else if ( !ASSIMP_strincmp( pPtr, OpacityTexture.c_str(), OpacityTexture.size() ) ) {
|
||||||
// Opacity texture
|
// Opacity texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureOpacity;
|
out = & m_pModel->m_pCurrentMaterial->textureOpacity;
|
||||||
clampIndex = ObjFile::Material::TextureOpacityType;
|
clampIndex = ObjFile::Material::TextureOpacityType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr, EmmissiveTexture.c_str(), EmmissiveTexture.size())) {
|
} else if (!ASSIMP_strincmp( pPtr, EmmissiveTexture.c_str(), EmmissiveTexture.size())) {
|
||||||
// Emissive texture
|
// Emissive texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureEmissive;
|
out = & m_pModel->m_pCurrentMaterial->textureEmissive;
|
||||||
clampIndex = ObjFile::Material::TextureEmissiveType;
|
clampIndex = ObjFile::Material::TextureEmissiveType;
|
||||||
} else if ( !ASSIMP_strincmp( pPtr, BumpTexture1.c_str(), BumpTexture1.size() ) ||
|
} else if ( !ASSIMP_strincmp( pPtr, BumpTexture1.c_str(), BumpTexture1.size() ) ||
|
||||||
!ASSIMP_strincmp( pPtr, BumpTexture2.c_str(), BumpTexture2.size() ) ||
|
!ASSIMP_strincmp( pPtr, BumpTexture2.c_str(), BumpTexture2.size() ) ||
|
||||||
!ASSIMP_strincmp( pPtr, BumpTexture3.c_str(), BumpTexture3.size() ) ) {
|
!ASSIMP_strincmp( pPtr, BumpTexture3.c_str(), BumpTexture3.size() ) ) {
|
||||||
// Bump texture
|
// Bump texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureBump;
|
out = & m_pModel->m_pCurrentMaterial->textureBump;
|
||||||
clampIndex = ObjFile::Material::TextureBumpType;
|
clampIndex = ObjFile::Material::TextureBumpType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr,NormalTexture.c_str(), NormalTexture.size())) {
|
} else if (!ASSIMP_strincmp( pPtr,NormalTexture.c_str(), NormalTexture.size())) {
|
||||||
// Normal map
|
// Normal map
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureNormal;
|
out = & m_pModel->m_pCurrentMaterial->textureNormal;
|
||||||
clampIndex = ObjFile::Material::TextureNormalType;
|
clampIndex = ObjFile::Material::TextureNormalType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr, DisplacementTexture.c_str(), DisplacementTexture.size() ) ) {
|
} else if (!ASSIMP_strincmp( pPtr, DisplacementTexture.c_str(), DisplacementTexture.size() ) ) {
|
||||||
// Displacement texture
|
// Displacement texture
|
||||||
out = &m_pModel->m_pCurrentMaterial->textureDisp;
|
out = &m_pModel->m_pCurrentMaterial->textureDisp;
|
||||||
clampIndex = ObjFile::Material::TextureDispType;
|
clampIndex = ObjFile::Material::TextureDispType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr, SpecularityTexture.c_str(),SpecularityTexture.size() ) ) {
|
} else if (!ASSIMP_strincmp( pPtr, SpecularityTexture.c_str(),SpecularityTexture.size() ) ) {
|
||||||
// Specularity scaling (glossiness)
|
// Specularity scaling (glossiness)
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureSpecularity;
|
out = & m_pModel->m_pCurrentMaterial->textureSpecularity;
|
||||||
clampIndex = ObjFile::Material::TextureSpecularityType;
|
clampIndex = ObjFile::Material::TextureSpecularityType;
|
||||||
} else {
|
} else {
|
||||||
DefaultLogger::get()->error("OBJ/MTL: Encountered unknown texture type");
|
DefaultLogger::get()->error("OBJ/MTL: Encountered unknown texture type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool clamp = false;
|
bool clamp = false;
|
||||||
getTextureOption(clamp);
|
getTextureOption(clamp);
|
||||||
m_pModel->m_pCurrentMaterial->clamp[clampIndex] = clamp;
|
m_pModel->m_pCurrentMaterial->clamp[clampIndex] = clamp;
|
||||||
|
|
||||||
std::string strTexture;
|
std::string strTexture;
|
||||||
m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strTexture );
|
m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strTexture );
|
||||||
out->Set( strTexture );
|
out->Set( strTexture );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* /////////////////////////////////////////////////////////////////////////////
|
/* /////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -359,54 +360,54 @@ void ObjFileMtlImporter::getTexture() {
|
||||||
*/
|
*/
|
||||||
void ObjFileMtlImporter::getTextureOption(bool &clamp)
|
void ObjFileMtlImporter::getTextureOption(bool &clamp)
|
||||||
{
|
{
|
||||||
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
||||||
|
|
||||||
//If there is any more texture option
|
//If there is any more texture option
|
||||||
while (!isEndOfBuffer(m_DataIt, m_DataItEnd) && *m_DataIt == '-')
|
while (!isEndOfBuffer(m_DataIt, m_DataItEnd) && *m_DataIt == '-')
|
||||||
{
|
{
|
||||||
const char *pPtr( &(*m_DataIt) );
|
const char *pPtr( &(*m_DataIt) );
|
||||||
//skip option key and value
|
//skip option key and value
|
||||||
int skipToken = 1;
|
int skipToken = 1;
|
||||||
|
|
||||||
if (!ASSIMP_strincmp(pPtr, ClampOption.c_str(), ClampOption.size()))
|
if (!ASSIMP_strincmp(pPtr, ClampOption.c_str(), ClampOption.size()))
|
||||||
{
|
{
|
||||||
DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
||||||
char value[3];
|
char value[3];
|
||||||
CopyNextWord(it, m_DataItEnd, value, sizeof(value) / sizeof(*value));
|
CopyNextWord(it, m_DataItEnd, value, sizeof(value) / sizeof(*value));
|
||||||
if (!ASSIMP_strincmp(value, "on", 2))
|
if (!ASSIMP_strincmp(value, "on", 2))
|
||||||
{
|
{
|
||||||
clamp = true;
|
clamp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
skipToken = 2;
|
skipToken = 2;
|
||||||
}
|
}
|
||||||
else if ( !ASSIMP_strincmp(pPtr, BlendUOption.c_str(), BlendUOption.size())
|
else if ( !ASSIMP_strincmp(pPtr, BlendUOption.c_str(), BlendUOption.size())
|
||||||
|| !ASSIMP_strincmp(pPtr, BlendVOption.c_str(), BlendVOption.size())
|
|| !ASSIMP_strincmp(pPtr, BlendVOption.c_str(), BlendVOption.size())
|
||||||
|| !ASSIMP_strincmp(pPtr, BoostOption.c_str(), BoostOption.size())
|
|| !ASSIMP_strincmp(pPtr, BoostOption.c_str(), BoostOption.size())
|
||||||
|| !ASSIMP_strincmp(pPtr, ResolutionOption.c_str(), ResolutionOption.size())
|
|| !ASSIMP_strincmp(pPtr, ResolutionOption.c_str(), ResolutionOption.size())
|
||||||
|| !ASSIMP_strincmp(pPtr, BumpOption.c_str(), BumpOption.size())
|
|| !ASSIMP_strincmp(pPtr, BumpOption.c_str(), BumpOption.size())
|
||||||
|| !ASSIMP_strincmp(pPtr, ChannelOption.c_str(), ChannelOption.size())
|
|| !ASSIMP_strincmp(pPtr, ChannelOption.c_str(), ChannelOption.size())
|
||||||
|| !ASSIMP_strincmp(pPtr, TypeOption.c_str(), TypeOption.size()) )
|
|| !ASSIMP_strincmp(pPtr, TypeOption.c_str(), TypeOption.size()) )
|
||||||
{
|
{
|
||||||
skipToken = 2;
|
skipToken = 2;
|
||||||
}
|
}
|
||||||
else if (!ASSIMP_strincmp(pPtr, ModifyMapOption.c_str(), ModifyMapOption.size()))
|
else if (!ASSIMP_strincmp(pPtr, ModifyMapOption.c_str(), ModifyMapOption.size()))
|
||||||
{
|
{
|
||||||
skipToken = 3;
|
skipToken = 3;
|
||||||
}
|
}
|
||||||
else if ( !ASSIMP_strincmp(pPtr, OffsetOption.c_str(), OffsetOption.size())
|
else if ( !ASSIMP_strincmp(pPtr, OffsetOption.c_str(), OffsetOption.size())
|
||||||
|| !ASSIMP_strincmp(pPtr, ScaleOption.c_str(), ScaleOption.size())
|
|| !ASSIMP_strincmp(pPtr, ScaleOption.c_str(), ScaleOption.size())
|
||||||
|| !ASSIMP_strincmp(pPtr, TurbulenceOption.c_str(), TurbulenceOption.size())
|
|| !ASSIMP_strincmp(pPtr, TurbulenceOption.c_str(), TurbulenceOption.size())
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
skipToken = 4;
|
skipToken = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < skipToken; ++i)
|
for (int i = 0; i < skipToken; ++i)
|
||||||
{
|
{
|
||||||
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "../include/assimp/DefaultLogger.hpp"
|
#include "../include/assimp/DefaultLogger.hpp"
|
||||||
#include "../include/assimp/material.h"
|
#include "../include/assimp/material.h"
|
||||||
#include "../include/assimp/Importer.hpp"
|
#include "../include/assimp/Importer.hpp"
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
|
@ -44,8 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "MakeVerboseFormat.h"
|
#include "MakeVerboseFormat.h"
|
||||||
|
|
||||||
#include <openddlparser/OpenDDLParser.h>
|
#include <openddlparser/OpenDDLParser.h>
|
||||||
#include "../include/assimp/scene.h"
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/ai_assert.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -80,6 +80,10 @@ namespace Grammar {
|
||||||
static const char *IndexArrayType = "IndexArray";
|
static const char *IndexArrayType = "IndexArray";
|
||||||
static const char *MaterialType = "Material";
|
static const char *MaterialType = "Material";
|
||||||
static const char *ColorType = "Color";
|
static const char *ColorType = "Color";
|
||||||
|
static const std::string DiffuseColorToken = "diffuse";
|
||||||
|
static const std::string SpecularColorToken = "specular";
|
||||||
|
static const std::string EmissionColorToken = "emission";
|
||||||
|
|
||||||
static const char *TextureType = "Texture";
|
static const char *TextureType = "Texture";
|
||||||
|
|
||||||
enum TokenType {
|
enum TokenType {
|
||||||
|
@ -363,9 +367,9 @@ void OpenGEXImporter::handleMetricNode( DDLNode *node, aiScene *pScene ) {
|
||||||
|
|
||||||
Property *prop( node->getProperties() );
|
Property *prop( node->getProperties() );
|
||||||
while( NULL != prop ) {
|
while( NULL != prop ) {
|
||||||
if( NULL != prop->m_id ) {
|
if( NULL != prop->m_key ) {
|
||||||
if( Value::ddl_string == prop->m_primData->m_type ) {
|
if( Value::ddl_string == prop->m_value->m_type ) {
|
||||||
std::string valName( (char*) prop->m_primData->m_data );
|
std::string valName( ( char* ) prop->m_value->m_data );
|
||||||
int type( Grammar::isValidMetricType( valName.c_str() ) );
|
int type( Grammar::isValidMetricType( valName.c_str() ) );
|
||||||
if( Grammar::NoneType != type ) {
|
if( Grammar::NoneType != type ) {
|
||||||
Value *val( node->getValue() );
|
Value *val( node->getValue() );
|
||||||
|
@ -415,7 +419,7 @@ static void getRefNames( DDLNode *node, std::vector<std::string> &names ) {
|
||||||
for( size_t i = 0; i < ref->m_numRefs; i++ ) {
|
for( size_t i = 0; i < ref->m_numRefs; i++ ) {
|
||||||
Name *currentName( ref->m_referencedName[ i ] );
|
Name *currentName( ref->m_referencedName[ i ] );
|
||||||
if( NULL != currentName && NULL != currentName->m_id ) {
|
if( NULL != currentName && NULL != currentName->m_id ) {
|
||||||
const std::string name( currentName->m_id->m_buffer );
|
const std::string name( currentName->m_id->m_text.m_buffer );
|
||||||
if( !name.empty() ) {
|
if( !name.empty() ) {
|
||||||
names.push_back( name );
|
names.push_back( name );
|
||||||
}
|
}
|
||||||
|
@ -530,10 +534,10 @@ static void propId2StdString( Property *prop, std::string &name, std::string &ke
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( NULL != prop->m_id ) {
|
if( NULL != prop->m_key ) {
|
||||||
name = prop->m_id->m_buffer;
|
name = prop->m_key->m_text.m_buffer;
|
||||||
if( Value::ddl_string == prop->m_primData->m_type ) {
|
if( Value::ddl_string == prop->m_value->m_type ) {
|
||||||
key = prop->m_primData->getString();
|
key = prop->m_value->getString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,7 +709,7 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
|
||||||
Value *next( vaList->m_dataList );
|
Value *next( vaList->m_dataList );
|
||||||
for( size_t indices = 0; indices < current.mNumIndices; indices++ ) {
|
for( size_t indices = 0; indices < current.mNumIndices; indices++ ) {
|
||||||
const int idx = next->getInt32();
|
const int idx = next->getInt32();
|
||||||
ai_assert( idx <= m_currentVertices.m_numVerts );
|
ai_assert( static_cast<size_t>( idx ) <= m_currentVertices.m_numVerts );
|
||||||
|
|
||||||
aiVector3D &pos = ( m_currentVertices.m_vertices[ idx ] );
|
aiVector3D &pos = ( m_currentVertices.m_vertices[ idx ] );
|
||||||
aiVector3D &normal = ( m_currentVertices.m_normals[ idx ] );
|
aiVector3D &normal = ( m_currentVertices.m_normals[ idx ] );
|
||||||
|
@ -725,30 +729,36 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
static void getColorRGBA( aiColor3D *pColor, Value *data ) {
|
static void getColorRGB( aiColor3D *pColor, DataArrayList *colList ) {
|
||||||
if( NULL == pColor || NULL == data ) {
|
if( NULL == pColor || NULL == colList ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pColor->r = data->getFloat();
|
ai_assert( 3 == colList->m_numItems );
|
||||||
data = data->getNext();
|
Value *val( colList->m_dataList );
|
||||||
pColor->g = data->getFloat();
|
pColor->r = val->getFloat();
|
||||||
data = data->getNext();
|
val = val->getNext();
|
||||||
pColor->b = data->getFloat();
|
pColor->g = val->getFloat();
|
||||||
data = data->getNext();
|
val = val->getNext();
|
||||||
|
pColor->b = val->getFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
enum ColorType {
|
enum ColorType {
|
||||||
NoneColor = 0,
|
NoneColor = 0,
|
||||||
DiffuseColor
|
DiffuseColor,
|
||||||
|
SpecularColor,
|
||||||
|
EmissionColor
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
static ColorType getColorType( Identifier *id ) {
|
static ColorType getColorType( Identifier *id ) {
|
||||||
const int res(strncmp("diffuse", id->m_buffer, id->m_len ) );
|
if( id->m_text == Grammar::DiffuseColorToken ) {
|
||||||
if( 0 == res ) {
|
|
||||||
return DiffuseColor;
|
return DiffuseColor;
|
||||||
|
} else if( id->m_text == Grammar::SpecularColorToken ) {
|
||||||
|
return SpecularColor;
|
||||||
|
} else if( id->m_text == Grammar::EmissionColorToken ) {
|
||||||
|
return EmissionColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NoneColor;
|
return NoneColor;
|
||||||
|
@ -769,9 +779,23 @@ void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Property *colorProp = node->getProperties();
|
Property *prop = node->findPropertyByName( "attrib" );
|
||||||
if( NULL != colorProp ) {
|
if( NULL != prop ) {
|
||||||
if( NULL != colorProp->m_id ) {
|
if( NULL != prop->m_value ) {
|
||||||
|
DataArrayList *colList( node->getDataArrayList() );
|
||||||
|
if( NULL == colList ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
aiColor3D col;
|
||||||
|
getColorRGB( &col, colList );
|
||||||
|
const ColorType colType( getColorType( prop->m_key ) );
|
||||||
|
if( DiffuseColor == colType ) {
|
||||||
|
m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_DIFFUSE );
|
||||||
|
} else if( SpecularColor == colType ) {
|
||||||
|
m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_SPECULAR );
|
||||||
|
} else if( EmissionColor == colType ) {
|
||||||
|
m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_EMISSIVE );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,13 +810,10 @@ void OpenGEXImporter::copyMeshes( aiScene *pScene ) {
|
||||||
if( m_meshCache.empty() ) {
|
if( m_meshCache.empty() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pScene->mNumMeshes = m_meshCache.size();
|
pScene->mNumMeshes = m_meshCache.size();
|
||||||
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
|
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
|
||||||
size_t i( 0 );
|
std::copy( m_meshCache.begin(), m_meshCache.end(), pScene->mMeshes );
|
||||||
for( std::vector<aiMesh*>::iterator it = m_meshCache.begin(); it != m_meshCache.end(); it++ ) {
|
|
||||||
pScene->mMeshes[ i ] = *it;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
@ -833,13 +854,10 @@ void OpenGEXImporter::createNodeTree( aiScene *pScene ) {
|
||||||
if( m_root->m_children.empty() ) {
|
if( m_root->m_children.empty() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t i( 0 );
|
|
||||||
pScene->mRootNode->mNumChildren = m_root->m_children.size();
|
pScene->mRootNode->mNumChildren = m_root->m_children.size();
|
||||||
pScene->mRootNode->mChildren = new C_STRUCT aiNode*[ pScene->mRootNode->mNumChildren ];
|
pScene->mRootNode->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren ];
|
||||||
for( ChildInfo::NodeList::iterator it = m_root->m_children.begin(); it != m_root->m_children.end(); it++ ) {
|
std::copy( m_root->m_children.begin(), m_root->m_children.end(), pScene->mRootNode->mChildren );
|
||||||
pScene->mRootNode->mChildren[ i ] = *it;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_OPENGEX_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_OPENGEX_IMPORTER
|
||||||
|
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
#include "../include/assimp/mesh.h"
|
#include <assimp/mesh.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
|
@ -44,11 +44,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "PlyExporter.h"
|
#include "PlyExporter.h"
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
#include <cmath>
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
#include "../include/assimp/scene.h"
|
#include "../include/assimp/scene.h"
|
||||||
#include "../include/assimp/version.h"
|
#include "../include/assimp/version.h"
|
||||||
#include "../include/assimp/IOSystem.hpp"
|
#include "../include/assimp/IOSystem.hpp"
|
||||||
#include "../include/assimp/Exporter.hpp"
|
#include "../include/assimp/Exporter.hpp"
|
||||||
|
#include "qnan.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
@ -213,6 +215,8 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
|
void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
|
||||||
{
|
{
|
||||||
|
static const float inf = std::numeric_limits<float>::infinity();
|
||||||
|
|
||||||
// If a component (for instance normal vectors) is present in at least one mesh in the scene,
|
// If a component (for instance normal vectors) is present in at least one mesh in the scene,
|
||||||
// then default values are written for meshes that do not contain this component.
|
// then default values are written for meshes that do not contain this component.
|
||||||
for (unsigned int i = 0; i < m->mNumVertices; ++i) {
|
for (unsigned int i = 0; i < m->mNumVertices; ++i) {
|
||||||
|
@ -222,11 +226,11 @@ void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
|
||||||
m->mVertices[i].z
|
m->mVertices[i].z
|
||||||
;
|
;
|
||||||
if(components & PLY_EXPORT_HAS_NORMALS) {
|
if(components & PLY_EXPORT_HAS_NORMALS) {
|
||||||
if (m->HasNormals()) {
|
if (m->HasNormals() && is_not_qnan(m->mNormals[i].x) && std::fabs(m->mNormals[i].x) != inf) {
|
||||||
mOutput <<
|
mOutput <<
|
||||||
" " << m->mNormals[i].x <<
|
" " << m->mNormals[i].x <<
|
||||||
" " << m->mNormals[i].y <<
|
" " << m->mNormals[i].y <<
|
||||||
" " << m->mNormals[i].z;
|
" " << m->mNormals[i].z;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mOutput << " 0.0 0.0 0.0";
|
mOutput << " 0.0 0.0 0.0";
|
||||||
|
|
|
@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "PlyLoader.h"
|
#include "PlyLoader.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
#include "../include/assimp/DefaultLogger.hpp"
|
#include "../include/assimp/DefaultLogger.hpp"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
|
@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "Q3BSPZipArchive.h"
|
#include "Q3BSPZipArchive.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cstdlib>
|
||||||
#include "../include/assimp/ai_assert.h"
|
#include "../include/assimp/ai_assert.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,11 +141,11 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem* pIOHandler) {
|
||||||
ZipFile::ZipFile(size_t size) : m_Size(size) {
|
ZipFile::ZipFile(size_t size) : m_Size(size) {
|
||||||
ai_assert(m_Size != 0);
|
ai_assert(m_Size != 0);
|
||||||
|
|
||||||
m_Buffer = std::malloc(m_Size);
|
m_Buffer = malloc(m_Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipFile::~ZipFile() {
|
ZipFile::~ZipFile() {
|
||||||
std::free(m_Buffer);
|
free(m_Buffer);
|
||||||
m_Buffer = NULL;
|
m_Buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -332,7 +332,7 @@ bool STEP::StringToUTF8(std::string& s)
|
||||||
case '4':
|
case '4':
|
||||||
if (s[i+3] == '\\') {
|
if (s[i+3] == '\\') {
|
||||||
const size_t basei = i+4;
|
const size_t basei = i+4;
|
||||||
size_t j = basei, jend = s.size()-4;
|
size_t j = basei, jend = s.size()-3;
|
||||||
|
|
||||||
for (; j < jend; ++j) {
|
for (; j < jend; ++j) {
|
||||||
if (s[j] == '\\' && s[j] == 'X' && s[j] == '0' && s[j] == '\\') {
|
if (s[j] == '\\' && s[j] == 'X' && s[j] == '0' && s[j] == '\\') {
|
||||||
|
|
|
@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "../include/assimp/Exporter.hpp"
|
#include "../include/assimp/Exporter.hpp"
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
|
@ -920,7 +920,7 @@ void SceneCombiner::MergeMaterials(aiMaterial** dest,
|
||||||
|
|
||||||
// Test if we already have a matching property
|
// Test if we already have a matching property
|
||||||
const aiMaterialProperty* prop_exist;
|
const aiMaterialProperty* prop_exist;
|
||||||
if(aiGetMaterialProperty(out, sprop->mKey.C_Str(), sprop->mType, sprop->mIndex, &prop_exist) != AI_SUCCESS) {
|
if(aiGetMaterialProperty(out, sprop->mKey.C_Str(), sprop->mSemantic, sprop->mIndex, &prop_exist) != AI_SUCCESS) {
|
||||||
// If not, we add it to the new material
|
// If not, we add it to the new material
|
||||||
aiMaterialProperty* prop = out->mProperties[out->mNumProperties] = new aiMaterialProperty();
|
aiMaterialProperty* prop = out->mProperties[out->mNumProperties] = new aiMaterialProperty();
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_STREAMREADER_H_INCLUDED
|
#ifndef AI_STREAMREADER_H_INCLUDED
|
||||||
#define AI_STREAMREADER_H_INCLUDED
|
#define AI_STREAMREADER_H_INCLUDED
|
||||||
|
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include "../include/assimp/IOStream.hpp"
|
#include "../include/assimp/IOStream.hpp"
|
||||||
|
|
|
@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_STREAMWRITER_H_INCLUDED
|
#ifndef AI_STREAMWRITER_H_INCLUDED
|
||||||
#define AI_STREAMWRITER_H_INCLUDED
|
#define AI_STREAMWRITER_H_INCLUDED
|
||||||
|
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include "../include/assimp/IOStream.hpp"
|
#include "../include/assimp/IOStream.hpp"
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
|
@ -51,6 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define INCLUDED_AI_STRING_WORKERS_H
|
#define INCLUDED_AI_STRING_WORKERS_H
|
||||||
|
|
||||||
#include "../include/assimp/ai_assert.h"
|
#include "../include/assimp/ai_assert.h"
|
||||||
|
#include "StringComparison.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -42,11 +42,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "TextureTransform.h"
|
#include <assimp/Importer.hpp>
|
||||||
#include "../include/assimp/postprocess.h"
|
#include <assimp/postprocess.h>
|
||||||
#include "../include/assimp/DefaultLogger.hpp"
|
#include <assimp/DefaultLogger.hpp>
|
||||||
#include "../include/assimp/scene.h"
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
|
#include "TextureTransform.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "ParsingUtils.h"
|
#include "ParsingUtils.h"
|
||||||
#include "fast_atof.h"
|
#include "fast_atof.h"
|
||||||
#include "ConvertToLHProcess.h"
|
#include "ConvertToLHProcess.h"
|
||||||
#include "../include/assimp/DefaultLogger.hpp"
|
|
||||||
#include "../include/assimp/IOSystem.hpp"
|
#include <assimp/Importer.hpp>
|
||||||
#include "../include/assimp/scene.h"
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
#include <assimp/IOSystem.hpp>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
|
@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwapper.h"
|
||||||
#include "../include/assimp/DefaultLogger.hpp"
|
#include "../include/assimp/DefaultLogger.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ inline int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* m
|
||||||
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
template <typename Real>
|
template <typename Real>
|
||||||
inline const char* fast_atoreal_move( const char* c, Real& out, bool check_comma = true)
|
inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true)
|
||||||
{
|
{
|
||||||
Real f = 0;
|
Real f = 0;
|
||||||
|
|
||||||
|
@ -286,14 +286,14 @@ inline const char* fast_atoreal_move( const char* c, Real& out, bool check_comma
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(c[0] >= '0' && c[0] <= '9') &&
|
if (!(c[0] >= '0' && c[0] <= '9') &&
|
||||||
!(c[0] == '.' && c[1] >= '0' && c[1] <= '9'))
|
!((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9'))
|
||||||
{
|
{
|
||||||
throw std::invalid_argument("Cannot parse string "
|
throw std::invalid_argument("Cannot parse string "
|
||||||
"as real number: does not start with digit "
|
"as real number: does not start with digit "
|
||||||
"or decimal point followed by digit.");
|
"or decimal point followed by digit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*c != '.')
|
if (*c != '.' && (! check_comma || c[0] != ','))
|
||||||
{
|
{
|
||||||
f = static_cast<Real>( strtoul10_64 ( c, &c) );
|
f = static_cast<Real>( strtoul10_64 ( c, &c) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ Property *DDLNode::findPropertyByName( const std::string &name ) {
|
||||||
}
|
}
|
||||||
Property *current( m_properties );
|
Property *current( m_properties );
|
||||||
while( ddl_nullptr != current ) {
|
while( ddl_nullptr != current ) {
|
||||||
int res = strncmp( current->m_id->m_buffer, name.c_str(), name.size() );
|
int res = strncmp( current->m_key->m_text.m_buffer, name.c_str(), name.size() );
|
||||||
if( 0 == res ) {
|
if( 0 == res ) {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ static DDLNode *createDDLNode( Identifier *id, OpenDDLParser *parser ) {
|
||||||
return ddl_nullptr;
|
return ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string type( id->m_buffer );
|
const std::string type( id->m_text.m_buffer );
|
||||||
DDLNode *parent( parser->top() );
|
DDLNode *parent( parser->top() );
|
||||||
DDLNode *node = DDLNode::create( type, "", parent );
|
DDLNode *node = DDLNode::create( type, "", parent );
|
||||||
|
|
||||||
|
@ -191,8 +191,6 @@ bool OpenDDLParser::parse() {
|
||||||
|
|
||||||
normalizeBuffer( m_buffer );
|
normalizeBuffer( m_buffer );
|
||||||
|
|
||||||
std::cout << &m_buffer[0] << std::endl;
|
|
||||||
|
|
||||||
m_context = new Context;
|
m_context = new Context;
|
||||||
m_context->m_root = DDLNode::create( "root", "", ddl_nullptr );
|
m_context->m_root = DDLNode::create( "root", "", ddl_nullptr );
|
||||||
pushNode( m_context->m_root );
|
pushNode( m_context->m_root );
|
||||||
|
@ -217,7 +215,7 @@ char *OpenDDLParser::parseNextNode( char *in, char *end ) {
|
||||||
|
|
||||||
static void dumpId( Identifier *id ) {
|
static void dumpId( Identifier *id ) {
|
||||||
if( ddl_nullptr != id ) {
|
if( ddl_nullptr != id ) {
|
||||||
std::cout << id->m_buffer << std::endl;
|
std::cout << id->m_text.m_buffer << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +275,7 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
Name *name( ddl_nullptr );
|
Name *name( ddl_nullptr );
|
||||||
in = OpenDDLParser::parseName( in, end, &name );
|
in = OpenDDLParser::parseName( in, end, &name );
|
||||||
if( ddl_nullptr != name ) {
|
if( ddl_nullptr != name ) {
|
||||||
const std::string nodeName( name->m_id->m_buffer );
|
const std::string nodeName( name->m_id->m_text.m_buffer );
|
||||||
node->setName( nodeName );
|
node->setName( nodeName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,10 +498,8 @@ char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
|
||||||
idLen++;
|
idLen++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t len( idLen + 1 );
|
const size_t len( idLen );
|
||||||
Identifier *newId = new Identifier( len, new char[ len ] );
|
Identifier *newId = new Identifier( start, len );
|
||||||
::strncpy( newId->m_buffer, start, newId->m_len-1 );
|
|
||||||
newId->m_buffer[ newId->m_len - 1 ] = '\0';
|
|
||||||
*id = newId;
|
*id = newId;
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
|
@ -714,7 +710,7 @@ char *OpenDDLParser::parseStringLiteral( char *in, char *end, Value **stringData
|
||||||
static void createPropertyWithData( Identifier *id, Value *primData, Property **prop ) {
|
static void createPropertyWithData( Identifier *id, Value *primData, Property **prop ) {
|
||||||
if( ddl_nullptr != primData ) {
|
if( ddl_nullptr != primData ) {
|
||||||
( *prop ) = new Property( id );
|
( *prop ) = new Property( id );
|
||||||
( *prop )->m_primData = primData;
|
( *prop )->m_value = primData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -77,41 +78,83 @@ enum NameType {
|
||||||
LocalName
|
LocalName
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Token {
|
struct Text {
|
||||||
public:
|
size_t m_capacity;
|
||||||
Token( const char *token )
|
size_t m_len;
|
||||||
: m_token( token )
|
char *m_buffer;
|
||||||
, m_size( 0 ){
|
|
||||||
if( ddl_nullptr != token ) {
|
Text( const char *buffer, size_t numChars )
|
||||||
m_size = strlen( m_token );
|
: m_capacity( 0 )
|
||||||
|
, m_len( 0 )
|
||||||
|
, m_buffer( ddl_nullptr ) {
|
||||||
|
set( buffer, numChars );
|
||||||
|
}
|
||||||
|
|
||||||
|
~Text() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
delete[] m_buffer;
|
||||||
|
m_buffer = ddl_nullptr;
|
||||||
|
m_capacity = 0;
|
||||||
|
m_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set( const char *buffer, size_t numChars ) {
|
||||||
|
clear();
|
||||||
|
if( numChars > 0 ) {
|
||||||
|
m_len = numChars;
|
||||||
|
m_capacity = m_len + 1;
|
||||||
|
m_buffer = new char[ m_capacity ];
|
||||||
|
strncpy( m_buffer, buffer, numChars );
|
||||||
|
m_buffer[ numChars ] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~Token() {
|
bool operator == ( const std::string &name ) const {
|
||||||
// empty
|
if( m_len != name.size() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const int res( strncmp( m_buffer, name.c_str(), name.size() ) );
|
||||||
|
return ( 0 == res );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t length() const {
|
bool operator == ( const Text &rhs ) const {
|
||||||
return m_size;
|
if( m_len != rhs.m_len ) {
|
||||||
}
|
|
||||||
|
|
||||||
bool operator == ( const Token &rhs ) const {
|
|
||||||
if( m_size != rhs.m_size ) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int res( strncmp( m_token, rhs.m_token, m_size ) );
|
const int res ( strncmp( m_buffer, rhs.m_buffer, m_len ) );
|
||||||
return ( res == 0 );
|
return ( 0 == res );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Token();
|
Text( const Text & );
|
||||||
Token( const Token & );
|
Text &operator = ( const Text & );
|
||||||
Token &operator = ( const Token & );
|
};
|
||||||
|
|
||||||
|
struct Identifier {
|
||||||
|
Text m_text;
|
||||||
|
|
||||||
|
Identifier( char buffer[], size_t len )
|
||||||
|
: m_text( buffer, len ) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
Identifier( char buffer[] )
|
||||||
|
: m_text( buffer, strlen( buffer ) ) {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == ( const Identifier &rhs ) const {
|
||||||
|
return m_text == rhs.m_text;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *m_token;
|
Identifier( const Identifier & );
|
||||||
size_t m_size;
|
Identifier &operator = ( const Identifier & );
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Name {
|
struct Name {
|
||||||
|
@ -154,30 +197,15 @@ private:
|
||||||
Reference &operator = ( const Reference & );
|
Reference &operator = ( const Reference & );
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Identifier {
|
|
||||||
size_t m_len;
|
|
||||||
char *m_buffer;
|
|
||||||
|
|
||||||
Identifier( size_t len, char buffer[] )
|
|
||||||
: m_len( len )
|
|
||||||
, m_buffer( buffer ) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Identifier( const Identifier & );
|
|
||||||
Identifier &operator = ( const Identifier & );
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Property {
|
struct Property {
|
||||||
Identifier *m_id;
|
Identifier *m_key;
|
||||||
Value *m_primData;
|
Value *m_value;
|
||||||
Reference *m_ref;
|
Reference *m_ref;
|
||||||
Property *m_next;
|
Property *m_next;
|
||||||
|
|
||||||
Property( Identifier *id )
|
Property( Identifier *id )
|
||||||
: m_id( id )
|
: m_key( id )
|
||||||
, m_primData( ddl_nullptr )
|
, m_value( ddl_nullptr )
|
||||||
, m_ref( ddl_nullptr )
|
, m_ref( ddl_nullptr )
|
||||||
, m_next( ddl_nullptr ) {
|
, m_next( ddl_nullptr ) {
|
||||||
// empty
|
// empty
|
||||||
|
|
|
@ -107,6 +107,12 @@ bool isNumeric( const T in ) {
|
||||||
return false;*/
|
return false;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline
|
||||||
|
bool isNotEndOfToken( T *in, T *end ) {
|
||||||
|
return ( '}' != *in && ',' != *in && !isSpace( *in ) && in != end );
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
bool isInteger( T *in, T *end ) {
|
bool isInteger( T *in, T *end ) {
|
||||||
|
@ -117,7 +123,8 @@ bool isInteger( T *in, T *end ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result( false );
|
bool result( false );
|
||||||
while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) {
|
while( isNotEndOfToken( in, end ) ) {
|
||||||
|
//while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) {
|
||||||
result = isNumeric( *in );
|
result = isNumeric( *in );
|
||||||
if( !result ) {
|
if( !result ) {
|
||||||
break;
|
break;
|
||||||
|
@ -139,7 +146,9 @@ bool isFloat( T *in, T *end ) {
|
||||||
|
|
||||||
// check for <1>.0f
|
// check for <1>.0f
|
||||||
bool result( false );
|
bool result( false );
|
||||||
while( !isSpace( *in ) && in != end ) {
|
while( isNotEndOfToken( in, end ) ) {
|
||||||
|
|
||||||
|
// while( !isSpace( *in ) && in != end ) {
|
||||||
if( *in == '.' ) {
|
if( *in == '.' ) {
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
|
@ -159,7 +168,9 @@ bool isFloat( T *in, T *end ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for 1.<0>f
|
// check for 1.<0>f
|
||||||
while( !isSpace( *in ) && in != end && *in != ',' ) {
|
while( isNotEndOfToken( in, end ) ) {
|
||||||
|
|
||||||
|
// while( !isSpace( *in ) && in != end && *in != ',' && *in != '}' ) {
|
||||||
result = isNumeric( *in );
|
result = isNumeric( *in );
|
||||||
if( !result ) {
|
if( !result ) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1586,7 +1586,7 @@ Don't trust the input data! Check all offsets!
|
||||||
|
|
||||||
Mixed stuff for internal use by loaders, mostly documented (most of them are already included by <i>AssimpPCH.h</i>):
|
Mixed stuff for internal use by loaders, mostly documented (most of them are already included by <i>AssimpPCH.h</i>):
|
||||||
<ul>
|
<ul>
|
||||||
<li><b>ByteSwap</b> (<i>ByteSwap.h</i>) - manual byte swapping stuff for binary loaders.</li>
|
<li><b>ByteSwapper</b> (<i>ByteSwapper.h</i>) - manual byte swapping stuff for binary loaders.</li>
|
||||||
<li><b>StreamReader</b> (<i>StreamReader.h</i>) - safe, endianess-correct, binary reading.</li>
|
<li><b>StreamReader</b> (<i>StreamReader.h</i>) - safe, endianess-correct, binary reading.</li>
|
||||||
<li><b>IrrXML</b> (<i>irrXMLWrapper.h</i>) - for XML-parsing (SAX.</li>
|
<li><b>IrrXML</b> (<i>irrXMLWrapper.h</i>) - for XML-parsing (SAX.</li>
|
||||||
<li><b>CommentRemover</b> (<i>RemoveComments.h</i>) - remove single-line and multi-line comments from a text file.</li>
|
<li><b>CommentRemover</b> (<i>RemoveComments.h</i>) - remove single-line and multi-line comments from a text file.</li>
|
||||||
|
|
|
@ -348,16 +348,14 @@ public:
|
||||||
* are defined in the aiConfig.g header (all constants share the
|
* are defined in the aiConfig.g header (all constants share the
|
||||||
* prefix AI_CONFIG_XXX and are simple strings).
|
* prefix AI_CONFIG_XXX and are simple strings).
|
||||||
* @param iValue New value of the property
|
* @param iValue New value of the property
|
||||||
* @param bWasExisting Optional pointer to receive true if the
|
* @return true if the property was set before. The new value replaces
|
||||||
* property was set before. The new value replaces the previous value
|
* the previous value in this case.
|
||||||
* in this case.
|
|
||||||
* @note Property of different types (float, int, string ..) are kept
|
* @note Property of different types (float, int, string ..) are kept
|
||||||
* on different stacks, so calling SetPropertyInteger() for a
|
* on different stacks, so calling SetPropertyInteger() for a
|
||||||
* floating-point property has no effect - the loader will call
|
* floating-point property has no effect - the loader will call
|
||||||
* GetPropertyFloat() to read the property, but it won't be there.
|
* GetPropertyFloat() to read the property, but it won't be there.
|
||||||
*/
|
*/
|
||||||
void SetPropertyInteger(const char* szName, int iValue,
|
bool SetPropertyInteger(const char* szName, int iValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a boolean configuration property. Boolean properties
|
/** Set a boolean configuration property. Boolean properties
|
||||||
|
@ -366,30 +364,27 @@ public:
|
||||||
* #GetPropertyBool and vice versa.
|
* #GetPropertyBool and vice versa.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) {
|
bool SetPropertyBool(const char* szName, bool value) {
|
||||||
SetPropertyInteger(szName,value,bWasExisting);
|
return SetPropertyInteger(szName,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a floating-point configuration property.
|
/** Set a floating-point configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyFloat(const char* szName, float fValue,
|
bool SetPropertyFloat(const char* szName, float fValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a string configuration property.
|
/** Set a string configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyString(const char* szName, const std::string& sValue,
|
bool SetPropertyString(const char* szName, const std::string& sValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a matrix configuration property.
|
/** Set a matrix configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue,
|
bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Get a configuration property.
|
/** Get a configuration property.
|
||||||
|
|
|
@ -194,16 +194,14 @@ public:
|
||||||
* are defined in the aiConfig.g header (all constants share the
|
* are defined in the aiConfig.g header (all constants share the
|
||||||
* prefix AI_CONFIG_XXX and are simple strings).
|
* prefix AI_CONFIG_XXX and are simple strings).
|
||||||
* @param iValue New value of the property
|
* @param iValue New value of the property
|
||||||
* @param bWasExisting Optional pointer to receive true if the
|
* @return true if the property was set before. The new value replaces
|
||||||
* property was set before. The new value replaces the previous value
|
* the previous value in this case.
|
||||||
* in this case.
|
|
||||||
* @note Property of different types (float, int, string ..) are kept
|
* @note Property of different types (float, int, string ..) are kept
|
||||||
* on different stacks, so calling SetPropertyInteger() for a
|
* on different stacks, so calling SetPropertyInteger() for a
|
||||||
* floating-point property has no effect - the loader will call
|
* floating-point property has no effect - the loader will call
|
||||||
* GetPropertyFloat() to read the property, but it won't be there.
|
* GetPropertyFloat() to read the property, but it won't be there.
|
||||||
*/
|
*/
|
||||||
void SetPropertyInteger(const char* szName, int iValue,
|
bool SetPropertyInteger(const char* szName, int iValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a boolean configuration property. Boolean properties
|
/** Set a boolean configuration property. Boolean properties
|
||||||
|
@ -212,30 +210,27 @@ public:
|
||||||
* #GetPropertyBool and vice versa.
|
* #GetPropertyBool and vice versa.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL) {
|
bool SetPropertyBool(const char* szName, bool value) {
|
||||||
SetPropertyInteger(szName,value,bWasExisting);
|
return SetPropertyInteger(szName,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a floating-point configuration property.
|
/** Set a floating-point configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyFloat(const char* szName, float fValue,
|
bool SetPropertyFloat(const char* szName, float fValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a string configuration property.
|
/** Set a string configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyString(const char* szName, const std::string& sValue,
|
bool SetPropertyString(const char* szName, const std::string& sValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Set a matrix configuration property.
|
/** Set a matrix configuration property.
|
||||||
* @see SetPropertyInteger()
|
* @see SetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue,
|
bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
|
||||||
bool* bWasExisting = NULL);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Get a configuration property.
|
/** Get a configuration property.
|
||||||
|
|
|
@ -877,8 +877,24 @@ enum aiComponent
|
||||||
*/
|
*/
|
||||||
#define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION"
|
#define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION"
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** @brief Specifies whether the Collada loader will ignore the provided up direction.
|
||||||
|
*
|
||||||
|
* If this property is set to true, the up direction provided in the file header will
|
||||||
|
* be ignored and the file will be loaded as is.
|
||||||
|
* Property type: Bool. Default value: false.
|
||||||
|
*/
|
||||||
#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION"
|
#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION"
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/** @brief Specifies whether the Collada loader will invert the transparency value.
|
||||||
|
*
|
||||||
|
* If this property is set to true, the transparency value will be interpreted as the
|
||||||
|
* inverse of the usual transparency. This is useful because lots of exporters does
|
||||||
|
* not respect the standard and do the opposite of what is normally expected.
|
||||||
|
* Property type: Bool. Default value: false.
|
||||||
|
*/
|
||||||
|
#define AI_CONFIG_IMPORT_COLLADA_INVERT_TRANSPARENCY "IMPORT_COLLADA_INVERT_TRANSPARENCY"
|
||||||
|
|
||||||
// ---------- All the Export defines ------------
|
// ---------- All the Export defines ------------
|
||||||
|
|
||||||
|
@ -889,5 +905,4 @@ enum aiComponent
|
||||||
|
|
||||||
#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
|
#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
|
||||||
|
|
||||||
|
|
||||||
#endif // !! AI_CONFIG_H_INC
|
#endif // !! AI_CONFIG_H_INC
|
||||||
|
|
|
@ -131,21 +131,19 @@ TEST_F(ImporterTest, testMemoryRead)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testIntProperty)
|
TEST_F(ImporterTest, testIntProperty)
|
||||||
{
|
{
|
||||||
bool b;
|
bool b = pImp->SetPropertyInteger("quakquak",1503);
|
||||||
pImp->SetPropertyInteger("quakquak",1503,&b);
|
|
||||||
EXPECT_FALSE(b);
|
EXPECT_FALSE(b);
|
||||||
EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak",0));
|
EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak",0));
|
||||||
EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there",314159));
|
EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there",314159));
|
||||||
|
|
||||||
pImp->SetPropertyInteger("quakquak",1504,&b);
|
b = pImp->SetPropertyInteger("quakquak",1504);
|
||||||
EXPECT_TRUE(b);
|
EXPECT_TRUE(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testFloatProperty)
|
TEST_F(ImporterTest, testFloatProperty)
|
||||||
{
|
{
|
||||||
bool b;
|
bool b = pImp->SetPropertyFloat("quakquak",1503.f);
|
||||||
pImp->SetPropertyFloat("quakquak",1503.f,&b);
|
|
||||||
EXPECT_TRUE(!b);
|
EXPECT_TRUE(!b);
|
||||||
EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak",0.f));
|
EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak",0.f));
|
||||||
EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there",314159.f));
|
EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there",314159.f));
|
||||||
|
@ -154,8 +152,7 @@ TEST_F(ImporterTest, testFloatProperty)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
TEST_F(ImporterTest, testStringProperty)
|
TEST_F(ImporterTest, testStringProperty)
|
||||||
{
|
{
|
||||||
bool b;
|
bool b = pImp->SetPropertyString("quakquak","test");
|
||||||
pImp->SetPropertyString("quakquak","test",&b);
|
|
||||||
EXPECT_TRUE(!b);
|
EXPECT_TRUE(!b);
|
||||||
EXPECT_EQ("test", pImp->GetPropertyString("quakquak","weghwekg"));
|
EXPECT_EQ("test", pImp->GetPropertyString("quakquak","weghwekg"));
|
||||||
EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there","ILoveYou"));
|
EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there","ILoveYou"));
|
||||||
|
|
|
@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
using namespace AssimpView;
|
using namespace AssimpView;
|
||||||
|
|
|
@ -43,195 +43,204 @@ 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
|
||||||
|
|
||||||
class SceneAnimator;
|
#include <d3d9.h>
|
||||||
|
#include <d3dx9.h>
|
||||||
|
#include <d3dx9mesh.h>
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
#include <assimp/scene.h>
|
||||||
/** \brief Class to wrap ASSIMP's asset output structures
|
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
class AssetHelper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
// the original normal set will be used
|
|
||||||
ORIGINAL = 0x0u,
|
|
||||||
|
|
||||||
// a smoothed normal set will be used
|
namespace AssimpView {
|
||||||
SMOOTH = 0x1u,
|
|
||||||
|
|
||||||
// a hard normal set will be used
|
class SceneAnimator;
|
||||||
HARD = 0x2u,
|
|
||||||
};
|
|
||||||
|
|
||||||
// default constructor
|
//-------------------------------------------------------------------------------
|
||||||
AssetHelper()
|
/** \brief Class to wrap ASSIMP's asset output structures
|
||||||
: iNormalSet(ORIGINAL)
|
*/
|
||||||
{
|
//-------------------------------------------------------------------------------
|
||||||
mAnimator = NULL;
|
class AssetHelper
|
||||||
apcMeshes = NULL;
|
{
|
||||||
pcScene = NULL;
|
public:
|
||||||
}
|
enum
|
||||||
|
{
|
||||||
|
// the original normal set will be used
|
||||||
|
ORIGINAL = 0x0u,
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
// a smoothed normal set will be used
|
||||||
// default vertex data structure
|
SMOOTH = 0x1u,
|
||||||
// (even if tangents, bitangents or normals aren't
|
|
||||||
// required by the shader they will be committed to the GPU)
|
|
||||||
//---------------------------------------------------------------
|
|
||||||
struct Vertex
|
|
||||||
{
|
|
||||||
aiVector3D vPosition;
|
|
||||||
aiVector3D vNormal;
|
|
||||||
|
|
||||||
D3DCOLOR dColorDiffuse;
|
// a hard normal set will be used
|
||||||
aiVector3D vTangent;
|
HARD = 0x2u,
|
||||||
aiVector3D vBitangent;
|
};
|
||||||
aiVector2D vTextureUV;
|
|
||||||
aiVector2D vTextureUV2;
|
|
||||||
unsigned char mBoneIndices[4];
|
|
||||||
unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
|
|
||||||
|
|
||||||
/** Returns the vertex declaration elements to create a declaration from. */
|
// default constructor
|
||||||
static D3DVERTEXELEMENT9* GetDeclarationElements()
|
AssetHelper()
|
||||||
{
|
: iNormalSet( ORIGINAL )
|
||||||
static D3DVERTEXELEMENT9 decl[] =
|
{
|
||||||
{
|
mAnimator = NULL;
|
||||||
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
apcMeshes = NULL;
|
||||||
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
|
pcScene = NULL;
|
||||||
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
}
|
||||||
{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
|
|
||||||
{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
|
|
||||||
{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
|
|
||||||
{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
|
|
||||||
{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
|
|
||||||
{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
|
|
||||||
D3DDECL_END()
|
|
||||||
};
|
|
||||||
|
|
||||||
return decl;
|
//---------------------------------------------------------------
|
||||||
}
|
// default vertex data structure
|
||||||
};
|
// (even if tangents, bitangents or normals aren't
|
||||||
|
// required by the shader they will be committed to the GPU)
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
struct Vertex
|
||||||
|
{
|
||||||
|
aiVector3D vPosition;
|
||||||
|
aiVector3D vNormal;
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
D3DCOLOR dColorDiffuse;
|
||||||
// FVF vertex structure used for normals
|
aiVector3D vTangent;
|
||||||
//---------------------------------------------------------------
|
aiVector3D vBitangent;
|
||||||
struct LineVertex
|
aiVector2D vTextureUV;
|
||||||
{
|
aiVector2D vTextureUV2;
|
||||||
aiVector3D vPosition;
|
unsigned char mBoneIndices[ 4 ];
|
||||||
DWORD dColorDiffuse;
|
unsigned char mBoneWeights[ 4 ]; // last Weight not used, calculated inside the vertex shader
|
||||||
|
|
||||||
// retrieves the FVF code of the vertex type
|
/** Returns the vertex declaration elements to create a declaration from. */
|
||||||
static DWORD GetFVF()
|
static D3DVERTEXELEMENT9* GetDeclarationElements()
|
||||||
{
|
{
|
||||||
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
|
static D3DVERTEXELEMENT9 decl[] =
|
||||||
}
|
{
|
||||||
};
|
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
||||||
|
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
|
||||||
|
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
||||||
|
{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
|
||||||
|
{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
|
||||||
|
{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
|
||||||
|
{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
|
||||||
|
{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
|
||||||
|
{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
|
||||||
|
D3DDECL_END()
|
||||||
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
return decl;
|
||||||
// Helper class to store GPU related resources created for
|
}
|
||||||
// a given aiMesh
|
};
|
||||||
//---------------------------------------------------------------
|
|
||||||
class MeshHelper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
MeshHelper ()
|
//---------------------------------------------------------------
|
||||||
:
|
// FVF vertex structure used for normals
|
||||||
piVB (NULL),
|
//---------------------------------------------------------------
|
||||||
piIB (NULL),
|
struct LineVertex
|
||||||
piVBNormals (NULL),
|
{
|
||||||
piEffect (NULL),
|
aiVector3D vPosition;
|
||||||
bSharedFX (false),
|
DWORD dColorDiffuse;
|
||||||
piDiffuseTexture (NULL),
|
|
||||||
piSpecularTexture (NULL),
|
|
||||||
piAmbientTexture (NULL),
|
|
||||||
piEmissiveTexture (NULL),
|
|
||||||
piNormalTexture (NULL),
|
|
||||||
piOpacityTexture (NULL),
|
|
||||||
piShininessTexture (NULL),
|
|
||||||
piLightmapTexture (NULL),
|
|
||||||
twosided (false),
|
|
||||||
pvOriginalNormals (NULL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~MeshHelper ()
|
// retrieves the FVF code of the vertex type
|
||||||
{
|
static DWORD GetFVF()
|
||||||
// NOTE: This is done in DeleteAssetData()
|
{
|
||||||
// TODO: Make this a proper d'tor
|
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// shading mode to use. Either Lambert or otherwise phong
|
//---------------------------------------------------------------
|
||||||
// will be used in every case
|
// Helper class to store GPU related resources created for
|
||||||
aiShadingMode eShadingMode;
|
// a given aiMesh
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
class MeshHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
// vertex buffer
|
MeshHelper()
|
||||||
IDirect3DVertexBuffer9* piVB;
|
:
|
||||||
|
piVB( NULL ),
|
||||||
|
piIB( NULL ),
|
||||||
|
piVBNormals( NULL ),
|
||||||
|
piEffect( NULL ),
|
||||||
|
bSharedFX( false ),
|
||||||
|
piDiffuseTexture( NULL ),
|
||||||
|
piSpecularTexture( NULL ),
|
||||||
|
piAmbientTexture( NULL ),
|
||||||
|
piEmissiveTexture( NULL ),
|
||||||
|
piNormalTexture( NULL ),
|
||||||
|
piOpacityTexture( NULL ),
|
||||||
|
piShininessTexture( NULL ),
|
||||||
|
piLightmapTexture( NULL ),
|
||||||
|
twosided( false ),
|
||||||
|
pvOriginalNormals( NULL )
|
||||||
|
{}
|
||||||
|
|
||||||
// index buffer. For partially transparent meshes
|
~MeshHelper()
|
||||||
// created with dynamic usage to be able to update
|
{
|
||||||
// the buffer contents quickly
|
// NOTE: This is done in DeleteAssetData()
|
||||||
IDirect3DIndexBuffer9* piIB;
|
// TODO: Make this a proper d'tor
|
||||||
|
}
|
||||||
|
|
||||||
// vertex buffer to be used to draw vertex normals
|
// shading mode to use. Either Lambert or otherwise phong
|
||||||
// (vertex normals are generated in every case)
|
// will be used in every case
|
||||||
IDirect3DVertexBuffer9* piVBNormals;
|
aiShadingMode eShadingMode;
|
||||||
|
|
||||||
// shader to be used
|
// vertex buffer
|
||||||
ID3DXEffect* piEffect;
|
IDirect3DVertexBuffer9* piVB;
|
||||||
bool bSharedFX;
|
|
||||||
|
|
||||||
// material textures
|
// index buffer. For partially transparent meshes
|
||||||
IDirect3DTexture9* piDiffuseTexture;
|
// created with dynamic usage to be able to update
|
||||||
IDirect3DTexture9* piSpecularTexture;
|
// the buffer contents quickly
|
||||||
IDirect3DTexture9* piAmbientTexture;
|
IDirect3DIndexBuffer9* piIB;
|
||||||
IDirect3DTexture9* piEmissiveTexture;
|
|
||||||
IDirect3DTexture9* piNormalTexture;
|
|
||||||
IDirect3DTexture9* piOpacityTexture;
|
|
||||||
IDirect3DTexture9* piShininessTexture;
|
|
||||||
IDirect3DTexture9* piLightmapTexture;
|
|
||||||
|
|
||||||
// material colors
|
// vertex buffer to be used to draw vertex normals
|
||||||
D3DXVECTOR4 vDiffuseColor;
|
// (vertex normals are generated in every case)
|
||||||
D3DXVECTOR4 vSpecularColor;
|
IDirect3DVertexBuffer9* piVBNormals;
|
||||||
D3DXVECTOR4 vAmbientColor;
|
|
||||||
D3DXVECTOR4 vEmissiveColor;
|
|
||||||
|
|
||||||
// opacity for the material
|
// shader to be used
|
||||||
float fOpacity;
|
ID3DXEffect* piEffect;
|
||||||
|
bool bSharedFX;
|
||||||
|
|
||||||
// shininess for the material
|
// material textures
|
||||||
float fShininess;
|
IDirect3DTexture9* piDiffuseTexture;
|
||||||
|
IDirect3DTexture9* piSpecularTexture;
|
||||||
|
IDirect3DTexture9* piAmbientTexture;
|
||||||
|
IDirect3DTexture9* piEmissiveTexture;
|
||||||
|
IDirect3DTexture9* piNormalTexture;
|
||||||
|
IDirect3DTexture9* piOpacityTexture;
|
||||||
|
IDirect3DTexture9* piShininessTexture;
|
||||||
|
IDirect3DTexture9* piLightmapTexture;
|
||||||
|
|
||||||
// strength of the specular highlight
|
// material colors
|
||||||
float fSpecularStrength;
|
D3DXVECTOR4 vDiffuseColor;
|
||||||
|
D3DXVECTOR4 vSpecularColor;
|
||||||
|
D3DXVECTOR4 vAmbientColor;
|
||||||
|
D3DXVECTOR4 vEmissiveColor;
|
||||||
|
|
||||||
// two-sided?
|
// opacity for the material
|
||||||
bool twosided;
|
float fOpacity;
|
||||||
|
|
||||||
// Stores a pointer to the original normal set of the asset
|
// shininess for the material
|
||||||
aiVector3D* pvOriginalNormals;
|
float fShininess;
|
||||||
};
|
|
||||||
|
|
||||||
// One instance per aiMesh in the globally loaded asset
|
// strength of the specular highlight
|
||||||
MeshHelper** apcMeshes;
|
float fSpecularStrength;
|
||||||
|
|
||||||
// Scene wrapper instance
|
// two-sided?
|
||||||
aiScene* pcScene;
|
bool twosided;
|
||||||
|
|
||||||
// Animation player to animate the scene if necessary
|
// Stores a pointer to the original normal set of the asset
|
||||||
SceneAnimator* mAnimator;
|
aiVector3D* pvOriginalNormals;
|
||||||
|
};
|
||||||
|
|
||||||
// Specifies the normal set to be used
|
// One instance per aiMesh in the globally loaded asset
|
||||||
unsigned int iNormalSet;
|
MeshHelper** apcMeshes;
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// Scene wrapper instance
|
||||||
// set the normal set to be used
|
aiScene* pcScene;
|
||||||
void SetNormalSet(unsigned int iSet);
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// Animation player to animate the scene if necessary
|
||||||
// flip all normal vectors
|
SceneAnimator* mAnimator;
|
||||||
void FlipNormals();
|
|
||||||
void FlipNormalsInt();
|
// Specifies the normal set to be used
|
||||||
};
|
unsigned int iNormalSet;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// set the normal set to be used
|
||||||
|
void SetNormalSet( unsigned int iSet );
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// flip all normal vectors
|
||||||
|
void FlipNormals();
|
||||||
|
void FlipNormalsInt();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !! IG
|
#endif // !! IG
|
||||||
|
|
|
@ -39,12 +39,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
extern std::string g_szSkyboxShader;
|
||||||
|
|
||||||
// From: U3D build 1256 (src\kernel\graphic\scenegraph\SkyBox.cpp)
|
// From: U3D build 1256 (src\kernel\graphic\scenegraph\SkyBox.cpp)
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -38,91 +38,91 @@ 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.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#if (!defined AV_BACKGROUND_H_INCLUDED)
|
namespace AssimpView
|
||||||
#define AV_BACKGROUND_H_INCLUDED
|
{
|
||||||
|
|
||||||
|
class CBackgroundPainter
|
||||||
|
{
|
||||||
|
CBackgroundPainter()
|
||||||
|
:
|
||||||
|
clrColor( D3DCOLOR_ARGB( 0xFF, 100, 100, 100 ) ),
|
||||||
|
pcTexture( NULL ),
|
||||||
|
piSkyBoxEffect( NULL ),
|
||||||
|
eMode( SIMPLE_COLOR )
|
||||||
|
{}
|
||||||
|
|
||||||
class CBackgroundPainter
|
public:
|
||||||
{
|
|
||||||
CBackgroundPainter()
|
|
||||||
:
|
|
||||||
clrColor(D3DCOLOR_ARGB(0xFF,100,100,100)),
|
|
||||||
pcTexture(NULL),
|
|
||||||
piSkyBoxEffect(NULL),
|
|
||||||
eMode(SIMPLE_COLOR)
|
|
||||||
{}
|
|
||||||
|
|
||||||
public:
|
// Supported background draw modi
|
||||||
|
enum MODE { SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE };
|
||||||
|
|
||||||
// Supported background draw modi
|
// Singleton accessors
|
||||||
enum MODE {SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE};
|
static CBackgroundPainter s_cInstance;
|
||||||
|
inline static CBackgroundPainter& Instance()
|
||||||
|
{
|
||||||
|
return s_cInstance;
|
||||||
|
}
|
||||||
|
|
||||||
// Singleton accessors
|
// set the current background color
|
||||||
static CBackgroundPainter s_cInstance;
|
// (this removes any textures loaded)
|
||||||
inline static CBackgroundPainter& Instance ()
|
void SetColor( D3DCOLOR p_clrNew );
|
||||||
{
|
|
||||||
return s_cInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the current background color
|
// Setup a cubemap/a 2d texture as background
|
||||||
// (this removes any textures loaded)
|
void SetCubeMapBG( const char* p_szPath );
|
||||||
void SetColor (D3DCOLOR p_clrNew);
|
void SetTextureBG( const char* p_szPath );
|
||||||
|
|
||||||
// Setup a cubemap/a 2d texture as background
|
// Called by the render loop
|
||||||
void SetCubeMapBG (const char* p_szPath);
|
void OnPreRender();
|
||||||
void SetTextureBG (const char* p_szPath);
|
void OnPostRender();
|
||||||
|
|
||||||
// Called by the render loop
|
// Release any native resources associated with the instance
|
||||||
void OnPreRender();
|
void ReleaseNativeResource();
|
||||||
void OnPostRender();
|
|
||||||
|
|
||||||
// Release any native resources associated with the instance
|
// Recreate any native resources associated with the instance
|
||||||
void ReleaseNativeResource();
|
void RecreateNativeResource();
|
||||||
|
|
||||||
// Recreate any native resources associated with the instance
|
// Rotate the skybox
|
||||||
void RecreateNativeResource();
|
void RotateSB( const aiMatrix4x4* pm );
|
||||||
|
|
||||||
// Rotate the skybox
|
// Reset the state of the skybox
|
||||||
void RotateSB(const aiMatrix4x4* pm);
|
void ResetSB();
|
||||||
|
|
||||||
// Reset the state of the skybox
|
inline MODE GetMode() const
|
||||||
void ResetSB();
|
{
|
||||||
|
return this->eMode;
|
||||||
|
}
|
||||||
|
|
||||||
inline MODE GetMode() const
|
inline IDirect3DBaseTexture9* GetTexture()
|
||||||
{
|
{
|
||||||
return this->eMode;
|
return this->pcTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline IDirect3DBaseTexture9* GetTexture()
|
inline ID3DXBaseEffect* GetEffect()
|
||||||
{
|
{
|
||||||
return this->pcTexture;
|
return this->piSkyBoxEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ID3DXBaseEffect* GetEffect()
|
private:
|
||||||
{
|
|
||||||
return this->piSkyBoxEffect;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
void RemoveSBDeps();
|
||||||
|
|
||||||
void RemoveSBDeps();
|
// current background color
|
||||||
|
D3DCOLOR clrColor;
|
||||||
|
|
||||||
// current background color
|
// current background texture
|
||||||
D3DCOLOR clrColor;
|
IDirect3DBaseTexture9* pcTexture;
|
||||||
|
ID3DXEffect* piSkyBoxEffect;
|
||||||
|
|
||||||
// current background texture
|
// current background mode
|
||||||
IDirect3DBaseTexture9* pcTexture;
|
MODE eMode;
|
||||||
ID3DXEffect* piSkyBoxEffect;
|
|
||||||
|
|
||||||
// current background mode
|
// path to the texture
|
||||||
MODE eMode;
|
std::string szPath;
|
||||||
|
|
||||||
// path to the texture
|
// transformation matrix for the skybox
|
||||||
std::string szPath;
|
aiMatrix4x4 mMatrix;
|
||||||
|
};
|
||||||
|
|
||||||
// transformation matrix for the skybox
|
}
|
||||||
aiMatrix4x4 mMatrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // !! AV_BACKGROUND_H_INCLUDED
|
|
||||||
|
|
|
@ -38,13 +38,16 @@ 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 "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
#include "AnimEvaluator.h"
|
||||||
|
#include "SceneAnimator.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
extern std::string g_szCheckerBackgroundShader;
|
||||||
|
|
||||||
struct SVertex
|
struct SVertex
|
||||||
{
|
{
|
||||||
float x,y,z,w,u,v;
|
float x,y,z,w,u,v;
|
||||||
|
@ -690,7 +693,7 @@ int CDisplay::FillDisplayList(void)
|
||||||
// fill in the first entry
|
// fill in the first entry
|
||||||
TVITEMEX tvi;
|
TVITEMEX tvi;
|
||||||
TVINSERTSTRUCT sNew;
|
TVINSERTSTRUCT sNew;
|
||||||
tvi.pszText = "Model";
|
tvi.pszText = (char*) "Model";
|
||||||
tvi.cchTextMax = (int)strlen(tvi.pszText);
|
tvi.cchTextMax = (int)strlen(tvi.pszText);
|
||||||
tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE | TVIF_STATE;
|
tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE | TVIF_STATE;
|
||||||
tvi.state = TVIS_EXPANDED;
|
tvi.state = TVIS_EXPANDED;
|
||||||
|
@ -2240,7 +2243,7 @@ int CDisplay::RenderTextureView()
|
||||||
const float ny = (float)sRect.bottom;
|
const float ny = (float)sRect.bottom;
|
||||||
const float x = (float)sDesc.Width;
|
const float x = (float)sDesc.Width;
|
||||||
const float y = (float)sDesc.Height;
|
const float y = (float)sDesc.Height;
|
||||||
float f = std::min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
|
float f = min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
|
||||||
|
|
||||||
float fHalfX = (nx - (f * x)) / 2.0f;
|
float fHalfX = (nx - (f * x)) / 2.0f;
|
||||||
float fHalfY = (ny - (f * y)) / 2.0f;
|
float fHalfY = (ny - (f * y)) / 2.0f;
|
||||||
|
|
|
@ -42,6 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#if (!defined AV_DISPLAY_H_INCLUDED)
|
#if (!defined AV_DISPLAY_H_INCLUDED)
|
||||||
#define AV_DISPLAY_H_INCLUDE
|
#define AV_DISPLAY_H_INCLUDE
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <shellapi.h>
|
||||||
|
#include <commctrl.h>
|
||||||
|
|
||||||
// see CDisplay::m_aiImageList
|
// see CDisplay::m_aiImageList
|
||||||
#define AI_VIEW_IMGLIST_NODE 0x0
|
#define AI_VIEW_IMGLIST_NODE 0x0
|
||||||
#define AI_VIEW_IMGLIST_MATERIAL 0x1
|
#define AI_VIEW_IMGLIST_MATERIAL 0x1
|
||||||
|
@ -49,486 +53,490 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_VIEW_IMGLIST_TEXTURE_INVALID 0x3
|
#define AI_VIEW_IMGLIST_TEXTURE_INVALID 0x3
|
||||||
#define AI_VIEW_IMGLIST_MODEL 0x4
|
#define AI_VIEW_IMGLIST_MODEL 0x4
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
namespace AssimpView
|
||||||
/* Corresponds to the "Display" combobox in the UI
|
{
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
class CDisplay
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
// helper class
|
//-------------------------------------------------------------------------------
|
||||||
struct Info
|
/* Corresponds to the "Display" combobox in the UI
|
||||||
{
|
*/
|
||||||
Info( D3DXVECTOR4* p1,
|
//-------------------------------------------------------------------------------
|
||||||
AssetHelper::MeshHelper* p2,
|
class CDisplay
|
||||||
const char* p3)
|
{
|
||||||
: pclrColor(p1),pMesh(p2),szShaderParam(p3) {}
|
private:
|
||||||
|
|
||||||
D3DXVECTOR4* pclrColor;
|
// helper class
|
||||||
AssetHelper::MeshHelper* pMesh;
|
struct Info
|
||||||
const char* szShaderParam;
|
{
|
||||||
};
|
Info( D3DXVECTOR4* p1,
|
||||||
|
AssetHelper::MeshHelper* p2,
|
||||||
|
const char* p3 )
|
||||||
|
: pclrColor( p1 ), pMesh( p2 ), szShaderParam( p3 ) {}
|
||||||
|
|
||||||
// default constructor
|
D3DXVECTOR4* pclrColor;
|
||||||
CDisplay()
|
AssetHelper::MeshHelper* pMesh;
|
||||||
: m_iViewMode(VIEWMODE_FULL),
|
const char* szShaderParam;
|
||||||
m_pcCurrentTexture(NULL),
|
};
|
||||||
m_pcCurrentNode(NULL),
|
|
||||||
m_pcCurrentMaterial(NULL),
|
|
||||||
m_hImageList(NULL),
|
|
||||||
m_hRoot(NULL),
|
|
||||||
m_fTextureZoom(1000.0f)
|
|
||||||
{
|
|
||||||
this->m_aiImageList[0] = 0;
|
|
||||||
this->m_aiImageList[1] = 1;
|
|
||||||
this->m_aiImageList[2] = 2;
|
|
||||||
this->m_aiImageList[3] = 3;
|
|
||||||
this->m_aiImageList[4] = 4;
|
|
||||||
|
|
||||||
this->m_avCheckerColors[0].x = this->m_avCheckerColors[0].y = this->m_avCheckerColors[0].z = 0.4f;
|
// default constructor
|
||||||
this->m_avCheckerColors[1].x = this->m_avCheckerColors[1].y = this->m_avCheckerColors[1].z = 0.6f;
|
CDisplay()
|
||||||
}
|
: m_iViewMode( VIEWMODE_FULL ),
|
||||||
|
m_pcCurrentTexture( NULL ),
|
||||||
|
m_pcCurrentNode( NULL ),
|
||||||
|
m_pcCurrentMaterial( NULL ),
|
||||||
|
m_hImageList( NULL ),
|
||||||
|
m_hRoot( NULL ),
|
||||||
|
m_fTextureZoom( 1000.0f )
|
||||||
|
{
|
||||||
|
this->m_aiImageList[ 0 ] = 0;
|
||||||
|
this->m_aiImageList[ 1 ] = 1;
|
||||||
|
this->m_aiImageList[ 2 ] = 2;
|
||||||
|
this->m_aiImageList[ 3 ] = 3;
|
||||||
|
this->m_aiImageList[ 4 ] = 4;
|
||||||
|
|
||||||
public:
|
this->m_avCheckerColors[ 0 ].x = this->m_avCheckerColors[ 0 ].y = this->m_avCheckerColors[ 0 ].z = 0.4f;
|
||||||
|
this->m_avCheckerColors[ 1 ].x = this->m_avCheckerColors[ 1 ].y = this->m_avCheckerColors[ 1 ].z = 0.6f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// the full model is displayed
|
// the full model is displayed
|
||||||
VIEWMODE_FULL,
|
VIEWMODE_FULL,
|
||||||
|
|
||||||
// a material is displayed on a simple spjere as model
|
// a material is displayed on a simple spjere as model
|
||||||
VIEWMODE_MATERIAL,
|
VIEWMODE_MATERIAL,
|
||||||
|
|
||||||
// a texture with an UV set mapped on it is displayed
|
// a texture with an UV set mapped on it is displayed
|
||||||
VIEWMODE_TEXTURE,
|
VIEWMODE_TEXTURE,
|
||||||
|
|
||||||
// a single node in the scenegraph is displayed
|
// a single node in the scenegraph is displayed
|
||||||
VIEWMODE_NODE,
|
VIEWMODE_NODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// represents a texture in the tree view
|
// represents a texture in the tree view
|
||||||
struct TextureInfo
|
struct TextureInfo
|
||||||
{
|
{
|
||||||
// texture info
|
// texture info
|
||||||
IDirect3DTexture9** piTexture;
|
IDirect3DTexture9** piTexture;
|
||||||
|
|
||||||
// Blend factor of the texture
|
// Blend factor of the texture
|
||||||
float fBlend;
|
float fBlend;
|
||||||
|
|
||||||
// blend operation for the texture
|
// blend operation for the texture
|
||||||
aiTextureOp eOp;
|
aiTextureOp eOp;
|
||||||
|
|
||||||
// UV index for the texture
|
// UV index for the texture
|
||||||
unsigned int iUV;
|
unsigned int iUV;
|
||||||
|
|
||||||
// Associated tree item
|
// Associated tree item
|
||||||
HTREEITEM hTreeItem;
|
HTREEITEM hTreeItem;
|
||||||
|
|
||||||
// Original path to the texture
|
// Original path to the texture
|
||||||
std::string szPath;
|
std::string szPath;
|
||||||
|
|
||||||
// index of the corresponding material
|
// index of the corresponding material
|
||||||
unsigned int iMatIndex;
|
unsigned int iMatIndex;
|
||||||
|
|
||||||
// type of the texture
|
// type of the texture
|
||||||
unsigned int iType;
|
unsigned int iType;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// represents a node in the tree view
|
// represents a node in the tree view
|
||||||
struct NodeInfo
|
struct NodeInfo
|
||||||
{
|
{
|
||||||
// node object
|
// node object
|
||||||
aiNode* psNode;
|
aiNode* psNode;
|
||||||
|
|
||||||
// corresponding tree view item
|
// corresponding tree view item
|
||||||
HTREEITEM hTreeItem;
|
HTREEITEM hTreeItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// represents a mesh in the tree view
|
// represents a mesh in the tree view
|
||||||
struct MeshInfo
|
struct MeshInfo
|
||||||
{
|
{
|
||||||
// the mesh object
|
// the mesh object
|
||||||
aiMesh* psMesh;
|
aiMesh* psMesh;
|
||||||
|
|
||||||
// corresponding tree view item
|
// corresponding tree view item
|
||||||
HTREEITEM hTreeItem;
|
HTREEITEM hTreeItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// represents a material in the tree view
|
// represents a material in the tree view
|
||||||
struct MaterialInfo
|
struct MaterialInfo
|
||||||
{
|
{
|
||||||
// material index
|
// material index
|
||||||
unsigned int iIndex;
|
unsigned int iIndex;
|
||||||
|
|
||||||
// material object
|
// material object
|
||||||
aiMaterial* psMaterial;
|
aiMaterial* psMaterial;
|
||||||
|
|
||||||
// ID3DXEffect interface
|
// ID3DXEffect interface
|
||||||
ID3DXEffect* piEffect;
|
ID3DXEffect* piEffect;
|
||||||
|
|
||||||
// corresponding tree view item
|
// corresponding tree view item
|
||||||
HTREEITEM hTreeItem;
|
HTREEITEM hTreeItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Singleton accessors
|
// Singleton accessors
|
||||||
static CDisplay s_cInstance;
|
static CDisplay s_cInstance;
|
||||||
inline static CDisplay& Instance ()
|
inline static CDisplay& Instance()
|
||||||
{
|
{
|
||||||
return s_cInstance;
|
return s_cInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Called during the render loop. Renders the scene (including the
|
// Called during the render loop. Renders the scene (including the
|
||||||
// HUD etc) in the current view mode
|
// HUD etc) in the current view mode
|
||||||
int OnRender();
|
int OnRender();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// called when the user selects another item in the "Display" tree
|
// called when the user selects another item in the "Display" tree
|
||||||
// view the method determines the new view mode and performs all
|
// view the method determines the new view mode and performs all
|
||||||
// required operations
|
// required operations
|
||||||
// \param p_hTreeItem Selected tree view item
|
// \param p_hTreeItem Selected tree view item
|
||||||
int OnSetup(HTREEITEM p_hTreeItem);
|
int OnSetup( HTREEITEM p_hTreeItem );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Variant 1: Render the full scene with the asset
|
// Variant 1: Render the full scene with the asset
|
||||||
int RenderFullScene();
|
int RenderFullScene();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Variant 2: Render only a part of the scene. One node to
|
// Variant 2: Render only a part of the scene. One node to
|
||||||
// be exact
|
// be exact
|
||||||
int RenderScenePart();
|
int RenderScenePart();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Variant 3: Render a large sphere and map a given material on it
|
// Variant 3: Render a large sphere and map a given material on it
|
||||||
int RenderMaterialView();
|
int RenderMaterialView();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Variant 4: Render a flat plane, map a texture on it and
|
// Variant 4: Render a flat plane, map a texture on it and
|
||||||
// display the UV wire on it
|
// display the UV wire on it
|
||||||
int RenderTextureView();
|
int RenderTextureView();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Fill the UI combobox with a list of all supported view modi
|
// Fill the UI combobox with a list of all supported view modi
|
||||||
//
|
//
|
||||||
// The display modes are added in order
|
// The display modes are added in order
|
||||||
int FillDisplayList(void);
|
int FillDisplayList( void );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Add a material and all sub textures to the display mode list
|
// Add a material and all sub textures to the display mode list
|
||||||
// hRoot - Handle to the root of the tree view
|
// hRoot - Handle to the root of the tree view
|
||||||
// iIndex - Material index
|
// iIndex - Material index
|
||||||
int AddMaterialToDisplayList(HTREEITEM hRoot,
|
int AddMaterialToDisplayList( HTREEITEM hRoot,
|
||||||
unsigned int iIndex);
|
unsigned int iIndex );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Add a texture to the display list
|
// Add a texture to the display list
|
||||||
// pcMat - material containing the texture
|
// pcMat - material containing the texture
|
||||||
// hTexture - Handle to the material tree item
|
// hTexture - Handle to the material tree item
|
||||||
// szPath - Path to the texture
|
// szPath - Path to the texture
|
||||||
// iUVIndex - UV index to be used for the texture
|
// iUVIndex - UV index to be used for the texture
|
||||||
// fBlendFactor - Blend factor to be used for the texture
|
// fBlendFactor - Blend factor to be used for the texture
|
||||||
// eTextureOp - texture operation to be used for the texture
|
// eTextureOp - texture operation to be used for the texture
|
||||||
int AddTextureToDisplayList(unsigned int iType,
|
int AddTextureToDisplayList( unsigned int iType,
|
||||||
unsigned int iIndex,
|
unsigned int iIndex,
|
||||||
const aiString* szPath,
|
const aiString* szPath,
|
||||||
HTREEITEM hFX,
|
HTREEITEM hFX,
|
||||||
unsigned int iUVIndex = 0,
|
unsigned int iUVIndex = 0,
|
||||||
const float fBlendFactor = 0.0f,
|
const float fBlendFactor = 0.0f,
|
||||||
aiTextureOp eTextureOp = aiTextureOp_Multiply,
|
aiTextureOp eTextureOp = aiTextureOp_Multiply,
|
||||||
unsigned int iMesh = 0);
|
unsigned int iMesh = 0 );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Add a node to the display list
|
// Add a node to the display list
|
||||||
// Recusrivly adds all subnodes as well
|
// Recusrivly adds all subnodes as well
|
||||||
// iIndex - Index of the node in the parent's child list
|
// iIndex - Index of the node in the parent's child list
|
||||||
// iDepth - Current depth of the node
|
// iDepth - Current depth of the node
|
||||||
// pcNode - Node object
|
// pcNode - Node object
|
||||||
// hRoot - Parent tree view node
|
// hRoot - Parent tree view node
|
||||||
int AddNodeToDisplayList(
|
int AddNodeToDisplayList(
|
||||||
unsigned int iIndex,
|
unsigned int iIndex,
|
||||||
unsigned int iDepth,
|
unsigned int iDepth,
|
||||||
aiNode* pcNode,
|
aiNode* pcNode,
|
||||||
HTREEITEM hRoot);
|
HTREEITEM hRoot );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Add a mesh to the display list
|
// Add a mesh to the display list
|
||||||
// iIndex - Index of the mesh in the scene's mesh list
|
// iIndex - Index of the mesh in the scene's mesh list
|
||||||
// hRoot - Parent tree view node
|
// hRoot - Parent tree view node
|
||||||
int AddMeshToDisplayList(
|
int AddMeshToDisplayList(
|
||||||
unsigned int iIndex,
|
unsigned int iIndex,
|
||||||
HTREEITEM hRoot);
|
HTREEITEM hRoot );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Load the image list for the tree view item
|
// Load the image list for the tree view item
|
||||||
int LoadImageList(void);
|
int LoadImageList( void );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Expand all nodes in the tree
|
// Expand all nodes in the tree
|
||||||
int ExpandTree();
|
int ExpandTree();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Fill the UI combobox with a list of all supported animations
|
// Fill the UI combobox with a list of all supported animations
|
||||||
// The animations are added in order
|
// The animations are added in order
|
||||||
int FillAnimList(void);
|
int FillAnimList( void );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Clear the combox box containing the list of animations
|
// Clear the combox box containing the list of animations
|
||||||
int ClearAnimList(void);
|
int ClearAnimList( void );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Clear the combox box containing the list of scenegraph items
|
// Clear the combox box containing the list of scenegraph items
|
||||||
int ClearDisplayList(void);
|
int ClearDisplayList( void );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Fill in the default statistics
|
// Fill in the default statistics
|
||||||
int FillDefaultStatistics(void);
|
int FillDefaultStatistics( void );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Called by LoadAsset()
|
// Called by LoadAsset()
|
||||||
// reset the class instance to the default values
|
// reset the class instance to the default values
|
||||||
int Reset(void);
|
int Reset( void );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Replace the texture that is current selected with
|
// Replace the texture that is current selected with
|
||||||
// a new texture
|
// a new texture
|
||||||
int ReplaceCurrentTexture(const char* szPath);
|
int ReplaceCurrentTexture( const char* szPath );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Display the context menu (if there) for the specified tree item
|
// Display the context menu (if there) for the specified tree item
|
||||||
// hItem Valid tree view item handle
|
// hItem Valid tree view item handle
|
||||||
int ShowTreeViewContextMenu(HTREEITEM hItem);
|
int ShowTreeViewContextMenu( HTREEITEM hItem );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Event handling for pop-up menus displayed by th tree view
|
// Event handling for pop-up menus displayed by th tree view
|
||||||
int HandleTreeViewPopup(WPARAM wParam,LPARAM lParam);
|
int HandleTreeViewPopup( WPARAM wParam, LPARAM lParam );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Enable animation-related parts of the UI
|
// Enable animation-related parts of the UI
|
||||||
int EnableAnimTools(BOOL hm) ;
|
int EnableAnimTools( BOOL hm );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// setter for m_iViewMode
|
// setter for m_iViewMode
|
||||||
inline void SetViewMode(unsigned int p_iNew)
|
inline void SetViewMode( unsigned int p_iNew )
|
||||||
{
|
{
|
||||||
this->m_iViewMode = p_iNew;
|
this->m_iViewMode = p_iNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// getter for m_iViewMode
|
// getter for m_iViewMode
|
||||||
inline unsigned int GetViewMode()
|
inline unsigned int GetViewMode()
|
||||||
{
|
{
|
||||||
return m_iViewMode;
|
return m_iViewMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// change the texture view's zoom factor
|
// change the texture view's zoom factor
|
||||||
inline void SetTextureViewZoom(float f)
|
inline void SetTextureViewZoom( float f )
|
||||||
{
|
{
|
||||||
// FIX: Removed log(), seems to make more problems than it fixes
|
// FIX: Removed log(), seems to make more problems than it fixes
|
||||||
this->m_fTextureZoom += f* 15;
|
this->m_fTextureZoom += f * 15;
|
||||||
if (this->m_fTextureZoom < 0.05f)this->m_fTextureZoom = 0.05f;
|
if( this->m_fTextureZoom < 0.05f )this->m_fTextureZoom = 0.05f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// change the texture view's offset on the x axis
|
// change the texture view's offset on the x axis
|
||||||
inline void SetTextureViewOffsetX(float f)
|
inline void SetTextureViewOffsetX( float f )
|
||||||
{
|
{
|
||||||
this->m_vTextureOffset.x += f;
|
this->m_vTextureOffset.x += f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// change the texture view's offset on the y axis
|
// change the texture view's offset on the y axis
|
||||||
inline void SetTextureViewOffsetY(float f)
|
inline void SetTextureViewOffsetY( float f )
|
||||||
{
|
{
|
||||||
this->m_vTextureOffset.y += f;
|
this->m_vTextureOffset.y += f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// add a new texture to the list
|
// add a new texture to the list
|
||||||
inline void AddTexture(const TextureInfo& info)
|
inline void AddTexture( const TextureInfo& info )
|
||||||
{
|
{
|
||||||
this->m_asTextures.push_back(info);
|
this->m_asTextures.push_back( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// add a new node to the list
|
// add a new node to the list
|
||||||
inline void AddNode(const NodeInfo& info)
|
inline void AddNode( const NodeInfo& info )
|
||||||
{
|
{
|
||||||
this->m_asNodes.push_back(info);
|
this->m_asNodes.push_back( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// add a new mesh to the list
|
// add a new mesh to the list
|
||||||
inline void AddMesh(const MeshInfo& info)
|
inline void AddMesh( const MeshInfo& info )
|
||||||
{
|
{
|
||||||
this->m_asMeshes.push_back(info);
|
this->m_asMeshes.push_back( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// add a new material to the list
|
// add a new material to the list
|
||||||
inline void AddMaterial(const MaterialInfo& info)
|
inline void AddMaterial( const MaterialInfo& info )
|
||||||
{
|
{
|
||||||
this->m_asMaterials.push_back(info);
|
this->m_asMaterials.push_back( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// set the primary color of the checker pattern background
|
// set the primary color of the checker pattern background
|
||||||
inline void SetFirstCheckerColor(D3DXVECTOR4 c)
|
inline void SetFirstCheckerColor( D3DXVECTOR4 c )
|
||||||
{
|
{
|
||||||
this->m_avCheckerColors[0] = c;
|
this->m_avCheckerColors[ 0 ] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// set the secondary color of the checker pattern background
|
// set the secondary color of the checker pattern background
|
||||||
inline void SetSecondCheckerColor(D3DXVECTOR4 c)
|
inline void SetSecondCheckerColor( D3DXVECTOR4 c )
|
||||||
{
|
{
|
||||||
this->m_avCheckerColors[1] = c;
|
this->m_avCheckerColors[ 1 ] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// get the primary color of the checker pattern background
|
// get the primary color of the checker pattern background
|
||||||
inline const D3DXVECTOR4* GetFirstCheckerColor() const
|
inline const D3DXVECTOR4* GetFirstCheckerColor() const
|
||||||
{
|
{
|
||||||
return &this->m_avCheckerColors[0];
|
return &this->m_avCheckerColors[ 0 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// get the secondary color of the checker pattern background
|
// get the secondary color of the checker pattern background
|
||||||
inline const D3DXVECTOR4* GetSecondCheckerColor() const
|
inline const D3DXVECTOR4* GetSecondCheckerColor() const
|
||||||
{
|
{
|
||||||
return &this->m_avCheckerColors[1];
|
return &this->m_avCheckerColors[ 1 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Render a screen-filling square using the checker pattern shader
|
// Render a screen-filling square using the checker pattern shader
|
||||||
int RenderPatternBG();
|
int RenderPatternBG();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Render a given node in the scenegraph
|
// Render a given node in the scenegraph
|
||||||
// piNode Node to be rendered
|
// piNode Node to be rendered
|
||||||
// piMatrix Current transformation matrix
|
// piMatrix Current transformation matrix
|
||||||
// bAlpha Render alpha or opaque objects only?
|
// bAlpha Render alpha or opaque objects only?
|
||||||
int RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
|
int RenderNode( aiNode* piNode, const aiMatrix4x4& piMatrix,
|
||||||
bool bAlpha = false);
|
bool bAlpha = false );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Setup the camera for the stereo view rendering mode
|
// Setup the camera for the stereo view rendering mode
|
||||||
int SetupStereoView();
|
int SetupStereoView();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Render the second view (for the right eye) in stereo mod
|
// Render the second view (for the right eye) in stereo mod
|
||||||
// m - World matrix
|
// m - World matrix
|
||||||
int RenderStereoView(const aiMatrix4x4& m);
|
int RenderStereoView( const aiMatrix4x4& m );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Handle user input
|
// Handle user input
|
||||||
int HandleInput();
|
int HandleInput();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Handle user input for the texture viewer
|
// Handle user input for the texture viewer
|
||||||
int HandleInputTextureView();
|
int HandleInputTextureView();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Handle user input if no asset is loaded
|
// Handle user input if no asset is loaded
|
||||||
int HandleInputEmptyScene();
|
int HandleInputEmptyScene();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Draw the HUD (call only if FPS mode isn't active)
|
// Draw the HUD (call only if FPS mode isn't active)
|
||||||
int DrawHUD();
|
int DrawHUD();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Used by OnSetup().
|
// Used by OnSetup().
|
||||||
// Do everything necessary to switch to texture view mode
|
// Do everything necessary to switch to texture view mode
|
||||||
int OnSetupTextureView(TextureInfo* pcNew);
|
int OnSetupTextureView( TextureInfo* pcNew );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Used by OnSetup().
|
// Used by OnSetup().
|
||||||
// Do everything necessary to switch to material view mode
|
// Do everything necessary to switch to material view mode
|
||||||
int OnSetupMaterialView(MaterialInfo* pcNew);
|
int OnSetupMaterialView( MaterialInfo* pcNew );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Used by OnSetup().
|
// Used by OnSetup().
|
||||||
// Do everything necessary to switch to node view mode
|
// Do everything necessary to switch to node view mode
|
||||||
int OnSetupNodeView(NodeInfo* pcNew);
|
int OnSetupNodeView( NodeInfo* pcNew );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Used by OnSetup().
|
// Used by OnSetup().
|
||||||
// Do everything necessary to switch back to normal view mode
|
// Do everything necessary to switch back to normal view mode
|
||||||
int OnSetupNormalView();
|
int OnSetupNormalView();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Used by HandleTreeViewPopup().
|
// Used by HandleTreeViewPopup().
|
||||||
int HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam);
|
int HandleTreeViewPopup2( WPARAM wParam, LPARAM lParam );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Render skeleton
|
// Render skeleton
|
||||||
int RenderSkeleton (aiNode* piNode,const aiMatrix4x4& piMatrix,
|
int RenderSkeleton( aiNode* piNode, const aiMatrix4x4& piMatrix,
|
||||||
const aiMatrix4x4& parent);
|
const aiMatrix4x4& parent );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// view mode
|
// view mode
|
||||||
unsigned int m_iViewMode;
|
unsigned int m_iViewMode;
|
||||||
|
|
||||||
// List of all textures in the display CB
|
// List of all textures in the display CB
|
||||||
std::vector<TextureInfo> m_asTextures;
|
std::vector<TextureInfo> m_asTextures;
|
||||||
|
|
||||||
// current texture or NULL if no texture is active
|
// current texture or NULL if no texture is active
|
||||||
TextureInfo* m_pcCurrentTexture;
|
TextureInfo* m_pcCurrentTexture;
|
||||||
|
|
||||||
// List of all node in the display CB
|
// List of all node in the display CB
|
||||||
std::vector<NodeInfo> m_asNodes;
|
std::vector<NodeInfo> m_asNodes;
|
||||||
|
|
||||||
// List of all node in the display CB
|
// List of all node in the display CB
|
||||||
std::vector<MeshInfo> m_asMeshes;
|
std::vector<MeshInfo> m_asMeshes;
|
||||||
|
|
||||||
// current Node or NULL if no Node is active
|
// current Node or NULL if no Node is active
|
||||||
NodeInfo* m_pcCurrentNode;
|
NodeInfo* m_pcCurrentNode;
|
||||||
|
|
||||||
// List of all materials in the display CB
|
// List of all materials in the display CB
|
||||||
std::vector<MaterialInfo> m_asMaterials;
|
std::vector<MaterialInfo> m_asMaterials;
|
||||||
|
|
||||||
// current material or NULL if no material is active
|
// current material or NULL if no material is active
|
||||||
MaterialInfo* m_pcCurrentMaterial;
|
MaterialInfo* m_pcCurrentMaterial;
|
||||||
|
|
||||||
// indices into the image list of the "display" tree view control
|
// indices into the image list of the "display" tree view control
|
||||||
unsigned int m_aiImageList[5]; /* = {0,1,2,3,4};*/
|
unsigned int m_aiImageList[ 5 ]; /* = {0,1,2,3,4};*/
|
||||||
|
|
||||||
// Image list
|
// Image list
|
||||||
HIMAGELIST m_hImageList;
|
HIMAGELIST m_hImageList;
|
||||||
|
|
||||||
// Root node of the tree, "Model"
|
// Root node of the tree, "Model"
|
||||||
HTREEITEM m_hRoot;
|
HTREEITEM m_hRoot;
|
||||||
|
|
||||||
// Current zoom factor of the texture viewer
|
// Current zoom factor of the texture viewer
|
||||||
float m_fTextureZoom;
|
float m_fTextureZoom;
|
||||||
|
|
||||||
// Current offset (in pixels) of the texture viewer
|
// Current offset (in pixels) of the texture viewer
|
||||||
aiVector2D m_vTextureOffset;
|
aiVector2D m_vTextureOffset;
|
||||||
|
|
||||||
// Colors used to draw the checker pattern (for the
|
// Colors used to draw the checker pattern (for the
|
||||||
// texture viewer as background )
|
// texture viewer as background )
|
||||||
D3DXVECTOR4 m_avCheckerColors[2];
|
D3DXVECTOR4 m_avCheckerColors[ 2 ];
|
||||||
|
|
||||||
// View projection matrix
|
// View projection matrix
|
||||||
aiMatrix4x4 mViewProjection;
|
aiMatrix4x4 mViewProjection;
|
||||||
aiVector3D vPos;
|
aiVector3D vPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
#endif // AV_DISPLAY_H_INCLUDE
|
#endif // AV_DISPLAY_H_INCLUDE
|
|
@ -39,14 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
#include "richedit.h"
|
#include "richedit.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Message procedure for the help dialog
|
// Message procedure for the help dialog
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -39,10 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -39,14 +39,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
CLogDisplay CLogDisplay::s_cInstance;
|
||||||
/* extern */ CLogDisplay CLogDisplay::s_cInstance;
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogDisplay::AddEntry(const std::string& szText,
|
void CLogDisplay::AddEntry(const std::string& szText,
|
||||||
|
|
|
@ -38,59 +38,62 @@ 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.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#if (!defined AV_LOG_DISPLAY_H_INCLUDED)
|
#include <list>
|
||||||
#define AV_LOG_DISPLAY_H_INCLUDE
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
namespace AssimpView
|
||||||
/** \brief Class to display log strings in the upper right corner of the view
|
{
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
class CLogDisplay
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
CLogDisplay() {}
|
//-------------------------------------------------------------------------------
|
||||||
|
/** \brief Class to display log strings in the upper right corner of the view
|
||||||
|
*/
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
class CLogDisplay
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
public:
|
CLogDisplay() {}
|
||||||
|
|
||||||
// data structure for an entry in the log queue
|
public:
|
||||||
struct SEntry
|
|
||||||
{
|
|
||||||
SEntry ()
|
|
||||||
:
|
|
||||||
clrColor(D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0x00)), dwStartTicks(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
std::string szText;
|
// data structure for an entry in the log queue
|
||||||
D3DCOLOR clrColor;
|
struct SEntry
|
||||||
DWORD dwStartTicks;
|
{
|
||||||
};
|
SEntry()
|
||||||
|
:
|
||||||
|
clrColor( D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) ), dwStartTicks( 0 )
|
||||||
|
{}
|
||||||
|
|
||||||
// Singleton accessors
|
std::string szText;
|
||||||
static CLogDisplay s_cInstance;
|
D3DCOLOR clrColor;
|
||||||
inline static CLogDisplay& Instance ()
|
DWORD dwStartTicks;
|
||||||
{
|
};
|
||||||
return s_cInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add an entry to the log queue
|
// Singleton accessors
|
||||||
void AddEntry(const std::string& szText,
|
static CLogDisplay s_cInstance;
|
||||||
const D3DCOLOR clrColor = D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0x00));
|
inline static CLogDisplay& Instance()
|
||||||
|
{
|
||||||
|
return s_cInstance;
|
||||||
|
}
|
||||||
|
|
||||||
// Release any native resources associated with the instance
|
// Add an entry to the log queue
|
||||||
void ReleaseNativeResource();
|
void AddEntry( const std::string& szText,
|
||||||
|
const D3DCOLOR clrColor = D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) );
|
||||||
|
|
||||||
// Recreate any native resources associated with the instance
|
// Release any native resources associated with the instance
|
||||||
void RecreateNativeResource();
|
void ReleaseNativeResource();
|
||||||
|
|
||||||
// Called during the render loop
|
// Recreate any native resources associated with the instance
|
||||||
void OnRender();
|
void RecreateNativeResource();
|
||||||
|
|
||||||
private:
|
// Called during the render loop
|
||||||
|
void OnRender();
|
||||||
|
|
||||||
std::list<SEntry> asEntries;
|
private:
|
||||||
ID3DXFont* piFont;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // AV_LOG_DISPLAY_H_INCLUDE
|
std::list<SEntry> asEntries;
|
||||||
|
ID3DXFont* piFont;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -39,13 +39,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
#include "richedit.h"
|
#include "richedit.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
/* extern */ CLogWindow CLogWindow::s_cInstance;
|
CLogWindow CLogWindow::s_cInstance;
|
||||||
|
|
||||||
extern HKEY g_hRegistry;
|
extern HKEY g_hRegistry;
|
||||||
|
|
||||||
// header for the RTF log file
|
// header for the RTF log file
|
||||||
|
|
|
@ -42,87 +42,92 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#if (!defined AV_LOG_WINDOW_H_INCLUDED)
|
#if (!defined AV_LOG_WINDOW_H_INCLUDED)
|
||||||
#define AV_LOG_WINDOW_H_INCLUDE
|
#define AV_LOG_WINDOW_H_INCLUDE
|
||||||
|
|
||||||
|
namespace AssimpView
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
/** \brief Subclass of Assimp::LogStream used to add all log messages to the
|
|
||||||
* log window.
|
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
class CMyLogStream : public Assimp::LogStream
|
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
/** @brief Implementation of the abstract method */
|
|
||||||
void write(const char* message);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/** \brief Class to display log strings in a separate window
|
/** \brief Subclass of Assimp::LogStream used to add all log messages to the
|
||||||
*/
|
* log window.
|
||||||
//-------------------------------------------------------------------------------
|
*/
|
||||||
class CLogWindow
|
//-------------------------------------------------------------------------------
|
||||||
{
|
class CMyLogStream : public Assimp::LogStream
|
||||||
private:
|
{
|
||||||
|
public:
|
||||||
friend class CMyLogStream;
|
/** @brief Implementation of the abstract method */
|
||||||
friend INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
void write( const char* message );
|
||||||
WPARAM wParam,LPARAM lParam);
|
};
|
||||||
|
|
||||||
CLogWindow() : hwnd(NULL), bIsVisible(false), bUpdate(true) {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
// Singleton accessors
|
//-------------------------------------------------------------------------------
|
||||||
static CLogWindow s_cInstance;
|
/** \brief Class to display log strings in a separate window
|
||||||
inline static CLogWindow& Instance ()
|
*/
|
||||||
{
|
//-------------------------------------------------------------------------------
|
||||||
return s_cInstance;
|
class CLogWindow
|
||||||
}
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
// initializes the log window
|
friend class CMyLogStream;
|
||||||
void Init ();
|
friend INT_PTR CALLBACK LogDialogProc( HWND hwndDlg, UINT uMsg,
|
||||||
|
WPARAM wParam, LPARAM lParam );
|
||||||
|
|
||||||
// Shows the log window
|
CLogWindow() : hwnd( NULL ), bIsVisible( false ), bUpdate( true ) {}
|
||||||
void Show();
|
|
||||||
|
|
||||||
// Clears the log window
|
public:
|
||||||
void Clear();
|
|
||||||
|
|
||||||
// Save the log window to an user-defined file
|
|
||||||
void Save();
|
|
||||||
|
|
||||||
// write a line to the log window
|
|
||||||
void WriteLine(const char* message);
|
|
||||||
|
|
||||||
// Set the bUpdate member
|
|
||||||
inline void SetAutoUpdate(bool b)
|
|
||||||
{
|
|
||||||
this->bUpdate = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
// updates the log file
|
|
||||||
void Update();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// Window handle
|
|
||||||
HWND hwnd;
|
|
||||||
|
|
||||||
// current text of the window (contains RTF tags)
|
|
||||||
std::string szText;
|
|
||||||
std::string szPlainText;
|
|
||||||
|
|
||||||
// is the log window currently visible?
|
|
||||||
bool bIsVisible;
|
|
||||||
|
|
||||||
// Specified whether each new log message updates the log automatically
|
|
||||||
bool bUpdate;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
// Singleton accessors
|
||||||
// associated log stream
|
static CLogWindow s_cInstance;
|
||||||
CMyLogStream* pcStream;
|
inline static CLogWindow& Instance()
|
||||||
};
|
{
|
||||||
|
return s_cInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// initializes the log window
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
// Shows the log window
|
||||||
|
void Show();
|
||||||
|
|
||||||
|
// Clears the log window
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
// Save the log window to an user-defined file
|
||||||
|
void Save();
|
||||||
|
|
||||||
|
// write a line to the log window
|
||||||
|
void WriteLine( const char* message );
|
||||||
|
|
||||||
|
// Set the bUpdate member
|
||||||
|
inline void SetAutoUpdate( bool b )
|
||||||
|
{
|
||||||
|
this->bUpdate = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// updates the log file
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Window handle
|
||||||
|
HWND hwnd;
|
||||||
|
|
||||||
|
// current text of the window (contains RTF tags)
|
||||||
|
std::string szText;
|
||||||
|
std::string szPlainText;
|
||||||
|
|
||||||
|
// is the log window currently visible?
|
||||||
|
bool bIsVisible;
|
||||||
|
|
||||||
|
// Specified whether each new log message updates the log automatically
|
||||||
|
bool bUpdate;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
// associated log stream
|
||||||
|
CMyLogStream* pcStream;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // AV_LOG_DISPLA
|
#endif // AV_LOG_DISPLA
|
File diff suppressed because it is too large
Load Diff
|
@ -39,164 +39,170 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (!defined AV_MATERIAL_H_INCLUDED)
|
#pragma once
|
||||||
#define AV_MATERIAL_H_INCLUDE
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
#include <map>
|
||||||
/* Helper class to create, access and destroy materials
|
|
||||||
*/
|
#include "AssetHelper.h"
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
class CMaterialManager
|
namespace AssimpView
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
|
|
||||||
friend class CDisplay;
|
//-------------------------------------------------------------------------------
|
||||||
|
/* Helper class to create, access and destroy materials
|
||||||
|
*/
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
class CMaterialManager
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
// default constructor
|
friend class CDisplay;
|
||||||
CMaterialManager()
|
|
||||||
: m_iShaderCount (0), sDefaultTexture() {}
|
|
||||||
|
|
||||||
~CMaterialManager() {
|
// default constructor
|
||||||
if (sDefaultTexture) {
|
CMaterialManager()
|
||||||
sDefaultTexture->Release();
|
: m_iShaderCount( 0 ), sDefaultTexture() {}
|
||||||
}
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
~CMaterialManager() {
|
||||||
|
if( sDefaultTexture ) {
|
||||||
|
sDefaultTexture->Release();
|
||||||
|
}
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
public:
|
||||||
// Singleton accessors
|
|
||||||
static CMaterialManager s_cInstance;
|
|
||||||
inline static CMaterialManager& Instance ()
|
|
||||||
{
|
|
||||||
return s_cInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Delete all resources of a given material
|
// Singleton accessors
|
||||||
//
|
static CMaterialManager s_cInstance;
|
||||||
// Must be called before CreateMaterial() to prevent memory leaking
|
inline static CMaterialManager& Instance()
|
||||||
void DeleteMaterial(AssetHelper::MeshHelper* pcIn);
|
{
|
||||||
|
return s_cInstance;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Create the material for a mesh.
|
// Delete all resources of a given material
|
||||||
//
|
//
|
||||||
// The function checks whether an identical shader is already in use.
|
// Must be called before CreateMaterial() to prevent memory leaking
|
||||||
// A shader is considered to be identical if it has the same input
|
void DeleteMaterial( AssetHelper::MeshHelper* pcIn );
|
||||||
// signature and takes the same number of texture channels.
|
|
||||||
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,
|
|
||||||
const aiMesh* pcSource);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Setup the material for a given mesh
|
// Create the material for a mesh.
|
||||||
// pcMesh Mesh to be rendered
|
//
|
||||||
// pcProj Projection matrix
|
// The function checks whether an identical shader is already in use.
|
||||||
// aiMe Current world matrix
|
// A shader is considered to be identical if it has the same input
|
||||||
// pcCam Camera matrix
|
// signature and takes the same number of texture channels.
|
||||||
// vPos Position of the camera
|
int CreateMaterial( AssetHelper::MeshHelper* pcMesh,
|
||||||
// TODO: Extract camera position from matrix ...
|
const aiMesh* pcSource );
|
||||||
//
|
|
||||||
int SetupMaterial (AssetHelper::MeshHelper* pcMesh,
|
|
||||||
const aiMatrix4x4& pcProj,
|
|
||||||
const aiMatrix4x4& aiMe,
|
|
||||||
const aiMatrix4x4& pcCam,
|
|
||||||
const aiVector3D& vPos);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// End the material for a given mesh
|
// Setup the material for a given mesh
|
||||||
// Called after mesh rendering is complete
|
// pcMesh Mesh to be rendered
|
||||||
// pcMesh Mesh object
|
// pcProj Projection matrix
|
||||||
int EndMaterial (AssetHelper::MeshHelper* pcMesh);
|
// aiMe Current world matrix
|
||||||
|
// pcCam Camera matrix
|
||||||
|
// vPos Position of the camera
|
||||||
|
// TODO: Extract camera position from matrix ...
|
||||||
|
//
|
||||||
|
int SetupMaterial( AssetHelper::MeshHelper* pcMesh,
|
||||||
|
const aiMatrix4x4& pcProj,
|
||||||
|
const aiMatrix4x4& aiMe,
|
||||||
|
const aiMatrix4x4& pcCam,
|
||||||
|
const aiVector3D& vPos );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Recreate all specular materials depending on the current
|
// End the material for a given mesh
|
||||||
// specularity settings
|
// Called after mesh rendering is complete
|
||||||
//
|
// pcMesh Mesh object
|
||||||
// Diffuse-only materials are ignored.
|
int EndMaterial( AssetHelper::MeshHelper* pcMesh );
|
||||||
// Must be called after specular highlights have been toggled
|
|
||||||
int UpdateSpecularMaterials();
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// find a valid path to a texture file
|
// Recreate all specular materials depending on the current
|
||||||
//
|
// specularity settings
|
||||||
// Handle 8.3 syntax correctly, search the environment of the
|
//
|
||||||
// executable and the asset for a texture with a name very similar
|
// Diffuse-only materials are ignored.
|
||||||
// to a given one
|
// Must be called after specular highlights have been toggled
|
||||||
int FindValidPath(aiString* p_szString);
|
int UpdateSpecularMaterials();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Load a texture into memory and create a native D3D texture resource
|
// find a valid path to a texture file
|
||||||
//
|
//
|
||||||
// The function tries to find a valid path for a texture
|
// Handle 8.3 syntax correctly, search the environment of the
|
||||||
int LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath);
|
// executable and the asset for a texture with a name very similar
|
||||||
|
// to a given one
|
||||||
|
int FindValidPath( aiString* p_szString );
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Load a texture into memory and create a native D3D texture resource
|
||||||
|
//
|
||||||
|
// The function tries to find a valid path for a texture
|
||||||
|
int LoadTexture( IDirect3DTexture9** p_ppiOut, aiString* szPath );
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Getter for m_iShaderCount
|
// 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();
|
||||||
}
|
}
|
||||||
sCachedTextures.clear();
|
sCachedTextures.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// find a valid path to a texture file
|
// find a valid path to a texture file
|
||||||
//
|
//
|
||||||
// Handle 8.3 syntax correctly, search the environment of the
|
// Handle 8.3 syntax correctly, search the environment of the
|
||||||
// executable and the asset for a texture with a name very similar
|
// executable and the asset for a texture with a name very similar
|
||||||
// to a given one
|
// to a given one
|
||||||
bool TryLongerPath(char* szTemp,aiString* p_szString);
|
bool TryLongerPath( char* szTemp, aiString* p_szString );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Setup the default texture for a texture channel
|
// Setup the default texture for a texture channel
|
||||||
//
|
//
|
||||||
// Generates a default checker pattern for a texture
|
// Generates a default checker pattern for a texture
|
||||||
int SetDefaultTexture(IDirect3DTexture9** p_ppiOut);
|
int SetDefaultTexture( IDirect3DTexture9** p_ppiOut );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Convert a height map to a normal map if necessary
|
// Convert a height map to a normal map if necessary
|
||||||
//
|
//
|
||||||
// The function tries to detect the type of a texture automatically.
|
// The function tries to detect the type of a texture automatically.
|
||||||
// However, this wont work in every case.
|
// However, this wont work in every case.
|
||||||
void HMtoNMIfNecessary(IDirect3DTexture9* piTexture,
|
void HMtoNMIfNecessary( IDirect3DTexture9* piTexture,
|
||||||
IDirect3DTexture9** piTextureOut,
|
IDirect3DTexture9** piTextureOut,
|
||||||
bool bWasOriginallyHM = true);
|
bool bWasOriginallyHM = true );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Search for non-opaque pixels in a texture
|
// Search for non-opaque pixels in a texture
|
||||||
//
|
//
|
||||||
// A pixel is considered to be non-opaque if its alpha value is
|
// A pixel is considered to be non-opaque if its alpha value is
|
||||||
// less than 255
|
// less than 255
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
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()
|
||||||
// each time a shader isn't found in cache and needs to be created
|
// each time a shader isn't found in cache and needs to be created
|
||||||
//
|
//
|
||||||
unsigned int m_iShaderCount;
|
unsigned int m_iShaderCount;
|
||||||
IDirect3DTexture9* sDefaultTexture;
|
IDirect3DTexture9* sDefaultTexture;
|
||||||
|
|
||||||
typedef std::map<std::string,IDirect3DTexture9*> TextureCache;
|
typedef std::map<std::string, IDirect3DTexture9*> TextureCache;
|
||||||
TextureCache sCachedTextures;
|
TextureCache sCachedTextures;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //!! include guard
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -47,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
|
||||||
CMeshRenderer CMeshRenderer::s_cInstance;
|
CMeshRenderer CMeshRenderer::s_cInstance;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -42,56 +42,58 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#if (!defined AV_MESH_RENDERER_H_INCLUDED)
|
#if (!defined AV_MESH_RENDERER_H_INCLUDED)
|
||||||
#define AV_MESH_RENDERER_H_INCLUDED
|
#define AV_MESH_RENDERER_H_INCLUDED
|
||||||
|
|
||||||
|
namespace AssimpView {
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/* Helper class tp render meshes
|
/* Helper class tp render meshes
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class CMeshRenderer
|
class CMeshRenderer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// default constructor
|
// default constructor
|
||||||
CMeshRenderer()
|
CMeshRenderer()
|
||||||
|
|
||||||
{
|
{
|
||||||
// no other members to initialize
|
// no other members to initialize
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Singleton accessors
|
// Singleton accessors
|
||||||
static CMeshRenderer s_cInstance;
|
static CMeshRenderer s_cInstance;
|
||||||
inline static CMeshRenderer& Instance ()
|
inline static CMeshRenderer& Instance()
|
||||||
{
|
{
|
||||||
return s_cInstance;
|
return s_cInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Draw a mesh in the global mesh list using the current pipeline state
|
// Draw a mesh in the global mesh list using the current pipeline state
|
||||||
// iIndex Index of the mesh to be drawn
|
// iIndex Index of the mesh to be drawn
|
||||||
//
|
//
|
||||||
// The function draws all faces in order, regardless of their distance
|
// The function draws all faces in order, regardless of their distance
|
||||||
int DrawUnsorted(unsigned int iIndex);
|
int DrawUnsorted( unsigned int iIndex );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Draw a mesh in the global mesh list using the current pipeline state
|
// Draw a mesh in the global mesh list using the current pipeline state
|
||||||
// iIndex Index of the mesh to be drawn
|
// iIndex Index of the mesh to be drawn
|
||||||
//
|
//
|
||||||
// The method sorts all vertices by their distance (back to front)
|
// The method sorts all vertices by their distance (back to front)
|
||||||
//
|
//
|
||||||
// mWorld World matrix for the node
|
// mWorld World matrix for the node
|
||||||
int DrawSorted(unsigned int iIndex,
|
int DrawSorted( unsigned int iIndex,
|
||||||
const aiMatrix4x4& mWorld);
|
const aiMatrix4x4& mWorld );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
#endif //!! include guard
|
#endif //!! include guard
|
|
@ -39,12 +39,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
// Static array to keep custom color values
|
// Static array to keep custom color values
|
||||||
COLORREF g_aclCustomColors[16] = {0};
|
COLORREF g_aclCustomColors[16] = {0};
|
||||||
|
|
||||||
|
@ -1044,9 +1048,9 @@ void DoExport(size_t formatId)
|
||||||
ai_assert(strlen(szFileName) <= MAX_PATH);
|
ai_assert(strlen(szFileName) <= MAX_PATH);
|
||||||
|
|
||||||
// invent a nice default file name
|
// invent a nice default file name
|
||||||
char* sz = std::max(strrchr(szFileName,'\\'),strrchr(szFileName,'/'));
|
char* sz = max(strrchr(szFileName,'\\'),strrchr(szFileName,'/'));
|
||||||
if (sz) {
|
if (sz) {
|
||||||
strncpy(sz,std::max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH);
|
strncpy(sz,max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
// note: these are no longer part of the public API, but they are
|
// note: these are no longer part of the public API, but they are
|
||||||
|
@ -53,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
bool g_bWasFlipped = false;
|
bool g_bWasFlipped = false;
|
||||||
float g_smoothAngle = 80.f;
|
float g_smoothAngle = 80.f;
|
||||||
|
|
|
@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @brief Implementation of the utility class SceneAnimator
|
* @brief Implementation of the utility class SceneAnimator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
using namespace AssimpView;
|
using namespace AssimpView;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -47,6 +47,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// include resource definitions
|
// include resource definitions
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <stdio.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/cimport.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
@ -59,17 +67,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/LogStream.hpp>
|
#include <assimp/LogStream.hpp>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
|
||||||
#include "../../code/AssimpPCH.h" /* HACK */
|
|
||||||
|
|
||||||
#include "../../code/MaterialSystem.h" // aiMaterial class
|
#include "../../code/MaterialSystem.h" // aiMaterial class
|
||||||
#include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp
|
#include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp
|
||||||
|
|
||||||
// in order for std::min and std::max to behave properly
|
// in order for std::min and std::max to behave properly
|
||||||
#ifdef min
|
#ifndef max
|
||||||
#undef min
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#endif // min
|
#endif // max
|
||||||
#ifdef max
|
#ifndef min
|
||||||
#undef max
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
#endif // min
|
#endif // min
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -77,11 +84,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
// default movement speed
|
// default movement speed
|
||||||
#define MOVE_SPEED 3.f
|
#define MOVE_SPEED 3.f
|
||||||
|
|
||||||
using namespace Assimp;
|
|
||||||
|
|
||||||
namespace AssimpView
|
|
||||||
{
|
|
||||||
|
|
||||||
#include "AssetHelper.h"
|
#include "AssetHelper.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "RenderOptions.h"
|
#include "RenderOptions.h"
|
||||||
|
@ -93,7 +95,6 @@ namespace AssimpView
|
||||||
#include "MeshRenderer.h"
|
#include "MeshRenderer.h"
|
||||||
#include "MaterialManager.h"
|
#include "MaterialManager.h"
|
||||||
|
|
||||||
} // end of namespace AssimpView - for a while
|
|
||||||
|
|
||||||
// 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"
|
||||||
|
@ -105,30 +106,30 @@ namespace AssimpView
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int InitD3D(void);
|
int InitD3D(void);
|
||||||
int ShutdownD3D(void);
|
int ShutdownD3D(void);
|
||||||
int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true);
|
int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true);
|
||||||
int CreateDevice (void);
|
int CreateDevice (void);
|
||||||
int ShutdownDevice(void);
|
int ShutdownDevice(void);
|
||||||
int GetProjectionMatrix (aiMatrix4x4& p_mOut);
|
int GetProjectionMatrix (aiMatrix4x4& p_mOut);
|
||||||
int LoadAsset(void);
|
int LoadAsset(void);
|
||||||
int CreateAssetData(void);
|
int CreateAssetData(void);
|
||||||
int DeleteAssetData(bool bNoMaterials = false);
|
int DeleteAssetData(bool bNoMaterials = false);
|
||||||
int ScaleAsset(void);
|
int ScaleAsset(void);
|
||||||
int DeleteAsset(void);
|
int DeleteAsset(void);
|
||||||
int SetupFPSView();
|
int SetupFPSView();
|
||||||
|
|
||||||
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
|
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
|
||||||
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
|
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
|
||||||
|
|
||||||
void HandleMouseInputFPS( void );
|
void HandleMouseInputFPS( void );
|
||||||
void HandleMouseInputLightRotate( void );
|
void HandleMouseInputLightRotate( void );
|
||||||
void HandleMouseInputLocal( void );
|
void HandleMouseInputLocal( void );
|
||||||
void HandleKeyboardInputFPS( void );
|
void HandleKeyboardInputFPS( void );
|
||||||
void HandleMouseInputLightIntensityAndColor( void );
|
void HandleMouseInputLightIntensityAndColor( void );
|
||||||
void HandleMouseInputSkyBox( void );
|
void HandleMouseInputSkyBox( void );
|
||||||
void HandleKeyboardInputTextureView( void );
|
void HandleKeyboardInputTextureView( void );
|
||||||
void HandleMouseInputTextureView( void );
|
void HandleMouseInputTextureView( void );
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -160,7 +161,7 @@ INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Dialog prcoedure for the help dialog
|
// Dialog procedure for the help dialog
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
|
@ -182,7 +183,7 @@ 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)max((intype)0,min(in,mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -117,11 +117,11 @@
|
||||||
2B7F478E1708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
|
2B7F478E1708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
|
||||||
2B7F478F1708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
|
2B7F478F1708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
|
||||||
2B7F47901708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
|
2B7F47901708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
|
||||||
2B7F479B1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
|
2B7F479B1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
|
||||||
2B7F479C1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
|
2B7F479C1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
|
||||||
2B7F479D1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
|
2B7F479D1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
|
||||||
2B7F479E1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
|
2B7F479E1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
|
||||||
2B7F479F1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
|
2B7F479F1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
|
||||||
2B7F47A01708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
|
2B7F47A01708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
|
||||||
2B7F47A11708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
|
2B7F47A11708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
|
||||||
2B7F47A21708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
|
2B7F47A21708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
|
||||||
|
@ -2018,7 +2018,7 @@
|
||||||
2B7F45931708365100A106A9 /* static_assert.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = static_assert.hpp; sourceTree = "<group>"; };
|
2B7F45931708365100A106A9 /* static_assert.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = static_assert.hpp; sourceTree = "<group>"; };
|
||||||
2B7F45941708365100A106A9 /* timer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = timer.hpp; sourceTree = "<group>"; };
|
2B7F45941708365100A106A9 /* timer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = timer.hpp; sourceTree = "<group>"; };
|
||||||
2B7F45961708365100A106A9 /* tuple.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tuple.hpp; sourceTree = "<group>"; };
|
2B7F45961708365100A106A9 /* tuple.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tuple.hpp; sourceTree = "<group>"; };
|
||||||
2B7F45991708365100A106A9 /* ByteSwap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteSwap.h; sourceTree = "<group>"; };
|
2B7F45991708365100A106A9 /* ByteSwapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteSwapper.h; sourceTree = "<group>"; };
|
||||||
2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CalcTangentsProcess.cpp; sourceTree = "<group>"; };
|
2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CalcTangentsProcess.cpp; sourceTree = "<group>"; };
|
||||||
2B7F459B1708365100A106A9 /* CalcTangentsProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CalcTangentsProcess.h; sourceTree = "<group>"; };
|
2B7F459B1708365100A106A9 /* CalcTangentsProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CalcTangentsProcess.h; sourceTree = "<group>"; };
|
||||||
2B7F459C1708365100A106A9 /* CInterfaceIOWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CInterfaceIOWrapper.h; sourceTree = "<group>"; };
|
2B7F459C1708365100A106A9 /* CInterfaceIOWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CInterfaceIOWrapper.h; sourceTree = "<group>"; };
|
||||||
|
@ -2509,7 +2509,7 @@
|
||||||
2B7F45761708365100A106A9 /* BaseProcess.cpp */,
|
2B7F45761708365100A106A9 /* BaseProcess.cpp */,
|
||||||
2B7F45771708365100A106A9 /* BaseProcess.h */,
|
2B7F45771708365100A106A9 /* BaseProcess.h */,
|
||||||
2B7F45831708365100A106A9 /* BlobIOSystem.h */,
|
2B7F45831708365100A106A9 /* BlobIOSystem.h */,
|
||||||
2B7F45991708365100A106A9 /* ByteSwap.h */,
|
2B7F45991708365100A106A9 /* ByteSwapper.h */,
|
||||||
2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */,
|
2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */,
|
||||||
2B7F459B1708365100A106A9 /* CalcTangentsProcess.h */,
|
2B7F459B1708365100A106A9 /* CalcTangentsProcess.h */,
|
||||||
2B7F459C1708365100A106A9 /* CInterfaceIOWrapper.h */,
|
2B7F459C1708365100A106A9 /* CInterfaceIOWrapper.h */,
|
||||||
|
@ -3517,7 +3517,7 @@
|
||||||
2B7F47841708365200A106A9 /* static_assert.hpp in Headers */,
|
2B7F47841708365200A106A9 /* static_assert.hpp in Headers */,
|
||||||
2B7F47891708365200A106A9 /* timer.hpp in Headers */,
|
2B7F47891708365200A106A9 /* timer.hpp in Headers */,
|
||||||
2B7F478E1708365200A106A9 /* tuple.hpp in Headers */,
|
2B7F478E1708365200A106A9 /* tuple.hpp in Headers */,
|
||||||
2B7F479D1708365200A106A9 /* ByteSwap.h in Headers */,
|
2B7F479D1708365200A106A9 /* ByteSwapper.h in Headers */,
|
||||||
2B7F47A71708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
2B7F47A71708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
||||||
2B7F47AC1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
2B7F47AC1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
||||||
2B7F47C51708365200A106A9 /* ColladaExporter.h in Headers */,
|
2B7F47C51708365200A106A9 /* ColladaExporter.h in Headers */,
|
||||||
|
@ -3765,7 +3765,7 @@
|
||||||
2B7F47851708365200A106A9 /* static_assert.hpp in Headers */,
|
2B7F47851708365200A106A9 /* static_assert.hpp in Headers */,
|
||||||
2B7F478A1708365200A106A9 /* timer.hpp in Headers */,
|
2B7F478A1708365200A106A9 /* timer.hpp in Headers */,
|
||||||
2B7F478F1708365200A106A9 /* tuple.hpp in Headers */,
|
2B7F478F1708365200A106A9 /* tuple.hpp in Headers */,
|
||||||
2B7F479E1708365200A106A9 /* ByteSwap.h in Headers */,
|
2B7F479E1708365200A106A9 /* ByteSwapper.h in Headers */,
|
||||||
2B7F47A81708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
2B7F47A81708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
||||||
2B7F47AD1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
2B7F47AD1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
||||||
2B7F47C61708365200A106A9 /* ColladaExporter.h in Headers */,
|
2B7F47C61708365200A106A9 /* ColladaExporter.h in Headers */,
|
||||||
|
@ -4013,7 +4013,7 @@
|
||||||
2B7F47861708365200A106A9 /* static_assert.hpp in Headers */,
|
2B7F47861708365200A106A9 /* static_assert.hpp in Headers */,
|
||||||
2B7F478B1708365200A106A9 /* timer.hpp in Headers */,
|
2B7F478B1708365200A106A9 /* timer.hpp in Headers */,
|
||||||
2B7F47901708365200A106A9 /* tuple.hpp in Headers */,
|
2B7F47901708365200A106A9 /* tuple.hpp in Headers */,
|
||||||
2B7F479F1708365200A106A9 /* ByteSwap.h in Headers */,
|
2B7F479F1708365200A106A9 /* ByteSwapper.h in Headers */,
|
||||||
2B7F47A91708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
2B7F47A91708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
||||||
2B7F47AE1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
2B7F47AE1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
||||||
2B7F47C71708365200A106A9 /* ColladaExporter.h in Headers */,
|
2B7F47C71708365200A106A9 /* ColladaExporter.h in Headers */,
|
||||||
|
@ -4261,7 +4261,7 @@
|
||||||
2B7F47821708365200A106A9 /* static_assert.hpp in Headers */,
|
2B7F47821708365200A106A9 /* static_assert.hpp in Headers */,
|
||||||
2B7F47871708365200A106A9 /* timer.hpp in Headers */,
|
2B7F47871708365200A106A9 /* timer.hpp in Headers */,
|
||||||
2B7F478C1708365200A106A9 /* tuple.hpp in Headers */,
|
2B7F478C1708365200A106A9 /* tuple.hpp in Headers */,
|
||||||
2B7F479B1708365200A106A9 /* ByteSwap.h in Headers */,
|
2B7F479B1708365200A106A9 /* ByteSwapper.h in Headers */,
|
||||||
2B7F47A51708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
2B7F47A51708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
||||||
2B7F47AA1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
2B7F47AA1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
||||||
2B7F47C31708365200A106A9 /* ColladaExporter.h in Headers */,
|
2B7F47C31708365200A106A9 /* ColladaExporter.h in Headers */,
|
||||||
|
@ -4509,7 +4509,7 @@
|
||||||
2B7F47831708365200A106A9 /* static_assert.hpp in Headers */,
|
2B7F47831708365200A106A9 /* static_assert.hpp in Headers */,
|
||||||
2B7F47881708365200A106A9 /* timer.hpp in Headers */,
|
2B7F47881708365200A106A9 /* timer.hpp in Headers */,
|
||||||
2B7F478D1708365200A106A9 /* tuple.hpp in Headers */,
|
2B7F478D1708365200A106A9 /* tuple.hpp in Headers */,
|
||||||
2B7F479C1708365200A106A9 /* ByteSwap.h in Headers */,
|
2B7F479C1708365200A106A9 /* ByteSwapper.h in Headers */,
|
||||||
2B7F47A61708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
2B7F47A61708365200A106A9 /* CalcTangentsProcess.h in Headers */,
|
||||||
2B7F47AB1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
2B7F47AB1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
|
||||||
2B7F47C41708365200A106A9 /* ColladaExporter.h in Headers */,
|
2B7F47C41708365200A106A9 /* ColladaExporter.h in Headers */,
|
||||||
|
|
Loading…
Reference in New Issue