diff options
author | jonas <himself@jonasgunz.de> | 2019-01-15 10:49:31 +0100 |
---|---|---|
committer | jonas <himself@jonasgunz.de> | 2019-01-15 10:49:31 +0100 |
commit | eb396e54d6c073ad69b52660fb0bd9c6dd74c58a (patch) | |
tree | cd27b4e147f26ae1ee1c1321bbdcefde3df3a3a3 | |
parent | 60ea1ae7257d60d3ee05f1b9d412a1bd441db7cb (diff) | |
download | termgl-eb396e54d6c073ad69b52660fb0bd9c6dd74c58a.tar.gz |
cleanup
-rw-r--r-- | cWiremesh.cpp | 28 | ||||
-rw-r--r-- | cWiremesh.h | 2 |
2 files changed, 14 insertions, 16 deletions
diff --git a/cWiremesh.cpp b/cWiremesh.cpp index f15c0d8..f54fa5e 100644 --- a/cWiremesh.cpp +++ b/cWiremesh.cpp @@ -40,25 +40,14 @@ void cWiremesh::write(cRender *_render) translate(vectors[i].origin + vectors[i].direction + position, origin), true, vectors[i].color); - /*_render->drawPoint(vectors[i].c, translate(vectors[i].origin + position, origin), true, vectors[i].color); - _render->drawPoint(vectors[i].c, translate(vectors[i].origin + vectors[i].direction + position, origin), true, vectors[i].color);*/ - } } sPos cWiremesh::translate(sCoord3d _coord, sCoord3d _origin) { sPos ret; - sCoord3d coord; - coord.x = _coord.x - _origin.x; - coord.y = _coord.y - _origin.y; - coord.z = _coord.z - _origin.z; - - 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))); - - ret.x += _origin.x; - ret.y += _origin.y; + 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; } @@ -78,7 +67,16 @@ void cWiremesh::setPosition(sCoord3d _pos) position = _pos; } -void cWiremesh::scale(int _scalar) +void cWiremesh::scale(float _scalar) { - //Implement Scale + for(unsigned long int i = 0; i < vectors.size(); i++) + { + vectors[i].origin.x = (int)((float)vectors[i].origin.x * _scalar); + vectors[i].origin.y = (int)((float)vectors[i].origin.y * _scalar); + vectors[i].origin.z = (int)((float)vectors[i].origin.z * _scalar); + + vectors[i].direction.x = (int)((float)vectors[i].direction.x * _scalar); + vectors[i].direction.y = (int)((float)vectors[i].direction.y * _scalar); + vectors[i].direction.z = (int)((float)vectors[i].direction.z * _scalar); + } } diff --git a/cWiremesh.h b/cWiremesh.h index 17231a2..37df740 100644 --- a/cWiremesh.h +++ b/cWiremesh.h @@ -53,7 +53,7 @@ public: void rotate(sCoord3d _val); - void scale(int _scalar); + void scale(float _scalar); sCoord3d getPosition(); |