threedimensions 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- threedimensions-0.1.0/.github/workflows/publish.yml +48 -0
- threedimensions-0.1.0/CMakeLists.txt +54 -0
- threedimensions-0.1.0/LICENSE +21 -0
- threedimensions-0.1.0/Manual.md +164 -0
- threedimensions-0.1.0/PKG-INFO +93 -0
- threedimensions-0.1.0/README.md +78 -0
- threedimensions-0.1.0/cpp_core/bindings.cpp +70 -0
- threedimensions-0.1.0/cpp_core/geometry/Primitives.cpp +224 -0
- threedimensions-0.1.0/cpp_core/geometry/Primitives.h +20 -0
- threedimensions-0.1.0/cpp_core/math/Matrix4.h +39 -0
- threedimensions-0.1.0/cpp_core/math/Vector3.h +59 -0
- threedimensions-0.1.0/cpp_core/mesh/Mesh.cpp +217 -0
- threedimensions-0.1.0/cpp_core/mesh/Mesh.h +61 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl +0 -0
- threedimensions-0.1.0/dist/threedimensions-0.1.0-cp314-cp314t-musllinux_1_2_x86_64.whl +0 -0
- threedimensions-0.1.0/examples/baseball_bat.obj +301 -0
- threedimensions-0.1.0/examples/baseball_bat.py +80 -0
- threedimensions-0.1.0/examples/bed.obj +199 -0
- threedimensions-0.1.0/examples/bed.py +110 -0
- threedimensions-0.1.0/examples/chair.obj +199 -0
- threedimensions-0.1.0/examples/chair.py +85 -0
- threedimensions-0.1.0/pyproject.toml +28 -0
- threedimensions-0.1.0/python/threedimensions/__init__.py +11 -0
- threedimensions-0.1.0/python/threedimensions/core.py +258 -0
- threedimensions-0.1.0/python/threedimensions/curves.py +9 -0
- threedimensions-0.1.0/python/threedimensions/exporters.py +71 -0
- threedimensions-0.1.0/python/threedimensions/mesh.py +198 -0
- threedimensions-0.1.0/python/threedimensions/modifiers.py +90 -0
- threedimensions-0.1.0/python/threedimensions/scene.py +79 -0
- threedimensions-0.1.0/python/threedimensions/sculpt.py +14 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: Build and Publish ThreeDimensions
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch: # manual only (no auto spam)
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
id-token: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build-and-publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
# Checkout repo
|
|
16
|
+
- name: Checkout source
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
# Setup Python
|
|
20
|
+
- name: Setup Python
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.11"
|
|
24
|
+
|
|
25
|
+
# Install build tools
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
python -m pip install --upgrade pip
|
|
29
|
+
pip install build cibuildwheel pybind11
|
|
30
|
+
|
|
31
|
+
# Clean old builds (IMPORTANT)
|
|
32
|
+
- name: Clean old builds
|
|
33
|
+
run: |
|
|
34
|
+
rm -rf dist
|
|
35
|
+
rm -rf build
|
|
36
|
+
rm -rf *.egg-info
|
|
37
|
+
|
|
38
|
+
# Build wheel ONCE using cibuildwheel
|
|
39
|
+
- name: Build wheel
|
|
40
|
+
run: cibuildwheel --output-dir dist
|
|
41
|
+
|
|
42
|
+
# Build source distribution ONCE
|
|
43
|
+
- name: Build sdist
|
|
44
|
+
run: python -m build --sdist
|
|
45
|
+
|
|
46
|
+
# Publish to PyPI
|
|
47
|
+
- name: Publish to PyPI
|
|
48
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15)
|
|
2
|
+
project(ThreeDimensions LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
7
|
+
|
|
8
|
+
# Optimization flags
|
|
9
|
+
if(MSVC)
|
|
10
|
+
add_compile_options(/O2 /arch:AVX2 /fp:fast)
|
|
11
|
+
else()
|
|
12
|
+
add_compile_options(-O3 -march=native -ffast-math -pthread)
|
|
13
|
+
endif()
|
|
14
|
+
|
|
15
|
+
# Fetch pybind11
|
|
16
|
+
include(FetchContent)
|
|
17
|
+
FetchContent_Declare(
|
|
18
|
+
pybind11
|
|
19
|
+
GIT_REPOSITORY https://github.com/pybind/pybind11.git
|
|
20
|
+
GIT_TAG v2.11.1
|
|
21
|
+
)
|
|
22
|
+
FetchContent_MakeAvailable(pybind11)
|
|
23
|
+
|
|
24
|
+
# Include directories
|
|
25
|
+
include_directories(
|
|
26
|
+
cpp_core/math
|
|
27
|
+
cpp_core/geometry
|
|
28
|
+
cpp_core/mesh
|
|
29
|
+
cpp_core/topology
|
|
30
|
+
cpp_core/modifiers
|
|
31
|
+
cpp_core/sculpt
|
|
32
|
+
cpp_core/curves
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# Core library sources
|
|
36
|
+
file(GLOB_RECURSE SOURCES
|
|
37
|
+
"cpp_core/math/*.cpp"
|
|
38
|
+
"cpp_core/geometry/*.cpp"
|
|
39
|
+
"cpp_core/mesh/*.cpp"
|
|
40
|
+
"cpp_core/topology/*.cpp"
|
|
41
|
+
"cpp_core/modifiers/*.cpp"
|
|
42
|
+
"cpp_core/sculpt/*.cpp"
|
|
43
|
+
"cpp_core/curves/*.cpp"
|
|
44
|
+
"cpp_core/bindings.cpp"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# Create the python extension module
|
|
48
|
+
pybind11_add_module(_threedimensions_core ${SOURCES})
|
|
49
|
+
|
|
50
|
+
# Link libraries
|
|
51
|
+
target_link_libraries(_threedimensions_core PRIVATE pybind11::module)
|
|
52
|
+
|
|
53
|
+
# Install rules
|
|
54
|
+
install(TARGETS _threedimensions_core DESTINATION python/threedimensions)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LEGEND'S DaD
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# ThreeDimensions Documentation
|
|
2
|
+
|
|
3
|
+
Welcome to the official documentation for **ThreeDimensions**, a professional 3D modeling engine and SDK.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
1. [Installation](#install)
|
|
8
|
+
2. [Quick Start](#start)
|
|
9
|
+
3. [User Guide](#guide)
|
|
10
|
+
- [Creating Objects](#create)
|
|
11
|
+
- [Transforming Objects](#transform)
|
|
12
|
+
- [Combining Objects](#combine)
|
|
13
|
+
- [Saving and Exporting](#save)
|
|
14
|
+
4. [API Reference](#api)
|
|
15
|
+
5. [Examples](#examples)
|
|
16
|
+
|
|
17
|
+
<a name="install"></a>
|
|
18
|
+
## 1. Installation
|
|
19
|
+
|
|
20
|
+
ThreeDimensions is a hybrid C++/Python library.
|
|
21
|
+
|
|
22
|
+
### Prerequisites
|
|
23
|
+
- Python 3.11+
|
|
24
|
+
- C++20 Compiler (Optional, but recommended for performance)
|
|
25
|
+
- CMake 3.15+ (Optional)
|
|
26
|
+
|
|
27
|
+
### Installing via pip
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If you do not have a C++ compiler, the library will automatically fallback to a pure Python implementation.
|
|
34
|
+
|
|
35
|
+
<a name="start"></a>
|
|
36
|
+
## 2. Quick Start
|
|
37
|
+
|
|
38
|
+
Here is a simple example to create a Cube and save it.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import threedimensions as td
|
|
42
|
+
|
|
43
|
+
# Create a Cube of size 2.0
|
|
44
|
+
cube = td.Mesh.create_cube(size=2.0)
|
|
45
|
+
|
|
46
|
+
# Move it up by 1 unit
|
|
47
|
+
cube.translate(0, 1, 0)
|
|
48
|
+
|
|
49
|
+
# Save to OBJ file
|
|
50
|
+
cube.save("my_cube.obj")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
<a name="guide"></a>
|
|
54
|
+
## 3. User Guide
|
|
55
|
+
|
|
56
|
+
### <a name="create"></a> Creating Objects
|
|
57
|
+
|
|
58
|
+
You can create various geometric primitives.
|
|
59
|
+
|
|
60
|
+
**Cube**
|
|
61
|
+
```python
|
|
62
|
+
# Create a 1x1x1 cube
|
|
63
|
+
box = td.Mesh.create_cube(size=1.0)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Sphere**
|
|
67
|
+
```python
|
|
68
|
+
# Create a sphere with radius 1.0
|
|
69
|
+
ball = td.Mesh.create_sphere(radius=1.0, segments=32, rings=16)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Cylinder**
|
|
73
|
+
```python
|
|
74
|
+
# Create a cylinder (radius=0.5, height=2.0)
|
|
75
|
+
pole = td.Mesh.create_cylinder(radius=0.5, height=2.0, segments=16)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Other Primitives**
|
|
79
|
+
- `create_cone(radius, height, segments)`
|
|
80
|
+
- `create_torus(main_radius, tube_radius, main_segments, tube_segments)`
|
|
81
|
+
- `create_plane(size, subdivisions)`
|
|
82
|
+
|
|
83
|
+
### <a name="transform"></a> Transforming Objects
|
|
84
|
+
|
|
85
|
+
You can move, rotate, and scale your meshes.
|
|
86
|
+
|
|
87
|
+
**Translation (Move)**
|
|
88
|
+
```python
|
|
89
|
+
# Move x=1, y=2, z=0
|
|
90
|
+
mesh.translate(1.0, 2.0, 0.0)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Scaling (Resize)**
|
|
94
|
+
```python
|
|
95
|
+
# Scale x=2 (double width), y=0.5 (half height), z=1 (same depth)
|
|
96
|
+
mesh.scale(2.0, 0.5, 1.0)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Rotation**
|
|
100
|
+
```python
|
|
101
|
+
import math
|
|
102
|
+
# Rotate 90 degrees around Y axis
|
|
103
|
+
mesh.rotate_y(math.pi / 2)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### <a name="combine"></a> Combining Objects
|
|
107
|
+
|
|
108
|
+
To build complex objects (like furniture), you can join multiple meshes together.
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
# Create a seat
|
|
112
|
+
seat = td.Mesh.create_cube(size=1.0)
|
|
113
|
+
seat.scale(1.0, 0.1, 1.0)
|
|
114
|
+
|
|
115
|
+
# Create a leg
|
|
116
|
+
leg = td.Mesh.create_cube(size=1.0)
|
|
117
|
+
leg.scale(0.1, 1.0, 0.1)
|
|
118
|
+
|
|
119
|
+
# Attach leg to seat at specific offset
|
|
120
|
+
# This merges the leg geometry INTO the seat mesh
|
|
121
|
+
seat.join(leg, offset_x=0.4, offset_y=-0.5, offset_z=0.4)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### <a name="save"></a> Saving and Exporting
|
|
125
|
+
|
|
126
|
+
The library supports `.obj` and `.stl` formats.
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# Save as OBJ (Wavefront) - Good for rendering
|
|
130
|
+
mesh.save("model.obj")
|
|
131
|
+
|
|
132
|
+
# Save as STL (Stereolithography) - Good for 3D Printing
|
|
133
|
+
mesh.save("model.stl")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
<a name="api"></a>
|
|
137
|
+
## 4. API Reference
|
|
138
|
+
|
|
139
|
+
### `threedimensions.Mesh`
|
|
140
|
+
|
|
141
|
+
The core class representing a 3D object.
|
|
142
|
+
|
|
143
|
+
#### Properties
|
|
144
|
+
- `vertex_count`: Number of vertices.
|
|
145
|
+
- `face_count`: Number of faces.
|
|
146
|
+
|
|
147
|
+
#### Methods
|
|
148
|
+
- `add_vertex(x, y, z)`: Add a single vertex manually.
|
|
149
|
+
- `add_face(indices)`: Add a face manually using vertex indices.
|
|
150
|
+
- `translate(x, y, z)`: Move the entire mesh.
|
|
151
|
+
- `scale(x, y, z)`: Scale the entire mesh.
|
|
152
|
+
- `rotate_x(angle)`: Rotate around X axis (radians).
|
|
153
|
+
- `rotate_y(angle)`: Rotate around Y axis (radians).
|
|
154
|
+
- `rotate_z(angle)`: Rotate around Z axis (radians).
|
|
155
|
+
- `extrude_face(index, distance)`: Extrude a specific face along its normal.
|
|
156
|
+
- `join(other_mesh, offset_x, offset_y, offset_z)`: Merge another mesh into this one.
|
|
157
|
+
- `save(filepath)`: Auto-detects format from extension and saves file.
|
|
158
|
+
|
|
159
|
+
<a name="examples"></a>
|
|
160
|
+
## 5. Examples
|
|
161
|
+
|
|
162
|
+
Check the `examples/` directory for full scripts:
|
|
163
|
+
- `baseball_bat.py`: Demonstrates extrusion and scaling to model a bat.
|
|
164
|
+
- `chair.py`: Demonstrates `join()` to compose a complex object from primitives.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: threedimensions
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Professional 3D Modeling Engine & SDK
|
|
5
|
+
Author-Email: LegedsDaD <legendsdad001@gmail.com>
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Intended Audience :: Developers
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: C++
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# ThreeDimensions
|
|
17
|
+
<img width="1024" height="1024" alt="ChatGPT Image Mar 1, 2026, 09_40_22 AM" src="https://github.com/user-attachments/assets/f07c4899-ef07-43af-b00b-03e90cc3af77" />
|
|
18
|
+
|
|
19
|
+
**Professional 3D Modeling Engine & SDK**
|
|
20
|
+
|
|
21
|
+
ThreeDimensions is a high-performance, hybrid C++20/Python 3D modeling library designed to provide a complete toolset comparable to Blender's modeling capabilities. It features a modern C++ core for heavy lifting and a flexible Python SDK for scripting and tool development.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- **Hybrid Architecture**:
|
|
26
|
+
- **C++20 Core**: High-performance mesh kernel, geometry processing, and math engine.
|
|
27
|
+
- **Python SDK**: Object-oriented API, scene graph, and modifier system.
|
|
28
|
+
- **Mesh Engine**: Efficient topology, support for N-gons, and large mesh optimization.
|
|
29
|
+
- **Modeling Tools**:
|
|
30
|
+
- Primitives: Cube, Sphere, Cylinder, Cone, Torus, Plane.
|
|
31
|
+
- Edit Mode: Vertex/Edge/Face operations (Extrude, Bevel, Inset, etc.).
|
|
32
|
+
- Advanced: Booleans, Subdivision Surface, Decimate, Remesh.
|
|
33
|
+
- **Non-Destructive Workflow**: Modifier stack system (Subdivision, Mirror, Array, Boolean).
|
|
34
|
+
- **Scene System**: Hierarchical scene graph, object instancing, and collections.
|
|
35
|
+
- **Export**: OBJ, STL support.
|
|
36
|
+
|
|
37
|
+
## Project Structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
ThreeDimensions/
|
|
41
|
+
├── cpp_core/ # C++20 Core Engine
|
|
42
|
+
├── python/ # Python SDK
|
|
43
|
+
├── examples/ # Usage examples (chair.py, baseball_bat.py)
|
|
44
|
+
├── LICENSE
|
|
45
|
+
├── Manual.md
|
|
46
|
+
├── CMakeLists.txt
|
|
47
|
+
├── README.md
|
|
48
|
+
├── pyproject.toml
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Build Instructions
|
|
52
|
+
|
|
53
|
+
### Prerequisites
|
|
54
|
+
|
|
55
|
+
- CMake 3.15+
|
|
56
|
+
- C++20 compliant compiler (GCC 10+, Clang 10+, MSVC 2019+)
|
|
57
|
+
- Python 3.11+
|
|
58
|
+
- pip
|
|
59
|
+
|
|
60
|
+
### Building from Source
|
|
61
|
+
|
|
62
|
+
1. Clone the repository:
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/LegendsDaD/ThreeDimensions.git
|
|
65
|
+
cd ThreeDimensions
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. Install dependencies and build the Python extension:
|
|
69
|
+
```bash
|
|
70
|
+
pip install .
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If a C++ compiler is not found, the library will fallback to a pure Python implementation automatically.
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
See [manual.md](https://github.com/LegedsDaD/ThreeDimensions/blob/main/Manual.md) for detailed documentation.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
import threedimensions as td
|
|
81
|
+
|
|
82
|
+
# Create a scene
|
|
83
|
+
bat = td.Mesh.create_cylinder(radius=0.15, height=1.0)
|
|
84
|
+
bat.save("bat.obj")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Authors
|
|
88
|
+
|
|
89
|
+
- **LegedsDaD** (legendsdad001@gmail.com)
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT License
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# ThreeDimensions
|
|
2
|
+
<img width="1024" height="1024" alt="ChatGPT Image Mar 1, 2026, 09_40_22 AM" src="https://github.com/user-attachments/assets/f07c4899-ef07-43af-b00b-03e90cc3af77" />
|
|
3
|
+
|
|
4
|
+
**Professional 3D Modeling Engine & SDK**
|
|
5
|
+
|
|
6
|
+
ThreeDimensions is a high-performance, hybrid C++20/Python 3D modeling library designed to provide a complete toolset comparable to Blender's modeling capabilities. It features a modern C++ core for heavy lifting and a flexible Python SDK for scripting and tool development.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Hybrid Architecture**:
|
|
11
|
+
- **C++20 Core**: High-performance mesh kernel, geometry processing, and math engine.
|
|
12
|
+
- **Python SDK**: Object-oriented API, scene graph, and modifier system.
|
|
13
|
+
- **Mesh Engine**: Efficient topology, support for N-gons, and large mesh optimization.
|
|
14
|
+
- **Modeling Tools**:
|
|
15
|
+
- Primitives: Cube, Sphere, Cylinder, Cone, Torus, Plane.
|
|
16
|
+
- Edit Mode: Vertex/Edge/Face operations (Extrude, Bevel, Inset, etc.).
|
|
17
|
+
- Advanced: Booleans, Subdivision Surface, Decimate, Remesh.
|
|
18
|
+
- **Non-Destructive Workflow**: Modifier stack system (Subdivision, Mirror, Array, Boolean).
|
|
19
|
+
- **Scene System**: Hierarchical scene graph, object instancing, and collections.
|
|
20
|
+
- **Export**: OBJ, STL support.
|
|
21
|
+
|
|
22
|
+
## Project Structure
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
ThreeDimensions/
|
|
26
|
+
├── cpp_core/ # C++20 Core Engine
|
|
27
|
+
├── python/ # Python SDK
|
|
28
|
+
├── examples/ # Usage examples (chair.py, baseball_bat.py)
|
|
29
|
+
├── LICENSE
|
|
30
|
+
├── Manual.md
|
|
31
|
+
├── CMakeLists.txt
|
|
32
|
+
├── README.md
|
|
33
|
+
├── pyproject.toml
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Build Instructions
|
|
37
|
+
|
|
38
|
+
### Prerequisites
|
|
39
|
+
|
|
40
|
+
- CMake 3.15+
|
|
41
|
+
- C++20 compliant compiler (GCC 10+, Clang 10+, MSVC 2019+)
|
|
42
|
+
- Python 3.11+
|
|
43
|
+
- pip
|
|
44
|
+
|
|
45
|
+
### Building from Source
|
|
46
|
+
|
|
47
|
+
1. Clone the repository:
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/LegendsDaD/ThreeDimensions.git
|
|
50
|
+
cd ThreeDimensions
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
2. Install dependencies and build the Python extension:
|
|
54
|
+
```bash
|
|
55
|
+
pip install .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If a C++ compiler is not found, the library will fallback to a pure Python implementation automatically.
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
See [manual.md](https://github.com/LegedsDaD/ThreeDimensions/blob/main/Manual.md) for detailed documentation.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import threedimensions as td
|
|
66
|
+
|
|
67
|
+
# Create a scene
|
|
68
|
+
bat = td.Mesh.create_cylinder(radius=0.15, height=1.0)
|
|
69
|
+
bat.save("bat.obj")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Authors
|
|
73
|
+
|
|
74
|
+
- **LegedsDaD** (legendsdad001@gmail.com)
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT License
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#include <pybind11/pybind11.h>
|
|
2
|
+
#include <pybind11/stl.h>
|
|
3
|
+
#include "math/Vector3.h"
|
|
4
|
+
#include "mesh/Mesh.h"
|
|
5
|
+
#include "geometry/Primitives.h"
|
|
6
|
+
|
|
7
|
+
namespace py = pybind11;
|
|
8
|
+
using namespace ThreeDimensions;
|
|
9
|
+
|
|
10
|
+
PYBIND11_MODULE(_threedimensions_core, m) {
|
|
11
|
+
m.doc() = "ThreeDimensions Core C++ Module";
|
|
12
|
+
|
|
13
|
+
// Math
|
|
14
|
+
py::class_<Math::Vec3>(m, "Vector3")
|
|
15
|
+
.def(py::init<float, float, float>())
|
|
16
|
+
.def_readwrite("x", &Math::Vec3::x)
|
|
17
|
+
.def_readwrite("y", &Math::Vec3::y)
|
|
18
|
+
.def_readwrite("z", &Math::Vec3::z)
|
|
19
|
+
.def("length", &Math::Vec3::length)
|
|
20
|
+
.def("normalize", &Math::Vec3::normalize)
|
|
21
|
+
.def("__add__", &Math::Vec3::operator+)
|
|
22
|
+
.def("__sub__", &Math::Vec3::operator-)
|
|
23
|
+
.def("__mul__", &Math::Vec3::operator*)
|
|
24
|
+
.def("__repr__", [](const Math::Vec3& v) {
|
|
25
|
+
return "<Vector3 (" + std::to_string(v.x) + ", " + std::to_string(v.y) + ", " + std::to_string(v.z) + ")>";
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Mesh
|
|
29
|
+
py::class_<Core::Vertex>(m, "Vertex")
|
|
30
|
+
.def_readwrite("position", &Core::Vertex::position)
|
|
31
|
+
.def_readwrite("normal", &Core::Vertex::normal)
|
|
32
|
+
.def_readwrite("uv", &Core::Vertex::uv)
|
|
33
|
+
.def_readwrite("index", &Core::Vertex::index);
|
|
34
|
+
|
|
35
|
+
py::class_<Core::Face>(m, "Face")
|
|
36
|
+
.def_readwrite("indices", &Core::Face::indices)
|
|
37
|
+
.def_readwrite("normal", &Core::Face::normal);
|
|
38
|
+
|
|
39
|
+
py::class_<Core::Mesh>(m, "Mesh")
|
|
40
|
+
.def(py::init<std::string>())
|
|
41
|
+
.def_readwrite("name", &Core::Mesh::name)
|
|
42
|
+
.def("add_vertex", &Core::Mesh::addVertex)
|
|
43
|
+
.def("add_face", &Core::Mesh::addFace)
|
|
44
|
+
.def("calculate_normals", &Core::Mesh::calculateNormals)
|
|
45
|
+
.def("clear", &Core::Mesh::clear)
|
|
46
|
+
// Transforms
|
|
47
|
+
.def("translate", &Core::Mesh::translate)
|
|
48
|
+
.def("scale", &Core::Mesh::scale)
|
|
49
|
+
.def("rotate_x", &Core::Mesh::rotateX)
|
|
50
|
+
.def("rotate_y", &Core::Mesh::rotateY)
|
|
51
|
+
.def("rotate_z", &Core::Mesh::rotateZ)
|
|
52
|
+
// Editing
|
|
53
|
+
.def("extrude_face", &Core::Mesh::extrudeFace)
|
|
54
|
+
.def("scale_face", &Core::Mesh::scaleFace)
|
|
55
|
+
.def("translate_face", &Core::Mesh::translateFace)
|
|
56
|
+
.def("join", &Core::Mesh::join)
|
|
57
|
+
// Properties
|
|
58
|
+
.def_property_readonly("vertex_count", &Core::Mesh::vertexCount)
|
|
59
|
+
.def_property_readonly("face_count", &Core::Mesh::faceCount)
|
|
60
|
+
.def_readonly("vertices", &Core::Mesh::vertices)
|
|
61
|
+
.def_readonly("faces", &Core::Mesh::faces);
|
|
62
|
+
|
|
63
|
+
// Geometry Primitives
|
|
64
|
+
m.def("create_cube", &Geometry::Primitives::CreateCube, "Create a cube mesh", py::arg("size") = 1.0f);
|
|
65
|
+
m.def("create_sphere", &Geometry::Primitives::CreateSphere, "Create a sphere mesh", py::arg("radius") = 1.0f, py::arg("segments") = 16, py::arg("rings") = 16);
|
|
66
|
+
m.def("create_cylinder", &Geometry::Primitives::CreateCylinder, "Create a cylinder mesh", py::arg("radius") = 1.0f, py::arg("height") = 2.0f, py::arg("segments") = 16);
|
|
67
|
+
m.def("create_cone", &Geometry::Primitives::CreateCone, "Create a cone mesh", py::arg("radius") = 1.0f, py::arg("height") = 2.0f, py::arg("segments") = 16);
|
|
68
|
+
m.def("create_torus", &Geometry::Primitives::CreateTorus, "Create a torus mesh", py::arg("main_radius") = 1.0f, py::arg("tube_radius") = 0.4f, py::arg("main_segments") = 32, py::arg("tube_segments") = 16);
|
|
69
|
+
m.def("create_plane", &Geometry::Primitives::CreatePlane, "Create a plane mesh", py::arg("size") = 2.0f, py::arg("subdivisions") = 1);
|
|
70
|
+
}
|