Panda3D
Loading...
Searching...
No Matches
qtessSurface.h
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 qtessSurface.h
10 * @author drose
11 * @date 2003-10-13
12 */
13
14#ifndef QTESSSURFACE_H
15#define QTESSSURFACE_H
16
17#include "pandatoolbase.h"
18#include "isoPlacer.h"
19#include "eggNurbsSurface.h"
20#include "eggGroup.h"
21#include "eggVertex.h"
23#include "nurbsSurfaceResult.h"
24#include "referenceCount.h"
25#include "pointerTo.h"
26
27/**
28 * A reference to an EggNurbsSurface in the egg file, and its parameters as
29 * set by the user input file and as computed in relation to the other
30 * surfaces.
31 */
33public:
34 QtessSurface(EggNurbsSurface *egg_surface);
35
36 INLINE const std::string &get_name() const;
37 INLINE bool is_valid() const;
38
39 INLINE void set_importance(double importance2);
40 INLINE void set_match_u(QtessSurface **match_u, bool match_u_to_u);
41 INLINE void set_match_v(QtessSurface **match_v, bool match_v_to_v);
42 INLINE void set_min_u(int min_u);
43 INLINE void set_min_v(int min_v);
44
45 INLINE double count_patches() const;
46 INLINE int count_tris() const;
47
48 double get_score(double ratio);
49
50 int tesselate();
51 int write_qtess_parameter(std::ostream &out);
52 void omit();
53 void tesselate_uv(int u, int v, bool autoplace, double ratio);
54 void tesselate_specific(const pvector<double> &u_list,
55 const pvector<double> &v_list);
56 void tesselate_per_isoparam(double pi, bool autoplace, double ratio);
57 void tesselate_per_score(double pi, bool autoplace, double ratio);
58 void tesselate_auto(int u, int v, double ratio);
59
60private:
61 void record_vertex_extras();
62 INLINE int get_joint_membership_index(EggGroup *joint);
63 INLINE int get_dxyz_index(const std::string &morph_name);
64 INLINE int get_drgba_index(const std::string &morph_name);
65
66 void apply_match();
67 PT(EggGroup) do_uniform_tesselate(int &tris) const;
68 PT(EggVertex) evaluate_vertex(double u, double v) const;
69
70 PT(EggNurbsSurface) _egg_surface;
71 PT(NurbsSurfaceEvaluator) _nurbs;
72 PT(NurbsSurfaceResult) _nurbs_result;
73 bool _has_vertex_color;
74
75 // Mapping arbitrary attributes to integer extended dimension values, so we
76 // can hang arbitrary data in the extra dimensional space of the surface.
77 int _next_d;
78 typedef std::map<EggGroup *, int> JointTable;
79 JointTable _joint_table;
80 typedef std::map<std::string, int> MorphTable;
81 MorphTable _dxyz_table;
82 MorphTable _drgba_table;
83
84 int _num_u, _num_v;
85 int _tess_u, _tess_v;
86 pvector<double> _iso_u, _iso_v; // If nonempty, isoparams at which to tess.
87
88 // _importance is the relative importance of the surface along either axis;
89 // _importance2 is this number squared, which is the value set by
90 // set_importance().
91 double _importance;
92 double _importance2;
93
94 // _match_u and _match_v indicate which surface we must match exactly for
95 // tesselation in U or V. This helps get edges to line up properly. They
96 // are indirect pointers because we go through the surfaces in one pass, and
97 // might need to fill in the correct value later.
98 QtessSurface **_match_u, **_match_v;
99 bool _match_u_to_u, _match_v_to_v;
100
101 // _min_u and _min_v specify a mininum number of quads below which we should
102 // not attempt to subdivide the surface in either dimension. This is
103 // intended to prevent degenerate cases like knife-fingers.
104 int _min_u, _min_v;
105
106 IsoPlacer _u_placer, _v_placer;
107 bool _got_scores;
108};
109
110#include "qtessSurface.I"
111
112#endif
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition eggGroup.h:34
A parametric NURBS surface.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
Definition eggVertex.h:39
Contains the logic used to place isoparams where they'll do the most good on a surface.
Definition isoPlacer.h:27
This class is an abstraction for evaluating NURBS surfaces.
The result of a NurbsSurfaceEvaluator.
A reference to an EggNurbsSurface in the egg file, and its parameters as set by the user input file a...
int count_tris() const
Returns the number of triangles that will be generated by the current tesselation parameters.
double get_score(double ratio)
Computes the curvature/stretch score for the surface, if it has not been already computed,...
void set_min_u(int min_u)
Specifies the absolute minimum number of segments allowed in the U direction.
void tesselate_per_isoparam(double pi, bool autoplace, double ratio)
Sets the surface up to tesselate itself to a uniform amount per isoparam.
void omit()
Sets up the surface to omit itself from the output.
int write_qtess_parameter(std::ostream &out)
Writes a line to the given output file telling qtess how this surface should be tesselated uniformly.
void set_match_u(QtessSurface **match_u, bool match_u_to_u)
Indicates the surface to which this surface must match in its U direction.
double count_patches() const
Returns the number of patches the NURBS contains.
void set_min_v(int min_v)
Specifies the absolute minimum number of segments allowed in the V direction.
void tesselate_auto(int u, int v, double ratio)
Sets the surface up to tesselate itself by automatically determining the best place to put the indica...
int tesselate()
Applies the appropriate tesselation to the surface, and replaces its node in the tree with an EggGrou...
void set_match_v(QtessSurface **match_v, bool match_v_to_v)
Indicates the surface to which this surface must match in its V direction.
void tesselate_uv(int u, int v, bool autoplace, double ratio)
Sets the surface up to tesselate itself uniformly at u x v, or if autoplace is true,...
void tesselate_per_score(double pi, bool autoplace, double ratio)
Sets the surface up to tesselate itself according to its computed curvature score in both dimensions.
void set_importance(double importance2)
Sets the importance of the surface, as a ratio in proportion to the square of its size.
void tesselate_specific(const pvector< double > &u_list, const pvector< double > &v_list)
Sets the surface up to tesselate itself at specific isoparams only.
bool is_valid() const
Returns true if the defined surface is valid, false otherwise.
A base class for all things that want to be reference-counted.
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.