Panda3D
 All Classes Functions Variables Enumerations
meshDrawer.cxx
1 // Filename: meshDrawer.cxx
2 // Created by: treeform (19dec08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "meshDrawer.h"
16 
17 #include "geomVertexFormat.h"
18 #include "geomVertexArrayFormat.h"
19 #include "geomVertexData.h"
20 #include "geomVertexWriter.h"
21 #include "geomVertexRewriter.h"
22 #include "camera.h"
23 #include "boundingSphere.h"
24 #include "geomTristrips.h"
25 #include "geomTriangles.h"
26 #include "geom.h"
27 #include "geomNode.h"
28 #include "pnmPainter.h"
29 #include "pnmBrush.h"
30 #include "lvecBase4.h"
31 #include "lvector3.h"
32 #include "pandaNode.h"
33 
34 TypeHandle MeshDrawer::_type_handle;
35 
36 PN_stdfloat randFloat() {
37  return ((PN_stdfloat) rand() / (PN_stdfloat) 0x7fffffff);
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: MeshDrawer::generator
42 // Access: Private
43 // Description: Creates a system with a given budget.
44 ////////////////////////////////////////////////////////////////////
45 void MeshDrawer::generator(int budget) {
46  // create enough triangles for budget:
47  _vdata = new GeomVertexData(_root.get_name(), GeomVertexFormat::get_v3n3c4t2(), Geom::UH_static);//UH_dynamic);
48  GeomVertexWriter *tvertex = new GeomVertexWriter(_vdata, "vertex");
49  GeomVertexWriter *tnormal = new GeomVertexWriter(_vdata, "normal");
50  GeomVertexWriter *tuv = new GeomVertexWriter(_vdata, "texcoord");
51  GeomVertexWriter *tcolor = new GeomVertexWriter(_vdata, "color");
52  _prim = new GeomTriangles(Geom::UH_static);
53 
54  // iterate and fill _up a geom with random data so that it will
55  // not be optimized out by panda3d system
56  for(int i = 0; i < budget; i++) {
57  for( int vert = 0; vert < 3; vert++) {
58  LVector3 vec3 = LVector3(randFloat()+1000,randFloat(),randFloat())*.001;
59  LVector4 vec4 = LVector4(1,1,1,randFloat());
60  LVector2 vec2 = LVector2(0,randFloat());
61  tvertex->add_data3(vec3);
62  tcolor->add_data4(vec4);
63  tuv->add_data2(vec2);
64  tnormal->add_data3(vec3);
65  }
66  _prim->add_vertices(i * 3, i * 3 + 1, i * 3 + 2);
67  }
68  // create our node and attach it to this node path
69  _prim->close_primitive();
70  _geom = new Geom(_vdata);
71  _geom->add_primitive(_prim);
72  _geomnode = new GeomNode("__MeshDrawer_GeomNode");
73  _geomnode->add_geom(_geom);
74  _root.attach_new_node(_geomnode);
75  _last_clear_index = budget;
76 
77  delete tvertex;
78  delete tnormal;
79  delete tuv;
80  delete tcolor;
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: MeshDrawer::begin
85 // Access: Published
86 // Description: Pass the current camera node and the root node.
87 // Passing the camera is required to generate
88 // bill boards that face it.
89 ////////////////////////////////////////////////////////////////////
90 void MeshDrawer::begin(NodePath camera, NodePath render) {
91  // sanity check
92  assert(render.get_error_type() == NodePath::ET_ok);
93  assert(camera.get_error_type() == NodePath::ET_ok);
94 
95  // remember our arguments
96  _camera = camera;
97  _render = render;
98 
99  // compute some help vectors
100  _eyePos = camera.get_pos();
101  _up = _render.get_relative_vector(camera, LVector3(0, 0, 1));
102  _right = _render.get_relative_vector(camera, LVector3(1, 0, 0));
103  _b1 = - _right - _up;
104  _b2 = _right - _up;
105  _b3 = _right + _up;
106  _b4 = - _right + _up;
107 
108  // recreate our rewriters
109  if (_vertex != NULL) delete _vertex;
110  if (_normal != NULL) delete _normal;
111  if (_uv != NULL) delete _uv;
112  if (_color != NULL) delete _color;
113 
114  if (_vdata == NULL) {
115  generator(_budget);
116  }
117 
118  _vertex = new GeomVertexRewriter(_vdata, "vertex");
119  _uv = new GeomVertexRewriter(_vdata, "texcoord");
120  _normal = new GeomVertexRewriter(_vdata, "normal");
121  _color = new GeomVertexRewriter(_vdata, "color");
122  _dprim = _prim->decompose();
123 
124  // reseta our clearning indexes
125  _start_clear_index = 0;
126  _end_clear_index = _budget;
127  _clear_index = _start_clear_index;
128 
129 }
130 
131 ////////////////////////////////////////////////////////////////////
132 // Function: MeshDrawer::end
133 // Access: Published
134 // Description: Finish the drawing and clearing off the remaining
135 // vertexes.
136 ////////////////////////////////////////////////////////////////////
138 
139  // clear the unused triangles at the end of the buffer
140  for(int i = _clear_index ; i < _last_clear_index; i ++ ) {
141  _vertex->add_data3(0,0,0);
142  _vertex->add_data3(0,0,0);
143  _vertex->add_data3(0,0,0);
144  }
145  // don't clear more then you have too
146  _last_clear_index = _clear_index;
147 
148  // delete the re writers
149  delete _vertex; _vertex = NULL;
150  delete _uv; _uv = NULL;
151  delete _normal; _normal = NULL;
152  delete _color; _color = NULL;
153 
154 }
155 
156 ////////////////////////////////////////////////////////////////////
157 // Function: MeshDrawer::particle
158 // Access: Published
159 // Description: Draws a particle that is sort of like a bill board
160 // but has an extra rotation component.
161 // Frame contains u,v,u-size,v-size quadruple.
162 ////////////////////////////////////////////////////////////////////
163 void MeshDrawer::particle(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size,
164  const LVector4 &color, PN_stdfloat rotation) {
165 
166  rotation = rotation / 57.29578;
167 
168  LVector3 v1 = pos + _b1*size*sin(rotation) + _b2*size*cos(rotation);
169  LVector3 v2 = pos + _b2*size*sin(rotation) + _b3*size*cos(rotation);
170  LVector3 v3 = pos + _b3*size*sin(rotation) + _b4*size*cos(rotation);
171  LVector3 v4 = pos + _b4*size*sin(rotation) + _b1*size*cos(rotation);
172 
173  PN_stdfloat u = frame.get_x();
174  PN_stdfloat v = frame.get_y();
175  PN_stdfloat us = frame.get_z();
176  PN_stdfloat vs = frame.get_w();
177 
178  tri(
179  v1, color, LVector2(u,v),
180  v2, color, LVector2(u+us,v),
181  v3, color, LVector2(u+us,v+vs));
182  tri(
183  v3, color, LVector2(u+us,v+vs),
184  v4, color, LVector2(u,v+vs),
185  v1, color, LVector2(u,v));
186 }
187 
188 ////////////////////////////////////////////////////////////////////
189 // Function: MeshDrawer::blended_particle
190 // Access: Published
191 // Description: Works just like particle but accepts 2 frames and
192 // a blend (from 0 to 1) component between them
193 // Frame contains u,v,u-size,v-size quadruple.
194 ////////////////////////////////////////////////////////////////////
195 void MeshDrawer::blended_particle(const LVector3 &pos, const LVector4 &frame1,
196  const LVector4 &frame2, PN_stdfloat blend, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation) {
197 
198  LVector4 c2 = color;
199  PN_stdfloat original_w = c2.get_w();
200  c2.set_w((1.f-blend)*original_w);
201  particle(pos,frame1,size,c2,rotation);
202  c2.set_w(blend*original_w);
203  particle(pos,frame2,size,c2,rotation);
204 
205 }
206 
207 ////////////////////////////////////////////////////////////////////
208 // Function: MeshDrawer::billboard
209 // Access: Published
210 // Description: Draws a billboard - particle with no rotation.
211 // Billboards always face the camera.
212 // Frame contains u,v,u-size,v-size quadruple.
213 ////////////////////////////////////////////////////////////////////
214 void MeshDrawer::billboard(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size,
215  const LVector4 &_color) {
216 
217  LVector3 v1 = pos + _b1*size;
218  LVector3 v2 = pos + _b2*size;
219  LVector3 v3 = pos + _b3*size;
220  LVector3 v4 = pos + _b4*size;
221 
222  PN_stdfloat u = frame.get_x();
223  PN_stdfloat v = frame.get_y();
224  PN_stdfloat us = frame.get_z();
225  PN_stdfloat vs = frame.get_w();
226 
227  tri(
228  v1, _color, LVector2(u,v),
229  v2, _color, LVector2(u+us,v),
230  v3, _color, LVector2(u+us,v+vs));
231  tri(
232  v3, _color, LVector2(u+us,v+vs),
233  v4, _color, LVector2(u,v+vs),
234  v1, _color, LVector2(u,v));
235 }
236 
237 
238 ////////////////////////////////////////////////////////////////////
239 // Function: MeshDrawer::segment
240 // Access: Published
241 // Description: Draws a segment a line with a thickness. That has
242 // billboarding effect.
243 // Frame contains u,v,u-size,v-size quadruple.
244 ////////////////////////////////////////////////////////////////////
245 void MeshDrawer::segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame,
246  PN_stdfloat thickness, const LVector4 &color) {
247  link_segment(start, frame, thickness, color);
248  link_segment(stop, frame, thickness, color);
249  link_segment_end(frame, color);
250 }
251 ////////////////////////////////////////////////////////////////////
252 // Function: MeshDrawer::cross_segment
253 // Access: Published
254 // Description: Draws a segment a line with a thickness. This
255 // segment does not use the bill boarding behavior
256 // and instead draws 2 planes in a cross.
257 // Stars at start and ends at stop.
258 // Frame contains u,v,u-size,v-size quadruple.
259 ////////////////////////////////////////////////////////////////////
260 void MeshDrawer::cross_segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame,
261  PN_stdfloat thickness, const LVector4 &color) {
262 
263  PN_stdfloat u = frame.get_x();
264  PN_stdfloat v = frame.get_y();
265  PN_stdfloat us = frame.get_z();
266  PN_stdfloat vs = frame.get_w();
267 
268  LVector3 v1 = start - _up*thickness;
269  LVector3 v2 = stop - _up*thickness;
270  LVector3 v3 = stop + _up*thickness;
271  LVector3 v4 = start + _up*thickness;
272 
273  tri(v1, color, LVector2(u,v),
274  v2, color, LVector2(u+us,v),
275  v3, color, LVector2(u+us,v+vs));
276  tri(v3, color, LVector2(u+us,v+vs),
277  v4, color, LVector2(u,v+vs),
278  v1, color, LVector2(u,v));
279 
280  v1 = start - _right*thickness;
281  v2 = stop - _right*thickness;
282  v3 = stop + _right*thickness;
283  v4 = start + _right*thickness;
284 
285  tri(v1, color, LVector2(u,v),
286  v2, color, LVector2(u+us,v),
287  v3, color, LVector2(u+us,v+vs));
288  tri(v3, color, LVector2(u+us,v+vs),
289  v4, color, LVector2(u,v+vs),
290  v1, color, LVector2(u,v));
291 
292 }
293 
294 
295 
296 
297 ////////////////////////////////////////////////////////////////////
298 // Function: MeshDrawer::uneven_segment
299 // Access: Published
300 // Description: Draws a segment a line with different thickness
301 // and color on both sides.
302 // Stars at start and ends at stop.
303 // Frame contains u,v,u-size,v-size quadruple.
304 ////////////////////////////////////////////////////////////////////
305 void MeshDrawer::uneven_segment(const LVector3 &start, const LVector3 &stop,
306  const LVector4 &frame, PN_stdfloat thickness_start, const LVector4 &color_start,
307  PN_stdfloat thickness_stop, const LVector4 &color_stop) {
308 
309  PN_stdfloat u = frame.get_x();
310  PN_stdfloat v = frame.get_y();
311  PN_stdfloat us = frame.get_z();
312  PN_stdfloat vs = frame.get_w();
313 
314  LVector3 v1 = start - _up*thickness_start;
315  LVector3 v2 = stop - _up*thickness_stop;
316  LVector3 v3 = stop + _up*thickness_stop;
317  LVector3 v4 = start + _up*thickness_start;
318 
319  tri(v1, color_start, LVector2(u,v),
320  v2, color_stop, LVector2(u+us,v),
321  v3, color_stop, LVector2(u+us,v+vs));
322  tri(v3, color_stop, LVector2(u+us,v+vs),
323  v4, color_start, LVector2(u,v+vs),
324  v1, color_start, LVector2(u,v));
325 
326  v1 = start - _right*thickness_start;
327  v2 = stop - _right*thickness_stop;
328  v3 = stop + _right*thickness_stop;
329  v4 = start + _right*thickness_start;
330 
331  tri(v1, color_start, LVector2(u,v),
332  v2, color_stop, LVector2(u+us,v),
333  v3, color_stop, LVector2(u+us,v+vs));
334  tri(v3, color_stop, LVector2(u+us,v+vs),
335  v4, color_start, LVector2(u,v+vs),
336  v1, color_start, LVector2(u,v));
337 }
338 
339 ////////////////////////////////////////////////////////////////////
340 // Function: MeshDrawer::explosion
341 // Access: Published
342 // Description: Draws number of particles in a sphere like emitter.
343 // Frame contains u,v,u-size,v-size quadruple.
344 ////////////////////////////////////////////////////////////////////
346  const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &_color,
347  int seed, int number, PN_stdfloat distance) {
348  srand(seed);
349  LVector3 relative_pos;
350  for(int i = 0; i < number; i++) {
351  relative_pos = LVector3(randFloat()-.5f,randFloat()-.5f,randFloat()-.5f);
352  relative_pos.normalize();
353  relative_pos *= randFloat()*distance;
354  particle(relative_pos+pos,frame,size,_color,randFloat()*360.0f);
355  }
356 }
357 
358 ////////////////////////////////////////////////////////////////////
359 // Function: MeshDrawer::stream
360 // Access: Published
361 // Description: Draws a number of particles in a big line with a
362 // shift dictated by the offset.
363 // Frame contains u,v,u-size,v-size quadruple.
364 ////////////////////////////////////////////////////////////////////
365 void MeshDrawer::stream(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat size, const LVector4 &_color,
366  int number, PN_stdfloat offset) {
367 
368  offset = offset-floor(offset);
369  LVector3 relative_pos = stop;
370  LVector3 vec = stop - start;
371  PN_stdfloat distance = vec.length();
372  vec.normalize();
373  for(int i = 0; i < number; i++) {
374  relative_pos = start + vec * ((i+offset)*(distance/PN_stdfloat(number)));
375  billboard(relative_pos,frame,size,_color);
376  }
377 }
378 
379 
380 
381 ////////////////////////////////////////////////////////////////////
382 // Function: MeshDrawer::geometry
383 // Access: Published
384 // Description: Draws the geometry that is inside this node path into
385 // the MeshDrawer object. This performs a similar
386 // functions as RigidBodyCombiner but for very
387 // dynamic situations that share the same texture
388 // like physcal chunks of explosions.
389 // It can be a little slow
390 ////////////////////////////////////////////////////////////////////
392  assert(_render.get_error_type() == NodePath::ET_ok);
393 
394  LVector4 color = LVector4(1,1,1,1);
395  LVector3 vec[3];
396  LVector2 uv[3];
397 
398  // process node
399  NodePathCollection geom_collection = draw_node.find_all_matches("**/+GeomNode");
400  for(int i=0; i < geom_collection.get_num_paths(); i++ ) {
401  NodePath current_node_path = geom_collection.get_path(i);
402  PT(GeomNode) geomNode = DCAST(GeomNode, current_node_path.node());
403 
404  // process geom node
405  for(int j=0; j<geomNode->get_num_geoms(); j++) {
406  CPT(Geom) geom = geomNode->get_geom(j);
407  CPT(GeomVertexData) v_data = geom->get_vertex_data();
408  GeomVertexReader *prim_vertex_reader = new GeomVertexReader(v_data, "vertex");
409  GeomVertexReader *prim_uv_reader = new GeomVertexReader(v_data, "texcoord");
410  for(int k=0; k <geom->get_num_primitives(); k++) {
411  CPT(GeomPrimitive) prim1 = geom->get_primitive(k);
412  CPT(GeomPrimitive) _prim = prim1->decompose();
413 
414  // process primitive
415  for(int p=0; p < _prim->get_num_primitives();p++) {
416  int s = _prim->get_primitive_start(p);
417  int e = _prim->get_primitive_end(p);
418  int indx_over = 0;
419 
420  // process polygon
421  for(int idx=s; idx<e; idx++) {
422  int vidx = _prim->get_vertex(idx);
423  prim_vertex_reader->set_row_unsafe(vidx);
424  prim_uv_reader->set_row_unsafe(vidx);
425  vec[indx_over] = _render.get_relative_point(
426  current_node_path,prim_vertex_reader->get_data3());
427  uv[indx_over] = prim_uv_reader->get_data2();
428  indx_over++;
429  if (indx_over > 2) break;
430  }
431 
432  // draw polygon
433  tri(vec[0],color,uv[0],
434  vec[1],color,uv[1],
435  vec[2],color,uv[2]);
436  }
437  // if we are over budget just quit
438  if( _clear_index > _end_clear_index) return;
439  }
440  // delete our reders
441  delete prim_vertex_reader;
442  delete prim_uv_reader;
443  }
444  }
445 }
446 
447 
448 
449 ////////////////////////////////////////////////////////////////////
450 // Function: MeshDrawer::link_segment
451 // Access: Published
452 // Description: Stars or continues linked segment.
453 // Control position, frame, thickness and color with
454 // parameters.
455 // Frame contains u,v,u-size,v-size quadruple.
456 ////////////////////////////////////////////////////////////////////
457 void MeshDrawer::
458 link_segment(const LVector3 &pos, const LVector4 &frame,
459  PN_stdfloat thickness, const LVector4 &color) {
460  assert(_render.get_error_type() == NodePath::ET_ok);
461  assert(_camera.get_error_type() == NodePath::ET_ok);
462  /*
463  * X
464  * ---X
465  * ===0---X
466  * ===0===0---X
467  * ===0===0===O---X
468  * ===0===0===0===End
469  *
470  * first call marks position X
471  * second call moves position and promises to draw segment
472  * it can't draw it yet because next segment might bend it
473  * third call finally draws segment
474  * and the chain continues till
475  * link_segment_end to flush the linking segments is called.
476  */
477 
478  // mark 1st position
479  if(_at_start==0) {
480  _last_pos = pos;
481  _last_thickness = thickness;
482  _last_color = color;
483  _at_start=1;
484  return;
485  }
486 
487  LVector3 start = _last_pos;
488  LVector3 stop = pos;
489 
490  LVector3 cam_start3d = _camera.get_relative_point(_render, start);
491  LPoint2 cam_start2d = LVector2();
492  LVector3 cam_stop3d = _camera.get_relative_point(_render, stop);
493  LPoint2 cam_stop2d = LVector2();
494 
495  PT(Camera) camera = DCAST(Camera, _camera.node());
496  PT(Lens) lens = camera->get_lens();
497 
498  lens->project(cam_start3d, cam_start2d);
499  lens->project(cam_stop3d, cam_stop2d);
500 
501  LVector2 dif = cam_stop2d - cam_start2d;
502  PN_stdfloat rotation = atan2(dif.get_x(),dif.get_y());
503 
504  LVector3 now_v1 = start + _b1*(PN_stdfloat)(thickness*sin(rotation)) + _b2*(PN_stdfloat)(thickness*cos(rotation));
505  LVector3 now_v4 = start + _b4*(PN_stdfloat)(thickness*sin(rotation)) + _b1*(PN_stdfloat)(thickness*cos(rotation));
506  LVector3 now_v2 = stop + _b2*(PN_stdfloat)(thickness*sin(rotation)) + _b3*(PN_stdfloat)(thickness*cos(rotation));
507  LVector3 now_v3 = stop + _b3*(PN_stdfloat)(thickness*sin(rotation)) + _b4*(PN_stdfloat)(thickness*cos(rotation));
508 
509  // mark the segment we going to draw
510  // we need to draw it when we know what the next segment looks like
511  // because it can bend it a little
512  if(_at_start==1) {
513  _last_v1 = now_v1;
514  _last_v2 = now_v2;
515  _last_v3 = now_v3;
516  _last_v4 = now_v4;
517  _at_start = 2;
518  return;
519  }
520 
521  // draw the last segment a little bent
522  LVector3 v1 = _last_v1;
523  LVector3 v2 = (_last_v2+now_v1)/2.0f;
524  LVector3 v3 = (_last_v3+now_v4)/2.0f;
525  LVector3 v4 = _last_v4;
526 
527  // compute this frame
528  PN_stdfloat u = frame.get_x();
529  PN_stdfloat v = frame.get_y();
530  PN_stdfloat us = frame.get_z();
531  PN_stdfloat vs = frame.get_w();
532 
533  tri(v1, _last_color, LVector2(u,v),
534  v2, color, LVector2(u+us,v),
535  v3, color, LVector2(u+us,v+vs));
536  tri(v3, color, LVector2(u+us,v+vs),
537  v4, _last_color, LVector2(u,v+vs),
538  v1, _last_color, LVector2(u,v));
539 
540  // save this segment
541  _last_v1 = v2;
542  _last_v2 = now_v2;
543  _last_v3 = now_v3;
544  _last_v4 = v3;
545 
546  // make this position
547  _last_pos = pos;
548  _last_thickness = thickness;
549  _last_color = color;
550 }
551 
552 ////////////////////////////////////////////////////////////////////
553 // Function: MeshDrawer::link_segment_end
554 // Access: Published
555 // Description: Finish drawing linked segments, needs at least
556 // two calls to link_segment before it can end
557 // the linked segment.
558 // Frame contains u,v,u-size,v-size quadruple.
559 ////////////////////////////////////////////////////////////////////
561 {
562  PN_stdfloat u = frame.get_x();
563  PN_stdfloat v = frame.get_y();
564  PN_stdfloat us = frame.get_z();
565  PN_stdfloat vs = frame.get_w();
566 
567  tri(_last_v1, _last_color, LVector2(u,v),
568  _last_v2, color, LVector2(u+us,v),
569  _last_v3, color, LVector2(u+us,v+vs));
570  tri(_last_v3, color, LVector2(u+us,v+vs),
571  _last_v4, _last_color, LVector2(u,v+vs),
572  _last_v1, _last_color, LVector2(u,v));
573 
574  _at_start = 0;
575 }
void segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color)
Draws a segment a line with a thickness.
Definition: meshDrawer.cxx:245
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
void explosion(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color, int seed, int number, PN_stdfloat distance)
Draws number of particles in a sphere like emitter.
Definition: meshDrawer.cxx:345
A base class for any number of different kinds of lenses, linear and otherwise.
Definition: lens.h:45
void billboard(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color)
Draws a billboard - particle with no rotation.
Definition: meshDrawer.cxx:214
void end()
Finish the drawing and clearing off the remaining vertexes.
Definition: meshDrawer.cxx:137
const LVecBase2 & get_data2()
Returns the data associated with the read row, expressed as a 2-component value, and advances the rea...
NodePath get_path(int index) const
Returns the nth NodePath in the collection.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:63
void add_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row. ...
PandaNode * node() const
Returns the referenced node of the path.
Definition: nodePath.I:284
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
int get_num_paths() const
Returns the number of NodePaths in the collection.
ErrorType get_error_type() const
If is_empty() is true, this returns a code that represents the reason why the NodePath is empty...
Definition: nodePath.I:259
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. ...
float length() const
Returns the length of the vector, by the Pythagorean theorem.
Definition: lvecBase3.h:765
LPoint3 get_pos() const
Retrieves the translation component of the transform.
Definition: nodePath.cxx:1178
string get_name() const
Returns the name of the referenced node.
Definition: nodePath.I:2580
void stream(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat size, const LVector4 &color, int number, PN_stdfloat offset)
Draws a number of particles in a big line with a shift dictated by the offset.
Definition: meshDrawer.cxx:365
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
Definition: geom.h:58
const LVecBase3 & get_data3()
Returns the data associated with the read row, expressed as a 3-component value, and advances the rea...
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. ...
This is a four-component vector distance.
Definition: lvector4.h:91
void blended_particle(const LVector3 &pos, const LVector4 &frame1, const LVector4 &frame2, PN_stdfloat blend, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation)
Works just like particle but accepts 2 frames and a blend (from 0 to 1) component between them Frame ...
Definition: meshDrawer.cxx:195
void cross_segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color)
Draws a segment a line with a thickness.
Definition: meshDrawer.cxx:260
LVector3 get_relative_vector(const NodePath &other, const LVecBase3 &vec) const
Given that the indicated vector is in the coordinate system of the other node, returns the same vecto...
Definition: nodePath.cxx:2212
void tri(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)
Draws a triangle with the given parameters.
Definition: meshDrawer.I:90
This is a two-component vector offset.
Definition: lvector2.h:91
void particle(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation)
Draws a particle that is sort of like a bill board but has an extra rotation component.
Definition: meshDrawer.cxx:163
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
NodePathCollection find_all_matches(const string &path) const
Returns the complete set of all NodePaths that begin with this NodePath and can be extended by path...
Definition: nodePath.cxx:480
Defines a series of disconnected triangles.
Definition: geomTriangles.h:25
void link_segment_end(const LVector4 &frame, const LVector4 &color)
Finish drawing linked segments, needs at least two calls to link_segment before it can end the linked...
Definition: meshDrawer.cxx:560
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
LPoint3 get_relative_point(const NodePath &other, const LVecBase3 &point) const
Given that the indicated point is in the coordinate system of the other node, returns the same point ...
Definition: nodePath.cxx:2198
This is a two-component point in space.
Definition: lpoint2.h:92
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A node that can be positioned around in the scene graph to represent a point of view for rendering a ...
Definition: camera.h:37
void begin(NodePath camera, NodePath render)
Pass the current camera node and the root node.
Definition: meshDrawer.cxx:90
void uneven_segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness_start, const LVector4 &color_start, PN_stdfloat thickness_stop, const LVector4 &color_stop)
Draws a segment a line with different thickness and color on both sides.
Definition: meshDrawer.cxx:305
void geometry(NodePath node)
Draws the geometry that is inside this node path into the MeshDrawer object.
Definition: meshDrawer.cxx:391
bool normalize()
Normalizes the vector in place.
Definition: lvecBase3.h:782
void link_segment(const LVector3 &pos, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color)
Stars or continues linked segment.
Definition: meshDrawer.cxx:458
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37
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...
Definition: nodePath.cxx:723
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter, combined together into one convenient package.
This is a set of zero or more NodePaths.