Merge remote-tracking branch 'official/master' into contrib

Conflicts:
	include/assimp/matrix4x4.inl
	include/assimp/vector2.h
	include/assimp/vector3.h
pull/261/head
Léo Terziman 2014-04-22 14:32:59 +02:00
commit 7c3a039349
28 changed files with 407 additions and 184 deletions

View File

@ -53,9 +53,7 @@ SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH
SET(ASSIMP_DEBUG_POSTFIX "d" CACHE STRING "Debug Postfitx for lib, samples and tools")
# Allow the user to build a static library
SET ( ASSIMP_BUILD_STATIC_LIB OFF CACHE BOOL
"Build a static (.a) version of the library"
)
option ( BUILD_SHARED_LIB "Build a shared version of the library" ON )
# Generate a pkg-config .pc for the Assimp library.
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/assimp.pc.in" "${PROJECT_BINARY_DIR}/assimp.pc" @ONLY )

View File

@ -109,11 +109,11 @@ void BlenderBMeshConverter::AssertValidMesh( )
// ------------------------------------------------------------------------------------------------
void BlenderBMeshConverter::AssertValidSizes( )
{
if ( BMesh->totpoly != BMesh->mpoly.size( ) )
if ( BMesh->totpoly != static_cast<int>( BMesh->mpoly.size( ) ) )
{
ThrowException( "BMesh poly array has incorrect size" );
}
if ( BMesh->totloop != BMesh->mloop.size( ) )
if ( BMesh->totloop != static_cast<int>( BMesh->mloop.size( ) ) )
{
ThrowException( "BMesh loop array has incorrect size" );
}

View File

@ -251,10 +251,7 @@ template <> void Structure :: Convert<Base> (
const int initial_pos = db.reader->GetCurrentPos();
std::pair<Base*, int> todo = std::make_pair(&dest, initial_pos);
Base* saved_prev = NULL;
while(true) {
for ( ;; ) {
Base& cur_dest = *todo.first;
db.reader->SetCurrentPos(todo.second);
@ -265,10 +262,6 @@ template <> void Structure :: Convert<Base> (
ReadFieldPtr<ErrorPolicy_Warn>(cur_dest.object,"*object",db);
// just record the offset of the blob data and allocate storage.
// Does _not_ invoke Convert() recursively.
const int old = db.reader->GetCurrentPos();
// the return value of ReadFieldPtr indicates whether the object
// was already cached. In this case, we don't need to resolve
// it again.

View File

@ -51,11 +51,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BlenderBMesh.h"
#include "BlenderTessellator.h"
#define BLEND_TESS_MAGIC ( 0x83ed9ac3 )
static const unsigned int BLEND_TESS_MAGIC = 0x83ed9ac3;
#if ASSIMP_BLEND_WITH_GLU_TESSELLATE
namespace Assimp
namspace Assimp
{
template< > const std::string LogFunctions< BlenderTessellatorGL >::log_prefix = "BLEND_TESS_GL: ";
}
@ -382,7 +382,7 @@ inline PointP2T& BlenderTessellatorP2T::GetActualPointStructure( p2t::Point& poi
{
unsigned int pointOffset = OffsetOf( PointP2T, point2D );
PointP2T& pointStruct = *reinterpret_cast< PointP2T* >( reinterpret_cast< char* >( &point ) - pointOffset );
if ( pointStruct.magic != BLEND_TESS_MAGIC )
if ( pointStruct.magic != static_cast<int>( BLEND_TESS_MAGIC ) )
{
ThrowException( "Point returned by poly2tri was probably not one of ours. This indicates we need a new way to store vertex information" );
}

View File

@ -693,15 +693,7 @@ SET( assimp_src
#ADD_MSVC_PRECOMPILED_HEADER("AssimpPCH.h" "AssimpPCH.cpp" assimp_src)
IF ( ASSIMP_BUILD_STATIC_LIB )
ADD_LIBRARY( assimp STATIC
${assimp_src}
)
ELSE ( ASSIMP_BUILD_STATIC_LIB )
ADD_LIBRARY( assimp SHARED
${assimp_src}
)
ENDIF ( ASSIMP_BUILD_STATIC_LIB )
ADD_LIBRARY( assimp ${assimp_src} )
SET_PROPERTY(TARGET assimp PROPERTY DEBUG_POSTFIX ${ASSIMP_DEBUG_POSTFIX})
@ -725,7 +717,11 @@ else (UNZIP_FOUND)
INCLUDE_DIRECTORIES("../contrib/unzip")
endif (UNZIP_FOUND)
INSTALL( TARGETS assimp DESTINATION ${ASSIMP_LIB_INSTALL_DIR} COMPONENT ${LIBASSIMP_COMPONENT})
INSTALL( TARGETS assimp
LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR}
COMPONENT ${LIBASSIMP_COMPONENT})
INSTALL( FILES ${PUBLIC_HEADERS} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}/assimp COMPONENT assimp-dev)
INSTALL( FILES ${COMPILER_HEADERS} DESTINATION ${ASSIMP_INCLUDE_INSTALL_DIR}/assimp/Compiler COMPONENT assimp-dev)

View File

@ -378,10 +378,11 @@ private:
out_camera->mName.Set(FixNodeName(model.Name()));
out_camera->mAspect = cam.AspectWidth();
out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight();
out_camera->mPosition = cam.Position();
out_camera->mLookAt = cam.InterestPosition() - out_camera->mPosition;
// BUG HERE cam.FieldOfView() returns 1.0f every time. 1.0f is default value.
out_camera->mHorizontalFOV = AI_DEG_TO_RAD(cam.FieldOfView());
}
@ -766,6 +767,7 @@ private:
// find user defined properties (3ds Max)
data->Set(index++, "UserProperties", aiString(PropertyGet<std::string>(props, "UDP3DSMAX", "")));
unparsedProperties.erase("UDP3DSMAX");
// preserve the info that a node was marked as Null node in the original file.
data->Set(index++, "IsNull", model.IsNull() ? true : false);
@ -1439,6 +1441,7 @@ private:
// texture assignments
SetTextureProperties(out_mat,material.Textures());
SetTextureProperties(out_mat,material.LayeredTextures());
return static_cast<unsigned int>(materials.size() - 1);
}
@ -1455,6 +1458,102 @@ private:
}
const Texture* const tex = (*it).second;
if(tex !=0 )
{
aiString path;
path.Set(tex->RelativeFilename());
out_mat->AddProperty(&path,_AI_MATKEY_TEXTURE_BASE,target,0);
aiUVTransform uvTrafo;
// XXX handle all kinds of UV transformations
uvTrafo.mScaling = tex->UVScaling();
uvTrafo.mTranslation = tex->UVTranslation();
out_mat->AddProperty(&uvTrafo,1,_AI_MATKEY_UVTRANSFORM_BASE,target,0);
const PropertyTable& props = tex->Props();
int uvIndex = 0;
bool ok;
const std::string& uvSet = PropertyGet<std::string>(props,"UVSet",ok);
if(ok) {
// "default" is the name which usually appears in the FbxFileTexture template
if(uvSet != "default" && uvSet.length()) {
// this is a bit awkward - we need to find a mesh that uses this
// material and scan its UV channels for the given UV name because
// assimp references UV channels by index, not by name.
// XXX: the case that UV channels may appear in different orders
// in meshes is unhandled. A possible solution would be to sort
// the UV channels alphabetically, but this would have the side
// effect that the primary (first) UV channel would sometimes
// be moved, causing trouble when users read only the first
// UV channel and ignore UV channel assignments altogether.
const unsigned int matIndex = static_cast<unsigned int>(std::distance(materials.begin(),
std::find(materials.begin(),materials.end(),out_mat)
));
uvIndex = -1;
BOOST_FOREACH(const MeshMap::value_type& v,meshes_converted) {
const MeshGeometry* const mesh = dynamic_cast<const MeshGeometry*> (v.first);
if(!mesh) {
continue;
}
const MatIndexArray& mats = mesh->GetMaterialIndices();
if(std::find(mats.begin(),mats.end(),matIndex) == mats.end()) {
continue;
}
int index = -1;
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
if(mesh->GetTextureCoords(i).empty()) {
break;
}
const std::string& name = mesh->GetTextureCoordChannelName(i);
if(name == uvSet) {
index = static_cast<int>(i);
break;
}
}
if(index == -1) {
FBXImporter::LogWarn("did not find UV channel named " + uvSet + " in a mesh using this material");
continue;
}
if(uvIndex == -1) {
uvIndex = index;
}
else {
FBXImporter::LogWarn("the UV channel named " + uvSet +
" appears at different positions in meshes, results will be wrong");
}
}
if(uvIndex == -1) {
FBXImporter::LogWarn("failed to resolve UV channel " + uvSet + ", using first UV channel");
uvIndex = 0;
}
}
}
out_mat->AddProperty(&uvIndex,1,_AI_MATKEY_UVWSRC_BASE,target,0);
}
}
// ------------------------------------------------------------------------------------------------
void TrySetTextureProperties(aiMaterial* out_mat, const LayeredTextureMap& layeredTextures,
const std::string& propName,
aiTextureType target)
{
LayeredTextureMap::const_iterator it = layeredTextures.find(propName);
if(it == layeredTextures.end()) {
return;
}
const Texture* const tex = (*it).second->getTexture();
aiString path;
path.Set(tex->RelativeFilename());
@ -1538,7 +1637,6 @@ private:
out_mat->AddProperty(&uvIndex,1,_AI_MATKEY_UVWSRC_BASE,target,0);
}
// ------------------------------------------------------------------------------------------------
void SetTextureProperties(aiMaterial* out_mat, const TextureMap& textures)
{
@ -1554,6 +1652,20 @@ private:
TrySetTextureProperties(out_mat, textures, "ShininessExponent", aiTextureType_SHININESS);
}
// ------------------------------------------------------------------------------------------------
void SetTextureProperties(aiMaterial* out_mat, const LayeredTextureMap& layeredTextures)
{
TrySetTextureProperties(out_mat, layeredTextures, "DiffuseColor", aiTextureType_DIFFUSE);
TrySetTextureProperties(out_mat, layeredTextures, "AmbientColor", aiTextureType_AMBIENT);
TrySetTextureProperties(out_mat, layeredTextures, "EmissiveColor", aiTextureType_EMISSIVE);
TrySetTextureProperties(out_mat, layeredTextures, "SpecularColor", aiTextureType_SPECULAR);
TrySetTextureProperties(out_mat, layeredTextures, "TransparentColor", aiTextureType_OPACITY);
TrySetTextureProperties(out_mat, layeredTextures, "ReflectionColor", aiTextureType_REFLECTION);
TrySetTextureProperties(out_mat, layeredTextures, "DisplacementColor", aiTextureType_DISPLACEMENT);
TrySetTextureProperties(out_mat, layeredTextures, "NormalMap", aiTextureType_NORMALS);
TrySetTextureProperties(out_mat, layeredTextures, "Bump", aiTextureType_HEIGHT);
TrySetTextureProperties(out_mat, layeredTextures, "ShininessExponent", aiTextureType_SHININESS);
}
// ------------------------------------------------------------------------------------------------

View File

@ -14,7 +14,7 @@ following conditions are met:
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
copyright notice, this list of conditions and the*
following disclaimer in the documentation and/or other
materials provided with the distribution.
@ -176,6 +176,9 @@ const Object* LazyObject::Get(bool dieOnError)
else if (!strncmp(obtype,"Texture",length)) {
object.reset(new Texture(id,element,doc,name));
}
else if (!strncmp(obtype,"LayeredTexture",length)) {
object.reset(new LayeredTexture(id,element,doc,name));
}
else if (!strncmp(obtype,"AnimationStack",length)) {
object.reset(new AnimationStack(id,element,name,doc));
}

View File

@ -516,8 +516,6 @@ private:
boost::shared_ptr<const PropertyTable> props;
};
/** DOM class for generic FBX textures */
class Texture : public Object
{
@ -576,8 +574,73 @@ private:
unsigned int crop[4];
};
/** DOM class for layered FBX textures */
class LayeredTexture : public Object
{
public:
LayeredTexture(uint64_t id, const Element& element, const Document& doc, const std::string& name);
~LayeredTexture();
//Can only be called after construction of the layered texture object due to construction flag.
void fillTexture(const Document& doc);
enum BlendMode
{
BlendMode_Translucent,
BlendMode_Additive,
BlendMode_Modulate,
BlendMode_Modulate2,
BlendMode_Over,
BlendMode_Normal,
BlendMode_Dissolve,
BlendMode_Darken,
BlendMode_ColorBurn,
BlendMode_LinearBurn,
BlendMode_DarkerColor,
BlendMode_Lighten,
BlendMode_Screen,
BlendMode_ColorDodge,
BlendMode_LinearDodge,
BlendMode_LighterColor,
BlendMode_SoftLight,
BlendMode_HardLight,
BlendMode_VividLight,
BlendMode_LinearLight,
BlendMode_PinLight,
BlendMode_HardMix,
BlendMode_Difference,
BlendMode_Exclusion,
BlendMode_Subtract,
BlendMode_Divide,
BlendMode_Hue,
BlendMode_Saturation,
BlendMode_Color,
BlendMode_Luminosity,
BlendMode_Overlay,
BlendMode_BlendModeCount
};
const Texture* getTexture() const
{
return texture;
}
BlendMode GetBlendMode()
{
return blendMode;
}
float Alpha()
{
return alpha;
}
private:
const Texture* texture;
BlendMode blendMode;
float alpha;
};
typedef std::fbx_unordered_map<std::string, const Texture*> TextureMap;
typedef std::fbx_unordered_map<std::string, const LayeredTexture*> LayeredTextureMap;
/** DOM class for generic FBX materials */
@ -607,6 +670,10 @@ public:
return textures;
}
const LayeredTextureMap& LayeredTextures() const {
return layeredTextures;
}
private:
std::string shading;
@ -614,6 +681,7 @@ private:
boost::shared_ptr<const PropertyTable> props;
TextureMap textures;
LayeredTextureMap layeredTextures;
};

View File

@ -110,10 +110,21 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
const Texture* const tex = dynamic_cast<const Texture*>(ob);
if(!tex) {
DOMWarning("source object for texture link is not a texture, ignoring",&element);
const LayeredTexture* const layeredTexture = dynamic_cast<const LayeredTexture*>(ob);
if(!layeredTexture) {
DOMWarning("source object for texture link is not a texture or layered texture, ignoring",&element);
continue;
}
const std::string& prop = con->PropertyName();
if (layeredTextures.find(prop) != layeredTextures.end()) {
DOMWarning("duplicate layered texture link: " + prop,&element);
}
layeredTextures[prop] = layeredTexture;
((LayeredTexture*)layeredTexture)->fillTexture(doc);
}
else
{
const std::string& prop = con->PropertyName();
if (textures.find(prop) != textures.end()) {
DOMWarning("duplicate texture link: " + prop,&element);
@ -121,6 +132,8 @@ Material::Material(uint64_t id, const Element& element, const Document& doc, con
textures[prop] = tex;
}
}
}
@ -194,6 +207,52 @@ Texture::~Texture()
}
LayeredTexture::LayeredTexture(uint64_t id, const Element& element, const Document& doc, const std::string& name)
: Object(id,element,name)
,texture(0)
,blendMode(BlendMode_Modulate)
,alpha(1)
{
const Scope& sc = GetRequiredScope(element);
const Element* const BlendModes = sc["BlendModes"];
const Element* const Alphas = sc["Alphas"];
if(BlendModes!=0)
{
blendMode = (BlendMode)ParseTokenAsInt(GetRequiredToken(*BlendModes,0));
}
if(Alphas!=0)
{
alpha = ParseTokenAsFloat(GetRequiredToken(*Alphas,0));
}
}
LayeredTexture::~LayeredTexture()
{
}
void LayeredTexture::fillTexture(const Document& doc)
{
const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID());
for(size_t i = 0; i < conns.size();++i)
{
const Connection* con = conns.at(i);
const Object* const ob = con->SourceObject();
if(!ob) {
DOMWarning("failed to read source object for texture link, ignoring",&element);
continue;
}
const Texture* const tex = dynamic_cast<const Texture*>(ob);
texture = tex;
}
}
} //!FBX
} //!Assimp

View File

@ -142,7 +142,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int
const aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]];
const aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]];
const aiVector3D* pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices-1]];
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).Normalize();
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1));
for (unsigned int i = 0;i < face.mNumIndices;++i) {
pMesh->mNormals[face.mIndices[i]] = vNor;
@ -209,17 +209,18 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int
// Get all vertices that share this one ...
vertexFinder->FindPositions( pMesh->mVertices[i] , posEpsilon, verticesFound);
aiVector3D vr = pMesh->mNormals[i];
float vrlen = vr.Length();
aiVector3D pcNor;
for (unsigned int a = 0; a < verticesFound.size(); ++a) {
const aiVector3D& v = pMesh->mNormals[verticesFound[a]];
aiVector3D v = pMesh->mNormals[verticesFound[a]];
// check whether the angle between the two normals is not too large
// HACK: if v.x is qnan the dot product will become qnan, too
// therefore the comparison against fLimit should be false
// in every case.
if (v * pMesh->mNormals[i] < fLimit)
continue;
if (v * vr >= fLimit * vrlen * v.Length())
pcNor += v;
}
pcNew[i] = pcNor.Normalize();

View File

@ -326,8 +326,6 @@ void ProcessSweptDiskSolid(const IfcSweptDiskSolid solid, TempMesh& result, Conv
return;
}
const std::vector<IfcVector3>& in = result.verts;
const unsigned int cnt_segments = 16;
const IfcFloat deltaAngle = AI_MATH_TWO_PI/cnt_segments;

View File

@ -74,7 +74,7 @@ bool OptimizeMeshesProcess::IsActive( unsigned int pFlags) const
// That's a serious design flaw, consider redesign.
if( 0 != (pFlags & aiProcess_OptimizeMeshes) ) {
pts = (0 != (pFlags & aiProcess_SortByPType));
max_verts = (0 != (pFlags & aiProcess_SplitLargeMeshes)) ? 0xdeadbeef : 0;
max_verts = (0 != (pFlags & aiProcess_SplitLargeMeshes)) ? 0xdeadbeef : max_verts;
return true;
}
return false;

View File

@ -154,9 +154,6 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
#if (!defined ASSIMP_BUILD_NO_OPTIMIZEGRAPH_PROCESS)
out.push_back( new OptimizeGraphProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_OPTIMIZEMESHES_PROCESS)
out.push_back( new OptimizeMeshesProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FINDDEGENERATES_PROCESS)
out.push_back( new FindDegeneratesProcess());
#endif
@ -178,6 +175,9 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out)
#if (!defined ASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS)
out.push_back( new FindInvalidDataProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_OPTIMIZEMESHES_PROCESS)
out.push_back( new OptimizeMeshesProcess());
#endif
#if (!defined ASSIMP_BUILD_NO_FIXINFACINGNORMALS_PROCESS)
out.push_back( new FixInfacingNormalsProcess());
#endif

View File

@ -42,10 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
namespace Assimp
{
namespace Q3BSP
{
namespace Assimp {
namespace Q3BSP {
static const unsigned int CE_BSP_LIGHTMAPWIDTH = 128;
static const unsigned int CE_BSP_LIGHTMAPHEIGHT = 128;
@ -54,8 +52,7 @@ static const unsigned int CE_BSP_LIGHTMAPSIZE = 128*128*3; ///< = 128( width ) *
static const int VERION_Q3LEVEL = 46; ///< Supported version.
/// Geometric type enumeration
enum Q3BSPGeoType
{
enum Q3BSPGeoType {
Polygon = 1,
Patch,
TriangleMesh,
@ -63,25 +60,23 @@ enum Q3BSPGeoType
};
/// Integer vector.
struct ceVec3i
{
struct ceVec3i {
int x, y, z;
ceVec3i(): x( 0 ), y( 0 ), z( 0 ) { /* empty */ }
ceVec3i( int iX, int iY=0, int iZ=0) : x( iX ), y( iY ), z( iZ ) { /* empty */ }
};
/// Fileheader
struct sQ3BSPHeader
{
char strID[ 4 ]; //!< Should be "IBSP"
int iVersion; //!< 46 for standard levels
/// the file header
struct sQ3BSPHeader {
char strID[ 4 ]; ///< Should be "IBSP"
int iVersion; ///< 46 for standard levels
};
/// Descripes an entry.
/// Describes an entry.
struct sQ3BSPLump
{
int iOffset; ///< Offset from startpointer of file
int iSize; ///< Size fo part
int iOffset; ///< Offset from start pointer of file
int iSize; ///< Size of part
};
struct vec2f
@ -108,47 +103,42 @@ struct sQ3BSPVertex
struct sQ3BSPFace
{
int iTextureID; ///< Index in texture array
int iEffect; ///< Index in effectarray (-1 = no effect)
int iEffect; ///< Index in effect array (-1 = no effect)
int iType; ///< 1=Polygon, 2=Patch, 3=Mesh, 4=Billboard
int iVertexIndex; ///< Start index of polygon
int iNumOfVerts; ///< Number of vertices
int iFaceVertexIndex; ///< Index of first mesh vertex
int iNumOfFaceVerts; ///< Anzahl der Meshvertices
int iLightmapID; ///< Index to the lightmap array
int iLMapCorner[ 2 ]; ///< Die Ecke der Lightmap in der Textur
int iLMapSize[ 2 ]; ///< Size of the lightmap stored on the texture
vec3f vLMapPos; ///< 3D-Ursprung der Lightmap
vec3f vLMapVecs[ 2 ]; ///< 3D-s-t-Vektoren
vec3f vNormal; ///< Polygonnormale
int iNumOfFaceVerts; ///< number of mesh vertices
int iLightmapID; ///< Index to the light-map array
int iLMapCorner[ 2 ]; ///< edge of the light-map in texture
int iLMapSize[ 2 ]; ///< Size of the light-map stored on the texture
vec3f vLMapPos; ///< 3D origin of the light-map
vec3f vLMapVecs[ 2 ]; ///< 3D-s-t-vectors
vec3f vNormal; ///< Polygon normals
int patchWidth, patchHeight; ///< bezier patch
};
/// A quake3 texture name.
struct sQ3BSPTexture
{
char strName[ 64 ]; ///< Name of the texture without extention
struct sQ3BSPTexture {
char strName[ 64 ]; ///< Name of the texture without extension
int iFlags; ///< Not used
int iContents; ///< Not used
};
/// A lightmap of the level, size 128 x 128, RGB components.
struct sQ3BSPLightmap
{
/// A light-map of the level, size 128 x 128, RGB components.
struct sQ3BSPLightmap {
unsigned char bLMapData[ CE_BSP_LIGHTMAPSIZE ];
sQ3BSPLightmap()
{
memset(bLMapData, 0, CE_BSP_LIGHTMAPSIZE );
sQ3BSPLightmap() {
::memset(bLMapData, 0, CE_BSP_LIGHTMAPSIZE );
}
};
struct SubPatch
{
struct SubPatch {
std::vector<size_t> indices;
int lightmapID;
};
enum eLumps
{
enum eLumps {
kEntities = 0,
kTextures,
kPlanes,
@ -169,8 +159,7 @@ enum eLumps
kMaxLumps
};
struct Q3BSPModel
{
struct Q3BSPModel {
std::vector<unsigned char> m_Data;
std::vector<sQ3BSPLump*> m_Lumps;
std::vector<sQ3BSPVertex*> m_Vertices;
@ -195,24 +184,22 @@ struct Q3BSPModel
// empty
}
~Q3BSPModel()
{
for ( unsigned int i=0; i<m_Lumps.size(); i++ )
if ( NULL != m_Lumps[i] )
delete m_Lumps[i];
for ( unsigned int i=0; i<m_Vertices.size(); i++ )
if ( NULL != m_Vertices[ i ] )
~Q3BSPModel() {
for ( unsigned int i=0; i<m_Lumps.size(); i++ ) {
delete m_Lumps[ i ];
}
for ( unsigned int i=0; i<m_Vertices.size(); i++ ) {
delete m_Vertices[ i ];
for ( unsigned int i=0; i<m_Faces.size(); i++ )
if ( NULL != m_Faces[ i ] )
}
for ( unsigned int i=0; i<m_Faces.size(); i++ ) {
delete m_Faces[ i ];
for ( unsigned int i=0; i<m_Textures.size(); i++ )
if ( NULL != m_Textures[ i ] )
}
for ( unsigned int i=0; i<m_Textures.size(); i++ ) {
delete m_Textures[ i ];
for ( unsigned int i=0; i<m_Lightmaps.size(); i++ )
if ( NULL != m_Lightmaps[ i ] )
}
for ( unsigned int i=0; i<m_Lightmaps.size(); i++ ) {
delete m_Lightmaps[ i ];
}
m_Lumps.clear();
m_Vertices.clear();

View File

@ -71,8 +71,13 @@ static const aiImporterDesc desc = {
"pk3"
};
namespace Assimp
{
namespace Assimp {
static void getSupportedExtensions(std::vector<std::string> &supportedExtensions) {
supportedExtensions.push_back( ".jpg" );
supportedExtensions.push_back( ".png" );
supportedExtensions.push_back( ".tga" );
}
using namespace Q3BSP;
@ -86,7 +91,7 @@ static void createKey( int id1, int id2, std::string &rKey )
}
// ------------------------------------------------------------------------------------------------
// Local function to extract the texture ids from a material keyname.
// Local function to extract the texture ids from a material key-name.
static void extractIds( const std::string &rKey, int &rId1, int &rId2 )
{
rId1 = -1;
@ -146,24 +151,16 @@ Q3BSPFileImporter::Q3BSPFileImporter() :
// ------------------------------------------------------------------------------------------------
// Destructor.
Q3BSPFileImporter::~Q3BSPFileImporter()
{
// For lint
Q3BSPFileImporter::~Q3BSPFileImporter() {
m_pCurrentMesh = NULL;
m_pCurrentFace = NULL;
// Clear face-to-material map
for ( FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end();
++it )
{
const std::string matName = (*it).first;
if ( matName.empty() )
{
continue;
for ( FaceMap::iterator it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it ) {
const std::string &matName = it->first;
if ( !matName.empty() ) {
delete it->second;
}
std::vector<Q3BSP::sQ3BSPFace*> *pCurFaceArray = (*it).second;
delete pCurFaceArray;
}
m_MaterialLookupMap.clear();
}
@ -566,7 +563,7 @@ size_t Q3BSPFileImporter::countFaces( const std::vector<Q3BSP::sQ3BSPFace*> &rAr
}
// ------------------------------------------------------------------------------------------------
// Counts the number of triangles in a Q3-facearray.
// Counts the number of triangles in a Q3-face-array.
size_t Q3BSPFileImporter::countTriangles( const std::vector<Q3BSP::sQ3BSPFace*> &rArray ) const
{
size_t numTriangles = 0;
@ -617,16 +614,11 @@ void Q3BSPFileImporter::createMaterialMap( const Q3BSP::Q3BSPModel *pModel )
// Returns the next face.
aiFace *Q3BSPFileImporter::getNextFace( aiMesh *pMesh, unsigned int &rFaceIdx )
{
aiFace *pFace = NULL;
if ( rFaceIdx < pMesh->mNumFaces )
{
aiFace *pFace( NULL );
if ( rFaceIdx < pMesh->mNumFaces ) {
pFace = &pMesh->mFaces[ rFaceIdx ];
rFaceIdx++;
}
else
{
pFace = NULL;
}
return pFace;
}
@ -634,34 +626,30 @@ aiFace *Q3BSPFileImporter::getNextFace( aiMesh *pMesh, unsigned int &rFaceIdx )
// ------------------------------------------------------------------------------------------------
// Imports a texture file.
bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *pModel,
Q3BSP::Q3BSPZipArchive *pArchive, aiScene* /*pScene*/,
aiMaterial *pMatHelper, int textureId )
{
std::vector<std::string> supportedExtensions;
supportedExtensions.push_back( ".jpg" );
supportedExtensions.push_back( ".png" );
supportedExtensions.push_back( ".tga" );
if ( NULL == pArchive || NULL == pArchive || NULL == pMatHelper )
{
Q3BSP::Q3BSPZipArchive *pArchive, aiScene*,
aiMaterial *pMatHelper, int textureId ) {
if ( NULL == pArchive || NULL == pArchive || NULL == pMatHelper ) {
return false;
}
if ( textureId < 0 || textureId >= static_cast<int>( pModel->m_Textures.size() ) )
{
if ( textureId < 0 || textureId >= static_cast<int>( pModel->m_Textures.size() ) ) {
return false;
}
bool res = true;
sQ3BSPTexture *pTexture = pModel->m_Textures[ textureId ];
if ( NULL == pTexture )
if ( !pTexture ) {
return false;
}
std::vector<std::string> supportedExtensions;
supportedExtensions.push_back( ".jpg" );
supportedExtensions.push_back( ".png" );
supportedExtensions.push_back( ".tga" );
std::string textureName, ext;
if ( expandFile( pArchive, pTexture->strName, supportedExtensions, textureName, ext ) )
{
if ( expandFile( pArchive, pTexture->strName, supportedExtensions, textureName, ext ) ) {
IOStream *pTextureStream = pArchive->Open( textureName.c_str() );
if ( NULL != pTextureStream )
{
if ( !pTextureStream ) {
size_t texSize = pTextureStream->FileSize();
aiTexture *pTexture = new aiTexture;
pTexture->mHeight = 0;
@ -685,9 +673,7 @@ bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *pMode
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
mTextures.push_back( pTexture );
}
else
{
} else {
// If it doesn't exist in the archive, it is probably just a reference to an external file.
// We'll leave it up to the user to figure out which extension the file has.
aiString name;

View File

@ -52,9 +52,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "quaternion.h"
#include <algorithm>
#include <cmath>
#include <limits>
#ifdef __cplusplus
# include <cmath>
#else
# include <math.h>
#endif
// ----------------------------------------------------------------------------------------
template <typename TReal>
aiMatrix4x4t<TReal> ::aiMatrix4x4t () :

View File

@ -143,8 +143,8 @@ struct aiMetadata
/** Destructor */
~aiMetadata()
{
if (mKeys)
delete [] mKeys;
delete[] mKeys;
mKeys = NULL;
if (mValues)
{
// Delete each metadata entry
@ -179,8 +179,8 @@ struct aiMetadata
// Delete the metadata array
delete [] mValues;
mValues = NULL;
}
}
@ -208,8 +208,9 @@ struct aiMetadata
// Return false if the output data type does
// not match the found value's data type
if (GetAiType(value) != mValues[index].mType)
if ( GetAiType( value ) != mValues[ index ].mType ) {
return false;
}
// Otherwise, output the found value and
// return true
@ -228,10 +229,12 @@ struct aiMetadata
}
template<typename T>
inline bool Get( const std::string& key, T& value )
{ return Get(aiString(key), value); }
inline bool Get( const std::string& key, T& value ) {
return Get(aiString(key), value);
}
#endif // __cplusplus
};
#endif // __AI_METADATA_H_INC__

View File

@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_TYPES_H_INC
// Some runtime headers
#include <cstring>
#include <sys/types.h>
#include <memory.h>
#include <math.h>

View File

@ -44,6 +44,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_VECTOR2D_H_INC
#define AI_VECTOR2D_H_INC
#ifdef __cplusplus
# include <cmath>
#else
# include <math.h>
#endif
#include "./Compiler/pushpack1.h"
// ----------------------------------------------------------------------------------

View File

@ -44,6 +44,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_VECTOR3D_H_INC
#define AI_VECTOR3D_H_INC
#ifdef __cplusplus
# include <cmath>
#else
# include <math.h>
#endif
#include "./Compiler/pushpack1.h"
#ifdef __cplusplus

View File

@ -92,7 +92,7 @@ AI_FORCE_INLINE TReal aiVector3t<TReal>::SquareLength() const {
// ------------------------------------------------------------------------------------------------
template <typename TReal>
AI_FORCE_INLINE TReal aiVector3t<TReal>::Length() const {
return sqrt( SquareLength());
return ::sqrt( SquareLength());
}
// ------------------------------------------------------------------------------------------------
template <typename TReal>
@ -217,6 +217,7 @@ AI_FORCE_INLINE aiVector3t<TReal> operator - ( const aiVector3t<TReal>& v) {
return aiVector3t<TReal>( -v.x, -v.y, -v.z);
}
// ------------------------------------------------------------------------------------------------
#endif // __cplusplus
#endif // AI_VECTOR3D_INL_INC

View File

@ -2,9 +2,9 @@ INCLUDE(CMakeForceCompiler)
SET (CMAKE_CROSSCOMPILING TRUE)
SET (CMAKE_SYSTEM_NAME "Darwin")
SET (CMAKE_SYSTEM_PROCESSOR "arm64”)
SET (CMAKE_SYSTEM_PROCESSOR "arm64")
SET (SDKVER “7.1”)
SET (SDKVER "7.1")
SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk")
SET (CC "${DEVROOT}/usr/bin/llvm-gcc")

View File

@ -4,10 +4,10 @@ SET (CMAKE_CROSSCOMPILING TRUE)
SET (CMAKE_SYSTEM_NAME "Darwin")
SET (CMAKE_SYSTEM_PROCESSOR "armv6")
SET (SDKVER “7.1”)
SET (SDKVER "7.1")
SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk")
SET (CC "${DEVROOT}/usr/bin/clang”)
SET (CC "${DEVROOT}/usr/bin/clang")
SET (CXX "${DEVROOT}/usr/bin/clang++")
CMAKE_FORCE_C_COMPILER (${CC} LLVM)

View File

@ -2,12 +2,12 @@ INCLUDE(CMakeForceCompiler)
SET (CMAKE_CROSSCOMPILING TRUE)
SET (CMAKE_SYSTEM_NAME "Darwin")
SET (CMAKE_SYSTEM_PROCESSOR "armv7s”)
SET (CMAKE_SYSTEM_PROCESSOR "armv7s")
SET (SDKVER “7.1”)
SET (SDKVER "7.1")
SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk")
SET (CC "${DEVROOT}/usr/bin/clang”)
SET (CC "${DEVROOT}/usr/bin/clang")
SET (CXX "${DEVROOT}/usr/bin/clang++")
CMAKE_FORCE_C_COMPILER (${CC} LLVM)

View File

@ -4,10 +4,10 @@ SET (CMAKE_CROSSCOMPILING TRUE)
SET (CMAKE_SYSTEM_NAME "Darwin")
SET (CMAKE_SYSTEM_PROCESSOR "armv7")
SET (SDKVER “7.1”)
SET (SDKVER "7.1")
SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${SDKVER}.sdk")
SET (CC "${DEVROOT}/usr/bin/clang”)
SET (CC "${DEVROOT}/usr/bin/clang")
SET (CXX "${DEVROOT}/usr/bin/clang++")
CMAKE_FORCE_C_COMPILER (${CC} LLVM)

View File

@ -2,13 +2,13 @@ INCLUDE(CMakeForceCompiler)
SET (CMAKE_CROSSCOMPILING TRUE)
SET (CMAKE_SYSTEM_NAME "Darwin")
SET (CMAKE_SYSTEM_PROCESSOR “i386”)
SET (CMAKE_SYSTEM_PROCESSOR "i386")
SET (SDKVER “7.1”)
SET (SDKVER "7.1")
SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVER}.sdk")
SET (CC "${DEVROOT}/usr/bin/clang”)
SET (CC "${DEVROOT}/usr/bin/clang")
SET (CXX "${DEVROOT}/usr/bin/clang++")
CMAKE_FORCE_C_COMPILER (${CC} LLVM)

View File

@ -2,13 +2,13 @@ INCLUDE(CMakeForceCompiler)
SET (CMAKE_CROSSCOMPILING TRUE)
SET (CMAKE_SYSTEM_NAME "Darwin")
SET (CMAKE_SYSTEM_PROCESSOR “x86_64”)
SET (CMAKE_SYSTEM_PROCESSOR "x86_64")
SET (SDKVER “7.1”)
SET (SDKVER "7.1")
SET (DEVROOT "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
SET (SDKROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${SDKVER}.sdk")
SET (CC "${DEVROOT}/usr/bin/clang”)
SET (CC "${DEVROOT}/usr/bin/clang")
SET (CXX "${DEVROOT}/usr/bin/clang++")
CMAKE_FORCE_C_COMPILER (${CC} LLVM)

View File

@ -1258,7 +1258,7 @@ void WriteDump(const aiScene* scene, FILE* out, const char* src, const char* cmd
mesh->mColors[a][n].a);
}
}
fprintf(out,"\t\t</Color>\n");
fprintf(out,"\t\t</Colors>\n");
}
fprintf(out,"\t</Mesh>\n");
}