diff options
author | jonas <himself@jonasgunz.de> | 2019-01-12 21:36:30 +0100 |
---|---|---|
committer | jonas <himself@jonasgunz.de> | 2019-01-12 21:36:30 +0100 |
commit | 5d0b6dd79722707afb15642cc8523b36a6391e0d (patch) | |
tree | e7045bb0d5c2b25bbb4a2903ebb044c30b1b55d7 /cWiremesh.cpp | |
parent | 91e4ffec239c198c9c4652dc50812165813fe79f (diff) | |
download | termgl-5d0b6dd79722707afb15642cc8523b36a6391e0d.tar.gz |
changed to cWiremesh, removed inherit, cWiremesh now directly writes to renderer
Things get funky when x > origin.x ?!?
Diffstat (limited to 'cWiremesh.cpp')
-rw-r--r-- | cWiremesh.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/cWiremesh.cpp b/cWiremesh.cpp new file mode 100644 index 0000000..f21b1d0 --- /dev/null +++ b/cWiremesh.cpp @@ -0,0 +1,68 @@ +#include "cWiremesh.h" + +cWiremesh::cWiremesh() +{ + position = {0,0,0}; +} + +cWiremesh::~cWiremesh() +{ + +} + +void cWiremesh::addVector(sCoord3d _origin, sCoord3d _vector, char _char, WORD _color) +{ + vectors.push_back(sVector{_origin, _vector, _char, _color}); +} + +void cWiremesh::rotate(sCoord3d _val) +{ + +} + +void cWiremesh::reset() +{ + vectors.clear(); +} + +void cWiremesh::write(cRender *_render) +{ + if(!_render) + return; + + sPos porigin = _render->getSize(); + sCoord3d origin = {porigin.x / 2, porigin.y / 2, 0}; + + for(long unsigned int i = 0; i < vectors.size(); i++) + { + _render->drawLine(vectors[i].c, + translate(vectors[i].origin + position, origin), + translate(vectors[i].origin + vectors[i].direction + position, origin), + true, vectors[i].color); + } +} + +sPos cWiremesh::translate(sCoord3d _coord, sCoord3d _origin) +{ + sPos ret; + + ret.x = (int)((float)_coord.x - ((float)_coord.z / (float)_DEPTH * (float)(_coord.x - _origin.x))); + ret.y = (int)((float)_coord.y - ((float)_coord.z / (float)_DEPTH * (float)(_coord.y - _origin.y))); + + return ret; +} + +sCoord3d cWiremesh::getPosition() +{ + return position; +} + +void cWiremesh::setPosition(int _x, int _y, int _z) +{ + position = {_x, _y, _z}; +} + +void cWiremesh::setPosition(sCoord3d _pos) +{ + position = _pos; +} |