Skip to content

Commit

Permalink
feature/ply-normals
Browse files Browse the repository at this point in the history
- Support for reading vertex normals
- Added the concept of face normals
  • Loading branch information
lessthanoptimal committed Jun 11, 2024
1 parent 164cde6 commit 656d688
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
* Copyright (c) 2024, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -63,6 +63,9 @@ public class StlDataStructure {
/** What's the name of this Solid */
public String name = "";

// Internal workspace
Point3D_F64 temp = new Point3D_F64();

public void reset() {
vertexes.reset();
normals.reset();
Expand Down Expand Up @@ -124,15 +127,14 @@ private void addNormal( Point3D_F64 v1, Point3D_F64 v2, Point3D_F64 v3 ) {
double by = v3.y - v1.y;
double bz = v3.z - v1.z;

Point3D_F64 t = vertexes.temp;
GeometryMath_F64.cross(ax, ay, az, bx, by, bz, t);
GeometryMath_F64.cross(ax, ay, az, bx, by, bz, temp);

// Ensure the norm is 1
double n = t.norm();
t.divideIP(n);
double n = temp.norm();
temp.divideIP(n);

// Save the results
normals.append(t.x, t.y, t.z);
normals.append(temp.x, temp.y, temp.z);
}

/**
Expand Down
Loading

0 comments on commit 656d688

Please sign in to comment.