Panda3D
 All Classes Functions Variables Enumerations
cardMaker.I
1 // Filename: cardMaker.I
2 // Created by: drose (16Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: CardMaker::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE CardMaker::
22 CardMaker(const string &name) : Namable(name) {
23  reset();
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: CardMaker::Destructor
28 // Access: Public
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 INLINE CardMaker::
32 ~CardMaker() {
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: CardMaker::set_has_uvs
37 // Access: Public
38 // Description: Sets the flag indicating whether vertices will be
39 // generated with UV's or not.
40 ////////////////////////////////////////////////////////////////////
41 INLINE void CardMaker::
42 set_has_uvs(bool flag) {
43  _has_uvs = flag;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: CardMaker::set_has_3d_uvs
48 // Access: Public
49 // Description: Sets the flag indicating whether vertices will be
50 // generated with 3-component UVW's (true) or
51 // 2-component UV's (the default, false). Normally,
52 // this will be implicitly set by setting the uv_range.
53 ////////////////////////////////////////////////////////////////////
54 INLINE void CardMaker::
55 set_has_3d_uvs(bool flag) {
56  _has_3d_uvs = flag;
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: CardMaker::set_frame
61 // Access: Public
62 // Description: Sets the size of the card.
63 ////////////////////////////////////////////////////////////////////
64 INLINE void CardMaker::
65 set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
66  _ll_pos = LVector3::rfu(left, 0.0f, bottom);
67  _lr_pos = LVector3::rfu(right, 0.0f, bottom);
68  _ur_pos = LVector3::rfu(right, 0.0f, top);
69  _ul_pos = LVector3::rfu(left, 0.0f, top);
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: CardMaker::set_frame
74 // Access: Public
75 // Description: Sets the size of the card.
76 ////////////////////////////////////////////////////////////////////
77 INLINE void CardMaker::
78 set_frame(const LVecBase4 &frame) {
79  set_frame(frame[0], frame[1], frame[2], frame[3]);
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: CardMaker::set_frame
84 // Access: Public
85 // Description: Sets the size of the card.
86 ////////////////////////////////////////////////////////////////////
87 INLINE void CardMaker::
88 set_frame(const LVertex &ll, const LVertex &lr, const LVertex &ur, const LVertex &ul) {
89  _ll_pos = ll;
90  _lr_pos = lr;
91  _ur_pos = ur;
92  _ul_pos = ul;
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: CardMaker::set_frame_fullscreen_quad
97 // Access: Public
98 // Description: Sets the card to (-1,1,-1,1), which is appropriate
99 // if you plan to parent it to render2d and use it
100 // as a fullscreen quad.
101 ////////////////////////////////////////////////////////////////////
102 INLINE void CardMaker::
104  set_frame(-1.0f, 1.0f, -1.0f, 1.0f);
105 }
106 
107 ////////////////////////////////////////////////////////////////////
108 // Function: CardMaker::set_color
109 // Access: Public
110 // Description: Sets the color of the card.
111 ////////////////////////////////////////////////////////////////////
112 INLINE void CardMaker::
113 set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
114  set_color(LVecBase4(r, g, b, a));
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: CardMaker::set_color
119 // Access: Public
120 // Description: Sets the color of the card.
121 ////////////////////////////////////////////////////////////////////
122 INLINE void CardMaker::
124  _color = color;
125  _has_color = true;
126 }
127 
128 ////////////////////////////////////////////////////////////////////
129 // Function: CardMaker::set_has_normals
130 // Access: Public
131 // Description: Sets the flag indicating whether vertices will be
132 // generated with normals or not. Normals are required
133 // if you intend to enable lighting on the card, but are
134 // just wasted space and bandwidth otherwise, so there
135 // is a (slight) optimization for disabling them. If
136 // enabled, the normals will be generated perpendicular
137 // to the card's face.
138 ////////////////////////////////////////////////////////////////////
139 INLINE void CardMaker::
140 set_has_normals(bool flag) {
141  _has_normals = flag;
142 }
143 
144 ////////////////////////////////////////////////////////////////////
145 // Function: CardMaker::set_source_geometry
146 // Access: Published
147 // Description: Sets a node that will be copied (and scaled and
148 // translated) to generate the frame, instead of
149 // generating a new polygon. The node may contain
150 // arbitrary geometry that describes a flat polygon
151 // contained within the indicated left, right, bottom,
152 // top frame.
153 //
154 // When generate() is called, the geometry in this node
155 // will be scaled and translated appropriately to give
156 // it the size and aspect ratio specified by
157 // set_frame().
158 ////////////////////////////////////////////////////////////////////
159 INLINE void CardMaker::
161  _source_geometry = node;
162  _source_frame = frame;
163 }
164 
165 ////////////////////////////////////////////////////////////////////
166 // Function: CardMaker::clear_source_geometry
167 // Access: Published
168 // Description: Removes the node specified by an earlier call to
169 // set_source_geometry().
170 ////////////////////////////////////////////////////////////////////
171 INLINE void CardMaker::
173  _source_geometry = (PandaNode *)NULL;
174 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a)
Sets the color of the card.
Definition: cardMaker.I:113
void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the size of the card.
Definition: cardMaker.I:65
void set_has_uvs(bool flag)
Sets the flag indicating whether vertices will be generated with UV's or not.
Definition: cardMaker.I:42
static LVector3f rfu(float right, float fwd, float up, CoordinateSystem cs=CS_default)
Returns a vector that is described by its right, forward, and up components, in whatever way the coor...
Definition: lvector3.h:631
void set_frame_fullscreen_quad()
Sets the card to (-1,1,-1,1), which is appropriate if you plan to parent it to render2d and use it as...
Definition: cardMaker.I:103
A base class for all things which can have a name.
Definition: namable.h:29
void clear_source_geometry()
Removes the node specified by an earlier call to set_source_geometry().
Definition: cardMaker.I:172
void set_source_geometry(PandaNode *node, const LVecBase4 &frame)
Sets a node that will be copied (and scaled and translated) to generate the frame, instead of generating a new polygon.
Definition: cardMaker.I:160
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
void set_has_normals(bool flag)
Sets the flag indicating whether vertices will be generated with normals or not.
Definition: cardMaker.I:140
void set_has_3d_uvs(bool flag)
Sets the flag indicating whether vertices will be generated with 3-component UVW's (true) or 2-compon...
Definition: cardMaker.I:55
void reset()
Resets all the parameters to their initial defaults.
Definition: cardMaker.cxx:31