Panda3D
meshDrawer.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file meshDrawer.I
10  * @author treeform
11  * @date 2008-12-19
12  */
13 
14 #include "lpoint2.h"
15 
16 /**
17  * Creates the MeshDrawer low level system.
18  */
19 INLINE MeshDrawer::
21  _root = NodePath("MeshDrawer");
22  _at_start = 0;
23  _bv = nullptr;
24  _vertex = nullptr;
25  _normal = nullptr;
26  _uv = nullptr;
27  _color = nullptr;
28  _budget = 5000;
29  _vdata = nullptr;
30 }
31 
32 /**
33  * Destroys the MeshDrawer low level system.
34  */
35 INLINE MeshDrawer::
37  _root.remove_node();
38  if (_vertex != nullptr) delete _vertex;
39  if (_normal != nullptr) delete _normal;
40  if (_uv != nullptr) delete _uv;
41  if (_color != nullptr) delete _color;
42 }
43 
44 /**
45  * Returns the root NodePath. You should use this node to reparent mesh
46  * drawer onto the scene might also want to disable depth draw or enable
47  * transparency.
48  */
51  return _root;
52 }
53 
54 /**
55  * Sets the total triangle budget of the drawer. This will not be exceeded.
56  * Don't set some thing too large because it will be slow
57  */
58 INLINE void MeshDrawer::
59 set_budget(int total_budget) {
60  _budget = total_budget;
61  generator(_budget);
62 }
63 
64 /**
65  * Gets the total triangle budget of the drawer
66  */
67 INLINE int MeshDrawer::
69  return _budget;
70 }
71 
72 /**
73  * Draws a triangle with the given parameters.
74  */
75 INLINE void MeshDrawer::tri(const LVector3 &v1, const LVector4 &c1, const LVector2 &uv1,
76  const LVector3 &v2, const LVector4 &c2, const LVector2 &uv2,
77  const LVector3 &v3, const LVector4 &c3, const LVector2 &uv3) {
78 
79  if( _clear_index > _end_clear_index) return;
80 
81  _vertex->add_data3(v1);
82  _color->add_data4(c1);
83  _uv->add_data2(uv1);
84 
85  _vertex->add_data3(v2);
86  _color->add_data4(c2);
87  _uv->add_data2(uv2);
88 
89  _vertex->add_data3(v3);
90  _color->add_data4(c3);
91  _uv->add_data2(uv3);
92 
93  _clear_index += 1;
94 }
void set_budget(int budget)
Sets the total triangle budget of the drawer.
Definition: meshDrawer.I:59
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_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.
MeshDrawer()
Creates the MeshDrawer low level system.
Definition: meshDrawer.I:20
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_root()
Returns the root NodePath.
Definition: meshDrawer.I:50
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:75
void remove_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from the scene graph.
Definition: nodePath.cxx:591
~MeshDrawer()
Destroys the MeshDrawer low level system.
Definition: meshDrawer.I:36
int get_budget()
Gets the total triangle budget of the drawer.
Definition: meshDrawer.I:68
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161