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);
59 tvertex->add_data3(vec3);
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;
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.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
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 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 end()
Finish the drawing and clearing off the remaining vertexes.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 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, that can be cliped.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_name
Returns the name of the referenced node.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A container for geometry primitives.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void begin()
Opens up the geom for drawing, don't forget to call MeshDrawer2D::end()
Defines a series of disconnected triangles.
TypeHandle is the identifier used to differentiate C++ class types.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A node that holds Geom objects, renderable pieces of geometry.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.