Panda3D
|
00001 // Filename: fisheyeMaker.h 00002 // Created by: drose (3Oct05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef FISHEYEMAKER_H 00016 #define FISHEYEMAKER_H 00017 00018 #include "pandabase.h" 00019 00020 #include "pandaNode.h" 00021 #include "pointerTo.h" 00022 #include "namable.h" 00023 00024 class GeomVertexWriter; 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : FisheyeMaker 00028 // Description : This class is similar to CardMaker, but instead of 00029 // generating ordinary cards, it generates a circular 00030 // rose that represents the projection of a 3-D scene 00031 // through a fisheye lens. The texture coordinates of 00032 // the rose are defined so that each 2-D vertex has a 00033 // 3-D UVW that reflects the corresponding position in 00034 // 3-D space of that particular vertex. 00035 // 00036 // This class is particularly suited for converting cube 00037 // maps to sphere maps. 00038 //////////////////////////////////////////////////////////////////// 00039 class EXPCL_PANDA_GRUTIL FisheyeMaker : public Namable { 00040 PUBLISHED: 00041 INLINE FisheyeMaker(const string &name); 00042 INLINE ~FisheyeMaker(); 00043 00044 void reset(); 00045 void set_fov(PN_stdfloat fov); 00046 INLINE void set_num_vertices(int num_vertices); 00047 INLINE void set_square_inscribed(bool square_inscribed, PN_stdfloat square_radius); 00048 INLINE void set_reflection(bool reflection); 00049 00050 PT(PandaNode) generate(); 00051 00052 private: 00053 void add_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, 00054 PN_stdfloat r, PN_stdfloat a); 00055 00056 void add_square_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, 00057 PN_stdfloat a); 00058 00059 PN_stdfloat _fov; 00060 PN_stdfloat _half_fov_rad; 00061 int _num_vertices; 00062 bool _square_inscribed; 00063 PN_stdfloat _square_radius; 00064 PN_stdfloat _reflect; 00065 }; 00066 00067 #include "fisheyeMaker.I" 00068 00069 #endif 00070