30 set_uv_range(LTexCoord(0.0f, 0.0f), LTexCoord(1.0f, 1.0f));
33 _color.set(1.0f, 1.0f, 1.0f, 1.0f);
36 _source_geometry =
nullptr;
37 _source_frame.set(0.0f, 0.0f, 0.0f, 0.0f);
46 if (_source_geometry !=
nullptr) {
47 return rescale_source_geometry();
56 format = GeomVertexFormat::register_format
58 (InternalName::get_vertex(), 3,
59 GeomEnums::NT_stdfloat, GeomEnums::C_point,
60 InternalName::get_normal(), 3,
61 GeomEnums::NT_stdfloat, GeomEnums::C_normal,
62 InternalName::get_texcoord(), 3,
63 GeomEnums::NT_stdfloat, GeomEnums::C_texcoord));
73 format = GeomVertexFormat::register_format
75 (InternalName::get_vertex(), 3,
76 GeomEnums::NT_stdfloat, GeomEnums::C_point,
77 InternalName::get_texcoord(), 3,
78 GeomEnums::NT_stdfloat, GeomEnums::C_texcoord));
88 (
"card", format, Geom::UH_static);
107 n = (_ll_pos - _ul_pos).cross(_ur_pos - _ul_pos);
110 n = (_lr_pos - _ll_pos).cross(_ul_pos - _ll_pos);
113 n = (_ul_pos - _ur_pos).cross(_lr_pos - _ur_pos);
116 n = (_ur_pos - _lr_pos).cross(_ll_pos - _lr_pos);
122 strip->set_shade_model(Geom::SM_uniform);
123 strip->add_next_vertices(4);
124 strip->close_primitive();
127 geom->add_primitive(strip);
129 CPT(
RenderState) state = RenderState::make_empty();
131 state = RenderState::make(ColorAttrib::make_flat(_color));
134 gnode->add_geom(geom, state);
146 set_uv_range(
const LTexCoord3 &ll,
const LTexCoord3 &lr,
const LTexCoord3 &ur,
const LTexCoord3 &ul) {
162 set_uv_range(
const LTexCoord &ll,
const LTexCoord &lr,
const LTexCoord &ur,
const LTexCoord &ul) {
163 _ll_tex.set(ll[0], ll[1], 0.0f);
164 _lr_tex.set(lr[0], lr[1], 0.0f);
165 _ur_tex.set(ur[0], ur[1], 0.0f);
166 _ul_tex.set(ul[0], ul[1], 0.0f);
179 _ll_tex.set(ll[0], ll[1], 0.0f);
180 _lr_tex.set(ur[0], ll[1], 0.0f);
181 _ur_tex.set(ur[0], ur[1], 0.0f);
182 _ul_tex.set(ll[0], ur[1], 0.0f);
194 set_uv_range(
const LVector4 &x,
const LVector4 &y,
const LVector4 &z) {
195 _ll_tex.set(x[0], y[0], z[0]);
196 _lr_tex.set(x[1], y[1], z[1]);
197 _ur_tex.set(x[2], y[2], z[2]);
198 _ul_tex.set(x[3], y[3], z[3]);
209 LVector4 varya(-1, 1, 1, -1);
210 LVector4 varyb(-1, -1, 1, 1);
211 LVector4 fixed( 1, 1, 1, 1);
231 double maxu = (nonpadx*1.0) / tex->
get_x_size();
232 double maxv = (nonpady*1.0) / tex->
get_y_size();
240 rescale_source_geometry() {
241 PT(
PandaNode) root = _source_geometry->copy_subgraph();
244 LVector3 frame_max = _ll_pos.fmax(_lr_pos.fmax(_ur_pos.fmax(_ul_pos)));
245 LVector3 frame_min = _ll_pos.fmin(_lr_pos.fmin(_ur_pos.fmax(_ul_pos)));
246 LVector3 frame_ctr = (frame_max + frame_min) * 0.5f;
248 LVector3 geom_center((_source_frame[0] + _source_frame[1]) * 0.5f,
250 (_source_frame[2] + _source_frame[3]) * 0.5f);
252 LVector3 scale((frame_max[0] - frame_min[0]) / (_source_frame[1] - _source_frame[0]),
254 (frame_max[2] - frame_min[2]) / (_source_frame[3] - _source_frame[2]));
256 LVector3 trans = frame_ctr - geom_center;
259 TransformState::make_pos_hpr_scale(trans, LPoint3(0.0f, 0.0f, 0.0f), scale);
260 root->set_transform(transform);
263 root->set_attrib(ColorAttrib::make_flat(_color));
get_y_size
Returns the height of the texture image in texels.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_pad_y_size() const
Returns size of the pad region.
void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the size of the card.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
get_texture_type
Returns the overall interpretation of the texture.
An interface for simplifying ("flattening") scene graphs by eliminating unneeded nodes and collapsing...
Defines a series of triangle strips.
int get_pad_x_size() const
Returns size of the pad region.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_uv_range_cube(int face)
Sets the range of UV's that will be applied to the vertices appropriately for a cube-map face.
PT(PandaNode) CardMaker
Generates a GeomNode that renders the specified geometry.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A container for geometry primitives.
void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row.
int flatten(PandaNode *root, int combine_siblings_bits)
Simplifies the graph by removing unnecessary nodes and nodes.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void apply_attribs(PandaNode *node, int attrib_types=~(TT_clip_plane|TT_cull_face|TT_apply_texture_color))
Walks the scene graph, accumulating attribs of the indicated types, applying them to the vertices,...
void set_uv_range(const LTexCoord &ll, const LTexCoord &ur)
Sets the range of UV's that will be applied to the vertices.
A node that holds Geom objects, renderable pieces of geometry.
get_x_size
Returns the width of the texture image in texels.
void reset()
Resets all the parameters to their initial defaults.