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