TextureMapping3D 类
class TextureMapping3D {
public:
// TextureMapping3D Interface
virtual ~TextureMapping3D() { }
virtual Point Map(const DifferentialGeometry &dg,
Vector *dpdx, Vector *dpdy) const = 0;
};
类的作用:
(计算 3D 纹理坐标)
We will also define a TextureMapping3D class that defines the interface for generating
three-dimensional texture coordinates.
IdentityMapping3D 类
class IdentityMapping3D : public TextureMapping3D {
public:
IdentityMapping3D(const Transform &x)
: WorldToTexture(x) { }
Point Map(const DifferentialGeometry &dg, Vector *dpdx,
Vector *dpdy) const;
private:
Transform WorldToTexture;
};
Point IdentityMapping3D::Map(const DifferentialGeometry &dg,
Vector *dpdx, Vector *dpdy) const {
*dpdx = WorldToTexture(dg.dpdx);
*dpdy = WorldToTexture(dg.dpdy);
return WorldToTexture(dg.p);
}
作用:
()
The natural three-dimensional mapping just takes the world space coordinate of the
point and applies a linear transformation to it. This will often be a transformation that
takes the point back to the primitive’s object space.
Because a linear mapping is used, the differential change in texture coordinates can be
found by applying the same mapping to the partial derivatives of position.