Mostly formatting commit, small elaboration in extra handling API (take pointer to importer).

This commit is contained in:
Nathan Letwory
2011-03-25 09:52:36 +00:00
parent 5f5d091554
commit c5c4b31d6b
4 changed files with 867 additions and 889 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -53,7 +53,7 @@ struct bContext;
/** Importer class. */ /** Importer class. */
class DocumentImporter : COLLADAFW::IWriter class DocumentImporter : COLLADAFW::IWriter
{ {
public: public:
//! Enumeration to denote the stage of import //! Enumeration to denote the stage of import
enum ImportStage { enum ImportStage {
General, //!< First pass to collect all data except controller General, //!< First pass to collect all data except controller
@@ -78,8 +78,8 @@ class DocumentImporter : COLLADAFW::IWriter
void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*); void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*);
/** This method will be called if an error in the loading process occurred and the loader cannot /** This method will be called if an error in the loading process occurred and the loader cannot
continue to load. The writer should undo all operations that have been performed. continue to load. The writer should undo all operations that have been performed.
@param errorMessage A message containing informations about the error that occurred. @param errorMessage A message containing informations about the error that occurred.
*/ */
void cancel(const COLLADAFW::String& errorMessage); void cancel(const COLLADAFW::String& errorMessage);
@@ -88,7 +88,7 @@ class DocumentImporter : COLLADAFW::IWriter
/** This method is called after the last write* method. No other methods will be called after this.*/ /** This method is called after the last write* method. No other methods will be called after this.*/
void finish(); void finish();
bool writeGlobalAsset(const COLLADAFW::FileInfo*); bool writeGlobalAsset(const COLLADAFW::FileInfo*);
bool writeScene(const COLLADAFW::Scene*); bool writeScene(const COLLADAFW::Scene*);
@@ -121,31 +121,34 @@ class DocumentImporter : COLLADAFW::IWriter
bool writeKinematicsScene(const COLLADAFW::KinematicsScene*); bool writeKinematicsScene(const COLLADAFW::KinematicsScene*);
private: /** Add element and data for UniqueId */
bool addElementData(const COLLADAFW::UniqueId &uid);
private:
/** Current import stage we're in. */ /** Current import stage we're in. */
ImportStage mImportStage; ImportStage mImportStage;
std::string mFilename; std::string mFilename;
bContext *mContext; bContext *mContext;
UnitConverter unit_converter; UnitConverter unit_converter;
ArmatureImporter armature_importer; ArmatureImporter armature_importer;
MeshImporter mesh_importer; MeshImporter mesh_importer;
AnimationImporter anim_importer; AnimationImporter anim_importer;
std::map<COLLADAFW::UniqueId, Image*> uid_image_map; std::map<COLLADAFW::UniqueId, Image*> uid_image_map;
std::map<COLLADAFW::UniqueId, Material*> uid_material_map; std::map<COLLADAFW::UniqueId, Material*> uid_material_map;
std::map<COLLADAFW::UniqueId, Material*> uid_effect_map; std::map<COLLADAFW::UniqueId, Material*> uid_effect_map;
std::map<COLLADAFW::UniqueId, Camera*> uid_camera_map; std::map<COLLADAFW::UniqueId, Camera*> uid_camera_map;
std::map<COLLADAFW::UniqueId, Lamp*> uid_lamp_map; std::map<COLLADAFW::UniqueId, Lamp*> uid_lamp_map;
std::map<Material*, TexIndexTextureArrayMap> material_texture_mapping_map; std::map<Material*, TexIndexTextureArrayMap> material_texture_mapping_map;
std::map<COLLADAFW::UniqueId, Object*> object_map; std::map<COLLADAFW::UniqueId, Object*> object_map;
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map; std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map;
std::vector<const COLLADAFW::VisualScene*> vscenes; std::vector<const COLLADAFW::VisualScene*> vscenes;
std::vector<Object*> libnode_ob; std::vector<Object*> libnode_ob;
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling
}; };

View File

@@ -27,14 +27,16 @@
*/ */
#include <stddef.h> #include <stddef.h>
#include "BLI_string.h" #include "BLI_string.h"
#include "ExtraHandler.h" #include "ExtraHandler.h"
ExtraHandler::ExtraHandler(){} ExtraHandler::ExtraHandler(DocumentImporter *dimp)
{
this->dimp = dimp;
}
ExtraHandler::~ExtraHandler(){} ExtraHandler::~ExtraHandler() {}
bool ExtraHandler::elementBegin( const char* elementName, const char** attributes) bool ExtraHandler::elementBegin( const char* elementName, const char** attributes)
{ {
@@ -45,6 +47,7 @@ bool ExtraHandler::elementBegin( const char* elementName, const char** attribute
bool ExtraHandler::elementEnd(const char* elementName ) bool ExtraHandler::elementEnd(const char* elementName )
{ {
printf("end: %s\n", elementName); printf("end: %s\n", elementName);
currentUid = COLLADAFW::UniqueId();
return true; return true;
} }
@@ -62,6 +65,7 @@ bool ExtraHandler::parseElement (
const COLLADAFW::UniqueId& uniqueId ) { const COLLADAFW::UniqueId& uniqueId ) {
if(BLI_strcaseeq(profileName, "blender")) { if(BLI_strcaseeq(profileName, "blender")) {
printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); printf("In parseElement for supported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());
currentUid = uniqueId;
return true; return true;
} }
printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str()); printf("In parseElement for unsupported profile %s for id %s\n", profileName, uniqueId.toAscii().c_str());

View File

@@ -33,6 +33,7 @@
#include "COLLADASaxFWLIExtraDataCallbackHandler.h" #include "COLLADASaxFWLIExtraDataCallbackHandler.h"
#include "DocumentImporter.h"
/** \brief Handler class for <extra> data, through which different /** \brief Handler class for <extra> data, through which different
* profiles can be handled * profiles can be handled
@@ -41,7 +42,7 @@ class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler
{ {
public: public:
/** Constructor. */ /** Constructor. */
ExtraHandler(); ExtraHandler(DocumentImporter *dimp);
/** Destructor. */ /** Destructor. */
virtual ~ExtraHandler(); virtual ~ExtraHandler();
@@ -65,5 +66,10 @@ private:
ExtraHandler( const ExtraHandler& pre ); ExtraHandler( const ExtraHandler& pre );
/** Disable default assignment operator. */ /** Disable default assignment operator. */
const ExtraHandler& operator= ( const ExtraHandler& pre ); const ExtraHandler& operator= ( const ExtraHandler& pre );
/** Handle to DocumentImporter for interface to extra element data saving. */
DocumentImporter* dimp;
/** Holds Id of element for which <extra> XML elements are handled. */
COLLADAFW::UniqueId currentUid;
}; };