Panda3D
Loading...
Searching...
No Matches
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 */
17INLINE CardMaker::
18CardMaker(const std::string &name) : Namable(name) {
19 reset();
20}
21
22/**
23 *
24 */
25INLINE CardMaker::
26~CardMaker() {
27}
28
29/**
30 * Sets the flag indicating whether vertices will be generated with UV's or
31 * not.
32 */
33INLINE void CardMaker::
34set_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 */
43INLINE void CardMaker::
44set_has_3d_uvs(bool flag) {
45 _has_3d_uvs = flag;
46}
47
48/**
49 * Sets the size of the card.
50 */
51INLINE void CardMaker::
52set_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 */
62INLINE void CardMaker::
63set_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 */
70INLINE void CardMaker::
71set_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 */
82INLINE void CardMaker::
84 set_frame(-1.0f, 1.0f, -1.0f, 1.0f);
85}
86
87/**
88 * Sets the color of the card.
89 */
90INLINE void CardMaker::
91set_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 */
98INLINE void CardMaker::
99set_color(const LVecBase4 &color) {
100 _color = color;
101 _has_color = true;
102}
103
104/**
105 * Unsets the color of the card.
106 */
107INLINE void CardMaker::
108clear_color() {
109 _has_color = false;
110 _color.set(1.0f, 1.0f, 1.0f, 1.0f);
111}
112
113/**
114 * Sets the flag indicating whether vertices will be generated with normals or
115 * not. Normals are required if you intend to enable lighting on the card,
116 * but are just wasted space and bandwidth otherwise, so there is a (slight)
117 * optimization for disabling them. If enabled, the normals will be generated
118 * perpendicular to the card's face.
119 */
120INLINE void CardMaker::
121set_has_normals(bool flag) {
122 _has_normals = flag;
123}
124
125/**
126 * Sets a node that will be copied (and scaled and translated) to generate the
127 * frame, instead of generating a new polygon. The node may contain arbitrary
128 * geometry that describes a flat polygon contained within the indicated left,
129 * right, bottom, top frame.
130 *
131 * When generate() is called, the geometry in this node will be scaled and
132 * translated appropriately to give it the size and aspect ratio specified by
133 * set_frame().
134 */
135INLINE void CardMaker::
136set_source_geometry(PandaNode *node, const LVecBase4 &frame) {
137 _source_geometry = node;
138 _source_frame = frame;
139}
140
141/**
142 * Removes the node specified by an earlier call to set_source_geometry().
143 */
144INLINE void CardMaker::
146 _source_geometry = nullptr;
147}
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_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 clear_source_geometry()
Removes the node specified by an earlier call to set_source_geometry().
Definition cardMaker.I:145
void clear_color()
Unsets the color of the card.
Definition cardMaker.I:108
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
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:136
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_normals(bool flag)
Sets the flag indicating whether vertices will be generated with normals or not.
Definition cardMaker.I:121
A base class for all things which can have a name.
Definition namable.h:26
A basic node of the scene graph or data graph.
Definition pandaNode.h:65