Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40b052bcef | ||
|
|
92cd831b05 | ||
|
|
362603fa9b | ||
|
|
f7f3eea9e3 | ||
|
|
5e11d812c6 | ||
|
|
c954f2f2df | ||
|
|
7eedd59f6f | ||
|
|
3c5d04cbe3 | ||
|
|
1bdcedb100 | ||
|
|
8b720d8b5b | ||
|
|
558c9160f6 | ||
|
|
6855f5fd28 | ||
|
|
0579b6054c | ||
|
|
3b1a499293 | ||
|
|
e2c87dddb9 | ||
|
|
ffc126599c | ||
|
|
9338f2511b | ||
|
|
4559cb3892 | ||
|
|
164ef61900 | ||
|
|
b6b1bd63a9 | ||
|
|
5c94d3dcff | ||
|
|
c08842ce86 | ||
|
|
ecfef40f72 | ||
|
|
d1ff980345 | ||
|
|
108102f03f |
@@ -0,0 +1,3 @@
|
||||
cmake-build-debug-mingw/
|
||||
cmake-build-debug/
|
||||
.idea/
|
||||
+47
-16
@@ -1,39 +1,70 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(Prog3B)
|
||||
|
||||
# === Basis-Konfiguration ===
|
||||
set(EXECUTABLE_NAME Prog3B)
|
||||
set(OS_NAME windows)
|
||||
|
||||
# Generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Set the default build type if not specified
|
||||
# Default-Build-Type (falls nicht angegeben)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
|
||||
# === Quell- und Header-Dateien ===
|
||||
set(SRC_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/main.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/gamecube.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/gamematrix.cpp
|
||||
)
|
||||
|
||||
set(INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_LIST_DIR}/OS_NAME
|
||||
${CMAKE_CURRENT_LIST_DIR}/windows
|
||||
${CMAKE_CURRENT_LIST_DIR}/raylib
|
||||
)
|
||||
|
||||
# === Betriebssystem automatisch erkennen ===
|
||||
if(WIN32)
|
||||
set(OS_DIR "windows")
|
||||
elseif(APPLE)
|
||||
# Prüfen, ob ARM oder x86
|
||||
execute_process(
|
||||
COMMAND uname -m
|
||||
OUTPUT_VARIABLE ARCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(ARCH STREQUAL "arm64")
|
||||
set(OS_DIR "mac_arm")
|
||||
else()
|
||||
set(OS_DIR "mac_x86")
|
||||
endif()
|
||||
elseif(UNIX)
|
||||
set(OS_DIR "linux")
|
||||
else()
|
||||
message(FATAL_ERROR "Unbekanntes Betriebssystem!")
|
||||
endif()
|
||||
|
||||
|
||||
# === Executable erstellen ===
|
||||
add_executable(${EXECUTABLE_NAME} ${SRC_FILES})
|
||||
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${INCLUDE_DIRS})
|
||||
|
||||
# === Bibliotheken verlinken ===
|
||||
target_link_libraries(${EXECUTABLE_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/${OS_NAME}/libgamematrix.a
|
||||
${CMAKE_CURRENT_LIST_DIR}/${OS_NAME}/libraylib.a
|
||||
${CMAKE_CURRENT_LIST_DIR}/${OS_DIR}/libraylib.a
|
||||
)
|
||||
if (WIN32)
|
||||
target_link_libraries(Prog3B PRIVATE winmm)
|
||||
|
||||
# Windows: zusätzliche Systemlib
|
||||
if(WIN32)
|
||||
target_link_libraries(${EXECUTABLE_NAME} PRIVATE winmm)
|
||||
endif()
|
||||
|
||||
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
||||
if (APPLE)
|
||||
target_link_libraries(Prog3B "-framework IOKit")
|
||||
target_link_libraries(Prog3B "-framework Cocoa")
|
||||
target_link_libraries(Prog3B "-framework OpenGL")
|
||||
# macOS: Frameworks
|
||||
if(APPLE)
|
||||
target_link_libraries(${EXECUTABLE_NAME}
|
||||
"-framework IOKit"
|
||||
"-framework Cocoa"
|
||||
"-framework OpenGL"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
========================================================
|
||||
Projekt: gamematrix (C++ Library)
|
||||
Rolle: Architekt
|
||||
Datei: design.txt
|
||||
Datum: 03.11
|
||||
Team: Stone_Development
|
||||
========================================================
|
||||
|
||||
# ----------------------------
|
||||
# 1. Projektstruktur / Namespace
|
||||
# ----------------------------
|
||||
Namespace: Matrix3D
|
||||
|
||||
Ziel: Saubere Trennung der Bibliothek, Vermeidung von Namenskonflikten.
|
||||
|
||||
Beispiel:
|
||||
namespace Matrix3D {
|
||||
// Funktionen, ggf Klasse(n)
|
||||
}
|
||||
|
||||
# ----------------------------
|
||||
# 2. Datenstrukturen / Klassen
|
||||
# ----------------------------
|
||||
Listen Sie die Klassen oder Structs auf, die verwendet werden:
|
||||
|
||||
| Name | Typ | Beschreibung |
|
||||
|--------|------------------------------------------|--------------|
|
||||
| Vec3 | struct Vec3 | 3D-Vektor (x, y, z) |
|
||||
| Mat4 | std::array<std::array<double,4>,4> | 4x4-Matrix (homogen) |
|
||||
| ______ | ________ | ___________________ |
|
||||
| ______ | ________ | ___________________ |
|
||||
|
||||
# ----------------------------
|
||||
# 3. Operatoren / Templates
|
||||
# ----------------------------
|
||||
Welche Operatoren oder Templates sollen definiert werden?
|
||||
|
||||
- Templates für unterschiedliche Datentypen? x Ja
|
||||
- Operatoren:
|
||||
- Mat4 * Mat4
|
||||
- Mat4 * Vec3
|
||||
|
||||
# ----------------------------
|
||||
# 4. Funktionen / Schnittstellen
|
||||
# ----------------------------
|
||||
Liste der Funktionen mit Eingabe/Ausgabe und kurzer Beschreibung:
|
||||
|
||||
| Funktion | Eingabe | Ausgabe | Kurzbeschreibung |
|
||||
|---------------|------------------------------------|-----------------------|----------------------------------------|
|
||||
| matmul | Mat4 A, Mat4 B | Mat4 | Matrixmultiplikation 4x4 |
|
||||
| translate | Vec3 pos | Mat4 | Verschiebungstransformation |
|
||||
| rot3D | double angle_deg, char axis | Mat4 | Rotation um Achse x/y/z | |
|
||||
| _____________ | __________________________________ | ____________________ | ______________________________ |
|
||||
|
||||
# ----------------------------
|
||||
# 5. Designentscheidungen / Hinweise
|
||||
# ----------------------------
|
||||
- Rückgabe der Matrizen per Wert oder Referenz? Rückgabe
|
||||
- Verwendung von std::array oder std::vector? std::array
|
||||
- Homogene Koordinaten für Translation / Rotation (4x4)? ☐ Ja
|
||||
- Weitere Designüberlegungen: ___________________________
|
||||
|
||||
# ----------------------------
|
||||
# 6. Deliverables / Milestones
|
||||
# ----------------------------
|
||||
- design.txt fertig und im Branch architect committed
|
||||
- Übergabe an Entwickler für Implementierung
|
||||
|
||||
========================================================
|
||||
Hinweis:
|
||||
- Dieses Dokument dient als Grundlage für die Implementierung.
|
||||
- Alle Designentscheidungen sollen klar nachvollziehbar sein.
|
||||
========================================================
|
||||
|
||||
test
|
||||
+4
-3
@@ -7,6 +7,7 @@ gamecube::gamecube(const Vec3 &pos, Color col)
|
||||
// hallo hier ist robert
|
||||
//hallo Robert hier ist Niklas
|
||||
//test
|
||||
// Ich bin ein Roberter
|
||||
void gamecube::Update(float flipSpeed)
|
||||
{
|
||||
if (flippingForward)
|
||||
@@ -43,11 +44,11 @@ void gamecube::Draw() const
|
||||
rlPushMatrix();
|
||||
|
||||
// Matrizen für Rotation und Translation erzeugen
|
||||
auto matrix_a = gameMatrix::translate({ position.x, position.y, position.z});
|
||||
auto matrix_b = gameMatrix::rot3D(rotation, 'y');
|
||||
auto matrix_a = Matrix3D::gameMatrix::translate({ position.x, position.y, position.z});
|
||||
auto matrix_b = Matrix3D::gameMatrix::rot3D(rotation, 'y');
|
||||
|
||||
// Matrizen multiplizieren (Translation * Rotation)
|
||||
auto model = gameMatrix::matmul(matrix_a, matrix_b);
|
||||
auto model = Matrix3D::gameMatrix::matmul(matrix_a, matrix_b);
|
||||
|
||||
// transform for raylib matrix
|
||||
float f[16];
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#include "gamematrix.h"
|
||||
|
||||
|
||||
using namespace Matrix3D;
|
||||
|
||||
///
|
||||
/// @param matrix1 - First matrix
|
||||
/// @param matrix2 - Second matrix
|
||||
/// @return Returns the multiplication of matrix 1 and matrix 2.
|
||||
std::array<std::array<double,4>,4> gameMatrix::matmul(const std::array<std::array<double,4>,4>& matrix1,
|
||||
const std::array<std::array<double,4>,4>& matrix2) {
|
||||
|
||||
std::array<std::array<double,4>,4> matrix3 = {};
|
||||
if (matrix1[0].size() != matrix2.size()) {
|
||||
throw std::invalid_argument("Number of columns of matrix 1 must be equal to number of rows of matrix 2");
|
||||
};
|
||||
for (int i = 0; i < matrix1.size(); i++) {
|
||||
std::array<double,4> temp_array = {};
|
||||
for (int j = 0; j < matrix2[i].size(); j++) {
|
||||
double temp = 0;
|
||||
for (int k = 0; k < matrix2.size(); k++) {
|
||||
temp += matrix1[i][k] * matrix2[k][j];
|
||||
}
|
||||
temp_array[j] = temp;
|
||||
}
|
||||
matrix3[i] = temp_array;
|
||||
}
|
||||
return matrix3;
|
||||
}
|
||||
|
||||
///
|
||||
/// @param angle_deg Rotation angle
|
||||
/// @param axis Rotation axis (x, y, z)
|
||||
/// @return Returns a rotation matrix based on a given angle and axis.
|
||||
std::array<std::array<double,4>,4> gameMatrix::rot3D(double angle_deg, char axis) {
|
||||
if (axis != 'x' && axis != 'y' && axis != 'z') {
|
||||
throw std::invalid_argument("Invalid axis");
|
||||
};
|
||||
const auto angle_rad = angle_deg * M_PI / 180;
|
||||
std::array<std::array<double,4>,4> rotationMatrix = {};
|
||||
switch (axis) {
|
||||
case 'x': {
|
||||
std::array<std::array<double,4>,4> rMx = {{
|
||||
{1, 0, 0, 0},
|
||||
{0, cos(angle_rad), -sin(angle_rad), 0},
|
||||
{0, sin(angle_rad), cos(angle_rad), 0},
|
||||
{0, 0, 0, 1}
|
||||
}};
|
||||
rotationMatrix = rMx;
|
||||
}
|
||||
break;
|
||||
case 'y': {
|
||||
std::array<std::array<double,4>,4> rMy = {{
|
||||
{cos(angle_rad), 0, sin(angle_rad), 0},
|
||||
{0, 1, 0, 0},
|
||||
{-sin(angle_rad), 0, cos(angle_rad), 0},
|
||||
{0, 0, 0, 1}
|
||||
}};
|
||||
rotationMatrix = rMy;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'z': {
|
||||
std::array<std::array<double,4>,4> rMz = {{
|
||||
{cos(angle_rad), -sin(angle_rad), 0, 0},
|
||||
{sin(angle_rad), cos(angle_rad), 0, 0},
|
||||
{0, 0, 1, 0},
|
||||
{0, 0, 0, 1}
|
||||
}};
|
||||
rotationMatrix = rMz;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return rotationMatrix;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// @param pos 3 point vector (x, y, z)
|
||||
/// @return Returns a 4x4 translation matrix base on a given vector.
|
||||
std::array<std::array<double,4>,4> gameMatrix::translate(const std::array<double, 3>& pos) {
|
||||
std::array<std::array<double,4>,4> transMatrix = {{{1, 0, 0, pos[0]}, {0, 1, 0, pos[1]}, {0, 0, 1, pos[2]}, {0, 0, 0, 1}}};
|
||||
return transMatrix;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+18
-11
@@ -4,16 +4,23 @@
|
||||
#include <stdexcept>
|
||||
#include <cmath>
|
||||
|
||||
class gameMatrix
|
||||
{
|
||||
public:
|
||||
// Matrix Multiplikation
|
||||
static std::array<std::array<double,4>,4> matmul(const std::array<std::array<double,4>,4>& A,
|
||||
const std::array<std::array<double,4>,4>& B);
|
||||
namespace Matrix3D {
|
||||
class gameMatrix
|
||||
{
|
||||
public:
|
||||
// Matrix Multiplikation
|
||||
static std::array<std::array<double,4>,4> matmul(const std::array<std::array<double,4>,4>& matrix1,
|
||||
const std::array<std::array<double,4>,4>& matrix2);
|
||||
|
||||
// Rotationsmatrix um Achse x/y/z
|
||||
static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis);
|
||||
// Rotationsmatrix um Achse x/y/z
|
||||
static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis);
|
||||
|
||||
// Verschiebung
|
||||
static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos);
|
||||
};
|
||||
// Verschiebung
|
||||
static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos);
|
||||
|
||||
private:
|
||||
//TODO: Was für eine Rolle spielen Vec3 und Mat4???
|
||||
struct Vec3 {double x,y,z;};
|
||||
std::array<std::array<double,4>,4> Mat4 {};
|
||||
};
|
||||
}
|
||||
@@ -8,9 +8,9 @@
|
||||
int main()
|
||||
{
|
||||
//CHRIS WAR HIER
|
||||
//AXIOM WAR HIER
|
||||
// Zufall initialisieren
|
||||
srand(time(NULL));
|
||||
|
||||
// Fenster und Kamera
|
||||
InitWindow(800, 600, "3D Memory Game with Matrix3D Library");
|
||||
SetTargetFPS(60);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Hallo ehrwürdige Teamkameraden, wir werden das Projekt mit Bravur meistern! //lern deutsch //Wovon redest du hä? ist doch alles astrein... //du Schlingel
|
||||
@@ -0,0 +1,64 @@
|
||||
========================================================
|
||||
Projekt: gamematrix (C++ Library)
|
||||
Rolle: Projektleiter
|
||||
Datei: requirements.txt
|
||||
Datum: 03.11.2025
|
||||
Team: Stone_Development
|
||||
========================================================
|
||||
|
||||
# ----------------------------
|
||||
# 1. Projektziel
|
||||
# ----------------------------
|
||||
Beschreiben Sie hier kurz das Ziel des Projekts:
|
||||
|
||||
Ziel: gamematrix.cpp erweitern, Matrizenoperationen für 3D-Transformationen bereitstellen,
|
||||
Integration in das bestehende Spielprojekt, Vorgehensmodell: Wasserfall
|
||||
|
||||
# ----------------------------
|
||||
# 2. Funktionale Anforderungen
|
||||
# ----------------------------
|
||||
Listen Sie alle Funktionen auf, die die Bibliothek bereitstellen soll.
|
||||
Tragen Sie ein: Funktion, Eingabe, Ausgabe, kurze Beschreibung
|
||||
|
||||
| Funktion | Eingabe, Kurzbeschreibung | Ausgabe | |
|
||||
|---------------|------------------------------------|-----------------------|----------------------------------------|
|
||||
| matmul | 4x4 Matrix A, 4x4 Matrix B | 4x4 Matrix | _____________________________________ |
|
||||
| translate | 3D Vektor | 4x4 Matrix | _____________________________________ |
|
||||
| rot3D | Winkel in °, Rotationsachse (x/y/z)| 4x4 Matrix | _____________________________________ |
|
||||
| _____________ | __________________________________ | ____________________ | ______________________________ |
|
||||
| _____________ | __________________________________ | ____________________ | ______________________________ |
|
||||
|
||||
# ----------------------------
|
||||
# 3. Nicht-funktionale Anforderungen
|
||||
# ----------------------------
|
||||
|
||||
|
||||
- Lesbarkeit
|
||||
- Performance
|
||||
- Wartbarkeit
|
||||
- Python-Kompatibilität via pybind11
|
||||
|
||||
# ----------------------------
|
||||
# 4. Annahmen / Einschränkungen
|
||||
# ----------------------------
|
||||
(z. B. alle Matrizen sind 4x4, Winkel in Grad, nur double)
|
||||
|
||||
- Alle Matrizen sind 4x4
|
||||
- Winkel in Grad
|
||||
- nur double
|
||||
|
||||
# ----------------------------
|
||||
# 5. Abnahmekriterien
|
||||
# ----------------------------
|
||||
Wie soll geprüft werden, dass die Anforderungen erfüllt sind?
|
||||
(z. B. Unit-Tests, Beispielrotationen, Matrizenmultiplikation)
|
||||
|
||||
- Unit-Tests
|
||||
- Beispielrotationen
|
||||
- Matrizenmultiplikation
|
||||
|
||||
========================================================
|
||||
Hinweis:
|
||||
- Diese Datei wird vom Projektleiter erstellt und gepflegt.
|
||||
- Jede Phase des Projekts soll hier dokumentiert werden.
|
||||
========================================================
|
||||
Reference in New Issue
Block a user