Skip to content

Commit 8d2a074

Browse files
committed
2 parents 924e547 + 95bb907 commit 8d2a074

File tree

3 files changed

+161
-3
lines changed

3 files changed

+161
-3
lines changed
309 KB
Loading

documentation/modifiers.md

Lines changed: 120 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,90 @@
11
# Mesh Modifiers
22

3+
## Understanding Mesh Modifiers
4+
5+
Mesh modifiers are powerful tools for transforming 3D meshes. They allow you to apply various
6+
geometric operations, such as translation, rotation, scaling, bending, and more. By understanding
7+
the core concepts and how to use these modifiers effectively, you can create a wide range of 3D
8+
shapes and effects.
9+
10+
The library offers a versatile set of pre-built modifiers, each adhering to the ```IMeshModifier``` interface.
11+
If you aim to extend the library with custom modifiers, ensuring adherence to this interface is crucial.
12+
13+
```java
14+
package mesh.modifier;
15+
16+
import mesh.Mesh3D;
17+
18+
public interface IMeshModifier {
19+
20+
public Mesh3D modify(Mesh3D mesh);
21+
22+
}
23+
```
24+
25+
**Key Point:** Returning a Modified Reference
26+
27+
An aspect of the ```IMeshModifier``` interface is that the modify method returns a reference to the modified mesh.
28+
29+
**Applying Modifications**
30+
31+
You can apply modifications to a mesh in two primary ways:
32+
33+
**1. Direct Modification:**
34+
35+
```java
36+
Mesh3D cube = new CubeCreator().create();
37+
ScaleModifier scaleModifier = new ScaleModifier(10);
38+
scaleModifier.modify(cube);
39+
```
40+
41+
**2. Mesh-Based Application:**
42+
43+
```java
44+
Mesh3D cube = new CubeCreator().create();
45+
ScaleModifier scaleModifier = new ScaleModifier(10);
46+
cube.apply(scaleModifier);
47+
```
48+
49+
The preferred approach depends on your specific use case and coding style. However,
50+
it's recommended to maintain consistency within your project to enhance code readability
51+
and maintainability.
52+
53+
## A Practical Example: Creating a Complex Shape
54+
55+
To demonstrate the power of combining multiple modifiers, let's create a complex shape:
56+
57+
![modfifiers-example](images/modifiers-example-001.png)
58+
59+
```java
60+
Mesh3D mesh = new CubeCreator().create();
61+
mesh.apply(new ExtrudeModifier(0.4f, 2));
62+
mesh.apply(new HolesModifier());
63+
mesh.apply(new SolidifyModifier(0.2f));
64+
mesh.apply(new ScaleModifier(1, 5, 1));
65+
mesh.apply(new RotateZModifier(Mathf.HALF_PI));
66+
mesh.apply(new CatmullClarkModifier(3));
67+
mesh.apply(new BendModifier(0.2f));
68+
```
69+
70+
By applying these modifiers sequentially, we can create a complex shape that
71+
starts as a simple cube and undergoes various transformations. This example
72+
highlights the flexibility and power of the mesh modifier framework.
73+
74+
**Remember:** The order in which modifiers are applied can significantly
75+
impact the final result. Experiment with different sequences to achieve
76+
desired effects.
77+
78+
## Best Practices for Using Mesh Modifiers
79+
80+
* **Start with Simple Shapes:** Begin with basic shapes like cubes, spheres, and planes to understand the effects of different modifiers.
81+
* **Combine Modifiers:** Experiment with combining multiple modifiers to achieve complex deformations.
82+
* **Iterative Approach:** Apply modifiers iteratively to fine-tune the desired shape.
83+
* **Consider Mesh Topology:** The topology of the mesh can significantly influence the results of the modification process.
84+
* **Optimize Modifier Stacks:** For performance reasons, try to minimize the number of modifiers applied to a mesh.
85+
386
## Basic Modifiers
4-
* **BendModifier:** Bends the mesh along a specified axis.
87+
* **BendModifier:** Bends the mesh along the X-axis.
588
* **BevelEdgesModifier:** Creates a bevel along the edges of the mesh.
689
* **BevelFacesModifier:** Creates a bevel around the faces of the mesh.
790
* **BevelVerticesModifier:** Creates a bevel around the vertices of the mesh.
@@ -19,12 +102,12 @@
19102
* **RotateYModifier:** Rotates the mesh around the Y-axis.
20103
* **RotateZModifier:** Rotates the mesh around the Z-axis.
21104
* **ScaleModifier:** Scales the mesh uniformly or non-uniformly.
22-
* **SmoothModifier:** Smoothes the mesh by averaging vertex positions. **???**
105+
* **SmoothModifier:** Smoothes the mesh by averaging vertex positions.
23106
* **SolidifyModifier:** Adds thickness to the faces of the mesh.
24107
* **SpherifyModifier:** Spherifies the mesh.
25108
* **TranslateModifier:** Translates the mesh.
26109
* **UpdateFaceNormalsModifier** Updates the face normals of the mesh.
27-
* **WireframeModifier:** Converts the mesh to a wireframe representation. **???**
110+
* **WireframeModifier:** Converts the mesh to a wireframe representation.
28111

29112
## Subdivision Modifiers
30113
* **CatmullClarkModifier:** Subdivides the mesh using the Catmull-Clark subdivision scheme.
@@ -152,3 +235,37 @@ This will shift the entire cube mesh 2 units along the X-axis, 1 unit along the
152235

153236
By understanding the basic principles and parameters of the Translate Modifier, you can effectively use it to position and manipulate 3D meshes in your projects.
154237

238+
## RotateXModifier
239+
240+
**Purpose:**
241+
242+
The `RotateXModifier` is a mesh modification tool designed to rotate a 3D mesh around the X-axis by a specified angle. This is useful for various transformations and manipulations, such as aligning objects, creating rotations, or simulating object movement.
243+
244+
**How it Works:**
245+
246+
1. **Rotation Angle:** The `angle` parameter defines the angle of rotation in radians.
247+
2. **Rotation Matrix:** A 3x3 rotation matrix is created using the specified angle.
248+
3. **Vertex Rotation:** Each vertex of the mesh is multiplied by the rotation matrix to apply the rotation.
249+
250+
**Using the RotateXModifier:**
251+
252+
1. **Create a Mesh:** Start with a basic 3D mesh, such as a plane, cube, or sphere.
253+
2. **Create a Rotator:** Instantiate a `RotateXModifier` object, specifying the desired rotation angle in radians.
254+
3. **Apply the Modifier:** Apply the `modify` method of the `RotateXModifier` to the mesh.
255+
256+
**Example:**
257+
258+
```java
259+
Mesh3D mesh = new CubeCreator().create(); // Create a cube mesh
260+
RotateXModifier rotator = new RotateXModifier(Mathf.QUATER_PI); // Rotate 45 degrees
261+
mesh.apply(rotator); // Apply the modifier to the mesh
262+
```
263+
264+
This will rotate the cube 45 degrees around the X-axis.
265+
266+
**Additional Considerations:**
267+
268+
* **Combining with Other Modifiers:** The RotateXModifier can be combined with other modifiers like Translate, Scale, or Bend to create more complex deformations.
269+
* **Order of Application:** The order in which modifiers are applied can affect the final result. Experiment with different sequences to achieve desired effects.
270+
271+
By understanding the basic principles and parameters of the RotateXModifier, you can effectively use it to rotate 3D meshes around the X-axis in your projects.

documentation/project-structure.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Project Structure
2+
3+
High-level overview of the project structure.
4+
5+
**Core Functionality:**
6+
7+
* **src.main.java.math:** This package contains fundamental math classes like `Vector3f`, `Matrix3f`, and `Matrix4f` used for 3D geometry calculations.
8+
* **src.main.java.mesh:** This package is the heart of the project and deals with meshes. It includes:
9+
* **animator:** Classes for animating meshes (e.g., `AbstractAnimator`, `MoveAlongNormalAnimator`).
10+
* **conway:** Classes specific to Conway polyhedra generation (e.g., `Conway`, various modifier classes).
11+
* **creator:** Classes for creating different types of meshes (e.g., Platonic solids, architectural elements).
12+
* **archimedian:** Creators for Archimedean solids.
13+
* **assets:** Creators for various assets used in meshes.
14+
* **beam:** Creators for different beam profiles.
15+
* **catalan:** Creators for Catalan solids.
16+
* **creative:** Creators for custom and creative mesh types.
17+
* **platonic:** Creators for Platonic solids.
18+
* **primitives:** Creators for basic geometric primitives.
19+
* **special:** Creators for specialized meshes (e.g., Accordion Torus, Mobius Strip).
20+
* **unsorted:** Creators for miscellaneous mesh types.
21+
* **Edge3D, Face3D, Mesh3D:** Classes representing the building blocks of a mesh (edges, faces, and the entire mesh).
22+
* **io:** Classes for reading and writing meshes from/to files (e.g., `SimpleObjectReader`, `SimpleObjectWriter`).
23+
* **modifier:** Classes for modifying existing meshes (e.g., `BendModifier`, `BevelFacesModifier`, subdivision modifiers).
24+
* **selection:** Classes for selecting faces or vertices within a mesh.
25+
* **util:** Utility classes for mesh-related operations (e.g., `Bounds3`, `Mesh3DUtil`).
26+
27+
**Workspace Integration (Optional):**
28+
29+
* **src.main.java.workspace:** This package handles integrating meshes within a workspace environment.
30+
31+
**Testing:**
32+
33+
* **src.test.java:** This package contains unit tests for various functionalities in the project. It includes tests for:
34+
* **bugs:** Tests for identified bugs in specific mesh creators or modifiers.
35+
* **math:** Tests for math utility functions.
36+
* **mesh:** Tests for mesh creation, modification, and utility functions.
37+
* **util:** Tests for utility classes used throughout the project.
38+
39+
**Resources:**
40+
41+
* **src.main.resources:** This directory contains resource files used by the project (e.g., configuration files, icons).

0 commit comments

Comments
 (0)