-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13563e4
commit 71c9556
Showing
16 changed files
with
178 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
CMakeFiles/* | ||
CMakeCache.txt | ||
*.cmake | ||
Makefile | ||
.vscode | ||
*/Makefile | ||
*.3d | ||
*/CMakeCache.txt | ||
generator/CMakeFiles/* | ||
engine/CMakeFiles/* | ||
generator | ||
visualizer | ||
bin/* | ||
engine | ||
models/* | ||
.idea/* |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// | ||
// Created by juliojpinto on 27-02-2024. | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
# Project Name | ||
project(generator) | ||
|
||
# Include directories | ||
include_directories(${PROJECT_NAME} PUBLIC include) # Assuming headers are in the 'include' directory | ||
|
||
file(GLOB SRC_FILES src/shapes/*.cpp src/*.cpp) | ||
add_executable(${PROJECT_NAME} ${SRC_FILES}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef SOLAR_SYSTEM_PLANE_HPP | ||
#define SOLAR_SYSTEM_PLANE_HPP | ||
|
||
|
||
#include <vector> | ||
#include <string> | ||
#include "../utils.hpp" | ||
|
||
std::vector<Point> calculateTriangles(float length, int divisions); | ||
|
||
void saveToFile(const std::vector<Point>& points, const std::string& filepath); | ||
|
||
bool generatePlane(float length, int divisions, const char* filepath); | ||
|
||
|
||
|
||
#endif //SOLAR_SYSTEM_PLANE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef SOLAR_SYSTEM_UTILS_HPP | ||
#define SOLAR_SYSTEM_UTILS_HPP | ||
|
||
#include <string> | ||
#include <sstream> | ||
|
||
// Define Point struct | ||
typedef struct Point { | ||
float x; | ||
float y; | ||
float z; | ||
|
||
// Constructor | ||
Point(float x_val = 0.0f, float y_val = 0.0f, float z_val = 0.0f) | ||
: x(x_val), y(y_val), z(z_val) {} | ||
} Point; | ||
|
||
// Function to convert Point to string | ||
std::string pointToString(const Point& point); | ||
|
||
#endif //SOLAR_SYSTEM_UTILS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include "../include/shapes/plane.hpp" | ||
|
||
void generateFigure(int argc, char* argv[]) { | ||
if (argc < 5) { | ||
std::cerr << "Insufficient arguments\n"; | ||
return; | ||
} | ||
|
||
std::string figureType = argv[argc - 1]; | ||
std::string figureName = argv[1]; | ||
|
||
if (figureName == "sphere" && figureType == "sphere.3d" && argc == 6) { | ||
// Generate Sphere | ||
std::cout << "Generating Sphere\n"; | ||
} else if (figureName == "box" && figureType == "box.3d" && argc == 5) { | ||
// Generate Box | ||
std::cout << "Generating Box\n"; | ||
} else if (figureName == "plane" && figureType == "plane.3d" && argc == 5) { | ||
// Generate Plane | ||
std::cout << "Generating Plane\n"; // Added newline here | ||
float length = std::stof(argv[2]); | ||
int divisions = std::stoi(argv[3]); | ||
|
||
generatePlane(length, divisions, argv[4]); // Assuming saveToFile is available | ||
} else if (figureName == "cone" && figureType == "cone.3d" && argc == 7) { | ||
// Generate Cone | ||
std::cout << "Generating Cone\n"; | ||
} else { | ||
std::cerr << "Invalid arguments\n"; | ||
} | ||
} | ||
|
||
int main(int argc, char* argv[]) { | ||
generateFigure(argc, argv); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "utils.hpp" | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include <vector> | ||
|
||
float planeWidth = 5.0f; | ||
float planeLength = 5.0f; | ||
int divisions = 3; | ||
|
||
std::vector<Point> calculateTriangles(float length, int divisions) { | ||
float half = length / 2.0f; | ||
float steps = length / divisions; | ||
|
||
std::vector<Point> points; | ||
|
||
for (int i = 0; i < divisions; i++) { | ||
for (int j = 0; j < divisions; j++) { | ||
|
||
float x1 = -half + i * steps; | ||
float y1 = 0.0f; // Adjusted for consistency with the Point constructor | ||
float z1 = -half + j * steps; | ||
float x2 = -half + (i + 1) * steps; | ||
float y2 = 0.0f; // Adjusted for consistency with the Point constructor | ||
float z2 = -half + (j + 1) * steps; | ||
|
||
Point p1(x1, y1, z1); // Corrected the constructor usage | ||
Point p2(x2, y1, z1); | ||
Point p3(x1, y1, z2); | ||
Point p4(x2, y1, z2); | ||
|
||
points.push_back(p1); | ||
points.push_back(p2); | ||
points.push_back(p3); | ||
|
||
points.push_back(p2); | ||
points.push_back(p4); | ||
points.push_back(p3); | ||
} | ||
} | ||
|
||
return points; | ||
} | ||
|
||
void saveToFile(const std::vector<Point>& points, const char* filepath) { // Changed parameter type to const char* | ||
std::ofstream file(filepath); | ||
|
||
if (file.is_open()) { | ||
for (const auto& point : points) { | ||
file << point.x << " " << point.y << " " << point.z << "\n"; | ||
} | ||
file.close(); | ||
std::cout << "File saved successfully.\n"; | ||
} else { | ||
std::cerr << "Unable to open file: " << filepath << std::endl; | ||
} | ||
} | ||
|
||
bool generatePlane(float length, int divisions, const char* filepath) { // Changed parameter type to const char* | ||
std::vector<Point> triangles = calculateTriangles(length, divisions); | ||
|
||
if (triangles.empty()) { | ||
std::cerr << "Error: Empty vector of triangles.\n"; | ||
return false; | ||
} | ||
|
||
saveToFile(triangles, filepath); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "utils.hpp" | ||
#include <string> | ||
#include <sstream> | ||
|
||
std::string pointToString(Point point) { | ||
std::ostringstream oss; | ||
oss << point.x << " " << point.y << " " << point.z << "\n"; | ||
return oss.str(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.