Merge branch 'master' into issue_2390
commit
fa37018e08
|
@ -555,8 +555,6 @@ void WriteDump(const aiScene* scene, IOStream* io, bool shortened) {
|
|||
mesh->mNormals[n].z);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
ioprintf(io,"\t\t</Normals>\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -416,7 +416,7 @@ template <> struct Structure :: _defaultInitializer<ErrorPolicy_Fail> {
|
|||
void operator ()(T& /*out*/,const char* = "") {
|
||||
// obviously, it is crucial that _DefaultInitializer is used
|
||||
// only from within a catch clause.
|
||||
throw;
|
||||
throw DeadlyImportError("Constructing BlenderDNA Structure encountered an error");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ void COBImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
|||
// check header
|
||||
char head[32];
|
||||
stream->CopyAndAdvance(head,32);
|
||||
if (strncmp(head,"Caligari ",9)) {
|
||||
if (strncmp(head,"Caligari ",9) != 0) {
|
||||
ThrowException("Could not found magic id: `Caligari`");
|
||||
}
|
||||
|
||||
|
@ -656,14 +656,14 @@ void COBImporter::ReadLght_Ascii(Scene& out, LineSplitter& splitter, const Chunk
|
|||
ReadFloat3Tuple_Ascii(msh.color ,&rgb);
|
||||
|
||||
SkipSpaces(&rgb);
|
||||
if (strncmp(rgb,"cone angle",10)) {
|
||||
if (strncmp(rgb,"cone angle",10) != 0) {
|
||||
ASSIMP_LOG_WARN_F( "Expected `cone angle` entity in `color` line in `Lght` chunk ", nfo.id );
|
||||
}
|
||||
SkipSpaces(rgb+10,&rgb);
|
||||
msh.angle = fast_atof(&rgb);
|
||||
|
||||
SkipSpaces(&rgb);
|
||||
if (strncmp(rgb,"inner angle",11)) {
|
||||
if (strncmp(rgb,"inner angle",11) != 0) {
|
||||
ASSIMP_LOG_WARN_F( "Expected `inner angle` entity in `color` line in `Lght` chunk ", nfo.id);
|
||||
}
|
||||
SkipSpaces(rgb+11,&rgb);
|
||||
|
@ -903,7 +903,7 @@ public:
|
|||
if(nfo.size != static_cast<unsigned int>(-1)) {
|
||||
try {
|
||||
reader.IncPtr( static_cast< int >( nfo.size ) - reader.GetCurrentPos() + cur );
|
||||
} catch ( DeadlyImportError e ) {
|
||||
} catch (const DeadlyImportError& e ) {
|
||||
// out of limit so correct the value
|
||||
reader.IncPtr( reader.GetReadLimit() );
|
||||
}
|
||||
|
@ -1214,7 +1214,7 @@ void COBImporter::ReadGrou_Binary(COB::Scene& out, StreamReaderLE& reader, const
|
|||
|
||||
const chunk_guard cn(nfo,reader);
|
||||
|
||||
out.nodes.push_back(std::shared_ptr<Group>(new Group()));
|
||||
out.nodes.push_back(std::make_shared<Group>());
|
||||
Group& msh = (Group&)(*out.nodes.back().get());
|
||||
msh = nfo;
|
||||
|
||||
|
|
|
@ -476,8 +476,11 @@ D3MFOpcPackage::D3MFOpcPackage(IOSystem* pIOHandler, const std::string& rFile)
|
|||
mZipArchive->Close( fileStream );
|
||||
|
||||
} else if( file == D3MF::XmlTag::CONTENT_TYPES_ARCHIVE) {
|
||||
|
||||
ASSIMP_LOG_WARN_F("Ignored file of unsupported type CONTENT_TYPES_ARCHIVES",file);
|
||||
} else {
|
||||
ASSIMP_LOG_WARN_F("Ignored file of unknown type: ",file);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1717,22 +1717,22 @@ namespace Assimp {
|
|||
if (!mesh)
|
||||
{
|
||||
for (const MeshMap::value_type& v : meshes_converted) {
|
||||
const MeshGeometry* const mesh = dynamic_cast<const MeshGeometry*> (v.first);
|
||||
if (!mesh) {
|
||||
const MeshGeometry* const meshGeom = dynamic_cast<const MeshGeometry*> (v.first);
|
||||
if (!meshGeom) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const MatIndexArray& mats = mesh->GetMaterialIndices();
|
||||
const MatIndexArray& mats = meshGeom->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()) {
|
||||
if (meshGeom->GetTextureCoords(i).empty()) {
|
||||
break;
|
||||
}
|
||||
const std::string& name = mesh->GetTextureCoordChannelName(i);
|
||||
const std::string& name = meshGeom->GetTextureCoordChannelName(i);
|
||||
if (name == uvSet) {
|
||||
index = static_cast<int>(i);
|
||||
break;
|
||||
|
@ -1840,22 +1840,22 @@ namespace Assimp {
|
|||
if (!mesh)
|
||||
{
|
||||
for (const MeshMap::value_type& v : meshes_converted) {
|
||||
const MeshGeometry* const mesh = dynamic_cast<const MeshGeometry*> (v.first);
|
||||
if (!mesh) {
|
||||
const MeshGeometry* const meshGeom = dynamic_cast<const MeshGeometry*> (v.first);
|
||||
if (!meshGeom) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const MatIndexArray& mats = mesh->GetMaterialIndices();
|
||||
const MatIndexArray& mats = meshGeom->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()) {
|
||||
if (meshGeom->GetTextureCoords(i).empty()) {
|
||||
break;
|
||||
}
|
||||
const std::string& name = mesh->GetTextureCoordChannelName(i);
|
||||
const std::string& name = meshGeom->GetTextureCoordChannelName(i);
|
||||
if (name == uvSet) {
|
||||
index = static_cast<int>(i);
|
||||
break;
|
||||
|
@ -2196,22 +2196,22 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
|
|||
if (!mesh)
|
||||
{
|
||||
for (const MeshMap::value_type& v : meshes_converted) {
|
||||
const MeshGeometry* const mesh = dynamic_cast<const MeshGeometry*>(v.first);
|
||||
if (!mesh) {
|
||||
const MeshGeometry* const meshGeom = dynamic_cast<const MeshGeometry*>(v.first);
|
||||
if (!meshGeom) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const MatIndexArray& mats = mesh->GetMaterialIndices();
|
||||
const MatIndexArray& mats = meshGeom->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()) {
|
||||
if (meshGeom->GetTextureCoords(i).empty()) {
|
||||
break;
|
||||
}
|
||||
const std::string& name = mesh->GetTextureCoordChannelName(i);
|
||||
const std::string& name = meshGeom->GetTextureCoordChannelName(i);
|
||||
if (name == uvSet) {
|
||||
index = static_cast<int>(i);
|
||||
break;
|
||||
|
|
|
@ -432,7 +432,7 @@ void FBX::Node::WritePropertyNodeAscii(
|
|||
char buffer[32];
|
||||
FBX::Node node(name);
|
||||
node.Begin(s, false, indent);
|
||||
std::string vsize = std::to_string(v.size());
|
||||
std::string vsize = to_string(v.size());
|
||||
// *<size> {
|
||||
s.PutChar('*'); s.PutString(vsize); s.PutString(" {\n");
|
||||
// indent + 1
|
||||
|
@ -468,7 +468,7 @@ void FBX::Node::WritePropertyNodeAscii(
|
|||
char buffer[32];
|
||||
FBX::Node node(name);
|
||||
node.Begin(s, false, indent);
|
||||
std::string vsize = std::to_string(v.size());
|
||||
std::string vsize = to_string(v.size());
|
||||
// *<size> {
|
||||
s.PutChar('*'); s.PutString(vsize); s.PutString(" {\n");
|
||||
// indent + 1
|
||||
|
|
|
@ -326,8 +326,11 @@ Video::Video(uint64_t id, const Element& element, const Document& doc, const std
|
|||
content = new uint8_t[len];
|
||||
::memcpy(content, data + 5, len);
|
||||
}
|
||||
} catch (runtime_error runtimeError) {
|
||||
} catch (const runtime_error& runtimeError)
|
||||
{
|
||||
//we don't need the content data for contents that has already been loaded
|
||||
ASSIMP_LOG_DEBUG_F("Caught exception in FBXMaterial (likely because content was already loaded): ",
|
||||
runtimeError.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -304,9 +304,6 @@ inline void FindSuitableMultiple(int& angle)
|
|||
else if (angle < 10) angle = 10;
|
||||
else if (angle < 20) angle = 20;
|
||||
else if (angle < 30) angle = 30;
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -317,6 +314,8 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector<aiNode
|
|||
// XXX totally WIP - doesn't produce proper results, need to evaluate
|
||||
// whether there's any use for Irrlicht's proprietary scene format
|
||||
// outside Irrlicht ...
|
||||
// This also applies to the above function of FindSuitableMultiple and ClampSpline which are
|
||||
// solely used in this function
|
||||
|
||||
if (root->animators.empty()) {
|
||||
return;
|
||||
|
@ -674,38 +673,38 @@ void IRRImporter::GenerateGraph(Node* root,aiNode* rootOut ,aiScene* scene,
|
|||
// Get the loaded mesh from the scene and add it to
|
||||
// the list of all scenes to be attached to the
|
||||
// graph we're currently building
|
||||
aiScene* scene = batch.GetImport(root->id);
|
||||
if (!scene) {
|
||||
aiScene* localScene = batch.GetImport(root->id);
|
||||
if (!localScene) {
|
||||
ASSIMP_LOG_ERROR("IRR: Unable to load external file: " + root->meshPath);
|
||||
break;
|
||||
}
|
||||
attach.push_back(AttachmentInfo(scene,rootOut));
|
||||
attach.push_back(AttachmentInfo(localScene,rootOut));
|
||||
|
||||
// Now combine the material we've loaded for this mesh
|
||||
// with the real materials we got from the file. As we
|
||||
// don't execute any pp-steps on the file, the numbers
|
||||
// should be equal. If they are not, we can impossibly
|
||||
// do this ...
|
||||
if (root->materials.size() != (unsigned int)scene->mNumMaterials) {
|
||||
if (root->materials.size() != (unsigned int)localScene->mNumMaterials) {
|
||||
ASSIMP_LOG_WARN("IRR: Failed to match imported materials "
|
||||
"with the materials found in the IRR scene file");
|
||||
|
||||
break;
|
||||
}
|
||||
for (unsigned int i = 0; i < scene->mNumMaterials;++i) {
|
||||
for (unsigned int i = 0; i < localScene->mNumMaterials;++i) {
|
||||
// Delete the old material, we don't need it anymore
|
||||
delete scene->mMaterials[i];
|
||||
delete localScene->mMaterials[i];
|
||||
|
||||
std::pair<aiMaterial*, unsigned int>& src = root->materials[i];
|
||||
scene->mMaterials[i] = src.first;
|
||||
localScene->mMaterials[i] = src.first;
|
||||
}
|
||||
|
||||
// NOTE: Each mesh should have exactly one material assigned,
|
||||
// but we do it in a separate loop if this behaviour changes
|
||||
// in future.
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes;++i) {
|
||||
for (unsigned int i = 0; i < localScene->mNumMeshes;++i) {
|
||||
// Process material flags
|
||||
aiMesh* mesh = scene->mMeshes[i];
|
||||
aiMesh* mesh = localScene->mMeshes[i];
|
||||
|
||||
|
||||
// If "trans_vertex_alpha" mode is enabled, search all vertex colors
|
||||
|
|
|
@ -278,10 +278,10 @@ void STEP::ReadFile(DB& db,const EXPRESS::ConversionSchema& scheme,
|
|||
std::transform( type.begin(), type.end(), type.begin(), &Assimp::ToLower<char> );
|
||||
const char* sz = scheme.GetStaticStringForToken(type);
|
||||
if(sz) {
|
||||
const std::string::size_type len = n2-n1+1;
|
||||
char* const copysz = new char[len+1];
|
||||
const std::string::size_type szLen = n2-n1+1;
|
||||
char* const copysz = new char[szLen+1];
|
||||
std::copy(s.c_str()+n1,s.c_str()+n2+1,copysz);
|
||||
copysz[len] = '\0';
|
||||
copysz[szLen] = '\0';
|
||||
db.InternInsert(new LazyObject(db,id,line,sz,copysz));
|
||||
}
|
||||
if(!has_next) {
|
||||
|
|
|
@ -443,10 +443,10 @@ void MD5Importer::LoadMD5MeshFile ()
|
|||
for (MD5::VertexList::const_iterator iter = meshSrc.mVertices.begin();iter != meshSrc.mVertices.end();++iter,++pv) {
|
||||
for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights;++w)
|
||||
{
|
||||
MD5::WeightDesc& desc = meshSrc.mWeights[w];
|
||||
MD5::WeightDesc& weightDesc = meshSrc.mWeights[w];
|
||||
/* FIX for some invalid exporters */
|
||||
if (!(desc.mWeight < AI_MD5_WEIGHT_EPSILON && desc.mWeight >= -AI_MD5_WEIGHT_EPSILON ))
|
||||
++piCount[desc.mBone];
|
||||
if (!(weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON ))
|
||||
++piCount[weightDesc.mBone];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -493,20 +493,20 @@ void MD5Importer::LoadMD5MeshFile ()
|
|||
if (w >= meshSrc.mWeights.size())
|
||||
throw DeadlyImportError("MD5MESH: Invalid weight index");
|
||||
|
||||
MD5::WeightDesc& desc = meshSrc.mWeights[w];
|
||||
if ( desc.mWeight < AI_MD5_WEIGHT_EPSILON && desc.mWeight >= -AI_MD5_WEIGHT_EPSILON) {
|
||||
MD5::WeightDesc& weightDesc = meshSrc.mWeights[w];
|
||||
if ( weightDesc.mWeight < AI_MD5_WEIGHT_EPSILON && weightDesc.mWeight >= -AI_MD5_WEIGHT_EPSILON) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const ai_real fNewWeight = desc.mWeight / fSum;
|
||||
const ai_real fNewWeight = weightDesc.mWeight / fSum;
|
||||
|
||||
// transform the local position into worldspace
|
||||
MD5::BoneDesc& boneSrc = meshParser.mJoints[desc.mBone];
|
||||
const aiVector3D v = boneSrc.mRotationQuatConverted.Rotate (desc.vOffsetPosition);
|
||||
MD5::BoneDesc& boneSrc = meshParser.mJoints[weightDesc.mBone];
|
||||
const aiVector3D v = boneSrc.mRotationQuatConverted.Rotate (weightDesc.vOffsetPosition);
|
||||
|
||||
// use the original weight to compute the vertex position
|
||||
// (some MD5s seem to depend on the invalid weight values ...)
|
||||
*pv += ((boneSrc.mPositionXYZ+v)* (ai_real)desc.mWeight);
|
||||
*pv += ((boneSrc.mPositionXYZ+v)* (ai_real)weightDesc.mWeight);
|
||||
|
||||
aiBone* bone = mesh->mBones[boneSrc.mMap];
|
||||
*bone->mWeights++ = aiVertexWeight((unsigned int)(pv-mesh->mVertices),fNewWeight);
|
||||
|
|
|
@ -127,7 +127,7 @@ STLExporter::STLExporter(const char* _filename, const aiScene* pScene, bool expo
|
|||
mOutput.write((char *)&meshnum, 4);
|
||||
|
||||
if (exportPointClouds) {
|
||||
|
||||
throw DeadlyExportError("This functionality is not yet implemented for binary output.");
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
||||
|
|
|
@ -294,17 +294,17 @@ namespace glTF {
|
|||
// filling object "compressedData"
|
||||
json_comp_data.SetObject();
|
||||
json_comp_data.AddMember("buffer", ptr_ext_comp->Buffer, w.mAl);
|
||||
json_comp_data.AddMember("byteOffset", ptr_ext_comp->Offset, w.mAl);
|
||||
json_comp_data.AddMember("byteOffset", static_cast<uint64_t>(ptr_ext_comp->Offset), w.mAl);
|
||||
json_comp_data.AddMember("componentType", 5121, w.mAl);
|
||||
json_comp_data.AddMember("type", "SCALAR", w.mAl);
|
||||
json_comp_data.AddMember("count", ptr_ext_comp->Count, w.mAl);
|
||||
json_comp_data.AddMember("count", static_cast<uint64_t>(ptr_ext_comp->Count), w.mAl);
|
||||
if(ptr_ext_comp->Binary)
|
||||
json_comp_data.AddMember("mode", "binary", w.mAl);
|
||||
else
|
||||
json_comp_data.AddMember("mode", "ascii", w.mAl);
|
||||
|
||||
json_comp_data.AddMember("indicesCount", ptr_ext_comp->IndicesCount, w.mAl);
|
||||
json_comp_data.AddMember("verticesCount", ptr_ext_comp->VerticesCount, w.mAl);
|
||||
json_comp_data.AddMember("indicesCount", static_cast<uint64_t>(ptr_ext_comp->IndicesCount), w.mAl);
|
||||
json_comp_data.AddMember("verticesCount", static_cast<uint64_t>(ptr_ext_comp->VerticesCount), w.mAl);
|
||||
// filling object "Open3DGC-compression"
|
||||
Value json_o3dgc;
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& bu
|
|||
|
||||
namespace {
|
||||
void GetMatScalar(const aiMaterial* mat, float& val, const char* propName, int type, int idx) {
|
||||
if (mat->Get(propName, type, idx, val) == AI_SUCCESS) {}
|
||||
ai_assert(mat->Get(propName, type, idx, val) == AI_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,20 +6,18 @@ This is the main-module of PyAssimp.
|
|||
|
||||
import sys
|
||||
if sys.version_info < (2,6):
|
||||
raise 'pyassimp: need python 2.6 or newer'
|
||||
raise RuntimeError('pyassimp: need python 2.6 or newer')
|
||||
|
||||
# xrange was renamed range in Python 3 and the original range from Python 2 was removed.
|
||||
# To keep compatibility with both Python 2 and 3, xrange is set to range for version 3.0 and up.
|
||||
if sys.version_info >= (3,0):
|
||||
xrange = range
|
||||
|
||||
import ctypes
|
||||
import os
|
||||
|
||||
try: import numpy
|
||||
except: numpy = None
|
||||
|
||||
except ImportError: numpy = None
|
||||
import logging
|
||||
import ctypes
|
||||
logger = logging.getLogger("pyassimp")
|
||||
# attach default null handler to logger so it doesn't complain
|
||||
# even if you don't attach another handler to logger
|
||||
|
@ -67,10 +65,10 @@ def make_tuple(ai_obj, type = None):
|
|||
|
||||
# Returns unicode object for Python 2, and str object for Python 3.
|
||||
def _convert_assimp_string(assimp_string):
|
||||
try:
|
||||
return unicode(assimp_string.data, errors='ignore')
|
||||
except:
|
||||
if sys.version_info >= (3, 0):
|
||||
return str(assimp_string.data, errors='ignore')
|
||||
else:
|
||||
return unicode(assimp_string.data, errors='ignore')
|
||||
|
||||
# It is faster and more correct to have an init function for each assimp class
|
||||
def _init_face(aiFace):
|
||||
|
@ -305,7 +303,7 @@ def load(filename,
|
|||
# unsigned int pLength,
|
||||
# unsigned int pFlags,
|
||||
# const char* pHint)
|
||||
if file_type == None:
|
||||
if file_type is None:
|
||||
raise AssimpError('File type must be specified when passing file objects!')
|
||||
data = filename.read()
|
||||
model = _assimp_lib.load_mem(data,
|
||||
|
@ -343,8 +341,7 @@ def export(scene,
|
|||
|
||||
'''
|
||||
|
||||
from ctypes import pointer
|
||||
exportStatus = _assimp_lib.export(pointer(scene), file_type.encode("ascii"), filename.encode(sys.getfilesystemencoding()), processing)
|
||||
exportStatus = _assimp_lib.export(ctypes.pointer(scene), file_type.encode("ascii"), filename.encode(sys.getfilesystemencoding()), processing)
|
||||
|
||||
if exportStatus != 0:
|
||||
raise AssimpError('Could not export scene!')
|
||||
|
@ -369,16 +366,14 @@ def export_blob(scene,
|
|||
---------
|
||||
Pointer to structs.ExportDataBlob
|
||||
'''
|
||||
from ctypes import pointer
|
||||
exportBlobPtr = _assimp_lib.export_blob(pointer(scene), file_type.encode("ascii"), processing)
|
||||
exportBlobPtr = _assimp_lib.export_blob(ctypes.pointer(scene), file_type.encode("ascii"), processing)
|
||||
|
||||
if exportBlobPtr == 0:
|
||||
raise AssimpError('Could not export scene to blob!')
|
||||
return exportBlobPtr
|
||||
|
||||
def release(scene):
|
||||
from ctypes import pointer
|
||||
_assimp_lib.release(pointer(scene))
|
||||
_assimp_lib.release(ctypes.pointer(scene))
|
||||
|
||||
def _finalize_texture(tex, target):
|
||||
setattr(target, "achformathint", tex.achFormatHint)
|
||||
|
@ -442,24 +437,22 @@ def _finalize_mesh(mesh, target):
|
|||
setattr(target, 'faces', faces)
|
||||
|
||||
def _init_metadata_entry(entry):
|
||||
from ctypes import POINTER, c_bool, c_int32, c_uint64, c_float, c_double, cast
|
||||
|
||||
entry.type = entry.mType
|
||||
if entry.type == structs.MetadataEntry.AI_BOOL:
|
||||
entry.data = cast(entry.mData, POINTER(c_bool)).contents.value
|
||||
entry.data = ctypes.cast(entry.mData, ctypes.POINTER(ctypes.c_bool)).contents.value
|
||||
elif entry.type == structs.MetadataEntry.AI_INT32:
|
||||
entry.data = cast(entry.mData, POINTER(c_int32)).contents.value
|
||||
entry.data = ctypes.cast(entry.mData, ctypes.POINTER(ctypes.c_int32)).contents.value
|
||||
elif entry.type == structs.MetadataEntry.AI_UINT64:
|
||||
entry.data = cast(entry.mData, POINTER(c_uint64)).contents.value
|
||||
entry.data = ctypes.cast(entry.mData, ctypes.POINTER(ctypes.c_uint64)).contents.value
|
||||
elif entry.type == structs.MetadataEntry.AI_FLOAT:
|
||||
entry.data = cast(entry.mData, POINTER(c_float)).contents.value
|
||||
entry.data = ctypes.cast(entry.mData, ctypes.POINTER(ctypes.c_float)).contents.value
|
||||
elif entry.type == structs.MetadataEntry.AI_DOUBLE:
|
||||
entry.data = cast(entry.mData, POINTER(c_double)).contents.value
|
||||
entry.data = ctypes.cast(entry.mData, ctypes.POINTER(ctypes.c_double)).contents.value
|
||||
elif entry.type == structs.MetadataEntry.AI_AISTRING:
|
||||
assimp_string = cast(entry.mData, POINTER(structs.String)).contents
|
||||
assimp_string = ctypes.cast(entry.mData, ctypes.POINTER(structs.String)).contents
|
||||
entry.data = _convert_assimp_string(assimp_string)
|
||||
elif entry.type == structs.MetadataEntry.AI_AIVECTOR3D:
|
||||
assimp_vector = cast(entry.mData, POINTER(structs.Vector3D)).contents
|
||||
assimp_vector = ctypes.cast(entry.mData, ctypes.POINTER(structs.Vector3D)).contents
|
||||
entry.data = make_tuple(assimp_vector)
|
||||
|
||||
return entry
|
||||
|
@ -513,15 +506,18 @@ def _get_properties(properties, length):
|
|||
key = (key.split('.')[1], p.mSemantic)
|
||||
|
||||
#the data
|
||||
from ctypes import POINTER, cast, c_int, c_float, sizeof
|
||||
if p.mType == 1:
|
||||
arr = cast(p.mData, POINTER(c_float * int(p.mDataLength/sizeof(c_float)) )).contents
|
||||
arr = ctypes.cast(p.mData,
|
||||
ctypes.POINTER(ctypes.c_float * int(p.mDataLength/ctypes.sizeof(ctypes.c_float)))
|
||||
).contents
|
||||
value = [x for x in arr]
|
||||
elif p.mType == 3: #string can't be an array
|
||||
value = _convert_assimp_string(cast(p.mData, POINTER(structs.MaterialPropertyString)).contents)
|
||||
value = _convert_assimp_string(ctypes.cast(p.mData, ctypes.POINTER(structs.MaterialPropertyString)).contents)
|
||||
|
||||
elif p.mType == 4:
|
||||
arr = cast(p.mData, POINTER(c_int * int(p.mDataLength/sizeof(c_int)) )).contents
|
||||
arr = ctypes.cast(p.mData,
|
||||
ctypes.POINTER(ctypes.c_int * int(p.mDataLength/ctypes.sizeof(ctypes.c_int)))
|
||||
).contents
|
||||
value = [x for x in arr]
|
||||
else:
|
||||
value = p.mData[:p.mDataLength]
|
||||
|
@ -541,7 +537,9 @@ def decompose_matrix(matrix):
|
|||
rotation = structs.Quaternion()
|
||||
position = structs.Vector3D()
|
||||
|
||||
from ctypes import byref, pointer
|
||||
_assimp_lib.dll.aiDecomposeMatrix(pointer(matrix), byref(scaling), byref(rotation), byref(position))
|
||||
_assimp_lib.dll.aiDecomposeMatrix(ctypes.pointer(matrix),
|
||||
ctypes.byref(scaling),
|
||||
ctypes.byref(rotation),
|
||||
ctypes.byref(position))
|
||||
return scaling._init(), rotation._init(), position._init()
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ FORMATS = ["CSM",
|
|||
"STL",
|
||||
"IRR",
|
||||
"Q3O",
|
||||
"Q3D"
|
||||
"Q3D",
|
||||
"MS3D",
|
||||
"Q3S",
|
||||
"ZGL",
|
||||
|
|
|
@ -6,7 +6,6 @@ Some fancy helper functions.
|
|||
|
||||
import os
|
||||
import ctypes
|
||||
from ctypes import POINTER
|
||||
import operator
|
||||
|
||||
from distutils.sysconfig import get_python_lib
|
||||
|
@ -14,7 +13,7 @@ import re
|
|||
import sys
|
||||
|
||||
try: import numpy
|
||||
except: numpy = None
|
||||
except ImportError: numpy = None
|
||||
|
||||
import logging;logger = logging.getLogger("pyassimp")
|
||||
|
||||
|
@ -193,9 +192,9 @@ def try_load_functions(library_path, dll):
|
|||
|
||||
# library found!
|
||||
from .structs import Scene, ExportDataBlob
|
||||
load.restype = POINTER(Scene)
|
||||
load_mem.restype = POINTER(Scene)
|
||||
export2blob.restype = POINTER(ExportDataBlob)
|
||||
load.restype = ctype.POINTER(Scene)
|
||||
load_mem.restype = ctype.POINTER(Scene)
|
||||
export2blob.restype = ctype.POINTER(ExportDataBlob)
|
||||
return (library_path, load, load_mem, export, export2blob, release, dll)
|
||||
|
||||
def search_library():
|
||||
|
@ -276,5 +275,5 @@ def hasattr_silent(object, name):
|
|||
|
||||
try:
|
||||
return hasattr(object, name)
|
||||
except:
|
||||
except AttributeError:
|
||||
return False
|
||||
|
|
|
@ -435,6 +435,7 @@ aiProcess_Debone = 0x4000000
|
|||
aiProcess_GenEntityMeshes = 0x100000
|
||||
aiProcess_OptimizeAnimations = 0x200000
|
||||
aiProcess_FixTexturePaths = 0x200000
|
||||
aiProcess_EmbedTextures = 0x10000000,
|
||||
|
||||
## @def aiProcess_ConvertToLeftHanded
|
||||
# @brief Shortcut flag for Direct3D-based applications.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#-*- coding: UTF-8 -*-
|
||||
|
||||
from ctypes import POINTER, c_void_p, c_int, c_uint, c_char, c_float, Structure, c_char_p, c_double, c_ubyte, c_size_t, c_uint32
|
||||
from ctypes import POINTER, c_void_p, c_uint, c_char, c_float, Structure, c_char_p, c_double, c_ubyte, c_size_t, c_uint32
|
||||
|
||||
|
||||
class Vector2D(Structure):
|
||||
|
|
|
@ -24,12 +24,13 @@ This sample is based on several sources, including:
|
|||
- ASSIMP's C++ SimpleOpenGL viewer
|
||||
"""
|
||||
|
||||
import os, sys
|
||||
import sys
|
||||
from OpenGL.GLUT import *
|
||||
from OpenGL.GLU import *
|
||||
from OpenGL.GL import *
|
||||
|
||||
import logging;logger = logging.getLogger("pyassimp_opengl")
|
||||
import logging
|
||||
logger = logging.getLogger("pyassimp_opengl")
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
import math
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
This module demonstrates the functionality of PyAssimp.
|
||||
"""
|
||||
|
||||
import os, sys
|
||||
import sys
|
||||
import logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
@ -50,8 +50,8 @@ def main(filename=None):
|
|||
print(" colors:" + str(len(mesh.colors)))
|
||||
tcs = mesh.texturecoords
|
||||
if tcs.any():
|
||||
for index, tc in enumerate(tcs):
|
||||
print(" texture-coords "+ str(index) + ":" + str(len(tcs[index])) + "first3:" + str(tcs[index][:3]))
|
||||
for tc_index, tc in enumerate(tcs):
|
||||
print(" texture-coords "+ str(tc_index) + ":" + str(len(tcs[tc_index])) + "first3:" + str(tcs[tc_index][:3]))
|
||||
|
||||
else:
|
||||
print(" no texture coordinates")
|
||||
|
|
|
@ -292,6 +292,8 @@ def main():
|
|||
|
||||
output.write(templt.replace("<HERE>",s))
|
||||
|
||||
# we got here, so no error
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
|
@ -151,11 +151,8 @@ def handle_unset_args(field,entity,schema,argnum):
|
|||
return n+template_allow_optional.format()
|
||||
|
||||
def get_single_conversion(field,schema,argnum=0,classname='?'):
|
||||
typen = field.type
|
||||
name = field.name
|
||||
if field.collection:
|
||||
typen = 'LIST'
|
||||
return template_convert_single.format(type=typen,name=name,argnum=argnum,classname=classname,full_type=field.fullspec)
|
||||
return template_convert_single.format(name=name,argnum=argnum,classname=classname,full_type=field.fullspec)
|
||||
|
||||
def count_args_up(entity,schema):
|
||||
return len(entity.members) + (count_args_up(schema.entities[entity.parent],schema) if entity.parent else 0)
|
||||
|
@ -218,7 +215,7 @@ def get_derived(e,schema):
|
|||
return res
|
||||
|
||||
def get_hierarchy(e,schema):
|
||||
return get_derived(e.schema)+[e.name]+get_base_classes(e,schema)
|
||||
return get_derived(e, schema)+[e.name]+get_base_classes(e,schema)
|
||||
|
||||
def sort_entity_list(schema):
|
||||
deps = []
|
||||
|
@ -300,5 +297,8 @@ def work(filename):
|
|||
with open(output_file_cpp,'wt') as outp:
|
||||
outp.write(inp.read().replace('{schema-static-table}',schema_table).replace('{converter-impl}',converters))
|
||||
|
||||
# Finished without error, so return 0
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(work(sys.argv[1] if len(sys.argv)>1 else 'schema.exp'))
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
"""Parse an EXPRESS file and extract basic information on all
|
||||
entities and data types contained"""
|
||||
|
||||
import sys, os, re
|
||||
import sys
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
|
||||
re_match_entity = re.compile(r"""
|
||||
|
|
|
@ -229,6 +229,7 @@ int DoExport(const aiTexture* tx, FILE* p, const std::string& extension,
|
|||
int Assimp_Extract (const char* const* params, unsigned int num)
|
||||
{
|
||||
const char* const invalid = "assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n";
|
||||
// assimp extract in out [options]
|
||||
if (num < 1) {
|
||||
printf(invalid);
|
||||
return 1;
|
||||
|
@ -240,11 +241,7 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// asssimp extract in out [options]
|
||||
if (num < 1) {
|
||||
printf(invalid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
std::string in = std::string(params[0]);
|
||||
std::string out = (num > 1 ? std::string(params[1]) : "-");
|
||||
|
|
Loading…
Reference in New Issue