This library provides a set of classes and methods for creating and exporting 3D models in the Wavefront OBJ file format. The library supports creating and manipulating vertices, faces and meshes in a simple and intuitive way.
- Create and manipulate 3D models with vertices, faces, and texture coordinates
- Export models to the Wavefront OBJ file format
- Define meshes (combination of faces), extrude and loft faces,
- Easy to use and integrate into existing Java projects
Here's the list of classes:
Point is a immutable class which can be used to define Vectors, Faces and many more. To define a Point,
Point p = new Point(double X, double Y, double Z);
If you need origin, you can directly call the static variable ORIGIN,
Point origin = new Point(0,0,0);
//But instead,
Point origin = Point.ORIGIN;
double xCoordMyPoint = myPoint.getX();
double distance = myPoint.distanceToPoint(otherPoint);
Point shiftedPoint = myPoint.shift(myVector);
Do not forget that Point is an immutable class. Methods like this does not affect the point itself, but outputs new instances!
Vectors allow you to do many different operations. Vector is an immutable class. To define a Vector, you can use any of the ways below:
Vector v = new Vector(Point head);
//or
Vector v = new Vector(Point tail, Point head);
//or
Vector v = new Vector(double headX, double headY, double headZ);
Vector s in JavaMesh do not have the instance tail. Constructor with tail (which is the second example above), forms a new head, and creates a vector which is a shifted-to-origin version of the vector with user-given tail and head
Returns a unit vector which has the same direction as the vector itself.
Get the cross product of the vector with v .
Get the dot product of the vector with v .
Return value is radians.
Returns a new vector which is a scaled version of the original.
Angle must be in radians.
Mesh is a collection of Faces.
Use .saveAsObj() to save it as .obj file.