VRMLRenderer.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: VRMLRenderer.h,v 1.8.20.1 2007-03-25 21:26:14 oliver Exp $
00005 // v. 1.9 (2008.09.12) Annette Treichel
00006 //
00007 
00008 #ifndef BALL_VIEW_RENDERING_VRMLRENDERER_H
00009 #define BALL_VIEW_RENDERING_VRMLRENDERER_H
00010 
00011 #ifndef BALL_VIEW_RENDERING_RENDERER_H
00012 # include <BALL/VIEW/RENDERING/renderer.h>
00013 #endif
00014 
00015 #ifndef BALL_SYSTEM_FILE_H
00016 # include <BALL/SYSTEM/file.h>
00017 #endif
00018 
00019 #ifndef BALL_MATHS_VECTOR3_H
00020 # include <BALL/MATHS/vector3.h>
00021 #endif
00022 
00023 #ifndef BALL_MATHS_MATRIX44_H
00024 # include <BALL/MATHS/matrix44.h>
00025 #endif
00026 
00027 namespace BALL
00028 {
00029   namespace VIEW
00030   {
00031     class ColorRGBA;
00032 
00042 class BALL_VIEW_EXPORT VRMLRenderer : public Renderer
00043 {
00044   public:
00045 
00046   BALL_CREATE(VRMLRenderer)
00047 
00048   
00051 
00053   VRMLRenderer();
00054 
00058   VRMLRenderer(const String& name)
00059     throw(Exception::FileNotFound);
00060   
00062   virtual ~VRMLRenderer();
00063 
00065   virtual void clear();
00066 
00068 
00071 
00075   void setFileName(const String& name)
00076     throw(Exception::FileNotFound);
00077 
00080   String VRMLColorRGBA(const ColorRGBA& input);
00081 
00084   String VRMLVector3(Vector3 input);
00085 
00087   void VRMLColor(const ColorRGBA& color);
00088 
00090 
00093   
00097   virtual bool init(const Stage& stage);
00098 
00102   virtual bool finish();
00103 
00105 
00106   void renderSphere_(const Sphere& sphere);
00107   
00108   void renderMesh_(const Mesh& mesh);
00109 
00110   void renderLine_(const Line& miniTube);
00111 
00112   void renderTwoColoredLine_(const TwoColoredLine& miniTube);
00113 
00114   void renderTube_(const Tube& tube);
00115 
00116   void renderTwoColoredTube_(const TwoColoredTube& tube);
00117 
00118   void out_(const String& data);
00119 
00120   void outheader_(const String& data)
00121     {out_(data); current_indent_ += 1;}
00122 
00123   void outfinish_(const String& data)
00124     {out_(data); current_indent_ -= 1;}
00125 
00126   Size width, height;
00127 
00128   protected:
00129 
00130   void header_(const Vector3& translation, const ColorRGBA& color, 
00131                const String& rotation = "");
00132     
00133   void footer_();
00134 
00135   File outfile_;
00136 
00137   Vector3   origin_;
00138   Matrix4x4 rotation_;
00139   Index current_indent_;
00140 
00141   //size estimate for afterwards scaling for printing
00142   float smallX, smallY, smallZ, bigX, bigY, bigZ; 
00143 
00144   //boolean showing if scaling is relevant afterall
00145   bool scalingUsed;
00146 };
00147   
00148 } } // namespaces
00149 
00150 #endif // BALL_VIEW_RENDERING_VRMLRENDERER_H