Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
A set of files which I hope are usable by others using ESP-IDF v5.3.0
  • Loading branch information
motoani authored Nov 6, 2024
1 parent 4a99819 commit fcbaaaf
Show file tree
Hide file tree
Showing 57 changed files with 12,049 additions and 0 deletions.
Binary file added 3dtextures2.bin
Binary file not shown.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(i80_controller)
Binary file added DiscWorld11.bin
Binary file not shown.
Binary file added amaze_2_title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions dependencies.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dependencies:
idf:
source:
type: idf
version: 5.3.0
direct_dependencies:
- idf
manifest_hash: 620bb73887c520f756e6770a2a31cc1ad0837429534c5bc6dd432791ad7c3df6
target: esp32s3
version: 2.0.0
Binary file added gameover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

idf_component_register(
SRCS
"i80_lcd_main.cpp"
"ShowWorld.cpp"
"ClipBound.cpp"
"CameraWork.cpp"
"CheckTriangles.cpp"
"ShowError.cpp"
"TriangleQueues.cpp"
"wr_gpio.cpp"
"ChunkChooser.cpp"
"RasteriseBox.cpp"
"lcd_setup.c"
"ParseWorld.cpp"
"FindHitFace.cpp"
"TimeTracker.cpp"
"EventManager.cpp"

INCLUDE_DIRS
"."
"includes"
"World"
REQUIRES esp_partition esp_lcd esp_mm esp_timer
)





51 changes: 51 additions & 0 deletions main/CameraWork.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <math.h>

#include "geometry.h"
#include "CameraWork.h"


void make_camera(const Vec3f direction, const Vec3f cameraPosition, Matrix44f& worldToCamera)
{
// Build the view matrix as per https://medium.com/@carmencincotti/lets-look-at-magic-lookat-matrices-c77e53ebdf78
// This has worked with basic geometry functions but converted to glm to ensure that it works with the rest of 3D code

Vec3f forwardvector = (-direction).normalize();

const Vec3f tempup = { 0,1,0 };
Vec3f rightvector = (tempup.crossProduct(forwardvector)).normalize();

Vec3f upvector = (forwardvector.crossProduct(rightvector)).normalize();

Vec3f translate;
translate.x = rightvector.dotProduct(cameraPosition);
translate.y = upvector.dotProduct(cameraPosition);
translate.z = forwardvector.dotProduct(cameraPosition);

Matrix44f LookAt = {
rightvector.x,rightvector.y,rightvector.z,-translate.x,
upvector.x,upvector.y,upvector.z,-translate.y,
forwardvector.x,forwardvector.y,forwardvector.z,-translate.z,
0,0,0,1 };

worldToCamera = LookAt.transposed();
} // End of make_camera()

// Make a perspective projection matrix, simplified from glm opensource library
// so that can be used without glm library
void make_perspective(
float const fovy, // must be in radians
float const aspect,
float const zNear,
float const zFar,
Matrix44f& Result
)
{
float tanHalfFovy = tan(fovy / 2.0f);

Result[0][0] = 1.0f / (aspect * tanHalfFovy);
Result[1][1] = 1.0f / (tanHalfFovy);
Result[2][2] = -(zFar + zNear) / (zFar - zNear);
Result[2][3] = -1.0f;
Result[3][2] = -(2.0f * zFar * zNear) / (zFar - zNear);
} // End of make_perspective

Loading

0 comments on commit fcbaaaf

Please sign in to comment.