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){