pctm + foundation for obj models
This commit is contained in:
+26
-7
@@ -1,6 +1,8 @@
|
||||
#ifndef DELTA_MATH
|
||||
#define DELTA_MATH
|
||||
|
||||
#include <vector>
|
||||
|
||||
class DeltaVector2 {
|
||||
public:
|
||||
float x, y;
|
||||
@@ -35,9 +37,6 @@ class DeltaVector3 {
|
||||
float length() const;
|
||||
};
|
||||
|
||||
float getDeterminant(const DeltaVector2 &pointA, const DeltaVector2 &pointB, const DeltaVector2 &candidate);
|
||||
DeltaVector2 barycentricToScreen(const DeltaVector3 &baryPoint, const DeltaVector2 &a, const DeltaVector2 &b, const DeltaVector2 &c);
|
||||
DeltaVector3 intersect(DeltaVector3 a, DeltaVector3 b, float nearZ);
|
||||
|
||||
struct DeltaTriangle {
|
||||
DeltaVector3 a, b, c;
|
||||
@@ -47,14 +46,34 @@ struct DeltaTriangle2D {
|
||||
DeltaVector2 a, b, c;
|
||||
};
|
||||
|
||||
|
||||
struct DeltaRenderTriangle {
|
||||
DeltaVector3 a, b, c;
|
||||
DeltaVector2 uva, uvb, uvc;
|
||||
struct DeltaVertex {
|
||||
DeltaVector3 pos;
|
||||
DeltaVector2 uv;
|
||||
};
|
||||
|
||||
struct DeltaModelConnector {
|
||||
int ind1, ind2;
|
||||
};
|
||||
|
||||
struct DeltaRenderTriangle {
|
||||
DeltaVertex a, b, c;
|
||||
bool invert;
|
||||
};
|
||||
|
||||
struct DeltaModel {
|
||||
std::vector<DeltaVertex> vertexes;
|
||||
std::vector<DeltaModelConnector> lines;
|
||||
std::vector<DeltaRenderTriangle> triangles;
|
||||
};
|
||||
|
||||
|
||||
float getDeterminant(const DeltaVector2 &pointA, const DeltaVector2 &pointB, const DeltaVector2 &candidate);
|
||||
DeltaVector2 barycentricToScreen(const DeltaVector3 &baryPoint, const DeltaVector2 &a, const DeltaVector2 &b, const DeltaVector2 &c);
|
||||
DeltaVertex intersect(DeltaVertex a, DeltaVertex b, float nearZ);
|
||||
int clipTriangleAgainstNearPlane(float nearY, const DeltaRenderTriangle &in, DeltaRenderTriangle &out1, DeltaRenderTriangle &out2);
|
||||
|
||||
std::vector<DeltaTriangle2D> triangulatePolygon(std::vector<DeltaVertex>& points);
|
||||
|
||||
uint32_t SDLColorToUint32(SDL_Color color);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user