- OBJ read/write (multi-object, ngon fan-triangulation, negative indices), STL binary+ascii with auto-detect and vertex welding - info: bbox/size/area/volume + watertightness via edge manifold stats - view: z-buffered orthographic ASCII renders (front/side/top/iso/back) - transform: center/mirror/scale/rotate/translate/fit, per-object filter, winding auto-flip on negative determinant - create: box/sphere/cylinder/cone/plane/torus; merge; convert - go tests: primitive volumes vs analytic values, roundtrips, topology Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MmdG9GqfSWCzts7AkDwRDh
21 lines
489 B
Go
21 lines
489 B
Go
package mesh
|
|
|
|
// Apply transforms every vertex by mat. Mirroring transforms (negative
|
|
// determinant) flip triangle winding, so it is corrected here to keep
|
|
// normals pointing the same way relative to the surface.
|
|
func (m *Mesh) Apply(mat Mat4) {
|
|
for i := range m.Verts {
|
|
m.Verts[i] = mat.Apply(m.Verts[i])
|
|
}
|
|
if mat.Det3() < 0 {
|
|
m.FlipWinding()
|
|
}
|
|
}
|
|
|
|
// ApplyAll transforms a set of meshes.
|
|
func ApplyAll(meshes []*Mesh, mat Mat4) {
|
|
for _, m := range meshes {
|
|
m.Apply(mat)
|
|
}
|
|
}
|