Texture Mapping with Meshes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm looking to apply a variable texture to a body based on the angle of the body's surface normal to a chosen plane. The best way I have found is by converting the body to a mesh, checking the normal of each triangle, and splitting into smaller meshes which each get a texture. I have gotten this to work up to changing the texture mapping for each mesh - the textures have to be projected from a plane. Here, it seems that the projection type changes successfully but the transform is ignored (I have checked that its value changes), resulting in no texture mapping being applied. The second photo shows the texture mapping window after running the script. This code works for solid bodies but not meshes.
As a sidenote, I found that the TriangleMeshCalculator.maxNormalDeviation property is treated as an angle in degrees, although it is specified to be in radians.
mat = ad.Matrix3D.create()
mat.setWithCoordinateSystem(plane.origin, plane.normal, plane.uDirection, plane.vDirection)
for i in range(2*n + 1):
control:ad.ProjectedTextureMapControl = meshes[i].textureMapControl
control.transform = mat
control.projectedTextureMapType = ad.ProjectedTextureMapTypes.PlanarTextureMapProjection