Panda3D
|
00001 // Filename: meshDrawer2D.h 00002 // Created by: treeform (6Jan10) 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 MESHDRAWER2D_H 00016 #define MESHDRAWER2D_H 00017 00018 #include "pandabase.h" 00019 #include "luse.h" 00020 #include "pandaNode.h" 00021 #include "pointerTo.h" 00022 #include "lpoint2.h" 00023 #include "lvecBase2.h" 00024 #include "pnmImage.h" 00025 #include "nodePath.h" 00026 #include "texture.h" 00027 #include "geomVertexFormat.h" 00028 #include "geomVertexArrayFormat.h" 00029 #include "geomVertexData.h" 00030 #include "geomVertexWriter.h" 00031 #include "geomVertexRewriter.h" 00032 #include "boundingVolume.h" 00033 00034 #include "nodePathCollection.h" 00035 00036 #include "geomTristrips.h" 00037 #include "geomTriangles.h" 00038 #include "geom.h" 00039 #include "geomNode.h" 00040 #include "nodePath.h" 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Class : MeshDrawer2D 00044 // Description : This class allows the drawing of 2d objects - 00045 // mainly based on quads and rectangles. 00046 // Alows clipping and serverl high level UI theme 00047 // functions. 00048 //////////////////////////////////////////////////////////////////// 00049 class EXPCL_PANDA_GRUTIL MeshDrawer2D : public TypedObject { 00050 PUBLISHED: 00051 INLINE MeshDrawer2D(); 00052 INLINE ~MeshDrawer2D(); 00053 00054 INLINE void set_budget(int budget); 00055 INLINE int get_budget(); 00056 INLINE NodePath get_root(); 00057 00058 INLINE void quad_raw( 00059 LVector3f v1, LVector4f c1, LVector2f uv1, 00060 LVector3f v2, LVector4f c2, LVector2f uv2, 00061 LVector3f v3, LVector4f c3, LVector2f uv3, 00062 LVector3f v4, LVector4f c4, LVector2f uv4); 00063 00064 INLINE void rectangle_raw( 00065 float x, float y, float w, float h, 00066 float u, float v, float us, float vs, 00067 LVector4f color); 00068 00069 INLINE void set_clip(float x, float y, float w, float h); 00070 00071 INLINE void rectangle( 00072 float x, float y, float w, float h, 00073 float u, float v, float us, float vs, 00074 LVector4f color); 00075 00076 void rectangle_border( 00077 float x, float y, float w, float h, 00078 float r, float t, float l, float b, 00079 float tr, float tt, float tl, float tb, 00080 float u, float v, float us, float vs, 00081 LVector4f color); 00082 00083 void rectangle_border_tiled( 00084 float x, float y, float w, float h, 00085 float r, float t, float l, float b, 00086 float tr, float tt, float tl, float tb, 00087 float u, float v, float us, float vs, 00088 LVector4f color); 00089 00090 void rectangle_tiled( 00091 float x, float y, float w, float h, 00092 float u, float v, float us, float vs, 00093 LVector4f color); 00094 00095 void begin(); 00096 void end(); 00097 00098 private: 00099 00100 // use vars 00101 NodePath _root; 00102 int _budget; 00103 00104 // clip 00105 float _clip_x; 00106 float _clip_y; 00107 float _clip_w; 00108 float _clip_h; 00109 00110 // store regeneration geoms & nodes 00111 PT(Geom) _geom; 00112 PT(GeomNode) _geomnode; 00113 PT(GeomVertexData) _vdata; 00114 PT(GeomTriangles) _prim; 00115 CPT(GeomPrimitive) _dprim; 00116 00117 // writers 00118 GeomVertexRewriter *_vertex; 00119 GeomVertexRewriter *_uv; 00120 GeomVertexRewriter *_color; 00121 00122 // clear indexes 00123 int _last_clear_index, _start_clear_index, _end_clear_index, _clear_index; 00124 00125 // bounding volume 00126 PT(BoundingVolume) _bv; 00127 00128 // private create all the needed geoms 00129 void generator(int budget); 00130 00131 public: 00132 static TypeHandle get_class_type() { 00133 return _type_handle; 00134 } 00135 static void init_type() { 00136 TypedObject::init_type(); 00137 register_type(_type_handle, "MeshDrawer2D", 00138 TypedObject::get_class_type()); 00139 } 00140 virtual TypeHandle get_type() const { 00141 return get_class_type(); 00142 } 00143 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00144 00145 private: 00146 static TypeHandle _type_handle; 00147 00148 }; 00149 00150 #include "meshDrawer2D.I" 00151 00152 #endif /*MESHDRAWER2D_H*/