public class Model3D
extends java.lang.Object
Constructor and Description |
---|
Model3D(java.lang.String filename,
boolean normalize)
Reads in the vertices of a 3D model and performs (optional) normalization
on them before calculating the bounding sphere.
|
Model3D(java.lang.String filename,
java.lang.String modelInfo)
Reads in the vertices of a 3D model and performs some normalization
on them before calculating the bounding sphere.
|
Modifier and Type | Method and Description |
---|---|
static void |
applyPcaTransform(java.util.ArrayList<Vertex3D> points)
Rotates a set points so that they're aligned with the pricipal components of
the set.
|
static void |
applyPcaTransform(java.util.ArrayList<Vertex3D> points,
double[][] pcaBasis)
Rotates a set points so that they're aligned with the pricipal components of
the set, given a PCA basis.
|
static double |
furthestPoint(java.util.ArrayList<Vertex3D> points)
Finds furthest point from the origin.
|
BoundingSphere |
getBoundingSphere() |
java.util.ArrayList<Vertex3D> |
getVertices() |
static edu.txstate.mag262.Model3D.ModelInfo |
readModelInfo(java.lang.String filename)
Reads a Princeton Shape Benchmark style model_info file.
|
static void |
readPointsFromFile(java.lang.String filename,
java.util.ArrayList<Vertex3D> vertices)
Reads in a model file and returns the vertices as an ArrayList of Vertex3D objects.
|
static void |
rescale(double radius,
java.util.ArrayList<Vertex3D> points)
Rescales a set of points in 3D space in respect to the origin.
|
static void |
rescaleByMean(double radius,
java.util.ArrayList<Vertex3D> points)
Rescales a set of points in 3D space in respect to the origin.
|
static void |
subtractMeans(java.util.ArrayList<Vertex3D> points)
Subtracts the means from each dimension so that each dimension has mean of zero.
|
static void |
writePointsToFile(java.lang.String filename,
java.util.ArrayList<Vertex3D> vertices)
Writes a set of model vertices to a file, where each line is a vertex "x y z".
|
public Model3D(java.lang.String filename, boolean normalize)
filename
- the path to the 3D model file. Only .off and .obj files are
currently supported.normalize
- if true, normalizes the model against various factors; else
it just uses the model as-is.public Model3D(java.lang.String filename, java.lang.String modelInfo)
filename
- the path to the 3D model file. Only .off and .obj files are
currently supported.modelInfo
- the PSB style model_info file.public java.util.ArrayList<Vertex3D> getVertices()
public BoundingSphere getBoundingSphere()
public static double furthestPoint(java.util.ArrayList<Vertex3D> points)
points
- a list of points in 3D space.public static void rescale(double radius, java.util.ArrayList<Vertex3D> points)
radius
- the new radius.points
- a list of points in 3D space.public static void rescaleByMean(double radius, java.util.ArrayList<Vertex3D> points)
radius
- the new radius.points
- a list of points in 3D space.public static void subtractMeans(java.util.ArrayList<Vertex3D> points)
points
- a list of points in 3D space.public static void applyPcaTransform(java.util.ArrayList<Vertex3D> points)
points
- a list of points in 3D space.public static void applyPcaTransform(java.util.ArrayList<Vertex3D> points, double[][] pcaBasis)
points
- a list of points in 3D space.pcaBasis
- a matrix of where the columns are three dimensional PCA
basis vectors. For example, pcaBasis[0][2] will be row 0, column 2; using
zero-indexing.public static edu.txstate.mag262.Model3D.ModelInfo readModelInfo(java.lang.String filename)
filename
- the model info filepath.Model3D.ModelInfo
public static void readPointsFromFile(java.lang.String filename, java.util.ArrayList<Vertex3D> vertices) throws java.io.IOException
filename
- the path to the 3D model file. Only .off and .obj files are
currently supported.vertices
- an instantiated ArrayList to add the model vertices to.java.io.IOException
- if model file could not be opened.public static void writePointsToFile(java.lang.String filename, java.util.ArrayList<Vertex3D> vertices)
filename
- path to the file to save to.vertices
- a list of the model vertices.java.io.IOException
- if output file could not be created.