Compare commits
11 Commits
31e26a7a55
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c7cc86197c | |||
| 2f74c66844 | |||
| d9abb1cfe9 | |||
| 2a4fac44e5 | |||
| b7b87e7258 | |||
| e019d4b975 | |||
| 1e1e8fe93c | |||
|
|
979a7b6179 | ||
|
|
d7e51c73f1 | ||
| d9e5da49f2 | |||
|
|
71d5461138 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
.idea/
|
||||
@ -1,70 +1,36 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(Prog3B)
|
||||
|
||||
# === Basis-Konfiguration ===
|
||||
set(EXECUTABLE_NAME Prog3B)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# Default-Build-Type (falls nicht angegeben)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
# WICHTIG: wegen raylib + neuer CMake-Version
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
|
||||
|
||||
# === Quell- und Header-Dateien ===
|
||||
set(SRC_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/main.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/gamecube.cpp
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
raylib
|
||||
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
||||
GIT_TAG 5.0
|
||||
)
|
||||
|
||||
set(INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_LIST_DIR}/mac_arm
|
||||
${CMAKE_CURRENT_LIST_DIR}/raylib
|
||||
FetchContent_MakeAvailable(raylib)
|
||||
|
||||
add_executable(Prog3B
|
||||
main.cpp
|
||||
gamecube.cpp
|
||||
gamematrix.cpp
|
||||
)
|
||||
|
||||
# === 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()
|
||||
target_include_directories(Prog3B PRIVATE .)
|
||||
target_link_libraries(Prog3B raylib)
|
||||
|
||||
|
||||
# === 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_DIR}/libgamematrix.a
|
||||
${CMAKE_CURRENT_LIST_DIR}/${OS_DIR}/libraylib.a
|
||||
)
|
||||
|
||||
# Windows: zusätzliche Systemlib
|
||||
if(WIN32)
|
||||
target_link_libraries(${EXECUTABLE_NAME} PRIVATE winmm)
|
||||
endif()
|
||||
|
||||
# macOS: Frameworks
|
||||
# macOS-Frameworks nicht vergessen:
|
||||
if(APPLE)
|
||||
target_link_libraries(${EXECUTABLE_NAME} PRIVATE
|
||||
"-framework IOKit"
|
||||
"-framework Cocoa"
|
||||
"-framework OpenGL"
|
||||
target_link_libraries(Prog3B
|
||||
"-framework Cocoa"
|
||||
"-framework IOKit"
|
||||
"-framework CoreVideo"
|
||||
"-framework OpenGL"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@ -1,74 +0,0 @@
|
||||
========================================================
|
||||
Projekt: gamematrix (C++ Library)
|
||||
Rolle: Tester
|
||||
Datei: tests.txt
|
||||
Datum: ____________________
|
||||
Team: ____________________
|
||||
========================================================
|
||||
|
||||
# ----------------------------
|
||||
# 1. Testplan Übersicht
|
||||
# ----------------------------
|
||||
Ziel: Überprüfung der Funktionen matmul(), translate(), rot3D().
|
||||
Hinweise:
|
||||
- Numerik: Vergleiche mit EPS = 1e-6
|
||||
- Winkelmaß: rot3D erwartet Grad (90/180/270). (Anpassen, falls Implementierung Radiant nutzt.)
|
||||
- Homogene Koordinate: Beim Anwenden von Mat4 auf Vec3 gilt w = 1.
|
||||
|
||||
| Funktion | Testfall | Eingabe / Setup | Erwartetes Ergebnis / Prüfung | Bemerkung |
|
||||
|---------------|-----------------------------------|----------------------------------------------------------------------------------|-------------------------------------------------------------|------------------------------------|
|
||||
| matmul | Identity * Identity | A = I4, B = I4 | C = I4 | Basisfall |
|
||||
| matmul | Beispielmatrizen | A = [[1,2,0,0],[0,1,3,0],[0,0,1,4],[0,0,0,1]]; B = [[1,0,5,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]] | C = A*B (per Hand gerechnet); alle Einträge ≈ erwartet | Handrechnung in Abschnitt 2 |
|
||||
| matmul | Assoziativität (Stichprobe) | Zufällige A,B,C (kleine Ganzzahlen) | (A*B)*C ≈ A*(B*C) | Numerisch mit EPS |
|
||||
| matmul | Nicht-Kommutativität | A = rotZ(90), B = rotX(90) | A*B ≠ B*A | Beispiel |
|
||||
| translate | Matrix-Struktur | t = (1,2,3) | T = [[1,0,0,1],[0,1,0,2],[0,0,1,3],[0,0,0,1]] | Letzte Spalte ist Translation |
|
||||
| translate | Anwendung auf Vektor | v = (4,5,6), T = translate(1,2,3) | T·(v,1) → (5,7,9) | Homogene 1 beachten |
|
||||
| rot3D | Rotation Z 90° | v = (1,0,0), Rz = rot3D(90,'z') | Rz·v → (0,1,0) | Rechtshändiges System |
|
||||
| rot3D | Rotation X 180° | v = (0,1,0), Rx = rot3D(180,'x') | Rx·v → (0,-1,0) | |
|
||||
| rot3D | Rotation Y 270° (Korrektur) | v = (1,0,0), Ry = rot3D(270,'y') | Ry·v → (0,0,1) | Vorher war -1: korrigiert |
|
||||
| rot3D | Inverse | R = rot3D(θ,axis) | R * rot3D(-θ,axis) ≈ I4 | Für θ ∈ {30, 90} testen |
|
||||
| rot3D+trans | Reihenfolge-Effekt | Rz = rot3D(90,'z'), T = translate(1,0,0), p=(1,0,0) | Rz*T·p ≠ T*Rz·p (aber jeweils plausibles Ergebnis) | Reihenfolge wichtig |
|
||||
|
||||
# ----------------------------
|
||||
# 2. Testdaten / Matrizen
|
||||
# ----------------------------
|
||||
- Identity I4 = diag(1,1,1,1)
|
||||
- Beispielmatrizen für matmul:
|
||||
A = [[1,2,0,0],
|
||||
[0,1,3,0],
|
||||
[0,0,1,4],
|
||||
[0,0,0,1]]
|
||||
|
||||
B = [[1,0,5,0],
|
||||
[0,1,0,0],
|
||||
[0,0,1,0],
|
||||
[0,0,0,1]]
|
||||
|
||||
Erwartetes C = A*B =
|
||||
[[1,2,5,0],
|
||||
[0,1,3,0],
|
||||
[0,0,1,4],
|
||||
[0,0,0,1]]
|
||||
|
||||
- Translation t = (1,2,3) ⇒
|
||||
T = [[1,0,0,1],
|
||||
[0,1,0,2],
|
||||
[0,0,1,3],
|
||||
[0,0,0,1]]
|
||||
|
||||
- Beispielvektoren:
|
||||
v1=(1,0,0), v2=(0,1,0), v3=(4,5,6)
|
||||
|
||||
# ----------------------------
|
||||
# 3. Abnahmekriterien
|
||||
# ----------------------------
|
||||
- Alle Unit-Tests erfolgreich (keine Abweichung > EPS)
|
||||
- Einheitliches Winkelmaß eingehalten (Grad oder Radiant, dokumentiert)
|
||||
- Keine Exceptions außer gewollt (z. B. ungültige Achse löst definierte Exception aus)
|
||||
- Testbericht (Eingaben, erwartetes Ergebnis, Ist-Ergebnis, Status, Bemerkung) vollständig
|
||||
========================================================
|
||||
Hinweis:
|
||||
- Diese Datei wird vom Tester gepflegt.
|
||||
- Tester dokumentiert Input, Output, erwartetes Ergebnis und Erfolg/Fehler.
|
||||
========================================================
|
||||
|
||||
15
gamecube.cpp
15
gamecube.cpp
@ -14,7 +14,7 @@ void gamecube::Update(float flipSpeed)
|
||||
flippingForward = false;
|
||||
flipped = true;
|
||||
}
|
||||
}
|
||||
}// test
|
||||
else if (flippingBackward)
|
||||
{
|
||||
rotation -= flipSpeed;
|
||||
@ -27,8 +27,8 @@ void gamecube::Update(float flipSpeed)
|
||||
}
|
||||
}
|
||||
|
||||
void gamecube::FlipForward() { flippingForward = true; }
|
||||
void gamecube::FlipBackward() { flippingBackward = true; }
|
||||
void gamecube::FlipForward() { flippingForward = true; }
|
||||
void gamecube::FlipBackward() { flippingBackward = true; }
|
||||
|
||||
bool gamecube::IsFlipped() const { return flipped; }
|
||||
bool gamecube::IsMatched() const { return matched; }
|
||||
@ -38,18 +38,15 @@ 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');
|
||||
|
||||
// Matrizen multiplizieren (Translation * Rotation)
|
||||
auto model = gameMatrix::matmul(matrix_a, matrix_b);
|
||||
|
||||
// transform for raylib matrix
|
||||
float f[16];
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
f[j * 4 + i] = model[i][j];
|
||||
|
||||
rlMultMatrixf(f);
|
||||
|
||||
if (rotation < 90.0f)
|
||||
@ -62,5 +59,5 @@ void gamecube::Draw() const
|
||||
rlPopMatrix();
|
||||
}
|
||||
|
||||
Vec3 gamecube::GetPosition() const { return position; }
|
||||
float gamecube::GetRotationY() const { return rotation; }
|
||||
Vec3 gamecube::GetPosition() const { return position; }
|
||||
float gamecube::GetRotationY() const { return rotation; }
|
||||
|
||||
15
gamecube.h
15
gamecube.h
@ -3,22 +3,24 @@
|
||||
#include "raylib.h"
|
||||
#include <rlgl.h>
|
||||
|
||||
struct Vec3
|
||||
{
|
||||
struct Vec3 {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
class gamecube
|
||||
{
|
||||
class gamecube {
|
||||
public:
|
||||
gamecube(const Vec3 &pos, Color col);
|
||||
|
||||
void Update(float flipSpeed);
|
||||
void FlipForward();
|
||||
void FlipBackward();
|
||||
|
||||
bool IsFlipped() const;
|
||||
bool IsMatched() const;
|
||||
void SetMatched(bool m);
|
||||
|
||||
void Draw() const;
|
||||
|
||||
Vec3 GetPosition() const;
|
||||
float GetRotationY() const;
|
||||
Color GetColor() const { return color; }
|
||||
@ -26,9 +28,12 @@ public:
|
||||
private:
|
||||
Vec3 position;
|
||||
Color color;
|
||||
|
||||
bool flipped = false;
|
||||
bool matched = false;
|
||||
|
||||
bool flippingForward = false;
|
||||
bool flippingBackward = false;
|
||||
|
||||
float rotation = 0.0f;
|
||||
};
|
||||
};
|
||||
|
||||
43
gamematrix.cpp
Normal file
43
gamematrix.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "gamematrix.h"
|
||||
|
||||
std::array<std::array<double,4>,4> gameMatrix::matmul(
|
||||
const std::array<std::array<double,4>,4>& A,
|
||||
const std::array<std::array<double,4>,4>& B)
|
||||
{
|
||||
std::array<std::array<double,4>,4> R = {};
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
for(int j=0;j<4;j++)
|
||||
for(int k=0;k<4;k++)
|
||||
R[i][j] += A[i][k] * B[k][j];
|
||||
|
||||
return R;
|
||||
}
|
||||
|
||||
std::array<std::array<double,4>,4> gameMatrix::rot3D(double angle_deg, char axis)
|
||||
{
|
||||
double a = angle_deg * M_PI / 180.0;
|
||||
double c = cos(a);
|
||||
double s = sin(a);
|
||||
|
||||
std::array<std::array<double,4>,4> M = {0};
|
||||
|
||||
M[3][3] = 1;
|
||||
M[axis == 'x'][axis == 'y'] = 1; // init identity axis
|
||||
|
||||
if(axis == 'x') M = {{{1,0,0,0},{0,c,-s,0},{0,s,c,0},{0,0,0,1}}};
|
||||
if(axis == 'y') M = {{{c,0,s,0},{0,1,0,0},{-s,0,c,0},{0,0,0,1}}};
|
||||
if(axis == 'z') M = {{{c,-s,0,0},{s,c,0,0},{0,0,1,0},{0,0,0,1}}};
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
std::array<std::array<double,4>,4> gameMatrix::translate(const std::array<double,3>& p)
|
||||
{
|
||||
return {{
|
||||
{1,0,0,p[0]},
|
||||
{0,1,0,p[1]},
|
||||
{0,0,1,p[2]},
|
||||
{0,0,0,1}
|
||||
}};
|
||||
}
|
||||
66
gantt
Normal file
66
gantt
Normal file
@ -0,0 +1,66 @@
|
||||
========================================================
|
||||
GANTT-CHART – Projekt gamematrix (C++ Library)
|
||||
Rolle: Projektleiter
|
||||
========================================================
|
||||
|
||||
Gesamtdauer: 90 Minuten
|
||||
Vorgehensmodell: Wasserfall
|
||||
Datum: 03.11.2025
|
||||
Teammitglieder: (getBeerreturntrue)
|
||||
|
||||
--------------------------------------------------------
|
||||
Legende:
|
||||
█ = aktive Arbeitszeit
|
||||
░ = Unterstützung / Wartezeit / Review
|
||||
--------------------------------------------------------
|
||||
|
||||
Zeit: 0 10 20 30 40 50 60 70 80 90
|
||||
|----|----|----|----|----|----|----|----|----|
|
||||
|
||||
--------------------------------------------------------
|
||||
1. ANFORDERUNGSANALYSE (0–10 min)
|
||||
--------------------------------------------------------
|
||||
Projektleiter ██████████
|
||||
Architekt ████░░░░░░
|
||||
Entwickler ░░░░░░░░░░
|
||||
Tester ███░░░░░░░
|
||||
|
||||
--------------------------------------------------------
|
||||
2. DESIGN / ENTWURF (10–20 min)
|
||||
--------------------------------------------------------
|
||||
Architekt ████████████
|
||||
Projektleiter ███░░░░░░░░░
|
||||
Entwickler ░░░░░░░░░░░░
|
||||
Tester ███░░░░░░░░░
|
||||
|
||||
--------------------------------------------------------
|
||||
3. IMPLEMENTIERUNG (20–50 min)
|
||||
--------------------------------------------------------
|
||||
Entwickler ████████████████████████
|
||||
Projektleiter ███░░░░░░░░░░░░░░░░░░░░
|
||||
Architekt ░░░░░░░░░░░░░░░░░░░░░░░
|
||||
Tester ██░░░░░░░░░░░░░░░░░░░░░
|
||||
|
||||
--------------------------------------------------------
|
||||
4. TESTEN & VALIDIERUNG (50–70 min)
|
||||
--------------------------------------------------------
|
||||
Tester ███████████████
|
||||
Entwickler ███░░░░░░░░░░░░
|
||||
Projektleiter ██░░░░░░░░░░░░░
|
||||
Architekt ░░░░░░░░░░░░░░
|
||||
|
||||
--------------------------------------------------------
|
||||
5. ABSCHLUSS / DOKUMENTATION (70–90 min)
|
||||
--------------------------------------------------------
|
||||
Projektleiter ██████████████
|
||||
Architekt ██░░░░░░░░░░░░
|
||||
Entwickler ██░░░░░░░░░░░░
|
||||
Tester ██░░░░░░░░░░░░
|
||||
|
||||
--------------------------------------------------------
|
||||
Ergebnisse:
|
||||
- Anforderungen abgeschlossen
|
||||
- Design & Architektur dokumentiert
|
||||
- Funktionen implementiert und getestet
|
||||
- Merge & Abschlussdokumentation fertig
|
||||
========================================================
|
||||
59
requirements.txt
Normal file
59
requirements.txt
Normal file
@ -0,0 +1,59 @@
|
||||
========================================================
|
||||
Projekt: gamematrix (C++ Library)
|
||||
Rolle: Projektleiter
|
||||
Datei: requirements.txt
|
||||
Datum: 03.11.2025
|
||||
Team: getBeerreturntrue(3 Personen)
|
||||
========================================================
|
||||
|
||||
# ----------------------------
|
||||
# 1. Projektziel
|
||||
# ----------------------------
|
||||
Ziel: Entwicklung einer C++-Bibliothek für 3D-Transformationen (4x4-Matrizen)
|
||||
zur späteren Nutzung über pybind11 in Python sowie Integration in das
|
||||
bestehende Spielprojekt. Bereitstellung von Funktionen für Translation,
|
||||
Rotation und Matrixmultiplikation im 3D-Raum.
|
||||
|
||||
# ----------------------------
|
||||
# 2. Funktionale Anforderungen
|
||||
# ----------------------------
|
||||
|
||||
| Funktion | Eingabe | Ausgabe | Kurzbeschreibung |
|
||||
|---------------|------------------------------------|-----------------------|----------------------------------------|
|
||||
| matmul | 4x4 Matrix A, 4x4 Matrix B | 4x4 Matrix | Multiplikation zweier 4x4 Matrizen |
|
||||
| translate | 3D Vektor (x,y,z) | 4x4 Matrix | Erzeugt Translationsmatrix |
|
||||
| rot3D | Winkel in °, Rotationsachse (x/y/z)| 4x4 Matrix | Rotationsmatrix um Achse |
|
||||
| identity | --- | 4x4 Matrix | Identitätsmatrix zurückgeben |
|
||||
| apply | Matrix, Vec3 | Vec3 | Vektor mit Transformationsmatrix transformieren |
|
||||
|
||||
# ----------------------------
|
||||
# 3. Nicht-funktionale Anforderungen
|
||||
# ----------------------------
|
||||
|
||||
- Lesbarkeit & Wartbarkeit (klarer Namespace, Header-Trennung)
|
||||
- Ausführung in Echtzeit-Spielumgebung (gute Performance)
|
||||
- Kompatibilität mit pybind11
|
||||
- Keine dynamische Speicherallokation innerhalb der Matrixoperationen
|
||||
|
||||
# ----------------------------
|
||||
# 4. Annahmen / Einschränkungen
|
||||
# ----------------------------
|
||||
|
||||
- Alle Matrizen im homogenen Format 4x4
|
||||
- Winkelangabe in Grad
|
||||
- Datentyp double
|
||||
- Koordinatensystem: Rechtshändig
|
||||
|
||||
# ----------------------------
|
||||
# 5. Abnahmekriterien
|
||||
# ----------------------------
|
||||
|
||||
- Beispiel-Transformationen funktionieren korrekt
|
||||
- Unit-Tests für alle Funktionen bestehen
|
||||
- Vergleich mit bekannten Resultaten (z. B. 90°-Rotation)
|
||||
- Bibliothek lässt sich erfolgreich in Python binden
|
||||
|
||||
========================================================
|
||||
Hinweis:
|
||||
Diese Datei wird vom Projektleiter gepflegt.
|
||||
========================================================
|
||||
Loading…
x
Reference in New Issue
Block a user