inching slowly towards a renderer

This commit is contained in:
Hartmut Seichter 2019-01-11 23:21:09 +01:00
parent 4b695ecaf6
commit c7c7d5af77
28 changed files with 613 additions and 59 deletions

View file

@ -2,6 +2,7 @@
set(hdrs
include/pw/core/debug.hpp
include/pw/core/axisangle.hpp
# include/pw/core/buffer.hpp
include/pw/core/core.hpp
include/pw/core/math.hpp
include/pw/core/matrixbase.hpp
@ -13,12 +14,15 @@ set(hdrs
include/pw/core/point.hpp
include/pw/core/size.hpp
include/pw/core/timer.hpp
include/pw/core/mesh.hpp
include/pw/core/globals.hpp
)
set(srcs
src/buffer.cpp
src/image.cpp
src/debug.cpp
src/mesh.cpp
src/core.cpp
src/serialize.cpp
src/timer.cpp

View file

@ -1,4 +1,11 @@
#ifndef BUFFER_HPP
#define BUFFER_HPP
#ifndef PW_CORE_BUFFER_HPP
#define PW_CORE_BUFFER_HPP
#endif // BUFFER_HPP
#include <pw/core/globals.hpp>
#include <vector>
#endif // PW_CORE_BUFFER_HPP

View file

@ -6,18 +6,21 @@
namespace pw {
const static double __PW_PI = 3.1415926535897932384626433832795028841971693993751058209;
const static double __RAD2DEG = 180.0 / __PW_PI;
const static double __DEG2RAD = __PW_PI / 180.0;
template <typename T>
inline const T pi() { return static_cast<T>(__PW_PI); }
template <typename T>
inline static double rad_to_deg(const T& angle_in_radian) {
return static_cast<T>(angle_in_radian * T(180.) / pi<T>());
inline static T rad_to_deg(const T& angle_in_radian) {
return angle_in_radian * __RAD2DEG;
}
template <typename T>
inline static double deg_to_rad(const T& angle_in_degree) {
return static_cast<T>(angle_in_degree * pi<T>() / T(180.));
inline static T deg_to_rad(const T& angle_in_degree) {
return angle_in_degree * __DEG2RAD;
}
}

View file

@ -1,17 +1,17 @@
#ifndef PW_SCENE_MESH_HPP
#define PW_SCENE_MESH_HPP
#ifndef PW_CORE_MESH_HPP
#define PW_CORE_MESH_HPP
#include <pw/core/matrix.hpp>
#include <pw/scene/component.hpp>
#include <pw/core/globals.hpp>
#include <pw/core/vector.hpp>
namespace pw {
class mesh : public component {
class mesh {
public:
using component::component;
typedef std::vector<int32_t> index_t;
typedef std::vector<float> vertex_t;
typedef std::vector<int32_t> indexarray_t;
typedef std::vector<vector3> vertex3array_t;
typedef std::vector<vector2> vertex2array_t;
enum topology_type {
triangles,
@ -23,20 +23,24 @@ public:
points
};
void set_indices(const indexarray_t& v) { _indices = v; }
void set_vertices(const vertex3array_t& v) { _vertices = v; }
const indexarray_t& indices() const { return _indices; }
const vertex3array_t& vertices() const { return _vertices; }
void reset();
protected:
// index data
// vertex d ata
// normal data
// color data
// uv data
// tangents data
// boundary
indexarray_t _indices; //!< indices according to topology type
vertex3array_t _vertices; //!< geometry data
vertex3array_t _normals; //!< normal data
vertex3array_t _colors; //!< color data
std::vector<vertex2array_t> _uvs; //!< storing multiple UV sets
// TODO add weights, tangents etc. pp.
};
}

5
src/core/src/buffer.cpp Normal file
View file

@ -0,0 +1,5 @@
#include "pw/core/buffer.hpp"
namespace pw {
}

View file

@ -1,9 +1,8 @@
#include "pw/scene/mesh.hpp"
#include "pw/core/mesh.hpp"
namespace pw {
}