Panda3D
cardMaker.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file cardMaker.I
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 /**
15  *
16  */
17 INLINE CardMaker::
18 CardMaker(const std::string &name) : Namable(name) {
19  reset();
20 }
21 
22 /**
23  *
24  */
25 INLINE CardMaker::
26 ~CardMaker() {
27 }
28 
29 /**
30  * Sets the flag indicating whether vertices will be generated with UV's or
31  * not.
32  */
33 INLINE void CardMaker::
34 set_has_uvs(bool flag) {
35  _has_uvs = flag;
36 }
37 
38 /**
39  * Sets the flag indicating whether vertices will be generated with
40  * 3-component UVW's (true) or 2-component UV's (the default, false).
41  * Normally, this will be implicitly set by setting the uv_range.
42  */
43 INLINE void CardMaker::
44 set_has_3d_uvs(bool flag) {
45  _has_3d_uvs = flag;
46 }
47 
48 /**
49  * Sets the size of the card.
50  */
51 INLINE void CardMaker::
52 set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
53  _ll_pos = LVector3::rfu(left, 0.0f, bottom);
54  _lr_pos = LVector3::rfu(right, 0.0f, bottom);
55  _ur_pos = LVector3::rfu(right, 0.0f, top);
56  _ul_pos = LVector3::rfu(left, 0.0f, top);
57 }
58 
59 /**
60  * Sets the size of the card.
61  */
62 INLINE void CardMaker::
63 set_frame(const LVecBase4 &frame) {
64  set_frame(frame[0], frame[1], frame[2], frame[3]);
65 }
66 
67 /**
68  * Sets the size of the card.
69  */
70 INLINE void CardMaker::
71 set_frame(const LVertex &ll, const LVertex &lr, const LVertex &ur, const LVertex &ul) {
72  _ll_pos = ll;
73  _lr_pos = lr;
74  _ur_pos = ur;
75  _ul_pos = ul;
76 }
77 
78 /**
79  * Sets the card to (-1,1,-1,1), which is appropriate if you plan to parent it
80  * to render2d and use it as a fullscreen quad.
81  */
82 INLINE void CardMaker::
84  set_frame(-1.0f, 1.0f, -1.0f, 1.0f);
85 }
86 
87 /**
88  * Sets the color of the card.
89  */
90 INLINE void CardMaker::
91 set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) {
92  set_color(LVecBase4(r, g, b, a));
93 }
94 
95 /**
96  * Sets the color of the card.
97  */
98 INLINE void CardMaker::
99 set_color(const LVecBase4 &color) {
100  _color = color;
101  _has_color = true;
102 }
103 
104 /**
105  * Sets the flag indicating whether vertices will be generated with normals or
106  * not. Normals are required if you intend to enable lighting on the card,
107  * but are just wasted space and bandwidth otherwise, so there is a (slight)
108  * optimization for disabling them. If enabled, the normals will be generated
109  * perpendicular to the card's face.
110  */
111 INLINE void CardMaker::
112 set_has_normals(bool flag) {
113  _has_normals = flag;
114 }
115 
116 /**
117  * Sets a node that will be copied (and scaled and translated) to generate the
118  * frame, instead of generating a new polygon. The node may contain arbitrary
119  * geometry that describes a flat polygon contained within the indicated left,
120  * right, bottom, top frame.
121  *
122  * When generate() is called, the geometry in this node will be scaled and
123  * translated appropriately to give it the size and aspect ratio specified by
124  * set_frame().
125  */
126 INLINE void CardMaker::
127 set_source_geometry(PandaNode *node, const LVecBase4 &frame) {
128  _source_geometry = node;
129  _source_frame = frame;
130 }
131 
132 /**
133  * Removes the node specified by an earlier call to set_source_geometry().
134  */
135 INLINE void CardMaker::
137  _source_geometry = nullptr;
138 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a)
Sets the color of the card.
Definition: cardMaker.I:91
void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the size of the card.
Definition: cardMaker.I:52
void set_has_uvs(bool flag)
Sets the flag indicating whether vertices will be generated with UV's or not.
Definition: cardMaker.I:34
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:83
A base class for all things which can have a name.
Definition: namable.h:26
void clear_source_geometry()
Removes the node specified by an earlier call to set_source_geometry().
Definition: cardMaker.I:136
void set_source_geometry(PandaNode *node, const LVecBase4 &frame)
Sets a node that will be copied (and scaled and translated) to generate the frame,...
Definition: cardMaker.I:127
void set_has_normals(bool flag)
Sets the flag indicating whether vertices will be generated with normals or not.
Definition: cardMaker.I:112
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:44
void reset()
Resets all the parameters to their initial defaults.
Definition: cardMaker.cxx:28