summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--cRender.cpp6
-rw-r--r--cWiremesh.cpp22
-rw-r--r--cWiremesh.h13
-rw-r--r--main.cpp41
5 files changed, 60 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 3783295..258902c 100644
--- a/Makefile
+++ b/Makefile
@@ -36,5 +36,6 @@ genversion:
@echo "#pragma once" >> version.h
@echo "#define VERSION $(VERSION)" >> version.h
@echo "#define PATCHLEVEL $(PATCHLEVEL)" >> version.h
+ @echo "#define BRANCH \"`git status -bs | grep '##'`\"" >> version.h
@echo "#define DATE \"`date +'%d.%m.20%y'`\"" >> version.h
@echo "#define TIME \"`date +'%H:%M:%S'`\"" >> version.h
diff --git a/cRender.cpp b/cRender.cpp
index a01418e..41908e1 100644
--- a/cRender.cpp
+++ b/cRender.cpp
@@ -88,6 +88,12 @@ int cRender::drawPoint(char _c, sPos _pos, bool _overrideCollision, WORD _color)
int cRender::drawLine(char _c, sPos _pos1, sPos _pos2, bool _overrideCollision, WORD _color)
{
+ if(_pos1.x > _pos2.x)
+ {
+ //Shit WILL go wrong
+ return drawLine(_c, _pos2, _pos1, _overrideCollision, _color);
+ }
+
if (_pos1.x == _pos2.x) { //Horizontal line
for (int i = _pos1.y; i <= _pos2.y; i++)
{
diff --git a/cWiremesh.cpp b/cWiremesh.cpp
index f21b1d0..f15c0d8 100644
--- a/cWiremesh.cpp
+++ b/cWiremesh.cpp
@@ -17,7 +17,7 @@ void cWiremesh::addVector(sCoord3d _origin, sCoord3d _vector, char _char, WORD _
void cWiremesh::rotate(sCoord3d _val)
{
-
+ //Implement rotate
}
void cWiremesh::reset()
@@ -39,6 +39,9 @@ void cWiremesh::write(cRender *_render)
translate(vectors[i].origin + position, origin),
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);*/
}
}
@@ -46,8 +49,16 @@ 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)));
+ 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;
return ret;
}
@@ -66,3 +77,8 @@ void cWiremesh::setPosition(sCoord3d _pos)
{
position = _pos;
}
+
+void cWiremesh::scale(int _scalar)
+{
+ //Implement Scale
+}
diff --git a/cWiremesh.h b/cWiremesh.h
index 49bf4b9..17231a2 100644
--- a/cWiremesh.h
+++ b/cWiremesh.h
@@ -5,7 +5,7 @@
#include "cRender.h"
-#define _DEPTH 100
+#define _DEPTH 99
struct sCoord3d
{
@@ -21,6 +21,15 @@ struct sCoord3d
ret.z = z + p.z;
return ret;
}
+
+ sCoord3d operator-(sCoord3d p)
+ {
+ sCoord3d ret;
+ ret.x = x - p.x;
+ ret.y = y - p.y;
+ ret.z = z - p.z;
+ return ret;
+ }
};
struct sVector
@@ -44,6 +53,8 @@ public:
void rotate(sCoord3d _val);
+ void scale(int _scalar);
+
sCoord3d getPosition();
void setPosition(int _x, int _y, int _z);
diff --git a/main.cpp b/main.cpp
index e6bd74e..3e47996 100644
--- a/main.cpp
+++ b/main.cpp
@@ -9,13 +9,13 @@
#include "cInput.h"
#include "cWiremesh.h"
-#include "testobject.h"
+//#include "testobject.h"
int main()
{
cRender render(' ', _COL_DEFAULT, 30,30);
cObjectHandler handler(&render);
- cObject ver(30,1);
+ cObject ver(40,1);
cWiremesh obj;
cInput input;
@@ -30,29 +30,32 @@ int main()
ver.drawPoint(VERSION + 48, {1,0}, true, _COL_WHITE);
ver.drawPoint('.', {2,0}, true, _COL_WHITE);
ver.drawPoint(PATCHLEVEL + 48, {3,0}, true, _COL_WHITE);
- ver.drawText(DATE, {5,0}, _COL_WHITE);
+ ver.drawText(DATE, {30,0}, _COL_WHITE);
+ ver.drawText(BRANCH, {5,0}, _COL_WHITE);
int iver = handler.createObject(&ver);
handler.moveObject(iver, {0,0}, _MOVE_ABSOLUTE);
- int x = 25;
+ int x = 30;
+ int y = 20;
+ int z = 20;
- obj.addVector({0,0,x}, {x,0,0}, '+', _COL_RED);
- obj.addVector({x,0,x}, {0,x,0}, '+', _COL_RED);
- obj.addVector({0,0,x}, {0,x,0}, '+', _COL_RED);
- obj.addVector({0,x,x}, {x,0,0}, '+', _COL_RED);
+ obj.addVector({0,0,z}, {x,0,0}, '+', _COL_RED);
+ obj.addVector({0,0,z}, {0,y,0}, '+', _COL_RED);
+ obj.addVector({0,y,z}, {x,0,0}, '+', _COL_RED);
+ obj.addVector({x,0,z}, {0,y,0}, '+', _COL_RED);
- obj.addVector({0,0,0}, {0,0,x}, '.', _COL_RED);
- obj.addVector({x,0,0}, {0,0,x}, '.', _COL_RED);
- obj.addVector({0,x,0}, {0,0,x}, '.', _COL_RED);
- obj.addVector({x,x,0}, {0,0,x}, '.', _COL_RED);
+ obj.addVector({0,0,0}, {0,0,z}, ':', _COL_RED);
+ obj.addVector({x,0,0}, {0,0,z}, ':', _COL_RED);
+ obj.addVector({0,y,0}, {0,0,z}, ':', _COL_RED);
+ obj.addVector({x,y,0}, {0,0,z}, ':', _COL_RED);
- obj.addVector({0,0,0}, {x,0,0}, '|', _COL_RED);
- obj.addVector({x,0,0}, {0,x,0}, '|', _COL_RED);
- obj.addVector({0,0,0}, {0,x,0}, '|', _COL_RED);
- obj.addVector({0,x,0}, {x,0,0}, '|', _COL_RED);
+ obj.addVector({0,0,0}, {x,0,0}, ',', _COL_RED);
+ obj.addVector({0,0,0}, {0,y,0}, ',', _COL_RED);
+ obj.addVector({0,y,0}, {x,0,0}, ',', _COL_RED);
+ obj.addVector({x,0,0}, {0,y,0}, ',', _COL_RED);
handler.write();
- obj.setPosition(0,0,0);
+ obj.setPosition(2,2,0);
obj.write(&render);
@@ -102,10 +105,10 @@ int main()
handler.write();
obj.write(&render);
- render.render();
- usleep(10*1000);
}
+ render.render();
+ usleep(10*1000);
}