36 #define RANDF ((PN_stdfloat) rand() / (PN_stdfloat) 0x7fffffff)
42 void MeshDrawer2D::generator(
int budget) {
52 for(
int i = 0; i < budget; i++) {
53 for(
int vert = 0; vert < 4; vert++) {
55 LVector3 vec3 = LVector3(RANDF+10000,RANDF,RANDF);
56 LVector4 vec4 = LVector4(RANDF,RANDF,RANDF,0);
57 LVector2 vec2 = LVector2(RANDF,RANDF);
65 _prim->add_vertices(i*4+0, i*4+1, i*4+2);
66 _prim->close_primitive();
68 _prim->add_vertices(i*4+1, i*4+2, i*4+3);
69 _prim->close_primitive();
73 _geom =
new Geom(_vdata);
74 _geom->add_primitive(_prim);
75 _geomnode =
new GeomNode(
"__MeshDrawer_GeomNode");
76 _geomnode->add_geom(_geom);
78 _last_clear_index = budget;
91 if (_vertex !=
nullptr)
delete _vertex;
92 if (_uv !=
nullptr)
delete _uv;
93 if (_color !=
nullptr)
delete _color;
98 _dprim = _prim->decompose();
101 _start_clear_index = 0;
102 _end_clear_index = _budget;
103 _clear_index = _start_clear_index;
113 for(
int i = _clear_index ; i < _last_clear_index; i ++ ) {
120 _last_clear_index = _clear_index;
123 delete _vertex; _vertex =
nullptr;
124 delete _uv; _uv =
nullptr;
125 delete _color; _color =
nullptr;
135 rectangle_tiled(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h,
136 PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs,
137 const LVector4 &color
140 PN_stdfloat x_fit = w/us;
141 PN_stdfloat y_fit = h/vs;
142 PN_stdfloat x_pos = x;
145 PN_stdfloat y_pos = y;
149 PN_stdfloat fixed_us = us;
150 PN_stdfloat fixed_vs = vs;
155 while (fixed_us > us){
163 while (fixed_vs > vs){
168 rectangle(x_pos,y_pos,fixed_us,fixed_vs,u,v,fixed_us,fixed_vs,color);
187 PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h,
188 PN_stdfloat r, PN_stdfloat t, PN_stdfloat l, PN_stdfloat b,
189 PN_stdfloat tr, PN_stdfloat tt, PN_stdfloat tl, PN_stdfloat tb,
190 PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs,
191 const LVector4 &color){
196 rectangle(x, y+h, w, t, u, v+vs, us, tt, color);
197 rectangle(x, y-b, w, b, u, v-tb, us, tb, color);
200 rectangle(x-l, y, l, h, u-tl, v, tl, vs, color);
201 rectangle(x+w, y, r, h, r, v, tr, vs, color);
217 PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h,
218 PN_stdfloat r, PN_stdfloat t, PN_stdfloat l, PN_stdfloat b,
219 PN_stdfloat tr, PN_stdfloat tt, PN_stdfloat tl, PN_stdfloat tb,
220 PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs,
221 const LVector4 &color){
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A node that holds Geom objects, renderable pieces of geometry.
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,...
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
void add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w)
Sets the write row to a particular 4-component value, and advances the write row.
void add_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row.
void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row.
A container for geometry primitives.
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.
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.
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.
void end()
Finish the drawing and clearing off the remaining vertexes.
void begin()
Opens up the geom for drawing, don't forget to call MeshDrawer2D::end()
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.
NodePath attach_new_node(PandaNode *node, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Attaches a new node, with or without existing parents, to the scene graph below the referenced node o...
get_name
Returns the name of the referenced node.
TypeHandle is the identifier used to differentiate C++ class types.
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.