# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/plugins/COLLADA/DaeLoader.hpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.org                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    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     // --- options ---
    00053
    00054     void setLoadOptions(const LoadWriterDae::LoadOptions* options) { mLoadOptions = options; }
    00055
    00056     const LoadWriterDae::LoadOptions* loadOptions() const { return mLoadOptions; }
    00057
    00058     // --- internal logic ---
    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     // template required becase Transparent is implemented as something different from domCommon_color_or_texture_typeRef!!!
    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; // daeElement* -> <geometry>
    00116     std::vector< ref<Dae::Node> > mNodes;
    00117     std::map< daeElementRef, ref<Dae::Source> > mSources; // daeElement* -> <source>
    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

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:43:40.
Permission is granted to use this page to write and publish articles regarding Visualization Library.