00001 // Filename: eggCompositePrimitive.I 00002 // Created by: drose (13Mar05) 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 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: EggCompositePrimitive::Constructor 00018 // Access: Published 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE EggCompositePrimitive:: 00022 EggCompositePrimitive(const string &name) : EggPrimitive(name) { 00023 } 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: EggCompositePrimitive::Copy constructor 00027 // Access: Published 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 INLINE EggCompositePrimitive:: 00031 EggCompositePrimitive(const EggCompositePrimitive ©) : EggPrimitive(copy) { 00032 } 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: EggCompositePrimitive::Copy assignment operator 00036 // Access: Published 00037 // Description: 00038 //////////////////////////////////////////////////////////////////// 00039 INLINE EggCompositePrimitive &EggCompositePrimitive:: 00040 operator = (const EggCompositePrimitive ©) { 00041 EggPrimitive::operator = (copy); 00042 return *this; 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: EggCompositePrimitive::get_num_components 00047 // Access: Published 00048 // Description: Returns the number of individual component triangles 00049 // within the composite. Each one of these might have a 00050 // different set of attributes. 00051 //////////////////////////////////////////////////////////////////// 00052 INLINE int EggCompositePrimitive:: 00053 get_num_components() const { 00054 return _components.size(); 00055 } 00056 00057 //////////////////////////////////////////////////////////////////// 00058 // Function: EggCompositePrimitive::get_component 00059 // Access: Published 00060 // Description: Returns the attributes for the nth component 00061 // triangle. 00062 //////////////////////////////////////////////////////////////////// 00063 INLINE const EggAttributes *EggCompositePrimitive:: 00064 get_component(int i) const { 00065 nassertr(i >= 0 && i < (int)_components.size(), NULL); 00066 return _components[i]; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: EggCompositePrimitive::get_component 00071 // Access: Published 00072 // Description: Returns the attributes for the nth component 00073 // triangle. 00074 //////////////////////////////////////////////////////////////////// 00075 INLINE EggAttributes *EggCompositePrimitive:: 00076 get_component(int i) { 00077 nassertr(i >= 0 && i < (int)_components.size(), NULL); 00078 return _components[i]; 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: EggCompositePrimitive::set_component 00083 // Access: Published 00084 // Description: Changes the attributes for the nth component 00085 // triangle. 00086 //////////////////////////////////////////////////////////////////// 00087 INLINE void EggCompositePrimitive:: 00088 set_component(int i, const EggAttributes *attrib) { 00089 nassertv(i >= 0 && i < (int)_components.size()); 00090 _components[i] = new EggAttributes(*attrib); 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: EggCompositePrimitive::triangulate_into 00095 // Access: Published 00096 // Description: Subdivides the composite primitive into triangles and 00097 // adds those triangles to the indicated container. 00098 // Does not remove the primitive from its existing 00099 // parent or modify it in any way. 00100 // 00101 // Returns true if the triangulation is successful, or 00102 // false if there was some error (in which case the 00103 // container may contain some partial triangulation). 00104 //////////////////////////////////////////////////////////////////// 00105 INLINE bool EggCompositePrimitive:: 00106 triangulate_into(EggGroupNode *container) const { 00107 return do_triangulate(container); 00108 }