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 VLXWrapper_Core_INCLUDE_ONCE 00033 #define VLXWrapper_Core_INCLUDE_ONCE 00034 00035 #include <vlCore/VLXClassWrapper.hpp> 00036 #include <vlCore/VLXRegistry.hpp> 00037 #include <vlCore/VLXSerializer.hpp> 00038 #include <vlCore/VLXValue.hpp> 00039 #include <vlCore/vlxutils.hpp> 00040 00041 #define VL_SERIALIZER_VERSION 100 00042 00043 #define VLX_IMPORT_CHECK_RETURN(Condition, Obj) \ 00044 if (!(Condition)) \ 00045 { \ 00046 s.signalImportError( Say("Line %n : condition failed : %s\n\tsee %s : %n\n") << (Obj).lineNumber() << #Condition << __FILE__ << __LINE__ ); \ 00047 return; \ 00048 } 00049 00050 #define VLX_IMPORT_CHECK_RETURN_NULL(Condition, Obj) \ 00051 if (!(Condition)) \ 00052 { \ 00053 s.signalImportError( Say("Line %n : condition failed : %s\n\tsee %s : %n\n") << (Obj).lineNumber() << #Condition << __FILE__ << __LINE__ ); \ 00054 return NULL; \ 00055 } 00056 00057 namespace vl 00058 { 00059 inline VLXValue export_AABB(const AABB& aabb) 00060 { 00061 VLXValue value ( new VLXStructure("<vl::AABB>") ); 00062 *value.getStructure() << "MinCorner" << vlx_toValue(aabb.minCorner()); 00063 *value.getStructure() << "MaxCorner" << vlx_toValue(aabb.maxCorner()); 00064 return value; 00065 } 00066 00067 inline AABB import_AABB(const VLXStructure* vlx) 00068 { 00069 AABB aabb; 00070 00071 VL_CHECK( vlx->tag() == "<vl::AABB>" ) 00072 00073 for(size_t i=0; i<vlx->value().size(); ++i) 00074 { 00075 const std::string& key = vlx->value()[i].key(); 00076 const VLXValue& value = vlx->value()[i].value(); 00077 if (key == "MinCorner") 00078 { 00079 VL_CHECK(value.type() == VLXValue::ArrayReal) 00080 aabb.setMinCorner( vlx_vec3(value.getArrayReal()) ); 00081 } 00082 else 00083 if (key == "MaxCorner") 00084 { 00085 VL_CHECK(value.type() == VLXValue::ArrayReal) 00086 aabb.setMaxCorner( vlx_vec3(value.getArrayReal()) ); 00087 } 00088 } 00089 00090 return aabb; 00091 } 00092 00093 inline VLXValue export_Sphere(const Sphere& sphere) 00094 { 00095 VLXValue value ( new VLXStructure("<vl::Sphere>") ); 00096 *value.getStructure() << "Center" << vlx_toValue(sphere.center()); 00097 *value.getStructure() << "Radius" << sphere.radius(); 00098 return value; 00099 } 00100 00101 inline Sphere import_Sphere(const VLXStructure* vlx) 00102 { 00103 Sphere sphere; 00104 00105 VL_CHECK( vlx->tag() == "<vl::Sphere>" ) 00106 00107 for(size_t i=0; i<vlx->value().size(); ++i) 00108 { 00109 const std::string& key = vlx->value()[i].key(); 00110 const VLXValue& value = vlx->value()[i].value(); 00111 if (key == "Center") 00112 { 00113 VL_CHECK(value.type() == VLXValue::ArrayReal) 00114 sphere.setCenter( vlx_vec3(value.getArrayReal()) ); 00115 } 00116 else 00117 if (key == "Radius") 00118 { 00119 VL_CHECK(value.type() == VLXValue::Real) 00120 sphere.setRadius( (real)value.getReal() ); 00121 } 00122 } 00123 00124 return sphere; 00125 } 00126 } 00127 00128 #endif