Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://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 LoadWriterDae_INCLUDE_ONCE 00033 #define LoadWriterDae_INCLUDE_ONCE 00034 00035 #include <vlGraphics/link_config.hpp> 00036 #include <vlCore/VirtualFile.hpp> 00037 #include <vlCore/ResourceLoadWriter.hpp> 00038 #include <vlCore/ResourceDatabase.hpp> 00039 00040 namespace vl 00041 { 00042 //--------------------------------------------------------------------------- 00043 // LoadWriterDae 00044 //--------------------------------------------------------------------------- 00048 class LoadWriterDae: public ResourceLoadWriter 00049 { 00050 VL_INSTRUMENT_CLASS(vl::LoadWriterDae, ResourceLoadWriter) 00051 00052 public: 00054 class LoadOptions: public Object 00055 { 00056 public: 00057 enum TransparencyOption 00058 { 00059 TransparencyKeep, 00060 TransparencyInvert, 00061 TransparencyAuto 00062 }; 00063 00064 public: 00065 LoadOptions() 00066 { 00067 mInvertTransparency = TransparencyAuto; 00068 mUseAlwaysMipmapping = true; 00069 mFlattenTransformHierarchy = true; 00070 mComputeMissingNormals = true; 00071 mFixBadNormals = true; 00072 mMergeDrawCalls = true; 00073 mExtractSkins = false; 00074 mLightMeshSize = 0; 00075 mExportLights = false; 00076 } 00077 00079 void setFlattenTransformHierarchy(bool flatten) { mFlattenTransformHierarchy = flatten; } 00080 00082 bool flattenTransformHierarchy() const { return mFlattenTransformHierarchy; } 00083 00085 void setUseAlwaysMipmapping(bool use) { mUseAlwaysMipmapping = use; } 00086 00088 bool useAlwaysMipmapping() const { return mUseAlwaysMipmapping; } 00089 00091 void setInvertTransparency(TransparencyOption invert) { mInvertTransparency = invert; } 00092 00094 TransparencyOption invertTransparency() const { return mInvertTransparency; } 00095 00097 void setComputeMissingNormals(bool compute) { mComputeMissingNormals = compute; } 00098 00100 bool computeMissingNormals() const { return mComputeMissingNormals; } 00101 00103 void setFixBadNormals(bool fix) { mFixBadNormals = fix; } 00104 00106 bool fixBadNormals() const { return mFixBadNormals; } 00107 00109 void setExtractSkins(bool extract) { mExtractSkins = extract; } 00110 00112 bool extractSkins() const { return mExtractSkins; } 00113 00115 void setMergeDrawCalls(bool merge) { mMergeDrawCalls = merge; } 00116 00118 bool mergeDrawCalls() const { return mMergeDrawCalls; } 00119 00123 void setLightMeshSize(float size) { mLightMeshSize = size; } 00124 00128 float lightMeshSize() const { return mLightMeshSize; } 00129 00131 void setExportLights(bool exp_lights) { mExportLights = exp_lights; } 00132 00134 bool exportLights() const { return mExportLights; } 00135 00136 protected: 00137 TransparencyOption mInvertTransparency; 00138 bool mFlattenTransformHierarchy; 00139 bool mUseAlwaysMipmapping; 00140 bool mComputeMissingNormals; 00141 bool mFixBadNormals; 00142 bool mExtractSkins; 00143 bool mMergeDrawCalls; 00144 float mLightMeshSize; 00145 bool mExportLights; 00146 }; 00147 00148 public: 00149 static VLGRAPHICS_EXPORT ref<ResourceDatabase> load(const String& path, const LoadOptions* options); 00150 00151 static VLGRAPHICS_EXPORT ref<ResourceDatabase> load(VirtualFile* file, const LoadOptions* options); 00152 00153 LoadWriterDae(): ResourceLoadWriter("|dae|", "|dae|") 00154 { 00155 mLoadOptions = new LoadOptions; 00156 } 00157 00158 ref<ResourceDatabase> loadResource(const String& path) const 00159 { 00160 return load(path, loadOptions()); 00161 } 00162 00163 ref<ResourceDatabase> loadResource(VirtualFile* file) const 00164 { 00165 return load(file, loadOptions()); 00166 } 00167 00169 bool writeResource(const String& /*path*/, ResourceDatabase* /*resource*/) const 00170 { 00171 return false; 00172 } 00173 00175 bool writeResource(VirtualFile* /*file*/, ResourceDatabase* /*resource*/) const 00176 { 00177 return false; 00178 } 00179 00180 // --- options --- 00181 00182 const LoadOptions* loadOptions() const { return mLoadOptions.get(); } 00183 00184 LoadOptions* loadOptions() { return mLoadOptions.get(); } 00185 00186 protected: 00187 ref<LoadOptions> mLoadOptions; 00188 }; 00189 //--------------------------------------------------------------------------- 00190 } 00191 00192 #endif