51 get_geom(Geom::UsageHint usage_hint)
const {
52 if (_geom.is_null()) {
56 if (_geom.is_null()) {
71 new_geom->set_usage_hint(usage_hint);
73 nassertr(vdata !=
nullptr, new_geom);
75 new_geom->modify_vertex_data()->set_usage_hint(usage_hint);
87 calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point,
88 bool &found_any,
Thread *current_thread)
const {
91 min_point.set(_quad_dimensions[0], 0, _quad_dimensions[1]);
92 max_point.set(_quad_dimensions[2], 0, _quad_dimensions[3]);
94 }
else if (!_geom.is_null()) {
95 _geom->calc_tight_bounds(min_point, max_point, found_any, current_thread);
104 set_quad(
const LVecBase4 &dimensions,
const LVecBase4 &texcoords,
108 _quad_dimensions = dimensions;
109 _quad_texcoords = texcoords;
122 geom->add_primitive(prim);
141 if (vdata->get_num_rows() != 4) {
146 if (_geom->get_num_primitives() != 1) {
150 if (!prim->is_indexed() ||
151 prim->get_primitive_type() != GeomPrimitive::PT_polygons) {
154 if (!prim->is_of_type(GeomTriangles::get_class_type())) {
155 prim = prim->decompose();
157 if (prim->get_num_vertices() != 6) {
163 if (format->get_num_columns() > 2 ||
164 !format->has_column(InternalName::get_vertex())) {
167 if (format->has_column(InternalName::get_texcoord()) != (format->get_num_columns() == 2)) {
174 LVecBase3 v = vertex.get_data3();
175 if (!IS_NEARLY_ZERO(v[1])) {
178 PN_stdfloat minx = v[0];
179 PN_stdfloat maxx = v[0];
180 PN_stdfloat miny = v[2];
181 PN_stdfloat maxy = v[2];
183 for (
int i = 0; i < 3; ++i) {
184 v = vertex.get_data3();
185 if (!IS_NEARLY_ZERO(v[1])) {
188 if (!IS_NEARLY_EQUAL(v[0], minx) && !IS_NEARLY_EQUAL(v[0], maxx)) {
189 if (!IS_NEARLY_EQUAL(minx, maxx)) {
192 minx = min(v[0], minx);
193 maxx = max(v[0], maxx);
195 if (!IS_NEARLY_EQUAL(v[2], miny) && !IS_NEARLY_EQUAL(v[2], maxy)) {
196 if (!IS_NEARLY_EQUAL(miny, maxy)) {
199 miny = min(v[2], miny);
200 maxy = max(v[2], maxy);
204 PN_stdfloat minu = 0;
205 PN_stdfloat maxu = 0;
206 PN_stdfloat minv = 0;
207 PN_stdfloat maxv = 0;
210 if (format->has_column(InternalName::get_texcoord())) {
212 LVecBase2 tc = texcoord.get_data2();
218 for (
int i = 0; i < 3; ++i) {
219 tc = texcoord.get_data2();
220 if (!IS_NEARLY_EQUAL(tc[0], minu) && !IS_NEARLY_EQUAL(tc[0], maxu)) {
221 if (!IS_NEARLY_EQUAL(minu, maxu)) {
224 minu = min(tc[0], minu);
225 maxu = max(tc[0], maxu);
227 if (!IS_NEARLY_EQUAL(tc[1], minv) && !IS_NEARLY_EQUAL(tc[1], maxv)) {
228 if (!IS_NEARLY_EQUAL(minv, maxv)) {
231 minv = min(tc[1], minv);
232 maxv = max(tc[1], maxv);
237 _quad_dimensions.set(minx, miny, maxx, maxy);
238 _quad_texcoords.set(minu, minv, maxu, maxv);
249 LVecBase4 dimensions, uvs;
259 vdata->unclean_set_num_rows(4);
268 indices->unclean_set_num_rows(6);
272 vertex.set_data3(dimensions[0], 0, dimensions[3]);
273 vertex.set_data3(dimensions[0], 0, dimensions[1]);
274 vertex.set_data3(dimensions[2], 0, dimensions[3]);
275 vertex.set_data3(dimensions[2], 0, dimensions[1]);
277 texcoord.set_data2(uvs[0], uvs[3]);
278 texcoord.set_data2(uvs[0], uvs[1]);
279 texcoord.set_data2(uvs[2], uvs[3]);
280 texcoord.set_data2(uvs[2], uvs[1]);
294 geom->add_primitive(tris);
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.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
void set_geom(GeomVertexData *vdata, GeomPrimitive *prim, const RenderState *state)
Sets the geom from a pre-built Geom object.
virtual bool is_whitespace() const
Returns true if this glyph represents invisible whitespace, or false if it corresponds to some visibl...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
A representation of a single glyph (character) from a font.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PT(Geom) TextGlyph
Returns a Geom that renders the particular glyph.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A thread; that is, a lightweight process.
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
Defines a series of disconnected triangles.
get_usage_hint
Returns the usage hint that was passed to the constructor, and which will be passed to each array dat...
TypeHandle is the identifier used to differentiate C++ class types.
This is a specialization on Geom for containing a primitive intended to represent a TextGlyph.
bool get_quad(LVecBase4 &dimensions, LVecBase4 &texcoords) const
Assuming that this glyph is representable as a textured quad, returns its dimensions and UV range.
This is the data for one array of a GeomVertexData structure.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.