Panda3D
|
00001 // Filename: cardMaker.I 00002 // Created by: drose (16Mar02) 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: CardMaker::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE CardMaker:: 00022 CardMaker(const string &name) : Namable(name) { 00023 reset(); 00024 } 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Function: CardMaker::Destructor 00028 // Access: Public 00029 // Description: 00030 //////////////////////////////////////////////////////////////////// 00031 INLINE CardMaker:: 00032 ~CardMaker() { 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: CardMaker::set_has_uvs 00037 // Access: Public 00038 // Description: Sets the flag indicating whether vertices will be 00039 // generated with UV's or not. 00040 //////////////////////////////////////////////////////////////////// 00041 INLINE void CardMaker:: 00042 set_has_uvs(bool flag) { 00043 _has_uvs = flag; 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: CardMaker::set_has_3d_uvs 00048 // Access: Public 00049 // Description: Sets the flag indicating whether vertices will be 00050 // generated with 3-component UVW's (true) or 00051 // 2-component UV's (the default, false). Normally, 00052 // this will be implicitly set by setting the uv_range. 00053 //////////////////////////////////////////////////////////////////// 00054 INLINE void CardMaker:: 00055 set_has_3d_uvs(bool flag) { 00056 _has_3d_uvs = flag; 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: CardMaker::set_frame 00061 // Access: Public 00062 // Description: Sets the size of the card. 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE void CardMaker:: 00065 set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { 00066 _ll_pos.set(left, 0.0f, bottom); 00067 _lr_pos.set(right, 0.0f, bottom); 00068 _ur_pos.set(right, 0.0f, top); 00069 _ul_pos.set(left, 0.0f, top); 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: CardMaker::set_frame 00074 // Access: Public 00075 // Description: Sets the size of the card. 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE void CardMaker:: 00078 set_frame(const LVecBase4 &frame) { 00079 set_frame(frame[0], frame[1], frame[2], frame[3]); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: CardMaker::set_frame 00084 // Access: Public 00085 // Description: Sets the size of the card. 00086 //////////////////////////////////////////////////////////////////// 00087 INLINE void CardMaker:: 00088 set_frame(const LVertex &ll, const LVertex &lr, const LVertex &ur, const LVertex &ul) 00089 { 00090 _ll_pos = ll; 00091 _lr_pos = lr; 00092 _ur_pos = ur; 00093 _ul_pos = ul; 00094 } 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function: CardMaker::set_frame_fullscreen_quad 00098 // Access: Public 00099 // Description: Sets the card to (-1,1,-1,1), which is appropriate 00100 // if you plan to parent it to render2d and use it 00101 // as a fullscreen quad. 00102 //////////////////////////////////////////////////////////////////// 00103 INLINE void CardMaker:: 00104 set_frame_fullscreen_quad() 00105 { 00106 set_frame(-1,1,-1,1); 00107 } 00108 00109 //////////////////////////////////////////////////////////////////// 00110 // Function: CardMaker::set_color 00111 // Access: Public 00112 // Description: Sets the color of the card. 00113 //////////////////////////////////////////////////////////////////// 00114 INLINE void CardMaker:: 00115 set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { 00116 set_color(LVecBase4(r, g, b, a)); 00117 } 00118 00119 //////////////////////////////////////////////////////////////////// 00120 // Function: CardMaker::set_color 00121 // Access: Public 00122 // Description: Sets the color of the card. 00123 //////////////////////////////////////////////////////////////////// 00124 INLINE void CardMaker:: 00125 set_color(const LVecBase4 &color) { 00126 _color = color; 00127 _has_color = true; 00128 } 00129 00130 //////////////////////////////////////////////////////////////////// 00131 // Function: CardMaker::set_has_normals 00132 // Access: Public 00133 // Description: Sets the flag indicating whether vertices will be 00134 // generated with normals or not. Normals are required 00135 // if you intend to enable lighting on the card, but are 00136 // just wasted space and bandwidth otherwise, so there 00137 // is a (slight) optimization for disabling them. If 00138 // enabled, the normals will be generated perpendicular 00139 // to the card's face. 00140 //////////////////////////////////////////////////////////////////// 00141 INLINE void CardMaker:: 00142 set_has_normals(bool flag) { 00143 _has_normals = flag; 00144 } 00145 00146 //////////////////////////////////////////////////////////////////// 00147 // Function: CardMaker::set_source_geometry 00148 // Access: Published 00149 // Description: Sets a node that will be copied (and scaled and 00150 // translated) to generate the frame, instead of 00151 // generating a new polygon. The node may contain 00152 // arbitrary geometry that describes a flat polygon 00153 // contained within the indicated left, right, bottom, 00154 // top frame. 00155 // 00156 // When generate() is called, the geometry in this node 00157 // will be scaled and translated appropriately to give 00158 // it the size and aspect ratio specified by 00159 // set_frame(). 00160 //////////////////////////////////////////////////////////////////// 00161 INLINE void CardMaker:: 00162 set_source_geometry(PandaNode *node, const LVecBase4 &frame) { 00163 _source_geometry = node; 00164 _source_frame = frame; 00165 } 00166 00167 //////////////////////////////////////////////////////////////////// 00168 // Function: CardMaker::clear_source_geometry 00169 // Access: Published 00170 // Description: Removes the node specified by an earlier call to 00171 // set_source_geometry(). 00172 //////////////////////////////////////////////////////////////////// 00173 INLINE void CardMaker:: 00174 clear_source_geometry() { 00175 _source_geometry = (PandaNode *)NULL; 00176 }