Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef DaeHelpers_INCLUDE_ONCE
00033 #define DaeHelpers_INCLUDE_ONCE
00034
00035 #include <vlGraphics/plugins/COLLADA/DaeHelpers.hpp>
00036 #include <vlGraphics/plugins/COLLADA/ioDae.hpp>
00037
00038 namespace vl
00039 {
00041 class DaeLoader
00042 {
00043 public:
00044 DaeLoader();
00045
00046 bool load(VirtualFile* file);
00047
00048 const ResourceDatabase* resources() const { return mResources.get(); }
00049
00050 ResourceDatabase* resources() { return mResources.get(); }
00051
00052
00053
00054 void setLoadOptions(const LoadWriterDae::LoadOptions* options) { mLoadOptions = options; }
00055
00056 const LoadWriterDae::LoadOptions* loadOptions() const { return mLoadOptions; }
00057
00058
00059 protected:
00060
00061 void reset();
00062
00063 void parseInputs(Dae::Primitive* dae_primitive, const domInputLocalOffset_Array& input_arr, const std::vector< ref<Dae::Input> >& vertex_inputs);
00064
00065 ref<Dae::Mesh> parseGeometry(daeElement* geometry);
00066
00067 Dae::Source* getSource(daeElement* source_el);
00068
00069 void bindMaterials(Dae::Node* dae_node, Dae::Mesh* dae_mesh, domBind_materialRef bind_material);
00070
00071 void parseNode(daeElement* el, Dae::Node* parent);
00072
00073 void parseAsset(domElement* root);
00074
00075 void loadImages(const domImage_Array& images);
00076
00077 void parseImages(daeElement* library);
00078
00079 void parseEffects(daeElement* library);
00080
00081 void prepareTexture2D(Dae::Sampler2D* sampler2D);
00082
00083 void parseMaterials(daeElement* library);
00084
00085 ref<Light> parseLight(domLight*, Transform*);
00086
00087 void setupLights();
00088
00089 ref<Effect> setup_vl_Effect( Dae::Material* mat );
00090
00091 static std::string percentDecode(const char* uri);
00092
00093 static Dae::EInputSemantic getSemantic(const char* semantic);
00094
00095 static const char* getSemanticString(Dae::EInputSemantic semantic);
00096
00097 static ETexParamFilter translateSampleFilter(domFx_sampler_filter_common filter);
00098
00099 static ETexParamWrap translateWrapMode(domFx_sampler_wrap_common wrap);
00100
00101
00102 template<class T_color_or_texture>
00103 void parseColor(const domProfile_COMMON* common, const T_color_or_texture& color_or_texture, Dae::ColorOrTexture* out_col);
00104
00105 void generateGeometry(Dae::Primitive* primitive, const char* name);
00106
00107 protected:
00108 const LoadWriterDae::LoadOptions* mLoadOptions;
00109
00110 protected:
00111 ref<ResourceDatabase> mResources;
00112 std::vector< ref<Light> > mLights;
00113 std::map< daeElementRef, ref<Dae::Material> > mMaterials;
00114 std::map< daeElementRef, ref<Dae::Effect> > mEffects;
00115 std::map< daeElementRef, ref<Dae::Mesh> > mMeshes;
00116 std::vector< ref<Dae::Node> > mNodes;
00117 std::map< daeElementRef, ref<Dae::Source> > mSources;
00118 std::map< daeElementRef, ref<Image> > mImages;
00119 std::map< daeElementRef, ref<Dae::NewParam> > mDaeNewParams;
00120 ref<Effect> mDefaultFX;
00121 ref<Dae::Node> mScene;
00122 DAE mDAE;
00123 String mFilePath;
00124 mat4 mUpMatrix;
00125 bool mInvertTransparency;
00126 bool mAssumeOpaque;
00127 };
00128 }
00129
00130 #endif