Skip to content

Commit

Permalink
camera and frustum (pending changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarpilote committed Nov 8, 2021
1 parent c78c029 commit 7f80dac
Show file tree
Hide file tree
Showing 25 changed files with 1,436 additions and 516 deletions.
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.21)
cmake_policy(VERSION 3.21)

project(Myosotis VERSION 0.1)

set( CMAKE_EXPORT_COMPILE_COMMANDS ON )

configure_file(
${PROJECT_SOURCE_DIR}/version.h.in
${PROJECT_BINARY_DIR}/version.h
${PROJECT_SOURCE_DIR}/config/version.h.in
${PROJECT_BINARY_DIR}/Version.h
)

include_directories(
${PROJECT_BINARY_DIR}
)

find_package(OpenGL REQUIRED)
add_compile_definitions(NDC_HAS_REVERSED_Z=1)
add_compile_definitions(NDC_HAS_REVERSED_Y=0)
add_compile_definitions(NDC_DEPTH_RANGE_IS_ZERO_TO_ONE=1)

find_package(glfw3 REQUIRED)

add_subdirectory(
Expand Down
File renamed without changes.
69 changes: 69 additions & 0 deletions include/affine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include "vec3.h"

template <typename T> struct TPoint;
template <typename T> struct TVect;
template <typename T> struct TLine;
template <typename T> struct TPlane;


template <typename T>
struct TPoint {
T x;
T y;
T z;
T w; /* = 1 */

TPoint(T x, T y, T z, T w);
TPoint(T x, T y, T z);
explicit TPoint(TVec3<T> v);

TPoint operator+= (const TVect<T>& v);

static constexpr TPoint Origin;
};


/**
* Plucker coordinates for lines in 3D.
* Cfr https://en.wikipedia.org/wiki/Pl%C3%BCcker_coordinates
*/
template <typename T>
struct TLine {
union {
struct {
T wx;
T wy;
T wz;
};
TVec3<T> m;
};
union {
struct {
T yz;
T zx;
T xy;
};
TVec3<T> d;
};

TLine(const TPoint<T>& p, const TPoint<T>& q);
TLine(const TPoint<T>& p, const TVect<T>& v);
};

template <typename T>
struct TPlane {
T x;
T y;
T z;
T w;
TPlane(T x, T y, T z, T w);
};

/* Typedefs */

typedef TPoint<float> Point;
typedef TLine<float> Line;
typedef TPlane<float> Plane;

/* Implementations */

22 changes: 15 additions & 7 deletions include/array.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <stdlib.h>
#include <assert.h>

Expand All @@ -10,32 +12,38 @@ struct Array {
T *data;
Array();
~Array();
T& operator[](size_t i) const;
T& operator[] (size_t i);
const T& operator[] (size_t i) const;
void push_back(const T &t);
};

template< typename T>
Array<T>::Array() : size{0}, capacity{0}, data{nullptr} {}
inline Array<T>::Array() : size{0}, capacity{0}, data{nullptr} {}

template<typename T>
Array<T>::~Array()
inline Array<T>::~Array()
{
size = 0;
capacity = 0;
free(data);
}

template<typename T>
T&
Array<T>::operator[](size_t i) const
inline T& Array<T>::operator[](size_t i)
{
assert(i < size);
return (data[i]);
}

template<typename T>
inline const T& Array<T>::operator[](size_t i) const
{
assert(i < size);
return (data[i]);
}

template<typename T>
void
Array<T>::push_back(const T &t)
inline void Array<T>::push_back(const T &t)
{
if (size >= capacity) {
capacity = capacity < ARRAY_FIRST_CAPACITY ?
Expand Down
Loading

0 comments on commit 7f80dac

Please sign in to comment.