Panda3D

meshDrawer.I

00001 // Filename: meshDrawer.I
00002 // Created by:  treeform (19dec08)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "lpoint2.h"
00016 
00017 ////////////////////////////////////////////////////////////////////
00018 //     Function: MeshDrawer::Constructor
00019 //       Access: Published
00020 //  Description: Creates the MeshDrawer low level system.
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE MeshDrawer::
00023 MeshDrawer() {
00024   _root = NodePath("MeshDrawer");
00025   _at_start = 0;
00026   _bv = NULL;
00027   _vertex = NULL;
00028   _normal = NULL;
00029   _uv = NULL;
00030   _color = NULL;
00031   _budget = 5000;
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: MeshDrawer::Destructor
00036 //       Access: Published
00037 //  Description: Destroys the MeshDrawer low level system.
00038 ////////////////////////////////////////////////////////////////////
00039 INLINE MeshDrawer::
00040 ~MeshDrawer() {
00041   _root.remove_node();
00042   if (_vertex != NULL) delete _vertex;
00043   if (_normal != NULL) delete _normal;
00044   if (_uv != NULL)     delete _uv;
00045   if (_color != NULL)  delete _color;
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: MeshDrawer::get_root
00050 //       Access: Published
00051 //  Description: Returns the root NodePath.  You should use this node
00052 //               to reparent mesh drawer onto the scene
00053 //               might also want to disable depth draw or enable
00054 //               transparency.
00055 ////////////////////////////////////////////////////////////////////
00056 INLINE NodePath MeshDrawer::
00057 get_root() {
00058   return _root;
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: MeshDrawer::set_budget
00063 //       Access: Published
00064 //  Description: Sets the total triangle budget of the drawer.
00065 //               This will not be exceeded.  Don't set some thing too 
00066 //               large because it will be slow
00067 ////////////////////////////////////////////////////////////////////
00068 INLINE void MeshDrawer::
00069 set_budget(int total_budget) {
00070   _budget = total_budget;
00071   generator(_budget);
00072 }
00073 
00074 ////////////////////////////////////////////////////////////////////
00075 //     Function: MeshDrawer::get_budget()
00076 //       Access: Published
00077 //  Description: Gets the total triangle budget of the drawer
00078 ////////////////////////////////////////////////////////////////////
00079 INLINE int MeshDrawer::
00080 get_budget() {
00081   return _budget;
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: MeshDrawer::tri
00086 //       Access: Published
00087 //  Description: Draws a triangle with the given parameters.
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE void MeshDrawer::tri(const LVector3 &v1, const LVector4 &c1, const LVector2 &uv1,
00090                             const LVector3 &v2, const LVector4 &c2, const LVector2 &uv2,
00091                             const LVector3 &v3, const LVector4 &c3, const LVector2 &uv3) {
00092 
00093   if( _clear_index > _end_clear_index) return;
00094 
00095   _vertex->add_data3(v1);
00096   _color->add_data4(c1);
00097   _uv->add_data2(uv1);
00098 
00099   _vertex->add_data3(v2);
00100   _color->add_data4(c2);
00101   _uv->add_data2(uv2);
00102 
00103   _vertex->add_data3(v3);
00104   _color->add_data4(c3);
00105   _uv->add_data2(uv3);
00106 
00107   _clear_index += 1;
00108 }
 All Classes Functions Variables Enumerations