aboutsummaryrefslogtreecommitdiff
path: root/cObject3D.cpp
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-01-12 01:00:56 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-01-12 01:00:56 +0100
commit91e4ffec239c198c9c4652dc50812165813fe79f (patch)
tree0f85ceedb3c2edac68ab34b8b5baaf903ce28935 /cObject3D.cpp
parentbdce9a52170f1a3535c290a379e4cb9f509614ec (diff)
downloadtermgl-91e4ffec239c198c9c4652dc50812165813fe79f.tar.gz
cObject3D should displaya wiremesh of Object composed of vectors
Diffstat (limited to 'cObject3D.cpp')
-rw-r--r--cObject3D.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/cObject3D.cpp b/cObject3D.cpp
new file mode 100644
index 0000000..7ba7132
--- /dev/null
+++ b/cObject3D.cpp
@@ -0,0 +1,47 @@
+#include "cObject3D.h"
+
+cObject3D::cObject3D(unsigned int _sx, unsigned int _sy)
+{
+ setSize(_sx, _sy);
+}
+
+cObject3D::~cObject3D()
+{
+ destruct();
+}
+
+void cObject3D::addVector(sCoord3d _origin, sCoord3d _vector, char _char, WORD _color)
+{
+ vectors.push_back(sVector{_origin, _vector, _char, _color});
+}
+
+void cObject3D::rotate(sCoord3d _val)
+{
+
+}
+
+void cObject3D::reset()
+{
+ vectors.clear();
+}
+
+void cObject3D::write()
+{
+ for(long unsigned int i = 0; i < vectors.size(); i++)
+ {
+ drawLine(vectors[i].c,
+ translate(vectors[i].origin),
+ translate({vectors[i].origin.x + vectors[i].direction.x, vectors[i].origin.y + vectors[i].direction.y}),
+ true, vectors[i].color);
+ }
+}
+
+sPos cObject3D::translate(sCoord3d _coord)
+{
+ sPos ret;
+
+ ret.x = (int)((float)_coord.x - ((float)_coord.z / (float)_DEPTH * (float)_coord.x));
+ ret.y = (int)((float)_coord.y - ((float)_coord.z / (float)_DEPTH * (float)_coord.y));
+
+ return ret;
+}