1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
#include <unistd.h>
#include <string>
#include "version.h"
#include "cRender.h"
#include "cObject.h"
#include "cObjectHandler.h"
#include "cInput.h"
#include "cWiremesh.h"
//#include "testobject.h"
int main(int argc, char* argv[])
{
cRender render(' ', _COL_DEFAULT, 30,30);
cObjectHandler handler(&render);
cObject ver(45,1);
cWiremesh obj;
cInput input;
unsigned int framecounter = 0;
bool loop = true;
if(argc > 1)
{
loop = false;
}
render.render();
ver.drawPoint('v', {0,0}, true, _COL_WHITE);
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, {32,0}, _COL_WHITE);
ver.drawText(BRANCH, {5,0}, _COL_WHITE);
int iver = handler.createObject(&ver);
handler.moveObject(iver, {0,0}, _MOVE_ABSOLUTE);
int x = 15;
int y = 15;
int z = 30;
obj.addVector({-x,-y,z}, {2*x,0,0}, '+', _COL_RED);
obj.addVector({-x,-y,z}, {0,2*y,0}, '+', _COL_RED);
obj.addVector({-x,y,z}, {2*x,0,0}, '+', _COL_RED);
obj.addVector({x,-y,z}, {0,2*y,0}, '+', _COL_RED);
obj.addVector({-x,-y,0}, {0,0,z}, ':', _COL_RED);
obj.addVector({x,-y,0}, {0,0,z}, ':', _COL_RED);
obj.addVector({-x,y,0}, {0,0,z}, ':', _COL_RED);
obj.addVector({x,y,0}, {0,0,z}, ':', _COL_RED);
obj.addVector({-x,-y,0}, {2*x,0,0}, ',', _COL_RED);
obj.addVector({-x,-y,0}, {0,2*y,0}, ',', _COL_RED);
obj.addVector({-x,y,0}, {2*x,0,0}, ',', _COL_RED);
obj.addVector({x,-x,0}, {0,2*y,0}, ',', _COL_RED);
int imesh = handler.createWiremesh(&obj);
sPos middle = render.getSize();
middle.x /= 2;
middle.y /= 2;
handler.moveWiremesh(imesh,{middle.x,middle.y,0}, _MOVE_ABSOLUTE);
while( loop )
{
sInputEvent ie = input.poll();
if(ie.type != _EVENT_NULL)
{
if(ie.type == _EVENT_KEY)
{
switch (ie.c)
{
case 'A'://up
handler.moveWiremesh(imesh,{0,-1,0}, _MOVE_RELATIVE);
break;
case 'B'://down
handler.moveWiremesh(imesh,{0,1,0}, _MOVE_RELATIVE);
break;
case 'C'://right
handler.moveWiremesh(imesh,{1,0,0}, _MOVE_RELATIVE);
break;
case 'D'://left
handler.moveWiremesh(imesh,{-1,0,0}, _MOVE_RELATIVE);
break;
};
}
else if (ie.type == _EVENT_MOUSE)
{
if(ie.b == 0)
handler.clickEvent({ie.x, ie.y}, 0);
}
else if (ie.type == _EVENT_CHAR)
{
//handler.charEvent(ie.c);
switch(ie.c)
{
case 'w':
handler.rotateWiremesh(imesh,{-10,0,0});
break;
case 's':
handler.rotateWiremesh(imesh,{10,0,0});
break;
case 'a':
handler.rotateWiremesh(imesh,{0,-10,0});
break;
case 'd':
handler.rotateWiremesh(imesh,{0,10,0});
break;
case 'q':
handler.rotateWiremesh(imesh,{0,0,-10});
break;
case 'e':
handler.rotateWiremesh(imesh,{0,0,10});
break;
};
}
else if (ie.type == _EVENT_TERM)
{
return 0;
}
}
handler.rotateWiremesh(imesh,{1,1,1});
handler.write();
render.render();
framecounter++;
if(loop)
usleep(10*1000);
}
return 0;
}
|