00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef OST_GFX_PRIMITIVES_HH 00020 #define OST_GFX_PRIMITIVES_HH 00021 00022 #include <ost/geom/geom.hh> 00023 #include <ost/gfx/module_config.hh> 00024 #include <ost/gfx/color.hh> 00025 #include <ost/gfx/gfx_node.hh> 00026 00027 /* 00028 Author: Marco Biasini 00029 */ 00030 namespace ost { namespace gfx { 00031 00043 class DLLEXPORT_OST_GFX Primitive : 00044 public GfxNode { 00045 protected: 00046 Primitive(const String& name); 00047 public: 00048 void SetFill(const Color& color, bool fill=true); 00049 void SetOutline(const Color& color, bool line=true, float width=1.0); 00050 void SetFillColor(const Color& color); 00051 void SetOutlineColor(const Color& color); 00052 const Color& GetFillColor() const; 00053 const Color& GetOutlineColor() const; 00054 bool HasFill() const; 00055 bool HasOutline() const; 00056 float GetLineWidth() const; 00057 00058 void SetLineWidth(float width); 00059 private: 00060 bool fill_; 00061 bool line_; 00062 Color outline_color_; 00063 Color fill_color_; 00064 float line_width_; 00065 }; 00067 00068 class DLLEXPORT_OST_GFX Cuboid : public Primitive { 00069 public: 00070 Cuboid(const String& name, const geom::Cuboid& cuboid); 00071 virtual void RenderGL(RenderPass pass); 00072 private: 00073 geom::Cuboid cuboid_; 00074 }; 00075 00079 class DLLEXPORT_OST_GFX Quad : public Primitive { 00080 public: 00081 Quad(const String& name, const geom::Vec3& a, const geom::Vec3& b, 00082 const geom::Vec3& c, const geom::Vec3& d); 00083 virtual void RenderGL(RenderPass pass); 00084 private: 00085 geom::Vec3 corner_points_ [4]; 00086 }; 00087 00091 00092 }} 00093 00094 #endif