Panda3D
Loading...
Searching...
No Matches
meshDrawer.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 meshDrawer.h
10 * @author treeform
11 * @date 2008-12-19
12 * @author treeform
13 * @date 2010-01-12
14 */
15
16#ifndef MESHDRAWER_H
17#define MESHDRAWER_H
18
19#include "pandabase.h"
20#include "luse.h"
21#include "pandaNode.h"
22#include "pointerTo.h"
23#include "lpoint2.h"
24#include "lvecBase2.h"
25#include "pnmImage.h"
26#include "nodePath.h"
27#include "texture.h"
28#include "geomVertexFormat.h"
30#include "geomVertexData.h"
31#include "geomVertexWriter.h"
32#include "geomVertexRewriter.h"
33#include "boundingVolume.h"
34
35#include "nodePathCollection.h"
36
37#include "geomTristrips.h"
38#include "geomTriangles.h"
39#include "geom.h"
40#include "geomNode.h"
41#include "nodePath.h"
42
43/**
44 * Mesh drawer creates a single geom object that can be shaped with different
45 * draw commands. This is an efficient way to render bunch of billboards,
46 * particles, fast changing triangles. Its implemented by recycling same geom
47 * over and over again. Max budget specifies how many triangles are allowed.
48 * Some uses of this class can be : particle system, radar icons, health bars,
49 * 2d icons, 2d ui, bullets, missile trails. Any that can be drawn with
50 * triangles can be drawn with this class. At the low level this uses the
51 * GeomVertexRewriter's. The internal geom consists of vertex, normal, uv and
52 * color channels.
53 */
54class EXPCL_PANDA_GRUTIL MeshDrawer : public TypedObject {
55PUBLISHED:
56 INLINE MeshDrawer();
57 INLINE ~MeshDrawer();
58
59 INLINE void set_budget(int budget);
60 INLINE int get_budget();
61
62 INLINE NodePath get_root();
63
64 void begin(NodePath camera, NodePath render);
65 INLINE void tri(const LVector3 &v1, const LVector4 &c1, const LVector2 &uv1,
66 const LVector3 &v2, const LVector4 &c2, const LVector2 &uv2,
67 const LVector3 &v3, const LVector4 &c3, const LVector2 &uv3);
68
69 void particle(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation);
70 void blended_particle(const LVector3 &pos, const LVector4 &frame1, const LVector4 &frame2,
71 PN_stdfloat blend, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation);
72 void billboard(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color);
73 void segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color);
74 void cross_segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color);
75 void uneven_segment(const LVector3 &start, const LVector3 &stop,
76 const LVector4 &frame, PN_stdfloat thickness_start, const LVector4 &color_start,
77 PN_stdfloat thickness_stop, const LVector4 &color_stop);
78
79 void link_segment(const LVector3 &pos, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color);
80 void link_segment_end(const LVector4 &frame, const LVector4 &color);
81
82 void explosion(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color,
83 int seed, int number, PN_stdfloat distance);
84 void stream(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat size, const LVector4 &color,
85 int number, PN_stdfloat offset);
86 void geometry(NodePath node);
87 void end();
88
89private:
90
91 // use vars
92 NodePath _root;
93 NodePath _camera, _render;
94 int _budget;
95
96 // store regeneration geoms & nodes
97 PT(Geom) _geom;
98 PT(GeomNode) _geomnode;
99 PT(GeomVertexData) _vdata;
100 PT(GeomTriangles) _prim;
101 CPT(GeomPrimitive) _dprim;
102
103 // writers
104 GeomVertexRewriter *_vertex;
105 GeomVertexRewriter *_normal;
107 GeomVertexRewriter *_color;
108
109 // billboard vectors
110 LVector3 _eyePos;
111 LVector3 _b1, _b2, _b3, _b4;
112 LVector3 _up, _right;
113
114 // clear indexes
115 int _last_clear_index, _start_clear_index, _end_clear_index, _clear_index;
116
117 // used for curves
118 int _at_start;
119 LVector3 _last_v1,_last_v2,_last_v3,_last_v4,_last_pos;
120 PN_stdfloat _last_thickness;
121 LVector4 _last_color;
122
123 // bounding volume
124 PT(BoundingVolume) _bv;
125
126 // private create all the needed geoms
127 void generator(int budget);
128
129public:
130 static TypeHandle get_class_type() {
131 return _type_handle;
132 }
133 static void init_type() {
135 register_type(_type_handle, "MeshDrawer",
136 TypedObject::get_class_type());
137 }
138 virtual TypeHandle get_type() const {
139 return get_class_type();
140 }
141 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
142
143private:
144 static TypeHandle _type_handle;
145
146};
147
148#include "meshDrawer.I"
149
150#endif /*MESHDRAWER_H*/
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A node that holds Geom objects, renderable pieces of geometry.
Definition geomNode.h:34
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Defines a series of disconnected triangles.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter,...
A container for geometry primitives.
Definition geom.h:54
Mesh drawer creates a single geom object that can be shaped with different draw commands.
Definition meshDrawer.h:54
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition typedObject.h:88
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.