Panda3D
 All Classes Functions Variables Enumerations
cardMaker.I
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 = LVector3::rfu(left,  0.0f, bottom);
00067   _lr_pos = LVector3::rfu(right, 0.0f, bottom);
00068   _ur_pos = LVector3::rfu(right, 0.0f, top);
00069   _ul_pos = LVector3::rfu(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   _ll_pos = ll;
00090   _lr_pos = lr;
00091   _ur_pos = ur;
00092   _ul_pos = ul;
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: CardMaker::set_frame_fullscreen_quad
00097 //       Access: Public
00098 //  Description: Sets the card to (-1,1,-1,1), which is appropriate
00099 //               if you plan to parent it to render2d and use it
00100 //               as a fullscreen quad.
00101 ////////////////////////////////////////////////////////////////////
00102 INLINE void CardMaker::
00103 set_frame_fullscreen_quad() {
00104   set_frame(-1.0f, 1.0f, -1.0f, 1.0f);
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //     Function: CardMaker::set_color
00109 //       Access: Public
00110 //  Description: Sets the color of the card.
00111 ////////////////////////////////////////////////////////////////////
00112 INLINE void CardMaker::
00113 set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
00114   set_color(LVecBase4(r, g, b, a));
00115 } 
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: CardMaker::set_color
00119 //       Access: Public
00120 //  Description: Sets the color of the card.
00121 ////////////////////////////////////////////////////////////////////
00122 INLINE void CardMaker::
00123 set_color(const LVecBase4 &color) {
00124   _color = color;
00125   _has_color = true;
00126 }
00127 
00128 ////////////////////////////////////////////////////////////////////
00129 //     Function: CardMaker::set_has_normals
00130 //       Access: Public
00131 //  Description: Sets the flag indicating whether vertices will be
00132 //               generated with normals or not.  Normals are required
00133 //               if you intend to enable lighting on the card, but are
00134 //               just wasted space and bandwidth otherwise, so there
00135 //               is a (slight) optimization for disabling them.  If
00136 //               enabled, the normals will be generated perpendicular
00137 //               to the card's face.
00138 ////////////////////////////////////////////////////////////////////
00139 INLINE void CardMaker::
00140 set_has_normals(bool flag) {
00141   _has_normals = flag;
00142 }
00143 
00144 ////////////////////////////////////////////////////////////////////
00145 //     Function: CardMaker::set_source_geometry
00146 //       Access: Published
00147 //  Description: Sets a node that will be copied (and scaled and
00148 //               translated) to generate the frame, instead of
00149 //               generating a new polygon.  The node may contain
00150 //               arbitrary geometry that describes a flat polygon
00151 //               contained within the indicated left, right, bottom,
00152 //               top frame.
00153 //
00154 //               When generate() is called, the geometry in this node
00155 //               will be scaled and translated appropriately to give
00156 //               it the size and aspect ratio specified by
00157 //               set_frame().
00158 ////////////////////////////////////////////////////////////////////
00159 INLINE void CardMaker::
00160 set_source_geometry(PandaNode *node, const LVecBase4 &frame) {
00161   _source_geometry = node;
00162   _source_frame = frame;
00163 }
00164 
00165 ////////////////////////////////////////////////////////////////////
00166 //     Function: CardMaker::clear_source_geometry
00167 //       Access: Published
00168 //  Description: Removes the node specified by an earlier call to
00169 //               set_source_geometry().
00170 ////////////////////////////////////////////////////////////////////
00171 INLINE void CardMaker::
00172 clear_source_geometry() {
00173   _source_geometry = (PandaNode *)NULL;
00174 }
 All Classes Functions Variables Enumerations