154 lines
3.9 KiB
Text
154 lines
3.9 KiB
Text
/**
|
|
* PANDA 3D SOFTWARE
|
|
* Copyright (c) Carnegie Mellon University. All rights reserved.
|
|
*
|
|
* All use of this software is subject to the terms of the revised BSD
|
|
* license. You should have received a copy of this license along
|
|
* with this source code in a file named "LICENSE."
|
|
*
|
|
* @file qtessSurface.I
|
|
* @author drose
|
|
* @date 2003-10-13
|
|
*/
|
|
|
|
/**
|
|
*
|
|
*/
|
|
INLINE const std::string &QtessSurface::
|
|
get_name() const {
|
|
return _egg_surface->get_name();
|
|
}
|
|
|
|
/**
|
|
* Returns true if the defined surface is valid, false otherwise.
|
|
*/
|
|
INLINE bool QtessSurface::
|
|
is_valid() const {
|
|
return (_nurbs != nullptr);
|
|
}
|
|
|
|
/**
|
|
* Sets the importance of the surface, as a ratio in proportion to the square
|
|
* of its size.
|
|
*/
|
|
INLINE void QtessSurface::
|
|
set_importance(double importance2) {
|
|
_importance = sqrt(importance2);
|
|
_importance2 = importance2;
|
|
}
|
|
|
|
/**
|
|
* Indicates the surface to which this surface must match in its U direction.
|
|
* If u_to_u is true, it matches to the other surface's U direction;
|
|
* otherwise, it matches to the other surface's V direction.
|
|
*
|
|
* Note that the surface pointer is an indirect pointer. The value passed in
|
|
* is the address of the pointer to the actual surface (which may or may not
|
|
* be filled in yet). The actual pointer may be filled in later.
|
|
*/
|
|
INLINE void QtessSurface::
|
|
set_match_u(QtessSurface **match_u, bool match_u_to_u) {
|
|
_match_u = match_u;
|
|
_match_u_to_u = match_u_to_u;
|
|
}
|
|
|
|
/**
|
|
* Indicates the surface to which this surface must match in its V direction.
|
|
* If v_to_v is true, it matches to the other surface's V direction;
|
|
* otherwise, it matches to the other surface's U direction.
|
|
*
|
|
* Note that the surface pointer is an indirect pointer. The value passed in
|
|
* is the address of the pointer to the actual surface (which may or may not
|
|
* be filled in yet). The actual pointer may be filled in later.
|
|
*/
|
|
INLINE void QtessSurface::
|
|
set_match_v(QtessSurface **match_v, bool match_v_to_v) {
|
|
_match_v = match_v;
|
|
_match_v_to_v = match_v_to_v;
|
|
}
|
|
|
|
/**
|
|
* Specifies the absolute minimum number of segments allowed in the U
|
|
* direction.
|
|
*/
|
|
INLINE void QtessSurface::
|
|
set_min_u(int min_u) {
|
|
_min_u = min_u;
|
|
}
|
|
|
|
/**
|
|
* Specifies the absolute minimum number of segments allowed in the V
|
|
* direction.
|
|
*/
|
|
INLINE void QtessSurface::
|
|
set_min_v(int min_v) {
|
|
_min_v = min_v;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the number of patches the NURBS contains. Each patch is a square
|
|
* area bounded by isoparams. This actually scales by the importance of the
|
|
* surface, if it is not 1.
|
|
*/
|
|
INLINE double QtessSurface::
|
|
count_patches() const {
|
|
return _num_u * _num_v * _importance2;
|
|
}
|
|
|
|
/**
|
|
* Returns the number of triangles that will be generated by the current
|
|
* tesselation parameters.
|
|
*/
|
|
INLINE int QtessSurface::
|
|
count_tris() const {
|
|
return _tess_u * _tess_v * 2;
|
|
}
|
|
|
|
/**
|
|
* Returns the extra dimension number within the surface where the vertex
|
|
* membership in the indicated joint should be stored.
|
|
*/
|
|
INLINE int QtessSurface::
|
|
get_joint_membership_index(EggGroup *joint) {
|
|
JointTable::iterator jti = _joint_table.find(joint);
|
|
if (jti != _joint_table.end()) {
|
|
return (*jti).second;
|
|
}
|
|
int d = _next_d;
|
|
_next_d++;
|
|
_joint_table[joint] = d;
|
|
return d;
|
|
}
|
|
|
|
/**
|
|
* Returns the extra dimension number within the surface where the indicated
|
|
* Dxyz morph offset should be stored.
|
|
*/
|
|
INLINE int QtessSurface::
|
|
get_dxyz_index(const std::string &morph_name) {
|
|
MorphTable::iterator mti = _dxyz_table.find(morph_name);
|
|
if (mti != _dxyz_table.end()) {
|
|
return (*mti).second;
|
|
}
|
|
int d = _next_d;
|
|
_next_d += 3;
|
|
_dxyz_table[morph_name] = d;
|
|
return d;
|
|
}
|
|
|
|
/**
|
|
* Returns the extra dimension number within the surface where the indicated
|
|
* Drgba morph offset should be stored.
|
|
*/
|
|
INLINE int QtessSurface::
|
|
get_drgba_index(const std::string &morph_name) {
|
|
MorphTable::iterator mti = _drgba_table.find(morph_name);
|
|
if (mti != _drgba_table.end()) {
|
|
return (*mti).second;
|
|
}
|
|
int d = _next_d;
|
|
_next_d += 4;
|
|
_drgba_table[morph_name] = d;
|
|
return d;
|
|
}
|