Panda3D

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