Panda3D
 All Classes Functions Variables Enumerations
meshDrawer2D.h
1 // Filename: meshDrawer2D.h
2 // Created by: treeform (6Jan10)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MESHDRAWER2D_H
16 #define MESHDRAWER2D_H
17 
18 #include "pandabase.h"
19 #include "luse.h"
20 #include "pandaNode.h"
21 #include "pointerTo.h"
22 #include "lpoint2.h"
23 #include "lvecBase2.h"
24 #include "pnmImage.h"
25 #include "nodePath.h"
26 #include "texture.h"
27 #include "geomVertexFormat.h"
28 #include "geomVertexArrayFormat.h"
29 #include "geomVertexData.h"
30 #include "geomVertexWriter.h"
31 #include "geomVertexRewriter.h"
32 #include "boundingVolume.h"
33 
34 #include "nodePathCollection.h"
35 
36 #include "geomTristrips.h"
37 #include "geomTriangles.h"
38 #include "geom.h"
39 #include "geomNode.h"
40 #include "nodePath.h"
41 
42 ////////////////////////////////////////////////////////////////////
43 // Class : MeshDrawer2D
44 // Description : This class allows the drawing of 2d objects -
45 // mainly based on quads and rectangles.
46 // Allows clipping and serverl high level UI theme
47 // functions.
48 ////////////////////////////////////////////////////////////////////
49 class EXPCL_PANDA_GRUTIL MeshDrawer2D : public TypedObject {
50 PUBLISHED:
51  INLINE MeshDrawer2D();
52  INLINE ~MeshDrawer2D();
53 
54  INLINE void set_budget(int budget);
55  INLINE int get_budget();
56  INLINE NodePath get_root();
57 
58  INLINE void quad_raw(
59  const LVector3 &v1, const LVector4 &c1, const LVector2 &uv1,
60  const LVector3 &v2, const LVector4 &c2, const LVector2 &uv2,
61  const LVector3 &v3, const LVector4 &c3, const LVector2 &uv3,
62  const LVector3 &v4, const LVector4 &c4, const LVector2 &uv4);
63 
64  INLINE void rectangle_raw(
65  PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h,
66  PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs,
67  const LVector4 &color);
68 
69  INLINE void set_clip(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h);
70 
71  INLINE void rectangle(
72  PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h,
73  PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs,
74  const LVector4 &color);
75 
76  void rectangle_border(
77  PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h,
78  PN_stdfloat r, PN_stdfloat t, PN_stdfloat l, PN_stdfloat b,
79  PN_stdfloat tr, PN_stdfloat tt, PN_stdfloat tl, PN_stdfloat tb,
80  PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs,
81  const LVector4 &color);
82 
83  void rectangle_border_tiled(
84  PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h,
85  PN_stdfloat r, PN_stdfloat t, PN_stdfloat l, PN_stdfloat b,
86  PN_stdfloat tr, PN_stdfloat tt, PN_stdfloat tl, PN_stdfloat tb,
87  PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs,
88  const LVector4 &color);
89 
90  void rectangle_tiled(
91  PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h,
92  PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs,
93  const LVector4 &color);
94 
95  void begin();
96  void end();
97 
98 private:
99 
100  // use vars
101  NodePath _root;
102  int _budget;
103 
104  // clip
105  PN_stdfloat _clip_x;
106  PN_stdfloat _clip_y;
107  PN_stdfloat _clip_w;
108  PN_stdfloat _clip_h;
109 
110  // store regeneration geoms & nodes
111  PT(Geom) _geom;
112  PT(GeomNode) _geomnode;
113  PT(GeomVertexData) _vdata;
114  PT(GeomTriangles) _prim;
115  CPT(GeomPrimitive) _dprim;
116 
117  // writers
118  GeomVertexRewriter *_vertex;
119  GeomVertexRewriter *_uv;
120  GeomVertexRewriter *_color;
121 
122  // clear indexes
123  int _last_clear_index, _start_clear_index, _end_clear_index, _clear_index;
124 
125  // bounding volume
126  PT(BoundingVolume) _bv;
127 
128  // private create all the needed geoms
129  void generator(int budget);
130 
131 public:
132  static TypeHandle get_class_type() {
133  return _type_handle;
134  }
135  static void init_type() {
137  register_type(_type_handle, "MeshDrawer2D",
138  TypedObject::get_class_type());
139  }
140  virtual TypeHandle get_type() const {
141  return get_class_type();
142  }
143  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
144 
145 private:
146  static TypeHandle _type_handle;
147 
148 };
149 
150 #include "meshDrawer2D.I"
151 
152 #endif /*MESHDRAWER2D_H*/
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:52
This class allows the drawing of 2d objects - mainly based on quads and rectangles.
Definition: meshDrawer2D.h:49
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:63
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
Definition: geom.h:58
This is a four-component vector distance.
Definition: lvector4.h:91
This is a two-component vector offset.
Definition: lvector2.h:91
Defines a series of disconnected triangles.
Definition: geomTriangles.h:25
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter, combined together into one convenient package.