Merge branch 'master' of git://github.com/assimp/assimp
commit
7fd44f4ab7
|
@ -599,7 +599,7 @@ void ColladaParser::ReadControllerWeights( Collada::Controller& pController)
|
|||
if( mReader->getNodeType() == irr::io::EXN_ELEMENT)
|
||||
{
|
||||
// Input channels for weight data. Two possible semantics: "JOINT" and "WEIGHT"
|
||||
if( IsElement( "input"))
|
||||
if( IsElement( "input") && vertexCount > 0 )
|
||||
{
|
||||
InputChannel channel;
|
||||
|
||||
|
@ -628,7 +628,7 @@ void ColladaParser::ReadControllerWeights( Collada::Controller& pController)
|
|||
if( !mReader->isEmptyElement())
|
||||
SkipElement();
|
||||
}
|
||||
else if( IsElement( "vcount"))
|
||||
else if( IsElement( "vcount") && vertexCount > 0 )
|
||||
{
|
||||
// read weight count per vertex
|
||||
const char* text = GetTextContent();
|
||||
|
@ -648,7 +648,7 @@ void ColladaParser::ReadControllerWeights( Collada::Controller& pController)
|
|||
// reserve weight count
|
||||
pController.mWeights.resize( numWeights);
|
||||
}
|
||||
else if( IsElement( "v"))
|
||||
else if( IsElement( "v") && vertexCount > 0 )
|
||||
{
|
||||
// read JointIndex - WeightIndex pairs
|
||||
const char* text = GetTextContent();
|
||||
|
@ -1656,6 +1656,7 @@ void ColladaParser::ReadDataArray()
|
|||
std::string id = mReader->getAttributeValue( indexID);
|
||||
int indexCount = GetAttribute( "count");
|
||||
unsigned int count = (unsigned int) mReader->getAttributeValueAsInt( indexCount);
|
||||
if (count == 0) { return; } // some exporters write empty data arrays with count="0"
|
||||
const char* content = TestTextContent();
|
||||
|
||||
// read values and store inside an array in the data library
|
||||
|
|
|
@ -159,6 +159,7 @@ struct Material
|
|||
aiString textureBump;
|
||||
aiString textureSpecularity;
|
||||
aiString textureOpacity;
|
||||
aiString textureDisp;
|
||||
|
||||
//! Ambient color
|
||||
aiColor3D ambient;
|
||||
|
|
|
@ -556,6 +556,9 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
|
|||
if ( 0 != pCurrentMaterial->textureBump.length )
|
||||
mat->AddProperty( &pCurrentMaterial->textureBump, AI_MATKEY_TEXTURE_HEIGHT(0));
|
||||
|
||||
if ( 0 != pCurrentMaterial->textureDisp.length )
|
||||
mat->AddProperty( &pCurrentMaterial->textureDisp, AI_MATKEY_TEXTURE_DISPLACEMENT(0) );
|
||||
|
||||
if ( 0 != pCurrentMaterial->textureOpacity.length )
|
||||
mat->AddProperty( &pCurrentMaterial->textureOpacity, AI_MATKEY_TEXTURE_OPACITY(0));
|
||||
|
||||
|
|
|
@ -279,6 +279,10 @@ void ObjFileMtlImporter::getTexture()
|
|||
else if (!ASSIMP_strincmp(&(*m_DataIt),"map_bump",8) || !ASSIMP_strincmp(&(*m_DataIt),"bump",4))
|
||||
out = & m_pModel->m_pCurrentMaterial->textureBump;
|
||||
|
||||
// Displacement texture
|
||||
else if (!ASSIMP_strincmp(&(*m_DataIt),"disp",4))
|
||||
out = &m_pModel->m_pCurrentMaterial->textureDisp;
|
||||
|
||||
// Specularity scaling (glossiness)
|
||||
else if (!ASSIMP_strincmp(&(*m_DataIt),"map_ns",6))
|
||||
out = & m_pModel->m_pCurrentMaterial->textureSpecularity;
|
||||
|
|
|
@ -69,12 +69,12 @@ bool aiQuaterniont<TReal>::operator!= (const aiQuaterniont& o) const
|
|||
template<typename TReal>
|
||||
inline aiQuaterniont<TReal>::aiQuaterniont( const aiMatrix3x3t<TReal> &pRotMatrix)
|
||||
{
|
||||
TReal t = 1 + pRotMatrix.a1 + pRotMatrix.b2 + pRotMatrix.c3;
|
||||
TReal t = pRotMatrix.a1 + pRotMatrix.b2 + pRotMatrix.c3;
|
||||
|
||||
// large enough
|
||||
if( t > static_cast<TReal>(0.001))
|
||||
if( t > static_cast<TReal>(0))
|
||||
{
|
||||
TReal s = sqrt( t) * static_cast<TReal>(2.0);
|
||||
TReal s = sqrt(1 + t) * static_cast<TReal>(2.0);
|
||||
x = (pRotMatrix.c2 - pRotMatrix.b3) / s;
|
||||
y = (pRotMatrix.a3 - pRotMatrix.c1) / s;
|
||||
z = (pRotMatrix.b1 - pRotMatrix.a2) / s;
|
||||
|
|
|
@ -293,11 +293,9 @@ def release(scene):
|
|||
|
||||
def _finalize_texture(tex, target):
|
||||
setattr(target, "achformathint", tex.achFormatHint)
|
||||
data = numpy.array([make_tuple(getattr(tex, pcData)[i]) for i in range(tex.mWidth * tex.mHeight)])
|
||||
data = numpy.array([make_tuple(getattr(tex, "pcData")[i]) for i in range(tex.mWidth * tex.mHeight)])
|
||||
setattr(target, "data", data)
|
||||
|
||||
|
||||
|
||||
def _finalize_mesh(mesh, target):
|
||||
""" Building of meshes is a bit specific.
|
||||
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
This module demonstrates the functionality of PyAssimp.
|
||||
"""
|
||||
|
||||
|
||||
import pyassimp
|
||||
import pyassimp.core as pyassimp
|
||||
import os, sys
|
||||
|
||||
#get a model out of assimp's test-data if none is provided on the command line
|
||||
|
@ -22,6 +21,8 @@ def recur_node(node,level = 0):
|
|||
|
||||
def main(filename=None):
|
||||
filename = filename or DEFAULT_MODEL
|
||||
|
||||
print "Reading model", filename
|
||||
scene = pyassimp.load(filename)
|
||||
|
||||
#the model we load
|
||||
|
@ -45,21 +46,23 @@ def main(filename=None):
|
|||
print " material id:", mesh.materialindex+1
|
||||
print " vertices:", len(mesh.vertices)
|
||||
print " first 3 verts:", mesh.vertices[:3]
|
||||
if mesh.normals:
|
||||
if len(mesh.normals) > 0:
|
||||
print " first 3 normals:", mesh.normals[:3]
|
||||
else:
|
||||
print " no normals"
|
||||
print " colors:", len(mesh.colors)
|
||||
tc = mesh.texturecoords
|
||||
if tc:
|
||||
if len(tc) >= 4:
|
||||
print " texture-coords 1:", len(tc[0]), "first3:", tc[0][:3]
|
||||
print " texture-coords 2:", len(tc[1]), "first3:", tc[1][:3]
|
||||
print " texture-coords 3:", len(tc[2]), "first3:", tc[2][:3]
|
||||
print " texture-coords 4:", len(tc[3]), "first3:", tc[3][:3]
|
||||
else:
|
||||
elif len(tc) == 0:
|
||||
print " no texture coordinates"
|
||||
else:
|
||||
print " tc is an unexpected number of elements (expect 4, got", len(tc), ")"
|
||||
print " uv-component-count:", len(mesh.numuvcomponents)
|
||||
print " faces:", len(mesh.faces), "first:", [f.indices for f in mesh.faces[:3]]
|
||||
print " faces:", len(mesh.faces), "first:", [f for f in mesh.faces[:3]]
|
||||
print " bones:", len(mesh.bones), "first:", [str(b) for b in mesh.bones[:3]]
|
||||
print
|
||||
|
||||
|
@ -81,5 +84,7 @@ def main(filename=None):
|
|||
# Finally release the model
|
||||
pyassimp.release(scene)
|
||||
|
||||
print "Finished parsing the model."
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1] if len(sys.argv)>1 else None)
|
||||
|
|
Loading…
Reference in New Issue