Texture Mapping

Texture mapping allows you to define the orientation and scale of textures on the objects or faces to which they are applied. The mapping can be defined at the material, entity, and subentity level. This allows a versatility in mapping materials - especially for complex solids where per-face mapping might be required. Mappers are defined in two locations:

Call AcDbEntity::setMaterialMapper() to set texture maps at the entity level, and AcDb3dSolid::setSubentMaterialMapper() to set texture maps at the subentity level. By default, the per-entity mappers inherit the transform method from the current material’s mapper. You can override this using the setAutoTransform() member function to automatically assign an appropriate transform for entity mappers. The AutoTransform enum provides options to multiply the mapper transform by the object scale and bounds, or by the model (block) transform.

Material mapping determines how a texture map fits the shape of your object. Use the appropriate projection to improve the fit of your texture map to your object.

AcGiMapper supports planar, box, spherical, cylindrical, solid, and face projections. Planar projection maps the texture onto the object as if you were projecting it from a slide projector onto a 2D surface. Box mapping repeats the texture on all sides of an object. Spherical mapping warps the image horizontally and vertically to fit to spherical objects. Cylindrical mapping wraps the horizontal edges of a texture together.

You can also rotate, scale, and translate textures by setting the transform matrix of the mapper. The AcGeMatrix3d class provides member functions to easily create a transform matrix with the appropriate rotation, scaling, and translation applied to it. This transformation is independent of the projection.